[PATCH 2/3] qemu_monitor: move qemuMonitorJSONObjectProperty from qemu_monitor_json

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

 



Moving the struct and friends to qemu_monitor.h because the
'qemuMonitorJSONGetObjectProperty' has usage also for internal libvirt
code not only for tests.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/qemu/qemu_monitor.h      | 28 ++++++++++++++++++++++++++++
 src/qemu/qemu_monitor_json.c | 12 ++++++------
 src/qemu/qemu_monitor_json.h | 34 ++--------------------------------
 tests/qemumonitorjsontest.c  | 10 +++++-----
 4 files changed, 41 insertions(+), 43 deletions(-)

diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 21533a4..4918588 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -211,6 +211,34 @@ struct _qemuMonitorCallbacks {
     qemuMonitorDomainSerialChangeCallback domainSerialChange;
 };
 
+/* Flags for the 'type' field in _qemuMonitorObjectProperty */
+typedef enum {
+    QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN=1,
+    QEMU_MONITOR_OBJECT_PROPERTY_INT,
+    QEMU_MONITOR_OBJECT_PROPERTY_LONG,
+    QEMU_MONITOR_OBJECT_PROPERTY_UINT,
+    QEMU_MONITOR_OBJECT_PROPERTY_ULONG,
+    QEMU_MONITOR_OBJECT_PROPERTY_DOUBLE,
+    QEMU_MONITOR_OBJECT_PROPERTY_STRING,
+
+    QEMU_MONITOR_OBJECT_PROPERTY_LAST
+} qemuMonitorObjectPropertyType;
+
+typedef struct _qemuMonitorObjectProperty qemuMonitorObjectProperty;
+typedef qemuMonitorObjectProperty *qemuMonitorObjectPropertyPtr;
+struct _qemuMonitorObjectProperty {
+    int type;    /* qemuMonitorObjectPropertyType */
+    union {
+        bool b;
+        int iv;
+        long long l;
+        unsigned int ui;
+        unsigned long long ul;
+        double d;
+        char *str;
+    } val;
+};
+
 char *qemuMonitorEscapeArg(const char *in);
 char *qemuMonitorUnescapeArg(const char *in);
 
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 162579b..7854b9c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1489,10 +1489,10 @@ qemuMonitorJSONSetMemoryStatsPeriod(qemuMonitorPtr mon,
                                     char *balloonpath,
                                     int period)
 {
-    qemuMonitorJSONObjectProperty prop;
+    qemuMonitorObjectProperty prop;
 
     /* Set to the value in memballoon (could enable or disable) */
-    memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty));
+    memset(&prop, 0, sizeof(qemuMonitorObjectProperty));
     prop.type = QEMU_MONITOR_OBJECT_PROPERTY_INT;
     prop.val.iv = period;
     if (qemuMonitorJSONSetObjectProperty(mon, balloonpath,
@@ -5287,7 +5287,7 @@ void qemuMonitorJSONListPathFree(qemuMonitorJSONListPathPtr paths)
 int qemuMonitorJSONGetObjectProperty(qemuMonitorPtr mon,
                                      const char *path,
                                      const char *property,
-                                     qemuMonitorJSONObjectPropertyPtr prop)
+                                     qemuMonitorObjectPropertyPtr prop)
 {
     int ret;
     virJSONValuePtr cmd;
@@ -5317,7 +5317,7 @@ int qemuMonitorJSONGetObjectProperty(qemuMonitorPtr mon,
         goto cleanup;
     }
 
-    switch ((qemuMonitorJSONObjectPropertyType) prop->type) {
+    switch ((qemuMonitorObjectPropertyType) prop->type) {
     /* Simple cases of boolean, int, long, uint, ulong, double, and string
      * will receive return value as part of {"return": xxx} statement
      */
@@ -5378,13 +5378,13 @@ int qemuMonitorJSONGetObjectProperty(qemuMonitorPtr mon,
 int qemuMonitorJSONSetObjectProperty(qemuMonitorPtr mon,
                                      const char *path,
                                      const char *property,
-                                     qemuMonitorJSONObjectPropertyPtr prop)
+                                     qemuMonitorObjectPropertyPtr prop)
 {
     int ret = -1;
     virJSONValuePtr cmd = NULL;
     virJSONValuePtr reply = NULL;
 
-    switch ((qemuMonitorJSONObjectPropertyType) prop->type) {
+    switch ((qemuMonitorObjectPropertyType) prop->type) {
     /* Simple cases of boolean, int, long, uint, ulong, double, and string
      * will receive return value as part of {"return": xxx} statement
      */
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index ae20fb1..b8f14bc 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -388,47 +388,17 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitorPtr mon,
 
 void qemuMonitorJSONListPathFree(qemuMonitorJSONListPathPtr paths);
 
-/* ObjectProperty structures and Get/Set API's are public only
- * for qemumonitorjsontest
- */
-/* Flags for the 'type' field in _qemuMonitorJSONObjectProperty */
-typedef enum {
-    QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN=1,
-    QEMU_MONITOR_OBJECT_PROPERTY_INT,
-    QEMU_MONITOR_OBJECT_PROPERTY_LONG,
-    QEMU_MONITOR_OBJECT_PROPERTY_UINT,
-    QEMU_MONITOR_OBJECT_PROPERTY_ULONG,
-    QEMU_MONITOR_OBJECT_PROPERTY_DOUBLE,
-    QEMU_MONITOR_OBJECT_PROPERTY_STRING,
-
-    QEMU_MONITOR_OBJECT_PROPERTY_LAST
-} qemuMonitorJSONObjectPropertyType;
-
-typedef struct _qemuMonitorJSONObjectProperty qemuMonitorJSONObjectProperty;
-typedef qemuMonitorJSONObjectProperty *qemuMonitorJSONObjectPropertyPtr;
-struct _qemuMonitorJSONObjectProperty {
-    int type;    /* qemuMonitorJSONObjectPropertyType */
-    union {
-        bool b;
-        int iv;
-        long long l;
-        unsigned int ui;
-        unsigned long long ul;
-        double d;
-        char *str;
-    } val;
-};
 
 int qemuMonitorJSONGetObjectProperty(qemuMonitorPtr mon,
                                      const char *path,
                                      const char *property,
-                                     qemuMonitorJSONObjectPropertyPtr prop)
+                                     qemuMonitorObjectPropertyPtr prop)
     ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
 
 int qemuMonitorJSONSetObjectProperty(qemuMonitorPtr mon,
                                      const char *path,
                                      const char *property,
-                                     qemuMonitorJSONObjectPropertyPtr prop)
+                                     qemuMonitorObjectPropertyPtr prop)
     ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
 
 int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon,
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index bd92e63..14cde7c 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -895,7 +895,7 @@ testQemuMonitorJSONGetObjectProperty(const void *data)
     virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
     qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
     int ret = -1;
-    qemuMonitorJSONObjectProperty prop;
+    qemuMonitorObjectProperty prop;
 
     if (!test)
         return -1;
@@ -905,7 +905,7 @@ testQemuMonitorJSONGetObjectProperty(const void *data)
         goto cleanup;
 
     /* Present with path and property */
-    memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty));
+    memset(&prop, 0, sizeof(qemuMonitorObjectProperty));
     prop.type = QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN;
     if (qemuMonitorJSONGetObjectProperty(qemuMonitorTestGetMonitor(test),
                                          "/machine/i440fx",
@@ -938,7 +938,7 @@ testQemuMonitorJSONSetObjectProperty(const void *data)
     virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
     qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
     int ret = -1;
-    qemuMonitorJSONObjectProperty prop;
+    qemuMonitorObjectProperty prop;
 
     if (!test)
         return -1;
@@ -951,7 +951,7 @@ testQemuMonitorJSONSetObjectProperty(const void *data)
         goto cleanup;
 
     /* Let's attempt the setting */
-    memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty));
+    memset(&prop, 0, sizeof(qemuMonitorObjectProperty));
     prop.type = QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN;
     prop.val.b = true;
     if (qemuMonitorJSONSetObjectProperty(qemuMonitorTestGetMonitor(test),
@@ -963,7 +963,7 @@ testQemuMonitorJSONSetObjectProperty(const void *data)
     /* To make sure it worked, fetch the property - if this succeeds then
      * we didn't hose things
      */
-    memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty));
+    memset(&prop, 0, sizeof(qemuMonitorObjectProperty));
     prop.type = QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN;
     if (qemuMonitorJSONGetObjectProperty(qemuMonitorTestGetMonitor(test),
                                          "/machine/i440fx",
-- 
2.0.4

--
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]