qemu: monitor: Implement support for 'JOB_STATUS_CHANGE' event

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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2018-12-04 17:57:23 +01:00
parent ed56851f1b
commit 587c0ed12a
3 changed files with 48 additions and 0 deletions

View File

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

View File

@ -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);

View File

@ -100,6 +100,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);
@ -132,6 +133,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, },
@ -1172,6 +1174,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)