From nobody Fri May 3 11:15:04 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=1627289880; cv=none; d=zohomail.com; s=zohoarc; b=dsAaQ1M6S4Szv+TaqUELbUzYLGjBbAeK8Lqh6L0LQo9sl61gRYT/Mh3RDTih0pv9vVZOPZnj2vYH/ektBwaqpd7yGf3Bi5FpfZ4BiQT/KfLixUT1yeLi3UjBcpS5lXDZ3UVkKQE87PHA9y0TnBeosUTW52Io6fNhR/Sxs6Qj5Wc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627289880; 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=C4KVl8tmMWnMiE3c+010lpYgO4n5l4d3pbMrHKmCQyU=; b=BGxZ1gcOiWd3uc9nyYDYRUKnw1QOakZu89az42uTbLbr21ONEY2acLN6oobrGxUZkEcTPnXu19ce0GHJLds1hyvSZnhP4tXIkEoapripLJRXgTmqz8rTjCGP855AjP3oX/4MWfrSxzwrOMCOck11hcrWq5m+DWgRVyUVxazRR6g= 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) 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 1627289880408971.1554513716212; Mon, 26 Jul 2021 01:58:00 -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-167-Wv02vZeQOAyrfK1gb2pnDQ-1; Mon, 26 Jul 2021 04:57:57 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 83FD710066E7; Mon, 26 Jul 2021 08:57:52 +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 F38FB100F49F; Mon, 26 Jul 2021 08:57:51 +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 C78F74BB7B; Mon, 26 Jul 2021 08:57:49 +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 16Q8mLG6031458 for ; Mon, 26 Jul 2021 04:48:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0AA1F18A9E; Mon, 26 Jul 2021 08:48:21 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67CF869CBA for ; Mon, 26 Jul 2021 08:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627289879; 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=C4KVl8tmMWnMiE3c+010lpYgO4n5l4d3pbMrHKmCQyU=; b=RLQ8d+OXSCFQ2fdxazJ+luG3pcJ7K68hWWdpuAc8JC/7G9nigqyVTy/ZnJGYn02l8RH0w8 WSC5NeYPrOYSkXkQnhC6jf1Ugt4AFznd4pWylSWwOPrqo+YCltqvdRXiGh+50NxpF0AHMc zJim/0Ykhc6TgqBVnKGcuKRoVR8S01U= X-MC-Unique: Wv02vZeQOAyrfK1gb2pnDQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 1/2] qemu: process: Ignore 'RESET' event during startup Date: Mon, 26 Jul 2021 10:48:13 +0200 Message-Id: <8dd9b905b902ed9520049663d9e1532b40c4523e.1627289212.git.pkrempa@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 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.84 on 10.5.11.22 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) X-ZM-MESSAGEID: 1627289881514100002 Content-Type: text/plain; charset="utf-8" In cases when we are adding a disk with sharing backend (and thus hotplugging it) we need to re-initialize ACPI tables so that the VM boots from the correct device. This has a side-effect of emitting the RESET event and handling it which in case when the 'on_reset' policy is set leads to an attempt to obtain a domain job lock which is already held and needing to wait for a timeout. Fix this by ignoring RESET events during startup of the VM. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_process.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 521fda57da..f8581fa462 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -429,12 +429,24 @@ qemuProcessHandleReset(qemuMonitor *mon G_GNUC_UNUSED, void *opaque) { virQEMUDriver *driver =3D opaque; - virObjectEvent *event; + virObjectEvent *event =3D NULL; qemuDomainObjPrivate *priv; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + virDomainState state; + int reason; virObjectLock(vm); + state =3D virDomainObjGetState(vm, &reason); + + /* ignore reset events on VM startup. Libvirt in certain instances doe= s a + * reset during startup so that the ACPI tables are re-generated */ + if (state =3D=3D VIR_DOMAIN_PAUSED && + reason =3D=3D VIR_DOMAIN_PAUSED_STARTING_UP) { + VIR_DEBUG("ignoring reset event during startup"); + goto cleanup; + } + event =3D virDomainEventRebootNewFromObj(vm); priv =3D vm->privateData; if (priv->agent) --=20 2.31.1 From nobody Fri May 3 11:15:04 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=1627289893; cv=none; d=zohomail.com; s=zohoarc; b=MWYTG9Hy+SMnN16PocDOlx6nLI2BjuBNxq/wCnZv/w6tAJh9zooP1dyeNl4L5wveAWvcwGIutLHZqyhjeZ1LB0LOTdNSYt5JlQTPaMT9igqS7m25rmncWDeTNpoNbgUXFJiqQRJse/uWv/RK1/XUdgvanR8len/EK05P9CFatuc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627289893; 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=EZe1l+8+AAnzZirFcmpqVfYNSXLpXzrilXXsC/vkBvc=; b=nbe5uITf5A76GnVMgyvs1qv+mbpA2ELKpmqMWHtMtsdHUA1v63qC3aLAN2cfrA+AvN5nniwfEcywQSpamhLFv1Or7khLLl8LiOwqzeTDMHez44UHGd7Ls7yhvittToUsgW6q2to0srDfEwkvAjEEQ3pItB8NN9lNP7rvjGtJxDw= 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) 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 162728989392141.6683743956645; Mon, 26 Jul 2021 01:58:13 -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-187-lbajmTVKPA6czWNqDUzFww-1; Mon, 26 Jul 2021 04:58:10 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 486451074664; Mon, 26 Jul 2021 08:58:05 +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 EB8DD6A8F8; Mon, 26 Jul 2021 08:58:04 +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 B26494A7CA; Mon, 26 Jul 2021 08:58:04 +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 16Q8mMIc031464 for ; Mon, 26 Jul 2021 04:48:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1C3EC19811; Mon, 26 Jul 2021 08:48:22 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7226818A9E for ; Mon, 26 Jul 2021 08:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627289892; 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=EZe1l+8+AAnzZirFcmpqVfYNSXLpXzrilXXsC/vkBvc=; b=hvpYyjkcszWypRFBbQ9tW8VvVp8nXFc8omdM9mnBf0WMfOjqZHqGtW5kr5wcUZYyyW+nbM +n4Y+pcwkFefUMQYaebszIzt2YS0K4C2kfKNGWsDDNK4jmklPG1leoOTfaNVW+g66MZamB oy9l109xASYYya+ug6sRSZYZTuBJIdU= X-MC-Unique: lbajmTVKPA6czWNqDUzFww-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 2/2] qemu: process: Ignore 'SHUTDOWN' event during startup Date: Mon, 26 Jul 2021 10:48:14 +0200 Message-Id: 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 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.15 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) X-ZM-MESSAGEID: 1627289894450100001 Content-Type: text/plain; charset="utf-8" In cases when we are adding a disk with sharing backend (and thus hotplugging it) we need to re-initialize ACPI tables so that the VM boots from the correct device. In case of 'aarch64' this has a side-effect of emitting the SHUTDOWN event with a 'host-qmp-system-reset' reason instead of a RESET event which can lead to killing of the qemu process on startup. Fix this by ignoring SHUTDOWN events during startup of the VM. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_process.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f8581fa462..ace413fbdf 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -612,14 +612,18 @@ qemuProcessHandleShutdown(qemuMonitor *mon G_GNUC_UNU= SED, qemuDomainObjPrivate *priv; virObjectEvent *event =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + virDomainState state; + int reason; int detail =3D 0; VIR_DEBUG("vm=3D%p", vm); virObjectLock(vm); + state =3D virDomainObjGetState(vm, &reason); + priv =3D vm->privateData; - if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_SHUTDOWN) { + if (state =3D=3D VIR_DOMAIN_SHUTDOWN) { VIR_DEBUG("Ignoring repeated SHUTDOWN event from domain %s", vm->def->name); goto unlock; @@ -627,6 +631,13 @@ qemuProcessHandleShutdown(qemuMonitor *mon G_GNUC_UNUS= ED, VIR_DEBUG("Ignoring SHUTDOWN event from inactive domain %s", vm->def->name); goto unlock; + } else if (state =3D=3D VIR_DOMAIN_PAUSED && + reason =3D=3D VIR_DOMAIN_PAUSED_STARTING_UP) { + /* aarch64 emits a SHUTDOWN instead of a reset when 'system_reset'= is + * invoked during startup. In certain cases we force a reset during + * startup so that firmware picks up hotplugged devices */ + VIR_DEBUG("ignoring shutdown event during startup"); + goto unlock; } /* In case of fake reboot qemu shutdown state is transient so don't --=20 2.31.1