From 701c8c24678ce053733f6d0cd9084a14ef9d69a3 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 30 Nov 2021 16:20:50 +0100 Subject: [PATCH] qemuMonitorJSONGraphicsRelocate: Clean up command argument construction MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Move the construction of the command from the variable declaration so that it doesn't exceed the line length and we can also move the logic of determining the protocol outside of the command construction. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_monitor_json.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 18156a4fe4..4896f0b317 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3590,17 +3590,20 @@ int qemuMonitorJSONGraphicsRelocate(qemuMonitor *mon, int tlsPort, const char *tlsSubject) { - g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("client_migrate_info", - "s:protocol", - (type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE ? "spice" : "vnc"), - "s:hostname", hostname, - "i:port", port, - "i:tls-port", tlsPort, - "S:cert-subject", tlsSubject, - NULL); + const char *protocol = "vnc"; + g_autoptr(virJSONValue) cmd = NULL; g_autoptr(virJSONValue) reply = NULL; - if (!cmd) + if (type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) + protocol = "spice"; + + if (!(cmd = qemuMonitorJSONMakeCommand("client_migrate_info", + "s:protocol", protocol, + "s:hostname", hostname, + "i:port", port, + "i:tls-port", tlsPort, + "S:cert-subject", tlsSubject, + NULL))) return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) -- 2.47.2