From nobody Mon Feb 9 03:29:11 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=1633622565; cv=none; d=zohomail.com; s=zohoarc; b=crslOlNipnb/N8/xXuuvnmIN/gdIPZYLchOZKh9UJjIhCXTbrPHFdCrq0EY7M43V2KaBX4uNyAEgVKyigfqoKkBpy98cwBXZmNo1g93Zzap/O8AI8Uq1hVrsQHaJNjHjhjrjGRqV/uSHnSgYyTnjP/R0TV6+toMqN+btBnXmGwA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633622565; 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=k9cPMo/gaYAIss4Apac8WwSoVOLjBjVuBCYfoZxauUk=; b=gZ3rXNRbh3sVbqS+mGk/T8OcHL3hXEeW7GWdQwE7/HWY2Hm4WiimqCyHlxFc4htAz0Y7YkH/Wfkx5ROKrZEI/hhLeQFUv6diQEPc5Q7+gIQte8jcVNDP9W6LySN+Cru5Jy2MRUgVqucn37PNssVoZvVtExdcfFaKvJXOHkVmDCE= 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 1633622565698665.2505618360453; Thu, 7 Oct 2021 09:02:45 -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-456-sNqbFjNqOO6m7X6G1Bw1YA-1; Thu, 07 Oct 2021 12:02:41 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8649D1125523; Thu, 7 Oct 2021 15:44:52 +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 6349B12076D; Thu, 7 Oct 2021 15:44:52 +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 2D0B21800B8B; Thu, 7 Oct 2021 15:44:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 197FJGh9023886 for ; Thu, 7 Oct 2021 11:19:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id D5ABA5D6D5; Thu, 7 Oct 2021 15:19:16 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BAA25D6BA for ; Thu, 7 Oct 2021 15:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633622564; 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=k9cPMo/gaYAIss4Apac8WwSoVOLjBjVuBCYfoZxauUk=; b=HvOIVIgFemsdZ+EklUVAEBPjYWY9iHhFZpzgTmzHxPuHVpziR7+yTveih6GJrTgyLL6gmU pXI1qn98df3l1SSWR5arAa5gvdM/t/jfML0uUXWgA/4pIyIUH65Flp0yDtMKXBh0hNPKQP oUIOIjFNX+WM35hmjrKGABI0AyXZj/A= X-MC-Unique: sNqbFjNqOO6m7X6G1Bw1YA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 038/103] qemuDeviceVideoGetModel: Move to the beginning Date: Thu, 7 Oct 2021 17:17:26 +0200 Message-Id: <8486d4dfcb51fdb4ea0f52a973251de3529082ac.1633619630.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.16 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: 1633622567133100001 Content-Type: text/plain; charset="utf-8" The function is static and will be needed in the virtio device config helper. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 248 ++++++++++++++++++++-------------------- 1 file changed, 124 insertions(+), 124 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3c468ab0a4..e86c3bda22 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -583,6 +583,130 @@ qemuBuildDeviceAddressProps(virJSONValue *props, } +/** + * qemuDeviceVideoGetModel: + * @qemuCaps: qemu capabilities + * @video: video device definition + * @virtio: the returned video device is a 'virtio' device + * @virtioBusSuffix: the returned device needs to get the bus-suffix + * + * Returns the model fo the device for @video and @qemuCaps. @virtio and + * @virtioBusSuffix are filled with the corresponding flags. + */ +static const char * +qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, + const virDomainVideoDef *video, + bool *virtio, + bool *virtioBusSuffix) +{ + const char *model =3D NULL; + bool primaryVga =3D false; + virTristateSwitch accel3d =3D VIR_TRISTATE_SWITCH_ABSENT; + + *virtio =3D false; + *virtioBusSuffix =3D false; + + if (video->accel) + accel3d =3D video->accel->accel3d; + + if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps)) + primaryVga =3D true; + + /* 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 (primaryVga) { + model =3D "vhost-user-vga"; + } else { + model =3D "vhost-user-gpu"; + *virtio =3D true; + *virtioBusSuffix =3D true; + } + } else { + if (primaryVga) { + switch ((virDomainVideoType) video->type) { + case VIR_DOMAIN_VIDEO_TYPE_VGA: + model =3D "VGA"; + break; + case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: + model =3D "cirrus-vga"; + break; + case VIR_DOMAIN_VIDEO_TYPE_VMVGA: + model =3D "vmware-svga"; + break; + case VIR_DOMAIN_VIDEO_TYPE_QXL: + model =3D "qxl-vga"; + break; + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_VGA_GL) && + accel3d =3D=3D VIR_TRISTATE_SWITCH_ON) + model =3D "virtio-vga-gl"; + else + model =3D "virtio-vga"; + + *virtio =3D true; + *virtioBusSuffix =3D false; + break; + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + model =3D "bochs-display"; + break; + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: + model =3D "ramfb"; + break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: + case VIR_DOMAIN_VIDEO_TYPE_XEN: + case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_LAST: + break; + } + } else { + switch ((virDomainVideoType) video->type) { + case VIR_DOMAIN_VIDEO_TYPE_QXL: + model =3D "qxl"; + break; + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) = && + accel3d =3D=3D VIR_TRISTATE_SWITCH_ON) + model =3D "virtio-gpu-gl"; + else + model =3D "virtio-gpu"; + + *virtio =3D true; + *virtioBusSuffix =3D true; + break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: + case VIR_DOMAIN_VIDEO_TYPE_VGA: + case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: + case VIR_DOMAIN_VIDEO_TYPE_VMVGA: + case VIR_DOMAIN_VIDEO_TYPE_XEN: + case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: + case VIR_DOMAIN_VIDEO_TYPE_LAST: + break; + } + } + } + + if (!model || STREQ(model, "")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid model for video type '%s'"), + virDomainVideoTypeToString(video->type)); + return NULL; + } + + return model; +} + + static void qemuBuildVirtioDevGetConfigDev(virDomainDeviceDef *device, bool *has_tmodel, @@ -4291,130 +4415,6 @@ qemuBuildSoundCommandLine(virCommand *cmd, } -/** - * qemuDeviceVideoGetModel: - * @qemuCaps: qemu capabilities - * @video: video device definition - * @virtio: the returned video device is a 'virtio' device - * @virtioBusSuffix: the returned device needs to get the bus-suffix - * - * Returns the model fo the device for @video and @qemuCaps. @virtio and - * @virtioBusSuffix are filled with the corresponding flags. - */ -static const char * -qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, - const virDomainVideoDef *video, - bool *virtio, - bool *virtioBusSuffix) -{ - const char *model =3D NULL; - bool primaryVga =3D false; - virTristateSwitch accel3d =3D VIR_TRISTATE_SWITCH_ABSENT; - - *virtio =3D false; - *virtioBusSuffix =3D false; - - if (video->accel) - accel3d =3D video->accel->accel3d; - - if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps)) - primaryVga =3D true; - - /* 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 (primaryVga) { - model =3D "vhost-user-vga"; - } else { - model =3D "vhost-user-gpu"; - *virtio =3D true; - *virtioBusSuffix =3D true; - } - } else { - if (primaryVga) { - switch ((virDomainVideoType) video->type) { - case VIR_DOMAIN_VIDEO_TYPE_VGA: - model =3D "VGA"; - break; - case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: - model =3D "cirrus-vga"; - break; - case VIR_DOMAIN_VIDEO_TYPE_VMVGA: - model =3D "vmware-svga"; - break; - case VIR_DOMAIN_VIDEO_TYPE_QXL: - model =3D "qxl-vga"; - break; - case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_VGA_GL) && - accel3d =3D=3D VIR_TRISTATE_SWITCH_ON) - model =3D "virtio-vga-gl"; - else - model =3D "virtio-vga"; - - *virtio =3D true; - *virtioBusSuffix =3D false; - break; - case VIR_DOMAIN_VIDEO_TYPE_BOCHS: - model =3D "bochs-display"; - break; - case VIR_DOMAIN_VIDEO_TYPE_RAMFB: - model =3D "ramfb"; - break; - case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: - case VIR_DOMAIN_VIDEO_TYPE_XEN: - case VIR_DOMAIN_VIDEO_TYPE_VBOX: - case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: - case VIR_DOMAIN_VIDEO_TYPE_GOP: - case VIR_DOMAIN_VIDEO_TYPE_NONE: - case VIR_DOMAIN_VIDEO_TYPE_LAST: - break; - } - } else { - switch ((virDomainVideoType) video->type) { - case VIR_DOMAIN_VIDEO_TYPE_QXL: - model =3D "qxl"; - break; - case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) = && - accel3d =3D=3D VIR_TRISTATE_SWITCH_ON) - model =3D "virtio-gpu-gl"; - else - model =3D "virtio-gpu"; - - *virtio =3D true; - *virtioBusSuffix =3D true; - break; - case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: - case VIR_DOMAIN_VIDEO_TYPE_VGA: - case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: - case VIR_DOMAIN_VIDEO_TYPE_VMVGA: - case VIR_DOMAIN_VIDEO_TYPE_XEN: - case VIR_DOMAIN_VIDEO_TYPE_VBOX: - case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: - case VIR_DOMAIN_VIDEO_TYPE_GOP: - case VIR_DOMAIN_VIDEO_TYPE_NONE: - case VIR_DOMAIN_VIDEO_TYPE_BOCHS: - case VIR_DOMAIN_VIDEO_TYPE_RAMFB: - case VIR_DOMAIN_VIDEO_TYPE_LAST: - break; - } - } - } - - if (!model || STREQ(model, "")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid model for video type '%s'"), - virDomainVideoTypeToString(video->type)); - return NULL; - } - - return model; -} - - static char * qemuBuildDeviceVideoStr(const virDomainDef *def, virDomainVideoDef *video, --=20 2.31.1