In order to later process the event data, we need to be able to access
it over the lifetime of the domain. So, as an initial step, let's move
the event data structure and utility functions to qemu_domain.[ch] and
rename them appropriately to make it accessible for other users.
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk(a)linux.ibm.com>
---
src/qemu/qemu_domain.c | 53 +++++++++++++++++++++++++++++++++++-
src/qemu/qemu_domain.h | 42 ++++++++++++++++++++++++++++
src/qemu/qemu_driver.c | 6 ++--
src/qemu/qemu_monitor.c | 53 +-----------------------------------
src/qemu/qemu_monitor.h | 48 ++++----------------------------
src/qemu/qemu_monitor_json.c | 20 +++++++-------
src/qemu/qemu_process.c | 2 +-
7 files changed, 114 insertions(+), 110 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 9ca4ca33..c6e07bcb 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -13907,7 +13907,7 @@ qemuProcessEventFree(struct qemuProcessEvent *event)
switch (event->eventType) {
case QEMU_PROCESS_EVENT_GUESTPANIC:
- qemuMonitorEventPanicInfoFree(event->data);
+ qemuDomainStatePanicInfoFree(event->data);
break;
case QEMU_PROCESS_EVENT_RDMA_GID_STATUS_CHANGED:
qemuMonitorEventRdmaGidStatusFree(event->data);
@@ -14036,3 +14036,54 @@ qemuDomainNVRAMPathGenerate(virQEMUDriverConfigPtr cfg,
return 0;
}
+
+
+char *
+qemuDomainStatePanicInfoFormatMsg(qemuDomainStatePanicInfoPtr info)
+{
+ char *ret = NULL;
+
+ switch (info->type) {
+ case QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_HYPERV:
+ ignore_value(virAsprintf(&ret,
+ "hyper-v: arg1='0x%llx',
arg2='0x%llx', "
+ "arg3='0x%llx', arg4='0x%llx',
arg5='0x%llx'",
+ info->data.hyperv.arg1, info->data.hyperv.arg2,
+ info->data.hyperv.arg3, info->data.hyperv.arg4,
+ info->data.hyperv.arg5));
+ break;
+ case QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_S390:
+ ignore_value(virAsprintf(&ret, "s390: core='%d'
psw-mask='0x%016llx' "
+ "psw-addr='0x%016llx'
reason='%s'",
+ info->data.s390.core,
+ info->data.s390.psw_mask,
+ info->data.s390.psw_addr,
+ info->data.s390.reason));
+ break;
+ case QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_NONE:
+ case QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_LAST:
+ break;
+ }
+
+ return ret;
+}
+
+
+void
+qemuDomainStatePanicInfoFree(qemuDomainStatePanicInfoPtr info)
+{
+ if (!info)
+ return;
+
+ switch (info->type) {
+ case QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_S390:
+ VIR_FREE(info->data.s390.reason);
+ break;
+ case QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_NONE:
+ case QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_HYPERV:
+ case QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_LAST:
+ break;
+ }
+
+ VIR_FREE(info);
+}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index ca24de15..145b377e 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -268,6 +268,48 @@ struct _qemuDomainSecretInfo {
} s;
};
+typedef enum {
+ QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_NONE = 0,
+ QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_HYPERV,
+ QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_S390,
+
+ QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_LAST
+} qemuDomainStatePanicInfoType;
+
+typedef struct _qemuDomainStatePanicInfoHyperv qemuDomainStatePanicInfoHyperv;
+typedef qemuDomainStatePanicInfoHyperv *qemuDomainStatePanicInfoHypervPtr;
+struct _qemuDomainStatePanicInfoHyperv {
+ /* Hyper-V specific guest panic information (HV crash MSRs) */
+ unsigned long long arg1;
+ unsigned long long arg2;
+ unsigned long long arg3;
+ unsigned long long arg4;
+ unsigned long long arg5;
+};
+
+typedef struct _qemuDomainStatePanicInfoS390 qemuDomainStatePanicInfoS390;
+typedef qemuDomainStatePanicInfoS390 *qemuDomainStatePanicInfoS390Ptr;
+struct _qemuDomainStatePanicInfoS390 {
+ /* S390 specific guest panic information */
+ int core;
+ unsigned long long psw_mask;
+ unsigned long long psw_addr;
+ char *reason;
+};
+
+typedef struct _qemuDomainStatePanicInfo qemuDomainStatePanicInfo;
+typedef qemuDomainStatePanicInfo *qemuDomainStatePanicInfoPtr;
+struct _qemuDomainStatePanicInfo {
+ qemuDomainStatePanicInfoType type;
+ union {
+ qemuDomainStatePanicInfoHyperv hyperv;
+ qemuDomainStatePanicInfoS390 s390;
+ } data;
+};
+
+char *qemuDomainStatePanicInfoFormatMsg(qemuDomainStatePanicInfoPtr info);
+void qemuDomainStatePanicInfoFree(qemuDomainStatePanicInfoPtr info);
+
typedef struct _qemuDomainObjPrivate qemuDomainObjPrivate;
typedef qemuDomainObjPrivate *qemuDomainObjPrivatePtr;
struct _qemuDomainObjPrivate {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b27c6ce9..808d66cd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4163,9 +4163,9 @@ doCoreDumpToAutoDumpPath(virQEMUDriverPtr driver,
static void
qemuProcessGuestPanicEventInfo(virQEMUDriverPtr driver,
virDomainObjPtr vm,
- qemuMonitorEventPanicInfoPtr info)
+ qemuDomainStatePanicInfoPtr info)
{
- char *msg = qemuMonitorGuestPanicEventInfoFormatMsg(info);
+ char *msg = qemuDomainStatePanicInfoFormatMsg(info);
char *timestamp = virTimeStringNow();
if (msg && timestamp)
@@ -4180,7 +4180,7 @@ static void
processGuestPanicEvent(virQEMUDriverPtr driver,
virDomainObjPtr vm,
int action,
- qemuMonitorEventPanicInfoPtr info)
+ qemuDomainStatePanicInfoPtr info)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virObjectEventPtr event = NULL;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 0eb7f60e..9aa6172a 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1389,7 +1389,7 @@ qemuMonitorEmitResume(qemuMonitorPtr mon)
int
qemuMonitorEmitGuestPanic(qemuMonitorPtr mon,
- qemuMonitorEventPanicInfoPtr info)
+ qemuDomainStatePanicInfoPtr info)
{
int ret = -1;
VIR_DEBUG("mon=%p", mon);
@@ -4296,57 +4296,6 @@ qemuMonitorQueryNamedBlockNodes(qemuMonitorPtr mon)
}
-char *
-qemuMonitorGuestPanicEventInfoFormatMsg(qemuMonitorEventPanicInfoPtr info)
-{
- char *ret = NULL;
-
- switch (info->type) {
- case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_HYPERV:
- ignore_value(virAsprintf(&ret,
- "hyper-v: arg1='0x%llx',
arg2='0x%llx', "
- "arg3='0x%llx', arg4='0x%llx',
arg5='0x%llx'",
- info->data.hyperv.arg1, info->data.hyperv.arg2,
- info->data.hyperv.arg3, info->data.hyperv.arg4,
- info->data.hyperv.arg5));
- break;
- case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_S390:
- ignore_value(virAsprintf(&ret, "s390: core='%d'
psw-mask='0x%016llx' "
- "psw-addr='0x%016llx'
reason='%s'",
- info->data.s390.core,
- info->data.s390.psw_mask,
- info->data.s390.psw_addr,
- info->data.s390.reason));
- break;
- case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_NONE:
- case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_LAST:
- break;
- }
-
- return ret;
-}
-
-
-void
-qemuMonitorEventPanicInfoFree(qemuMonitorEventPanicInfoPtr info)
-{
- if (!info)
- return;
-
- switch (info->type) {
- case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_S390:
- VIR_FREE(info->data.s390.reason);
- break;
- case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_NONE:
- case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_HYPERV:
- case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_LAST:
- break;
- }
-
- VIR_FREE(info);
-}
-
-
void
qemuMonitorEventRdmaGidStatusFree(qemuMonitorRdmaGidStatusPtr info)
{
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index fd7dcc91..49eb838b 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -39,6 +39,9 @@ typedef qemuMonitor *qemuMonitorPtr;
typedef struct _qemuMonitorMessage qemuMonitorMessage;
typedef qemuMonitorMessage *qemuMonitorMessagePtr;
+typedef struct _qemuDomainStatePanicInfo qemuDomainStatePanicInfo;
+typedef qemuDomainStatePanicInfo *qemuDomainStatePanicInfoPtr;
+
typedef int (*qemuMonitorPasswordHandler)(qemuMonitorPtr mon,
qemuMonitorMessagePtr msg,
const char *data,
@@ -67,45 +70,6 @@ struct _qemuMonitorMessage {
void *passwordOpaque;
};
-typedef enum {
- QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_NONE = 0,
- QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_HYPERV,
- QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_S390,
-
- QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_LAST
-} qemuMonitorEventPanicInfoType;
-
-typedef struct _qemuMonitorEventPanicInfoHyperv qemuMonitorEventPanicInfoHyperv;
-typedef qemuMonitorEventPanicInfoHyperv *qemuMonitorEventPanicInfoHypervPtr;
-struct _qemuMonitorEventPanicInfoHyperv {
- /* Hyper-V specific guest panic information (HV crash MSRs) */
- unsigned long long arg1;
- unsigned long long arg2;
- unsigned long long arg3;
- unsigned long long arg4;
- unsigned long long arg5;
-};
-
-typedef struct _qemuMonitorEventPanicInfoS390 qemuMonitorEventPanicInfoS390;
-typedef qemuMonitorEventPanicInfoS390 *qemuMonitorEventPanicInfoS390Ptr;
-struct _qemuMonitorEventPanicInfoS390 {
- /* S390 specific guest panic information */
- int core;
- unsigned long long psw_mask;
- unsigned long long psw_addr;
- char *reason;
-};
-
-typedef struct _qemuMonitorEventPanicInfo qemuMonitorEventPanicInfo;
-typedef qemuMonitorEventPanicInfo *qemuMonitorEventPanicInfoPtr;
-struct _qemuMonitorEventPanicInfo {
- qemuMonitorEventPanicInfoType type;
- union {
- qemuMonitorEventPanicInfoHyperv hyperv;
- qemuMonitorEventPanicInfoS390 s390;
- } data;
-};
-
typedef struct _qemuMonitorRdmaGidStatus qemuMonitorRdmaGidStatus;
typedef qemuMonitorRdmaGidStatus *qemuMonitorRdmaGidStatusPtr;
@@ -117,8 +81,6 @@ struct _qemuMonitorRdmaGidStatus {
};
-char *qemuMonitorGuestPanicEventInfoFormatMsg(qemuMonitorEventPanicInfoPtr info);
-void qemuMonitorEventPanicInfoFree(qemuMonitorEventPanicInfoPtr info);
void qemuMonitorEventRdmaGidStatusFree(qemuMonitorRdmaGidStatusPtr info);
typedef void (*qemuMonitorDestroyCallback)(qemuMonitorPtr mon,
@@ -209,7 +171,7 @@ typedef int (*qemuMonitorDomainPMSuspendDiskCallback)(qemuMonitorPtr
mon,
void *opaque);
typedef int (*qemuMonitorDomainGuestPanicCallback)(qemuMonitorPtr mon,
virDomainObjPtr vm,
- qemuMonitorEventPanicInfoPtr info,
+ qemuDomainStatePanicInfoPtr info,
void *opaque);
typedef int (*qemuMonitorDomainDeviceDeletedCallback)(qemuMonitorPtr mon,
virDomainObjPtr vm,
@@ -431,7 +393,7 @@ int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon,
unsigned long long actual);
int qemuMonitorEmitPMSuspendDisk(qemuMonitorPtr mon);
int qemuMonitorEmitGuestPanic(qemuMonitorPtr mon,
- qemuMonitorEventPanicInfoPtr info);
+ qemuDomainStatePanicInfoPtr info);
int qemuMonitorEmitDeviceDeleted(qemuMonitorPtr mon,
const char *devAlias);
int qemuMonitorEmitNicRxFilterChanged(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 5c16e1f3..d3fa371a 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -632,15 +632,15 @@ static void qemuMonitorJSONHandleResume(qemuMonitorPtr mon,
virJSONValuePtr data
}
-static qemuMonitorEventPanicInfoPtr
+static qemuDomainStatePanicInfoPtr
qemuMonitorJSONGuestPanicExtractInfoHyperv(virJSONValuePtr data)
{
- qemuMonitorEventPanicInfoPtr ret;
+ qemuDomainStatePanicInfoPtr ret;
if (VIR_ALLOC(ret) < 0)
return NULL;
- ret->type = QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_HYPERV;
+ ret->type = QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_HYPERV;
if (virJSONValueObjectGetNumberUlong(data, "arg1",
&ret->data.hyperv.arg1) < 0 ||
virJSONValueObjectGetNumberUlong(data, "arg2",
&ret->data.hyperv.arg2) < 0 ||
@@ -655,14 +655,14 @@ qemuMonitorJSONGuestPanicExtractInfoHyperv(virJSONValuePtr data)
return ret;
error:
- qemuMonitorEventPanicInfoFree(ret);
+ qemuDomainStatePanicInfoFree(ret);
return NULL;
}
-static qemuMonitorEventPanicInfoPtr
+static qemuDomainStatePanicInfoPtr
qemuMonitorJSONGuestPanicExtractInfoS390(virJSONValuePtr data)
{
- qemuMonitorEventPanicInfoPtr ret;
+ qemuDomainStatePanicInfoPtr ret;
int core;
unsigned long long psw_mask, psw_addr;
const char *reason = NULL;
@@ -670,7 +670,7 @@ qemuMonitorJSONGuestPanicExtractInfoS390(virJSONValuePtr data)
if (VIR_ALLOC(ret) < 0)
return NULL;
- ret->type = QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_S390;
+ ret->type = QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_S390;
if (virJSONValueObjectGetNumberInt(data, "core", &core) < 0 ||
virJSONValueObjectGetNumberUlong(data, "psw-mask", &psw_mask) <
0 ||
@@ -690,11 +690,11 @@ qemuMonitorJSONGuestPanicExtractInfoS390(virJSONValuePtr data)
return ret;
error:
- qemuMonitorEventPanicInfoFree(ret);
+ qemuDomainStatePanicInfoFree(ret);
return NULL;
}
-static qemuMonitorEventPanicInfoPtr
+static qemuDomainStatePanicInfoPtr
qemuMonitorJSONGuestPanicExtractInfo(virJSONValuePtr data)
{
const char *type = virJSONValueObjectGetString(data, "type");
@@ -715,7 +715,7 @@ qemuMonitorJSONHandleGuestPanic(qemuMonitorPtr mon,
virJSONValuePtr data)
{
virJSONValuePtr infojson = virJSONValueObjectGetObject(data, "info");
- qemuMonitorEventPanicInfoPtr info = NULL;
+ qemuDomainStatePanicInfoPtr info = NULL;
if (infojson)
info = qemuMonitorJSONGuestPanicExtractInfo(infojson);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index dc7317b7..aec4af8f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1259,7 +1259,7 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
static int
qemuProcessHandleGuestPanic(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
- qemuMonitorEventPanicInfoPtr info,
+ qemuDomainStatePanicInfoPtr info,
void *opaque)
{
virQEMUDriverPtr driver = opaque;
--
2.17.0