diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8f4915cc66..bb6a887cb7 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -700,19 +700,14 @@ void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver, } -char *qemuDomainFormatXML(struct qemud_driver *driver, - virDomainObjPtr vm, - int flags) +char *qemuDomainDefFormatXML(struct qemud_driver *driver, + virDomainDefPtr def, + int flags) { char *ret = NULL; virCPUDefPtr cpu = NULL; - virDomainDefPtr def; virCPUDefPtr def_cpu; - if ((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef) - def = vm->newDef; - else - def = vm->def; def_cpu = def->cpu; /* Update guest CPU requirements according to host CPU */ @@ -737,6 +732,21 @@ cleanup: return ret; } +char *qemuDomainFormatXML(struct qemud_driver *driver, + virDomainObjPtr vm, + int flags) +{ + virDomainDefPtr def; + + if ((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef) + def = vm->newDef; + else + def = vm->def; + + return qemuDomainDefFormatXML(driver, def, flags); +} + + void qemuDomainObjTaint(struct qemud_driver *driver, virDomainObjPtr obj, enum virDomainTaintFlags taint, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index effaebc133..9e7a7e9f0a 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -120,6 +120,10 @@ void qemuDomainObjEnterRemoteWithDriver(struct qemud_driver *driver, void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver, virDomainObjPtr obj); +char *qemuDomainDefFormatXML(struct qemud_driver *driver, + virDomainDefPtr vm, + int flags); + char *qemuDomainFormatXML(struct qemud_driver *driver, virDomainObjPtr vm, int flags); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 66c34f54b9..be2b80847a 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -914,15 +914,10 @@ char *qemuMigrationBegin(struct qemud_driver *driver, { char *rv = NULL; qemuMigrationCookiePtr mig = NULL; + virDomainDefPtr def = NULL; VIR_DEBUG("driver=%p, vm=%p, xmlin=%s, cookieout=%p, cookieoutlen=%p", driver, vm, NULLSTR(xmlin), cookieout, cookieoutlen); - if (xmlin) { - qemuReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Passing XML for the target VM is not yet supported")); - goto cleanup; - } - if (!virDomainObjIsActive(vm)) { qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is not running")); @@ -940,13 +935,27 @@ char *qemuMigrationBegin(struct qemud_driver *driver, 0) < 0) goto cleanup; - rv = qemuDomainFormatXML(driver, vm, - VIR_DOMAIN_XML_SECURE | - VIR_DOMAIN_XML_UPDATE_CPU); + if (xmlin) { + if (!(def = virDomainDefParseString(driver->caps, xmlin, + VIR_DOMAIN_XML_INACTIVE))) + goto cleanup; + + if (!virDomainDefCheckABIStability(def, vm->def)) + goto cleanup; + + rv = qemuDomainDefFormatXML(driver, def, + VIR_DOMAIN_XML_SECURE | + VIR_DOMAIN_XML_UPDATE_CPU); + } else { + rv = qemuDomainFormatXML(driver, vm, + VIR_DOMAIN_XML_SECURE | + VIR_DOMAIN_XML_UPDATE_CPU); + } cleanup: virDomainObjUnlock(vm); qemuMigrationCookieFree(mig); + virDomainDefFree(def); return rv; }