[libvirt] [PATCH v2 0/2] qemu: fix type of default video device

This new version mostly integrates Cole's comments about the first version. Pavel Mores (2): qemu: fix type of default video device qemu: add tests of the default video type selection algorithm src/qemu/qemu_domain.c | 39 +++++++++++------ .../default-video-type-aarch64.xml | 16 +++++++ .../default-video-type-ppc64.xml | 16 +++++++ .../default-video-type-riscv64.xml | 16 +++++++ .../default-video-type-s390x.xml | 16 +++++++ .../default-video-type-x86_64-caps-test-0.xml | 17 ++++++++ .../default-video-type-x86_64-caps-test-1.xml | 17 ++++++++ tests/qemuxml2argvtest.c | 1 + ...ault-video-type-aarch64.aarch64-latest.xml | 42 +++++++++++++++++++ .../default-video-type-ppc64.ppc64-latest.xml | 31 ++++++++++++++ ...ault-video-type-riscv64.riscv64-latest.xml | 39 +++++++++++++++++ .../default-video-type-s390x.s390x-latest.xml | 32 ++++++++++++++ .../default-video-type-x86_64-caps-test-0.xml | 31 ++++++++++++++ .../default-video-type-x86_64-caps-test-1.xml | 31 ++++++++++++++ tests/qemuxml2xmltest.c | 10 ++++- 15 files changed, 341 insertions(+), 13 deletions(-) create mode 100644 tests/qemuxml2argvdata/default-video-type-aarch64.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-ppc64.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-riscv64.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-s390x.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-1.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-aarch64.aarch64-latest.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-ppc64.ppc64-latest.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-riscv64.riscv64-latest.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-s390x.s390x-latest.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-0.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-1.xml -- 2.21.0

If a graphics device is added to XML that has no video device, libvirt automatically added a video device which was always of type 'cirrus' on x86_64, even if the underlying qemu didn't support cirrus. This patch refines a bit the decision about the type of the video device. Based on QEMU capabilities, cirrus is still preferred but only added if QEMU supports it, otherwise VGA is used if supported by QEMU. There is now no fallback as libvirt only aspires to generate a basic working config and leaves anything more specific up to higher-level management tools. https://bugzilla.redhat.com/show_bug.cgi?id=1668141 Signed-off-by: Pavel Mores <pmores@redhat.com> --- src/qemu/qemu_domain.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b257db44b0..39b2d2da82 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7360,6 +7360,28 @@ qemuDomainDefaultNetModel(const virDomainDef *def, } +static int +qemuDomainDefaultVideoDevice(const virDomainDef *def, + virQEMUCapsPtr qemuCaps) +{ + if (ARCH_IS_PPC64(def->os.arch)) { + return VIR_DOMAIN_VIDEO_TYPE_VGA; + } else if (qemuDomainIsARMVirt(def) || + qemuDomainIsRISCVVirt(def) || + ARCH_IS_S390(def->os.arch)) { + return VIR_DOMAIN_VIDEO_TYPE_VIRTIO; + } else { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA)) { + return VIR_DOMAIN_VIDEO_TYPE_CIRRUS; + } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) { + return VIR_DOMAIN_VIDEO_TYPE_VGA; + } else { + return VIR_DOMAIN_VIDEO_TYPE_DEFAULT; + } + } +} + + /* * Clear auto generated unix socket paths: * @@ -7821,18 +7843,11 @@ qemuDomainDeviceNetDefPostParse(virDomainNetDefPtr net, static int qemuDomainDeviceVideoDefPostParse(virDomainVideoDefPtr video, - const virDomainDef *def) + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) { - if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) { - if (ARCH_IS_PPC64(def->os.arch)) - video->type = VIR_DOMAIN_VIDEO_TYPE_VGA; - else if (qemuDomainIsARMVirt(def) || - qemuDomainIsRISCVVirt(def) || - ARCH_IS_S390(def->os.arch)) - video->type = VIR_DOMAIN_VIDEO_TYPE_VIRTIO; - else - video->type = VIR_DOMAIN_VIDEO_TYPE_CIRRUS; - } + if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) + video->type = qemuDomainDefaultVideoDevice(def, qemuCaps); if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL && !video->vgamem) { @@ -7926,7 +7941,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, break; case VIR_DOMAIN_DEVICE_VIDEO: - ret = qemuDomainDeviceVideoDefPostParse(dev->data.video, def); + ret = qemuDomainDeviceVideoDefPostParse(dev->data.video, def, qemuCaps); break; case VIR_DOMAIN_DEVICE_PANIC: -- 2.21.0

