mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: monitor: Sanitize arguments of qemuMonitorBlockdevReopen
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>
This commit is contained in:
parent
24b667eeed
commit
7e66ff4fd1
@ -3169,7 +3169,6 @@ int
|
|||||||
qemuBlockReopenFormatMon(qemuMonitor *mon,
|
qemuBlockReopenFormatMon(qemuMonitor *mon,
|
||||||
virStorageSource *src)
|
virStorageSource *src)
|
||||||
{
|
{
|
||||||
g_autoptr(virJSONValue) reopenprops = NULL;
|
|
||||||
g_autoptr(virJSONValue) srcprops = NULL;
|
g_autoptr(virJSONValue) srcprops = NULL;
|
||||||
g_autoptr(virJSONValue) reopenoptions = virJSONValueNewArray();
|
g_autoptr(virJSONValue) reopenoptions = virJSONValueNewArray();
|
||||||
|
|
||||||
@ -3179,12 +3178,7 @@ qemuBlockReopenFormatMon(qemuMonitor *mon,
|
|||||||
if (virJSONValueArrayAppend(reopenoptions, &srcprops) < 0)
|
if (virJSONValueArrayAppend(reopenoptions, &srcprops) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virJSONValueObjectAdd(&reopenprops,
|
if (qemuMonitorBlockdevReopen(mon, &reopenoptions) < 0)
|
||||||
"a:options", &reopenoptions,
|
|
||||||
NULL) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (qemuMonitorBlockdevReopen(mon, &reopenprops) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -3971,14 +3971,11 @@ qemuMonitorBlockdevAdd(qemuMonitor *mon,
|
|||||||
|
|
||||||
int
|
int
|
||||||
qemuMonitorBlockdevReopen(qemuMonitor *mon,
|
qemuMonitorBlockdevReopen(qemuMonitor *mon,
|
||||||
virJSONValue **props)
|
virJSONValue **options)
|
||||||
{
|
{
|
||||||
VIR_DEBUG("props=%p (node-name=%s)", *props,
|
|
||||||
NULLSTR(virJSONValueObjectGetString(*props, "node-name")));
|
|
||||||
|
|
||||||
QEMU_CHECK_MONITOR(mon);
|
QEMU_CHECK_MONITOR(mon);
|
||||||
|
|
||||||
return qemuMonitorJSONBlockdevReopen(mon, props);
|
return qemuMonitorJSONBlockdevReopen(mon, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1309,7 +1309,7 @@ int qemuMonitorBlockdevAdd(qemuMonitor *mon,
|
|||||||
virJSONValue **props);
|
virJSONValue **props);
|
||||||
|
|
||||||
int qemuMonitorBlockdevReopen(qemuMonitor *mon,
|
int qemuMonitorBlockdevReopen(qemuMonitor *mon,
|
||||||
virJSONValue **props);
|
virJSONValue **options);
|
||||||
|
|
||||||
int qemuMonitorBlockdevDel(qemuMonitor *mon,
|
int qemuMonitorBlockdevDel(qemuMonitor *mon,
|
||||||
const char *nodename);
|
const char *nodename);
|
||||||
|
@ -7785,12 +7785,14 @@ qemuMonitorJSONBlockdevAdd(qemuMonitor *mon,
|
|||||||
|
|
||||||
int
|
int
|
||||||
qemuMonitorJSONBlockdevReopen(qemuMonitor *mon,
|
qemuMonitorJSONBlockdevReopen(qemuMonitor *mon,
|
||||||
virJSONValue **props)
|
virJSONValue **options)
|
||||||
{
|
{
|
||||||
g_autoptr(virJSONValue) cmd = NULL;
|
g_autoptr(virJSONValue) cmd = NULL;
|
||||||
g_autoptr(virJSONValue) reply = NULL;
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
|
|
||||||
if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-reopen", props)))
|
if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-reopen",
|
||||||
|
"a:options", options,
|
||||||
|
NULL)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||||
|
@ -691,7 +691,7 @@ qemuMonitorJSONBlockdevAdd(qemuMonitor *mon,
|
|||||||
|
|
||||||
int
|
int
|
||||||
qemuMonitorJSONBlockdevReopen(qemuMonitor *mon,
|
qemuMonitorJSONBlockdevReopen(qemuMonitor *mon,
|
||||||
virJSONValue **props)
|
virJSONValue **options)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user