90 lines
3.0 KiB
Diff
90 lines
3.0 KiB
Diff
From 3004a0c300e65777cf888a49eddcfdda8cd59941 Mon Sep 17 00:00:00 2001
|
|
Message-Id: <3004a0c300e65777cf888a49eddcfdda8cd59941@dist-git>
|
|
From: Jiri Denemark <jdenemar@redhat.com>
|
|
Date: Fri, 21 Jun 2019 09:26:00 +0200
|
|
Subject: [PATCH] qemu: Add type filter to qemuMonitorJSONParsePropsList
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
The function converts a list of QOM properties into a NULL-terminated
|
|
array of property names. The new type parameter may be used to limit the
|
|
result to properties of a specific type.
|
|
|
|
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
(cherry picked from commit 430023e5ee3f7549104f5eb09e3c26563a11882c)
|
|
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
|
|
|
|
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
Message-Id: <aaae4013352ac5c6724550a340921c394a701bcc.1561068591.git.jdenemar@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
---
|
|
src/qemu/qemu_monitor_json.c | 14 ++++++++++----
|
|
1 file changed, 10 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
|
|
index 8fead72ecf..abf952cd34 100644
|
|
--- a/src/qemu/qemu_monitor_json.c
|
|
+++ b/src/qemu/qemu_monitor_json.c
|
|
@@ -6067,11 +6067,13 @@ int qemuMonitorJSONSetObjectProperty(qemuMonitorPtr mon,
|
|
static int
|
|
qemuMonitorJSONParsePropsList(virJSONValuePtr cmd,
|
|
virJSONValuePtr reply,
|
|
+ const char *type,
|
|
char ***props)
|
|
{
|
|
virJSONValuePtr data;
|
|
char **proplist = NULL;
|
|
size_t n = 0;
|
|
+ size_t count = 0;
|
|
size_t i;
|
|
int ret = -1;
|
|
|
|
@@ -6089,17 +6091,21 @@ qemuMonitorJSONParsePropsList(virJSONValuePtr cmd,
|
|
virJSONValuePtr child = virJSONValueArrayGet(data, i);
|
|
const char *tmp;
|
|
|
|
+ if (type &&
|
|
+ STRNEQ_NULLABLE(virJSONValueObjectGetString(child, "type"), type))
|
|
+ continue;
|
|
+
|
|
if (!(tmp = virJSONValueObjectGetString(child, "name"))) {
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
_("reply data was missing 'name'"));
|
|
goto cleanup;
|
|
}
|
|
|
|
- if (VIR_STRDUP(proplist[i], tmp) < 0)
|
|
+ if (VIR_STRDUP(proplist[count++], tmp) < 0)
|
|
goto cleanup;
|
|
}
|
|
|
|
- ret = n;
|
|
+ ret = count;
|
|
*props = proplist;
|
|
proplist = NULL;
|
|
|
|
@@ -6132,7 +6138,7 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon,
|
|
goto cleanup;
|
|
}
|
|
|
|
- ret = qemuMonitorJSONParsePropsList(cmd, reply, props);
|
|
+ ret = qemuMonitorJSONParsePropsList(cmd, reply, NULL, props);
|
|
cleanup:
|
|
virJSONValueFree(reply);
|
|
virJSONValueFree(cmd);
|
|
@@ -6164,7 +6170,7 @@ qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon,
|
|
goto cleanup;
|
|
}
|
|
|
|
- ret = qemuMonitorJSONParsePropsList(cmd, reply, props);
|
|
+ ret = qemuMonitorJSONParsePropsList(cmd, reply, NULL, props);
|
|
cleanup:
|
|
virJSONValueFree(reply);
|
|
virJSONValueFree(cmd);
|
|
--
|
|
2.22.0
|
|
|