From nobody Mon Feb 9 00:56:14 2026 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=1623423923; cv=none; d=zohomail.com; s=zohoarc; b=m24NwV3VHaIiIPEyNjD+YuHiY//6gb0ReQ7I9y0nfllrZtxfJUzRbLL2cBguDS/3nrPSb5S9MLteoA9N8eodpYO/4xEtYa7RRF8yKY93bkbxGXbJHQScIXUQE0ljTqDkQ6wxJzOJPO2eI7Yz9OVYWPgxSbBkv3DOt2JdiO+JCHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623423923; 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=I1sdNbaFM2Fy2Hg3TBRHAHPS+sdImV1anETDFQ98SV4=; b=QCMuBZL5/S7e5o9j2oNT06Jf18WiuHtIN8HkkFKIh9+2s/NwV6nERN9bJcCTEZFmx+3KBhm8C2I7x+tqo7NtZdxf3rdDyiMDMWc5s+nQdYNoFmehScAGNazG3r2sYpwiK4XOFfBUi2dKD0LXSCY8pNd/w0CLNcUwNzme/2XCFEA= 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) 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 1623423923199718.4740750956997; Fri, 11 Jun 2021 08:05:23 -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-556-7TQohDPSMeWdSXB0VJSsaw-1; Fri, 11 Jun 2021 11:05:20 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79981100B3B2; Fri, 11 Jun 2021 15:05:16 +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 53C5E5D9C6; Fri, 11 Jun 2021 15:05:16 +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 EA52A46F5E; Fri, 11 Jun 2021 15:05:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15BF5DSF009905 for ; Fri, 11 Jun 2021 11:05:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 690A75D9C6; Fri, 11 Jun 2021 15:05:13 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id E10FD5D9D7 for ; Fri, 11 Jun 2021 15:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623423922; 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=I1sdNbaFM2Fy2Hg3TBRHAHPS+sdImV1anETDFQ98SV4=; b=HX7i3a06bRbBqtyLpkVpq4RC4q+2gLAQZ6XZI73uKx71Uvk9PgsmzZJgIci4VevOoJIvCj qeANUSQ8+1Pnqb2ZYCpPVilAo9W0OiILEEOytjofufIBOu1m6PtNZVn3i6o21/9ner/9MB 2myrTlIsymKeL8bQgTvraW+xkDtkBfs= X-MC-Unique: 7TQohDPSMeWdSXB0VJSsaw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/7] qemuDeviceVideoGetModel: Deduplicate a check Date: Fri, 11 Jun 2021 17:04:56 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.14 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" There is the same check written twice (whether given video card is primary one and whether it supports VGA mode). Write it just once and store it in a boolean variable. Signed-off-by: Michal Privoznik --- src/qemu/qemu_command.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7ca099bb39..9d8e41f4cd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4200,18 +4200,22 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, const virDomainVideoDef *video) { const char *model =3D NULL; + bool primaryVga =3D false; + + if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps)) + primaryVga =3D true; =20 /* We try to chose the best model for primary video device by preferri= ng * model with VGA compatibility mode. For some video devices on some * architectures there might not be such model so fallback to one * without VGA compatibility mode. */ if (video->backend =3D=3D VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { - if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps)) + if (primaryVga) model =3D "vhost-user-vga"; else model =3D "vhost-user-gpu"; } else { - if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps)) + if (primaryVga) model =3D qemuDeviceVideoTypeToString(video->type); else model =3D qemuDeviceVideoSecondaryTypeToString(video->type); --=20 2.31.1