]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: process: Copy final vcpu order information into the vcpu definition
authorPeter Krempa <pkrempa@redhat.com>
Thu, 4 Aug 2016 12:23:25 +0000 (14:23 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 24 Aug 2016 19:44:47 +0000 (15:44 -0400)
The vcpu order information is extracted only for hotpluggable entities,
while vcpu definitions belonging to the same hotpluggable entity need
to all share the order information.

We also can't overwrite it right away in the vcpu info detection code as
the order is necessary to add the hotpluggable vcpus enabled on boot in
the correct order.

The helper will store the order information in places where we are
certain that it's necessary.

src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
src/qemu/qemu_process.c

index 69e1e381be3bb6f52e12e3c263679002e1612d19..aa93498394094b7ea681d70b87d16d6e57004381 100644 (file)
@@ -5999,3 +5999,37 @@ qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
 
     return seenonlinevcpus == virDomainDefGetVcpus(def);
 }
+
+
+/**
+ * qemuDomainVcpuPersistOrder:
+ * @def: domain definition
+ *
+ * Saves the order of vcpus detected from qemu to the domain definition.
+ * The private data note the order only for the entry describing the
+ * hotpluggable entity. This function copies the order into the definition part
+ * of all sub entities.
+ */
+void
+qemuDomainVcpuPersistOrder(virDomainDefPtr def)
+{
+    size_t maxvcpus = virDomainDefGetVcpusMax(def);
+    virDomainVcpuDefPtr vcpu;
+    qemuDomainVcpuPrivatePtr vcpupriv;
+    unsigned int prevorder = 0;
+    size_t i;
+
+    for (i = 0; i < maxvcpus; i++) {
+        vcpu = virDomainDefGetVcpu(def, i);
+        vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
+
+        if (!vcpu->online) {
+            vcpu->order = 0;
+        } else {
+            if (vcpupriv->enable_id != 0)
+                prevorder = vcpupriv->enable_id;
+
+            vcpu->order = prevorder;
+        }
+    }
+}
index b873a8b49bc38ea43df4beb9d84a1da991a63728..13c03729f3cd5664563eddc6a3ab1401cdacc091 100644 (file)
@@ -725,4 +725,7 @@ int qemuDomainPrepareChannel(virDomainChrDefPtr chr,
 bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
     ATTRIBUTE_NONNULL(1);
 
+void qemuDomainVcpuPersistOrder(virDomainDefPtr def)
+    ATTRIBUTE_NONNULL(1);
+
 #endif /* __QEMU_DOMAIN_H__ */
index 3cf9d8cd97ceef528f0db1bae02e62b10c37544a..f3915a586b38a128449492b5b989bf900d4516ed 100644 (file)
@@ -5243,6 +5243,8 @@ qemuProcessLaunch(virConnectPtr conn,
     if (qemuDomainValidateVcpuInfo(vm) < 0)
         goto cleanup;
 
+    qemuDomainVcpuPersistOrder(vm->def);
+
     VIR_DEBUG("Detecting IOThread PIDs");
     if (qemuProcessDetectIOThreadPIDs(driver, vm, asyncJob) < 0)
         goto cleanup;