[PATCH 05/10] tests/qemumonitortestutils: Add JobStatusChange to update progress of blockdev-create

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

 



From: Masayoshi Mizuma <m.mizuma@xxxxxxxxxxxxxx>

Add qemuProcessHandleJobStatusChange to .jobStatusChange handler to
update the progress of blockdev-create.

Signed-off-by: Masayoshi Mizuma <m.mizuma@xxxxxxxxxxxxxx>
---
 src/qemu/qemu_process.c      |  2 +-
 src/qemu/qemu_process.h      |  7 +++++++
 tests/qemumonitortestutils.c | 22 +++++++++++++++++++++-
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index fedd1f56b1..4ba634dfc5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -992,7 +992,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon G_GNUC_UNUSED,
 }
 
 
-static int
+int
 qemuProcessHandleJobStatusChange(qemuMonitorPtr mon G_GNUC_UNUSED,
                                  virDomainObjPtr vm,
                                  const char *jobname,
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index f4feeaa68f..579564a905 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -244,3 +244,10 @@ void qemuProcessQMPFree(qemuProcessQMPPtr proc);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuProcessQMP, qemuProcessQMPFree);
 
 int qemuProcessQMPStart(qemuProcessQMPPtr proc);
+
+int
+qemuProcessHandleJobStatusChange(qemuMonitorPtr mon,
+                                 virDomainObjPtr vm,
+                                 const char *jobname,
+                                 int status,
+                                 void *opaque);
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 227b78d527..98fc5a9e9b 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -37,6 +37,7 @@
 #include "virerror.h"
 #include "virstring.h"
 #include "vireventthread.h"
+#include "qemu/qemu_process.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
@@ -575,6 +576,18 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
     return 0;
 }
 
+#define QEMU_BLOCKDEV_CREATE_CONCLUDED(id) \
+    "{"\
+    "    \"timestamp\": {"\
+    "        \"seconds\": 1616361602,"\
+    "        \"microseconds\": 893848"\
+    "    },"\
+    "    \"event\": \"JOB_STATUS_CHANGE\","\
+    "    \"data\": {"\
+    "        \"status\": \"concluded\","\
+    "        \"id\": \"" id "\""\
+    "    }"\
+    "}"
 
 static int
 qemuMonitorTestProcessCommandDefault(qemuMonitorTestPtr test,
@@ -585,6 +598,7 @@ qemuMonitorTestProcessCommandDefault(qemuMonitorTestPtr test,
     g_autoptr(virJSONValue) val = NULL;
     virJSONValuePtr cmdargs = NULL;
     const char *cmdname;
+    int ret;
 
     if (!(val = virJSONValueFromString(cmdstr)))
         return -1;
@@ -602,7 +616,12 @@ qemuMonitorTestProcessCommandDefault(qemuMonitorTestPtr test,
         qemuMonitorTestErrorInvalidCommand(data->command_name, cmdname);
         return -1;
     } else {
-        return qemuMonitorTestAddResponse(test, data->response);
+        ret = qemuMonitorTestAddResponse(test, data->response);
+        if (data->command_name && STREQ(data->command_name, "blockdev-create")) {
+            qemuMonitorTestAddResponse(test,
+                     QEMU_BLOCKDEV_CREATE_CONCLUDED("create-libvirt-1-format"));
+        }
+        return ret;
     }
 }
 
@@ -995,6 +1014,7 @@ qemuMonitorTestErrorNotify(qemuMonitorPtr mon G_GNUC_UNUSED,
 static qemuMonitorCallbacks qemuMonitorTestCallbacks = {
     .eofNotify = qemuMonitorTestEOFNotify,
     .errorNotify = qemuMonitorTestErrorNotify,
+    .jobStatusChange = qemuProcessHandleJobStatusChange,
     .domainDeviceDeleted = qemuProcessHandleDeviceDeleted,
 };
 
-- 
2.27.0




[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