提交 5d784bd6 编写于 作者: J Jiri Denemark

Clarify semantics of virDomainMigrate2

Explicitly disallow conflicts between domain name from dxml and dname.
上级 24b8be89
......@@ -4854,6 +4854,9 @@ error:
* 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
......
......@@ -8043,7 +8043,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
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;
......@@ -8083,7 +8083,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
if (qemuDomainCheckEjectableMedia(driver, vm) < 0)
goto endjob;
if (!(xml = qemuMigrationBegin(driver, vm, xmlin,
if (!(xml = qemuMigrationBegin(driver, vm, xmlin, dname,
cookieout, cookieoutlen)))
goto endjob;
......
......@@ -993,6 +993,7 @@ qemuDomainMigrateGraphicsRelocate(struct qemud_driver *driver,
char *qemuMigrationBegin(struct qemud_driver *driver,
virDomainObjPtr vm,
const char *xmlin,
const char *dname,
char **cookieout,
int *cookieoutlen)
{
......@@ -1001,8 +1002,10 @@ char *qemuMigrationBegin(struct qemud_driver *driver,
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
......@@ -1028,6 +1031,14 @@ char *qemuMigrationBegin(struct qemud_driver *driver,
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;
......@@ -2012,7 +2023,7 @@ static int doPeer2PeerMigrate3(struct qemud_driver *driver,
* 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;
......
......@@ -79,6 +79,7 @@ int qemuMigrationSetOffline(struct qemud_driver *driver,
char *qemuMigrationBegin(struct qemud_driver *driver,
virDomainObjPtr vm,
const char *xmlin,
const char *dname,
char **cookieout,
int *cookieoutlen);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册