Blame SOURCES/libvirt-qemu-command-Add-helper-to-convert-vcpu-definition-to-JSON-props.patch

6ae9ed
From dc796a3d8488292fe7088372a23046681f4d0a11 Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <dc796a3d8488292fe7088372a23046681f4d0a11@dist-git>
6ae9ed
From: Peter Krempa <pkrempa@redhat.com>
6ae9ed
Date: Wed, 24 Aug 2016 16:11:35 -0400
6ae9ed
Subject: [PATCH] qemu: command: Add helper to convert vcpu definition to JSON
6ae9ed
 props
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1097930
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1224341
6ae9ed
6ae9ed
For use on the monitor we need to format certain parts of the vcpu
6ae9ed
private definition into a JSON object. Add a helper.
6ae9ed
6ae9ed
(cherry picked from commit 8807f28b8541b59704df4f90ace06b622ab77866)
6ae9ed
---
6ae9ed
 src/qemu/qemu_command.c | 30 ++++++++++++++++++++++++++++++
6ae9ed
 src/qemu/qemu_command.h |  3 +++
6ae9ed
 2 files changed, 33 insertions(+)
6ae9ed
6ae9ed
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
6ae9ed
index 57b04ee..95055c4 100644
6ae9ed
--- a/src/qemu/qemu_command.c
6ae9ed
+++ b/src/qemu/qemu_command.c
6ae9ed
@@ -9823,3 +9823,33 @@ qemuBuildChrDeviceStr(char **deviceStr,
6ae9ed
 
6ae9ed
     return ret;
6ae9ed
 }
6ae9ed
+
6ae9ed
+
6ae9ed
+virJSONValuePtr
6ae9ed
+qemuBuildHotpluggableCPUProps(const virDomainVcpuDef *vcpu)
6ae9ed
+{
6ae9ed
+    qemuDomainVcpuPrivatePtr vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
6ae9ed
+    virJSONValuePtr ret = NULL;
6ae9ed
+
6ae9ed
+    if (virJSONValueObjectCreate(&ret, "s:driver", vcpupriv->type,
6ae9ed
+                                       "s:id", vcpupriv->alias, NULL) < 0)
6ae9ed
+        goto error;
6ae9ed
+
6ae9ed
+    if (vcpupriv->socket_id != -1 &&
6ae9ed
+        virJSONValueObjectAdd(ret, "i:socket-id", vcpupriv->socket_id, NULL) < 0)
6ae9ed
+        goto error;
6ae9ed
+
6ae9ed
+    if (vcpupriv->core_id != -1 &&
6ae9ed
+        virJSONValueObjectAdd(ret, "i:core-id", vcpupriv->core_id, NULL) < 0)
6ae9ed
+        goto error;
6ae9ed
+
6ae9ed
+    if (vcpupriv->thread_id != -1 &&
6ae9ed
+        virJSONValueObjectAdd(ret, "i:thread-id", vcpupriv->thread_id, NULL) < 0)
6ae9ed
+        goto error;
6ae9ed
+
6ae9ed
+    return ret;
6ae9ed
+
6ae9ed
+ error:
6ae9ed
+    virJSONValueFree(ret);
6ae9ed
+    return NULL;
6ae9ed
+}
6ae9ed
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
6ae9ed
index c4d0567..36cfc51 100644
6ae9ed
--- a/src/qemu/qemu_command.h
6ae9ed
+++ b/src/qemu/qemu_command.h
6ae9ed
@@ -180,4 +180,7 @@ bool qemuCheckCCWS390AddressSupport(const virDomainDef *def,
6ae9ed
                                     virQEMUCapsPtr qemuCaps,
6ae9ed
                                     const char *devicename);
6ae9ed
 
6ae9ed
+virJSONValuePtr qemuBuildHotpluggableCPUProps(const virDomainVcpuDef *vcpu)
6ae9ed
+    ATTRIBUTE_NONNULL(1);
6ae9ed
+
6ae9ed
 #endif /* __QEMU_COMMAND_H__*/
6ae9ed
-- 
6ae9ed
2.10.0
6ae9ed