From nobody Sat May 4 16:28:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616089233; cv=none; d=zohomail.com; s=zohoarc; b=Z0YwZhGNuyIP/bc1n3WHJYaRwpYI4yoMpQa6vdi9V7TWdctKK4n53IVSY2nDvjMDO0nlAT3ZQq1vY23TD92beyDdVD/c90D6ffymhe0xy6qvgCXs+dvwBRKA9SSrqBDuD8YDmko+msshtvocLOBy0urlbbvsMnw6HHD6QNLLK3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616089233; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y0EnLGI4pApgIK5pgjLLya05tFgXMRnvTUaZXHbUeRw=; b=lmx21yDFpIxv+LIpHZyaP+0AztY7VP7nIIJUMT5xY52CT7+3NP/723AAd5W63fCtP2OdmE4HbN8pYmVs1b8PGESzxBPuGCc9i9MPsi4SRbEVxZV/P8wX4D3EVkCaJuH+23GKyOsCtlxMfmEvZSC5WUFxFVxY/PXn06TqksdzEdU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1616089233307288.9548453529384; Thu, 18 Mar 2021 10:40:33 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-571-K48yxkYeNDC2E3dz5B7wNA-1; Thu, 18 Mar 2021 13:40:30 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E9E083DD20; Thu, 18 Mar 2021 17:40:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E8F4150DD0; Thu, 18 Mar 2021 17:40:22 +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 7F36D4A7C9; Thu, 18 Mar 2021 17:40:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12IHeJg3011146 for ; Thu, 18 Mar 2021 13:40:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id A9B0837DD; Thu, 18 Mar 2021 17:40:19 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16764610F1 for ; Thu, 18 Mar 2021 17:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616089232; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Y0EnLGI4pApgIK5pgjLLya05tFgXMRnvTUaZXHbUeRw=; b=Rqbn9dIfYTq2S4nFi5Ks04BtLZrE4RmY9PZC+yk1+5UCdGJNo/NQbgNJdJylY1/gxQR+yg CZPdNa9z7/F1EHl0fGtHFVBPEfrShVxYqdTXakrHYU0g6LWvTHlJPLM6k4RXsbRVNNtyL1 UebUPTGNvxWRk5ordL1PnWIoFubdkvI= X-MC-Unique: K48yxkYeNDC2E3dz5B7wNA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/3] qemuMonitorJSONGetStatus: Refactor cleanup Date: Thu, 18 Mar 2021 18:40:11 +0100 Message-Id: <8f5692f6f796f24cccc58201c52d0c628abafb6c.1616089186.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use g_autofree for the JSON values to remove cleanup label and ret variable. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_monitor_json.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index b669630bc8..e62adcb5b5 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1729,10 +1729,9 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon, bool *running, virDomainPausedReason *reason) { - int ret =3D -1; const char *status; - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValuePtr data; if (reason) @@ -1742,17 +1741,17 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon, return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) - goto cleanup; + return -1; data =3D virJSONValueObjectGetObject(reply, "return"); if (virJSONValueObjectGetBoolean(data, "running", running) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-status reply was missing running state")); - goto cleanup; + return -1; } if ((status =3D virJSONValueObjectGetString(data, "status"))) { @@ -1762,12 +1761,7 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon, VIR_DEBUG("query-status reply was missing status details"); } - ret =3D 0; - - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return 0; } --=20 2.29.2 From nobody Sat May 4 16:28:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616089233; cv=none; d=zohomail.com; s=zohoarc; b=IyWtpDuvqJ5tx8Fsn3cFLKeCzkVutprX7G9Xk/OxSfUhggocUA7liNgM1sKWTvQd2J3QzqIux3GpeMPMHr6fR97Oih6ftEsyMPZSItbRSiJvns2N2KJAh7z2E7NLylD05j9ceCiP3Tc4nHZMfJXZ6fgnVhokeCYRZWaWFeyPlT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616089233; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bQf9hVyFFoVhDbNsRsfVY0yCHxiqwNNhh9U4476ndCw=; b=I2+QfJTNjQKTb6BYbNF9VRrv2Ep/GD2QeSkvLtp/o5akN5o8qlotCkTEsglBlMYUC7VW4vHe4NcamtkROCBO7V4M/S1V8LhD7ir7NTA2tVHL149Jh5n0L6bnUy2qIwey6Gu4xEJ6oSEBcOMssOSjAt2B3X2tyRBTq6QE/3pRO44= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 16160892334511002.00228978229; Thu, 18 Mar 2021 10:40:33 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-573-_Qyhx08WPj6rcAr3Ujk6XA-1; Thu, 18 Mar 2021 13:40:30 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 35B0D91223; Thu, 18 Mar 2021 17:40:23 +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 103ED610F1; Thu, 18 Mar 2021 17:40:23 +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 725CA1809C83; Thu, 18 Mar 2021 17:40:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12IHeKVH011155 for ; Thu, 18 Mar 2021 13:40:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id B22805032F; Thu, 18 Mar 2021 17:40:20 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18F9937DD for ; Thu, 18 Mar 2021 17:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616089232; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bQf9hVyFFoVhDbNsRsfVY0yCHxiqwNNhh9U4476ndCw=; b=e1QGcBxBtXer+3Zz2pmD7CwsCON9xMuITtTjmNfFazGRYwmzOJD/1KJB+4r4qVBTjBefpB PUxyl4I46BAT8EWkEkk0v3Rtia1VcaSSnZKkHYbgBv9zl96UzfAm1tU7lESYglgJsBeEv2 rezWhWPItqJPk20P3DRDsUyTEoL2jrk= X-MC-Unique: _Qyhx08WPj6rcAr3Ujk6XA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/3] API: Add VIR_DOMAIN_PAUSED_HYPERVISOR_FAULT enum value Date: Thu, 18 Mar 2021 18:40:12 +0100 Message-Id: <367750e565838303179882e3839abf2482e31605.1616089186.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In certain cases hypervisors on encountering an internal fault pause the domain to allow gathering useful debugging information. Libvirt for now would report 'VIR_DOMAIN_PAUSED_UNKNOWN' which isn't entirely helpful. Add a new paused reason and the corresponding value for the suspended event, so that hypervisor drivers can report this state properly. In qemu this will be mapped to the 'internal-error' paused reason. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- examples/c/misc/event-test.c | 3 +++ include/libvirt/libvirt-domain.h | 2 ++ src/conf/domain_conf.c | 1 + src/qemu/qemu_domain.c | 3 +++ src/qemu/qemu_monitor.c | 4 +++- tools/virsh-domain-monitor.c | 1 + tools/virsh-domain.c | 3 ++- 7 files changed, 15 insertions(+), 2 deletions(-) diff --git a/examples/c/misc/event-test.c b/examples/c/misc/event-test.c index 76d4f3f6e8..c7d60d4c61 100644 --- a/examples/c/misc/event-test.c +++ b/examples/c/misc/event-test.c @@ -187,6 +187,9 @@ eventDetailToString(int event, case VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY_FAILED: return "Post-copy Error"; + case VIR_DOMAIN_EVENT_SUSPENDED_HYPERVISOR_FAULT: + return "Hypervisor fault"; + case VIR_DOMAIN_EVENT_SUSPENDED_LAST: break; } diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 03c119fe26..f1c0e960f9 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -119,6 +119,7 @@ typedef enum { VIR_DOMAIN_PAUSED_STARTING_UP =3D 11, /* the domain is being started */ VIR_DOMAIN_PAUSED_POSTCOPY =3D 12, /* paused for post-copy migratio= n */ VIR_DOMAIN_PAUSED_POSTCOPY_FAILED =3D 13, /* paused after failed post-= copy */ + VIR_DOMAIN_PAUSED_HYPERVISOR_FAULT =3D 14, /* paused after a hyperviso= r failure */ # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_PAUSED_LAST @@ -3108,6 +3109,7 @@ typedef enum { VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR =3D 6, /* suspended after failure= during libvirt API call */ VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY =3D 7, /* suspended for post-copy = migration */ VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY_FAILED =3D 8, /* suspended after f= ailed post-copy */ + VIR_DOMAIN_EVENT_SUSPENDED_HYPERVISOR_FAULT =3D 9, /* suspended after = a hypervisor fault */ # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_EVENT_SUSPENDED_LAST diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 47756ff0be..f49db930ca 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1082,6 +1082,7 @@ VIR_ENUM_IMPL(virDomainPausedReason, "starting up", "post-copy", "post-copy failed", + "hypervisor fault", ); VIR_ENUM_IMPL(virDomainShutdownReason, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ed2a1481d4..dde9ba92c6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11180,6 +11180,9 @@ qemuDomainPausedReasonToSuspendedEvent(virDomainPau= sedReason reason) case VIR_DOMAIN_PAUSED_POSTCOPY: return VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY; + case VIR_DOMAIN_PAUSED_HYPERVISOR_FAULT: + return VIR_DOMAIN_EVENT_SUSPENDED_HYPERVISOR_FAULT; + case VIR_DOMAIN_PAUSED_UNKNOWN: case VIR_DOMAIN_PAUSED_USER: case VIR_DOMAIN_PAUSED_SAVE: diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index c43c6f180e..ca6bd79516 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3508,10 +3508,12 @@ qemuMonitorVMStatusToPausedReason(const char *statu= s) switch ((qemuMonitorVMStatus) st) { case QEMU_MONITOR_VM_STATUS_DEBUG: - case QEMU_MONITOR_VM_STATUS_INTERNAL_ERROR: case QEMU_MONITOR_VM_STATUS_RESTORE_VM: return VIR_DOMAIN_PAUSED_UNKNOWN; + case QEMU_MONITOR_VM_STATUS_INTERNAL_ERROR: + return VIR_DOMAIN_PAUSED_HYPERVISOR_FAULT; + case QEMU_MONITOR_VM_STATUS_INMIGRATE: case QEMU_MONITOR_VM_STATUS_POSTMIGRATE: case QEMU_MONITOR_VM_STATUS_FINISH_MIGRATE: diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index c4d7464695..169fd5931b 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -195,6 +195,7 @@ VIR_ENUM_IMPL(virshDomainPausedReason, N_("starting up"), N_("post-copy"), N_("post-copy failed"), + N_("hypervisor fault"), ); VIR_ENUM_DECL(virshDomainShutdownReason); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7db88f700a..05b75edcda 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -12837,7 +12837,8 @@ VIR_ENUM_IMPL(virshDomainEventSuspended, N_("Snapshot"), N_("API error"), N_("Post-copy"), - N_("Post-copy Error")); + N_("Post-copy Error"), + N_("Hypervisor fault")); VIR_ENUM_DECL(virshDomainEventResumed); VIR_ENUM_IMPL(virshDomainEventResumed, --=20 2.29.2 From nobody Sat May 4 16:28:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616089267; cv=none; d=zohomail.com; s=zohoarc; b=A9D7OCIXIgB42YH7Tr8aqzRksZXGGSgQGg5KAWgNIgea9IGacgZQWGUwwsdis8w5FV5943ILwOfvEsb59Lc0aTiYSwj7ndx9SapnXJfzq82EszQtV+K2VoELwFUg1lQw6pJkgZUd5Or1lKv4ja4FnbqY2+0S5phiCcws87+DD5A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616089267; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AERglxOVuUMz30U4ShRRTt3gRy3ZcxcxVwih1N4716M=; b=nytTnbFT67MPRyX0pFbtm6Bgl6GjcNgx7ta0j67IppTBxsTCOV5l3dygp5A9g8MHwhRkqNLslxNnnKqnTTOMQKf0lXc2sgNiV3EcUJcG2RvhA9ZtUYb2bIilz1tZXPjTfWlolzOQSuaUSTORd9i+l13OZmVCBxnWl/vr4D4NA5o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1616089267008651.7633969343453; Thu, 18 Mar 2021 10:41:07 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-349-1i15S_pcN9Gv3TBjlgWymw-1; Thu, 18 Mar 2021 13:40:34 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CF399106BAFC; Thu, 18 Mar 2021 17:40:26 +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 A8FDF39A60; Thu, 18 Mar 2021 17:40:26 +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 5792A1800215; Thu, 18 Mar 2021 17:40:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12IHeLo8011164 for ; Thu, 18 Mar 2021 13:40:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id D2BD337DD; Thu, 18 Mar 2021 17:40:21 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25F6A610F1 for ; Thu, 18 Mar 2021 17:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616089265; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=AERglxOVuUMz30U4ShRRTt3gRy3ZcxcxVwih1N4716M=; b=HtbGjE+21sHcOSsDW4/YZAjS3RpoP861z0fQc/zTgIeYvVQypCqxc64OlLTh3eD1x3jUKx JA3wlwHWUMyeh6BiCKWMvS1OTNRp6AIjKQsBMy1EVMtsZI5fXjcj/ULwMYOI6fCJDw1f5P 8+qza5/g83UB0G3g5p0n0lSRJxiuhqs= X-MC-Unique: 1i15S_pcN9Gv3TBjlgWymw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/3] qemu: Update paused reason on unexpected 'STOP' event Date: Thu, 18 Mar 2021 18:40:13 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The qemu STOP event doesn't really report why the VM was stopped. In certain cases we do expect this by storing the expectation in the private data. In cases we've encountered an unexpected STOP event we can offload to the event thread a job to refresh the state using 'query-status'. For all other paused reasons which are expected we keep the original logic. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 1 + src/qemu/qemu_domain.h | 1 + src/qemu/qemu_driver.c | 37 +++++++++++++++++++++++++++++++++++++ src/qemu/qemu_process.c | 22 +++++++++++++++++++--- 4 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index dde9ba92c6..106a292ef3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11049,6 +11049,7 @@ qemuProcessEventFree(struct qemuProcessEvent *event) virObjectUnref(event->data); break; case QEMU_PROCESS_EVENT_PR_DISCONNECT: + case QEMU_PROCESS_EVENT_STOP: case QEMU_PROCESS_EVENT_LAST: break; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 949307229b..b057e94df0 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -441,6 +441,7 @@ typedef enum { QEMU_PROCESS_EVENT_PR_DISCONNECT, QEMU_PROCESS_EVENT_RDMA_GID_STATUS_CHANGED, QEMU_PROCESS_EVENT_GUEST_CRASHLOADED, + QEMU_PROCESS_EVENT_STOP, QEMU_PROCESS_EVENT_LAST } qemuProcessEventType; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f3f8caab44..53be363338 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4316,6 +4316,40 @@ processGuestCrashloadedEvent(virQEMUDriverPtr driver, } +static void +processGuestStopEvent(virDomainObjPtr vm) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virObjectEventPtr event =3D NULL; + virDomainPausedReason reason =3D VIR_DOMAIN_PAUSED_UNKNOWN; + + if (qemuDomainObjBeginJob(priv->driver, vm, QEMU_JOB_MODIFY) =3D=3D 0)= { + bool running; + int rc; + + qemuDomainObjEnterMonitor(priv->driver, vm); + + rc =3D qemuMonitorGetStatus(priv->mon, &running, &reason); + + /* update reason only on successful state update */ + if (qemuDomainObjExitMonitor(priv->driver, vm) < 0) + rc =3D -1; + + qemuDomainObjEndJob(priv->driver, vm); + + if (rc < 0) + return; + } + + virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, reason); + + event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_SUSPE= NDED, + qemuDomainPausedReasonToSusp= endedEvent(reason)); + + virObjectEventStateQueue(priv->driver->domainEventState, event); +} + + static void qemuProcessEventHandler(void *data, void *opaque) { struct qemuProcessEvent *processEvent =3D data; @@ -4365,6 +4399,9 @@ static void qemuProcessEventHandler(void *data, void = *opaque) case QEMU_PROCESS_EVENT_GUEST_CRASHLOADED: processGuestCrashloadedEvent(driver, vm); break; + case QEMU_PROCESS_EVENT_STOP: + processGuestStopEvent(vm); + break; case QEMU_PROCESS_EVENT_LAST: break; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5f31260221..7003c92046 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -689,10 +689,26 @@ qemuProcessHandleStop(qemuMonitorPtr mon G_GNUC_UNUSE= D, if (priv->signalStop) virDomainObjBroadcast(vm); + /* In case of VIR_DOMAIN_PAUSED_UNKNOWN we'll update it later, but= we + * must set the state to PAUSED right away. We delay the event unt= il + * the update. */ virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, reason); - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_SUSPEND= ED, - detail); + if (reason =3D=3D VIR_DOMAIN_PAUSED_UNKNOWN) { + /* offload unknown state to thread updating state */ + struct qemuProcessEvent *processEvent =3D g_new0(struct qemuPr= ocessEvent, 1); + + processEvent->eventType =3D QEMU_PROCESS_EVENT_STOP; + processEvent->vm =3D virObjectRef(vm); + + if (virThreadPoolSendJob(driver->workerPool, 0, processEvent) = < 0) { + virObjectUnref(vm); + qemuProcessEventFree(processEvent); + } + } else { + event =3D virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_SUS= PENDED, + detail); + } VIR_FREE(priv->lockState); if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lock= State) < 0) --=20 2.29.2