[libvirt] [PATCH v3 00/28] Fix serial console behavior on non-x86 architectures

Happy birthday to me. Changes from [v2]: * don't drop -serial suffix from existing target types; * add capability and machine type checks for isa-serial; * reduce code duplication; * improve documentation. Changes from [v1]: * introduce target model to go along with target type and store the actual hypervisor-specific device name, as suggested by Pavel; * shorten the names of the esisting target types; * introduce a bunch of additional cleanups required for the first item. [v1] https://www.redhat.com/archives/libvir-list/2017-November/msg00545.html [v2] https://www.redhat.com/archives/libvir-list/2017-November/msg00831.html Andrea Bolognani (24): docs: Improve documentation for serial consoles qemu: Introduce qemuDomainChrDefPostParse() conf: Run devicePostParse() again for the first serial device conf: Introduce VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE conf: Drop virDomainChrDeviceType.targetTypeAttr conf: Introduce virDomainChrTargetDefFormat() conf: Improve error handling in virDomainChrDefFormat() conf: Check virDomainChrSourceDefFormat() return value conf: Improve virDomainChrTargetDefFormat() conf: Remove ATTRIBUTE_FALLTHROUGH from virDomainChrTargetDefFormat() qemu: Introduce qemuDomainChrTargetDefValidate() qemu: Improve qemuDomainChrTargetDefValidate() conf: Parse and format virDomainChrSerialTargetModel qemu: Set targetModel based on targetType for serial devices qemu: Validate target model for serial devices qemu: Format targetModel for serial devices qemu: Remove redundancy in qemuBuildSerialChrDeviceStr() conf: Add target type and model for spapr-vty qemu: Support usb-serial and pci-serial on pSeries conf: Add target type and model for pl011 qemu: Add QEMU_CAPS_DEVICE_ISA_SERIAL qemu: Require QEMU_CAPS_DEVICE_ISA_SERIAL for isa-serial qemu: Limit isa-serial usage to x86 guests news: Update for serial console fixes Pino Toscano (4): conf: add VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP conf: pass parseFlags down to virDomainDefAddConsoleCompat conf: convert sclp/sclplm <console> as <serial> qemu: switch s390/s390x default console back to serial docs/formatdomain.html.in | 233 ++++++++++++---- docs/news.xml | 12 + docs/schemas/domaincommon.rng | 22 ++ src/conf/domain_conf.c | 304 ++++++++++++++++----- src/conf/domain_conf.h | 26 +- src/libvirt_private.syms | 2 + src/qemu/qemu_capabilities.c | 2 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 134 ++++----- src/qemu/qemu_domain.c | 301 ++++++++++++++++++-- src/qemu/qemu_domain_address.c | 7 +- src/vz/vz_sdk.c | 5 +- .../qemuargv2xml-console-compat.xml | 4 +- tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml | 4 +- .../qemuargv2xmldata/qemuargv2xml-serial-file.xml | 4 +- .../qemuargv2xmldata/qemuargv2xml-serial-many.xml | 8 +- tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml | 4 +- .../qemuargv2xml-serial-tcp-telnet.xml | 4 +- tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml | 4 +- tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml | 8 +- .../qemuargv2xmldata/qemuargv2xml-serial-unix.xml | 4 +- tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml | 4 +- tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml | 1 + .../caps_2.10.0-gicv2.aarch64.xml | 1 + .../caps_2.10.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 + .../caps_2.6.0-gicv2.aarch64.xml | 1 + .../caps_2.6.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + tests/qemuhelptest.c | 5 + ...otplug-console-compat-2-live+console-virtio.xml | 12 +- .../qemuhotplug-console-compat-2-live.xml | 12 +- .../qemuxml2argv-mach-virt-console-native.args | 1 + .../qemuxml2argv-mach-virt-console-native.xml | 17 ++ ... => qemuxml2argv-mach-virt-console-virtio.args} | 15 +- .../qemuxml2argv-mach-virt-console-virtio.xml | 19 ++ ...muxml2argv-mach-virt-serial+console-native.args | 1 + ...emuxml2argv-mach-virt-serial+console-native.xml | 18 ++ .../qemuxml2argv-mach-virt-serial-compat.args | 1 + .../qemuxml2argv-mach-virt-serial-compat.xml | 19 ++ ...muxml2argv-mach-virt-serial-invalid-machine.xml | 21 ++ ...s => qemuxml2argv-mach-virt-serial-native.args} | 12 +- .../qemuxml2argv-mach-virt-serial-native.xml | 16 ++ .../qemuxml2argv-mach-virt-serial-pci.args | 26 ++ .../qemuxml2argv-mach-virt-serial-pci.xml | 18 ++ .../qemuxml2argv-mach-virt-serial-usb.args | 27 ++ .../qemuxml2argv-mach-virt-serial-usb.xml | 21 ++ .../qemuxml2argv-pseries-basic.args | 2 +- .../qemuxml2argv-pseries-console-native.args | 1 + .../qemuxml2argv-pseries-console-native.xml | 17 ++ ...gs => qemuxml2argv-pseries-console-virtio.args} | 10 +- .../qemuxml2argv-pseries-console-virtio.xml | 19 ++ .../qemuxml2argv-pseries-cpu-compat-power9.args | 2 +- .../qemuxml2argv-pseries-cpu-compat.args | 2 +- .../qemuxml2argv-pseries-cpu-exact.args | 2 +- .../qemuxml2argv-pseries-cpu-le.args | 2 +- .../qemuxml2argv-pseries-panic-missing.args | 2 +- .../qemuxml2argv-pseries-panic-no-address.args | 2 +- ...qemuxml2argv-pseries-serial+console-native.args | 1 + .../qemuxml2argv-pseries-serial+console-native.xml | 18 ++ .../qemuxml2argv-pseries-serial-compat.args | 1 + .../qemuxml2argv-pseries-serial-compat.xml | 19 ++ ...qemuxml2argv-pseries-serial-invalid-machine.xml | 19 ++ ...rgs => qemuxml2argv-pseries-serial-native.args} | 7 +- .../qemuxml2argv-pseries-serial-native.xml | 16 ++ ...c.args => qemuxml2argv-pseries-serial-pci.args} | 7 +- .../qemuxml2argv-pseries-serial-pci.xml | 18 ++ ...c.args => qemuxml2argv-pseries-serial-usb.args} | 8 +- .../qemuxml2argv-pseries-serial-usb.xml | 21 ++ .../qemuxml2argv-pseries-usb-default.args | 2 +- .../qemuxml2argv-pseries-usb-kbd.args | 2 +- .../qemuxml2argv-pseries-usb-multi.args | 2 +- .../qemuxml2argv-pseries-vio-user-assigned.args | 4 +- .../qemuxml2argvdata/qemuxml2argv-pseries-vio.args | 4 +- ....args => qemuxml2argv-s390-console2serial.args} | 11 +- .../qemuxml2argv-s390-console2serial.xml | 19 ++ ...power9.args => qemuxml2argv-s390-serial-2.args} | 14 +- .../qemuxml2argv-s390-serial-2.xml | 19 ++ ....args => qemuxml2argv-s390-serial-console.args} | 11 +- .../qemuxml2argv-s390-serial-console.xml | 15 + ...es-basic.args => qemuxml2argv-s390-serial.args} | 11 +- .../qemuxml2argvdata/qemuxml2argv-s390-serial.xml | 14 + ...muxml2argv-serial-tcp-tlsx509-chardev-notls.xml | 8 +- .../qemuxml2argvdata/qemuxml2argv-user-aliases.xml | 8 +- tests/qemuxml2argvtest.c | 101 ++++++- .../qemuxml2xmlout-aarch64-pci-serial.xml | 4 +- .../qemuxml2xmlout-aarch64-virtio-pci-default.xml | 4 +- .../qemuxml2xmlout-bios-nvram-os-interleave.xml | 4 +- .../qemuxml2xmlout-chardev-label.xml | 8 +- .../qemuxml2xmlout-console-compat-auto.xml | 4 +- .../qemuxml2xmlout-console-compat.xml | 4 +- .../qemuxml2xmlout-console-compat2.xml | 4 +- .../qemuxml2xmlout-console-virtio-many.xml | 4 +- .../qemuxml2xmlout-interface-driver.xml | 4 +- .../qemuxml2xmlout-interface-server.xml | 8 +- .../qemuxml2xmlout-mach-virt-console-native.xml | 1 + ...=> qemuxml2xmlout-mach-virt-console-virtio.xml} | 19 +- ...uxml2xmlout-mach-virt-serial+console-native.xml | 1 + .../qemuxml2xmlout-mach-virt-serial-compat.xml | 31 +++ .../qemuxml2xmlout-mach-virt-serial-native.xml | 1 + ...xml => qemuxml2xmlout-mach-virt-serial-pci.xml} | 15 +- .../qemuxml2xmlout-mach-virt-serial-usb.xml | 41 +++ .../qemuxml2xmlout-net-bandwidth.xml | 4 +- .../qemuxml2xmlout-net-bandwidth2.xml | 4 +- .../qemuxml2xmlout-net-coalesce.xml | 4 +- .../qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml | 4 +- .../qemuxml2xmlout-panic-pseries.xml | 4 +- .../qemuxml2xmlout-pci-serial-dev-chardev.xml | 4 +- .../qemuxml2xmlout-pseries-console-native.xml | 1 + ...l => qemuxml2xmlout-pseries-console-virtio.xml} | 16 +- .../qemuxml2xmlout-pseries-cpu-compat-power9.xml | 4 +- .../qemuxml2xmlout-pseries-cpu-compat.xml | 4 +- .../qemuxml2xmlout-pseries-cpu-exact.xml | 4 +- .../qemuxml2xmlout-pseries-panic-missing.xml | 4 +- .../qemuxml2xmlout-pseries-panic-no-address.xml | 4 +- ...emuxml2xmlout-pseries-serial+console-native.xml | 1 + .../qemuxml2xmlout-pseries-serial-compat.xml | 1 + ...ml => qemuxml2xmlout-pseries-serial-native.xml} | 10 +- ...g.xml => qemuxml2xmlout-pseries-serial-pci.xml} | 16 +- ...g.xml => qemuxml2xmlout-pseries-serial-usb.xml} | 13 +- .../qemuxml2xmlout-q35-virt-manager-basic.xml | 4 +- .../qemuxml2xmlout-s390-defaultconsole.xml | 8 +- .../qemuxml2xmlout-s390-serial-2.xml | 33 +++ .../qemuxml2xmlout-s390-serial-console.xml | 28 ++ .../qemuxml2xmlout-s390-serial.xml | 28 ++ .../qemuxml2xmlout-serial-spiceport-nospice.xml | 4 +- .../qemuxml2xmlout-serial-spiceport.xml | 4 +- .../qemuxml2xmlout-serial-target-port-auto.xml | 12 +- .../qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml | 8 +- .../qemuxml2xmlout-tap-vhost-incorrect.xml | 4 +- .../qemuxml2xmlout-tap-vhost.xml | 4 +- .../qemuxml2xmlout-vhost_queues.xml | 4 +- tests/qemuxml2xmltest.c | 54 ++++ 147 files changed, 1883 insertions(+), 391 deletions(-) create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.xml copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-basic.args => qemuxml2argv-mach-virt-console-virtio.args} (53%) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-invalid-machine.xml copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-basic.args => qemuxml2argv-mach-virt-serial-native.args} (62%) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.xml copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-basic.args => qemuxml2argv-pseries-console-virtio.args} (59%) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-invalid-machine.xml copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-basic.args => qemuxml2argv-pseries-serial-native.args} (70%) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.xml copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-basic.args => qemuxml2argv-pseries-serial-pci.args} (70%) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-basic.args => qemuxml2argv-pseries-serial-usb.args} (65%) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-basic.args => qemuxml2argv-s390-console2serial.args} (71%) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-console2serial.xml copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-cpu-compat-power9.args => qemuxml2argv-s390-serial-2.args} (62%) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.xml copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-basic.args => qemuxml2argv-s390-serial-console.args} (71%) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.xml copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-basic.args => qemuxml2argv-s390-serial.args} (71%) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-native.xml copy tests/qemuxml2xmloutdata/{qemuxml2xmlout-s390-defaultconsole.xml => qemuxml2xmlout-mach-virt-console-virtio.xml} (50%) create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial+console-native.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-compat.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-native.xml copy tests/qemuxml2xmloutdata/{qemuxml2xmlout-aarch64-pci-serial.xml => qemuxml2xmlout-mach-virt-serial-pci.xml} (78%) create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-usb.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-native.xml copy tests/qemuxml2xmloutdata/{qemuxml2xmlout-panic-pseries.xml => qemuxml2xmlout-pseries-console-virtio.xml} (75%) create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial+console-native.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-compat.xml copy tests/qemuxml2xmloutdata/{qemuxml2xmlout-pseries-panic-missing.xml => qemuxml2xmlout-pseries-serial-native.xml} (82%) copy tests/qemuxml2xmloutdata/{qemuxml2xmlout-pseries-panic-missing.xml => qemuxml2xmlout-pseries-serial-pci.xml} (74%) copy tests/qemuxml2xmloutdata/{qemuxml2xmlout-pseries-panic-missing.xml => qemuxml2xmlout-pseries-serial-usb.xml} (75%) create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-2.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial.xml -- 2.14.3

Our current documentation is missing some information and doesn't do a great job at explaining how the <serial> and <console> elements are connected. Let's try to fix that. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/formatdomain.html.in | 210 +++++++++++++++++++++++++++++++++------------- 1 file changed, 154 insertions(+), 56 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 505676354..12d7fb407 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6518,77 +6518,62 @@ qemu-kvm -net nic,model=? /dev/null <pre> ... <devices> + <!-- Serial port --> <serial type='pty'> <source path='/dev/pts/3'/> <target port='0'/> </serial> </devices> +...</pre> + +<pre> +... +<devices> + <!-- USB serial port --> + <serial type='pty'> + <target type='usb-serial' port='0'/> + <address type='usb' bus='0' port='1'/> + </serial> +</devices> ...</pre> <p> - <code>target</code> can have a <code>port</code> attribute, which - specifies the port number. Ports are numbered starting from 0. There are - usually 0, 1 or 2 serial ports. There is also an optional - <code>type</code> attribute <span class="since">since 1.0.2</span> - which has three choices for its value, one is <code>isa-serial</code>, - then <code>usb-serial</code> and last one is <code>pci-serial</code>. - If <code>type</code> is missing, <code>isa-serial</code> will be used by - default. For <code>usb-serial</code> an optional sub-element - <code><address/></code> with <code>type='usb'</code> can tie the - device to a particular controller, <a href="#elementsAddress">documented above</a>. - Similarly, <code>pci-serial</code> can be used to attach the device to - the pci bus (<span class="since">since 1.2.16</span>). Again, it has - optional sub-element <code><address/></code> with - <code>type='pci'</code> to select desired location on the PCI bus. + The <code>target</code> element can have an optional <code>port</code> + attribute, which specifies the port number (starting from 0), and an + optional <code>type</code> attribute: valid values are, + <span class="since">since 1.0.2</span>, <code>isa-serial</code> (usable + on x86 machine types), + <code>usb-serial</code> (usable whenever USB support is available) + and <code>pci-serial</code> (usable whenever PCI support is available). </p> - <h6><a id="elementCharConsole">Console</a></h6> - <p> - The console element is used to represent interactive consoles. Depending - on the type of guest in use, the consoles might be paravirtualized devices, - or they might be a clone of a serial device, according to the following - rules: + If any of the attributes is not specified by the user, libvirt will + choose a value suitable for most users. </p> - <ul> - <li>If no <code>targetType</code> attribute is set, then the default - device type is according to the hypervisor's rules. The default - type will be added when re-querying the XML fed into libvirt. - For fully virtualized guests, the default device type will usually - be a serial port.</li> - <li>If the <code>targetType</code> attribute is <code>serial</code>, - then if no <code><serial></code> element exists, the console - element will be copied to the serial element. If a <code><serial></code> - element does already exist, the console element will be ignored.</li> - <li>If the <code>targetType</code> attribute is not <code>serial</code>, - it will be treated normally.</li> - <li>Only the first <code>console</code> element may use a <code>targetType</code> - of <code>serial</code>. Secondary consoles must all be paravirtualized. - </li> - <li>On S390, the <code>console</code> element may use a - <code>targetType</code> of <code>sclp</code> or <code>sclplm</code> - (line mode). SCLP is the native console type for S390. There's no - controller associated to SCLP consoles. - <span class="since">Since 1.0.2</span> - </li> - </ul> - <p> - A virtio console device is exposed in the - guest as /dev/hvc[0-7] (for more information, see - <a href="http://fedoraproject.org/wiki/Features/VirtioSerial">http://fedoraproject.org/wiki/Features/VirtioSerial</a>) - <span class="since">Since 0.8.3</span> + Some of the types support configuring the guest-visible device + address as <a href="#elementsAddress">documented above</a>. + For the relationship between serial ports and consoles, + <a href="#elementCharSerialAndConsole">see below</a>. </p> + <h6><a id="elementCharConsole">Console</a></h6> + <pre> ... <devices> + <!-- Serial console --> <console type='pty'> - <source path='/dev/pts/4'/> - <target port='0'/> + <source path='/dev/pts/2'/> + <target type='serial' port='0'/> </console> +</devices> +...</pre> +<pre> +... <!-- KVM virtio console --> <console type='pty'> <source path='/dev/pts/5'/> @@ -6597,21 +6582,134 @@ qemu-kvm -net nic,model=? /dev/null </devices> ...</pre> + <p> + The <code>console</code> element is used to represent interactive + serial consoles. Depending on the type of guest in use and the specifics + of the configuration, the <code>console</code> element might represent + the same device as an existing <code>serial</code> element or a separate + device. + </p> + + <p> + A <code>target</code> subelement is supported and works the same + way as with the <code>serial</code> element + (<a href="#elementCharSerial">see above</a> for details). + Valid values for the <code>type</code> attribute are: + <code>serial</code> (described below); + <code>virtio</code> (usable whenever VirtIO support is available); + <code>xen</code>, <code>lxc</code>, <code>uml</code> and + <code>openvz</code> (available when the corresponding hypervisor is in + use); <code>sclp</code> and <code>sclplm</code> (usable for s390 and + s390x QEMU guests). + </p> + + <p> + Of the target types listed above, <code>serial</code> is special in + that it doesn't represents a separate device, but rather the same + device as the first <code>serial</code> element. Due to this, there can + only be a single <code>console</code> element with target type + <code>serial</code> per guest. + </p> + + <p> + Virtio consoles are usually accessible as <code>/dev/hvc[0-7]</code> + from inside the guest; for more information, see + <a href="http://fedoraproject.org/wiki/Features/VirtioSerial">http://fedoraproject.org/wiki/Features/VirtioSerial</a>. + <span class="since">Since 0.8.3</span> + </p> + + <p> + For the relationship between serial ports and consoles, + <a href="#elementCharSerialAndConsole">see below</a>. + </p> + + <h6><a id="elementCharSerialAndConsole">Relationship between serial ports and consoles</a></h6> + + <p> + Due to hystorical reasons, the <code>serial</code> and + <code>console</code> elements have partially overlapping scopes. + </p> + + <p> + In general, both elements are used to configure one or more serial + consoles to be used for interacting with the guest. The main difference + between the two is that <code>serial</code> is used for emulated, + usually native, serial consoles, whereas <code>console</code> is used + for paravirtualized ones. + </p> + + <p> + Both emulated and paravirtualized serial consoles have advantages and + disadvantages: + </p> + + <ul> + <li> + emulated serial consoles are usually initialized much earlier than + paravirtualized ones, so they can be used to control the bootloader + and display both firmware and early boot messages; + </li> + <li> + on several platforms, there can only be a single emulated serial + console per guest but paravirtualized consoles don't suffer from the + same limitation. + </li> + </ul> + + <p> + A configuration such as: + </p> + <pre> ... -<devices> - <!-- KVM S390 sclp console --> +</devices> + <console type='pty'> + <target type='serial'/> + </console> <console type='pty'> - <source path='/dev/pts/1'/> - <target type='sclp' port='0'/> + <target type='virtio'/> </console> </devices> ...</pre> <p> - If the console is presented as a serial port, the <code>target</code> - element has the same attributes as for a serial port. There is usually - only 1 console. + will work on any platform and will result in one emulated serial console + for early boot logging / interactive / recovery use, and one + paravirtualized serial console to be used eg. as a side channel. Most + people will be fine with having just the first <code>console</code> + element in their configuration. + </p> + + <p> + Note that, due to the compatibility concerns mentioned earlier, all the + following configurations: + </p> + +<pre> +... +</devices> + <serial type='pty'/> +</devices> +...</pre> + +<pre> +... +</devices> + <console type='pty'/> +</devices> +...</pre> + +<pre> +... +</devices> + <serial type='pty'/> + <console type='pty'/> +</devices> +...</pre> + + <p> + will be treated the same and will result in a single emulated serial + console being available to the guest. </p> <h6><a id="elementCharChannel">Channel</a></h6> -- 2.14.3

On Sun, Nov 26, 2017 at 11:25:22PM +0100, Andrea Bolognani wrote:
Our current documentation is missing some information and doesn't do a great job at explaining how the <serial> and <console> elements are connected. Let's try to fix that.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/formatdomain.html.in | 210 +++++++++++++++++++++++++++++++++------------- 1 file changed, 154 insertions(+), 56 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 505676354..12d7fb407 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6518,77 +6518,62 @@ qemu-kvm -net nic,model=? /dev/null <pre> ... <devices> + <!-- Serial port --> <serial type='pty'> <source path='/dev/pts/3'/> <target port='0'/> </serial> </devices> +...</pre> + +<pre> +... +<devices> + <!-- USB serial port --> + <serial type='pty'> + <target type='usb-serial' port='0'/> + <address type='usb' bus='0' port='1'/> + </serial> +</devices> ...</pre>
<p> - <code>target</code> can have a <code>port</code> attribute, which - specifies the port number. Ports are numbered starting from 0. There are - usually 0, 1 or 2 serial ports. There is also an optional - <code>type</code> attribute <span class="since">since 1.0.2</span> - which has three choices for its value, one is <code>isa-serial</code>, - then <code>usb-serial</code> and last one is <code>pci-serial</code>. - If <code>type</code> is missing, <code>isa-serial</code> will be used by - default. For <code>usb-serial</code> an optional sub-element - <code><address/></code> with <code>type='usb'</code> can tie the - device to a particular controller, <a href="#elementsAddress">documented above</a>. - Similarly, <code>pci-serial</code> can be used to attach the device to - the pci bus (<span class="since">since 1.2.16</span>). Again, it has - optional sub-element <code><address/></code> with - <code>type='pci'</code> to select desired location on the PCI bus. + The <code>target</code> element can have an optional <code>port</code> + attribute, which specifies the port number (starting from 0), and an + optional <code>type</code> attribute: valid values are, + <span class="since">since 1.0.2</span>, <code>isa-serial</code> (usable + on x86 machine types), + <code>usb-serial</code> (usable whenever USB support is available) + and <code>pci-serial</code> (usable whenever PCI support is available). </p>
- <h6><a id="elementCharConsole">Console</a></h6> - <p> - The console element is used to represent interactive consoles. Depending - on the type of guest in use, the consoles might be paravirtualized devices, - or they might be a clone of a serial device, according to the following - rules: + If any of the attributes is not specified by the user, libvirt will + choose a value suitable for most users. </p>
- <ul> - <li>If no <code>targetType</code> attribute is set, then the default - device type is according to the hypervisor's rules. The default - type will be added when re-querying the XML fed into libvirt. - For fully virtualized guests, the default device type will usually - be a serial port.</li> - <li>If the <code>targetType</code> attribute is <code>serial</code>, - then if no <code><serial></code> element exists, the console - element will be copied to the serial element. If a <code><serial></code> - element does already exist, the console element will be ignored.</li> - <li>If the <code>targetType</code> attribute is not <code>serial</code>, - it will be treated normally.</li> - <li>Only the first <code>console</code> element may use a <code>targetType</code> - of <code>serial</code>. Secondary consoles must all be paravirtualized. - </li> - <li>On S390, the <code>console</code> element may use a - <code>targetType</code> of <code>sclp</code> or <code>sclplm</code> - (line mode). SCLP is the native console type for S390. There's no - controller associated to SCLP consoles. - <span class="since">Since 1.0.2</span> - </li> - </ul> - <p> - A virtio console device is exposed in the - guest as /dev/hvc[0-7] (for more information, see - <a href="http://fedoraproject.org/wiki/Features/VirtioSerial">http://fedoraproject.org/wiki/Features/VirtioSerial</a>) - <span class="since">Since 0.8.3</span> + Some of the types support configuring the guest-visible device + address as <a href="#elementsAddress">documented above</a>.
I prefer the original wording where we have explicit list of types that support the <address/> element. Having a link to the generic address description is definitely better but having a list of serial types that support address can help users a lot. From the following patches only "system-serial" and "sclp-serial" cannot have an address element. Currently this sentence should be: "All of the types support...". Later patches should modify this statement to exclude the types that don't support specifying address. Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

Having a separate function for char device handling is better than adding even more code to qemuDomainDeviceDefPostParse(). Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com> --- src/qemu/qemu_domain.c | 57 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9dab6b24b..e59aedcfd 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4086,6 +4086,35 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont, return 0; } +static int +qemuDomainChrDefPostParse(virDomainChrDefPtr chr, + const virDomainDef *def, + virQEMUDriverPtr driver, + unsigned int parseFlags) +{ + /* set the default console type for S390 arches */ + if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && + ARCH_IS_S390(def->os.arch)) { + chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO; + } + + /* clear auto generated unix socket path for inactive definitions */ + if (parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) { + if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0) + return -1; + + /* For UNIX chardev if no path is provided we generate one. + * This also implies that the mode is 'bind'. */ + if (chr->source && + chr->source->type == VIR_DOMAIN_CHR_TYPE_UNIX && + !chr->source->data.nix.path) { + chr->source->data.nix.listen = true; + } + } + + return 0; +} static int qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, @@ -4146,29 +4175,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, } } - /* set the default console type for S390 arches */ - if (dev->type == VIR_DOMAIN_DEVICE_CHR && - dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && - dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && - ARCH_IS_S390(def->os.arch)) - dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO; - - /* clear auto generated unix socket path for inactive definitions */ - if ((parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && - dev->type == VIR_DOMAIN_DEVICE_CHR) { - virDomainChrDefPtr chr = dev->data.chr; - if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0) - goto cleanup; - - /* For UNIX chardev if no path is provided we generate one. - * This also implies that the mode is 'bind'. */ - if (chr->source && - chr->source->type == VIR_DOMAIN_CHR_TYPE_UNIX && - !chr->source->data.nix.path) { - chr->source->data.nix.listen = true; - } - } - if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) { if (dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) { if ARCH_IS_PPC64(def->os.arch) @@ -4204,6 +4210,11 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, qemuDomainShmemDefPostParse(dev->data.shmem) < 0) goto cleanup; + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + qemuDomainChrDefPostParse(dev->data.chr, def, driver, parseFlags) < 0) { + goto cleanup; + } + ret = 0; cleanup: -- 2.14.3

