]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Fix virDomainObjGetDefs when getting persistent config on a live vm
authorPeter Krempa <pkrempa@redhat.com>
Fri, 12 Jun 2015 12:37:18 +0000 (14:37 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 18 Jun 2015 13:13:44 +0000 (15:13 +0200)
If @flags contains only VIR_DOMAIN_AFFECT_CONFIG and @vm is active, the
function would return the active config rather than the persistent one
that it should return. This happened due to the fact that
virDomainObjGetDefs was checking the updated flags which may not contain
VIR_DOMAIN_AFFECT_LIVE if it is not requested even if @vm is active.

Additionally the function would not take the flags into account when
setting the pointers which was later used to determine whether the code
needs to update the given configuration.

The mistake was caught by the virt-test suite.

src/conf/domain_conf.c

index f8407b6b7ce45c2988e72e8bc6af8f59a5f358c0..e771d346c5dd2dbcfc04b32fe9a27c57122795ff 100644 (file)
@@ -2933,11 +2933,11 @@ virDomainObjGetDefs(virDomainObjPtr vm,
     if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
         return -1;
 
-    if (flags & VIR_DOMAIN_AFFECT_LIVE) {
-        if (liveDef)
+    if (virDomainObjIsActive(vm)) {
+        if (liveDef && (flags & VIR_DOMAIN_AFFECT_LIVE))
             *liveDef = vm->def;
 
-        if (persDef)
+        if (persDef && (flags & VIR_DOMAIN_AFFECT_CONFIG))
             *persDef = vm->newDef;
     } else {
         if (persDef)