mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
Fix save/restore migrate syntax for new KVM releases
This commit is contained in:
parent
e96d88ff3d
commit
4f4bfbc79e
22
ChangeLog
22
ChangeLog
@ -1,3 +1,25 @@
|
|||||||
|
Thu Jan 29 17:24:22 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
|
Fix save/restore for new KVM releases
|
||||||
|
* src/domain_conf.h, src/lxc_driver.c, src/uml_driver.c:
|
||||||
|
Remove unused stdin_fd field from virDomainObjPtr
|
||||||
|
* src/qemu_conf.c, src/qemu_driver.c: Support new
|
||||||
|
migration options for save & restore, and fix deadlock
|
||||||
|
in save code.
|
||||||
|
* src/qemu_conf.h: Add more QEMU argv flags to various
|
||||||
|
migration options & describe existing flags
|
||||||
|
* src/util.c: Close original stdin file handle after
|
||||||
|
duping it onto STDIN_FILENO
|
||||||
|
* tests/qemuxml2argvtest.c: Test for various migrate
|
||||||
|
syntax options
|
||||||
|
* tests/qemuxml2argvdata/qemuxml2argv-migrate.args,
|
||||||
|
tests/qemuxml2argvdata/qemuxml2argv-migrate.xml,
|
||||||
|
tests/qemuxml2argvdata/qemuxml2argv-restore-v1.args,
|
||||||
|
tests/qemuxml2argvdata/qemuxml2argv-restore-v1.xml,
|
||||||
|
tests/qemuxml2argvdata/qemuxml2argv-restore-v2.args,
|
||||||
|
tests/qemuxml2argvdata/qemuxml2argv-restore-v2.xml: Data
|
||||||
|
files for testing migrate syntax options
|
||||||
|
|
||||||
Thu Jan 29 17:15:18 GMT 2009 John Levon <john.levon@sun.com>
|
Thu Jan 29 17:15:18 GMT 2009 John Levon <john.levon@sun.com>
|
||||||
|
|
||||||
* src/libvirt.c: fix another printf("%s", NULL) case
|
* src/libvirt.c: fix another printf("%s", NULL) case
|
||||||
|
@ -462,7 +462,6 @@ typedef virDomainObj *virDomainObjPtr;
|
|||||||
struct _virDomainObj {
|
struct _virDomainObj {
|
||||||
virMutex lock;
|
virMutex lock;
|
||||||
|
|
||||||
int stdin_fd;
|
|
||||||
int monitor;
|
int monitor;
|
||||||
int monitor_watch;
|
int monitor_watch;
|
||||||
char *monitorpath;
|
char *monitorpath;
|
||||||
|
@ -775,11 +775,10 @@ static int lxcControllerStart(virConnectPtr conn,
|
|||||||
|
|
||||||
ADD_ARG(NULL);
|
ADD_ARG(NULL);
|
||||||
|
|
||||||
vm->stdin_fd = -1;
|
|
||||||
FD_SET(appPty, &keepfd);
|
FD_SET(appPty, &keepfd);
|
||||||
|
|
||||||
if (virExec(conn, largv, NULL, &keepfd, &child,
|
if (virExec(conn, largv, NULL, &keepfd, &child,
|
||||||
vm->stdin_fd, &logfd, &logfd,
|
-1, &logfd, &logfd,
|
||||||
VIR_EXEC_NONE) < 0)
|
VIR_EXEC_NONE) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -396,6 +396,27 @@ int qemudExtractVersionInfo(const char *qemu,
|
|||||||
if (kvm_version >= 74)
|
if (kvm_version >= 74)
|
||||||
flags |= QEMUD_CMD_FLAG_VNET_HDR;
|
flags |= QEMUD_CMD_FLAG_VNET_HDR;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handling of -incoming arg with varying features
|
||||||
|
* -incoming tcp (kvm >= 79)
|
||||||
|
* -incoming exec (kvm >= 80)
|
||||||
|
* -incoming stdio (all earlier kvm)
|
||||||
|
*
|
||||||
|
* NB, there was a pre-kvm-79 'tcp' support, but it
|
||||||
|
* was broken, because it blocked the monitor console
|
||||||
|
* while waiting for data, so pretend it doesn't exist
|
||||||
|
*
|
||||||
|
* XXX when next QEMU release after 0.9.1 arrives,
|
||||||
|
* we'll need to add MIGRATE_QEMU_TCP/EXEC here too
|
||||||
|
*/
|
||||||
|
if (kvm_version >= 79) {
|
||||||
|
flags |= QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP;
|
||||||
|
if (kvm_version >= 80)
|
||||||
|
flags |= QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC;
|
||||||
|
} else if (kvm_version > 0) {
|
||||||
|
flags |= QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO;
|
||||||
|
}
|
||||||
|
|
||||||
if (retversion)
|
if (retversion)
|
||||||
*retversion = version;
|
*retversion = version;
|
||||||
if (retflags)
|
if (retflags)
|
||||||
@ -677,6 +698,33 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
|||||||
|
|
||||||
virUUIDFormat(vm->def->uuid, uuid);
|
virUUIDFormat(vm->def->uuid, uuid);
|
||||||
|
|
||||||
|
/* Migration is very annoying due to wildly varying syntax & capabilities
|
||||||
|
* over time of KVM / QEMU codebases
|
||||||
|
*/
|
||||||
|
if (migrateFrom) {
|
||||||
|
if (STRPREFIX(migrateFrom, "tcp")) {
|
||||||
|
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP)) {
|
||||||
|
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT,
|
||||||
|
"%s", _("TCP migration is not supported with this QEMU binary"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (STREQ(migrateFrom, "stdio")) {
|
||||||
|
if (qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC) {
|
||||||
|
migrateFrom = "exec:cat";
|
||||||
|
} else if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO)) {
|
||||||
|
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT,
|
||||||
|
"%s", _("STDIO migration is not supported with this QEMU binary"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (STRPREFIX(migrateFrom, "exec")) {
|
||||||
|
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC)) {
|
||||||
|
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT,
|
||||||
|
"%s", _("STDIO migration is not supported with this QEMU binary"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Need to explicitly disable KQEMU if
|
/* Need to explicitly disable KQEMU if
|
||||||
* 1. Arch matches host arch
|
* 1. Arch matches host arch
|
||||||
* 2. Guest is 'qemu'
|
* 2. Guest is 'qemu'
|
||||||
|
@ -40,15 +40,19 @@
|
|||||||
|
|
||||||
/* Internal flags to keep track of qemu command line capabilities */
|
/* Internal flags to keep track of qemu command line capabilities */
|
||||||
enum qemud_cmd_flags {
|
enum qemud_cmd_flags {
|
||||||
QEMUD_CMD_FLAG_KQEMU = (1 << 0),
|
QEMUD_CMD_FLAG_KQEMU = (1 << 0), /* Whether KQEMU is compiled in */
|
||||||
QEMUD_CMD_FLAG_VNC_COLON = (1 << 1),
|
QEMUD_CMD_FLAG_VNC_COLON = (1 << 1), /* Does the VNC take just port, or address + display */
|
||||||
QEMUD_CMD_FLAG_NO_REBOOT = (1 << 2),
|
QEMUD_CMD_FLAG_NO_REBOOT = (1 << 2), /* Is the -no-reboot flag available */
|
||||||
QEMUD_CMD_FLAG_DRIVE = (1 << 3),
|
QEMUD_CMD_FLAG_DRIVE = (1 << 3), /* Is the new -drive arg available */
|
||||||
QEMUD_CMD_FLAG_DRIVE_BOOT = (1 << 4),
|
QEMUD_CMD_FLAG_DRIVE_BOOT = (1 << 4), /* Does -drive support boot=on */
|
||||||
QEMUD_CMD_FLAG_NAME = (1 << 5),
|
QEMUD_CMD_FLAG_NAME = (1 << 5), /* Is the -name flag available */
|
||||||
QEMUD_CMD_FLAG_UUID = (1 << 6),
|
QEMUD_CMD_FLAG_UUID = (1 << 6), /* Is the -uuid flag available */
|
||||||
QEMUD_CMD_FLAG_DOMID = (1 << 7), /* Xenner only */
|
QEMUD_CMD_FLAG_DOMID = (1 << 7), /* Xenner only, special -domid flag available */
|
||||||
QEMUD_CMD_FLAG_VNET_HDR = (1 << 8),
|
QEMUD_CMD_FLAG_VNET_HDR = (1 << 8),
|
||||||
|
QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO = (1 << 9), /* Original migration code from KVM. Also had tcp, but we can't use that
|
||||||
|
* since it had a design bug blocking the entire monitor console */
|
||||||
|
QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP = (1 << 10), /* New migration syntax after merge to QEMU with TCP transport */
|
||||||
|
QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC = (1 << 11), /* New migration syntax after merge to QEMU with EXEC transport */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Main driver state */
|
/* Main driver state */
|
||||||
|
@ -130,7 +130,8 @@ static void qemudDispatchVMEvent(int watch,
|
|||||||
static int qemudStartVMDaemon(virConnectPtr conn,
|
static int qemudStartVMDaemon(virConnectPtr conn,
|
||||||
struct qemud_driver *driver,
|
struct qemud_driver *driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
const char *migrateFrom);
|
const char *migrateFrom,
|
||||||
|
int stdin_fd);
|
||||||
|
|
||||||
static void qemudShutdownVMDaemon(virConnectPtr conn,
|
static void qemudShutdownVMDaemon(virConnectPtr conn,
|
||||||
struct qemud_driver *driver,
|
struct qemud_driver *driver,
|
||||||
@ -237,7 +238,7 @@ qemudAutostartConfigs(struct qemud_driver *driver) {
|
|||||||
virDomainObjLock(vm);
|
virDomainObjLock(vm);
|
||||||
if (vm->autostart &&
|
if (vm->autostart &&
|
||||||
!virDomainIsActive(vm)) {
|
!virDomainIsActive(vm)) {
|
||||||
int ret = qemudStartVMDaemon(conn, driver, vm, NULL);
|
int ret = qemudStartVMDaemon(conn, driver, vm, NULL, -1);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
virErrorPtr err = virGetLastError();
|
virErrorPtr err = virGetLastError();
|
||||||
qemudLog(QEMUD_ERR, _("Failed to autostart VM '%s': %s\n"),
|
qemudLog(QEMUD_ERR, _("Failed to autostart VM '%s': %s\n"),
|
||||||
@ -1050,7 +1051,8 @@ static virDomainPtr qemudDomainLookupByName(virConnectPtr conn,
|
|||||||
static int qemudStartVMDaemon(virConnectPtr conn,
|
static int qemudStartVMDaemon(virConnectPtr conn,
|
||||||
struct qemud_driver *driver,
|
struct qemud_driver *driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
const char *migrateFrom) {
|
const char *migrateFrom,
|
||||||
|
int stdin_fd) {
|
||||||
const char **argv = NULL, **tmp;
|
const char **argv = NULL, **tmp;
|
||||||
const char **progenv = NULL;
|
const char **progenv = NULL;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
@ -1161,7 +1163,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
|
|||||||
FD_SET(tapfds[i], &keepfd);
|
FD_SET(tapfds[i], &keepfd);
|
||||||
|
|
||||||
ret = virExec(conn, argv, progenv, &keepfd, &child,
|
ret = virExec(conn, argv, progenv, &keepfd, &child,
|
||||||
vm->stdin_fd, &vm->logfile, &vm->logfile,
|
stdin_fd, &vm->logfile, &vm->logfile,
|
||||||
VIR_EXEC_NONBLOCK | VIR_EXEC_DAEMON);
|
VIR_EXEC_NONBLOCK | VIR_EXEC_DAEMON);
|
||||||
|
|
||||||
/* wait for qemu process to to show up */
|
/* wait for qemu process to to show up */
|
||||||
@ -1811,7 +1813,7 @@ static virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml,
|
|||||||
|
|
||||||
def = NULL;
|
def = NULL;
|
||||||
|
|
||||||
if (qemudStartVMDaemon(conn, driver, vm, NULL) < 0) {
|
if (qemudStartVMDaemon(conn, driver, vm, NULL, -1) < 0) {
|
||||||
virDomainRemoveInactive(&driver->domains,
|
virDomainRemoveInactive(&driver->domains,
|
||||||
vm);
|
vm);
|
||||||
vm = NULL;
|
vm = NULL;
|
||||||
@ -2287,11 +2289,14 @@ static int qemudDomainSave(virDomainPtr dom,
|
|||||||
/* Pause */
|
/* Pause */
|
||||||
if (vm->state == VIR_DOMAIN_RUNNING) {
|
if (vm->state == VIR_DOMAIN_RUNNING) {
|
||||||
header.was_running = 1;
|
header.was_running = 1;
|
||||||
if (qemudDomainSuspend(dom) != 0) {
|
if (qemudMonitorCommand(vm, "stop", &info) < 0) {
|
||||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("failed to pause domain"));
|
"%s", _("suspend operation failed"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
vm->state = VIR_DOMAIN_PAUSED;
|
||||||
|
qemudDebug("Reply %s", info);
|
||||||
|
VIR_FREE(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get XML for the domain */
|
/* Get XML for the domain */
|
||||||
@ -2678,10 +2683,14 @@ static int qemudDomainRestore(virConnectPtr conn,
|
|||||||
vm = virDomainFindByUUID(&driver->domains, def->uuid);
|
vm = virDomainFindByUUID(&driver->domains, def->uuid);
|
||||||
if (!vm)
|
if (!vm)
|
||||||
vm = virDomainFindByName(&driver->domains, def->name);
|
vm = virDomainFindByName(&driver->domains, def->name);
|
||||||
if (vm && virDomainIsActive(vm)) {
|
if (vm) {
|
||||||
qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
if (virDomainIsActive(vm)) {
|
||||||
_("domain is already active as '%s'"), vm->def->name);
|
qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
goto cleanup;
|
_("domain is already active as '%s'"), vm->def->name);
|
||||||
|
goto cleanup;
|
||||||
|
} else {
|
||||||
|
virDomainObjUnlock(vm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vm = virDomainAssignDef(conn,
|
if (!(vm = virDomainAssignDef(conn,
|
||||||
@ -2694,11 +2703,9 @@ static int qemudDomainRestore(virConnectPtr conn,
|
|||||||
def = NULL;
|
def = NULL;
|
||||||
|
|
||||||
/* Set the migration source and start it up. */
|
/* Set the migration source and start it up. */
|
||||||
vm->stdin_fd = fd;
|
ret = qemudStartVMDaemon(conn, driver, vm, "stdio", fd);
|
||||||
ret = qemudStartVMDaemon(conn, driver, vm, "stdio");
|
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
vm->stdin_fd = -1;
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("failed to start VM"));
|
"%s", _("failed to start VM"));
|
||||||
@ -2827,7 +2834,7 @@ static int qemudDomainStart(virDomainPtr dom) {
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = qemudStartVMDaemon(dom->conn, driver, vm, NULL);
|
ret = qemudStartVMDaemon(dom->conn, driver, vm, NULL, -1);
|
||||||
if (ret != -1)
|
if (ret != -1)
|
||||||
event = virDomainEventNewFromObj(vm,
|
event = virDomainEventNewFromObj(vm,
|
||||||
VIR_DOMAIN_EVENT_STARTED,
|
VIR_DOMAIN_EVENT_STARTED,
|
||||||
@ -4141,7 +4148,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
|
|||||||
* -incoming tcp:0.0.0.0:port
|
* -incoming tcp:0.0.0.0:port
|
||||||
*/
|
*/
|
||||||
snprintf (migrateFrom, sizeof (migrateFrom), "tcp:0.0.0.0:%d", this_port);
|
snprintf (migrateFrom, sizeof (migrateFrom), "tcp:0.0.0.0:%d", this_port);
|
||||||
if (qemudStartVMDaemon (dconn, driver, vm, migrateFrom) < 0) {
|
if (qemudStartVMDaemon (dconn, driver, vm, migrateFrom, -1) < 0) {
|
||||||
qemudReportError (dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError (dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("failed to start listening VM"));
|
"%s", _("failed to start listening VM"));
|
||||||
if (!vm->persistent) {
|
if (!vm->persistent) {
|
||||||
|
@ -811,13 +811,12 @@ static int umlStartVMDaemon(virConnectPtr conn,
|
|||||||
errno, strerror(errno));
|
errno, strerror(errno));
|
||||||
|
|
||||||
vm->monitor = -1;
|
vm->monitor = -1;
|
||||||
vm->stdin_fd = -1;
|
|
||||||
|
|
||||||
for (i = 0 ; i < ntapfds ; i++)
|
for (i = 0 ; i < ntapfds ; i++)
|
||||||
FD_SET(tapfds[i], &keepfd);
|
FD_SET(tapfds[i], &keepfd);
|
||||||
|
|
||||||
ret = virExec(conn, argv, progenv, &keepfd, &pid,
|
ret = virExec(conn, argv, progenv, &keepfd, &pid,
|
||||||
vm->stdin_fd, &logfd, &logfd,
|
-1, &logfd, &logfd,
|
||||||
VIR_EXEC_DAEMON);
|
VIR_EXEC_DAEMON);
|
||||||
close(logfd);
|
close(logfd);
|
||||||
|
|
||||||
|
@ -407,6 +407,8 @@ __virExec(virConnectPtr conn,
|
|||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (infd > 0)
|
||||||
|
close(infd);
|
||||||
close(null);
|
close(null);
|
||||||
if (childout > 0)
|
if (childout > 0)
|
||||||
close(childout);
|
close(childout);
|
||||||
|
1
tests/qemuxml2argvdata/qemuxml2argv-migrate.args
Normal file
1
tests/qemuxml2argvdata/qemuxml2argv-migrate.args
Normal file
@ -0,0 +1 @@
|
|||||||
|
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu-kvm -S -M pc -m 214 -smp 1 -nographic -monitor pty -pidfile /nowhere/QEMUGuest1.pid -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -incoming tcp:10.0.0.1:5000
|
22
tests/qemuxml2argvdata/qemuxml2argv-migrate.xml
Normal file
22
tests/qemuxml2argvdata/qemuxml2argv-migrate.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory>219200</memory>
|
||||||
|
<currentMemory>219200</currentMemory>
|
||||||
|
<vcpu>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
</disk>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
1
tests/qemuxml2argvdata/qemuxml2argv-restore-v1.args
Normal file
1
tests/qemuxml2argvdata/qemuxml2argv-restore-v1.args
Normal file
@ -0,0 +1 @@
|
|||||||
|
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu-kvm -S -M pc -m 214 -smp 1 -nographic -monitor pty -pidfile /nowhere/QEMUGuest1.pid -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -incoming stdio
|
22
tests/qemuxml2argvdata/qemuxml2argv-restore-v1.xml
Normal file
22
tests/qemuxml2argvdata/qemuxml2argv-restore-v1.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<domain type='kvm'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory>219200</memory>
|
||||||
|
<currentMemory>219200</currentMemory>
|
||||||
|
<vcpu>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
</disk>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
1
tests/qemuxml2argvdata/qemuxml2argv-restore-v2.args
Normal file
1
tests/qemuxml2argvdata/qemuxml2argv-restore-v2.args
Normal file
@ -0,0 +1 @@
|
|||||||
|
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu-kvm -S -M pc -m 214 -smp 1 -nographic -monitor pty -pidfile /nowhere/QEMUGuest1.pid -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -incoming exec:cat
|
22
tests/qemuxml2argvdata/qemuxml2argv-restore-v2.xml
Normal file
22
tests/qemuxml2argvdata/qemuxml2argv-restore-v2.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<domain type='kvm'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory>219200</memory>
|
||||||
|
<currentMemory>219200</currentMemory>
|
||||||
|
<vcpu>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
</disk>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -24,7 +24,8 @@ static struct qemud_driver driver;
|
|||||||
|
|
||||||
static int testCompareXMLToArgvFiles(const char *xml,
|
static int testCompareXMLToArgvFiles(const char *xml,
|
||||||
const char *cmd,
|
const char *cmd,
|
||||||
int extraFlags) {
|
int extraFlags,
|
||||||
|
const char *migrateFrom) {
|
||||||
char argvData[MAX_FILE];
|
char argvData[MAX_FILE];
|
||||||
char *expectargv = &(argvData[0]);
|
char *expectargv = &(argvData[0]);
|
||||||
char *actualargv = NULL;
|
char *actualargv = NULL;
|
||||||
@ -56,7 +57,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
|||||||
|
|
||||||
if (qemudBuildCommandLine(NULL, &driver,
|
if (qemudBuildCommandLine(NULL, &driver,
|
||||||
&vm, flags, &argv, &qenv,
|
&vm, flags, &argv, &qenv,
|
||||||
NULL, NULL, NULL) < 0)
|
NULL, NULL, migrateFrom) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
len = 1; /* for trailing newline */
|
len = 1; /* for trailing newline */
|
||||||
@ -122,6 +123,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
|||||||
struct testInfo {
|
struct testInfo {
|
||||||
const char *name;
|
const char *name;
|
||||||
int extraFlags;
|
int extraFlags;
|
||||||
|
const char *migrateFrom;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int testCompareXMLToArgvHelper(const void *data) {
|
static int testCompareXMLToArgvHelper(const void *data) {
|
||||||
@ -132,7 +134,7 @@ static int testCompareXMLToArgvHelper(const void *data) {
|
|||||||
abs_srcdir, info->name);
|
abs_srcdir, info->name);
|
||||||
snprintf(args, PATH_MAX, "%s/qemuxml2argvdata/qemuxml2argv-%s.args",
|
snprintf(args, PATH_MAX, "%s/qemuxml2argvdata/qemuxml2argv-%s.args",
|
||||||
abs_srcdir, info->name);
|
abs_srcdir, info->name);
|
||||||
return testCompareXMLToArgvFiles(xml, args, info->extraFlags);
|
return testCompareXMLToArgvFiles(xml, args, info->extraFlags, info->migrateFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -159,14 +161,17 @@ mymain(int argc, char **argv)
|
|||||||
if((driver.stateDir = strdup("/nowhere")) == NULL)
|
if((driver.stateDir = strdup("/nowhere")) == NULL)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
#define DO_TEST(name, extraFlags) \
|
#define DO_TEST_FULL(name, extraFlags, migrateFrom) \
|
||||||
do { \
|
do { \
|
||||||
struct testInfo info = { name, extraFlags }; \
|
const struct testInfo info = { name, extraFlags, migrateFrom }; \
|
||||||
if (virtTestRun("QEMU XML-2-ARGV " name, \
|
if (virtTestRun("QEMU XML-2-ARGV " name, \
|
||||||
1, testCompareXMLToArgvHelper, &info) < 0) \
|
1, testCompareXMLToArgvHelper, &info) < 0) \
|
||||||
ret = -1; \
|
ret = -1; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define DO_TEST(name, extraFlags) \
|
||||||
|
DO_TEST_FULL(name, extraFlags, NULL)
|
||||||
|
|
||||||
setenv("PATH", "/bin", 1);
|
setenv("PATH", "/bin", 1);
|
||||||
setenv("USER", "test", 1);
|
setenv("USER", "test", 1);
|
||||||
setenv("LOGNAME", "test", 1);
|
setenv("LOGNAME", "test", 1);
|
||||||
@ -228,6 +233,11 @@ mymain(int argc, char **argv)
|
|||||||
|
|
||||||
DO_TEST("hostdev-pci-address", 0);
|
DO_TEST("hostdev-pci-address", 0);
|
||||||
|
|
||||||
|
DO_TEST_FULL("restore-v1", QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO, "stdio");
|
||||||
|
DO_TEST_FULL("restore-v2", QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC, "stdio");
|
||||||
|
DO_TEST_FULL("restore-v2", QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC, "exec:cat");
|
||||||
|
DO_TEST_FULL("migrate", QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP, "tcp:10.0.0.1:5000");
|
||||||
|
|
||||||
virCapabilitiesFree(driver.caps);
|
virCapabilitiesFree(driver.caps);
|
||||||
|
|
||||||
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
|
Loading…
Reference in New Issue
Block a user