|
|
e9d682 |
From 198f38fa5540c7545607b9d1beb0bfb689d56c3d Mon Sep 17 00:00:00 2001
|
|
|
e9d682 |
Message-Id: <198f38fa5540c7545607b9d1beb0bfb689d56c3d@dist-git>
|
|
|
e9d682 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
e9d682 |
Date: Thu, 1 Dec 2022 17:02:42 +0100
|
|
|
e9d682 |
Subject: [PATCH] qemuAgentGetDisks: Don't use virJSONValueObjectGetStringArray
|
|
|
e9d682 |
for optional data
|
|
|
e9d682 |
|
|
|
e9d682 |
The 'dependencies' field in the return data may be missing in some
|
|
|
e9d682 |
cases. Historically 'virJSONValueObjectGetStringArray' didn't report
|
|
|
e9d682 |
error in such case, but later refactor (commit 043b50b948ef3c2 ) added
|
|
|
e9d682 |
an error in order to use it in other places too.
|
|
|
e9d682 |
|
|
|
e9d682 |
Unfortunately this results in the error log being spammed with an
|
|
|
e9d682 |
irrelevant error in case when qemuAgentGetDisks is invoked on a VM
|
|
|
e9d682 |
running windows.
|
|
|
e9d682 |
|
|
|
e9d682 |
Replace the use of virJSONValueObjectGetStringArray by fetching the
|
|
|
e9d682 |
array first and calling virJSONValueArrayToStringList only when we have
|
|
|
e9d682 |
an array.
|
|
|
e9d682 |
|
|
|
e9d682 |
Fixes: 043b50b948ef3c2a4adf5fa32a93ec2589851ac6
|
|
|
e9d682 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2149752
|
|
|
e9d682 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
e9d682 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
e9d682 |
(cherry picked from commit 3b576601dfb924bb518870a01de5d1a421cbb467)
|
|
|
e9d682 |
https://bugzilla.redhat.com/show_bug.cgi?id=2154410
|
|
|
e9d682 |
---
|
|
|
e9d682 |
src/qemu/qemu_agent.c | 7 ++++++-
|
|
|
e9d682 |
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
e9d682 |
|
|
|
e9d682 |
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
|
|
|
e9d682 |
index d81f01ba77..7afef06694 100644
|
|
|
e9d682 |
--- a/src/qemu/qemu_agent.c
|
|
|
e9d682 |
+++ b/src/qemu/qemu_agent.c
|
|
|
e9d682 |
@@ -2544,6 +2544,7 @@ int qemuAgentGetDisks(qemuAgent *agent,
|
|
|
e9d682 |
for (i = 0; i < ndata; i++) {
|
|
|
e9d682 |
virJSONValue *addr;
|
|
|
e9d682 |
virJSONValue *entry = virJSONValueArrayGet(data, i);
|
|
|
e9d682 |
+ virJSONValue *dependencies;
|
|
|
e9d682 |
qemuAgentDiskInfo *disk;
|
|
|
e9d682 |
|
|
|
e9d682 |
if (!entry) {
|
|
|
e9d682 |
@@ -2569,7 +2570,11 @@ int qemuAgentGetDisks(qemuAgent *agent,
|
|
|
e9d682 |
goto error;
|
|
|
e9d682 |
}
|
|
|
e9d682 |
|
|
|
e9d682 |
- disk->dependencies = virJSONValueObjectGetStringArray(entry, "dependencies");
|
|
|
e9d682 |
+ if ((dependencies = virJSONValueObjectGetArray(entry, "dependencies"))) {
|
|
|
e9d682 |
+ if (!(disk->dependencies = virJSONValueArrayToStringList(dependencies)))
|
|
|
e9d682 |
+ goto error;
|
|
|
e9d682 |
+ }
|
|
|
e9d682 |
+
|
|
|
e9d682 |
disk->alias = g_strdup(virJSONValueObjectGetString(entry, "alias"));
|
|
|
e9d682 |
addr = virJSONValueObjectGetObject(entry, "address");
|
|
|
e9d682 |
if (addr) {
|
|
|
e9d682 |
--
|
|
|
e9d682 |
2.39.0
|
|
|
e9d682 |
|