Sorry for the review delay. If you cc me on v3 I'll review it ASAP This patch is mixing two things: refactoring, and behavior change. This makes review more difficult. Please put the refactoring first which will maintain the old behavior, then add functional changes as additional patch(es). On its own, this patch breaks the test suite. Every patch should be self contained, keeping the test suite working. On 10/18/19 6:27 AM, Pavel Mores wrote:
If a graphics device is added to XML that has no video device, libvirt automatically added a video device which was always of type 'cirrus' on x86_64, even if the underlying qemu didn't support cirrus.
This patch refines a bit the decision about the type of the video device. Based on QEMU capabilities, cirrus is still preferred but only added if QEMU supports it, otherwise VGA is used if supported by QEMU. There is now no fallback as libvirt only aspires to generate a basic working config and leaves anything more specific up to higher-level management tools.
https://bugzilla.redhat.com/show_bug.cgi?id=1668141 Signed-off-by: Pavel Mores <pmores@redhat.com> --- src/qemu/qemu_domain.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b257db44b0..39b2d2da82 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7360,6 +7360,28 @@ qemuDomainDefaultNetModel(const virDomainDef *def, }
+static int +qemuDomainDefaultVideoDevice(const virDomainDef *def, + virQEMUCapsPtr qemuCaps) +{ + if (ARCH_IS_PPC64(def->os.arch)) { + return VIR_DOMAIN_VIDEO_TYPE_VGA; + } else if (qemuDomainIsARMVirt(def) || + qemuDomainIsRISCVVirt(def) || + ARCH_IS_S390(def->os.arch)) {
Indentation is off here.
+ return VIR_DOMAIN_VIDEO_TYPE_VIRTIO; + } else { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA)) { + return VIR_DOMAIN_VIDEO_TYPE_CIRRUS; + } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) { + return VIR_DOMAIN_VIDEO_TYPE_VGA; + } else { + return VIR_DOMAIN_VIDEO_TYPE_DEFAULT; + } + } +} +
You can remove any 'else' usage after 'return;' here. Every condition will then be at the same indent level. Then you can drop all the bracket usage too in accordance with the style guidelines. All this can be done in the same patch creating the new function IMO. Second patch can add qemuCaps up through the callstack and make the behavior change. The can probably resolve the test breakage by moving current patch #2 to be first in the series. Then the behavior change patch will demonstrate the new behavior in changed test suite output, which makes it easier to review exactly the effect of the changes. Thanks, Cole
+ /* * Clear auto generated unix socket paths: * @@ -7821,18 +7843,11 @@ qemuDomainDeviceNetDefPostParse(virDomainNetDefPtr net,
static int qemuDomainDeviceVideoDefPostParse(virDomainVideoDefPtr video, - const virDomainDef *def) + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) { - if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) { - if (ARCH_IS_PPC64(def->os.arch)) - video->type = VIR_DOMAIN_VIDEO_TYPE_VGA; - else if (qemuDomainIsARMVirt(def) || - qemuDomainIsRISCVVirt(def) || - ARCH_IS_S390(def->os.arch)) - video->type = VIR_DOMAIN_VIDEO_TYPE_VIRTIO; - else - video->type = VIR_DOMAIN_VIDEO_TYPE_CIRRUS; - } + if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) + video->type = qemuDomainDefaultVideoDevice(def, qemuCaps);
if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL && !video->vgamem) { @@ -7926,7 +7941,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, break;
case VIR_DOMAIN_DEVICE_VIDEO: - ret = qemuDomainDeviceVideoDefPostParse(dev->data.video, def); + ret = qemuDomainDeviceVideoDefPostParse(dev->data.video, def, qemuCaps); break;
case VIR_DOMAIN_DEVICE_PANIC:

The test case for x86_64 and neither cirrus nor vga capability is of the xml2argv type because it actually fails to parse the XML at all [*] which is something that xml2xml tests don't seem to handle. xml2argv test fails to produce a qemu argv for this case which xml2argv tests can handle. The (unrelated) "graphics-egl-headless-rendernode" had to be adjusted as it expects cirrus to be added as per previous behaviour. It now has to use QEMU_CAPS_DEVICE_CIRRUS_VGA to get that (otherwise it'd end up with vga). [*] This is a consequence of the decision not to have a fallback if the obvious choices (cirrus and vga) aren't viable due to missing QEMU caps. Signed-off-by: Pavel Mores <pmores@redhat.com> --- .../default-video-type-aarch64.xml | 16 +++++++ .../default-video-type-ppc64.xml | 16 +++++++ .../default-video-type-riscv64.xml | 16 +++++++ .../default-video-type-s390x.xml | 16 +++++++ .../default-video-type-x86_64-caps-test-0.xml | 17 ++++++++ .../default-video-type-x86_64-caps-test-1.xml | 17 ++++++++ tests/qemuxml2argvtest.c | 1 + ...ault-video-type-aarch64.aarch64-latest.xml | 42 +++++++++++++++++++ .../default-video-type-ppc64.ppc64-latest.xml | 31 ++++++++++++++ ...ault-video-type-riscv64.riscv64-latest.xml | 39 +++++++++++++++++ .../default-video-type-s390x.s390x-latest.xml | 32 ++++++++++++++ .../default-video-type-x86_64-caps-test-0.xml | 31 ++++++++++++++ .../default-video-type-x86_64-caps-test-1.xml | 31 ++++++++++++++ tests/qemuxml2xmltest.c | 10 ++++- 14 files changed, 314 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/default-video-type-aarch64.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-ppc64.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-riscv64.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-s390x.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-1.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-aarch64.aarch64-latest.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-ppc64.ppc64-latest.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-riscv64.riscv64-latest.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-s390x.s390x-latest.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-0.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-1.xml diff --git a/tests/qemuxml2argvdata/default-video-type-aarch64.xml b/tests/qemuxml2argvdata/default-video-type-aarch64.xml new file mode 100644 index 0000000000..03326d3c9b --- /dev/null +++ b/tests/qemuxml2argvdata/default-video-type-aarch64.xml @@ -0,0 +1,16 @@ +<domain type='kvm'> + <name>default-video-type-aarch64-test</name> + <uuid>6ba410c5-1e5c-4d57-bee7-2228e7ffa32f</uuid> + <memory unit='KiB'>1048576</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='aarch64' machine='virt'>hvm</type> + </os> + <cpu mode='host-passthrough'/> + <devices> + <emulator>/usr/bin/qemu-system-aarch64</emulator> + <controller type='usb' index='0' model='none'/> + <memballoon model='none'/> + <graphics type='spice'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/default-video-type-ppc64.xml b/tests/qemuxml2argvdata/default-video-type-ppc64.xml new file mode 100644 index 0000000000..739e07fc19 --- /dev/null +++ b/tests/qemuxml2argvdata/default-video-type-ppc64.xml @@ -0,0 +1,16 @@ +<domain type='kvm'> + <name>default-video-type-ppc64-test</name> + <uuid>6ba410c5-1e5c-4d57-bee7-2228e7ffa32f</uuid> + <memory unit='KiB'>1048576</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='ppc64' machine='virt'>hvm</type> + </os> + <cpu mode='host-passthrough'/> + <devices> + <emulator>/usr/bin/qemu-system-ppc64</emulator> + <controller type='usb' index='0' model='none'/> + <memballoon model='none'/> + <graphics type='spice'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/default-video-type-riscv64.xml b/tests/qemuxml2argvdata/default-video-type-riscv64.xml new file mode 100644 index 0000000000..55f6fa9391 --- /dev/null +++ b/tests/qemuxml2argvdata/default-video-type-riscv64.xml @@ -0,0 +1,16 @@ +<domain type='qemu'> + <name>default-video-type-riscv64-test</name> + <uuid>6ba410c5-1e5c-4d57-bee7-2228e7ffa32f</uuid> + <memory unit='KiB'>1048576</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='riscv64' machine='virt'>hvm</type> + </os> + <cpu mode='host-passthrough'/> + <devices> + <emulator>/usr/bin/qemu-system-riscv64</emulator> + <controller type='usb' index='0' model='none'/> + <memballoon model='none'/> + <graphics type='spice'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/default-video-type-s390x.xml b/tests/qemuxml2argvdata/default-video-type-s390x.xml new file mode 100644 index 0000000000..9eda06a3a1 --- /dev/null +++ b/tests/qemuxml2argvdata/default-video-type-s390x.xml @@ -0,0 +1,16 @@ +<domain type='kvm'> + <name>default-video-type-s390x-test</name> + <uuid>6ba410c5-1e5c-4d57-bee7-2228e7ffa32f</uuid> + <memory unit='KiB'>1048576</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='s390x' machine='virt'>hvm</type> + </os> + <cpu mode='host-passthrough'/> + <devices> + <emulator>/usr/bin/qemu-system-s390x</emulator> + <controller type='usb' index='0' model='none'/> + <memballoon model='none'/> + <graphics type='spice'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.xml b/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.xml new file mode 100644 index 0000000000..2c753fe227 --- /dev/null +++ b/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.xml @@ -0,0 +1,17 @@ +<domain type='kvm'> + <name>default-video-type-x86_64-test</name> + <uuid>6ba410c5-1e5c-4d57-bee7-2228e7ffa32f</uuid> + <memory unit='KiB'>1048576</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='virt'>hvm</type> + </os> + <cpu mode='host-passthrough'/> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='usb' index='0' model='none'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='none'/> + <graphics type='spice'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-1.xml b/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-1.xml new file mode 100644 index 0000000000..2c753fe227 --- /dev/null +++ b/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-1.xml @@ -0,0 +1,17 @@ +<domain type='kvm'> + <name>default-video-type-x86_64-test</name> + <uuid>6ba410c5-1e5c-4d57-bee7-2228e7ffa32f</uuid> + <memory unit='KiB'>1048576</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='virt'>hvm</type> + </os> + <cpu mode='host-passthrough'/> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='usb' index='0' model='none'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='none'/> + <graphics type='spice'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a84ea0954d..1f50afdc9c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2088,6 +2088,7 @@ mymain(void) DO_TEST("video-none-device", QEMU_CAPS_VNC); DO_TEST_PARSE_ERROR("video-invalid-multiple-devices", NONE); + DO_TEST_PARSE_ERROR("default-video-type-x86_64-caps-test-0", NONE); DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE_VIRTIO_RNG, diff --git a/tests/qemuxml2xmloutdata/default-video-type-aarch64.aarch64-latest.xml b/tests/qemuxml2xmloutdata/default-video-type-aarch64.aarch64-latest.xml new file mode 100644 index 0000000000..4b660b8d70 --- /dev/null +++ b/tests/qemuxml2xmloutdata/default-video-type-aarch64.aarch64-latest.xml @@ -0,0 +1,42 @@ +<domain type='kvm'> + <name>default-video-type-aarch64-test</name> + <uuid>6ba410c5-1e5c-4d57-bee7-2228e7ffa32f</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='aarch64' machine='virt'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <gic version='3'/> + </features> + <cpu mode='host-passthrough' check='none'/> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-aarch64</emulator> + <controller type='usb' index='0' model='none'/> + <controller type='pci' index='0' model='pcie-root'/> + <controller type='pci' index='1' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='1' port='0x8'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/> + </controller> + <controller type='pci' index='2' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='2' port='0x9'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <graphics type='spice'> + <listen type='none'/> + </graphics> + <video> + <model type='virtio' heads='1' primary='yes'/> + <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/default-video-type-ppc64.ppc64-latest.xml b/tests/qemuxml2xmloutdata/default-video-type-ppc64.ppc64-latest.xml new file mode 100644 index 0000000000..590a73b456 --- /dev/null +++ b/tests/qemuxml2xmloutdata/default-video-type-ppc64.ppc64-latest.xml @@ -0,0 +1,31 @@ +<domain type='kvm'> + <name>default-video-type-ppc64-test</name> + <uuid>6ba410c5-1e5c-4d57-bee7-2228e7ffa32f</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='ppc64' machine='virt'>hvm</type> + <boot dev='hd'/> + </os> + <cpu mode='host-passthrough' check='none'/> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-ppc64</emulator> + <controller type='usb' index='0' model='none'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='keyboard' bus='usb'/> + <input type='mouse' bus='usb'/> + <graphics type='spice'> + <listen type='none'/> + </graphics> + <video> + <model type='vga' vram='16384' heads='1' primary='yes'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/default-video-type-riscv64.riscv64-latest.xml b/tests/qemuxml2xmloutdata/default-video-type-riscv64.riscv64-latest.xml new file mode 100644 index 0000000000..ebb3bfe980 --- /dev/null +++ b/tests/qemuxml2xmloutdata/default-video-type-riscv64.riscv64-latest.xml @@ -0,0 +1,39 @@ +<domain type='qemu'> + <name>default-video-type-riscv64-test</name> + <uuid>6ba410c5-1e5c-4d57-bee7-2228e7ffa32f</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='riscv64' machine='virt'>hvm</type> + <boot dev='hd'/> + </os> + <cpu mode='host-passthrough' check='none'/> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-riscv64</emulator> + <controller type='usb' index='0' model='none'/> + <controller type='pci' index='0' model='pcie-root'/> + <controller type='pci' index='1' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='1' port='0x8'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/> + </controller> + <controller type='pci' index='2' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='2' port='0x9'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <graphics type='spice'> + <listen type='none'/> + </graphics> + <video> + <model type='virtio' heads='1' primary='yes'/> + <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/default-video-type-s390x.s390x-latest.xml b/tests/qemuxml2xmloutdata/default-video-type-s390x.s390x-latest.xml new file mode 100644 index 0000000000..21718db1ca --- /dev/null +++ b/tests/qemuxml2xmloutdata/default-video-type-s390x.s390x-latest.xml @@ -0,0 +1,32 @@ +<domain type='kvm'> + <name>default-video-type-s390x-test</name> + <uuid>6ba410c5-1e5c-4d57-bee7-2228e7ffa32f</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='s390x' machine='virt'>hvm</type> + <boot dev='hd'/> + </os> + <cpu mode='host-passthrough' check='none'/> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-s390x</emulator> + <controller type='usb' index='0' model='none'/> + <controller type='pci' index='0' model='pci-root'/> + <graphics type='spice'> + <listen type='none'/> + </graphics> + <video> + <model type='virtio' heads='1' primary='yes'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'> + <zpci uid='0x0001' fid='0x00000000'/> + </address> + </video> + <memballoon model='none'/> + <panic model='s390'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-0.xml b/tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-0.xml new file mode 100644 index 0000000000..645019c230 --- /dev/null +++ b/tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-0.xml @@ -0,0 +1,31 @@ +<domain type='kvm'> + <name>default-video-type-x86_64-test</name> + <uuid>6ba410c5-1e5c-4d57-bee7-2228e7ffa32f</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='virt'>hvm</type> + <boot dev='hd'/> + </os> + <cpu mode='host-passthrough' check='none'/> + <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='none'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='spice'> + <listen type='none'/> + </graphics> + <video> + <model type='vga' vram='16384' heads='1' primary='yes'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-1.xml b/tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-1.xml new file mode 100644 index 0000000000..f763b6902e --- /dev/null +++ b/tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-1.xml @@ -0,0 +1,31 @@ +<domain type='kvm'> + <name>default-video-type-x86_64-test</name> + <uuid>6ba410c5-1e5c-4d57-bee7-2228e7ffa32f</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='virt'>hvm</type> + <boot dev='hd'/> + </os> + <cpu mode='host-passthrough' check='none'/> + <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='none'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='spice'> + <listen type='none'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index b9364f942f..15ee38fa7e 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -374,6 +374,13 @@ mymain(void) DO_TEST("graphics-vnc-egl-headless", QEMU_CAPS_EGL_HEADLESS); + DO_TEST_CAPS_ARCH_LATEST("default-video-type-aarch64", "aarch64"); + DO_TEST_CAPS_ARCH_LATEST("default-video-type-ppc64", "ppc64"); + DO_TEST_CAPS_ARCH_LATEST("default-video-type-riscv64", "riscv64"); + DO_TEST_CAPS_ARCH_LATEST("default-video-type-s390x", "s390x"); + DO_TEST("default-video-type-x86_64-caps-test-0", QEMU_CAPS_DEVICE_VGA); + DO_TEST("default-video-type-x86_64-caps-test-1", QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST("graphics-sdl", NONE); DO_TEST("graphics-sdl-fullscreen", NONE); DO_TEST("graphics-spice", NONE); @@ -389,7 +396,8 @@ mymain(void) DO_TEST("graphics-egl-headless-rendernode", QEMU_CAPS_EGL_HEADLESS, - QEMU_CAPS_EGL_HEADLESS_RENDERNODE); + QEMU_CAPS_EGL_HEADLESS_RENDERNODE, + QEMU_CAPS_DEVICE_CIRRUS_VGA); DO_TEST("input-usbmouse", NONE); DO_TEST("input-usbtablet", NONE); -- 2.21.0

Hi, could someone please take a look at this so that I can move on with it? Thanks, pvl On Fri, Oct 18, 2019 at 12:27:20PM +0200, Pavel Mores wrote:
This new version mostly integrates Cole's comments about the first version.
Pavel Mores (2): qemu: fix type of default video device qemu: add tests of the default video type selection algorithm
src/qemu/qemu_domain.c | 39 +++++++++++------ .../default-video-type-aarch64.xml | 16 +++++++ .../default-video-type-ppc64.xml | 16 +++++++ .../default-video-type-riscv64.xml | 16 +++++++ .../default-video-type-s390x.xml | 16 +++++++ .../default-video-type-x86_64-caps-test-0.xml | 17 ++++++++ .../default-video-type-x86_64-caps-test-1.xml | 17 ++++++++ tests/qemuxml2argvtest.c | 1 + ...ault-video-type-aarch64.aarch64-latest.xml | 42 +++++++++++++++++++ .../default-video-type-ppc64.ppc64-latest.xml | 31 ++++++++++++++ ...ault-video-type-riscv64.riscv64-latest.xml | 39 +++++++++++++++++ .../default-video-type-s390x.s390x-latest.xml | 32 ++++++++++++++ .../default-video-type-x86_64-caps-test-0.xml | 31 ++++++++++++++ .../default-video-type-x86_64-caps-test-1.xml | 31 ++++++++++++++ tests/qemuxml2xmltest.c | 10 ++++- 15 files changed, 341 insertions(+), 13 deletions(-) create mode 100644 tests/qemuxml2argvdata/default-video-type-aarch64.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-ppc64.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-riscv64.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-s390x.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.xml create mode 100644 tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-1.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-aarch64.aarch64-latest.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-ppc64.ppc64-latest.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-riscv64.riscv64-latest.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-s390x.s390x-latest.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-0.xml create mode 100644 tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-1.xml
-- 2.21.0
participants (2)
-
Cole Robinson
-
Pavel Mores