From 6fbf8873c0e18fb08962ee59a23f9789cb92ca81 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 30 Nov 2021 15:50:53 +0100 Subject: [PATCH] qemu: monitor: Avoid ternary operators in helpers for drive/blockdev-mirror MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_monitor_json.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index ec13f270eb..a72d7c2099 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4262,6 +4262,14 @@ qemuMonitorJSONDriveMirror(qemuMonitor *mon, { g_autoptr(virJSONValue) cmd = NULL; g_autoptr(virJSONValue) reply = NULL; + const char *syncmode = "full"; + const char *mode = "absolute-paths"; + + if (shallow) + syncmode = "top"; + + if (reuse) + mode = "existing"; cmd = qemuMonitorJSONMakeCommand("drive-mirror", "s:device", device, @@ -4269,8 +4277,8 @@ qemuMonitorJSONDriveMirror(qemuMonitor *mon, "Y:speed", speed, "z:granularity", granularity, "P:buf-size", buf_size, - "s:sync", shallow ? "top" : "full", - "s:mode", reuse ? "existing" : "absolute-paths", + "s:sync", syncmode, + "s:mode", mode, "S:format", format, NULL); if (!cmd) @@ -4298,6 +4306,10 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon, g_autoptr(virJSONValue) reply = NULL; virTristateBool autofinalize = VIR_TRISTATE_BOOL_ABSENT; virTristateBool autodismiss = VIR_TRISTATE_BOOL_ABSENT; + const char *syncmode = "full"; + + if (shallow) + syncmode = "top"; if (persistjob) { autofinalize = VIR_TRISTATE_BOOL_YES; @@ -4311,7 +4323,7 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon, "Y:speed", speed, "z:granularity", granularity, "P:buf-size", buf_size, - "s:sync", shallow ? "top" : "full", + "s:sync", syncmode, "T:auto-finalize", autofinalize, "T:auto-dismiss", autodismiss, NULL);