From fd03d0e692b9b8c71d6b2ae111ee0c8671b61125 Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Fri, 13 Sep 2019 16:20:29 -0500 Subject: [PATCH] qemu: add a new video device model 'ramfb' This device is a very simple framebuffer device supported by qemu that is mostly intended to use as a boot framebuffer in conjunction with a vgpu. However, there is also a standalone ramfb device that can be used as a primary display device and is useful for e.g. aarch64 guests where different memory mappings between the host and guest can prevent use of other devices with framebuffers such as virtio-vga. https://bugzilla.redhat.com/show_bug.cgi?id=1679680 describes the issues in more detail. Reviewed-by: Cole Robinson Signed-off-by: Jonathon Jongsma --- docs/formatdomain.html.in | 7 ++-- docs/news.xml | 9 +++++ docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 2 + src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 3 ++ src/qemu/qemu_domain.c | 1 + src/qemu/qemu_domain_address.c | 12 ++++-- src/qemu/qemu_process.c | 4 +- ...eo-ramfb-display-device.x86_64-latest.args | 38 +++++++++++++++++++ .../video-ramfb-display-device.xml | 29 ++++++++++++++ tests/qemuxml2argvtest.c | 1 + 12 files changed, 101 insertions(+), 7 deletions(-) create mode 100644 tests/qemuxml2argvdata/video-ramfb-display-device.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/video-ramfb-display-device.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 647f96f651..80b403d54d 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -7032,9 +7032,10 @@ qemu-kvm -net nic,model=? /dev/null "vbox", "qxl" (since 0.8.6), "virtio" (since 1.3.0), "gop" (since 3.2.0), - "none" (since 4.6.0, or "bochs" - (since 5.6.0) - depending on the hypervisor features available. + "bochs" (since 5.6.0), "ramfb" + (since 5.9.0), or "none" + (since 4.6.0, depending on the hypervisor + features available. The purpose of the type none is to instruct libvirt not to add a default video device in the guest (see the paragraph above). This legacy behaviour can be inconvenient in cases where GPU mediated diff --git a/docs/news.xml b/docs/news.xml index d9c402e6bb..c13cb9f711 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -41,6 +41,15 @@
+ + + qemu: Introduce a new video model of type 'ramfb' + + + Introduce a new video model type to the domain XML that supports the + ramfb standalone device in qemu. + +
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 40eb4a2d75..cc2c6899ec 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3598,6 +3598,7 @@ gop none bochs + ramfb diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5fe03ea866..3dd0d0f5c8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -748,6 +748,7 @@ VIR_ENUM_IMPL(virDomainVideo, "gop", "none", "bochs", + "ramfb", ); VIR_ENUM_IMPL(virDomainVideoVGAConf, @@ -15299,6 +15300,7 @@ virDomainVideoDefaultRAM(const virDomainDef *def, case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: case VIR_DOMAIN_VIDEO_TYPE_GOP: case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: case VIR_DOMAIN_VIDEO_TYPE_LAST: default: return 0; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 653dcaf2bc..23474807a4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1399,6 +1399,7 @@ typedef enum { VIR_DOMAIN_VIDEO_TYPE_GOP, VIR_DOMAIN_VIDEO_TYPE_NONE, VIR_DOMAIN_VIDEO_TYPE_BOCHS, + VIR_DOMAIN_VIDEO_TYPE_RAMFB, VIR_DOMAIN_VIDEO_TYPE_LAST } virDomainVideoType; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index cbf25d5f07..817cf952d5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -114,6 +114,7 @@ VIR_ENUM_IMPL(qemuVideo, "" /* don't support gop */, "" /* 'none' doesn't make sense here */, "bochs-display", + "", /* ramfb can't be used with -vga */ ); VIR_ENUM_DECL(qemuDeviceVideo); @@ -132,6 +133,7 @@ VIR_ENUM_IMPL(qemuDeviceVideo, "" /* don't support gop */, "" /* 'none' doesn't make sense here */, "bochs-display", + "ramfb", ); VIR_ENUM_DECL(qemuDeviceVideoSecondary); @@ -150,6 +152,7 @@ VIR_ENUM_IMPL(qemuDeviceVideoSecondary, "" /* don't support gop */, "" /* 'none' doesn't make sense here */, "" /* no secondary device for bochs */, + "" /* no secondary device for ramfb */, ); VIR_ENUM_DECL(qemuSoundCodec); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b4175a846e..bc54393977 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5725,6 +5725,7 @@ qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video) case VIR_DOMAIN_VIDEO_TYPE_QXL: case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: case VIR_DOMAIN_VIDEO_TYPE_LAST: break; } diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 4f5671f458..ff770c6496 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -936,6 +936,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: case VIR_DOMAIN_VIDEO_TYPE_GOP: case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: case VIR_DOMAIN_VIDEO_TYPE_LAST: return 0; } @@ -1787,8 +1788,10 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def, return -1; } + /* ramfb is not a PCI device */ if (def->nvideos > 0 && - def->videos[0]->type != VIR_DOMAIN_VIDEO_TYPE_NONE) { + def->videos[0]->type != VIR_DOMAIN_VIDEO_TYPE_NONE && + def->videos[0]->type != VIR_DOMAIN_VIDEO_TYPE_RAMFB) { /* Because the PIIX3 integrated IDE/USB controllers are * already at slot 1, when qemu looks for the first free slot * to place the VGA controller (which is always the first @@ -1971,8 +1974,10 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def, return -1; } + /* ramfb is not a PCI device */ if (def->nvideos > 0 && - def->videos[0]->type != VIR_DOMAIN_VIDEO_TYPE_NONE) { + def->videos[0]->type != VIR_DOMAIN_VIDEO_TYPE_NONE && + def->videos[0]->type != VIR_DOMAIN_VIDEO_TYPE_RAMFB) { /* NB: unlike the pc machinetypes, on q35 machinetypes the * integrated devices are at slot 0x1f, so when qemu looks for * the first free slot for the first VGA, it will always be at @@ -2351,7 +2356,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, /* Video devices */ for (i = 0; i < def->nvideos; i++) { - if (def->videos[i]->type == VIR_DOMAIN_VIDEO_TYPE_NONE) + if (def->videos[i]->type == VIR_DOMAIN_VIDEO_TYPE_NONE || + def->videos[i]->type == VIR_DOMAIN_VIDEO_TYPE_RAMFB) continue; if (!virDeviceInfoPCIAddressIsWanted(&def->videos[i]->info)) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9de86b3ce1..ca2a5cab5b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5273,7 +5273,9 @@ qemuProcessStartValidateVideo(virDomainObjPtr vm, video->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW)) || (video->type == VIR_DOMAIN_VIDEO_TYPE_BOCHS && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_BOCHS_DISPLAY))) { + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_BOCHS_DISPLAY)) || + (video->type == VIR_DOMAIN_VIDEO_TYPE_RAMFB && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_RAMFB))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("this QEMU does not support '%s' video device"), virDomainVideoTypeToString(video->type)); diff --git a/tests/qemuxml2argvdata/video-ramfb-display-device.x86_64-latest.args b/tests/qemuxml2argvdata/video-ramfb-display-device.x86_64-latest.args new file mode 100644 index 0000000000..b26db5d546 --- /dev/null +++ b/tests/qemuxml2argvdata/video-ramfb-display-device.x86_64-latest.args @@ -0,0 +1,38 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i686 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off \ +-m 1024 \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,\ +id=drive-ide0-0-0,cache=none \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1,\ +write-cache=on \ +-device ramfb,id=video0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/video-ramfb-display-device.xml b/tests/qemuxml2argvdata/video-ramfb-display-device.xml new file mode 100644 index 0000000000..4123dad372 --- /dev/null +++ b/tests/qemuxml2argvdata/video-ramfb-display-device.xml @@ -0,0 +1,29 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
+ + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index db79301f0e..dbb18ebd71 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2083,6 +2083,7 @@ mymain(void) QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS); DO_TEST_CAPS_LATEST("video-bochs-display-device"); + DO_TEST_CAPS_LATEST("video-ramfb-display-device"); DO_TEST("video-none-device", QEMU_CAPS_VNC); DO_TEST_PARSE_ERROR("video-invalid-multiple-devices", NONE); -- GitLab