The devicePostParse() callback is invoked for all devices so that drivers have a chance to set their own specific values; however, virDomainDefAddImplicitDevices() runs *after* the devicePostParse() callbacks have been invoked and can add new devices, in which case the driver wouldn't have a chance to customize them. Work around the issue by invoking the devicePostParse() callback after virDomainDefAddImplicitDevices(), only for the first serial devices, which might have been added by it. The same was already happening for the first video device for the very same reason. This will become important later on, when we will change virDomainDefAddConsoleCompat() not to set a targetType for automatically added serial devices. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_conf.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 66536653b..83c121b02 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4946,6 +4946,18 @@ virDomainDefPostParseCommon(virDomainDefPtr def, return -1; } + if (def->nserials != 0) { + virDomainDeviceDef device = { + .type = VIR_DOMAIN_DEVICE_CHR, + .data.chr = def->serials[0], + }; + + /* serials[0] might have been added in AddImplicitDevices, after we've + * done the per-device post-parse */ + if (virDomainDefPostParseDeviceIterator(def, &device, NULL, data) < 0) + return -1; + } + /* clean up possibly duplicated metadata entries */ virXMLNodeSanitizeNamespaces(def->metadata); -- 2.14.3

This is the first step in getting rid of the assumption that isa-serial is the default target type for serial devices. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_conf.c | 8 +++++--- src/conf/domain_conf.h | 3 ++- src/qemu/qemu_command.c | 13 +++++++++++++ src/qemu/qemu_domain.c | 21 +++++++++++++++++++++ src/qemu/qemu_domain_address.c | 1 + 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 83c121b02..1b11d39b5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -448,6 +448,7 @@ VIR_ENUM_IMPL(virDomainChrDeviceState, VIR_DOMAIN_CHR_DEVICE_STATE_LAST, VIR_ENUM_IMPL(virDomainChrSerialTarget, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST, + "none", "isa-serial", "usb-serial", "pci-serial") @@ -4023,7 +4024,7 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def) /* modify it to be a serial port */ def->serials[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; - def->serials[0]->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; + def->serials[0]->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE; def->serials[0]->target.port = 0; } else { /* if the console source doesn't match */ @@ -4047,7 +4048,8 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def) def->serials[0]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) { switch ((virDomainChrSerialTargetType) def->serials[0]->targetType) { - case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: { + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: { /* Create a stub console to match the serial port. * console[0] either does not exist @@ -11493,7 +11495,7 @@ virDomainChrDefaultTargetType(int devtype) return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE; case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: - return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE; case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index dabbff1c2..83b6e9ee5 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1077,7 +1077,8 @@ typedef enum { } virDomainChrDeviceType; typedef enum { - VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA = 0, + VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE = 0, + VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0eb591253..81c652cc3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9259,6 +9259,14 @@ qemuChrIsPlatformDevice(const virDomainDef *def, return true; } + /* If we got all the way here and we're still stuck with the default + * target type for a serial device, it means we have no clue what kind of + * device we're talking about and we must treat it as a platform device. */ + if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) { + return true; + } + return false; } @@ -10407,7 +10415,12 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, } break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: + /* Except from _LAST, which is just a guard value and will never + * be used, all of the above are platform devices, which means + * qemuBuildSerialCommandLine() will have taken the appropriate + * branch and we will not have ended up here. */ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid target type for serial device")); goto error; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e59aedcfd..20e862a7b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4099,6 +4099,27 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO; } + /* Historically, isa-serial and the default matched, so in order to + * maintain backwards compatibility we map them here. The actual default + * will be picked below based on the architecture and machine type. */ + if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA) { + chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE; + } + + /* Set the default serial type */ + if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) { + if (ARCH_IS_X86(def->os.arch)) { + chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; + } else if (qemuDomainIsPSeries(def)) { + /* Setting TYPE_ISA here is just a temporary hack to reduce test + * suite churn. Later on we will have a proper serial type for + * pSeries and this line will be updated accordingly. */ + chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; + } + } + /* clear auto generated unix socket path for inactive definitions */ if (parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) { if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 7f4ac0f45..989c0e6c9 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -782,6 +782,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: return 0; } -- 2.14.3

This attribute was used to decide whether to format the type attribute of the <target> element, but the logic didn't take into account all possible cases and as such could lead to unexpected results. Moreover, it's one more thing to keep track of, and can easily fall out of sync with other attributes. Now that we have VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE, we can use that value to signal that no specific target type has been configured for the serial device and as such the attribute should not be formatted at all. All other values are now formatted. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_conf.c | 11 ++++------- src/conf/domain_conf.h | 1 - src/vz/vz_sdk.c | 3 +-- tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml | 2 +- tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml | 2 +- tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml | 2 +- tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml | 4 ++-- tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml | 2 +- tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml | 2 +- tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml | 2 +- tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml | 4 ++-- tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml | 2 +- tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml | 2 +- .../qemuhotplug-console-compat-2-live+console-virtio.xml | 4 ++-- .../qemuhotplug-console-compat-2-live.xml | 4 ++-- .../qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml | 4 ++-- tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml | 4 ++-- .../qemuxml2xmlout-bios-nvram-os-interleave.xml | 2 +- tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml | 4 ++-- .../qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml | 2 +- tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml | 2 +- tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml | 2 +- .../qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml | 2 +- tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml | 2 +- tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml | 4 ++-- tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml | 2 +- tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml | 2 +- tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml | 2 +- tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml | 2 +- tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml | 2 +- .../qemuxml2xmlout-pseries-cpu-compat-power9.xml | 2 +- .../qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml | 2 +- tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml | 2 +- .../qemuxml2xmlout-pseries-panic-missing.xml | 2 +- .../qemuxml2xmlout-pseries-panic-no-address.xml | 2 +- .../qemuxml2xmlout-q35-virt-manager-basic.xml | 2 +- .../qemuxml2xmlout-serial-spiceport-nospice.xml | 2 +- tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml | 2 +- .../qemuxml2xmlout-serial-target-port-auto.xml | 6 +++--- .../qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml | 4 ++-- .../qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml | 2 +- tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml | 2 +- tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml | 2 +- 43 files changed, 56 insertions(+), 61 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1b11d39b5..6ba6f923c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11507,8 +11507,7 @@ virDomainChrDefaultTargetType(int devtype) } static int -virDomainChrTargetTypeFromString(virDomainChrDefPtr def, - int devtype, +virDomainChrTargetTypeFromString(int devtype, const char *targetType) { int ret = -1; @@ -11536,8 +11535,6 @@ virDomainChrTargetTypeFromString(virDomainChrDefPtr def, break; } - def->targetTypeAttr = true; - return ret; } @@ -11554,7 +11551,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def, char *stateStr = NULL; if ((def->targetType = - virDomainChrTargetTypeFromString(def, def->deviceType, + virDomainChrTargetTypeFromString(def->deviceType, targetType)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown target type '%s' specified for character device"), @@ -16474,7 +16471,7 @@ virDomainChrEquals(virDomainChrDefPtr src, break; case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: - if (src->targetTypeAttr != tgt->targetTypeAttr) + if (src->targetType != tgt->targetType) return false; ATTRIBUTE_FALLTHROUGH; @@ -24035,7 +24032,7 @@ virDomainChrDefFormat(virBufferPtr buf, break; case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: - if (def->targetTypeAttr) { + if (def->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) { virBufferAsprintf(buf, "<target type='%s' port='%d'/>\n", virDomainChrTargetTypeToString(def->deviceType, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 83b6e9ee5..ac6c4a0ed 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1203,7 +1203,6 @@ struct _virDomainChrSourceDef { struct _virDomainChrDef { int deviceType; /* enum virDomainChrDeviceType */ - bool targetTypeAttr; int targetType; /* enum virDomainChrConsoleTargetType || enum virDomainChrChannelTargetType || enum virDomainChrSerialTargetType according to deviceType */ diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 819b02b1e..eea5f6fc6 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1191,7 +1191,6 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDefPtr chr) int ret = -1; chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; - chr->targetTypeAttr = false; pret = PrlVmDev_GetIndex(serialPort, &serialPortIndex); prlsdkCheckRetGoto(pret, cleanup); chr->target.port = serialPortIndex; @@ -2864,7 +2863,7 @@ static int prlsdkCheckSerialUnsupportedParams(virDomainChrDefPtr chr) return -1; } - if (chr->targetTypeAttr) { + if (chr->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Specified character device target type is not " "supported by vz driver.")); diff --git a/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml b/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml index f51284442..7c106f145 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml @@ -28,7 +28,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml index aac814d59..e76d0211d 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml @@ -29,7 +29,7 @@ </controller> <serial type='dev'> <source path='/dev/ttyS2'/> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='dev'> <source path='/dev/ttyS2'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml index 64819a48a..ed67ada0d 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml @@ -29,7 +29,7 @@ </controller> <serial type='file'> <source path='/tmp/serial.log'/> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='file'> <source path='/tmp/serial.log'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml index e00afe317..420771dc9 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml @@ -28,11 +28,11 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <serial type='file'> <source path='/tmp/serial.log'/> - <target port='1'/> + <target type='isa-serial' port='1'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml index f51284442..7c106f145 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml @@ -28,7 +28,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml index c35a4ca73..3fe61ffa0 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml @@ -30,7 +30,7 @@ <serial type='tcp'> <source mode='bind' host='127.0.0.1' service='9999'/> <protocol type='telnet'/> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='tcp'> <source mode='bind' host='127.0.0.1' service='9999'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml index 0d218f548..3fc9fd39b 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml @@ -30,7 +30,7 @@ <serial type='tcp'> <source mode='connect' host='127.0.0.1' service='9999'/> <protocol type='raw'/> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='tcp'> <source mode='connect' host='127.0.0.1' service='9999'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml index f7069d541..5b4af3fe9 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml @@ -30,11 +30,11 @@ <serial type='udp'> <source mode='bind' host='127.0.0.1' service='9999'/> <source mode='connect' host='127.0.0.1' service='9998'/> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <serial type='udp'> <source mode='connect' service='9999'/> - <target port='1'/> + <target type='isa-serial' port='1'/> </serial> <console type='udp'> <source mode='bind' host='127.0.0.1' service='9999'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml index 14fc8fc7c..6bb291ff7 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml @@ -29,7 +29,7 @@ </controller> <serial type='unix'> <source mode='connect' path='/tmp/serial.sock'/> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='unix'> <source mode='connect' path='/tmp/serial.sock'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml index 95aa1c7b9..41954fc85 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml @@ -28,7 +28,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <serial type='vc'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='vc'> <target type='serial' port='0'/> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml index 4e1dd49c2..427f431cc 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml @@ -72,13 +72,13 @@ <alias name='serial0'/> </serial> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> <alias name='serial1'/> </serial> <serial type='tcp'> <source mode='bind' host='0.0.0.0' service='2445'/> <protocol type='raw'/> - <target port='1'/> + <target type='isa-serial' port='1'/> <alias name='serial2'/> </serial> <console type='pty'> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml index c56d13ef4..144f6eff7 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml @@ -72,13 +72,13 @@ <alias name='serial0'/> </serial> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> <alias name='serial1'/> </serial> <serial type='tcp'> <source mode='bind' host='0.0.0.0' service='2445'/> <protocol type='raw'/> - <target port='1'/> + <target type='isa-serial' port='1'/> <alias name='serial2'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml index a95e29ad8..e6c4adb6f 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml @@ -29,12 +29,12 @@ <serial type='udp'> <source mode='bind' host='127.0.0.1' service='1111'/> <source mode='connect' host='127.0.0.1' service='2222'/> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <serial type='tcp'> <source mode='connect' host='127.0.0.1' service='5555' tls='no'/> <protocol type='raw'/> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='udp'> <source mode='bind' host='127.0.0.1' service='1111'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml index c760098fe..f9724d320 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml @@ -110,10 +110,10 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> </interface> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <serial type='pty'> - <target port='1'/> + <target type='isa-serial' port='1'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml index 033e86d3a..5ee73b527 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml @@ -33,7 +33,7 @@ </controller> <controller type='pci' index='0' model='pci-root'/> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml index 840bf69f6..ad77f62d9 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml @@ -25,13 +25,13 @@ <source path='/tmp/serial.file'> <seclabel model='dac' relabel='no'/> </source> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <serial type='unix'> <source mode='connect' path='/tmp/serial.sock'> <seclabel model='dac' relabel='no'/> </source> - <target port='1'/> + <target type='isa-serial' port='1'/> </serial> <console type='file'> <source path='/tmp/serial.file'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml index e76f857ae..cd9d75c4b 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml @@ -27,7 +27,7 @@ </controller> <controller type='pci' index='0' model='pci-root'/> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml index 8dc361dfc..0c0bd7b34 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml @@ -28,7 +28,7 @@ </controller> <controller type='pci' index='0' model='pci-root'/> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml index 858b2c675..305c53eab 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml @@ -31,7 +31,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </controller> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml index f9f9abd2d..b38b3ce98 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml @@ -30,7 +30,7 @@ </controller> <controller type='pci' index='0' model='pci-root'/> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml index 1c5501767..06192fbb4 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml @@ -47,7 +47,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml index 95b6e2df1..a6eaa3807 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml @@ -104,10 +104,10 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> </interface> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <serial type='pty'> - <target port='1'/> + <target type='isa-serial' port='1'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml index 7fe69bd6c..e6ad23424 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml @@ -55,7 +55,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </interface> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml index b631e5b51..66448ec3d 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml @@ -44,7 +44,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </interface> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml index fd5fdbece..b1240b8ed 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml @@ -57,7 +57,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </interface> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml index 4571b6a82..4f7ad323e 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml @@ -54,7 +54,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </interface> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml index 7fb49feb0..a563b6ddd 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml @@ -22,7 +22,7 @@ <target index='0'/> </controller> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> <address type='spapr-vio' reg='0x30000000'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml index f02005621..59587b3c3 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml @@ -25,7 +25,7 @@ <target index='0'/> </controller> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> <address type='spapr-vio' reg='0x30000000'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml index 3cbce9fe6..a39e1fd01 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml @@ -25,7 +25,7 @@ <target index='0'/> </controller> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> <address type='spapr-vio' reg='0x30000000'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml index d69b38768..666eede1a 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml @@ -26,7 +26,7 @@ <target index='0'/> </controller> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> <address type='spapr-vio' reg='0x30000000'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml index 7fb49feb0..a563b6ddd 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml @@ -22,7 +22,7 @@ <target index='0'/> </controller> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> <address type='spapr-vio' reg='0x30000000'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml index 7fb49feb0..a563b6ddd 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml @@ -22,7 +22,7 @@ <target index='0'/> </controller> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> <address type='spapr-vio' reg='0x30000000'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml index c4ccd98aa..27baaa3f1 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml @@ -79,7 +79,7 @@ <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> </interface> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml index 79c4ebc73..63462e6f9 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml @@ -28,7 +28,7 @@ <controller type='pci' index='0' model='pci-root'/> <serial type='spiceport'> <source channel='org.qemu.console.serial.0'/> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='spiceport'> <source channel='org.qemu.console.serial.0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml index 9527b2d15..c90bbeb7d 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml @@ -28,7 +28,7 @@ <controller type='pci' index='0' model='pci-root'/> <serial type='spiceport'> <source channel='org.qemu.console.serial.0'/> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='spiceport'> <source channel='org.qemu.console.serial.0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml index 71516a31a..a8790b509 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml @@ -27,13 +27,13 @@ </controller> <controller type='pci' index='0' model='pci-root'/> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <serial type='null'> - <target port='1'/> + <target type='isa-serial' port='1'/> </serial> <serial type='stdio'> - <target port='2'/> + <target type='isa-serial' port='2'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml index 18f51e538..a8af87b53 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml @@ -29,12 +29,12 @@ <serial type='udp'> <source mode='bind' host='127.0.0.1' service='1111'/> <source mode='connect' host='127.0.0.1' service='2222'/> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <serial type='tcp'> <source mode='connect' host='127.0.0.1' service='5555'/> <protocol type='raw'/> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='udp'> <source mode='bind' host='127.0.0.1' service='1111'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml index a6be7542c..f439f57ea 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml @@ -42,7 +42,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </interface> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml index 7787befb8..a2a6e5b3c 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml @@ -48,7 +48,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml index 8c27470dd..72cbcc4cb 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml @@ -46,7 +46,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> - <target port='0'/> + <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> -- 2.14.3

Move formatting of the <target/> element for char devices out of virDomainChrDefFormat() and into its own function. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_conf.c | 67 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6ba6f923c..c0e239def 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23945,38 +23945,15 @@ virDomainChrSourceDefFormat(virBufferPtr buf, return -1; } + static int -virDomainChrDefFormat(virBufferPtr buf, - virDomainChrDefPtr def, - unsigned int flags) +virDomainChrTargetDefFormat(virBufferPtr buf, + const virDomainChrDef *def, + unsigned int flags) { - const char *elementName = virDomainChrDeviceTypeToString(def->deviceType); const char *targetType = virDomainChrTargetTypeToString(def->deviceType, def->targetType); - bool tty_compat; - - int ret = 0; - - if (!elementName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected char device type %d"), - def->deviceType); - return -1; - } - virBufferAsprintf(buf, "<%s", elementName); - virBufferAdjustIndent(buf, 2); - tty_compat = (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && - def->target.port == 0 && - def->source->type == VIR_DOMAIN_CHR_TYPE_PTY && - !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) && - def->source->data.file.path); - if (virDomainChrAttrsDefFormat(buf, def->source, tty_compat) < 0) - return -1; - virBufferAddLit(buf, ">\n"); - virDomainChrSourceDefFormat(buf, def->source, flags); - - /* Format <target> block */ switch (def->deviceType) { case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: { if (!targetType) { @@ -24048,6 +24025,42 @@ virDomainChrDefFormat(virBufferPtr buf, break; } + return 0; +} + + +static int +virDomainChrDefFormat(virBufferPtr buf, + virDomainChrDefPtr def, + unsigned int flags) +{ + const char *elementName = virDomainChrDeviceTypeToString(def->deviceType); + bool tty_compat; + + int ret = 0; + + if (!elementName) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected char device type %d"), + def->deviceType); + return -1; + } + + virBufferAsprintf(buf, "<%s", elementName); + virBufferAdjustIndent(buf, 2); + tty_compat = (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + def->target.port == 0 && + def->source->type == VIR_DOMAIN_CHR_TYPE_PTY && + !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) && + def->source->data.file.path); + if (virDomainChrAttrsDefFormat(buf, def->source, tty_compat) < 0) + return -1; + virBufferAddLit(buf, ">\n"); + virDomainChrSourceDefFormat(buf, def->source, flags); + + if (virDomainChrTargetDefFormat(buf, def, flags) < 0) + return -1; + virDomainDeviceInfoFormat(buf, &def->info, flags); virBufferAdjustIndent(buf, -2); -- 2.14.3

