[PATCH RFC 46/51] 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 7d061a48ab..367e3265b8 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1526,6 +1526,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 e51177bf44..e7ea8f5b8e 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -222,6 +222,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,
@@ -341,6 +346,7 @@ struct _qemuMonitorCallbacks {
     qemuMonitorDomainIOErrorCallback domainIOError;
     qemuMonitorDomainGraphicsCallback domainGraphics;
     qemuMonitorDomainBlockJobCallback domainBlockJob;
+    qemuMonitorDomainJobStatusChangeCallback jobStatusChange;
     qemuMonitorDomainTrayChangeCallback domainTrayChange;
     qemuMonitorDomainPMWakeupCallback domainPMWakeup;
     qemuMonitorDomainPMSuspendCallback domainPMSuspend;
@@ -452,6 +458,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 101e6ec7cd..a8f6320414 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);
@@ -115,6 +116,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, },
@@ -1035,6 +1037,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.19.2

--
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