From nobody Fri May 3 08:29:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602075553; cv=none; d=zohomail.com; s=zohoarc; b=HnBVKe21aRlcbVW5J+mFSVUdklYlUX8kTlTkAUEbWmRQmZJXlcrINeomk6AwOtgInHzlYaK1QtsNNIu69mUWV9urPEGxSxFblFbDj/zGq9UE2u2izNVcUVq8CWjM4t2KypZ+XpoUhjCwIDlQylaj0zXHdKGr57Y7mShnVJNAoFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602075553; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=mU2FmNEDe5x0Dh5OSBgJAAzj/LoYm01T9kk15FtNtFw=; b=n81tzC7BLi8DrpiWhSm6NmvRTrwfbuNBTzVPglW00MI1NJgdoynqJERCh0PD3lR8dlk5l2PWGoxNTg9IvO5ySZ4CwjLlOixlb//HBSRzGwz1N81b/zDcRMqmNdKCTeb8jRSw//yEK90/PaytfS0IlMsFHtRMOtHHP1N9LIQ78eA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602075553351388.82817698260124; Wed, 7 Oct 2020 05:59: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-408-2XsEW98fPC62FLAuA3U5Ww-1; Wed, 07 Oct 2020 08:59: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 E22741021206; Wed, 7 Oct 2020 12:59:04 +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 A78B875125; Wed, 7 Oct 2020 12:59: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 EA1588C7AB; Wed, 7 Oct 2020 12:59:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097Cx2ZW015336 for ; Wed, 7 Oct 2020 08:59:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 07D66115D36E; Wed, 7 Oct 2020 12:59:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 03783115D36C for ; Wed, 7 Oct 2020 12:58:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D900889069 for ; Wed, 7 Oct 2020 12:58:59 +0000 (UTC) Received: from know-smtprelay-omc-11.server.virginmedia.net (know-smtprelay-omc-11.server.virginmedia.net [80.0.253.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-169-yNz5dkZqMuqDZmcb6pwkQA-1; Wed, 07 Oct 2020 08:58:56 -0400 Received: from mail.snewbury.org.uk ([86.24.188.28]) by cmsmtp with ESMTPA id Q91zkWecsNqd7Q91zkryoO; Wed, 07 Oct 2020 13:58:55 +0100 Received: from artifact.access.snewbury.org.uk ([IPv6:2001:470:6efd:f101:0:0:0:a58]) by mail.snewbury.org.uk (8.16.1/8.16.1) with ESMTP id 097Cuc8d1499686; Wed, 7 Oct 2020 13:56:38 +0100 X-MC-Unique: 2XsEW98fPC62FLAuA3U5Ww-1 X-MC-Unique: yNz5dkZqMuqDZmcb6pwkQA-1 X-Originating-IP: [86.24.188.28] X-Authenticated-User: sjnewbury@virginmedia.com X-Authority: v=2.3 cv=bvv4+3Si c=1 sm=1 tr=0 a=1Au+4VMCrm8g9YIHxruHCQ==:117 a=1Au+4VMCrm8g9YIHxruHCQ==:17 a=xqWC_Br6kY4A:10 a=afefHYAZSVUA:10 a=N1CowNylAAAA:8 a=crgbwLlIpGce1EEbGOwA:9 a=5cC0sqNPQM5x3hWo:21 a=4UL0ZW1zFVAL4JW9:21 a=sPYuha5Ws6K-Rx_L469D:22 X-Virus-Scanned: amavisd-new at snewbury.org.uk From: Steven Newbury To: libvir-list@redhat.com Subject: [PATCH] Support x-vga=on for PCI host passthrough devices Date: Wed, 7 Oct 2020 13:59:35 +0100 Message-Id: <20201007125935.225038-1-steve@snewbury.org.uk> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfOA26slN8nSLLXWZz6kkTma876VNh5OBipnoU875CeEEO/UthZZuWbDNp00PJnV2uEzIF1ZyDi5oK/miykUoWKcWvpXagt12hXkHqTlGsofr0IrZgUhb 9XdBiv/YARTWCGeD0gxE8x5yNfLqcoWrr4rcCylRBQX1xDsYQAMHQAX6Grr0msGqMCiY+xxzjqm0zg== X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Steven Newbury 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 Content-Type: text/plain; charset="utf-8" When using a passthrough GPU with libvirt there is no option to pass "x-vga=3Don" to the device specification. This means legacy VGA support isn't available which prevents any non-UEFI cards from POSTing and prevents some drivers from initialising for example Windows 10 NVIDIA driver for GeForce 8800. Signed-off-by: Steven Newbury --- src/conf/device_conf.c | 9 +++++++++ src/conf/domain_conf.c | 4 ++++ src/qemu/qemu_capabilities.c | 1 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 4 ++++ src/util/virpci.h | 1 + tools/virsh-domain.c | 6 ++++++ 7 files changed, 26 insertions(+) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 87bf32bbc6..02d226747e 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -215,6 +215,7 @@ virPCIDeviceAddressParseXML(xmlNodePtr node, g_autofree char *slot =3D virXMLPropString(node, "slot"); g_autofree char *function =3D virXMLPropString(node, "function"); g_autofree char *multi =3D virXMLPropString(node, "multifunction"); + g_autofree char *vga =3D virXMLPropString(node, "vga"); =20 memset(addr, 0, sizeof(*addr)); =20 @@ -253,6 +254,14 @@ virPCIDeviceAddressParseXML(xmlNodePtr node, multi); return -1; =20 + } + if (vga && + ((addr->vga =3D virTristateSwitchTypeFromString(vga)) <=3D 0)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown value '%s' for
'vga' attribute= "), + vga); + return -1; + } if (!virPCIDeviceAddressIsEmpty(addr) && !virPCIDeviceAddressIsValid(a= ddr, true)) return -1; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c003b5c030..048b0f4028 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7587,6 +7587,10 @@ virDomainDeviceInfoFormat(virBufferPtr buf, virBufferAsprintf(&attrBuf, " multifunction=3D'%s'", virTristateSwitchTypeToString(info->addr.pci= .multi)); } + if (info->addr.pci.vga) { + virBufferAsprintf(&attrBuf, " vga=3D'%s'", + virTristateSwitchTypeToString(info->addr.pci= .vga)); + } =20 if (virZPCIDeviceAddressIsPresent(&info->addr.pci.zpci)) { virBufferAsprintf(&childBuf, diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 38b901a6c4..b2864c1e9b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -600,6 +600,7 @@ VIR_ENUM_IMPL(virQEMUCaps, =20 /* 380 */ "usb-host.hostdevice", + "pci-vga", ); =20 =20 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 107056ba17..d2d456fc43 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -580,6 +580,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ =20 /* 380 */ QEMU_CAPS_USB_HOST_HOSTDEVICE, /* -device usb-host.hostdevice */ + X_QEMU_CAPS_PCI_VGA, /* -device x-vga=3Don|off */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 476cf6972e..b4285425ed 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -350,6 +350,10 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, virBufferAddLit(buf, ",multifunction=3Don"); else if (info->addr.pci.multi =3D=3D VIR_TRISTATE_SWITCH_OFF) virBufferAddLit(buf, ",multifunction=3Doff"); + if (info->addr.pci.vga =3D=3D VIR_TRISTATE_SWITCH_ON) + virBufferAddLit(buf, ",x-vga=3Don"); + else if (info->addr.pci.vga =3D=3D VIR_TRISTATE_SWITCH_OFF) + virBufferAddLit(buf, ",x-vga=3Doff"); virBufferAsprintf(buf, ",addr=3D0x%x", info->addr.pci.slot); if (info->addr.pci.function !=3D 0) virBufferAsprintf(buf, ".0x%x", info->addr.pci.function); diff --git a/src/util/virpci.h b/src/util/virpci.h index b3322ba61b..1ec2e3ba34 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -61,6 +61,7 @@ struct _virPCIDeviceAddress { unsigned int slot; unsigned int function; int multi; /* virTristateSwitch */ + int vga; /* virTristateSwitch */ int extFlags; /* enum virPCIDeviceAddressExtensionFlags */ virZPCIDeviceAddress zpci; /* Don't forget to update virPCIDeviceAddressCopy if needed. */ diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 8f11393197..587efbdb2a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -294,6 +294,10 @@ static const vshCmdOptDef opts_attach_disk[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("use multifunction pci under specified address") }, + {.name =3D "vga", + .type =3D VSH_OT_BOOL, + .help =3D N_("enable legacy VGA") + }, {.name =3D "print-xml", .type =3D VSH_OT_BOOL, .help =3D N_("print XML document rather than attach the disk") @@ -694,6 +698,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) diskAddr.addr.pci.slot, diskAddr.addr.pc= i.function); if (vshCommandOptBool(cmd, "multifunction")) virBufferAddLit(&buf, " multifunction=3D'on'"); + if (vshCommandOptBool(cmd, "vga")) + virBufferAddLit(&buf, " vga=3D'on'"); virBufferAddLit(&buf, "/>\n"); } else if (diskAddr.type =3D=3D DISK_ADDR_TYPE_CCW) { virBufferAsprintf(&buf, --=20 2.28.0