We don't need to store the return value since we never modify it. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/conf/domain_conf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c0e239def..cb98631fb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -24037,8 +24037,6 @@ virDomainChrDefFormat(virBufferPtr buf, const char *elementName = virDomainChrDeviceTypeToString(def->deviceType); bool tty_compat; - int ret = 0; - if (!elementName) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected char device type %d"), @@ -24059,14 +24057,14 @@ virDomainChrDefFormat(virBufferPtr buf, virDomainChrSourceDefFormat(buf, def->source, flags); if (virDomainChrTargetDefFormat(buf, def, flags) < 0) - return -1; + return -1; virDomainDeviceInfoFormat(buf, &def->info, flags); virBufferAdjustIndent(buf, -2); virBufferAsprintf(buf, "</%s>\n", elementName); - return ret; + return 0; } static int -- 2.14.3

On Sun, Nov 26, 2017 at 11:25:28PM +0100, Andrea Bolognani wrote:
We don't need to store the return value since we never modify it.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/conf/domain_conf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

The function can fail, but none of the caller were accounting for that. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/conf/domain_conf.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cb98631fb..4bae0cc94 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -24054,7 +24054,9 @@ virDomainChrDefFormat(virBufferPtr buf, if (virDomainChrAttrsDefFormat(buf, def->source, tty_compat) < 0) return -1; virBufferAddLit(buf, ">\n"); - virDomainChrSourceDefFormat(buf, def->source, flags); + + if (virDomainChrSourceDefFormat(buf, def->source, flags) < 0) + return -1; if (virDomainChrTargetDefFormat(buf, def, flags) < 0) return -1; @@ -24075,13 +24077,14 @@ virDomainSmartcardDefFormat(virBufferPtr buf, const char *mode = virDomainSmartcardTypeToString(def->type); virBuffer childBuf = VIR_BUFFER_INITIALIZER; size_t i; + int ret = -1; virBufferSetChildIndent(&childBuf, buf); if (!mode) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected smartcard type %d"), def->type); - return -1; + goto cleanup; } switch (def->type) { @@ -24098,23 +24101,25 @@ virDomainSmartcardDefFormat(virBufferPtr buf, break; case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: - virDomainChrSourceDefFormat(&childBuf, def->data.passthru, flags); + if (virDomainChrSourceDefFormat(&childBuf, def->data.passthru, flags) < 0) + goto cleanup; break; default: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected smartcard type %d"), def->type); - return -1; + goto cleanup; } virDomainDeviceInfoFormat(&childBuf, &def->info, flags); if (virBufferCheckError(&childBuf) < 0) - return -1; + goto cleanup; virBufferAsprintf(buf, "<smartcard mode='%s'", mode); if (def->type == VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH && - virDomainChrAttrsDefFormat(buf, def->data.passthru, false) < 0) - return -1; + virDomainChrAttrsDefFormat(buf, def->data.passthru, false) < 0) { + goto cleanup; + } if (virBufferUse(&childBuf)) { virBufferAddLit(buf, ">\n"); @@ -24123,7 +24128,12 @@ virDomainSmartcardDefFormat(virBufferPtr buf, } else { virBufferAddLit(buf, "/>\n"); } - return 0; + + ret = 0; + + cleanup: + virBufferFreeAndReset(&childBuf); + return ret; } static int @@ -24425,7 +24435,8 @@ virDomainRNGDefFormat(virBufferPtr buf, return -1; virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); - virDomainChrSourceDefFormat(buf, def->source.chardev, flags); + if (virDomainChrSourceDefFormat(buf, def->source.chardev, flags) < 0) + return -1; virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</backend>\n"); @@ -25270,7 +25281,10 @@ virDomainRedirdevDefFormat(virBufferPtr buf, return -1; virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); - virDomainChrSourceDefFormat(buf, def->source, flags); + + if (virDomainChrSourceDefFormat(buf, def->source, flags) < 0) + return -1; + virDomainDeviceInfoFormat(buf, &def->info, flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT); virBufferAdjustIndent(buf, -2); -- 2.14.3

On Sun, Nov 26, 2017 at 11:25:29PM +0100, Andrea Bolognani wrote:
The function can fail, but none of the caller were accounting for that.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/conf/domain_conf.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

Make the switch statement type-aware, avoid calling virDomainChrTargetTypeToString() more than once and check its return value before using it. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_conf.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4bae0cc94..72d5f289c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23954,7 +23954,7 @@ virDomainChrTargetDefFormat(virBufferPtr buf, const char *targetType = virDomainChrTargetTypeToString(def->deviceType, def->targetType); - switch (def->deviceType) { + switch ((virDomainChrDeviceType) def->deviceType) { case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: { if (!targetType) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -24001,28 +24001,43 @@ virDomainChrTargetDefFormat(virBufferPtr buf, } case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: + if (!targetType) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not format console target type")); + return -1; + } + virBufferAsprintf(buf, "<target type='%s' port='%d'/>\n", - virDomainChrTargetTypeToString(def->deviceType, - def->targetType), - def->target.port); + targetType, def->target.port); break; case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: + if (!targetType) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not format serial target type")); + return -1; + } + if (def->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) { virBufferAsprintf(buf, "<target type='%s' port='%d'/>\n", - virDomainChrTargetTypeToString(def->deviceType, - def->targetType), + targetType, def->target.port); break; } ATTRIBUTE_FALLTHROUGH; - default: + case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: virBufferAsprintf(buf, "<target port='%d'/>\n", def->target.port); break; + + case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected char device type %d"), + def->deviceType); + return -1; } return 0; -- 2.14.3

Formatting the <target/> element for serial devices will become a bit more complicated later on, and leaving the fallthrough behavior there would do nothing but complicate it further. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_conf.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 72d5f289c..42e7596ac 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -24019,14 +24019,18 @@ virDomainChrTargetDefFormat(virBufferPtr buf, return -1; } + virBufferAddLit(buf, "<target "); + if (def->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) { virBufferAsprintf(buf, - "<target type='%s' port='%d'/>\n", - targetType, - def->target.port); - break; + "type='%s' ", + targetType); } - ATTRIBUTE_FALLTHROUGH; + + virBufferAsprintf(buf, + "port='%d'/>\n", + def->target.port); + break; case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: virBufferAsprintf(buf, "<target port='%d'/>\n", -- 2.14.3

Instead of waiting until we get to command line generation, we can validate the target for a char device much earlier. Move all the checks out of qemuBuildSerialChrDeviceStr() and into the new fuction. This will later allow us to validate the target for platform devices. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_command.c | 20 ---------------- src/qemu/qemu_domain.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 81c652cc3..0a4684231 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10382,22 +10382,9 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, _("usb-serial is not supported in this QEMU binary")); goto error; } - - if (serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && - serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("usb-serial requires address of usb type")); - goto error; - } break; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: - if (serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && - serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("isa-serial requires address of isa type")); - goto error; - } break; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: @@ -10406,13 +10393,6 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, _("pci-serial is not supported with this QEMU binary")); goto error; } - - if (serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && - serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("pci-serial requires address of pci type")); - goto error; - } break; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 20e862a7b..0a04d9a24 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3460,6 +3460,65 @@ qemuDomainChrSourceDefValidate(const virDomainChrSourceDef *def) } +static int +qemuDomainChrTargetDefValidate(const virDomainDef *def, + const virDomainChrDef *chr) +{ + switch ((virDomainChrDeviceType) chr->deviceType) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: + + /* Validate target type */ + switch ((virDomainChrSerialTargetType) chr->targetType) { + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: + /* Hack required until we have a proper type for pSeries + * serial consoles */ + if (qemuDomainIsPSeries(def)) + return 0; + + if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("isa-serial requires address of isa type")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: + if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("usb-serial requires address of usb type")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: + if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("pci-serial requires address of pci type")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: + break; + } + break; + + case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: + case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST: + /* Nothing to do */ + break; + } + + return 0; +} + + static int qemuDomainChrDefValidate(const virDomainChrDef *dev, const virDomainDef *def) @@ -3467,6 +3526,9 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, if (qemuDomainChrSourceDefValidate(dev->source) < 0) return -1; + if (qemuDomainChrTargetDefValidate(def, dev) < 0) + return -1; + if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL && (ARCH_IS_S390(def->os.arch) || qemuDomainIsPSeries(def))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", -- 2.14.3

Instead of validating each target type / address type combination separately, create a small helper to perform the matching and collapse all existing checks into a single one. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/qemu/qemu_domain.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0a04d9a24..a719d14fe 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3460,43 +3460,53 @@ qemuDomainChrSourceDefValidate(const virDomainChrSourceDef *def) } +static int +qemuDomainChrSerialTargetTypeToAddressType(int targetType) +{ + switch ((virDomainChrSerialTargetType) targetType) { + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: + return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: + return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: + return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: + break; + } + + return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; +} + + static int qemuDomainChrTargetDefValidate(const virDomainDef *def, const virDomainChrDef *chr) { + int expected; + switch ((virDomainChrDeviceType) chr->deviceType) { case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: /* Validate target type */ switch ((virDomainChrSerialTargetType) chr->targetType) { case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: + /* Hack required until we have a proper type for pSeries * serial consoles */ if (qemuDomainIsPSeries(def)) return 0; - if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && - chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("isa-serial requires address of isa type")); - return -1; - } - break; - - case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: - if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && - chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("usb-serial requires address of usb type")); - return -1; - } - break; + expected = qemuDomainChrSerialTargetTypeToAddressType(chr->targetType); - case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && - chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("pci-serial requires address of pci type")); + chr->info.type != expected) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target type '%s' requires address type '%s'"), + virDomainChrSerialTargetTypeToString(chr->targetType), + virDomainDeviceAddressTypeToString(expected)); return -1; } break; -- 2.14.3

On Sun, Nov 26, 2017 at 11:25:33PM +0100, Andrea Bolognani wrote:
Instead of validating each target type / address type combination separately, create a small helper to perform the matching and collapse all existing checks into a single one.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/qemu/qemu_domain.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

