Blame SOURCES/libvirt-qemu-process-Copy-final-vcpu-order-information-into-the-vcpu-definition.patch

6ae9ed
From 6e807be3ce7a6a2ca3ea4ad8e853b953a052739d Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <6e807be3ce7a6a2ca3ea4ad8e853b953a052739d@dist-git>
6ae9ed
From: Peter Krempa <pkrempa@redhat.com>
6ae9ed
Date: Wed, 24 Aug 2016 16:11:36 -0400
6ae9ed
Subject: [PATCH] qemu: process: Copy final vcpu order information into the
6ae9ed
 vcpu definition
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1097930
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1224341
6ae9ed
6ae9ed
The vcpu order information is extracted only for hotpluggable entities,
6ae9ed
while vcpu definitions belonging to the same hotpluggable entity need
6ae9ed
to all share the order information.
6ae9ed
6ae9ed
We also can't overwrite it right away in the vcpu info detection code as
6ae9ed
the order is necessary to add the hotpluggable vcpus enabled on boot in
6ae9ed
the correct order.
6ae9ed
6ae9ed
The helper will store the order information in places where we are
6ae9ed
certain that it's necessary.
6ae9ed
6ae9ed
(cherry picked from commit 20ef1232ec9b51dc498d270f7c279235b6842d25)
6ae9ed
---
6ae9ed
 src/qemu/qemu_domain.c  | 34 ++++++++++++++++++++++++++++++++++
6ae9ed
 src/qemu/qemu_domain.h  |  3 +++
6ae9ed
 src/qemu/qemu_process.c |  2 ++
6ae9ed
 3 files changed, 39 insertions(+)
6ae9ed
6ae9ed
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
6ae9ed
index 07c42a0..959b551 100644
6ae9ed
--- a/src/qemu/qemu_domain.c
6ae9ed
+++ b/src/qemu/qemu_domain.c
6ae9ed
@@ -5949,3 +5949,37 @@ qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
6ae9ed
 
6ae9ed
     return seenonlinevcpus == virDomainDefGetVcpus(def);
6ae9ed
 }
6ae9ed
+
6ae9ed
+
6ae9ed
+/**
6ae9ed
+ * qemuDomainVcpuPersistOrder:
6ae9ed
+ * @def: domain definition
6ae9ed
+ *
6ae9ed
+ * Saves the order of vcpus detected from qemu to the domain definition.
6ae9ed
+ * The private data note the order only for the entry describing the
6ae9ed
+ * hotpluggable entity. This function copies the order into the definition part
6ae9ed
+ * of all sub entities.
6ae9ed
+ */
6ae9ed
+void
6ae9ed
+qemuDomainVcpuPersistOrder(virDomainDefPtr def)
6ae9ed
+{
6ae9ed
+    size_t maxvcpus = virDomainDefGetVcpusMax(def);
6ae9ed
+    virDomainVcpuDefPtr vcpu;
6ae9ed
+    qemuDomainVcpuPrivatePtr vcpupriv;
6ae9ed
+    unsigned int prevorder = 0;
6ae9ed
+    size_t i;
6ae9ed
+
6ae9ed
+    for (i = 0; i < maxvcpus; i++) {
6ae9ed
+        vcpu = virDomainDefGetVcpu(def, i);
6ae9ed
+        vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
6ae9ed
+
6ae9ed
+        if (!vcpu->online) {
6ae9ed
+            vcpu->order = 0;
6ae9ed
+        } else {
6ae9ed
+            if (vcpupriv->enable_id != 0)
6ae9ed
+                prevorder = vcpupriv->enable_id;
6ae9ed
+
6ae9ed
+            vcpu->order = prevorder;
6ae9ed
+        }
6ae9ed
+    }
6ae9ed
+}
6ae9ed
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
6ae9ed
index 3a80769..cc7bd51 100644
6ae9ed
--- a/src/qemu/qemu_domain.h
6ae9ed
+++ b/src/qemu/qemu_domain.h
6ae9ed
@@ -727,4 +727,7 @@ int qemuDomainPrepareChannel(virDomainChrDefPtr chr,
6ae9ed
 bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
6ae9ed
     ATTRIBUTE_NONNULL(1);
6ae9ed
 
6ae9ed
+void qemuDomainVcpuPersistOrder(virDomainDefPtr def)
6ae9ed
+    ATTRIBUTE_NONNULL(1);
6ae9ed
+
6ae9ed
 #endif /* __QEMU_DOMAIN_H__ */
6ae9ed
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
6ae9ed
index 1726608..c94eed4 100644
6ae9ed
--- a/src/qemu/qemu_process.c
6ae9ed
+++ b/src/qemu/qemu_process.c
6ae9ed
@@ -5202,6 +5202,8 @@ qemuProcessLaunch(virConnectPtr conn,
6ae9ed
     if (qemuDomainValidateVcpuInfo(vm) < 0)
6ae9ed
         goto cleanup;
6ae9ed
 
6ae9ed
+    qemuDomainVcpuPersistOrder(vm->def);
6ae9ed
+
6ae9ed
     VIR_DEBUG("Detecting IOThread PIDs");
6ae9ed
     if (qemuProcessDetectIOThreadPIDs(driver, vm, asyncJob) < 0)
6ae9ed
         goto cleanup;
6ae9ed
-- 
6ae9ed
2.10.0
6ae9ed