[libvirt] [PATCH 5/7] qemu: vcpu: Clear vcpu order information rather than making it invalid

Peter Krempa pkrempa at redhat.com
Wed Sep 21 11:49:57 UTC 2016


Certain operations may make the vcpu order information invalid. Since
the order is primarily used to ensure migration compatibility and has
basically no other user benefits, clear the order prior to certain
operations and document that it may be cleared.

All the operations that would clear the order can still be properly
executed by defining a new domain configuration rather than using the
helper APIs.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1370357
---
 docs/formatdomain.html.in |  3 ++-
 src/conf/domain_conf.c    | 10 ++++++++++
 src/conf/domain_conf.h    |  1 +
 src/libvirt_private.syms  |  1 +
 src/qemu/qemu_driver.c    |  5 +++++
 5 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index f48a4d8..6b9377d 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -569,7 +569,8 @@
         the order may be be duplicated accross all vcpus that need to be
         enabled at once. Specifying order is not necessary, vcpus are then
         added in an arbitrary order. If order info is used, it must be used for
-        all online vcpus.
+        all online vcpus. Hypervisors may clear or update ordering information
+        during certain operations to assure valid configuration.

         Note that hypervisors may create hotpluggable vcpus differently from
         boot vcpus thus special initialization may be necessary.
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a70be31..478cec8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -25504,3 +25504,13 @@ virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
     virBufferFreeAndReset(&buf);
     return -1;
 }
+
+
+void
+virDomainDefVcpuOrderClear(virDomainDefPtr def)
+{
+    size_t i;
+
+    for (i = 0; i < def->maxvcpus; i++)
+        def->vcpus[i]->order = 0;
+}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f43fcc8..869cce5 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2474,6 +2474,7 @@ unsigned int virDomainDefGetVcpus(const virDomainDef *def);
 virBitmapPtr virDomainDefGetOnlineVcpumap(const virDomainDef *def);
 virDomainVcpuDefPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu)
     ATTRIBUTE_RETURN_CHECK;
+void virDomainDefVcpuOrderClear(virDomainDefPtr def);

 virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
     ATTRIBUTE_NONNULL(1);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 562a3d9..690319e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -254,6 +254,7 @@ virDomainDefSetMemoryTotal;
 virDomainDefSetVcpus;
 virDomainDefSetVcpusMax;
 virDomainDefValidate;
+virDomainDefVcpuOrderClear;
 virDomainDeleteConfig;
 virDomainDeviceAddressIsValid;
 virDomainDeviceAddressTypeToString;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 336673d..357be4e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4742,6 +4742,9 @@ qemuDomainSetVcpusMax(virQEMUDriverPtr driver,
         }
     }

+    /* ordering information may become invalid, thus clear it */
+    virDomainDefVcpuOrderClear(persistentDef);
+
     if (virDomainDefSetVcpusMax(persistentDef, nvcpus, driver->xmlopt) < 0)
         goto cleanup;

@@ -4916,6 +4919,8 @@ qemuDomainSetVcpusConfig(virDomainDefPtr def,
     size_t maxvcpus = virDomainDefGetVcpusMax(def);
     size_t i;

+    /* ordering information may become invalid, thus clear it */
+    virDomainDefVcpuOrderClear(def);

     if (curvcpus == nvcpus)
         return;
-- 
2.10.0




More information about the libvir-list mailing list