From nobody Sat Nov 23 17:48:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1724771362383273.10759011793846; Tue, 27 Aug 2024 08:09:22 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 5B7FA11CC; Tue, 27 Aug 2024 11:09:21 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1D5A0126C; Tue, 27 Aug 2024 11:08:27 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7D5A1CCB; Tue, 27 Aug 2024 11:08:22 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 0B3B0DDF for ; Tue, 27 Aug 2024 11:08:22 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-QRw9CYEnNeq5pZOzEJqeFw-1; Tue, 27 Aug 2024 11:08:20 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B5CB21955D52 for ; Tue, 27 Aug 2024 15:08:19 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.225.149]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C889E19560A3 for ; Tue, 27 Aug 2024 15:08:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724771301; h=from:from: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; bh=tmQ2W429rO5frp3Op+jXO+5jonAIGYeUlRf8JpiO2HI=; b=YtLzPK/q9utqIGibJR0VAZY6xKeVcLlRFW1YT4qVloaEoP/f8yHw6FI1PHsY81d7xzLXWl zW4jfzv9WtbmrPDQydVrszhPURzWFN1kMQtcKfDyVtzgE8DiYWSDF1bJ8XMM+2ZTp+H+ax zExUD3+lEq1wMG/eSiBiRy1C3NuoTAw= X-MC-Unique: QRw9CYEnNeq5pZOzEJqeFw-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH 2/4] qemu: Refactor default panic model Date: Tue, 27 Aug 2024 17:08:11 +0200 Message-ID: <20240827150813.317166-3-abologna@redhat.com> In-Reply-To: <20240827150813.317166-1-abologna@redhat.com> References: <20240827150813.317166-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BZ3QFVHK5KLIWHKVOTSU5ZDAIZIXGOWI X-Message-ID-Hash: BZ3QFVHK5KLIWHKVOTSU5ZDAIZIXGOWI X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1724771364211116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Perform decisions based on the architecture and machine type in a single place instead of duplicating them. This technically adds new behavior for MODEL_ISA in qemuDomainDefAddDefaultDevices(), but it doesn't make any difference functionally since we don't set addPanicDevice outside of ppc64(le) and s390(x). If we did, the lack of handling for that value would be a latent bug. Signed-off-by: Andrea Bolognani --- src/qemu/qemu_domain.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d1767c326d..e460e48fce 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4150,6 +4150,19 @@ qemuDomainGetSCSIControllerModel(const virDomainDef = *def, } =20 =20 +static virDomainPanicModel +qemuDomainDefaultPanicModel(const virDomainDef *def) +{ + if (qemuDomainIsPSeries(def)) + return VIR_DOMAIN_PANIC_MODEL_PSERIES; + + if (ARCH_IS_S390(def->os.arch)) + return VIR_DOMAIN_PANIC_MODEL_S390; + + return VIR_DOMAIN_PANIC_MODEL_ISA; +} + + static int qemuDomainDefAddDefaultDevices(virQEMUDriver *driver, virDomainDef *def, @@ -4397,13 +4410,12 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *drive= r, return -1; =20 if (addPanicDevice) { + virDomainPanicModel defaultModel =3D qemuDomainDefaultPanicModel(d= ef); size_t j; + for (j =3D 0; j < def->npanics; j++) { if (def->panics[j]->model =3D=3D VIR_DOMAIN_PANIC_MODEL_DEFAUL= T || - (ARCH_IS_PPC64(def->os.arch) && - def->panics[j]->model =3D=3D VIR_DOMAIN_PANIC_MODEL_P= SERIES) || - (ARCH_IS_S390(def->os.arch) && - def->panics[j]->model =3D=3D VIR_DOMAIN_PANIC_MODEL_S= 390)) + def->panics[j]->model =3D=3D defaultModel) break; } =20 @@ -6100,14 +6112,8 @@ static int qemuDomainDevicePanicDefPostParse(virDomainPanicDef *panic, const virDomainDef *def) { - if (panic->model =3D=3D VIR_DOMAIN_PANIC_MODEL_DEFAULT) { - if (qemuDomainIsPSeries(def)) - panic->model =3D VIR_DOMAIN_PANIC_MODEL_PSERIES; - else if (ARCH_IS_S390(def->os.arch)) - panic->model =3D VIR_DOMAIN_PANIC_MODEL_S390; - else - panic->model =3D VIR_DOMAIN_PANIC_MODEL_ISA; - } + if (panic->model =3D=3D VIR_DOMAIN_PANIC_MODEL_DEFAULT) + panic->model =3D qemuDomainDefaultPanicModel(def); =20 return 0; } --=20 2.46.0