mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-21 21:25:25 +00:00
qemu: enable display/ramfb for vfio pci hostdevs
Implement display="on" and ramfb="on" for vfio PCI host devices in qemu. This enables passthrough PCI devices for display just like we did for mdevs. Resolves: https://issues.redhat.com/browse/RHEL-28808 Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
092f933a62
commit
21af003084
@ -4735,10 +4735,16 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def,
|
||||
virDomainNetTeamingInfo *teaming;
|
||||
g_autofree char *host = virPCIDeviceAddressAsString(&pcisrc->addr);
|
||||
const char *failover_pair_id = NULL;
|
||||
const char *driver = NULL;
|
||||
|
||||
/* caller has to assign proper passthrough driver name */
|
||||
switch (pcisrc->driver.name) {
|
||||
case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO:
|
||||
/* ramfb support requires the nohotplug variant */
|
||||
if (pcisrc->ramfb == VIR_TRISTATE_SWITCH_ON)
|
||||
driver = "vfio-pci-nohotplug";
|
||||
else
|
||||
driver = "vfio-pci";
|
||||
break;
|
||||
|
||||
case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM:
|
||||
@ -4762,11 +4768,13 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def,
|
||||
failover_pair_id = teaming->persistent;
|
||||
|
||||
if (virJSONValueObjectAdd(&props,
|
||||
"s:driver", "vfio-pci",
|
||||
"s:driver", driver,
|
||||
"s:host", host,
|
||||
"s:id", dev->info->alias,
|
||||
"p:bootindex", dev->info->effectiveBootIndex,
|
||||
"S:failover_pair_id", failover_pair_id,
|
||||
"S:display", qemuOnOffAuto(pcisrc->display),
|
||||
"B:ramfb", pcisrc->ramfb,
|
||||
NULL) < 0)
|
||||
return NULL;
|
||||
|
||||
|
@ -2478,6 +2478,14 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHostdevDef *hostdev,
|
||||
_("Write filtering of PCI device configuration space is not supported by qemu"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (hostdev->source.subsys.u.pci.display == VIR_TRISTATE_SWITCH_ON) {
|
||||
if (def->ngraphics == 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("graphics device is needed for attribute value 'display=on' in <hostdev>"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
|
||||
|
@ -0,0 +1,33 @@
|
||||
LC_ALL=C \
|
||||
PATH=/bin \
|
||||
HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest2 \
|
||||
USER=test \
|
||||
LOGNAME=test \
|
||||
XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest2/.local/share \
|
||||
XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest2/.cache \
|
||||
XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest2/.config \
|
||||
/usr/bin/qemu-system-x86_64 \
|
||||
-name guest=QEMUGuest2,debug-threads=on \
|
||||
-S \
|
||||
-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest2/master-key.aes"}' \
|
||||
-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
|
||||
-accel tcg \
|
||||
-cpu qemu64 \
|
||||
-m size=219136k \
|
||||
-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
|
||||
-overcommit mem-lock=off \
|
||||
-smp 1,sockets=1,cores=1,threads=1 \
|
||||
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
|
||||
-no-user-config \
|
||||
-nodefaults \
|
||||
-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
|
||||
-mon chardev=charmonitor,id=monitor,mode=control \
|
||||
-rtc base=utc \
|
||||
-no-shutdown \
|
||||
-boot strict=on \
|
||||
-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
|
||||
-audiodev '{"id":"audio1","driver":"none"}' \
|
||||
-vnc 127.0.0.1:0,audiodev=audio1 \
|
||||
-device '{"driver":"vfio-pci-nohotplug","host":"0000:06:12.5","id":"hostdev0","display":"on","ramfb":true,"bus":"pci.0","addr":"0x2"}' \
|
||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
|
||||
-msg timestamp=on
|
@ -0,0 +1,44 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest2</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219136</memory>
|
||||
<currentMemory unit='KiB'>219136</currentMemory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<cpu mode='custom' match='exact' check='none'>
|
||||
<model fallback='forbid'>qemu64</model>
|
||||
</cpu>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<controller type='usb' index='0' model='piix3-uhci'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
||||
</controller>
|
||||
<controller type='pci' index='0' model='pci-root'/>
|
||||
<controller type='ide' index='0'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||
</controller>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<input type='keyboard' bus='ps2'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes'>
|
||||
<listen type='address'/>
|
||||
</graphics>
|
||||
<audio id='1' type='none'/>
|
||||
<video>
|
||||
<model type='none'/>
|
||||
</video>
|
||||
<hostdev mode='subsystem' type='pci' managed='no' display='on' ramfb='on'>
|
||||
<source>
|
||||
<address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/>
|
||||
</source>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
||||
</hostdev>
|
||||
<memballoon model='none'/>
|
||||
</devices>
|
||||
</domain>
|
33
tests/qemuxmlconfdata/hostdev-pci-display-ramfb.xml
Normal file
33
tests/qemuxmlconfdata/hostdev-pci-display-ramfb.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest2</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219136</memory>
|
||||
<currentMemory unit='KiB'>219136</currentMemory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<controller type='usb' index='0'>
|
||||
</controller>
|
||||
<controller type='pci' index='0' model='pci-root'/>
|
||||
<controller type='ide' index='0'>
|
||||
</controller>
|
||||
<graphics type='vnc'/>
|
||||
<hostdev mode='subsystem' type='pci' display='on' ramfb='on'>
|
||||
<source>
|
||||
<address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/>
|
||||
</source>
|
||||
</hostdev>
|
||||
<video>
|
||||
<model type='none'/>
|
||||
</video>
|
||||
<memballoon model='none'/>
|
||||
</devices>
|
||||
</domain>
|
@ -2076,6 +2076,7 @@ mymain(void)
|
||||
DO_TEST_CAPS_LATEST("hostdev-pci-address");
|
||||
DO_TEST_CAPS_LATEST("hostdev-pci-address-device");
|
||||
DO_TEST_CAPS_LATEST_PARSE_ERROR("hostdev-pci-duplicate");
|
||||
DO_TEST_CAPS_LATEST("hostdev-pci-display-ramfb");
|
||||
DO_TEST_CAPS_LATEST("hostdev-vfio");
|
||||
DO_TEST_CAPS_LATEST("hostdev-vfio-multidomain");
|
||||
DO_TEST_CAPS_LATEST("hostdev-mdev-precreated");
|
||||
|
Loading…
Reference in New Issue
Block a user