Let's store additional state information in the hypervisor-specific
private data to virDomainObj. For now, just consider panic state in QEMU
domains for which additional information is available from the guest
crash event handler.
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk(a)linux.ibm.com>
---
src/qemu/qemu_domain.c | 27 +++++++++++++++++++++++++++
src/qemu/qemu_domain.h | 5 +++++
src/qemu/qemu_driver.c | 2 ++
3 files changed, 34 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index cfd88aff..6949628d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2052,6 +2052,9 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr priv)
virBitmapFree(priv->migrationCaps);
priv->migrationCaps = NULL;
+ qemuDomainStatePanicInfoFree(priv->panicInfo);
+ priv->panicInfo = NULL;
+
qemuDomainObjResetJob(priv);
qemuDomainObjResetAsyncJob(priv);
}
@@ -14021,6 +14024,30 @@ qemuDomainStatePanicInfoFormatMsg(qemuDomainStatePanicInfoPtr
info)
}
+void
+qemuDomainStatePanicInfoSet(virDomainObjPtr vm,
+ qemuDomainStatePanicInfoPtr info)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+
+ if (!priv->panicInfo && VIR_ALLOC(priv->panicInfo) < 0)
+ return;
+
+ memcpy(priv->panicInfo, info, sizeof(*info));
+
+ switch (info->type) {
+ case QEMU_DOMAIN_STATE_PANIC_INFO_TYPE_S390:
+ ignore_value(VIR_STRDUP(priv->panicInfo->data.s390.reason,
+ 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;
+ }
+}
+
+
void
qemuDomainStatePanicInfoFree(qemuDomainStatePanicInfoPtr info)
{
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index df2a08f0..31de8ee1 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -309,6 +309,8 @@ struct _qemuDomainStatePanicInfo {
};
char *qemuDomainStatePanicInfoFormatMsg(qemuDomainStatePanicInfoPtr info);
+void qemuDomainStatePanicInfoSet(virDomainObjPtr vm,
+ qemuDomainStatePanicInfoPtr info);
void qemuDomainStatePanicInfoFree(qemuDomainStatePanicInfoPtr info);
typedef struct _qemuDomainObjPrivate qemuDomainObjPrivate;
@@ -418,6 +420,9 @@ struct _qemuDomainObjPrivate {
/* true if global -mem-prealloc appears on cmd line */
bool memPrealloc;
+
+ /* store extra information for panicked domain state */
+ qemuDomainStatePanicInfoPtr panicInfo;
};
# define QEMU_DOMAIN_PRIVATE(vm) \
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b6c9f7b8..b9d1aaa1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4171,6 +4171,8 @@ qemuProcessGuestPanicEventInfo(virQEMUDriverPtr driver,
if (msg && timestamp)
qemuDomainLogAppendMessage(driver, vm, "%s: panic %s\n", timestamp,
msg);
+ qemuDomainStatePanicInfoSet(vm, info);
+
VIR_FREE(timestamp);
VIR_FREE(msg);
}
--
2.19.1