From 167028e37f22a321038da4f452e6bdc68f0d1e6a Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 30 Mar 2018 12:35:52 +0200 Subject: [PATCH] qemu: monitor: Don't resist stealing 'actions' in qemuMonitorJSONTransaction Rather than trying to prevent stealing of the 'actions' virJSONValue into the monitor command replace the code so that it does the same thing, since 'actions' was actually not really used after calling the monitor. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 4 ++-- src/qemu/qemu_monitor.c | 4 ++-- src/qemu/qemu_monitor.h | 2 +- src/qemu/qemu_monitor_json.c | 9 ++------- src/qemu/qemu_monitor_json.h | 2 +- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 072eb54b48..20c7cefccf 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14811,7 +14811,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto cleanup; - ret = qemuMonitorTransaction(priv->mon, actions); + ret = qemuMonitorTransaction(priv->mon, &actions); if (qemuDomainObjExitMonitor(driver, vm) < 0 || ret < 0) { ret = -1; @@ -14855,7 +14855,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, } } - if (ret == 0 || !actions) { + if (ret == 0 || !do_transaction) { if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0 || (persist && virDomainSaveConfig(cfg->configDir, driver->caps, vm->newDef) < 0)) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index e169553b7e..7b647525b3 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3386,9 +3386,9 @@ qemuMonitorDriveMirror(qemuMonitorPtr mon, /* Use the transaction QMP command to run atomic snapshot commands. */ int -qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr actions) +qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions) { - VIR_DEBUG("actions=%p", actions); + VIR_DEBUG("actions=%p", *actions); QEMU_CHECK_MONITOR_JSON(mon); diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 7a22323504..d04148e568 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -898,7 +898,7 @@ int qemuMonitorDiskSnapshot(qemuMonitorPtr mon, const char *file, const char *format, bool reuse); -int qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr actions) +int qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions) ATTRIBUTE_NONNULL(2); int qemuMonitorDriveMirror(qemuMonitorPtr mon, const char *device, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index de915eabb4..1fd09a3398 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4125,18 +4125,14 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, } int -qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJSONValuePtr actions) +qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions) { int ret = -1; virJSONValuePtr cmd; virJSONValuePtr reply = NULL; - virJSONValuePtr act = actions; - bool protect = actions->protect; - /* We do NOT want to free actions when recursively freeing cmd. */ - actions->protect = true; cmd = qemuMonitorJSONMakeCommand("transaction", - "a:actions", &act, + "a:actions", actions, NULL); if (!cmd) goto cleanup; @@ -4151,7 +4147,6 @@ qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJSONValuePtr actions) cleanup: virJSONValueFree(cmd); virJSONValueFree(reply); - actions->protect = protect; return ret; } diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 846d366b27..045df4919f 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -253,7 +253,7 @@ int qemuMonitorJSONDiskSnapshot(qemuMonitorPtr mon, bool reuse) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5); -int qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJSONValuePtr actions) +int qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, const char *device, -- 2.39.5