示例#1
0
		function domain_snapshot_create($domain) {
			$this->domain_set_metadata($domain);
			$domain = $this->get_domain_object($domain);
			$tmp = libvirt_domain_snapshot_create($domain);
			return ($tmp) ? $tmp : $this->_set_last_error();
		}
示例#2
0
/**
 * create snapshot of a virtual machine on the virt host
 *
 * @global  resource $host_conn  libvirt connection
 *
 * @param   string   $vm_virt_id virt_id of the vm
 *
 * @return bool                 on success
 */
function ace_kvm_vm_create_snapshot($vm_virt_id)
{
    global $host_conn;
    $vm_res = libvirt_domain_lookup_by_name($host_conn, $vm_virt_id);
    ace_kvm_log_last_error();
    $vm_is_active = ace_kvm_get_vm_state($vm_virt_id) == 1 ? TRUE : FALSE;
    if ($vm_is_active) {
        $vm_snap_res = libvirt_domain_snapshot_create($vm_res);
        ace_kvm_log_last_error();
        $return = $vm_snap_res ? TRUE : FALSE;
    } else {
        #start
        ace_kvm_vm_start($vm_virt_id);
        #suspend
        ace_kvm_vm_suspend($vm_virt_id);
        #take snapshot
        $vm_snap_res = libvirt_domain_snapshot_create($vm_res);
        ace_kvm_log_last_error();
        $return = is_resource($vm_snap_res) ? TRUE : FALSE;
        #stop
        ace_kvm_vm_stop($vm_virt_id);
    }
    return $return;
}