* in accessing the underlying storage. The migration will fail
* if @dxml would cause any guest-visible changes. Pass NULL
* if no changes are needed to the XML between source and destination.
+ * @dxml cannot be used to rename the domain during migration (use
+ * @dname for that purpose). Domain name in @dxml must either match the
+ * original domain name or @dname if it was specified.
*
* Returns the new domain object if the migration was successful,
* or NULL in case of error. Note that the new domain object
char **cookieout,
int *cookieoutlen,
unsigned long flags,
- const char *dname ATTRIBUTE_UNUSED,
+ const char *dname,
unsigned long resource ATTRIBUTE_UNUSED)
{
struct qemud_driver *driver = domain->conn->privateData;
if (qemuDomainCheckEjectableMedia(driver, vm) < 0)
goto endjob;
- if (!(xml = qemuMigrationBegin(driver, vm, xmlin,
+ if (!(xml = qemuMigrationBegin(driver, vm, xmlin, dname,
cookieout, cookieoutlen)))
goto endjob;
char *qemuMigrationBegin(struct qemud_driver *driver,
virDomainObjPtr vm,
const char *xmlin,
+ const char *dname,
char **cookieout,
int *cookieoutlen)
{
virDomainDefPtr def = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
- VIR_DEBUG("driver=%p, vm=%p, xmlin=%s, cookieout=%p, cookieoutlen=%p",
- driver, vm, NULLSTR(xmlin), cookieout, cookieoutlen);
+ VIR_DEBUG("driver=%p, vm=%p, xmlin=%s, dname=%s,"
+ " cookieout=%p, cookieoutlen=%p",
+ driver, vm, NULLSTR(xmlin), NULLSTR(dname),
+ cookieout, cookieoutlen);
/* Only set the phase if we are inside QEMU_ASYNC_JOB_MIGRATION_OUT.
* Otherwise we will start the async job later in the perform phase losing
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
+ if (STRNEQ(def->name, vm->def->name) &&
+ STRNEQ_NULLABLE(def->name, dname)) {
+ qemuReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("target domain name doesn't match source name"
+ " nor destination name"));
+ goto cleanup;
+ }
+
if (!virDomainDefCheckABIStability(vm->def, def))
goto cleanup;
* bit here, because we are already running inside the context of
* a single job. */
- dom_xml = qemuMigrationBegin(driver, vm, xmlin,
+ dom_xml = qemuMigrationBegin(driver, vm, xmlin, dname,
&cookieout, &cookieoutlen);
if (!dom_xml)
goto cleanup;