This information will be used to select, and store in the guest configuration in order to guarantee ABI stability, the concrete (hypervisor-specific) model for serial devices. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/formatdomain.html.in | 16 ++++++++-- docs/schemas/domaincommon.rng | 15 +++++++++ src/conf/domain_conf.c | 72 ++++++++++++++++++++++++++++++++++++++++++- src/conf/domain_conf.h | 12 ++++++++ 4 files changed, 112 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 12d7fb407..3126d6ed1 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6531,7 +6531,9 @@ qemu-kvm -net nic,model=? /dev/null <devices> <!-- USB serial port --> <serial type='pty'> - <target type='usb-serial' port='0'/> + <target type='usb-serial' port='0'> + <model name='usb-serial'/> + </target> <address type='usb' bus='0' port='1'/> </serial> </devices> @@ -6547,6 +6549,16 @@ qemu-kvm -net nic,model=? /dev/null and <code>pci-serial</code> (usable whenever PCI support is available). </p> + <p> + <span class="since">Since 3.10.0</span>, the <code>target</code> + element can have an optional <code>model</code> subelement; + valid values for its <code>name</code> attribute are: + <code>isa-serial</code> (usable with the <code>isa-serial</code> target + type); <code>usb-serial</code> (usable with the <code>usb-serial</code> + target type); <code>pci-serial</code> + (usable with the <code>pci-serial</code> target type). + </p> + <p> If any of the attributes is not specified by the user, libvirt will choose a value suitable for most users. @@ -6567,7 +6579,7 @@ qemu-kvm -net nic,model=? /dev/null <!-- Serial console --> <console type='pty'> <source path='/dev/pts/2'/> - <target type='serial' port='0'/> + <target type='serial' port='0'/> </console> </devices> ...</pre> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index f1808065b..fbba092d1 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3589,6 +3589,18 @@ </attribute> </define> + <define name='qemucdevSerialTgtModel'> + <element name='model'> + <attribute name='name'> + <choice> + <value>isa-serial</value> + <value>usb-serial</value> + <value>pci-serial</value> + </choice> + </attribute> + </element> + </define> + <define name="qemucdevTgtDef"> <element name="target"> <interleave> @@ -3603,6 +3615,9 @@ <optional> <attribute name="port"/> </optional> + <optional> + <ref name="qemucdevSerialTgtModel"/> + </optional> </interleave> </element> </define> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 42e7596ac..5df5f3aae 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -472,6 +472,14 @@ VIR_ENUM_IMPL(virDomainChrConsoleTarget, "sclp", "sclplm") +VIR_ENUM_IMPL(virDomainChrSerialTargetModel, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST, + "none", + "isa-serial", + "usb-serial", + "pci-serial", +); + VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST, "parallel", "serial", @@ -11538,14 +11546,42 @@ virDomainChrTargetTypeFromString(int devtype, return ret; } +static int +virDomainChrTargetModelFromString(int devtype, + const char *targetModel) +{ + int ret = -1; + + if (!targetModel) + return 0; + + switch ((virDomainChrDeviceType) devtype) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: + ret = virDomainChrSerialTargetModelTypeFromString(targetModel); + break; + + case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: + case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST: + /* Target model not supported yet */ + ret = 0; + break; + } + + return ret; +} + static int virDomainChrDefParseTargetXML(virDomainChrDefPtr def, xmlNodePtr cur, unsigned int flags) { int ret = -1; + xmlNodePtr child; unsigned int port; char *targetType = virXMLPropString(cur, "type"); + char *targetModel = NULL; char *addrStr = NULL; char *portStr = NULL; char *stateStr = NULL; @@ -11559,6 +11595,24 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def, goto error; } + child = cur->children; + while (child != NULL) { + if (child->type == XML_ELEMENT_NODE && + virXMLNodeNameEqual(child, "model")) { + targetModel = virXMLPropString(child, "name"); + } + child = child->next; + } + + if ((def->targetModel = + virDomainChrTargetModelFromString(def->deviceType, + targetModel)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown target model '%s' specified for character device"), + targetModel); + goto error; + } + switch (def->deviceType) { case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: switch (def->targetType) { @@ -11647,6 +11701,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def, ret = 0; error: VIR_FREE(targetType); + VIR_FREE(targetModel); VIR_FREE(addrStr); VIR_FREE(portStr); VIR_FREE(stateStr); @@ -24028,8 +24083,23 @@ virDomainChrTargetDefFormat(virBufferPtr buf, } virBufferAsprintf(buf, - "port='%d'/>\n", + "port='%d'", def->target.port); + + if (def->targetModel != VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE) { + virBufferAddLit(buf, ">\n"); + + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, + "<model name='%s'/>\n", + virDomainChrSerialTargetModelTypeToString(def->targetModel)); + virBufferAdjustIndent(buf, -2); + + virBufferAddLit(buf, "</target>\n"); + } else { + virBufferAddLit(buf, "/>\n"); + } + break; case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ac6c4a0ed..7895dea55 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1108,6 +1108,17 @@ typedef enum { VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST } virDomainChrConsoleTargetType; +typedef enum { + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE = 0, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL, + + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST +} virDomainChrSerialTargetModel; + +VIR_ENUM_DECL(virDomainChrSerialTargetModel); + typedef enum { VIR_DOMAIN_CHR_TYPE_NULL, VIR_DOMAIN_CHR_TYPE_VC, @@ -1206,6 +1217,7 @@ struct _virDomainChrDef { int targetType; /* enum virDomainChrConsoleTargetType || enum virDomainChrChannelTargetType || enum virDomainChrSerialTargetType according to deviceType */ + int targetModel; /* enum virDomainChrSerialTargetModel */ union { int port; /* parallel, serial, console */ -- 2.14.3

On Sun, Nov 26, 2017 at 11:25:34PM +0100, Andrea Bolognani wrote:
This information will be used to select, and store in the guest configuration in order to guarantee ABI stability, the concrete (hypervisor-specific) model for serial devices.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/formatdomain.html.in | 16 ++++++++-- docs/schemas/domaincommon.rng | 15 +++++++++ src/conf/domain_conf.c | 72 ++++++++++++++++++++++++++++++++++++++++++- src/conf/domain_conf.h | 12 ++++++++ 4 files changed, 112 insertions(+), 3 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_domain.c | 20 ++++++++++++++++++++ .../qemuargv2xmldata/qemuargv2xml-console-compat.xml | 4 +++- tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml | 4 +++- tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml | 4 +++- tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml | 8 ++++++-- tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml | 4 +++- .../qemuargv2xml-serial-tcp-telnet.xml | 4 +++- tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml | 4 +++- tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml | 8 ++++++-- tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml | 4 +++- tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml | 4 +++- ...uhotplug-console-compat-2-live+console-virtio.xml | 12 +++++++++--- .../qemuhotplug-console-compat-2-live.xml | 12 +++++++++--- ...qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml | 8 ++++++-- tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml | 8 ++++++-- .../qemuxml2xmlout-aarch64-pci-serial.xml | 4 +++- .../qemuxml2xmlout-bios-nvram-os-interleave.xml | 4 +++- .../qemuxml2xmlout-chardev-label.xml | 8 ++++++-- .../qemuxml2xmlout-console-compat-auto.xml | 4 +++- .../qemuxml2xmlout-console-compat.xml | 4 +++- .../qemuxml2xmlout-console-compat2.xml | 4 +++- .../qemuxml2xmlout-console-virtio-many.xml | 4 +++- .../qemuxml2xmlout-interface-driver.xml | 4 +++- .../qemuxml2xmlout-interface-server.xml | 8 ++++++-- .../qemuxml2xmlout-net-bandwidth.xml | 4 +++- .../qemuxml2xmlout-net-bandwidth2.xml | 4 +++- .../qemuxml2xmlout-net-coalesce.xml | 4 +++- tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml | 4 +++- .../qemuxml2xmlout-panic-pseries.xml | 4 +++- .../qemuxml2xmlout-pci-serial-dev-chardev.xml | 4 +++- .../qemuxml2xmlout-pseries-cpu-compat-power9.xml | 4 +++- .../qemuxml2xmlout-pseries-cpu-compat.xml | 4 +++- .../qemuxml2xmlout-pseries-cpu-exact.xml | 4 +++- .../qemuxml2xmlout-pseries-panic-missing.xml | 4 +++- .../qemuxml2xmlout-pseries-panic-no-address.xml | 4 +++- .../qemuxml2xmlout-q35-virt-manager-basic.xml | 4 +++- .../qemuxml2xmlout-serial-spiceport-nospice.xml | 4 +++- .../qemuxml2xmlout-serial-spiceport.xml | 4 +++- .../qemuxml2xmlout-serial-target-port-auto.xml | 12 +++++++++--- .../qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml | 8 ++++++-- .../qemuxml2xmlout-tap-vhost-incorrect.xml | 4 +++- .../qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml | 4 +++- .../qemuxml2xmlout-vhost_queues.xml | 4 +++- 43 files changed, 185 insertions(+), 55 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a719d14fe..e141e1132 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4192,6 +4192,26 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, } } + /* Set the default target model */ + if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + chr->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE) { + switch ((virDomainChrSerialTargetType) chr->targetType) { + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: + chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL; + break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: + chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL; + break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: + chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL; + break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: + /* Nothing to do */ + break; + } + } + /* clear auto generated unix socket path for inactive definitions */ if (parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) { if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0) diff --git a/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml b/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml index 7c106f145..cba43ca45 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml @@ -28,7 +28,9 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml index e76d0211d..e9998d554 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml @@ -29,7 +29,9 @@ </controller> <serial type='dev'> <source path='/dev/ttyS2'/> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='dev'> <source path='/dev/ttyS2'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml index ed67ada0d..0e9dfe578 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml @@ -29,7 +29,9 @@ </controller> <serial type='file'> <source path='/tmp/serial.log'/> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='file'> <source path='/tmp/serial.log'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml index 420771dc9..05374b38d 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml @@ -28,11 +28,15 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <serial type='file'> <source path='/tmp/serial.log'/> - <target type='isa-serial' port='1'/> + <target type='isa-serial' port='1'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml index 7c106f145..cba43ca45 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml @@ -28,7 +28,9 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml index 3fe61ffa0..1ac12440e 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml @@ -30,7 +30,9 @@ <serial type='tcp'> <source mode='bind' host='127.0.0.1' service='9999'/> <protocol type='telnet'/> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='tcp'> <source mode='bind' host='127.0.0.1' service='9999'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml index 3fc9fd39b..c10cee903 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml @@ -30,7 +30,9 @@ <serial type='tcp'> <source mode='connect' host='127.0.0.1' service='9999'/> <protocol type='raw'/> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='tcp'> <source mode='connect' host='127.0.0.1' service='9999'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml index 5b4af3fe9..fd56dda84 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml @@ -30,11 +30,15 @@ <serial type='udp'> <source mode='bind' host='127.0.0.1' service='9999'/> <source mode='connect' host='127.0.0.1' service='9998'/> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <serial type='udp'> <source mode='connect' service='9999'/> - <target type='isa-serial' port='1'/> + <target type='isa-serial' port='1'> + <model name='isa-serial'/> + </target> </serial> <console type='udp'> <source mode='bind' host='127.0.0.1' service='9999'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml index 6bb291ff7..70b192f67 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml @@ -29,7 +29,9 @@ </controller> <serial type='unix'> <source mode='connect' path='/tmp/serial.sock'/> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='unix'> <source mode='connect' path='/tmp/serial.sock'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml index 41954fc85..630844ea0 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml @@ -28,7 +28,9 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <serial type='vc'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='vc'> <target type='serial' port='0'/> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml index 427f431cc..abe68a0a0 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml @@ -68,17 +68,23 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> <alias name='serial0'/> </serial> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> <alias name='serial1'/> </serial> <serial type='tcp'> <source mode='bind' host='0.0.0.0' service='2445'/> <protocol type='raw'/> - <target type='isa-serial' port='1'/> + <target type='isa-serial' port='1'> + <model name='isa-serial'/> + </target> <alias name='serial2'/> </serial> <console type='pty'> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml index 144f6eff7..45161e1e2 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml @@ -68,17 +68,23 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> <alias name='serial0'/> </serial> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> <alias name='serial1'/> </serial> <serial type='tcp'> <source mode='bind' host='0.0.0.0' service='2445'/> <protocol type='raw'/> - <target type='isa-serial' port='1'/> + <target type='isa-serial' port='1'> + <model name='isa-serial'/> + </target> <alias name='serial2'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml index e6c4adb6f..89dc9e6e1 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml @@ -29,12 +29,16 @@ <serial type='udp'> <source mode='bind' host='127.0.0.1' service='1111'/> <source mode='connect' host='127.0.0.1' service='2222'/> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <serial type='tcp'> <source mode='connect' host='127.0.0.1' service='5555' tls='no'/> <protocol type='raw'/> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='udp'> <source mode='bind' host='127.0.0.1' service='1111'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml index f9724d320..52132a82d 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml @@ -110,10 +110,14 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <serial type='pty'> - <target type='isa-serial' port='1'/> + <target type='isa-serial' port='1'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-pci-serial.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-pci-serial.xml index fddab31f0..b02a5a7db 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-pci-serial.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-pci-serial.xml @@ -34,7 +34,9 @@ </controller> <serial type='pty'> <log file='/tmp/log' append='on'/> - <target type='pci-serial' port='0'/> + <target type='pci-serial' port='0'> + <model name='pci-serial'/> + </target> <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/> </serial> </devices> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml index 5ee73b527..b6d7a6636 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml @@ -33,7 +33,9 @@ </controller> <controller type='pci' index='0' model='pci-root'/> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml index ad77f62d9..7d5bbdd0a 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml @@ -25,13 +25,17 @@ <source path='/tmp/serial.file'> <seclabel model='dac' relabel='no'/> </source> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <serial type='unix'> <source mode='connect' path='/tmp/serial.sock'> <seclabel model='dac' relabel='no'/> </source> - <target type='isa-serial' port='1'/> + <target type='isa-serial' port='1'> + <model name='isa-serial'/> + </target> </serial> <console type='file'> <source path='/tmp/serial.file'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml index cd9d75c4b..267b253b1 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml @@ -27,7 +27,9 @@ </controller> <controller type='pci' index='0' model='pci-root'/> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml index 0c0bd7b34..6a52800a3 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml @@ -28,7 +28,9 @@ </controller> <controller type='pci' index='0' model='pci-root'/> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml index 305c53eab..8c7bbb768 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml @@ -31,7 +31,9 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml index b38b3ce98..1a22b78b8 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml @@ -30,7 +30,9 @@ </controller> <controller type='pci' index='0' model='pci-root'/> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml index 06192fbb4..5be590e75 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml @@ -47,7 +47,9 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml index a6eaa3807..049b1472a 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml @@ -104,10 +104,14 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <serial type='pty'> - <target type='isa-serial' port='1'/> + <target type='isa-serial' port='1'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml index e6ad23424..4ec77d154 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml @@ -55,7 +55,9 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml index 66448ec3d..ee65c3a5b 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml @@ -44,7 +44,9 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml index b1240b8ed..56792b999 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml @@ -57,7 +57,9 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml index 4f7ad323e..fc7b2e39a 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml @@ -54,7 +54,9 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml index a563b6ddd..496df0696 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml @@ -22,7 +22,9 @@ <target index='0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> <address type='spapr-vio' reg='0x30000000'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-serial-dev-chardev.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-serial-dev-chardev.xml index 2f704cc0a..8f77ef043 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-serial-dev-chardev.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-serial-dev-chardev.xml @@ -28,7 +28,9 @@ <controller type='pci' index='0' model='pci-root'/> <serial type='dev'> <source path='/dev/ttyS2'/> - <target type='pci-serial' port='0'/> + <target type='pci-serial' port='0'> + <model name='pci-serial'/> + </target> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </serial> <console type='dev'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml index 59587b3c3..9d4c5efe6 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml @@ -25,7 +25,9 @@ <target index='0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> <address type='spapr-vio' reg='0x30000000'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml index a39e1fd01..6059859ab 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml @@ -25,7 +25,9 @@ <target index='0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> <address type='spapr-vio' reg='0x30000000'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml index 666eede1a..f3216523e 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml @@ -26,7 +26,9 @@ <target index='0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> <address type='spapr-vio' reg='0x30000000'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml index a563b6ddd..496df0696 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml @@ -22,7 +22,9 @@ <target index='0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> <address type='spapr-vio' reg='0x30000000'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml index a563b6ddd..496df0696 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml @@ -22,7 +22,9 @@ <target index='0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> <address type='spapr-vio' reg='0x30000000'/> </serial> <console type='pty'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml index 27baaa3f1..2437fdec4 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml @@ -79,7 +79,9 @@ <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml index 63462e6f9..e1d5cb9d7 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml @@ -28,7 +28,9 @@ <controller type='pci' index='0' model='pci-root'/> <serial type='spiceport'> <source channel='org.qemu.console.serial.0'/> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='spiceport'> <source channel='org.qemu.console.serial.0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml index c90bbeb7d..ff92435af 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml @@ -28,7 +28,9 @@ <controller type='pci' index='0' model='pci-root'/> <serial type='spiceport'> <source channel='org.qemu.console.serial.0'/> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='spiceport'> <source channel='org.qemu.console.serial.0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml index a8790b509..fded758ea 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml @@ -27,13 +27,19 @@ </controller> <controller type='pci' index='0' model='pci-root'/> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <serial type='null'> - <target type='isa-serial' port='1'/> + <target type='isa-serial' port='1'> + <model name='isa-serial'/> + </target> </serial> <serial type='stdio'> - <target type='isa-serial' port='2'/> + <target type='isa-serial' port='2'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml index a8af87b53..76d894820 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml @@ -29,12 +29,16 @@ <serial type='udp'> <source mode='bind' host='127.0.0.1' service='1111'/> <source mode='connect' host='127.0.0.1' service='2222'/> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <serial type='tcp'> <source mode='connect' host='127.0.0.1' service='5555'/> <protocol type='raw'/> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='udp'> <source mode='bind' host='127.0.0.1' service='1111'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml index f439f57ea..c4334f6ca 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml @@ -42,7 +42,9 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml index a2a6e5b3c..8e761762f 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml @@ -48,7 +48,9 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml index 72cbcc4cb..49a7b550b 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml @@ -46,7 +46,9 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'/> + <target type='isa-serial' port='0'> + <model name='isa-serial'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> -- 2.14.3

Target model and target type must agree for the configuration to make sense, so check that's actually the case and error out otherwise. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/libvirt_private.syms | 2 ++ src/qemu/qemu_domain.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 875e474b6..290198ddd 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -209,6 +209,8 @@ virDomainChrGetDomainPtrs; virDomainChrInsertPreAlloced; virDomainChrPreAlloc; virDomainChrRemove; +virDomainChrSerialTargetModelTypeFromString; +virDomainChrSerialTargetModelTypeToString; virDomainChrSerialTargetTypeFromString; virDomainChrSerialTargetTypeToString; virDomainChrSourceDefClear; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e141e1132..0b033f496 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3479,6 +3479,25 @@ qemuDomainChrSerialTargetTypeToAddressType(int targetType) } +static int +qemuDomainChrSerialTargetModelToTargetType(int targetModel) +{ + switch ((virDomainChrSerialTargetModel) targetModel) { + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL: + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: + break; + } + + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE; +} + + static int qemuDomainChrTargetDefValidate(const virDomainDef *def, const virDomainChrDef *chr) @@ -3515,6 +3534,28 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def, case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: break; } + + /* Validate target model */ + switch ((virDomainChrSerialTargetModel) chr->targetModel) { + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: + + expected = qemuDomainChrSerialTargetModelToTargetType(chr->targetModel); + + if (chr->targetType != expected) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target model '%s' requires target type '%s'"), + virDomainChrSerialTargetModelTypeToString(chr->targetModel), + virDomainChrSerialTargetTypeToString(expected)); + return -1; + } + break; + + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: + break; + } break; case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: -- 2.14.3

On Sun, Nov 26, 2017 at 11:25:36PM +0100, Andrea Bolognani wrote:
Target model and target type must agree for the configuration to make sense, so check that's actually the case and error out otherwise.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/libvirt_private.syms | 2 ++ src/qemu/qemu_domain.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

Now that we've created a distinction between target type and target model, with the latter being the concrete device name, it's time to switch to formatting the model instead of the type. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_command.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0a4684231..718dfb15f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10375,8 +10375,8 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, serial->info.alias); } } else { - switch ((virDomainChrSerialTargetType) serial->targetType) { - case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: + switch ((virDomainChrSerialTargetModel) serial->targetModel) { + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL: if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_SERIAL)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("usb-serial is not supported in this QEMU binary")); @@ -10384,10 +10384,10 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, } break; - case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: break; - case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCI_SERIAL)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("pci-serial is not supported with this QEMU binary")); @@ -10395,19 +10395,19 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, } break; - case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: - case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: /* Except from _LAST, which is just a guard value and will never * be used, all of the above are platform devices, which means * qemuBuildSerialCommandLine() will have taken the appropriate * branch and we will not have ended up here. */ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Invalid target type for serial device")); + _("Invalid target model for serial device")); goto error; } virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s", - virDomainChrSerialTargetTypeToString(serial->targetType), + virDomainChrSerialTargetModelTypeToString(serial->targetModel), serial->info.alias, serial->info.alias); } -- 2.14.3

