]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: monitor: Sanitize arguments of qemuMonitorBlockdevReopen
authorPeter Krempa <pkrempa@redhat.com>
Wed, 22 Nov 2023 13:42:26 +0000 (14:42 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 27 Nov 2023 09:14:20 +0000 (10:14 +0100)
Take the virJSONValue array object which is passed to the
'blockdev-reopen' command as the 'options' argument rather than making
the caller wrap all the properties.

The code was a leftover from the time when the blockdev-reopen command
had a different syntax, and thus can be cleaned up.

Also note that the logging of the node name never worked as the top
level object didn't ever contain a 'node-name' property.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_block.c
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h

index 3d311b3fa0b772298441872cd81fca68edf26ca1..d470d79b92e0ab39bfd9bee455d3ac277708a4ca 100644 (file)
@@ -3169,7 +3169,6 @@ int
 qemuBlockReopenFormatMon(qemuMonitor *mon,
                          virStorageSource *src)
 {
-    g_autoptr(virJSONValue) reopenprops = NULL;
     g_autoptr(virJSONValue) srcprops = NULL;
     g_autoptr(virJSONValue) reopenoptions = virJSONValueNewArray();
 
@@ -3179,12 +3178,7 @@ qemuBlockReopenFormatMon(qemuMonitor *mon,
     if (virJSONValueArrayAppend(reopenoptions, &srcprops) < 0)
         return -1;
 
-    if (virJSONValueObjectAdd(&reopenprops,
-                              "a:options", &reopenoptions,
-                              NULL) < 0)
-        return -1;
-
-    if (qemuMonitorBlockdevReopen(mon, &reopenprops) < 0)
+    if (qemuMonitorBlockdevReopen(mon, &reopenoptions) < 0)
         return -1;
 
     return 0;
index 320729f067f9d27a6211df55fd27ecc54751f219..ec586b9036bcb6e8c69046ae38c8fdece18775d0 100644 (file)
@@ -3971,14 +3971,11 @@ qemuMonitorBlockdevAdd(qemuMonitor *mon,
 
 int
 qemuMonitorBlockdevReopen(qemuMonitor *mon,
-                          virJSONValue **props)
+                          virJSONValue **options)
 {
-    VIR_DEBUG("props=%p (node-name=%s)", *props,
-              NULLSTR(virJSONValueObjectGetString(*props, "node-name")));
-
     QEMU_CHECK_MONITOR(mon);
 
-    return qemuMonitorJSONBlockdevReopen(mon, props);
+    return qemuMonitorJSONBlockdevReopen(mon, options);
 }
 
 
index 6c590933aa461643807343fa425621a5c38f30ef..c4af9b407d2d57aaa3ea0d9674d0c32193b07612 100644 (file)
@@ -1309,7 +1309,7 @@ int qemuMonitorBlockdevAdd(qemuMonitor *mon,
                            virJSONValue **props);
 
 int qemuMonitorBlockdevReopen(qemuMonitor *mon,
-                              virJSONValue **props);
+                              virJSONValue **options);
 
 int qemuMonitorBlockdevDel(qemuMonitor *mon,
                            const char *nodename);
index 6f1dffe8f79b7979dbb650f2114c5c4b6a54d16c..a9133793f6a06c24c05829487a7751ea13c9089e 100644 (file)
@@ -7785,12 +7785,14 @@ qemuMonitorJSONBlockdevAdd(qemuMonitor *mon,
 
 int
 qemuMonitorJSONBlockdevReopen(qemuMonitor *mon,
-                              virJSONValue **props)
+                              virJSONValue **options)
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
-    if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-reopen", props)))
+    if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-reopen",
+                                           "a:options", options,
+                                           NULL)))
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
index 06023b98ea3fd367b0807d9197801b858b42bcbf..ed0027c118e6144458e83872c7d0d1d1e56818fe 100644 (file)
@@ -691,7 +691,7 @@ qemuMonitorJSONBlockdevAdd(qemuMonitor *mon,
 
 int
 qemuMonitorJSONBlockdevReopen(qemuMonitor *mon,
-                              virJSONValue **props)
+                              virJSONValue **options)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
 int