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

[libvirt] [PATCH RFC 43/51] qemu: monitor: Add support for 'job-complete' command



This belongs to the new job management API which can manage also
non-block based jobs.

Signed-off-by: Peter Krempa <pkrempa redhat com>
---
 src/qemu/qemu_monitor.c      | 12 ++++++++++++
 src/qemu/qemu_monitor.h      |  4 ++++
 src/qemu/qemu_monitor_json.c | 27 +++++++++++++++++++++++++++
 src/qemu/qemu_monitor_json.h |  4 ++++
 tests/qemumonitorjsontest.c  |  2 ++
 5 files changed, 49 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 294b2a3785..398d3b4d8b 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3509,6 +3509,18 @@ qemuMonitorJobCancel(qemuMonitorPtr mon,
 }


+int
+qemuMonitorJobComplete(qemuMonitorPtr mon,
+                       const char *jobname)
+{
+    VIR_DEBUG("jobname=%s", jobname);
+
+    QEMU_CHECK_MONITOR(mon);
+
+    return qemuMonitorJSONJobComplete(mon, jobname);
+}
+
+
 int
 qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon,
                               const char *drivealias,
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 13ba7be304..7feed8a427 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -953,6 +953,10 @@ int qemuMonitorJobCancel(qemuMonitorPtr mon,
                          const char *jobname)
     ATTRIBUTE_NONNULL(2);

+int qemuMonitorJobComplete(qemuMonitorPtr mon,
+                           const char *jobname)
+    ATTRIBUTE_NONNULL(2);
+
 int qemuMonitorOpenGraphics(qemuMonitorPtr mon,
                             const char *protocol,
                             int fd,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index d780a916a6..0a63cff7e2 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5010,6 +5010,33 @@ qemuMonitorJSONJobCancel(qemuMonitorPtr mon,
 }


+int
+qemuMonitorJSONJobComplete(qemuMonitorPtr mon,
+                           const char *jobname)
+{
+    int ret = -1;
+    virJSONValuePtr cmd;
+    virJSONValuePtr reply = NULL;
+
+    if (!(cmd = qemuMonitorJSONMakeCommand("job-complete",
+                                           "s:id", jobname,
+                                           NULL)))
+        return -1;
+
+    if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+        goto cleanup;
+
+    if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0)
+        goto cleanup;
+
+    ret = 0;
+ cleanup:
+    virJSONValueFree(cmd);
+    virJSONValueFree(reply);
+    return ret;
+}
+
+
 int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon,
                                 const char *protocol,
                                 const char *fdname,
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 5c6228e88a..8de1d8d547 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -340,6 +340,10 @@ int qemuMonitorJSONJobCancel(qemuMonitorPtr mon,
                              const char *jobname)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

+int qemuMonitorJSONJobComplete(qemuMonitorPtr mon,
+                               const char *jobname)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
 int qemuMonitorJSONSetLink(qemuMonitorPtr mon,
                            const char *name,
                            virDomainNetInterfaceLinkState state);
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 7065f0f49b..5284fe60c6 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1361,6 +1361,7 @@ GEN_TEST_FUNC(qemuMonitorJSONBlockdevMediumRemove, "foodev")
 GEN_TEST_FUNC(qemuMonitorJSONBlockdevMediumInsert, "foodev", "newnode")
 GEN_TEST_FUNC(qemuMonitorJSONJobDismiss, "jobname")
 GEN_TEST_FUNC(qemuMonitorJSONJobCancel, "jobname")
+GEN_TEST_FUNC(qemuMonitorJSONJobComplete, "jobname")

 static bool
 testQemuMonitorJSONqemuMonitorJSONQueryCPUsEqual(struct qemuMonitorQueryCpusEntry *a,
@@ -3009,6 +3010,7 @@ mymain(void)
     DO_TEST_GEN(qemuMonitorJSONBlockdevMediumInsert);
     DO_TEST_GEN(qemuMonitorJSONJobDismiss);
     DO_TEST_GEN(qemuMonitorJSONJobCancel);
+    DO_TEST_GEN(qemuMonitorJSONJobComplete);
     DO_TEST(qemuMonitorJSONGetBalloonInfo);
     DO_TEST(qemuMonitorJSONGetBlockInfo);
     DO_TEST(qemuMonitorJSONGetAllBlockStatsInfo);
-- 
2.19.2


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