From nobody Sun Apr 28 04:15:08 2024 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537881575799132.70869246344557; Tue, 25 Sep 2018 06:19:35 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id CB5E530832E5; Tue, 25 Sep 2018 13:19:33 +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 913FE19E61; Tue, 25 Sep 2018 13:19:33 +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 3B3874A464; Tue, 25 Sep 2018 13:19:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8PDJDmB025503 for ; Tue, 25 Sep 2018 09:19:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7E47510021B2; Tue, 25 Sep 2018 13:19:13 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 51349108131B for ; Tue, 25 Sep 2018 13:19:10 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 43C7F101E96; Tue, 25 Sep 2018 15:19:09 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 25 Sep 2018 15:19:01 +0200 Message-Id: <87f83d8375f5f17c8f5166cbcbaf00a6c351b617.1537881453.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/5] qemu: Properly report VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT 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: , 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 25 Sep 2018 13:19:34 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT was defined but not used anywhere in our event generation code. This fixes qemuDomainRevertToSnapshot to properly report why the domain was resumed. Signed-off-by: Jiri Denemark Reviewed-by: John Ferlan --- Notes: Version 2: - no change src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 10d6bca186..0c1afbfd4e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16273,7 +16273,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, detail); } else if (!was_running) { /* Transition 8 */ - detail =3D VIR_DOMAIN_EVENT_RESUMED; + detail =3D VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT; event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_RESUMED, detail); --=20 2.19.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 04:15:08 2024 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 153788157143553.88139812698603; Tue, 25 Sep 2018 06:19:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 31A64308212F; Tue, 25 Sep 2018 13:19:29 +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 E7D242010D9A; Tue, 25 Sep 2018 13:19:28 +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 8DECF181A139; Tue, 25 Sep 2018 13:19:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8PDJCNb025489 for ; Tue, 25 Sep 2018 09:19:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9EC9419E61; Tue, 25 Sep 2018 13:19:12 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 71DBE19E37 for ; Tue, 25 Sep 2018 13:19:10 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 46ADB1047C8; Tue, 25 Sep 2018 15:19:09 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 25 Sep 2018 15:19:02 +0200 Message-Id: <7c578f0975c2777786d9bad0c2ef75d300f43bcc.1537881453.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/5] qemu: Report more appropriate running reasons 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 25 Sep 2018 13:19:29 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch replaces some rather generic VIR_DOMAIN_RUNNING_UNPAUSED reasons when changing domain state to running with more specific ones. All of them are done when libvirtd reconnects to an existing domain after being restarted and sees an unfinished migration or save. Signed-off-by: Jiri Denemark Reviewed-by: John Ferlan --- Notes: Version 2: - modified commit message src/qemu/qemu_process.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index a471a1e839..417e47ec29 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3292,7 +3292,7 @@ qemuProcessRecoverMigrationIn(virQEMUDriverPtr driver, VIR_DEBUG("Incoming migration finished, resuming domain %s", vm->def->name); if (qemuProcessStartCPUs(driver, vm, - VIR_DOMAIN_RUNNING_UNPAUSED, + VIR_DOMAIN_RUNNING_MIGRATED, QEMU_ASYNC_JOB_NONE) < 0) { VIR_WARN("Could not resume domain %s", vm->def->name); } @@ -3399,7 +3399,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriverPtr drive= r, (reason =3D=3D VIR_DOMAIN_PAUSED_MIGRATION || reason =3D=3D VIR_DOMAIN_PAUSED_UNKNOWN)) { if (qemuProcessStartCPUs(driver, vm, - VIR_DOMAIN_RUNNING_UNPAUSED, + VIR_DOMAIN_RUNNING_MIGRATION_CANCELED, QEMU_ASYNC_JOB_NONE) < 0) { VIR_WARN("Could not resume domain %s", vm->def->name); } @@ -3457,7 +3457,7 @@ qemuProcessRecoverJob(virQEMUDriverPtr driver, reason =3D=3D VIR_DOMAIN_PAUSED_MIGRATION)) || reason =3D=3D VIR_DOMAIN_PAUSED_UNKNOWN)) { if (qemuProcessStartCPUs(driver, vm, - VIR_DOMAIN_RUNNING_UNPAUSED, + VIR_DOMAIN_RUNNING_SAVE_CANCELED, QEMU_ASYNC_JOB_NONE) < 0) { VIR_WARN("Could not resume domain '%s' after migration to= file", vm->def->name); --=20 2.19.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 04:15:08 2024 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537881562225520.0679277397037; Tue, 25 Sep 2018 06:19:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1340686660; Tue, 25 Sep 2018 13:19:20 +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 C7C355DD78; Tue, 25 Sep 2018 13:19:19 +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 6EAF5181A130; Tue, 25 Sep 2018 13:19:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8PDJDqQ025508 for ; Tue, 25 Sep 2018 09:19:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id B4037608EE; Tue, 25 Sep 2018 13:19:13 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DA3C5F7C9 for ; Tue, 25 Sep 2018 13:19:10 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 48DC21047CA; Tue, 25 Sep 2018 15:19:09 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 25 Sep 2018 15:19:03 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 3/5] qemu: Pass running reason to RESUME event handler 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: , 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 25 Sep 2018 13:19:20 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Whenever we get the RESUME event from QEMU, we change the state of the affected domain to VIR_DOMAIN_RUNNING with VIR_DOMAIN_RUNNING_UNPAUSED reason. This is fine if the domain is resumed unexpectedly, but when we sent "cont" to QEMU we usually have a better reason for the state change. The better reason is used in qemuProcessStartCPUs which also sets the domain state to running if qemuMonitorStartCPUs reports success. Thus we may end up with two state updates in a row, but the final reason is correct. This patch is a preparation for dropping the state change done in qemuMonitorStartCPUs for which we need to pass the actual running reason to the RESUME event handler and use it there instead of VIR_DOMAIN_RUNNING_UNPAUSED. Signed-off-by: Jiri Denemark Reviewed-by: John Ferlan --- Notes: Version 2: - no change src/qemu/qemu_domain.h | 4 ++++ src/qemu/qemu_process.c | 23 +++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index ecbe2e8533..461859e37f 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -366,6 +366,10 @@ struct _qemuDomainObjPrivate { =20 /* counter for generating node names for qemu disks */ unsigned long long nodenameindex; + + /* qemuProcessStartCPUs stores the reason for starting vCPUs here for = the + * RESUME event handler to use it */ + virDomainRunningReason runningReason; }; =20 # define QEMU_DOMAIN_PRIVATE(vm) \ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 417e47ec29..f79db1d4cf 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -712,21 +712,28 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_= UNUSED, virQEMUDriverPtr driver =3D opaque; virObjectEventPtr event =3D NULL; virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + qemuDomainObjPrivatePtr priv; + virDomainRunningReason reason =3D VIR_DOMAIN_RUNNING_UNPAUSED; =20 virObjectLock(vm); - if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_PAUSED) { - qemuDomainObjPrivatePtr priv =3D vm->privateData; =20 + priv =3D vm->privateData; + if (priv->runningReason !=3D VIR_DOMAIN_RUNNING_UNKNOWN) { + reason =3D priv->runningReason; + priv->runningReason =3D VIR_DOMAIN_RUNNING_UNKNOWN; + } + + if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_PAUSED) { if (priv->gotShutdown) { VIR_DEBUG("Ignoring RESUME event after SHUTDOWN"); goto unlock; } =20 - VIR_DEBUG("Transitioned guest %s out of paused into resumed state", - vm->def->name); + VIR_DEBUG("Transitioned guest %s out of paused into resumed state,= " + "reason '%s'", + vm->def->name, virDomainRunningReasonTypeToString(reason= )); =20 - virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, - VIR_DOMAIN_RUNNING_UNPAUSED); + virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason); event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_RESUMED, VIR_DOMAIN_EVENT_RESUMED_UNPAUSED= ); @@ -3087,6 +3094,8 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDoma= inObjPtr vm, } VIR_FREE(priv->lockState); =20 + priv->runningReason =3D reason; + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto release; =20 @@ -3104,6 +3113,7 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDoma= inObjPtr vm, return ret; =20 release: + priv->runningReason =3D VIR_DOMAIN_RUNNING_UNKNOWN; if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockStat= e) < 0) VIR_WARN("Unable to release lease on %s", vm->def->name); VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); @@ -5987,6 +5997,7 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver, priv->monError =3D false; priv->monStart =3D 0; priv->gotShutdown =3D false; + priv->runningReason =3D VIR_DOMAIN_RUNNING_UNKNOWN; =20 VIR_DEBUG("Updating guest CPU definition"); if (qemuProcessUpdateGuestCPU(vm->def, priv->qemuCaps, caps, flags) < = 0) --=20 2.19.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 04:15:08 2024 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537881572162559.4439870157288; Tue, 25 Sep 2018 06:19:32 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 17A993082120; Tue, 25 Sep 2018 13:19:30 +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 CFB3819497; Tue, 25 Sep 2018 13:19:29 +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 85436181A13A; Tue, 25 Sep 2018 13:19:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8PDJDWB025498 for ; Tue, 25 Sep 2018 09:19:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 448C22010D9F; Tue, 25 Sep 2018 13:19:13 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 138662010D0A for ; Tue, 25 Sep 2018 13:19:10 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 4B0E01047CB; Tue, 25 Sep 2018 15:19:09 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 25 Sep 2018 15:19:04 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 4/5] qemu: Map running reason to resume event detail 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 25 Sep 2018 13:19:30 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Thanks to the previous commit the RESUME event handler knows what reason should be used when changing the domain state to VIR_DOMAIN_RUNNING, but the emitted VIR_DOMAIN_EVENT_RESUMED event still uses a generic VIR_DOMAIN_EVENT_RESUMED_UNPAUSED detail. Luckily, the event detail can be easily deduced from the running reason, which saves us from having to pass one more value to the handler. Signed-off-by: Jiri Denemark Reviewed-by: John Ferlan --- Notes: Version 2: - no change src/qemu/qemu_domain.c | 29 +++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 3 +++ src/qemu/qemu_process.c | 11 +++++++---- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b20d43059e..939b2a3da2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -13505,3 +13505,32 @@ qemuDomainStorageIdReset(qemuDomainObjPrivatePtr p= riv) { priv->nodenameindex =3D 0; } + + +virDomainEventResumedDetailType +qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason) +{ + switch (reason) { + case VIR_DOMAIN_RUNNING_RESTORED: + case VIR_DOMAIN_RUNNING_FROM_SNAPSHOT: + return VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT; + + case VIR_DOMAIN_RUNNING_MIGRATED: + case VIR_DOMAIN_RUNNING_MIGRATION_CANCELED: + return VIR_DOMAIN_EVENT_RESUMED_MIGRATED; + + case VIR_DOMAIN_RUNNING_POSTCOPY: + return VIR_DOMAIN_EVENT_RESUMED_POSTCOPY; + + case VIR_DOMAIN_RUNNING_UNKNOWN: + case VIR_DOMAIN_RUNNING_SAVE_CANCELED: + case VIR_DOMAIN_RUNNING_BOOTED: + case VIR_DOMAIN_RUNNING_UNPAUSED: + case VIR_DOMAIN_RUNNING_WAKEUP: + case VIR_DOMAIN_RUNNING_CRASHED: + case VIR_DOMAIN_RUNNING_LAST: + break; + } + + return VIR_DOMAIN_EVENT_RESUMED_UNPAUSED; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 461859e37f..2f8a1bf03c 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1082,4 +1082,7 @@ char * qemuDomainGetManagedPRSocketPath(qemuDomainObj= PrivatePtr priv); unsigned int qemuDomainStorageIdNew(qemuDomainObjPrivatePtr priv); void qemuDomainStorageIdReset(qemuDomainObjPrivatePtr priv); =20 +virDomainEventResumedDetailType +qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason); + #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f79db1d4cf..a7d71962da 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -714,6 +714,7 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UN= USED, virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); qemuDomainObjPrivatePtr priv; virDomainRunningReason reason =3D VIR_DOMAIN_RUNNING_UNPAUSED; + virDomainEventResumedDetailType eventDetail; =20 virObjectLock(vm); =20 @@ -729,14 +730,16 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_= UNUSED, goto unlock; } =20 + eventDetail =3D qemuDomainRunningReasonToResumeEvent(reason); VIR_DEBUG("Transitioned guest %s out of paused into resumed state,= " - "reason '%s'", - vm->def->name, virDomainRunningReasonTypeToString(reason= )); + "reason '%s', event detail %d", + vm->def->name, virDomainRunningReasonTypeToString(reason= ), + eventDetail); =20 virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason); event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_RESUMED, - VIR_DOMAIN_EVENT_RESUMED_UNPAUSED= ); + VIR_DOMAIN_EVENT_RESUMED, + eventDetail); =20 if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { VIR_WARN("Unable to save status on vm %s after state change", --=20 2.19.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 04:15:08 2024 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537881582529180.14513824748997; Tue, 25 Sep 2018 06:19:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2290D3002701; Tue, 25 Sep 2018 13:19:39 +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 D9B981852D; Tue, 25 Sep 2018 13:19:38 +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 DC5E84A46C; Tue, 25 Sep 2018 13:19:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8PDJEvv025513 for ; Tue, 25 Sep 2018 09:19:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 59D9610021B2; Tue, 25 Sep 2018 13:19:14 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04D33108131B for ; Tue, 25 Sep 2018 13:19:14 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 4D5811047CD; Tue, 25 Sep 2018 15:19:09 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 25 Sep 2018 15:19:05 +0200 Message-Id: <6cde01d3c1ea2460216adf3b2f766c78fada980a.1537881453.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 5/5] qemu: Avoid duplicate resume events and state changes 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 25 Sep 2018 13:19:39 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The only place where VIR_DOMAIN_EVENT_RESUMED should be generated is the RESUME event handler to make sure we don't generate duplicate events or state changes. In the worse case the duplicity can revert or cover changes done by other event handlers. For example, after QEMU sent RESUME, BLOCK_IO_ERROR, and STOP events we could happily mark the domain as running and report VIR_DOMAIN_EVENT_RESUMED to registered clients. https://bugzilla.redhat.com/show_bug.cgi?id=3D1612943 Signed-off-by: Jiri Denemark --- Notes: Version 2: - keep VIR_DOMAIN_EVENT_RESUMED_MIGRATED event at the end of post-copy migration src/qemu/qemu_driver.c | 13 ----------- src/qemu/qemu_migration.c | 49 ++++++++++++++++----------------------- src/qemu/qemu_process.c | 10 ++++---- 3 files changed, 24 insertions(+), 48 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0c1afbfd4e..126c783a0f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1861,7 +1861,6 @@ static int qemuDomainResume(virDomainPtr dom) virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainObjPtr vm; int ret =3D -1; - virObjectEventPtr event =3D NULL; int state; int reason; virQEMUDriverConfigPtr cfg =3D NULL; @@ -1900,9 +1899,6 @@ static int qemuDomainResume(virDomainPtr dom) "%s", _("resume operation failed")); goto endjob; } - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_RESUMED, - VIR_DOMAIN_EVENT_RESUMED_UNPAUSED= ); } if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) goto endjob; @@ -1913,7 +1909,6 @@ static int qemuDomainResume(virDomainPtr dom) =20 cleanup: virDomainObjEndAPI(&vm); - virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); return ret; } @@ -15983,7 +15978,6 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, virDomainDefPtr config =3D NULL; virQEMUDriverConfigPtr cfg =3D NULL; virCapsPtr caps =3D NULL; - bool was_running =3D false; bool was_stopped =3D false; qemuDomainSaveCookiePtr cookie; virCPUDefPtr origCPU =3D NULL; @@ -16174,7 +16168,6 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, priv =3D vm->privateData; if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { /* Transitions 5, 6 */ - was_running =3D true; if (qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_FROM_SNAPSHOT, QEMU_ASYNC_JOB_START) < 0) @@ -16271,12 +16264,6 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sn= apshot, event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STARTED, detail); - } else if (!was_running) { - /* Transition 8 */ - detail =3D VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT; - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_RESUMED, - detail); } } break; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 825a9d399b..67940330aa 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2982,14 +2982,10 @@ qemuMigrationSrcConfirmPhase(virQEMUDriverPtr drive= r, virFreeError(orig_err); =20 if (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && - reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY) { + reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY) qemuMigrationAnyPostcopyFailed(driver, vm); - } else if (qemuMigrationSrcRestoreDomainState(driver, vm)) { - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_RES= UMED, - VIR_DOMAIN_EVENT_RES= UMED_MIGRATED); - virObjectEventStateQueue(driver->domainEventState, event); - } + else + qemuMigrationSrcRestoreDomainState(driver, vm); =20 qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, priv->job.migParams, priv->job.apiFlags); @@ -4624,11 +4620,7 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver, qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, priv->job.migParams, priv->job.apiFlags); =20 - if (qemuMigrationSrcRestoreDomainState(driver, vm)) { - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_RESUMED, - VIR_DOMAIN_EVENT_RESUMED_MIGRATED= ); - } + qemuMigrationSrcRestoreDomainState(driver, vm); =20 qemuMigrationJobFinish(driver, vm); if (!virDomainObjIsActive(vm) && ret =3D=3D 0) { @@ -4672,7 +4664,6 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver, unsigned long resource) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - virObjectEventPtr event =3D NULL; int ret =3D -1; =20 /* If we didn't start the job in the begin phase, start it now. */ @@ -4694,11 +4685,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver, nmigrate_disks, migrate_disks, mig= Params); =20 if (ret < 0) { - if (qemuMigrationSrcRestoreDomainState(driver, vm)) { - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_RES= UMED, - VIR_DOMAIN_EVENT_RES= UMED_MIGRATED); - } + qemuMigrationSrcRestoreDomainState(driver, vm); goto endjob; } =20 @@ -4722,7 +4709,6 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver, =20 cleanup: virDomainObjEndAPI(&vm); - virObjectEventStateQueue(driver->domainEventState, event); return ret; } =20 @@ -5074,13 +5060,8 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, goto endjob; } =20 - if (inPostCopy) { + if (inPostCopy) doKill =3D false; - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_RESUMED, - VIR_DOMAIN_EVENT_RESUMED_POSTCOPY); - virObjectEventStateQueue(driver->domainEventState, event); - } } =20 if (mig->jobInfo) { @@ -5111,10 +5092,20 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, =20 dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, vm->def->id); =20 - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_RESUMED, - VIR_DOMAIN_EVENT_RESUMED_MIG= RATED); - virObjectEventStateQueue(driver->domainEventState, event); + if (inPostCopy) { + /* The only RESUME event during post-copy migration is triggered by + * QEMU when the running domain moves from the source to the + * destination host, but then the migration keeps running until all + * modified memory is transferred from the source host. This will + * result in VIR_DOMAIN_EVENT_RESUMED with RESUMED_POSTCOPY detail. + * However, our API documentation says we need to fire another RES= UMED + * event at the very end of migration with RESUMED_MIGRATED detail. + */ + event =3D virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_RESUMED, + VIR_DOMAIN_EVENT_RESUMED= _MIGRATED); + virObjectEventStateQueue(driver->domainEventState, event); + } =20 if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_PAUSED) { virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER= ); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index a7d71962da..29b0ba1590 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -456,7 +456,6 @@ qemuProcessFakeReboot(void *opaque) virDomainObjPtr vm =3D opaque; qemuDomainObjPrivatePtr priv =3D vm->privateData; virQEMUDriverPtr driver =3D priv->driver; - virObjectEventPtr event =3D NULL; virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); virDomainRunningReason reason =3D VIR_DOMAIN_RUNNING_BOOTED; int ret =3D -1, rc; @@ -493,9 +492,6 @@ qemuProcessFakeReboot(void *opaque) goto endjob; } priv->gotShutdown =3D false; - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_RESUMED, - VIR_DOMAIN_EVENT_RESUMED_UNPAUSED); =20 if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) { VIR_WARN("Unable to save status on vm %s after state change", @@ -511,7 +507,6 @@ qemuProcessFakeReboot(void *opaque) if (ret =3D=3D -1) ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_FORCE)); virDomainObjEndAPI(&vm); - virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); } =20 @@ -3109,7 +3104,10 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDom= ainObjPtr vm, if (ret < 0) goto release; =20 - virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason); + /* The RESUME event handler will change the domain state with the reas= on + * saved in priv->runningReason and it will also emit corresponding do= main + * lifecycle event. + */ =20 cleanup: virObjectUnref(cfg); --=20 2.19.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list