[PATCH 21/27] qemu: command: Add helper to convert vcpu definition to JSON props

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For use on the monitor we need to format certain parts of the vcpu
private definition into a JSON object. Add a helper.
---
 src/qemu/qemu_command.c | 30 ++++++++++++++++++++++++++++++
 src/qemu/qemu_command.h |  3 +++
 2 files changed, 33 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 55df23d..c6ec7a7 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9796,3 +9796,33 @@ qemuBuildChrDeviceStr(char **deviceStr,

     return ret;
 }
+
+
+virJSONValuePtr
+qemuBuildHotpluggableCPUProps(const virDomainVcpuDef *vcpu)
+{
+    qemuDomainVcpuPrivatePtr vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
+    virJSONValuePtr ret = NULL;
+
+    if (virJSONValueObjectCreate(&ret, "s:driver", vcpupriv->type,
+                                       "s:id", vcpupriv->alias, NULL) < 0)
+        goto error;
+
+    if (vcpupriv->socket_id != -1 &&
+        virJSONValueObjectAdd(ret, "i:socket-id", vcpupriv->socket_id, NULL) < 0)
+        goto error;
+
+    if (vcpupriv->core_id != -1 &&
+        virJSONValueObjectAdd(ret, "i:core-id", vcpupriv->core_id, NULL) < 0)
+        goto error;
+
+    if (vcpupriv->thread_id != -1 &&
+        virJSONValueObjectAdd(ret, "i:thread-id", vcpupriv->thread_id, NULL) < 0)
+        goto error;
+
+    return ret;
+
+ error:
+    virJSONValueFree(ret);
+    return NULL;
+}
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index dcf9ba6..9b9ccb6 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -179,4 +179,7 @@ bool qemuCheckCCWS390AddressSupport(const virDomainDef *def,
                                     virQEMUCapsPtr qemuCaps,
                                     const char *devicename);

+virJSONValuePtr qemuBuildHotpluggableCPUProps(const virDomainVcpuDef *vcpu)
+    ATTRIBUTE_NONNULL(1);
+
 #endif /* __QEMU_COMMAND_H__*/
-- 
2.9.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]