From nobody Wed Feb 11 10:15:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1490082432324536.7120462026763; Tue, 21 Mar 2017 00:47:12 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A9AC67AE83; Tue, 21 Mar 2017 07:47:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7AC6F4DA15; Tue, 21 Mar 2017 07:47:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2EEBF18521C8; Tue, 21 Mar 2017 07:47:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2L7kxBK016407 for ; Tue, 21 Mar 2017 03:46:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 204C417AE0; Tue, 21 Mar 2017 07:46:59 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73F691713A; Tue, 21 Mar 2017 07:46:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A9AC67AE83 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A9AC67AE83 From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 21 Mar 2017 08:47:49 +0100 Message-Id: <1fbceed59b66a5794a3a2a0032a91fc209e5d508.1490082333.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 3/4] qemu: monitor: Extract additional info from GUEST_PANICKED event X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 21 Mar 2017 07:47:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For certain kinds of panic notifiers (notably hyper-v) qemu is able to report some data regarding the crash passed from the guest. Make the data accessible to the callback in qemu so that it can be processed further. --- src/qemu/qemu_monitor.c | 15 ++++++++++-- src/qemu/qemu_monitor.h | 32 ++++++++++++++++++++++++- src/qemu/qemu_monitor_json.c | 56 ++++++++++++++++++++++++++++++++++++++++= ++-- src/qemu/qemu_process.c | 2 ++ 4 files changed, 100 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 79da47237..4a7e71e8f 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1359,11 +1359,12 @@ qemuMonitorEmitResume(qemuMonitorPtr mon) int -qemuMonitorEmitGuestPanic(qemuMonitorPtr mon) +qemuMonitorEmitGuestPanic(qemuMonitorPtr mon, + qemuMonitorEventPanicInfoPtr info) { int ret =3D -1; VIR_DEBUG("mon=3D%p", mon); - QEMU_MONITOR_CALLBACK(mon, ret, domainGuestPanic, mon->vm); + QEMU_MONITOR_CALLBACK(mon, ret, domainGuestPanic, mon->vm, info); return ret; } @@ -4184,3 +4185,13 @@ qemuMonitorQueryQMPSchema(qemuMonitorPtr mon) return qemuMonitorJSONQueryQMPSchema(mon); } + + +void +qemuMonitorEventPanicInfoFree(qemuMonitorEventPanicInfoPtr info) +{ + if (!info) + return; + + VIR_FREE(info); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index c3d3f2fb3..c4d247e79 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -70,6 +70,34 @@ struct _qemuMonitorMessage { void *passwordOpaque; }; +typedef enum { + QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_NONE =3D 0, + QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_HYPERV, + + QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_LAST +} qemuMonitorEventPanicInfoType; + +typedef struct _qemuMonitorEventPanicInfoHyperv qemuMonitorEventPanicInfoH= yperv; +typedef qemuMonitorEventPanicInfoHyperv *qemuMonitorEventPanicInfoHypervPt= r; +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 _qemuMonitorEventPanicInfo qemuMonitorEventPanicInfo; +typedef qemuMonitorEventPanicInfo *qemuMonitorEventPanicInfoPtr; +struct _qemuMonitorEventPanicInfo { + qemuMonitorEventPanicInfoType type; + union { + qemuMonitorEventPanicInfoHyperv hyperv; + } data; +}; + +void qemuMonitorEventPanicInfoFree(qemuMonitorEventPanicInfoPtr info); typedef void (*qemuMonitorDestroyCallback)(qemuMonitorPtr mon, virDomainObjPtr vm, @@ -167,6 +195,7 @@ typedef int (*qemuMonitorDomainPMSuspendDiskCallback)(q= emuMonitorPtr mon, void *opaque); typedef int (*qemuMonitorDomainGuestPanicCallback)(qemuMonitorPtr mon, virDomainObjPtr vm, + qemuMonitorEventPanicIn= foPtr info, void *opaque); typedef int (*qemuMonitorDomainDeviceDeletedCallback)(qemuMonitorPtr mon, virDomainObjPtr vm, @@ -337,7 +366,8 @@ int qemuMonitorEmitBlockJob(qemuMonitorPtr mon, int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon, unsigned long long actual); int qemuMonitorEmitPMSuspendDisk(qemuMonitorPtr mon); -int qemuMonitorEmitGuestPanic(qemuMonitorPtr mon); +int qemuMonitorEmitGuestPanic(qemuMonitorPtr mon, + qemuMonitorEventPanicInfoPtr 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 553544aea..d75748bd8 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -546,11 +546,63 @@ static void qemuMonitorJSONHandleResume(qemuMonitorPt= r mon, virJSONValuePtr data qemuMonitorEmitResume(mon); } -static void qemuMonitorJSONHandleGuestPanic(qemuMonitorPtr mon, virJSONVal= uePtr data ATTRIBUTE_UNUSED) + +static qemuMonitorEventPanicInfoPtr +qemuMonitorJSONGuestPanicExtractInfoHyperv(virJSONValuePtr data) +{ + qemuMonitorEventPanicInfoPtr ret; + + if (VIR_ALLOC(ret) < 0) + return NULL; + + ret->type =3D QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_HYPERV; + + if (virJSONValueObjectGetNumberUlong(data, "arg1", &ret->data.hyperv.a= rg1) < 0 || + virJSONValueObjectGetNumberUlong(data, "arg2", &ret->data.hyperv.a= rg2) < 0 || + virJSONValueObjectGetNumberUlong(data, "arg3", &ret->data.hyperv.a= rg3) < 0 || + virJSONValueObjectGetNumberUlong(data, "arg4", &ret->data.hyperv.a= rg4) < 0 || + virJSONValueObjectGetNumberUlong(data, "arg5", &ret->data.hyperv.a= rg5) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed hyperv panic data")); + goto error; + } + + return ret; + + error: + qemuMonitorEventPanicInfoFree(ret); + return NULL; +} + + +static qemuMonitorEventPanicInfoPtr +qemuMonitorJSONGuestPanicExtractInfo(virJSONValuePtr data) { - qemuMonitorEmitGuestPanic(mon); + const char *type =3D virJSONValueObjectGetString(data, "type"); + + if (STREQ_NULLABLE(type, "hyper-v")) + return qemuMonitorJSONGuestPanicExtractInfoHyperv(data); + + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown panic info type '%s'"), NULLSTR(type)); + return NULL; } + +static void +qemuMonitorJSONHandleGuestPanic(qemuMonitorPtr mon, + virJSONValuePtr data) +{ + virJSONValuePtr infojson =3D virJSONValueObjectGetObject(data, "info"); + qemuMonitorEventPanicInfoPtr info =3D NULL; + + if (infojson) + info =3D qemuMonitorJSONGuestPanicExtractInfo(infojson); + + qemuMonitorEmitGuestPanic(mon, info); +} + + static void qemuMonitorJSONHandleRTCChange(qemuMonitorPtr mon, virJSONValu= ePtr data) { long long offset =3D 0; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index ec0e36d2e..6a73dd464 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1297,6 +1297,7 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon ATT= RIBUTE_UNUSED, static int qemuProcessHandleGuestPanic(qemuMonitorPtr mon ATTRIBUTE_UNUSED, virDomainObjPtr vm, + qemuMonitorEventPanicInfoPtr info, void *opaque) { virQEMUDriverPtr driver =3D opaque; @@ -1309,6 +1310,7 @@ qemuProcessHandleGuestPanic(qemuMonitorPtr mon ATTRIB= UTE_UNUSED, processEvent->eventType =3D QEMU_PROCESS_EVENT_GUESTPANIC; processEvent->action =3D vm->def->onCrash; processEvent->vm =3D vm; + processEvent->data =3D info; /* Hold an extra reference because we can't allow 'vm' to be * deleted before handling guest panic event is finished. */ --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list