[libvirt] [PATCH 1/2] qemu: Extract and store vCPU properties as qemu returned them

Peter Krempa pkrempa at redhat.com
Thu Aug 29 13:45:16 UTC 2019


In addition to the data that libvirt needs and extracts internally,
copy and store the whole 'props' JSON sub-object of the data returned by
query-hotpluggable-cpus for future use.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_domain.c       | 3 +++
 src/qemu/qemu_domain.h       | 3 +++
 src/qemu/qemu_monitor.c      | 2 ++
 src/qemu/qemu_monitor.h      | 6 ++++++
 src/qemu/qemu_monitor_json.c | 4 ++++
 5 files changed, 18 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 4998474dc9..657f3ecfe4 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1144,6 +1144,7 @@ qemuDomainVcpuPrivateDispose(void *obj)

     VIR_FREE(priv->type);
     VIR_FREE(priv->alias);
+    virJSONValueFree(priv->props);
     return;
 }

@@ -11920,6 +11921,8 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
         VIR_STEAL_PTR(vcpupriv->type, info[i].type);
         VIR_FREE(vcpupriv->alias);
         VIR_STEAL_PTR(vcpupriv->alias, info[i].alias);
+        virJSONValueFree(vcpupriv->props);
+        VIR_STEAL_PTR(vcpupriv->props, info[i].props);
         vcpupriv->enable_id = info[i].id;
         vcpupriv->qemu_id = info[i].qemu_id;

diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 37a00323a7..d097f23342 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -449,6 +449,9 @@ struct _qemuDomainVcpuPrivate {
     char *alias;
     virTristateBool halted;

+    /* copy of the data that qemu returned */
+    virJSONValuePtr props;
+
     /* information for hotpluggable cpus */
     char *type;
     int socket_id;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index a880da3ab6..58ad109680 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1780,6 +1780,7 @@ qemuMonitorCPUInfoClear(qemuMonitorCPUInfoPtr cpus,
         VIR_FREE(cpus[i].qom_path);
         VIR_FREE(cpus[i].alias);
         VIR_FREE(cpus[i].type);
+        virJSONValueFree(cpus[i].props);
     }
 }

@@ -1931,6 +1932,7 @@ qemuMonitorGetCPUInfoHotplug(struct qemuMonitorQueryHotpluggableCpusEntry *hotpl
         VIR_STEAL_PTR(vcpus[mastervcpu].qom_path, hotplugvcpus[i].qom_path);
         VIR_STEAL_PTR(vcpus[mastervcpu].alias, hotplugvcpus[i].alias);
         VIR_STEAL_PTR(vcpus[mastervcpu].type, hotplugvcpus[i].type);
+        VIR_STEAL_PTR(vcpus[mastervcpu].props, hotplugvcpus[i].props);
         vcpus[mastervcpu].id = hotplugvcpus[i].enable_id;

         /* copy state information to slave vcpus */
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 88c9702530..de85a3ba0d 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -570,6 +570,9 @@ struct qemuMonitorQueryHotpluggableCpusEntry {
     char *qom_path; /* full device qom path only present for online cpus */
     char *alias; /* device alias, may be NULL for non-hotpluggable entities */

+    /* verbatim copy of the JSON data representing the CPU which must be used for hotplug */
+    virJSONValuePtr props;
+
     /* topology information -1 if qemu didn't report given parameter */
     int node_id;
     int socket_id;
@@ -603,6 +606,9 @@ struct _qemuMonitorCPUInfo {
     /* name of the qemu type to add in case of hotplug */
     char *type;

+    /* verbatim copy of the returned data from qemu which should be used when plugging */
+    virJSONValuePtr props;
+
     /* alias of an hotpluggable entry. Entries with alias can be hot-unplugged */
     char *alias;

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index d38b2f2cbe..da1e89dded 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -8378,6 +8378,7 @@ qemuMonitorQueryHotpluggableCpusFree(struct qemuMonitorQueryHotpluggableCpusEntr
         VIR_FREE(entry->type);
         VIR_FREE(entry->qom_path);
         VIR_FREE(entry->alias);
+        virJSONValueFree(entry->props);
     }

     VIR_FREE(entries);
@@ -8426,6 +8427,9 @@ qemuMonitorJSONProcessHotpluggableCpusReply(virJSONValuePtr vcpu,
         return -1;
     }

+    if (!(entry->props = virJSONValueCopy(props)))
+        return -1;
+
     entry->node_id = -1;
     entry->socket_id = -1;
     entry->core_id = -1;
-- 
2.21.0




More information about the libvir-list mailing list