[PATCH 8/9] qemu: monitor: Implement support for 'JOB_STATUS_CHANGE' event

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

 



This new event is a superset of the BLOCK_JOB* events and also covers
jobs which don't bind to a VM disk.

In this patch the monitor part is implemented.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_monitor.c      | 13 +++++++++++++
 src/qemu/qemu_monitor.h      |  9 +++++++++
 src/qemu/qemu_monitor_json.c | 26 ++++++++++++++++++++++++++
 3 files changed, 48 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index c9dbc67f53..9358d0b1e2 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1503,6 +1503,19 @@ qemuMonitorEmitBlockJob(qemuMonitorPtr mon,
 }


+int
+qemuMonitorEmitJobStatusChange(qemuMonitorPtr mon,
+                               const char *jobname,
+                               qemuMonitorJobStatus status)
+{
+    int ret = -1;
+    VIR_DEBUG("mon=%p", mon);
+
+    QEMU_MONITOR_CALLBACK(mon, ret, jobStatusChange, mon->vm, jobname, status);
+    return ret;
+}
+
+
 int
 qemuMonitorEmitBalloonChange(qemuMonitorPtr mon,
                              unsigned long long actual)
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 4cbe185c5c..c6dddd1e9e 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -230,6 +230,11 @@ typedef int (*qemuMonitorDomainBlockJobCallback)(qemuMonitorPtr mon,
                                                  int status,
                                                  const char *error,
                                                  void *opaque);
+typedef int (*qemuMonitorDomainJobStatusChangeCallback)(qemuMonitorPtr mon,
+                                                        virDomainObjPtr vm,
+                                                        const char *jobname,
+                                                        int status,
+                                                        void *opaque);
 typedef int (*qemuMonitorDomainTrayChangeCallback)(qemuMonitorPtr mon,
                                                    virDomainObjPtr vm,
                                                    const char *devAlias,
@@ -357,6 +362,7 @@ struct _qemuMonitorCallbacks {
     qemuMonitorDomainIOErrorCallback domainIOError;
     qemuMonitorDomainGraphicsCallback domainGraphics;
     qemuMonitorDomainBlockJobCallback domainBlockJob;
+    qemuMonitorDomainJobStatusChangeCallback jobStatusChange;
     qemuMonitorDomainTrayChangeCallback domainTrayChange;
     qemuMonitorDomainPMWakeupCallback domainPMWakeup;
     qemuMonitorDomainPMSuspendCallback domainPMSuspend;
@@ -467,6 +473,9 @@ int qemuMonitorEmitBlockJob(qemuMonitorPtr mon,
                             int type,
                             int status,
                             const char *error);
+int qemuMonitorEmitJobStatusChange(qemuMonitorPtr mon,
+                                   const char *jobname,
+                                   qemuMonitorJobStatus status);
 int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon,
                                  unsigned long long actual);
 int qemuMonitorEmitPMSuspendDisk(qemuMonitorPtr mon);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 68780a5a4f..04538bc46c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -84,6 +84,7 @@ static void qemuMonitorJSONHandlePMSuspend(qemuMonitorPtr mon, virJSONValuePtr d
 static void qemuMonitorJSONHandleBlockJobCompleted(qemuMonitorPtr mon, virJSONValuePtr data);
 static void qemuMonitorJSONHandleBlockJobCanceled(qemuMonitorPtr mon, virJSONValuePtr data);
 static void qemuMonitorJSONHandleBlockJobReady(qemuMonitorPtr mon, virJSONValuePtr data);
+static void qemuMonitorJSONHandleJobStatusChange(qemuMonitorPtr mon, virJSONValuePtr data);
 static void qemuMonitorJSONHandleBalloonChange(qemuMonitorPtr mon, virJSONValuePtr data);
 static void qemuMonitorJSONHandlePMSuspendDisk(qemuMonitorPtr mon, virJSONValuePtr data);
 static void qemuMonitorJSONHandleGuestPanic(qemuMonitorPtr mon, virJSONValuePtr data);
@@ -116,6 +117,7 @@ static qemuEventHandler eventHandlers[] = {
     { "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, },
     { "DUMP_COMPLETED", qemuMonitorJSONHandleDumpCompleted, },
     { "GUEST_PANICKED", qemuMonitorJSONHandleGuestPanic, },
+    { "JOB_STATUS_CHANGE", qemuMonitorJSONHandleJobStatusChange, },
     { "MIGRATION", qemuMonitorJSONHandleMigrationStatus, },
     { "MIGRATION_PASS", qemuMonitorJSONHandleMigrationPass, },
     { "NIC_RX_FILTER_CHANGED", qemuMonitorJSONHandleNicRxFilterChanged, },
@@ -1156,6 +1158,30 @@ qemuMonitorJSONHandleBlockJobImpl(qemuMonitorPtr mon,
     qemuMonitorEmitBlockJob(mon, device, type, event, error);
 }

+
+static void
+qemuMonitorJSONHandleJobStatusChange(qemuMonitorPtr mon,
+                                     virJSONValuePtr data)
+{
+    const char *jobname = virJSONValueObjectGetString(data, "id");
+    const char *statusstr = virJSONValueObjectGetString(data, "status");
+    int status;
+
+    if (!jobname) {
+        VIR_WARN("missing job name in JOB_STATUS_CHANGE event");
+        return;
+    }
+
+    if ((status = qemuMonitorJobStatusTypeFromString(statusstr)) < 0) {
+        VIR_WARN("unknown job status '%s' for job '%s' in JOB_STATUS_CHANGE event",
+                 statusstr, jobname);
+        return;
+    }
+
+    qemuMonitorEmitJobStatusChange(mon, jobname, status);
+}
+
+
 static void
 qemuMonitorJSONHandleTrayChange(qemuMonitorPtr mon,
                                 virJSONValuePtr data)
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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