Instead duplicating the capability check for each possible target model, introduce a small helper that matches the target model with the corresponding capability and collapse all existing checks into a single one. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/qemu/qemu_command.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 718dfb15f..53b0e6841 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10351,6 +10351,25 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, return NULL; } + +static virQEMUCapsFlags +qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel) +{ + switch (targetModel) { + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL: + return QEMU_CAPS_DEVICE_USB_SERIAL; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: + return QEMU_CAPS_DEVICE_PCI_SERIAL; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: + break; + } + + return 0; +} + + /* This function generates the correct '-device' string for character * devices of each architecture. */ @@ -10361,6 +10380,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, virQEMUCapsPtr qemuCaps) { virBuffer cmd = VIR_BUFFER_INITIALIZER; + virQEMUCapsFlags caps; if (qemuDomainIsPSeries(def)) { if (serial->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && @@ -10377,9 +10397,14 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, } else { switch ((virDomainChrSerialTargetModel) serial->targetModel) { case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_SERIAL)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("usb-serial is not supported in this QEMU binary")); + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: + + caps = qemuChrSerialTargetModelToCaps(serial->targetModel); + + if (!virQEMUCapsGet(qemuCaps, caps)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("'%s' is not supported in this QEMU binary"), + virDomainChrSerialTargetModelTypeToString(serial->targetModel)); goto error; } break; @@ -10387,14 +10412,6 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: break; - case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCI_SERIAL)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("pci-serial is not supported with this QEMU binary")); - goto error; - } - break; - case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: /* Except from _LAST, which is just a guard value and will never -- 2.14.3

On Sun, Nov 26, 2017 at 11:25:38PM +0100, Andrea Bolognani wrote:
Instead duplicating the capability check for each possible target model, introduce a small helper that matches the target model with the corresponding capability and collapse all existing checks into a single one.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/qemu/qemu_command.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

We can finally introduce a specific target model for the spapr-vty device used by pSeries guests, which means isa-serial will no longer show up to confuse users. We make sure migration works in both directions by interpreting the isa-serial target type, or the lack of target type, appropriately when parsing the guest XML, and skipping the newly-introduced type when formatting if for migration. We also verify that spapr-vty is not used for non-pSeries guests and add a bunch of test cases. This commit is best viewed with 'git show -w'. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511421 Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/formatdomain.html.in | 9 ++- docs/schemas/domaincommon.rng | 2 + src/conf/domain_conf.c | 6 +- src/conf/domain_conf.h | 2 + src/qemu/qemu_command.c | 67 +++++++++------------ src/qemu/qemu_domain.c | 69 ++++++++++++++++++---- src/qemu/qemu_domain_address.c | 1 + .../qemuxml2argv-pseries-basic.args | 2 +- .../qemuxml2argv-pseries-console-native.args | 1 + .../qemuxml2argv-pseries-console-native.xml | 17 ++++++ ...gs => qemuxml2argv-pseries-console-virtio.args} | 10 ++-- .../qemuxml2argv-pseries-console-virtio.xml | 19 ++++++ .../qemuxml2argv-pseries-cpu-compat-power9.args | 2 +- .../qemuxml2argv-pseries-cpu-compat.args | 2 +- .../qemuxml2argv-pseries-cpu-exact.args | 2 +- .../qemuxml2argv-pseries-cpu-le.args | 2 +- .../qemuxml2argv-pseries-panic-missing.args | 2 +- .../qemuxml2argv-pseries-panic-no-address.args | 2 +- ...qemuxml2argv-pseries-serial+console-native.args | 1 + .../qemuxml2argv-pseries-serial+console-native.xml | 18 ++++++ .../qemuxml2argv-pseries-serial-compat.args | 1 + .../qemuxml2argv-pseries-serial-compat.xml | 19 ++++++ ...qemuxml2argv-pseries-serial-invalid-machine.xml | 19 ++++++ ...rgs => qemuxml2argv-pseries-serial-native.args} | 7 +-- .../qemuxml2argv-pseries-serial-native.xml | 16 +++++ .../qemuxml2argv-pseries-usb-default.args | 2 +- .../qemuxml2argv-pseries-usb-kbd.args | 2 +- .../qemuxml2argv-pseries-usb-multi.args | 2 +- .../qemuxml2argv-pseries-vio-user-assigned.args | 4 +- .../qemuxml2argvdata/qemuxml2argv-pseries-vio.args | 4 +- tests/qemuxml2argvtest.c | 16 +++++ .../qemuxml2xmlout-panic-pseries.xml | 4 +- .../qemuxml2xmlout-pseries-console-native.xml | 1 + ...l => qemuxml2xmlout-pseries-console-virtio.xml} | 18 ++---- .../qemuxml2xmlout-pseries-cpu-compat-power9.xml | 4 +- .../qemuxml2xmlout-pseries-cpu-compat.xml | 4 +- .../qemuxml2xmlout-pseries-cpu-exact.xml | 4 +- .../qemuxml2xmlout-pseries-panic-missing.xml | 4 +- .../qemuxml2xmlout-pseries-panic-no-address.xml | 4 +- ...emuxml2xmlout-pseries-serial+console-native.xml | 1 + .../qemuxml2xmlout-pseries-serial-compat.xml | 1 + ...ml => qemuxml2xmlout-pseries-serial-native.xml} | 10 ++-- tests/qemuxml2xmltest.c | 15 +++++ 43 files changed, 291 insertions(+), 107 deletions(-) create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.xml copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-basic.args => qemuxml2argv-pseries-console-virtio.args} (59%) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-invalid-machine.xml copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-basic.args => qemuxml2argv-pseries-serial-native.args} (70%) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-native.xml copy tests/qemuxml2xmloutdata/{qemuxml2xmlout-panic-pseries.xml => qemuxml2xmlout-pseries-console-virtio.xml} (71%) create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial+console-native.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-compat.xml copy tests/qemuxml2xmloutdata/{qemuxml2xmlout-panic-pseries.xml => qemuxml2xmlout-pseries-serial-native.xml} (79%) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 3126d6ed1..222504a06 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6546,7 +6546,10 @@ qemu-kvm -net nic,model=? /dev/null <span class="since">since 1.0.2</span>, <code>isa-serial</code> (usable on x86 machine types), <code>usb-serial</code> (usable whenever USB support is available) - and <code>pci-serial</code> (usable whenever PCI support is available). + and <code>pci-serial</code> (usable whenever PCI support is available); + <span class="since">since 3.10.0</span>, + <code>spapr-vio-serial</code> (usable with ppc64/pSeries guests) + is available as well. </p> <p> @@ -6556,7 +6559,9 @@ qemu-kvm -net nic,model=? /dev/null <code>isa-serial</code> (usable with the <code>isa-serial</code> target type); <code>usb-serial</code> (usable with the <code>usb-serial</code> target type); <code>pci-serial</code> - (usable with the <code>pci-serial</code> target type). + (usable with the <code>pci-serial</code> target type); + <code>spapr-vty</code> (usable with the <code>spapr-vio-serial</code> + target type). </p> <p> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index fbba092d1..1f6d25e1b 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3585,6 +3585,7 @@ <value>isa-serial</value> <value>usb-serial</value> <value>pci-serial</value> + <value>spapr-vio-serial</value> </choice> </attribute> </define> @@ -3596,6 +3597,7 @@ <value>isa-serial</value> <value>usb-serial</value> <value>pci-serial</value> + <value>spapr-vty</value> </choice> </attribute> </element> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5df5f3aae..62d54560e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -451,7 +451,9 @@ VIR_ENUM_IMPL(virDomainChrSerialTarget, "none", "isa-serial", "usb-serial", - "pci-serial") + "pci-serial", + "spapr-vio-serial", +); VIR_ENUM_IMPL(virDomainChrChannelTarget, VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST, @@ -478,6 +480,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTargetModel, "isa-serial", "usb-serial", "pci-serial", + "spapr-vty", ); VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST, @@ -4057,6 +4060,7 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def) switch ((virDomainChrSerialTargetType) def->serials[0]->targetType) { case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: { /* Create a stub console to match the serial port. diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 7895dea55..35f5c63c2 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1081,6 +1081,7 @@ typedef enum { VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI, + VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST } virDomainChrSerialTargetType; @@ -1113,6 +1114,7 @@ typedef enum { VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST } virDomainChrSerialTargetModel; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 53b0e6841..ad182bf15 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10360,6 +10360,8 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel) return QEMU_CAPS_DEVICE_USB_SERIAL; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: return QEMU_CAPS_DEVICE_PCI_SERIAL; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: + return QEMU_CAPS_DEVICE_SPAPR_VTY; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: @@ -10382,52 +10384,39 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, virBuffer cmd = VIR_BUFFER_INITIALIZER; virQEMUCapsFlags caps; - if (qemuDomainIsPSeries(def)) { - if (serial->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && - serial->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_VTY)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("spapr-vty not supported in this QEMU binary")); - goto error; - } - - virBufferAsprintf(&cmd, "spapr-vty,chardev=char%s", - serial->info.alias); - } - } else { - switch ((virDomainChrSerialTargetModel) serial->targetModel) { - case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL: - case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: - - caps = qemuChrSerialTargetModelToCaps(serial->targetModel); - - if (!virQEMUCapsGet(qemuCaps, caps)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("'%s' is not supported in this QEMU binary"), - virDomainChrSerialTargetModelTypeToString(serial->targetModel)); - goto error; - } - break; + switch ((virDomainChrSerialTargetModel) serial->targetModel) { + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: - case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: - break; + caps = qemuChrSerialTargetModelToCaps(serial->targetModel); - case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: - case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: - /* Except from _LAST, which is just a guard value and will never - * be used, all of the above are platform devices, which means - * qemuBuildSerialCommandLine() will have taken the appropriate - * branch and we will not have ended up here. */ - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Invalid target model for serial device")); + if (!virQEMUCapsGet(qemuCaps, caps)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("'%s' is not supported in this QEMU binary"), + virDomainChrSerialTargetModelTypeToString(serial->targetModel)); goto error; } + break; - virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s", - virDomainChrSerialTargetModelTypeToString(serial->targetModel), - serial->info.alias, serial->info.alias); + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: + break; + + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: + /* Except from _LAST, which is just a guard value and will never + * be used, all of the above are platform devices, which means + * qemuBuildSerialCommandLine() will have taken the appropriate + * branch and we will not have ended up here. */ + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Invalid target model for serial device")); + goto error; } + virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s", + virDomainChrSerialTargetModelTypeToString(serial->targetModel), + serial->info.alias, serial->info.alias); + if (qemuBuildDeviceAddressStr(&cmd, def, &serial->info, qemuCaps) < 0) goto error; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0b033f496..d8ab6ed52 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3470,6 +3470,8 @@ qemuDomainChrSerialTargetTypeToAddressType(int targetType) return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: + return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: break; @@ -3489,6 +3491,8 @@ qemuDomainChrSerialTargetModelToTargetType(int targetModel) return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: break; @@ -3499,8 +3503,7 @@ qemuDomainChrSerialTargetModelToTargetType(int targetModel) static int -qemuDomainChrTargetDefValidate(const virDomainDef *def, - const virDomainChrDef *chr) +qemuDomainChrTargetDefValidate(const virDomainChrDef *chr) { int expected; @@ -3512,11 +3515,7 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def, case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: - - /* Hack required until we have a proper type for pSeries - * serial consoles */ - if (qemuDomainIsPSeries(def)) - return 0; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: expected = qemuDomainChrSerialTargetTypeToAddressType(chr->targetType); @@ -3540,6 +3539,7 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def, case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: expected = qemuDomainChrSerialTargetModelToTargetType(chr->targetModel); @@ -3577,7 +3577,7 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, if (qemuDomainChrSourceDefValidate(dev->source) < 0) return -1; - if (qemuDomainChrTargetDefValidate(def, dev) < 0) + if (qemuDomainChrTargetDefValidate(dev) < 0) return -1; if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL && @@ -3587,6 +3587,26 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, return -1; } + if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) { + bool isCompatible = true; + + if (!qemuDomainIsPSeries(def) && + (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO || + dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY)) { + isCompatible = false; + } + + if (!isCompatible) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Serial device with target type '%s' and " + "target model '%s' not compatible with guest " + "architecture or machine type"), + virDomainChrSerialTargetTypeToString(dev->targetType), + virDomainChrSerialTargetModelTypeToString(dev->targetModel)); + return -1; + } + } + return 0; } @@ -4226,10 +4246,7 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, if (ARCH_IS_X86(def->os.arch)) { chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; } else if (qemuDomainIsPSeries(def)) { - /* Setting TYPE_ISA here is just a temporary hack to reduce test - * suite churn. Later on we will have a proper serial type for - * pSeries and this line will be updated accordingly. */ - chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; + chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO; } } @@ -4246,6 +4263,9 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL; break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: + chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY; + break; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: /* Nothing to do */ @@ -5151,6 +5171,31 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver, goto cleanup; } + for (i = 0; i < def->nserials; i++) { + virDomainChrDefPtr serial = def->serials[i]; + + /* Historically, the native console type for some machine types + * was not set at all, which means it defaulted to ISA even + * though that was not even remotely accurate. To ensure migration + * towards older libvirt versions works for such guests, we switch + * it back to the default here */ + if (flags & VIR_DOMAIN_XML_MIGRATABLE) { + switch ((virDomainChrSerialTargetType) serial->targetType) { + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: + serial->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE; + serial->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE; + break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: + /* Nothing to do */ + break; + } + } + } + /* Replace the CPU definition updated according to QEMU with the one * used for starting the domain. The updated def will be sent * separately for backward compatibility. diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 989c0e6c9..2319e503e 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -782,6 +782,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: return 0; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args index 97a7057ba..789d9f679 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args @@ -20,4 +20,4 @@ server,nowait \ -boot c \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x30000000 +-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.args new file mode 120000 index 000000000..d6c830ecd --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.args @@ -0,0 +1 @@ +qemuxml2argv-pseries-serial-native.args \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.xml new file mode 100644 index 000000000..9f37bf0de --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.xml @@ -0,0 +1,17 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='ppc64' machine='pseries'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-ppc64</emulator> + <controller type='usb' model='none'/> + <!-- The <console> element being present should result in a matching + <serial> element being created --> + <console type='pty'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.args similarity index 59% copy from tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args copy to tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.args index 97a7057ba..343018fb3 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.args @@ -5,7 +5,7 @@ USER=test \ LOGNAME=test \ QEMU_AUDIO_DRV=none \ /usr/bin/qemu-system-ppc64 \ --name QEMUGuest1 \ +-name guest \ -S \ -M pseries \ -m 512 \ @@ -14,10 +14,10 @@ QEMU_AUDIO_DRV=none \ -nographic \ -nodefconfig \ -nodefaults \ --chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\ server,nowait \ -mon chardev=charmonitor,id=monitor,mode=readline \ -boot c \ --usb \ --chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x30000000 +-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x1 \ +-chardev pty,id=charconsole0 \ +-device virtconsole,chardev=charconsole0,id=console0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.xml new file mode 100644 index 000000000..0190ab63a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.xml @@ -0,0 +1,19 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='ppc64' machine='pseries'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-ppc64</emulator> + <controller type='usb' model='none'/> + <!-- The <console> element being present should *not* result in a + matching <serial> element being created --> + <console type='pty'> + <target type='virtio'/> + </console> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args index af93d63dc..9bb375aeb 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args @@ -21,4 +21,4 @@ server,nowait \ -boot c \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x30000000 +-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args index 7740e2f5a..5174aa760 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args @@ -21,4 +21,4 @@ server,nowait \ -boot c \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x30000000 +-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args index d2c99a7fa..3790deca8 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args @@ -21,4 +21,4 @@ server,nowait \ -boot c \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x30000000 +-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args index 97a7057ba..789d9f679 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args @@ -20,4 +20,4 @@ server,nowait \ -boot c \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x30000000 +-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args index 97a7057ba..789d9f679 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args @@ -20,4 +20,4 @@ server,nowait \ -boot c \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x30000000 +-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args index 97a7057ba..789d9f679 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args @@ -20,4 +20,4 @@ server,nowait \ -boot c \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x30000000 +-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.args new file mode 120000 index 000000000..d6c830ecd --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.args @@ -0,0 +1 @@ +qemuxml2argv-pseries-serial-native.args \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.xml new file mode 100644 index 000000000..2733baa98 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.xml @@ -0,0 +1,18 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='ppc64' machine='pseries'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-ppc64</emulator> + <controller type='usb' model='none'/> + <!-- When both the <serial> and <console> elements are present, they will + be matched and end up representing the same native serial console --> + <serial type='pty'/> + <console type='pty'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.args new file mode 120000 index 000000000..d6c830ecd --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.args @@ -0,0 +1 @@ +qemuxml2argv-pseries-serial-native.args \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.xml new file mode 100644 index 000000000..2e182edbd --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.xml @@ -0,0 +1,19 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='ppc64' machine='pseries'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-ppc64</emulator> + <controller type='usb' model='none'/> + <!-- isa-serial has to be accepted for backwards compatibility reasons, + but should get converted to the proper type (spapr-vty-serial) --> + <serial type='pty'> + <target type='isa-serial'/> + </serial> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-invalid-machine.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-invalid-machine.xml new file mode 100644 index 000000000..5482146a5 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-invalid-machine.xml @@ -0,0 +1,19 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='usb' model='none'/> + <!-- The spapr-vio-serial target type can only be used for pSeries + guests, so this should be rejected --> + <serial type='pty'> + <target type='spapr-vio-serial'/> + </serial> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.args similarity index 70% copy from tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args copy to tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.args index 97a7057ba..f72b8b625 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.args @@ -5,7 +5,7 @@ USER=test \ LOGNAME=test \ QEMU_AUDIO_DRV=none \ /usr/bin/qemu-system-ppc64 \ --name QEMUGuest1 \ +-name guest \ -S \ -M pseries \ -m 512 \ @@ -14,10 +14,9 @@ QEMU_AUDIO_DRV=none \ -nographic \ -nodefconfig \ -nodefaults \ --chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\ server,nowait \ -mon chardev=charmonitor,id=monitor,mode=readline \ -boot c \ --usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x30000000 +-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.xml new file mode 100644 index 000000000..6cec4bc9d --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.xml @@ -0,0 +1,16 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='ppc64' machine='pseries'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-ppc64</emulator> + <controller type='usb' model='none'/> + <!-- This will use the spapr-vty-serial target type --> + <serial type='pty'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args index a92b1e01b..37c059403 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args @@ -20,4 +20,4 @@ server,nowait \ -boot c \ -device pci-ohci,id=usb,bus=pci.0,addr=0x1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x30000000 +-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args index caaccdbb8..838b80453 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args @@ -20,5 +20,5 @@ server,nowait \ -boot c \ -device pci-ohci,id=usb,bus=pci.0,addr=0x1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ -device usb-kbd,id=input0,bus=usb.0,port=1 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args index b9bd905a5..56bc1d67e 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args @@ -21,4 +21,4 @@ server,nowait \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1 \ -device pci-ohci,id=usb1,bus=pci.0,addr=0x2 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x30000000 +-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args index 63cf3c183..0fcfbe379 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args @@ -25,6 +25,6 @@ server,nowait \ -device scsi-disk,bus=scsi1.0,channel=0,scsi-id=0,lun=0,\ drive=drive-scsi1-0-0-0,id=scsi1-0-0-0 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x20000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=0x20000000 \ -chardev pty,id=charserial1 \ --device spapr-vty,chardev=charserial1,reg=0x30001000 +-device spapr-vty,chardev=charserial1,id=serial1,reg=0x30001000 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args index 0294067bc..8a9bdcc4c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args @@ -25,6 +25,6 @@ server,nowait \ -device scsi-disk,bus=scsi1.0,channel=0,scsi-id=0,lun=0,\ drive=drive-scsi1-0-0-0,id=scsi1-0-0-0 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ -chardev pty,id=charserial1 \ --device spapr-vty,chardev=charserial1,reg=0x30001000 +-device spapr-vty,chardev=charserial1,id=serial1,reg=0x30001000 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 29df253b8..5827a47e5 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1877,6 +1877,22 @@ mymain(void) QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT); + DO_TEST("pseries-serial-native", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_SPAPR_VTY); + DO_TEST("pseries-serial+console-native", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_SPAPR_VTY); + DO_TEST("pseries-serial-compat", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_SPAPR_VTY); + DO_TEST("pseries-console-native", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_SPAPR_VTY); + DO_TEST("pseries-console-virtio", + QEMU_CAPS_NODEFCONFIG); + DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE); + DO_TEST("disk-ide-drive-split", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_IDE_CD); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml index 496df0696..484fe4cfa 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml @@ -22,8 +22,8 @@ <target index='0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio-serial' port='0'> + <model name='spapr-vty'/> </target> <address type='spapr-vio' reg='0x30000000'/> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-native.xml new file mode 120000 index 000000000..b0e645fc0 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-native.xml @@ -0,0 +1 @@ +qemuxml2xmlout-pseries-serial-native.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-virtio.xml similarity index 71% copy from tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml copy to tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-virtio.xml index 496df0696..48760f282 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-virtio.xml @@ -1,5 +1,5 @@ <domain type='qemu'> - <name>QEMUGuest1</name> + <name>guest</name> <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> <memory unit='KiB'>524288</memory> <currentMemory unit='KiB'>524288</currentMemory> @@ -14,22 +14,16 @@ <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/qemu-system-ppc64</emulator> - <controller type='usb' index='0'> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> - </controller> + <controller type='usb' index='0' model='none'/> <controller type='pci' index='0' model='pci-root'> <model name='spapr-pci-host-bridge'/> <target index='0'/> </controller> - <serial type='pty'> - <target type='isa-serial' port='0'> - <model name='isa-serial'/> - </target> - <address type='spapr-vio' reg='0x30000000'/> - </serial> + <controller type='virtio-serial' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> + </controller> <console type='pty'> - <target type='serial' port='0'/> - <address type='spapr-vio' reg='0x30000000'/> + <target type='virtio' port='0'/> </console> <memballoon model='none'/> <panic model='pseries'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml index 9d4c5efe6..404bb0c76 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml @@ -25,8 +25,8 @@ <target index='0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio-serial' port='0'> + <model name='spapr-vty'/> </target> <address type='spapr-vio' reg='0x30000000'/> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml index 6059859ab..1891fa5f4 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml @@ -25,8 +25,8 @@ <target index='0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio-serial' port='0'> + <model name='spapr-vty'/> </target> <address type='spapr-vio' reg='0x30000000'/> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml index f3216523e..f08f3e005 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml @@ -26,8 +26,8 @@ <target index='0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio-serial' port='0'> + <model name='spapr-vty'/> </target> <address type='spapr-vio' reg='0x30000000'/> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml index 496df0696..484fe4cfa 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml @@ -22,8 +22,8 @@ <target index='0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio-serial' port='0'> + <model name='spapr-vty'/> </target> <address type='spapr-vio' reg='0x30000000'/> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml index 496df0696..484fe4cfa 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml @@ -22,8 +22,8 @@ <target index='0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio-serial' port='0'> + <model name='spapr-vty'/> </target> <address type='spapr-vio' reg='0x30000000'/> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial+console-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial+console-native.xml new file mode 120000 index 000000000..b0e645fc0 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial+console-native.xml @@ -0,0 +1 @@ +qemuxml2xmlout-pseries-serial-native.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-compat.xml new file mode 120000 index 000000000..b0e645fc0 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-compat.xml @@ -0,0 +1 @@ +qemuxml2xmlout-pseries-serial-native.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-native.xml similarity index 79% copy from tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml copy to tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-native.xml index 496df0696..fae7c54d5 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-native.xml @@ -1,5 +1,5 @@ <domain type='qemu'> - <name>QEMUGuest1</name> + <name>guest</name> <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> <memory unit='KiB'>524288</memory> <currentMemory unit='KiB'>524288</currentMemory> @@ -14,16 +14,14 @@ <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/qemu-system-ppc64</emulator> - <controller type='usb' index='0'> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> - </controller> + <controller type='usb' index='0' model='none'/> <controller type='pci' index='0' model='pci-root'> <model name='spapr-pci-host-bridge'/> <target index='0'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio-serial' port='0'> + <model name='spapr-vty'/> </target> <address type='spapr-vio' reg='0x30000000'/> </serial> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index d66cf155d..4318ae503 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -768,6 +768,21 @@ mymain(void) QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT); + DO_TEST("pseries-serial-native", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_SPAPR_VTY); + DO_TEST("pseries-serial+console-native", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_SPAPR_VTY); + DO_TEST("pseries-serial-compat", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_SPAPR_VTY); + DO_TEST("pseries-console-native", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_SPAPR_VTY); + DO_TEST("pseries-console-virtio", + QEMU_CAPS_NODEFCONFIG); + DO_TEST("balloon-device-auto", NONE); DO_TEST("balloon-device-period", NONE); DO_TEST("channel-virtio-auto", NONE); -- 2.14.3

On Sun, Nov 26, 2017 at 11:25:39PM +0100, Andrea Bolognani wrote:
We can finally introduce a specific target model for the spapr-vty device used by pSeries guests, which means isa-serial will no longer show up to confuse users.
We make sure migration works in both directions by interpreting the isa-serial target type, or the lack of target type, appropriately when parsing the guest XML, and skipping the newly-introduced type when formatting if for migration. We also verify that spapr-vty is not used for non-pSeries guests and add a bunch of test cases.
This commit is best viewed with 'git show -w'.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511421
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

The existing implementation set the address type for all serial devices to spapr-vio, which made it impossible to use other devices such as usb-serial and pci-serial; moreover, some decisions were made based on the address type rather than the device type. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1512934 Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_command.c | 9 ------ src/qemu/qemu_domain_address.c | 3 +- .../qemuxml2argv-pseries-serial-pci.args | 22 +++++++++++++++ .../qemuxml2argv-pseries-serial-pci.xml | 18 ++++++++++++ .../qemuxml2argv-pseries-serial-usb.args | 23 ++++++++++++++++ .../qemuxml2argv-pseries-serial-usb.xml | 21 ++++++++++++++ tests/qemuxml2argvtest.c | 7 +++++ .../qemuxml2xmlout-pseries-serial-pci.xml | 31 +++++++++++++++++++++ .../qemuxml2xmlout-pseries-serial-usb.xml | 32 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 7 +++++ 10 files changed, 163 insertions(+), 10 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ad182bf15..3b8757e10 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9243,15 +9243,6 @@ static bool qemuChrIsPlatformDevice(const virDomainDef *def, virDomainChrDefPtr chr) { - if ((def->os.arch == VIR_ARCH_PPC) || ARCH_IS_PPC64(def->os.arch)) { - if (!qemuDomainIsPSeries(def)) - return true; - /* only pseries need -device spapr-vty with -chardev */ - if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && - chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) - return true; - } - if (def->os.arch == VIR_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) { /* TARGET_TYPE_ISA here really means 'the default platform device' */ if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 2319e503e..f62bb2f97 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -246,8 +246,9 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def, for (i = 0; i < def->nserials; i++) { if (def->serials[i]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && - qemuDomainIsPSeries(def)) + def->serials[i]->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO) { def->serials[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; + } if (qemuDomainAssignSpaprVIOAddress(def, &def->serials[i]->info, VIO_ADDR_SERIAL) < 0) goto cleanup; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args new file mode 100644 index 000000000..eb2a9bf0e --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args @@ -0,0 +1,22 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-ppc64 \ +-name guest \ +-S \ +-M pseries \ +-m 512 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-boot c \ +-chardev pty,id=charserial0 \ +-device pci-serial,chardev=charserial0,id=serial0,bus=pci.0,addr=0x1 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml new file mode 100644 index 000000000..2c2534b4c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml @@ -0,0 +1,18 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='ppc64' machine='pseries'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-ppc64</emulator> + <controller type='usb' model='none'/> + <!-- This will be assigned a PCI address --> + <serial type='pty'> + <target type='pci-serial'/> + </serial> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args new file mode 100644 index 000000000..0403985dc --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args @@ -0,0 +1,23 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-ppc64 \ +-name guest \ +-S \ +-M pseries \ +-m 512 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-boot c \ +-device qemu-xhci,id=usb,bus=pci.0,addr=0x1 \ +-chardev pty,id=charserial0 \ +-device usb-serial,chardev=charserial0,id=serial0,bus=usb.0,port=1 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml new file mode 100644 index 000000000..734c90c66 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml @@ -0,0 +1,21 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='ppc64' machine='pseries'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-ppc64</emulator> + <controller type='usb' model='qemu-xhci'/> + <!-- This should be assigned a USB address. You'll not be able to find it + in the file generated by qemuxml2xmltest due to limitations in the + test suite, but it will be there when actually running libvirt; + moreover, the USB address will be present in the .args file --> + <serial type='pty'> + <target type='usb-serial'/> + </serial> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5827a47e5..0ba23d070 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1886,6 +1886,13 @@ mymain(void) DO_TEST("pseries-serial-compat", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_SPAPR_VTY); + DO_TEST("pseries-serial-pci", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_PCI_SERIAL); + DO_TEST("pseries-serial-usb", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_QEMU_XHCI, + QEMU_CAPS_DEVICE_USB_SERIAL); DO_TEST("pseries-console-native", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_SPAPR_VTY); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml new file mode 100644 index 000000000..cba7ea96b --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml @@ -0,0 +1,31 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <currentMemory unit='KiB'>524288</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='ppc64' machine='pseries'>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-ppc64</emulator> + <controller type='usb' index='0' model='none'/> + <controller type='pci' index='0' model='pci-root'> + <model name='spapr-pci-host-bridge'/> + <target index='0'/> + </controller> + <serial type='pty'> + <target type='pci-serial' port='0'> + <model name='pci-serial'/> + </target> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> + </serial> + <memballoon model='none'/> + <panic model='pseries'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml new file mode 100644 index 000000000..34f651308 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml @@ -0,0 +1,32 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <currentMemory unit='KiB'>524288</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='ppc64' machine='pseries'>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-ppc64</emulator> + <controller type='usb' index='0' model='qemu-xhci'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> + </controller> + <controller type='pci' index='0' model='pci-root'> + <model name='spapr-pci-host-bridge'/> + <target index='0'/> + </controller> + <serial type='pty'> + <target type='usb-serial' port='0'> + <model name='usb-serial'/> + </target> + </serial> + <memballoon model='none'/> + <panic model='pseries'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 4318ae503..45cb739cd 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -777,6 +777,13 @@ mymain(void) DO_TEST("pseries-serial-compat", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_SPAPR_VTY); + DO_TEST("pseries-serial-pci", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_PCI_SERIAL); + DO_TEST("pseries-serial-usb", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_QEMU_XHCI, + QEMU_CAPS_DEVICE_USB_SERIAL); DO_TEST("pseries-console-native", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_SPAPR_VTY); -- 2.14.3

We can finally introduce a specific target model for the pl011 device used by mach-virt guests, which means isa-serial will no longer show up to confuse users. We make sure migration works in both directions by interpreting the isa-serial target type, or the lack of target type, appropriately when parsing the guest XML, and skipping the newly-introduced type when formatting if for migration. We also verify that pl011 is not used for non-mach-virt guests and add a bunch of test cases. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=151292 Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/formatdomain.html.in | 8 ++-- docs/schemas/domaincommon.rng | 2 + src/conf/domain_conf.c | 3 ++ src/conf/domain_conf.h | 2 + src/qemu/qemu_command.c | 9 ++++- src/qemu/qemu_domain.c | 26 +++++++++++++ src/qemu/qemu_domain_address.c | 1 + .../qemuxml2argv-mach-virt-console-native.args | 1 + .../qemuxml2argv-mach-virt-console-native.xml | 17 +++++++++ .../qemuxml2argv-mach-virt-console-virtio.args | 24 ++++++++++++ .../qemuxml2argv-mach-virt-console-virtio.xml | 19 ++++++++++ ...muxml2argv-mach-virt-serial+console-native.args | 1 + ...emuxml2argv-mach-virt-serial+console-native.xml | 18 +++++++++ .../qemuxml2argv-mach-virt-serial-compat.args | 1 + .../qemuxml2argv-mach-virt-serial-compat.xml | 19 ++++++++++ ...muxml2argv-mach-virt-serial-invalid-machine.xml | 21 +++++++++++ .../qemuxml2argv-mach-virt-serial-native.args | 23 +++++++++++ .../qemuxml2argv-mach-virt-serial-native.xml | 16 ++++++++ .../qemuxml2argv-mach-virt-serial-pci.args | 26 +++++++++++++ .../qemuxml2argv-mach-virt-serial-pci.xml | 18 +++++++++ .../qemuxml2argv-mach-virt-serial-usb.args | 27 +++++++++++++ .../qemuxml2argv-mach-virt-serial-usb.xml | 21 +++++++++++ tests/qemuxml2argvtest.c | 27 +++++++++++++ .../qemuxml2xmlout-aarch64-virtio-pci-default.xml | 4 +- .../qemuxml2xmlout-mach-virt-console-native.xml | 1 + .../qemuxml2xmlout-mach-virt-console-virtio.xml | 27 +++++++++++++ ...uxml2xmlout-mach-virt-serial+console-native.xml | 1 + .../qemuxml2xmlout-mach-virt-serial-compat.xml | 31 +++++++++++++++ .../qemuxml2xmlout-mach-virt-serial-native.xml | 1 + .../qemuxml2xmlout-mach-virt-serial-pci.xml | 44 ++++++++++++++++++++++ .../qemuxml2xmlout-mach-virt-serial-usb.xml | 41 ++++++++++++++++++++ tests/qemuxml2xmltest.c | 26 +++++++++++++ 32 files changed, 500 insertions(+), 6 deletions(-) create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-invalid-machine.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-native.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-virtio.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial+console-native.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-compat.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-native.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-pci.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-usb.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 222504a06..16bf4fd5e 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6548,8 +6548,9 @@ qemu-kvm -net nic,model=? /dev/null <code>usb-serial</code> (usable whenever USB support is available) and <code>pci-serial</code> (usable whenever PCI support is available); <span class="since">since 3.10.0</span>, - <code>spapr-vio-serial</code> (usable with ppc64/pSeries guests) - is available as well. + <code>spapr-vio-serial</code> (usable with ppc64/pSeries guests) and + <code>system-serial</code> (usable with aarch64/virt guests) are + available as well. </p> <p> @@ -6561,7 +6562,8 @@ qemu-kvm -net nic,model=? /dev/null target type); <code>pci-serial</code> (usable with the <code>pci-serial</code> target type); <code>spapr-vty</code> (usable with the <code>spapr-vio-serial</code> - target type). + target type); <code>pl011</code> (usable with the + <code>system-serial</code> target type). </p> <p> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 1f6d25e1b..5fff3a40f 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3586,6 +3586,7 @@ <value>usb-serial</value> <value>pci-serial</value> <value>spapr-vio-serial</value> + <value>system-serial</value> </choice> </attribute> </define> @@ -3598,6 +3599,7 @@ <value>usb-serial</value> <value>pci-serial</value> <value>spapr-vty</value> + <value>pl011</value> </choice> </attribute> </element> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 62d54560e..820caba0f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -453,6 +453,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTarget, "usb-serial", "pci-serial", "spapr-vio-serial", + "system-serial", ); VIR_ENUM_IMPL(virDomainChrChannelTarget, @@ -481,6 +482,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTargetModel, "usb-serial", "pci-serial", "spapr-vty", + "pl011", ); VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST, @@ -4061,6 +4063,7 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def) switch ((virDomainChrSerialTargetType) def->serials[0]->targetType) { case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: { /* Create a stub console to match the serial port. diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 35f5c63c2..28d158980 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1082,6 +1082,7 @@ typedef enum { VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO, + VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST } virDomainChrSerialTargetType; @@ -1115,6 +1116,7 @@ typedef enum { VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST } virDomainChrSerialTargetModel; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3b8757e10..a8aaa3d8c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9244,10 +9244,13 @@ qemuChrIsPlatformDevice(const virDomainDef *def, virDomainChrDefPtr chr) { if (def->os.arch == VIR_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) { - /* TARGET_TYPE_ISA here really means 'the default platform device' */ + + /* pl011 (used on mach-virt) is a platform device */ if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && - chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA) + chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM && + chr->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011) { return true; + } } /* If we got all the way here and we're still stuck with the default @@ -10354,6 +10357,7 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel) case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: return QEMU_CAPS_DEVICE_SPAPR_VTY; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: break; @@ -10393,6 +10397,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: /* Except from _LAST, which is just a guard value and will never diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d8ab6ed52..2cc91b468 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3472,6 +3472,7 @@ qemuDomainChrSerialTargetTypeToAddressType(int targetType) return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: break; @@ -3493,6 +3494,8 @@ qemuDomainChrSerialTargetModelToTargetType(int targetModel) return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: break; @@ -3529,6 +3532,16 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr) } break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM: + if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target type '%s' cannot have an " + "associated address"), + virDomainChrSerialTargetTypeToString(chr->targetType)); + return -1; + } + break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: break; @@ -3540,6 +3553,7 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr) case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: expected = qemuDomainChrSerialTargetModelToTargetType(chr->targetModel); @@ -3596,6 +3610,12 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, isCompatible = false; } + if (!qemuDomainIsVirt(def) && + (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM || + dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011)) { + isCompatible = false; + } + if (!isCompatible) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Serial device with target type '%s' and " @@ -4247,6 +4267,8 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; } else if (qemuDomainIsPSeries(def)) { chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO; + } else if (qemuDomainIsVirt(def)) { + chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM; } } @@ -4266,6 +4288,9 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY; break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM: + chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011; + break; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: /* Nothing to do */ @@ -5182,6 +5207,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver, if (flags & VIR_DOMAIN_XML_MIGRATABLE) { switch ((virDomainChrSerialTargetType) serial->targetType) { case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM: serial->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE; serial->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE; break; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index f62bb2f97..db9656a3a 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -784,6 +784,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: return 0; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.args new file mode 120000 index 000000000..1a90484d3 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.args @@ -0,0 +1 @@ +qemuxml2argv-mach-virt-serial-native.args \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.xml new file mode 100644 index 000000000..6aba864d0 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.xml @@ -0,0 +1,17 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='aarch64' machine='virt'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-aarch64</emulator> + <controller type='usb' model='none'/> + <!-- The <console> element being present should result in a matching + <serial> element being created --> + <console type='pty'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.args new file mode 100644 index 000000000..2a862bff1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.args @@ -0,0 +1,24 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-aarch64 \ +-name guest \ +-S \ +-M virt \ +-m 512 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-no-acpi \ +-boot c \ +-device virtio-serial,id=virtio-serial0 \ +-chardev pty,id=charconsole0 \ +-device virtconsole,chardev=charconsole0,id=console0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.xml new file mode 100644 index 000000000..92704504c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.xml @@ -0,0 +1,19 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='aarch64' machine='virt'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-aarch64</emulator> + <controller type='usb' model='none'/> + <!-- The <console> element being present should *not* result in a + matching <serial> element being created --> + <console type='pty'> + <target type='virtio'/> + </console> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.args new file mode 120000 index 000000000..1a90484d3 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.args @@ -0,0 +1 @@ +qemuxml2argv-mach-virt-serial-native.args \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.xml new file mode 100644 index 000000000..549b764e9 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.xml @@ -0,0 +1,18 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='aarch64' machine='virt'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-aarch64</emulator> + <controller type='usb' model='none'/> + <!-- When both the <serial> and <console> elements are present, they will + be matched and end up representing the same native serial console --> + <serial type='pty'/> + <console type='pty'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.args new file mode 120000 index 000000000..1a90484d3 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.args @@ -0,0 +1 @@ +qemuxml2argv-mach-virt-serial-native.args \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.xml new file mode 100644 index 000000000..9e6be3ffe --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.xml @@ -0,0 +1,19 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='aarch64' machine='virt'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-aarch64</emulator> + <controller type='usb' model='none'/> + <!-- isa-serial has to be accepted for backwards compatibility reasons, + but should get converted to the proper type (pl011) --> + <serial type='pty'> + <target type='isa-serial'/> + </serial> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-invalid-machine.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-invalid-machine.xml new file mode 100644 index 000000000..a8de76abf --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-invalid-machine.xml @@ -0,0 +1,21 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='usb' model='none'/> + <!-- The pl011 serial console can only be used for mach-virt guests, + so this should be rejected --> + <serial type='pty'> + <target type='system-serial'> + <model name='pl011'/> + </target> + </serial> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.args new file mode 100644 index 000000000..f4bfce376 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.args @@ -0,0 +1,23 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-aarch64 \ +-name guest \ +-S \ +-M virt \ +-m 512 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-no-acpi \ +-boot c \ +-chardev pty,id=charserial0 \ +-serial chardev:charserial0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.xml new file mode 100644 index 000000000..817f606ee --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.xml @@ -0,0 +1,16 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='aarch64' machine='virt'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-aarch64</emulator> + <controller type='usb' model='none'/> + <!-- This will use the pl011 target type --> + <serial type='pty'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.args new file mode 100644 index 000000000..334194efe --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.args @@ -0,0 +1,26 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-aarch64 \ +-name guest \ +-S \ +-M virt \ +-m 512 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-no-acpi \ +-boot c \ +-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1 \ +-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ +-device pcie-root-port,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \ +-chardev pty,id=charserial0 \ +-device pci-serial,chardev=charserial0,id=serial0,bus=pci.2,addr=0x1 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.xml new file mode 100644 index 000000000..29aa7664b --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.xml @@ -0,0 +1,18 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='aarch64' machine='virt'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-aarch64</emulator> + <controller type='usb' model='none'/> + <!-- This will be assigned a PCI address --> + <serial type='pty'> + <target type='pci-serial'/> + </serial> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.args b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.args new file mode 100644 index 000000000..44c4027ac --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.args @@ -0,0 +1,27 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-aarch64 \ +-name guest \ +-S \ +-M virt \ +-m 512 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-no-acpi \ +-boot c \ +-device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ +addr=0x1 \ +-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ +-chardev pty,id=charserial0 \ +-device usb-serial,chardev=charserial0,id=serial0,bus=usb.0,port=1 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.xml b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.xml new file mode 100644 index 000000000..35f192a3e --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.xml @@ -0,0 +1,21 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='aarch64' machine='virt'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-aarch64</emulator> + <controller type='usb' model='qemu-xhci'/> + <!-- This should be assigned a USB address. You'll not be able to find it + in the file generated by qemuxml2xmltest due to limitations in the + test suite, but it will be there when actually running libvirt; + moreover, the USB address will be present in the .args file --> + <serial type='pty'> + <target type='usb-serial'/> + </serial> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 0ba23d070..593057653 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1900,6 +1900,33 @@ mymain(void) QEMU_CAPS_NODEFCONFIG); DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE); + DO_TEST("mach-virt-serial-native", + QEMU_CAPS_NODEFCONFIG); + DO_TEST("mach-virt-serial+console-native", + QEMU_CAPS_NODEFCONFIG); + DO_TEST("mach-virt-serial-compat", + QEMU_CAPS_NODEFCONFIG); + DO_TEST("mach-virt-serial-pci", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_OBJECT_GPEX, + QEMU_CAPS_PCI_MULTIFUNCTION, + QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, + QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_PCI_SERIAL); + DO_TEST("mach-virt-serial-usb", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_OBJECT_GPEX, + QEMU_CAPS_PCI_MULTIFUNCTION, + QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, + QEMU_CAPS_DEVICE_QEMU_XHCI, + QEMU_CAPS_DEVICE_USB_SERIAL); + DO_TEST("mach-virt-console-native", + QEMU_CAPS_NODEFCONFIG); + DO_TEST("mach-virt-console-virtio", + QEMU_CAPS_NODEFCONFIG); + DO_TEST_PARSE_ERROR("mach-virt-serial-invalid-machine", NONE); + DO_TEST("disk-ide-drive-split", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_IDE_CD); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml index e5496424b..9796d7f63 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml @@ -71,7 +71,9 @@ <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> </interface> <serial type='pty'> - <target port='0'/> + <target type='system-serial' port='0'> + <model name='pl011'/> + </target> </serial> <console type='pty'> <target type='serial' port='0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-native.xml new file mode 120000 index 000000000..a4768fcf8 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-native.xml @@ -0,0 +1 @@ +qemuxml2xmlout-mach-virt-serial-compat.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-virtio.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-virtio.xml new file mode 100644 index 000000000..3e46cd201 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-virtio.xml @@ -0,0 +1,27 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <currentMemory unit='KiB'>524288</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='aarch64' machine='virt'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <gic version='2'/> + </features> + <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='virtio-serial' index='0'/> + <console type='pty'> + <target type='virtio' port='0'/> + </console> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial+console-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial+console-native.xml new file mode 120000 index 000000000..a4768fcf8 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial+console-native.xml @@ -0,0 +1 @@ +qemuxml2xmlout-mach-virt-serial-compat.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-compat.xml new file mode 100644 index 000000000..3d7325a8d --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-compat.xml @@ -0,0 +1,31 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <currentMemory unit='KiB'>524288</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='aarch64' machine='virt'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <gic version='2'/> + </features> + <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'/> + <serial type='pty'> + <target type='system-serial' port='0'> + <model name='pl011'/> + </target> + </serial> + <console type='pty'> + <target type='serial' port='0'/> + </console> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-native.xml new file mode 120000 index 000000000..a4768fcf8 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-native.xml @@ -0,0 +1 @@ +qemuxml2xmlout-mach-virt-serial-compat.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-pci.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-pci.xml new file mode 100644 index 000000000..4bcf69a3d --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-pci.xml @@ -0,0 +1,44 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <currentMemory unit='KiB'>524288</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='aarch64' machine='virt'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <gic version='2'/> + </features> + <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='dmi-to-pci-bridge'> + <model name='i82801b11-bridge'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> + </controller> + <controller type='pci' index='2' model='pci-bridge'> + <model name='pci-bridge'/> + <target chassisNr='2'/> + <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> + </controller> + <controller type='pci' index='3' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='3' port='0x10'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> + <serial type='pty'> + <target type='pci-serial' port='0'> + <model name='pci-serial'/> + </target> + <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/> + </serial> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-usb.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-usb.xml new file mode 100644 index 000000000..01c2a5255 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-usb.xml @@ -0,0 +1,41 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <currentMemory unit='KiB'>524288</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='aarch64' machine='virt'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <gic version='2'/> + </features> + <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='qemu-xhci'> + <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> + </controller> + <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> + <serial type='pty'> + <target type='usb-serial' port='0'> + <model name='usb-serial'/> + </target> + </serial> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 45cb739cd..323845340 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -790,6 +790,32 @@ mymain(void) DO_TEST("pseries-console-virtio", QEMU_CAPS_NODEFCONFIG); + DO_TEST("mach-virt-serial-native", + QEMU_CAPS_NODEFCONFIG); + DO_TEST("mach-virt-serial+console-native", + QEMU_CAPS_NODEFCONFIG); + DO_TEST("mach-virt-serial-compat", + QEMU_CAPS_NODEFCONFIG); + DO_TEST("mach-virt-serial-pci", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_OBJECT_GPEX, + QEMU_CAPS_PCI_MULTIFUNCTION, + QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, + QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_PCI_SERIAL); + DO_TEST("mach-virt-serial-usb", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_OBJECT_GPEX, + QEMU_CAPS_PCI_MULTIFUNCTION, + QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, + QEMU_CAPS_DEVICE_QEMU_XHCI, + QEMU_CAPS_DEVICE_USB_SERIAL); + DO_TEST("mach-virt-console-native", + QEMU_CAPS_NODEFCONFIG); + DO_TEST("mach-virt-console-virtio", + QEMU_CAPS_NODEFCONFIG); + DO_TEST("balloon-device-auto", NONE); DO_TEST("balloon-device-period", NONE); DO_TEST("channel-virtio-auto", NONE); -- 2.14.3

On Sun, Nov 26, 2017 at 11:25:41PM +0100, Andrea Bolognani wrote:
We can finally introduce a specific target model for the pl011 device used by mach-virt guests, which means isa-serial will no longer show up to confuse users.
We make sure migration works in both directions by interpreting the isa-serial target type, or the lack of target type, appropriately when parsing the guest XML, and skipping the newly-introduced type when formatting if for migration. We also verify that pl011 is not used for non-mach-virt guests and add a bunch of test cases.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=151292
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/formatdomain.html.in | 8 ++-- docs/schemas/domaincommon.rng | 2 + src/conf/domain_conf.c | 3 ++ src/conf/domain_conf.h | 2 + src/qemu/qemu_command.c | 9 ++++- src/qemu/qemu_domain.c | 26 +++++++++++++ src/qemu/qemu_domain_address.c | 1 + .../qemuxml2argv-mach-virt-console-native.args | 1 + .../qemuxml2argv-mach-virt-console-native.xml | 17 +++++++++ .../qemuxml2argv-mach-virt-console-virtio.args | 24 ++++++++++++ .../qemuxml2argv-mach-virt-console-virtio.xml | 19 ++++++++++ ...muxml2argv-mach-virt-serial+console-native.args | 1 + ...emuxml2argv-mach-virt-serial+console-native.xml | 18 +++++++++ .../qemuxml2argv-mach-virt-serial-compat.args | 1 + .../qemuxml2argv-mach-virt-serial-compat.xml | 19 ++++++++++ ...muxml2argv-mach-virt-serial-invalid-machine.xml | 21 +++++++++++ .../qemuxml2argv-mach-virt-serial-native.args | 23 +++++++++++ .../qemuxml2argv-mach-virt-serial-native.xml | 16 ++++++++ .../qemuxml2argv-mach-virt-serial-pci.args | 26 +++++++++++++ .../qemuxml2argv-mach-virt-serial-pci.xml | 18 +++++++++ .../qemuxml2argv-mach-virt-serial-usb.args | 27 +++++++++++++ .../qemuxml2argv-mach-virt-serial-usb.xml | 21 +++++++++++ tests/qemuxml2argvtest.c | 27 +++++++++++++ .../qemuxml2xmlout-aarch64-virtio-pci-default.xml | 4 +- .../qemuxml2xmlout-mach-virt-console-native.xml | 1 + .../qemuxml2xmlout-mach-virt-console-virtio.xml | 27 +++++++++++++ ...uxml2xmlout-mach-virt-serial+console-native.xml | 1 + .../qemuxml2xmlout-mach-virt-serial-compat.xml | 31 +++++++++++++++ .../qemuxml2xmlout-mach-virt-serial-native.xml | 1 + .../qemuxml2xmlout-mach-virt-serial-pci.xml | 44 ++++++++++++++++++++++ .../qemuxml2xmlout-mach-virt-serial-usb.xml | 41 ++++++++++++++++++++ tests/qemuxml2xmltest.c | 26 +++++++++++++ 32 files changed, 500 insertions(+), 6 deletions(-) create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-native.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-console-virtio.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial+console-native.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-compat.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-invalid-machine.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-native.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-pci.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-mach-virt-serial-usb.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-native.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-console-virtio.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial+console-native.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-compat.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-native.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-pci.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-mach-virt-serial-usb.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 222504a06..16bf4fd5e 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6548,8 +6548,9 @@ qemu-kvm -net nic,model=? /dev/null <code>usb-serial</code> (usable whenever USB support is available) and <code>pci-serial</code> (usable whenever PCI support is available); <span class="since">since 3.10.0</span>, - <code>spapr-vio-serial</code> (usable with ppc64/pSeries guests) - is available as well. + <code>spapr-vio-serial</code> (usable with ppc64/pSeries guests) and + <code>system-serial</code> (usable with aarch64/virt guests) are + available as well. </p>
<p> @@ -6561,7 +6562,8 @@ qemu-kvm -net nic,model=? /dev/null target type); <code>pci-serial</code> (usable with the <code>pci-serial</code> target type); <code>spapr-vty</code> (usable with the <code>spapr-vio-serial</code> - target type). + target type); <code>pl011</code> (usable with the + <code>system-serial</code> target type).
In this patch we should document that system-serial type doesn't have any address therefore no <address/> element. One thing that I've just realized is that there is no capability check whether that device exists. In QEMU it's configurable so there can be QEMU compiled without this device, however, by default it's enabled. I would compare it to the isa-serial, in most cases it will be enabled by default so there is no need to have the capability check but since you are adding that check, you can add this one as well, or drop the isa-serial capability check :). Otherwise this patch looks good so: Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

On Mon, 2017-11-27 at 17:05 +0100, Pavel Hrdina wrote:
One thing that I've just realized is that there is no capability check whether that device exists. In QEMU it's configurable so there can be QEMU compiled without this device, however, by default it's enabled.
I would compare it to the isa-serial, in most cases it will be enabled by default so there is no need to have the capability check but since you are adding that check, you can add this one as well, or drop the isa-serial capability check :).
Yeah, having a capability for isa-serial, spapr-vty and pl011 is arguably kind of overkill because they will always be compiled into the QEMU binary for the corresponding architecture... On the other hand I don't like the idea of using functionality without checking for its presence first, so I'll add a capability for pl011 too :) -- Andrea Bolognani / Red Hat / Virtualization

From: Pino Toscano <ptoscano@redhat.com> Introduce specific a target types with two models for the console devices (sclp and sclplm) used in s390 and s390x guests, so isa-serial is no more used for them. This makes <serial> usable on s390 and s390x guests, with at most only a single sclpconsole and one sclplmconsole devices usable in a single guest (due to limitations in QEMU, which will enforce already at runtime). Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1449265 Signed-off-by: Pino Toscano <ptoscano@redhat.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> --- docs/formatdomain.html.in | 18 ++++++++---- docs/schemas/domaincommon.rng | 3 ++ src/conf/domain_conf.c | 4 +++ src/conf/domain_conf.h | 3 ++ src/qemu/qemu_command.c | 6 ++++ src/qemu/qemu_domain.c | 20 +++++++++++++ src/qemu/qemu_domain_address.c | 1 + .../qemuxml2argv-s390-serial-2.args | 24 +++++++++++++++ .../qemuxml2argv-s390-serial-2.xml | 19 ++++++++++++ .../qemuxml2argv-s390-serial-console.args | 25 ++++++++++++++++ .../qemuxml2argv-s390-serial-console.xml | 15 ++++++++++ .../qemuxml2argvdata/qemuxml2argv-s390-serial.args | 22 ++++++++++++++ .../qemuxml2argvdata/qemuxml2argv-s390-serial.xml | 14 +++++++++ tests/qemuxml2argvtest.c | 16 ++++++++++ .../qemuxml2xmlout-s390-serial-2.xml | 33 +++++++++++++++++++++ .../qemuxml2xmlout-s390-serial-console.xml | 34 ++++++++++++++++++++++ .../qemuxml2xmlout-s390-serial.xml | 28 ++++++++++++++++++ tests/qemuxml2xmltest.c | 6 ++++ 18 files changed, 285 insertions(+), 6 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-serial.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-2.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 16bf4fd5e..841f1e3f2 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6548,9 +6548,10 @@ qemu-kvm -net nic,model=? /dev/null <code>usb-serial</code> (usable whenever USB support is available) and <code>pci-serial</code> (usable whenever PCI support is available); <span class="since">since 3.10.0</span>, - <code>spapr-vio-serial</code> (usable with ppc64/pSeries guests) and - <code>system-serial</code> (usable with aarch64/virt guests) are - available as well. + <code>spapr-vio-serial</code> (usable with ppc64/pSeries guests), + <code>system-serial</code> (usable with aarch64/virt guests) and + <code>sclp-serial</code> (usable with s390x guests) are available as + well. </p> <p> @@ -6563,7 +6564,9 @@ qemu-kvm -net nic,model=? /dev/null (usable with the <code>pci-serial</code> target type); <code>spapr-vty</code> (usable with the <code>spapr-vio-serial</code> target type); <code>pl011</code> (usable with the - <code>system-serial</code> target type). + <code>system-serial</code> target type); <code>sclpconsole</code> and + <code>sclplmconsole</code> (usable with the <code>sclp-serial</code> + target type). </p> <p> @@ -6618,8 +6621,11 @@ qemu-kvm -net nic,model=? /dev/null <code>virtio</code> (usable whenever VirtIO support is available); <code>xen</code>, <code>lxc</code>, <code>uml</code> and <code>openvz</code> (available when the corresponding hypervisor is in - use); <code>sclp</code> and <code>sclplm</code> (usable for s390 and - s390x QEMU guests). + use). <code>sclp</code> and <code>sclplm</code> (usable for s390 and + s390x QEMU guests) are supported for compatibility reasons but should + not be used for new guests: use the <code>sclpconsole</code> and + <code>sclplmconsole</code> target models, respectively, with the + <code>serial</code> element instead. </p> <p> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 5fff3a40f..5b9fc162c 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3587,6 +3587,7 @@ <value>pci-serial</value> <value>spapr-vio-serial</value> <value>system-serial</value> + <value>sclp-serial</value> </choice> </attribute> </define> @@ -3600,6 +3601,8 @@ <value>pci-serial</value> <value>spapr-vty</value> <value>pl011</value> + <value>sclpconsole</value> + <value>sclplmconsole</value> </choice> </attribute> </element> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 820caba0f..b31917dad 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -454,6 +454,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTarget, "pci-serial", "spapr-vio-serial", "system-serial", + "sclp-serial", ); VIR_ENUM_IMPL(virDomainChrChannelTarget, @@ -483,6 +484,8 @@ VIR_ENUM_IMPL(virDomainChrSerialTargetModel, "pci-serial", "spapr-vty", "pl011", + "sclpconsole", + "sclplmconsole", ); VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST, @@ -4064,6 +4067,7 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def) case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: { /* Create a stub console to match the serial port. diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 28d158980..48b07226e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1083,6 +1083,7 @@ typedef enum { VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM, + VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST } virDomainChrSerialTargetType; @@ -1117,6 +1118,8 @@ typedef enum { VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST } virDomainChrSerialTargetModel; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a8aaa3d8c..d0d72affe 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10356,6 +10356,10 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel) return QEMU_CAPS_DEVICE_PCI_SERIAL; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: return QEMU_CAPS_DEVICE_SPAPR_VTY; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE: + return QEMU_CAPS_DEVICE_SCLPCONSOLE; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE: + return QEMU_CAPS_DEVICE_SCLPLMCONSOLE; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: @@ -10383,6 +10387,8 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE: caps = qemuChrSerialTargetModelToCaps(serial->targetModel); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2cc91b468..b3b34348b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3473,6 +3473,7 @@ qemuDomainChrSerialTargetTypeToAddressType(int targetType) case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: break; @@ -3496,6 +3497,9 @@ qemuDomainChrSerialTargetModelToTargetType(int targetModel) return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE: + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: break; @@ -3533,6 +3537,7 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr) break; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP: if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Target type '%s' cannot have an " @@ -3554,6 +3559,8 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr) case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE: expected = qemuDomainChrSerialTargetModelToTargetType(chr->targetModel); @@ -3616,6 +3623,13 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, isCompatible = false; } + if (!ARCH_IS_S390(def->os.arch) && + (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP || + dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE || + dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE)) { + isCompatible = false; + } + if (!isCompatible) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Serial device with target type '%s' and " @@ -4269,6 +4283,8 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO; } else if (qemuDomainIsVirt(def)) { chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM; + } else if (ARCH_IS_S390(def->os.arch)) { + chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP; } } @@ -4291,6 +4307,9 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM: chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011; break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP: + chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE; + break; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: /* Nothing to do */ @@ -5214,6 +5233,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver, case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: /* Nothing to do */ diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index db9656a3a..a40cdb399 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -785,6 +785,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: return 0; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.args new file mode 100644 index 000000000..346dcd16b --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.args @@ -0,0 +1,24 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-s390x \ +-name QEMUGuest1 \ +-S \ +-M s390-ccw-virtio \ +-m 214 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-boot c \ +-chardev pty,id=charserial0 \ +-device sclpconsole,chardev=charserial0,id=serial0 \ +-chardev pty,id=charserial1 \ +-device sclplmconsole,chardev=charserial1,id=serial1 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.xml b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.xml new file mode 100644 index 000000000..b6eb377c9 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-2.xml @@ -0,0 +1,19 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch="s390x" machine="s390-ccw-virtio">hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-s390x</emulator> + <serial type='pty'/> + <serial type='pty'> + <target type='sclp-serial'> + <model name='sclplmconsole'/> + </target> + </serial> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args new file mode 100644 index 000000000..c405fb59e --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args @@ -0,0 +1,25 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-s390x \ +-name QEMUGuest1 \ +-S \ +-M s390-ccw-virtio \ +-m 214 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-boot c \ +-device virtio-serial-ccw,id=virtio-serial0,devno=fe.0.0000 \ +-chardev pty,id=charserial0 \ +-device sclpconsole,chardev=charserial0,id=serial0 \ +-chardev pty,id=charconsole1 \ +-device virtconsole,chardev=charconsole1,id=console1 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.xml b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.xml new file mode 100644 index 000000000..c841f1f24 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.xml @@ -0,0 +1,15 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch="s390x" machine="s390-ccw-virtio">hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-s390x</emulator> + <serial type='pty'/> + <console type='pty'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial.args new file mode 100644 index 000000000..20968f794 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial.args @@ -0,0 +1,22 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-s390x \ +-name QEMUGuest1 \ +-S \ +-M s390-ccw-virtio \ +-m 214 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-boot c \ +-chardev pty,id=charserial0 \ +-device sclpconsole,chardev=charserial0,id=serial0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial.xml b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial.xml new file mode 100644 index 000000000..55b45bac0 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial.xml @@ -0,0 +1,14 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch="s390x" machine="s390-ccw-virtio">hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-s390x</emulator> + <serial type='pty'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 593057653..d9ed8af79 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2051,6 +2051,22 @@ mymain(void) QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); + DO_TEST("s390-serial", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_VIRTIO_CCW, + QEMU_CAPS_VIRTIO_S390, + QEMU_CAPS_DEVICE_SCLPCONSOLE); + DO_TEST("s390-serial-2", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_VIRTIO_CCW, + QEMU_CAPS_VIRTIO_S390, + QEMU_CAPS_DEVICE_SCLPCONSOLE, + QEMU_CAPS_DEVICE_SCLPLMCONSOLE); + DO_TEST("s390-serial-console", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_VIRTIO_CCW, + QEMU_CAPS_VIRTIO_S390, + QEMU_CAPS_DEVICE_SCLPCONSOLE); DO_TEST("ppc-dtb", QEMU_CAPS_KVM, diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-2.xml new file mode 100644 index 000000000..bb9ca30f1 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-2.xml @@ -0,0 +1,33 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='s390x' machine='s390-ccw-virtio'>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-s390x</emulator> + <serial type='pty'> + <target type='sclp-serial' port='0'> + <model name='sclpconsole'/> + </target> + </serial> + <serial type='pty'> + <target type='sclp-serial' port='1'> + <model name='sclplmconsole'/> + </target> + </serial> + <console type='pty'> + <target type='serial' port='0'/> + </console> + <memballoon model='none'/> + <panic model='s390'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml new file mode 100644 index 000000000..db3023b7a --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml @@ -0,0 +1,34 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='s390x' machine='s390-ccw-virtio'>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-s390x</emulator> + <controller type='virtio-serial' index='0'> + <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/> + </controller> + <serial type='pty'> + <target type='sclp-serial' port='0'> + <model name='sclpconsole'/> + </target> + </serial> + <console type='pty'> + <target type='serial' port='0'/> + </console> + <console type='pty'> + <target type='virtio' port='0'/> + </console> + <memballoon model='none'/> + <panic model='s390'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial.xml new file mode 100644 index 000000000..9c9b4dd27 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='s390x' machine='s390-ccw-virtio'>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-s390x</emulator> + <serial type='pty'> + <target type='sclp-serial' port='0'> + <model name='sclpconsole'/> + </target> + </serial> + <console type='pty'> + <target type='serial' port='0'/> + </console> + <memballoon model='none'/> + <panic model='s390'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 323845340..146a67ee2 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1157,6 +1157,12 @@ mymain(void) QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); DO_TEST("s390-panic-no-address", QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); + DO_TEST("s390-serial", + QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); + DO_TEST("s390-serial-2", + QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); + DO_TEST("s390-serial-console", + QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); DO_TEST("pcihole64", NONE); DO_TEST("pcihole64-gib", NONE); -- 2.14.3

From: Pino Toscano <ptoscano@redhat.com> Signed-off-by: Pino Toscano <ptoscano@redhat.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com> --- src/conf/domain_conf.c | 10 ++++++---- src/conf/domain_conf.h | 3 ++- src/vz/vz_sdk.c | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b31917dad..792d9bef4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3987,7 +3987,8 @@ virDomainDefPostParseMemory(virDomainDefPtr def, static int -virDomainDefAddConsoleCompat(virDomainDefPtr def) +virDomainDefAddConsoleCompat(virDomainDefPtr def, + unsigned int parseFlags ATTRIBUTE_UNUSED) { size_t i; @@ -4948,7 +4949,7 @@ virDomainDefPostParseCommon(virDomainDefPtr def, if (virDomainDefPostParseTimer(def) < 0) return -1; - if (virDomainDefAddImplicitDevices(def) < 0) + if (virDomainDefAddImplicitDevices(def, data->parseFlags) < 0) return -1; if (def->nvideos != 0) { @@ -22017,9 +22018,10 @@ virDomainDefAddImplicitVideo(virDomainDefPtr def) } int -virDomainDefAddImplicitDevices(virDomainDefPtr def) +virDomainDefAddImplicitDevices(virDomainDefPtr def, + unsigned int parseFlags) { - if (virDomainDefAddConsoleCompat(def) < 0) + if (virDomainDefAddConsoleCompat(def, parseFlags) < 0) return -1; if (virDomainDefAddImplicitControllers(def) < 0) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 48b07226e..6e23cdd7d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2945,7 +2945,8 @@ bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src, virDomainXMLOptionPtr xmlopt, unsigned int flags); -int virDomainDefAddImplicitDevices(virDomainDefPtr def); +int virDomainDefAddImplicitDevices(virDomainDefPtr def, + unsigned int parseFlags); virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(const virDomainDef *def, unsigned int iothread_id); diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index eea5f6fc6..35522f46c 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1932,7 +1932,7 @@ prlsdkLoadDomain(vzDriverPtr driver, if (prlsdkGetDomainState(dom, sdkdom, &domainState) < 0) goto error; - if (!IS_CT(def) && virDomainDefAddImplicitDevices(def) < 0) + if (!IS_CT(def) && virDomainDefAddImplicitDevices(def, 0) < 0) goto error; if (def->ngraphics > 0) { -- 2.14.3

From: Pino Toscano <ptoscano@redhat.com> In case we are allowed to break the ABI of a s390/s390x guest, then convert the first sclp/sclplm console from <console> to <serial>, just like it is done on other architectures. Signed-off-by: Pino Toscano <ptoscano@redhat.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> --- This patch might need to be dropped. See https://www.redhat.com/archives/libvir-list/2017-November/msg00996.html src/conf/domain_conf.c | 46 ++++++++++++++++++++-- .../qemuxml2argv-s390-console2serial.args | 22 +++++++++++ .../qemuxml2argv-s390-console2serial.xml | 19 +++++++++ tests/qemuxml2argvtest.c | 6 +++ 4 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-console2serial.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-console2serial.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 792d9bef4..29afcb6c5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3986,9 +3986,40 @@ virDomainDefPostParseMemory(virDomainDefPtr def, } +static void +virDomainChrConsoleTargetTypeToSerial(virDomainChrConsoleTargetType type, + int *targetType, + int *targetModel) +{ + switch (type) { + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP: + *targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP; + *targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE; + break; + + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM: + *targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP; + *targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE; + break; + + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE: + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL: + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN: + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML: + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO: + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC: + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ: + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST: + *targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE; + *targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE; + break; + } +} + + static int virDomainDefAddConsoleCompat(virDomainDefPtr def, - unsigned int parseFlags ATTRIBUTE_UNUSED) + unsigned int parseFlags) { size_t i; @@ -4005,6 +4036,10 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def, * * We then fill def->consoles[0] with a stub just so we get sequencing * correct for consoles > 0 + * + * sclp/sclplm consoles (in s390 and s390x guests) are converted to serial + * only when we can update the ABI of the guest, to avoid breaking + * migrations to old libvirt. */ /* Only the first console (if there are any) can be of type serial, @@ -4021,7 +4056,10 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def, } if (def->nconsoles > 0 && def->os.type == VIR_DOMAIN_OSTYPE_HVM && (def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL || - def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)) { + def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE || + ((def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP || + def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM) && + (parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE)))) { /* If there isn't a corresponding serial port: * - create one and set, the console to be an alias for it @@ -4041,7 +4079,9 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def, /* modify it to be a serial port */ def->serials[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; - def->serials[0]->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE; + virDomainChrConsoleTargetTypeToSerial(def->serials[0]->targetType, + &def->serials[0]->targetType, + &def->serials[0]->targetModel); def->serials[0]->target.port = 0; } else { /* if the console source doesn't match */ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-console2serial.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-console2serial.args new file mode 100644 index 000000000..20968f794 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-console2serial.args @@ -0,0 +1,22 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-s390x \ +-name QEMUGuest1 \ +-S \ +-M s390-ccw-virtio \ +-m 214 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-boot c \ +-chardev pty,id=charserial0 \ +-device sclpconsole,chardev=charserial0,id=serial0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-console2serial.xml b/tests/qemuxml2argvdata/qemuxml2argv-s390-console2serial.xml new file mode 100644 index 000000000..5f02ec8a0 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-console2serial.xml @@ -0,0 +1,19 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch="s390x" machine="s390-ccw-virtio">hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-s390x</emulator> + <!-- Since this test is run with the flag VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, + then it will result in a <serial> element created for it, and thus + a serial chardev for QEMU. --> + <console type='pty'> + <target type='sclp'/> + </console> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d9ed8af79..9480f865f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2067,6 +2067,12 @@ mymain(void) QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_DEVICE_SCLPCONSOLE); + DO_TEST_FULL("s390-console2serial", NULL, -1, 0, + VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, GIC_NONE, + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_VIRTIO_CCW, + QEMU_CAPS_VIRTIO_S390, + QEMU_CAPS_DEVICE_SCLPCONSOLE); DO_TEST("ppc-dtb", QEMU_CAPS_KVM, -- 2.14.3

From: Pino Toscano <ptoscano@redhat.com> Now that <serial> and <console> on s390/s390x behave a bit more like the other architectures, remove this extra differentation, and use sclp console by default for new guests. New virtio consoles can still be added, and it is actually needed because of the limited number of instances for sclp and sclplm. This reverts commit b1c88c14764e0b043a269d454a83a6ac7af34eac, whose reasons are not totally clear. Signed-off-by: Pino Toscano <ptoscano@redhat.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> --- src/qemu/qemu_domain.c | 7 ------- tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args | 5 +---- tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml | 8 ++++++-- tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml | 6 ------ 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b3b34348b..d1e391f48 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4259,13 +4259,6 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, virQEMUDriverPtr driver, unsigned int parseFlags) { - /* set the default console type for S390 arches */ - if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && - chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && - ARCH_IS_S390(def->os.arch)) { - chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO; - } - /* Historically, isa-serial and the default matched, so in order to * maintain backwards compatibility we map them here. The actual default * will be picked below based on the architecture and machine type. */ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args index c405fb59e..20968f794 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-serial-console.args @@ -18,8 +18,5 @@ QEMU_AUDIO_DRV=none \ server,nowait \ -mon chardev=charmonitor,id=monitor,mode=readline \ -boot c \ --device virtio-serial-ccw,id=virtio-serial0,devno=fe.0.0000 \ -chardev pty,id=charserial0 \ --device sclpconsole,chardev=charserial0,id=serial0 \ --chardev pty,id=charconsole1 \ --device virtconsole,chardev=charconsole1,id=console1 +-device sclpconsole,chardev=charserial0,id=serial0 diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml index 7eb1a765a..0f278f2c9 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml @@ -14,9 +14,13 @@ <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/qemu-system-s390x</emulator> - <controller type='virtio-serial' index='0'/> + <serial type='pty'> + <target type='sclp-serial' port='0'> + <model name='sclpconsole'/> + </target> + </serial> <console type='pty'> - <target type='virtio' port='0'/> + <target type='serial' port='0'/> </console> <memballoon model='none'/> <panic model='s390'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml index db3023b7a..9c9b4dd27 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-serial-console.xml @@ -14,9 +14,6 @@ <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/qemu-system-s390x</emulator> - <controller type='virtio-serial' index='0'> - <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/> - </controller> <serial type='pty'> <target type='sclp-serial' port='0'> <model name='sclpconsole'/> @@ -25,9 +22,6 @@ <console type='pty'> <target type='serial' port='0'/> </console> - <console type='pty'> - <target type='virtio' port='0'/> - </console> <memballoon model='none'/> <panic model='s390'/> </devices> -- 2.14.3

All other serial devices have an associated capability. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + tests/qemuhelptest.c | 5 +++++ 24 files changed, 29 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f2d24a309..cd519cb3c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -452,6 +452,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "numa.dist", "disk-share-rw", "iscsi.password-secret", + "isa-serial", ); @@ -1682,6 +1683,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "vmcoreinfo", QEMU_CAPS_DEVICE_VMCOREINFO }, { "spapr-vty", QEMU_CAPS_DEVICE_SPAPR_VTY }, { "sclplmconsole", QEMU_CAPS_DEVICE_SCLPLMCONSOLE }, + { "isa-serial", QEMU_CAPS_DEVICE_ISA_SERIAL }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 68a2541d3..fc043b075 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -438,6 +438,7 @@ typedef enum { QEMU_CAPS_NUMA_DIST, /* -numa dist */ QEMU_CAPS_DISK_SHARE_RW, /* share-rw=on for concurrent disk access */ QEMU_CAPS_ISCSI_PASSWORD_SECRET, /* -drive file.driver=iscsi,...,password-secret= */ + QEMU_CAPS_DEVICE_ISA_SERIAL, /* -device isa-serial */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml index 956284d5d..d560811ab 100644 --- a/tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml @@ -109,6 +109,7 @@ <flag name='device-tray-moved-event'/> <flag name='display'/> <flag name='query-cpu-definitions'/> + <flag name='isa-serial'/> <version>1002002</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml index 99384ce5e..576475f7f 100644 --- a/tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml @@ -127,6 +127,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='display'/> <flag name='query-cpu-definitions'/> + <flag name='isa-serial'/> <version>1003001</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml index aea043c57..0c271d3e4 100644 --- a/tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml @@ -128,6 +128,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='display'/> <flag name='query-cpu-definitions'/> + <flag name='isa-serial'/> <version>1004002</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml index 6f860e4f2..5c667975b 100644 --- a/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml @@ -140,6 +140,7 @@ <flag name='vhost-scsi'/> <flag name='query-cpu-definitions'/> <flag name='kernel-irqchip'/> + <flag name='isa-serial'/> <version>1005003</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml index e5dc8360d..8ae07a91d 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml @@ -145,6 +145,7 @@ <flag name='vhost-scsi'/> <flag name='query-cpu-definitions'/> <flag name='kernel-irqchip'/> + <flag name='isa-serial'/> <version>1006000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml index 86d87eaf0..34bd6be1c 100644 --- a/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml @@ -147,6 +147,7 @@ <flag name='vhost-scsi'/> <flag name='query-cpu-definitions'/> <flag name='kernel-irqchip'/> + <flag name='isa-serial'/> <version>1007000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml index 2fa551b1a..0d7c144ff 100644 --- a/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml @@ -163,6 +163,7 @@ <flag name='query-cpu-definitions'/> <flag name='query-named-block-nodes'/> <flag name='kernel-irqchip'/> + <flag name='isa-serial'/> <version>2001001</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml index 96b42bbe9..b4dc8f196 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml @@ -183,6 +183,7 @@ <flag name='numa.dist'/> <flag name='disk-share-rw'/> <flag name='iscsi.password-secret'/> + <flag name='isa-serial'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <package> (v2.10.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml index 79866a025..f2f598967 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml @@ -183,6 +183,7 @@ <flag name='numa.dist'/> <flag name='disk-share-rw'/> <flag name='iscsi.password-secret'/> + <flag name='isa-serial'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <package> (v2.10.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml index 5f97bc393..ca55e11eb 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml @@ -182,6 +182,7 @@ <flag name='numa.dist'/> <flag name='disk-share-rw'/> <flag name='iscsi.password-secret'/> + <flag name='isa-serial'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <package> (v2.10.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml index ec7f29cc1..8fea70a52 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml @@ -227,6 +227,7 @@ <flag name='numa.dist'/> <flag name='disk-share-rw'/> <flag name='iscsi.password-secret'/> + <flag name='isa-serial'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <package> (v2.10.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml index f97e4cb81..5007523c1 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml @@ -188,6 +188,7 @@ <flag name='vnc-multi-servers'/> <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> + <flag name='isa-serial'/> <version>2004000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml index 2ba40fc49..a9ad292d0 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml @@ -194,6 +194,7 @@ <flag name='vnc-multi-servers'/> <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> + <flag name='isa-serial'/> <version>2005000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml index 0b34fa30d..e699bdbaf 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml @@ -172,6 +172,7 @@ <flag name='vnc-multi-servers'/> <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> + <flag name='isa-serial'/> <version>2006000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml index d41d578c7..f4c1de7e1 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml @@ -172,6 +172,7 @@ <flag name='vnc-multi-servers'/> <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> + <flag name='isa-serial'/> <version>2006000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml index 5ff8598fc..27d99bd93 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml @@ -168,6 +168,7 @@ <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> <flag name='spapr-vty'/> + <flag name='isa-serial'/> <version>2006000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml index bdf006f6b..97621612a 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml @@ -204,6 +204,7 @@ <flag name='vnc-multi-servers'/> <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> + <flag name='isa-serial'/> <version>2006000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml index 59adff6c9..e4ea9452c 100644 --- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml @@ -208,6 +208,7 @@ <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> <flag name='virtio-blk.num-queues'/> + <flag name='isa-serial'/> <version>2007000</version> <kvmVersion>0</kvmVersion> <package> (v2.7.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml index 3165b2dee..c6d3e21d5 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml @@ -210,6 +210,7 @@ <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> <flag name='virtio-blk.num-queues'/> + <flag name='isa-serial'/> <version>2008000</version> <kvmVersion>0</kvmVersion> <package> (v2.8.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml index 4e712f69e..96aa5d59f 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml @@ -176,6 +176,7 @@ <flag name='spapr-vty'/> <flag name='disk-share-rw'/> <flag name='iscsi.password-secret'/> + <flag name='isa-serial'/> <version>2009000</version> <kvmVersion>0</kvmVersion> <package> (v2.9.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml index 4e8079d8f..9f489129f 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml @@ -223,6 +223,7 @@ <flag name='virtio-blk.num-queues'/> <flag name='disk-share-rw'/> <flag name='iscsi.password-secret'/> + <flag name='isa-serial'/> <version>2009000</version> <kvmVersion>0</kvmVersion> <package> (v2.9.0)</package> diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 2280e96a3..1336eeef5 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -174,6 +174,7 @@ mymain(void) QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_DEVICE_RTL8139, QEMU_CAPS_DEVICE_E1000, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_DEVICE_VIRTIO_NET); DO_TEST("qemu-kvm-0.12.3", 12003, 1, 0, QEMU_CAPS_DRIVE_BOOT, @@ -210,6 +211,7 @@ mymain(void) QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_DEVICE_RTL8139, QEMU_CAPS_DEVICE_E1000, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_DEVICE_VIRTIO_NET); DO_TEST("qemu-kvm-0.13.0", 13000, 1, 0, QEMU_CAPS_DRIVE_BOOT, @@ -258,6 +260,7 @@ mymain(void) QEMU_CAPS_DEVICE_IVSHMEM, QEMU_CAPS_DEVICE_RTL8139, QEMU_CAPS_DEVICE_E1000, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_DEVICE_VIRTIO_NET); DO_TEST("qemu-1.0", 1000000, 0, 0, QEMU_CAPS_DRIVE_CACHE_UNSAFE, @@ -328,6 +331,7 @@ mymain(void) QEMU_CAPS_DEVICE_RTL8139, QEMU_CAPS_DEVICE_E1000, QEMU_CAPS_DEVICE_VIRTIO_NET, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_DISPLAY); DO_TEST("qemu-1.1.0", 1001000, 0, 0, QEMU_CAPS_DRIVE_CACHE_UNSAFE, @@ -411,6 +415,7 @@ mymain(void) QEMU_CAPS_DEVICE_RTL8139, QEMU_CAPS_DEVICE_E1000, QEMU_CAPS_DEVICE_VIRTIO_NET, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_DISPLAY); DO_TEST_FULL("qemu-1.2.0", 1002000, 0, 0, VIR_ERR_CONFIG_UNSUPPORTED, QEMU_CAPS_LAST); -- 2.14.3

On Sun, Nov 26, 2017 at 11:25:46PM +0100, Andrea Bolognani wrote:
All other serial devices have an associated capability.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com> But see my note about pl011, I'm OK with adding capability checks for all possible devices that we use, so we should add a capability check for pl011 as well.

We should make sure the isa-serial device is available before formatting it on the QEMU command line. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/qemu/qemu_command.c | 7 +++---- tests/qemuxml2argvtest.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d0d72affe..7d0d32c2a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10350,6 +10350,8 @@ static virQEMUCapsFlags qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel) { switch (targetModel) { + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: + return QEMU_CAPS_DEVICE_ISA_SERIAL; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL: return QEMU_CAPS_DEVICE_USB_SERIAL; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: @@ -10360,7 +10362,6 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel) return QEMU_CAPS_DEVICE_SCLPCONSOLE; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE: return QEMU_CAPS_DEVICE_SCLPLMCONSOLE; - case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: @@ -10384,6 +10385,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, virQEMUCapsFlags caps; switch ((virDomainChrSerialTargetModel) serial->targetModel) { + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: @@ -10400,9 +10402,6 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, } break; - case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: - break; - case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 9480f865f..cd6c66b3f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -771,6 +771,7 @@ mymain(void) DO_TEST_FAILURE("reboot-timeout-enabled", NONE); DO_TEST("bios", + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_SGA); DO_TEST("bios-nvram", NONE); DO_TEST("bios-nvram-secure", @@ -814,6 +815,7 @@ mymain(void) QEMU_CAPS_SPICE, QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_USB_HUB, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_DEVICE_CIRRUS_VGA); DO_TEST("eoi-disabled", NONE); DO_TEST("eoi-enabled", NONE); @@ -1231,48 +1233,64 @@ mymain(void) DO_TEST("serial-file-log", QEMU_CAPS_CHARDEV_FILE_APPEND, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_CHARDEV_LOGFILE); DO_TEST("serial-spiceport", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_SPICE, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_CHARDEV_SPICEPORT); DO_TEST("serial-spiceport-nospice", NONE); - DO_TEST("console-compat", NONE); - DO_TEST("console-compat-auto", NONE); + DO_TEST("console-compat", + QEMU_CAPS_DEVICE_ISA_SERIAL); + DO_TEST("console-compat-auto", + QEMU_CAPS_DEVICE_ISA_SERIAL); DO_TEST("serial-vc-chardev", + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_NODEFCONFIG); DO_TEST("serial-pty-chardev", + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_NODEFCONFIG); DO_TEST("serial-dev-chardev", + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_NODEFCONFIG); DO_TEST("serial-dev-chardev-iobase", + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_NODEFCONFIG); DO_TEST("serial-file-chardev", QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_CHARDEV_FILE_APPEND); DO_TEST("serial-unix-chardev", + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_NODEFCONFIG); DO_TEST("serial-tcp-chardev", + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_NODEFCONFIG); DO_TEST("serial-udp-chardev", + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_NODEFCONFIG); DO_TEST("serial-tcp-telnet-chardev", + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_NODEFCONFIG); driver.config->chardevTLS = 1; DO_TEST("serial-tcp-tlsx509-chardev", QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_OBJECT_TLS_CREDS_X509); driver.config->chardevTLSx509verify = 1; DO_TEST("serial-tcp-tlsx509-chardev-verify", QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_OBJECT_TLS_CREDS_X509); driver.config->chardevTLSx509verify = 0; DO_TEST("serial-tcp-tlsx509-chardev-notls", QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_OBJECT_TLS_CREDS_X509); VIR_FREE(driver.config->chardevTLSx509certdir); if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509certdir, "/etc/pki/libvirt-chardev") < 0) @@ -1284,22 +1302,26 @@ mymain(void) DO_TEST("serial-tcp-tlsx509-secret-chardev", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_OBJECT_SECRET, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_OBJECT_TLS_CREDS_X509); # else DO_TEST_FAILURE("serial-tcp-tlsx509-secret-chardev", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_OBJECT_SECRET, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_OBJECT_TLS_CREDS_X509); # endif driver.config->chardevTLS = 0; VIR_FREE(driver.config->chardevTLSx509certdir); DO_TEST("serial-many-chardev", + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_NODEFCONFIG); DO_TEST("parallel-tcp-chardev", QEMU_CAPS_NODEFCONFIG); DO_TEST("parallel-parport-chardev", QEMU_CAPS_NODEFCONFIG); DO_TEST("console-compat-chardev", + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_NODEFCONFIG); DO_TEST("pci-serial-dev-chardev", QEMU_CAPS_NODEFCONFIG, @@ -1320,6 +1342,7 @@ mymain(void) DO_TEST("console-virtio", QEMU_CAPS_NODEFCONFIG); DO_TEST("console-virtio-many", + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_NODEFCONFIG); DO_TEST("console-virtio-s390", QEMU_CAPS_NODEFCONFIG, @@ -2318,6 +2341,7 @@ mymain(void) QEMU_CAPS_CHARDEV_SPICEVMC, QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_HDA_DUPLEX, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_USB_REDIR); /* Test automatic and manual setting of pcie-root-port attributes */ @@ -2922,6 +2946,7 @@ mymain(void) DO_TEST("user-aliases", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4, QEMU_CAPS_VNC, + QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_HDA_DUPLEX); DO_TEST("user-aliases2", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI); -- 2.14.3

On Sun, Nov 26, 2017 at 11:25:47PM +0100, Andrea Bolognani wrote:
We should make sure the isa-serial device is available before formatting it on the QEMU command line.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/qemu/qemu_command.c | 7 +++---- tests/qemuxml2argvtest.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

The ISA bus is x86 specific, so we should limit usage of isa-serial to x86 guests only, just like we already do eg. with sclpconsole and s390x guests. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/qemu/qemu_domain.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d1e391f48..cf4af14dd 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3611,6 +3611,12 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) { bool isCompatible = true; + if (!ARCH_IS_X86(def->os.arch) && + (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA || + dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL)) { + isCompatible = false; + } + if (!qemuDomainIsPSeries(def) && (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO || dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY)) { -- 2.14.3

Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/news.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 104668ce9..397e382b9 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -148,6 +148,18 @@ can prepare the files if they need to do so. </description> </change> + <change> + <summary> + Improve serial console behavior on non-x86 architectures + </summary> + <description> + ppc64, aarch64 and s390x guests were treating the <serial> + and <console> elements differently from x86, in some cases + presenting misleading information to the user. The behavior is now + consistent across all architectures and the information reported + is always accurate. + </description> + </change> </section> <section title="Bug fixes"> <change> -- 2.14.3
participants (2)
-
Andrea Bolognani
-
Pavel Hrdina