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 <mpriv...@redhat.com>
---
 src/lxc/lxc_domain.c |  3 ++-
 src/lxc/lxc_driver.c | 23 ++++++++++++++++-------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index 51a9fd36eb..609cfa6dae 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -93,6 +93,7 @@ virLXCDomainObjBeginJob(virLXCDriverPtr driver 
ATTRIBUTE_UNUSED,
     virLXCDomainObjPrivatePtr 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;
@@ -117,7 +118,7 @@ virLXCDomainObjBeginJob(virLXCDriverPtr driver 
ATTRIBUTE_UNUSED,
     VIR_WARN("Cannot start job (%s) for domain %s;"
              " current job is (%s) owned by (%d)",
              virLXCDomainJobTypeToString(job),
-             obj->def->name,
+             domName,
              virLXCDomainJobTypeToString(priv->job.active),
              priv->job.owner);
 
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index eaf26563f5..2bd1274c90 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -448,6 +448,12 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char 
*xml, unsigned int flags)
                                    driver->xmlopt, 0)))
         goto cleanup;
 
+    if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) {
+        if (!vm->persistent)
+            virDomainObjListRemove(driver->domains, vm);
+        goto cleanup;
+    }
+
     virDomainObjAssignDef(vm, def, false, &oldDef);
     def = NULL;
     vm->persistent = 1;
@@ -455,7 +461,7 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char 
*xml, unsigned int flags)
     if (virDomainSaveConfig(cfg->configDir, driver->caps,
                             vm->newDef ? vm->newDef : vm->def) < 0) {
         virDomainObjListRemove(driver->domains, vm);
-        goto cleanup;
+        goto endjob;
     }
 
     event = virDomainEventLifecycleNewFromObj(vm,
@@ -466,6 +472,9 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char 
*xml, unsigned int flags)
 
     dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
 
+ endjob:
+    virLXCDomainObjEndJob(driver, vm);
+
  cleanup:
     virDomainDefFree(def);
     virDomainDefFree(oldDef);
@@ -1196,15 +1205,15 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
                                    VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE)))
         goto cleanup;
 
+    if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) {
+        if (!vm->persistent)
+            virDomainObjListRemove(driver->domains, vm);
+        goto cleanup;
+    }
+
     virDomainObjAssignDef(vm, def, true, NULL);
     def = NULL;
 
-    if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) {
-        if (!vm->persistent)
-            virDomainObjListRemove(driver->domains, vm);
-        goto cleanup;
-    }
-
     if (virLXCProcessStart(conn, driver, vm,
                            nfiles, files,
                            (flags & VIR_DOMAIN_START_AUTODESTROY),
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to