[libvirt PATCH 06/30] qemu_monitor: introduce qemuMonitorJobFinalize

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Upcoming snapshot deletion code will require that multiple commit jobs
are finished in sync. To allow aborting then if one fails we will need
to use manual finalization of the jobs.

This commit implements the monitor code for `job-finalize`.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/qemu/qemu_monitor.c      | 12 ++++++++++++
 src/qemu/qemu_monitor.h      |  5 +++++
 src/qemu/qemu_monitor_json.c | 22 ++++++++++++++++++++++
 src/qemu/qemu_monitor_json.h |  5 +++++
 tests/qemumonitorjsontest.c  |  2 ++
 5 files changed, 46 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 734364e070..0354832fa5 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2932,6 +2932,18 @@ qemuMonitorJobDismiss(qemuMonitor *mon,
 }
 
 
+int
+qemuMonitorJobFinalize(qemuMonitor *mon,
+                       const char *jobname)
+{
+    VIR_DEBUG("jobname=%s", jobname);
+
+    QEMU_CHECK_MONITOR(mon);
+
+    return qemuMonitorJSONJobFinalize(mon, jobname);
+}
+
+
 int
 qemuMonitorJobComplete(qemuMonitor *mon,
                        const char *jobname)
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 906a919f52..eebac918c1 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1029,6 +1029,11 @@ int qemuMonitorJobDismiss(qemuMonitor *mon,
                           const char *jobname)
     ATTRIBUTE_NONNULL(2);
 
+int
+qemuMonitorJobFinalize(qemuMonitor *mon,
+                       const char *jobname)
+    ATTRIBUTE_NONNULL(2);
+
 int qemuMonitorJobComplete(qemuMonitor *mon,
                            const char *jobname)
     ATTRIBUTE_NONNULL(2);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 9822097bd7..baf01a7206 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4405,6 +4405,28 @@ qemuMonitorJSONJobDismiss(qemuMonitor *mon,
 }
 
 
+int
+qemuMonitorJSONJobFinalize(qemuMonitor *mon,
+                           const char *jobname)
+{
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
+
+    if (!(cmd = qemuMonitorJSONMakeCommand("job-finalize",
+                                           "s:id", jobname,
+                                           NULL)))
+        return -1;
+
+    if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+        return -1;
+
+    if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0)
+        return -1;
+
+    return 0;
+}
+
+
 int
 qemuMonitorJSONJobComplete(qemuMonitor *mon,
                            const char *jobname)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 484cb09830..073a0579b5 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -377,6 +377,11 @@ qemuMonitorJSONJobDismiss(qemuMonitor *mon,
                           const char *jobname)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
+int
+qemuMonitorJSONJobFinalize(qemuMonitor *mon,
+                           const char *jobname)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
 int
 qemuMonitorJSONJobComplete(qemuMonitor *mon,
                            const char *jobname)
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 59f7322711..f224ccb364 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1223,6 +1223,7 @@ GEN_TEST_FUNC(qemuMonitorJSONBlockdevMediumInsert, "foodev", "newnode")
 GEN_TEST_FUNC(qemuMonitorJSONBitmapRemove, "foodev", "newnode")
 GEN_TEST_FUNC(qemuMonitorJSONJobDismiss, "jobname")
 GEN_TEST_FUNC(qemuMonitorJSONJobComplete, "jobname")
+GEN_TEST_FUNC(qemuMonitorJSONJobFinalize, "jobname")
 GEN_TEST_FUNC(qemuMonitorJSONBlockJobCancel, "jobname", true)
 GEN_TEST_FUNC(qemuMonitorJSONSetAction,
               QEMU_MONITOR_ACTION_SHUTDOWN_PAUSE,
@@ -2921,6 +2922,7 @@ mymain(void)
     DO_TEST_GEN(qemuMonitorJSONBitmapRemove);
     DO_TEST_GEN(qemuMonitorJSONJobDismiss);
     DO_TEST_GEN(qemuMonitorJSONJobComplete);
+    DO_TEST_GEN(qemuMonitorJSONJobFinalize);
     DO_TEST_GEN(qemuMonitorJSONBlockJobCancel);
     DO_TEST_GEN(qemuMonitorJSONSetAction);
     DO_TEST_GEN(qemuMonitorJSONSetLaunchSecurityState);
-- 
2.38.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux