The reasoning here is the same as in qemu driver fixed in previous commit. Long story short, changing an XML of a domain requires modify job to be acquired. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/libxl/libxl_domain.c | 3 ++- src/libxl/libxl_driver.c | 34 ++++++++++++++++++++++++---------- src/libxl/libxl_migration.c | 10 ++++------ 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 2d8569e592..a2c90f0461 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -115,6 +115,7 @@ libxlDomainObjBeginJob(libxlDriverPrivatePtr driver ATTRIBUTE_UNUSED, libxlDomainObjPrivatePtr priv = obj->privateData; unsigned long long now; unsigned long long then; + const char *domName = NULLSTR(obj->def ? obj->def->name : NULL); if (virTimeMillisNow(&now) < 0) return -1; @@ -141,7 +142,7 @@ libxlDomainObjBeginJob(libxlDriverPrivatePtr driver ATTRIBUTE_UNUSED, VIR_WARN("Cannot start job (%s) for domain %s;" " current job is (%s) owned by (%d)", libxlDomainJobTypeToString(job), - obj->def->name, + domName, libxlDomainJobTypeToString(priv->job.active), priv->job.owner); diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 809d298ac1..1bd7148345 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -606,22 +606,29 @@ libxlAddDom0(libxlDriverPrivatePtr driver) 0))) goto cleanup; + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) { + virDomainObjListRemove(driver->domains, vm); + goto cleanup; + } + virDomainObjAssignDef(vm, def, false, &oldDef); def = NULL; vm->persistent = 1; virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED); if (virDomainDefSetVcpusMax(vm->def, d_info.vcpu_max_id + 1, driver->xmlopt)) - goto cleanup; + goto endjob; if (virDomainDefSetVcpus(vm->def, d_info.vcpu_online) < 0) - goto cleanup; + goto endjob; vm->def->mem.cur_balloon = d_info.current_memkb; if (libxlDriverGetDom0MaxmemConf(cfg, &maxmem) < 0) maxmem = d_info.current_memkb; virDomainDefSetMemoryTotal(vm->def, maxmem); ret = 0; + endjob: + libxlDomainObjEndJob(driver, vm); cleanup: libxl_dominfo_dispose(&d_info); @@ -1035,15 +1042,15 @@ libxlDomainCreateXML(virConnectPtr conn, const char *xml, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; - virDomainObjAssignDef(vm, def, true, NULL); - def = NULL; - if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) { if (!vm->persistent) virDomainObjListRemove(driver->domains, vm); goto cleanup; } + virDomainObjAssignDef(vm, def, true, NULL); + def = NULL; + if (libxlDomainStartNew(driver, vm, (flags & VIR_DOMAIN_START_PAUSED) != 0) < 0) { if (!vm->persistent) @@ -1955,15 +1962,15 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char *from, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; - virDomainObjAssignDef(vm, def, true, NULL); - def = NULL; - if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) { if (!vm->persistent) virDomainObjListRemove(driver->domains, vm); goto cleanup; } + virDomainObjAssignDef(vm, def, true, NULL); + def = NULL; + ret = libxlDomainStartRestore(driver, vm, (flags & VIR_DOMAIN_SAVE_PAUSED) != 0, fd, hdr.version); @@ -2855,16 +2862,20 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag 0))) goto cleanup; + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) { + virDomainObjListRemove(driver->domains, vm); + goto cleanup; + } + virDomainObjAssignDef(vm, def, false, &oldDef); def = NULL; - vm->persistent = 1; if (virDomainSaveConfig(cfg->configDir, cfg->caps, vm->newDef ? vm->newDef : vm->def) < 0) { virDomainObjListRemove(driver->domains, vm); - goto cleanup; + goto endjob; } dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); @@ -2874,6 +2885,9 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag VIR_DOMAIN_EVENT_DEFINED_ADDED : VIR_DOMAIN_EVENT_DEFINED_UPDATED); + endjob: + libxlDomainObjEndJob(driver, vm); + cleanup: virDomainDefFree(def); virDomainDefFree(oldDef); diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 35403380d0..64bc10bc34 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -571,9 +571,6 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dconn, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto error; - virDomainObjAssignDef(vm, *def, true, NULL); - *def = NULL; - /* * Unless an error is encountered in this function, the job will * be terminated in the finish phase. @@ -581,6 +578,8 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dconn, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto error; + virDomainObjAssignDef(vm, *def, true, NULL); + *def = NULL; priv = vm->privateData; if (taint_hook) { @@ -680,9 +679,6 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto error; - virDomainObjAssignDef(vm, *def, true, NULL); - *def = NULL; - /* * Unless an error is encountered in this function, the job will * be terminated in the finish phase. @@ -690,6 +686,8 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto error; + virDomainObjAssignDef(vm, *def, true, NULL); + *def = NULL; priv = vm->privateData; if (taint_hook) { -- 2.21.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list