[libvirt] [PATCH v2 00/21] Fix serial console behavior on non-x86 architectures

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. I've kept existing R-bs because the changes didn't IMHO invalidate them, but feel free to double check and possibly disagree. Proper documentation will come as a follow-up, see the previous version to get an idea of what it will look like. [1] https://www.redhat.com/archives/libvir-list/2017-November/msg00545.html Andrea Bolognani (17): 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: Improve virDomainChrTargetDefFormat() conf: Remove ATTRIBUTE_FALLTHROUGH from virDomainChrTargetDefFormat() qemu: Introduce 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 conf: Shorten names in virDomainChrSerialTarget enumeration 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 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 | 13 +- docs/schemas/domaincommon.rng | 26 ++ src/conf/domain_conf.c | 311 +++++++++++++++++---- src/conf/domain_conf.h | 26 +- src/libvirt_private.syms | 2 + src/qemu/qemu_command.c | 126 ++++----- src/qemu/qemu_domain.c | 310 ++++++++++++++++++-- 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 +- ...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 | 72 +++++ .../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 ++++ 122 files changed, 1667 insertions(+), 329 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} (79%) 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

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> --- 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 cc7596bad..c6ba4079d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4036,6 +4036,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, @@ -4096,29 +4125,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) @@ -4154,6 +4160,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

On Tue, Nov 21, 2017 at 05:42:11PM +0100, Andrea Bolognani wrote:
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> --- src/qemu/qemu_domain.c | 57 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 23 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

On Tue, Nov 21, 2017 at 05:42 PM +0100, Andrea Bolognani <abologna@redhat.com> wrote:
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> --- 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 cc7596bad..c6ba4079d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4036,6 +4036,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, @@ -4096,29 +4125,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) @@ -4154,6 +4160,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
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com> -- Beste Grüße / Kind regards Marc Hartmayer IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

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 969a6632b..20a4acd74 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4939,6 +4939,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 20a4acd74..321ee6a0f 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") @@ -4016,7 +4017,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 */ @@ -4040,7 +4041,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 @@ -11481,7 +11483,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 cb8701dd2..9b88bf19d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1081,7 +1081,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 216a4bdfe..d534bc8ad 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9166,6 +9166,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; } @@ -10314,7 +10322,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 c6ba4079d..b60c374d9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4049,6 +4049,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 321ee6a0f..e4c537136 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11495,8 +11495,7 @@ virDomainChrDefaultTargetType(int devtype) } static int -virDomainChrTargetTypeFromString(virDomainChrDefPtr def, - int devtype, +virDomainChrTargetTypeFromString(int devtype, const char *targetType) { int ret = -1; @@ -11524,8 +11523,6 @@ virDomainChrTargetTypeFromString(virDomainChrDefPtr def, break; } - def->targetTypeAttr = true; - return ret; } @@ -11542,7 +11539,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"), @@ -16462,7 +16459,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; @@ -24023,7 +24020,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 9b88bf19d..5d4d17ed6 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1207,7 +1207,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 3a95b6088..6d847de3a 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml @@ -40,7 +40,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 759b84439..30989658f 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.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-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> --- 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 e4c537136..224b88d9a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23933,38 +23933,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) { @@ -24036,6 +24013,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

On Tue, Nov 21, 2017 at 05:42:15PM +0100, Andrea Bolognani wrote:
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> --- src/conf/domain_conf.c | 67 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 27 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

We don't need to store the return value since we never modify it; we should also report failure when virDomainChrSourceDefFormat() fails. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/conf/domain_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 224b88d9a..cb4ed6ef6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -24025,8 +24025,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"), @@ -24044,7 +24042,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; @@ -24054,7 +24054,7 @@ virDomainChrDefFormat(virBufferPtr buf, virBufferAdjustIndent(buf, -2); virBufferAsprintf(buf, "</%s>\n", elementName); - return ret; + return 0; } static int -- 2.14.3

On Tue, Nov 21, 2017 at 05:42:16PM +0100, Andrea Bolognani wrote:
We don't need to store the return value since we never modify it; we should also report failure when virDomainChrSourceDefFormat() fails.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/conf/domain_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 224b88d9a..cb4ed6ef6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -24025,8 +24025,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"), @@ -24044,7 +24042,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;
This change could be separated and all other calls of that function should be checked for error since none of them are checked. Pavel

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> --- 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 cb4ed6ef6..cd9d384d3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23942,7 +23942,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", @@ -23989,28 +23989,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

On Tue, Nov 21, 2017 at 05:42:17PM +0100, Andrea Bolognani wrote:
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> --- src/conf/domain_conf.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

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> --- 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 cd9d384d3..9d6e06025 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -24007,14 +24007,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

On Tue, Nov 21, 2017 at 05:42:18PM +0100, Andrea Bolognani wrote:
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> --- src/conf/domain_conf.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

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> --- src/qemu/qemu_command.c | 20 --------------- src/qemu/qemu_domain.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d534bc8ad..86521d498 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10289,22 +10289,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: @@ -10313,13 +10300,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 b60c374d9..12b2a0bf6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3490,6 +3490,68 @@ 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", + _("Target type 'isa-serial' requires address " + "of type 'isa'")); + 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", + _("Target type 'usb-serial' requires address " + "of type 'usb'")); + 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", + _("Target type 'pci-serial' requires address " + "of type 'pci'")); + 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) @@ -3497,6 +3559,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

On Tue, Nov 21, 2017 at 05:42:19PM +0100, Andrea Bolognani wrote:
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> --- src/qemu/qemu_command.c | 20 --------------- src/qemu/qemu_domain.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 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/schemas/domaincommon.rng | 15 +++++++++ src/conf/domain_conf.c | 72 ++++++++++++++++++++++++++++++++++++++++++- src/conf/domain_conf.h | 12 ++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) 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 9d6e06025..140f478b0 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", @@ -11526,14 +11534,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; @@ -11547,6 +11583,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) { @@ -11635,6 +11689,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def, ret = 0; error: VIR_FREE(targetType); + VIR_FREE(targetModel); VIR_FREE(addrStr); VIR_FREE(portStr); VIR_FREE(stateStr); @@ -24016,8 +24071,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 5d4d17ed6..3e74c635b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1112,6 +1112,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, @@ -1210,6 +1221,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 Tue, Nov 21, 2017 at 05:42:20PM +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/schemas/domaincommon.rng | 15 +++++++++ src/conf/domain_conf.c | 72 ++++++++++++++++++++++++++++++++++++++++++- src/conf/domain_conf.h | 12 ++++++++ 3 files changed, 98 insertions(+), 1 deletion(-)
This patch doesn't include documentation for the new element, it's in the followup patch 22/21 which is not ideal. I guess that we will need v3 :). It's common to add the documentation together with the patch that introduces new change to the domain XML so I would suggest to split the patch 22/21 into the part that cleanups and improves the current documentation without mentioning new features and the <model> documentation should be part of this patch to make it close together. Otherwise this patch looks good.
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'>
This name is horrible and ugly, but I see that it follows naming for other defines. I know that nobody will send a patch to change it, but I wanted to point it out :). Pavel

Signed-off-by: Andrea Bolognani <abologna@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 12b2a0bf6..32cb62fb9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4135,6 +4135,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 6d847de3a..df4c67bb4 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml @@ -40,7 +40,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 30989658f..70c6a1a0f 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.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-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

On Tue, Nov 21, 2017 at 05:42:21PM +0100, Andrea Bolognani wrote:
Signed-off-by: Andrea Bolognani <abologna@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(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

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 | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d3ca6b2ec..0fb7d0e81 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 32cb62fb9..06ce382fa 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3538,6 +3538,43 @@ 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: + if (chr->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target model '%s' requires " + "target type 'isa'"), + virDomainChrSerialTargetModelTypeToString(chr->targetModel)); + return -1; + } + break; + + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL: + if (chr->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target model '%s' requires " + "target type 'usb'"), + virDomainChrSerialTargetModelTypeToString(chr->targetModel)); + return -1; + } + break; + + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL: + if (chr->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target model '%s' requires " + "target type 'pci'"), + virDomainChrSerialTargetModelTypeToString(chr->targetModel)); + 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 Tue, Nov 21, 2017 at 05:42:22PM +0100, Andrea Bolognani wrote:
Target model and target type must agree for the configuration
s/agree/correspond/
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 | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d3ca6b2ec..0fb7d0e81 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 32cb62fb9..06ce382fa 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3538,6 +3538,43 @@ 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: + if (chr->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target model '%s' requires " + "target type 'isa'"),
I'm not sure that using the 'isa' directly is a good choice. Currently the target type is 'isa-serial' and following patch renames it to 'isa'. Pavel

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> --- src/qemu/qemu_command.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 86521d498..d49183931 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10282,8 +10282,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")); @@ -10291,10 +10291,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")); @@ -10302,8 +10302,8 @@ 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 @@ -10314,7 +10314,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, } virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s", - virDomainChrSerialTargetTypeToString(serial->targetType), + virDomainChrSerialTargetModelTypeToString(serial->targetModel), serial->info.alias, serial->info.alias); } -- 2.14.3

On Tue, Nov 21, 2017 at 05:42:23PM +0100, Andrea Bolognani wrote:
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> --- src/qemu/qemu_command.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

Now that the target type is no longer formatted on the QEMU command line, we don't need the values to match the QEMU device names any longer, so we can shorten the names and reduce redundancy by dropping the -serial suffix: this also has the nice side-effect that target type and address type will now match. We still need to parse the old names, and format them when preparing a migratable XML, to preserve backwards compatibility. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/formatdomain.html.in | 10 +++--- docs/schemas/domaincommon.rng | 4 +++ src/conf/domain_conf.c | 39 +++++++++++++++++++--- .../qemuargv2xml-console-compat.xml | 2 +- tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml | 2 +- .../qemuargv2xmldata/qemuargv2xml-serial-file.xml | 2 +- .../qemuargv2xmldata/qemuargv2xml-serial-many.xml | 4 +-- tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml | 2 +- .../qemuargv2xml-serial-tcp-telnet.xml | 2 +- tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml | 2 +- tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml | 4 +-- .../qemuargv2xmldata/qemuargv2xml-serial-unix.xml | 2 +- tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml | 2 +- ...otplug-console-compat-2-live+console-virtio.xml | 6 ++-- .../qemuhotplug-console-compat-2-live.xml | 6 ++-- ...muxml2argv-serial-tcp-tlsx509-chardev-notls.xml | 4 +-- .../qemuxml2argvdata/qemuxml2argv-user-aliases.xml | 4 +-- .../qemuxml2xmlout-aarch64-pci-serial.xml | 2 +- .../qemuxml2xmlout-bios-nvram-os-interleave.xml | 2 +- .../qemuxml2xmlout-chardev-label.xml | 4 +-- .../qemuxml2xmlout-console-compat-auto.xml | 2 +- .../qemuxml2xmlout-console-compat.xml | 2 +- .../qemuxml2xmlout-console-compat2.xml | 2 +- .../qemuxml2xmlout-console-virtio-many.xml | 2 +- .../qemuxml2xmlout-interface-driver.xml | 2 +- .../qemuxml2xmlout-interface-server.xml | 4 +-- .../qemuxml2xmlout-net-bandwidth.xml | 2 +- .../qemuxml2xmlout-net-bandwidth2.xml | 2 +- .../qemuxml2xmlout-net-coalesce.xml | 2 +- .../qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml | 2 +- .../qemuxml2xmlout-panic-pseries.xml | 2 +- .../qemuxml2xmlout-pci-serial-dev-chardev.xml | 2 +- .../qemuxml2xmlout-pseries-cpu-compat-power9.xml | 2 +- .../qemuxml2xmlout-pseries-cpu-compat.xml | 2 +- .../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 +- .../qemuxml2xmlout-serial-spiceport.xml | 2 +- .../qemuxml2xmlout-serial-target-port-auto.xml | 6 ++-- .../qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml | 4 +-- .../qemuxml2xmlout-tap-vhost-incorrect.xml | 2 +- .../qemuxml2xmlout-tap-vhost.xml | 2 +- .../qemuxml2xmlout-vhost_queues.xml | 2 +- 45 files changed, 99 insertions(+), 64 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 4bc88cfc5..2edc61a01 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6530,13 +6530,13 @@ qemu-kvm -net nic,model=? /dev/null 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 + which has three choices for its value, one is <code>isa</code>, + then <code>usb</code> and last one is <code>pci</code>. + If <code>type</code> is missing, <code>isa</code> will be used by + default. For <code>usb</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 + Similarly, <code>pci</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. diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index fbba092d1..93beabc5e 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3582,6 +3582,10 @@ <define name='qemucdevSerialTgtType'> <attribute name='type'> <choice> + <value>isa</value> + <value>usb</value> + <value>pci</value> + <!-- Legacy values, for backwards compatibility --> <value>isa-serial</value> <value>usb-serial</value> <value>pci-serial</value> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 140f478b0..0d8c88db9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -449,9 +449,10 @@ 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") + "isa", + "usb", + "pci", +); VIR_ENUM_IMPL(virDomainChrChannelTarget, VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST, @@ -11511,6 +11512,17 @@ virDomainChrTargetTypeFromString(int devtype, if (!targetType) return virDomainChrDefaultTargetType(devtype); + /* Perform conversion between the legacy values for targetType, which + * are still accepted for backwards compatibility reasons, and the + * new values expected by virDomainChrSerialTargetTypeFromString() */ + if (STREQ(targetType, "isa-serial")) { + targetType = "isa"; + } else if (STREQ(targetType, "usb-serial")) { + targetType = "usb"; + } else if (STREQ(targetType, "pci-serial")) { + targetType = "pci"; + } + switch ((virDomainChrDeviceType) devtype) { case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: ret = virDomainChrChannelTargetTypeFromString(targetType); @@ -24066,8 +24078,27 @@ virDomainChrTargetDefFormat(virBufferPtr buf, if (def->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) { virBufferAsprintf(buf, - "type='%s' ", + "type='%s", targetType); + + /* When formatting a migratable XML, some target types need to + * be converted by appending "-serial" to their names, so that + * migration to older libvirt versions to work */ + if ((flags & VIR_DOMAIN_XML_MIGRATABLE)) { + switch ((virDomainChrSerialTargetType) def->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: + virBufferAddLit(buf, "-serial"); + break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: + /* No conversion necessary */ + break; + } + } + + virBufferAddLit(buf, "' "); } virBufferAsprintf(buf, diff --git a/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml b/tests/qemuargv2xmldata/qemuargv2xml-console-compat.xml index cba43ca45..1b0b82faa 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-dev.xml index e9998d554..038ac7b64 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-file.xml index 0e9dfe578..4735c2f6c 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml index 05374b38d..fd24305d3 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-many.xml @@ -28,13 +28,13 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <serial type='pty'> - <target type='isa-serial' port='0'> + <target type='isa' 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' port='1'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-pty.xml index cba43ca45..1b0b82faa 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp-telnet.xml index 1ac12440e..3d7cb35b2 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-tcp.xml index c10cee903..11b59f757 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml index fd56dda84..5dd2af063 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-serial-udp.xml @@ -30,13 +30,13 @@ <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' 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' port='1'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-unix.xml index 70b192f67..76cd70215 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml b/tests/qemuargv2xmldata/qemuargv2xml-serial-vc.xml index 630844ea0..8bda30472 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> 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 abe68a0a0..be42dbed6 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml @@ -68,13 +68,13 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> <alias name='serial0'/> </serial> <serial type='pty'> - <target type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> <alias name='serial1'/> @@ -82,7 +82,7 @@ <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' port='1'> <model name='isa-serial'/> </target> <alias name='serial2'/> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml index 45161e1e2..ba08844d0 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml @@ -68,13 +68,13 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> <alias name='serial0'/> </serial> <serial type='pty'> - <target type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> <alias name='serial1'/> @@ -82,7 +82,7 @@ <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' port='1'> <model name='isa-serial'/> </target> <alias name='serial2'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml index 89dc9e6e1..418d12c05 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-notls.xml @@ -29,14 +29,14 @@ <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' 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' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml index 52132a82d..b22e63915 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml @@ -110,12 +110,12 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> <serial type='pty'> - <target type='isa-serial' port='1'> + <target type='isa' port='1'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-pci-serial.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-pci-serial.xml index b02a5a7db..354f7acf2 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-pci-serial.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-pci-serial.xml @@ -34,7 +34,7 @@ </controller> <serial type='pty'> <log file='/tmp/log' append='on'/> - <target type='pci-serial' port='0'> + <target type='pci' port='0'> <model name='pci-serial'/> </target> <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-bios-nvram-os-interleave.xml index b6d7a6636..ffcf7641c 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml index 7d5bbdd0a..23c3aedb2 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-chardev-label.xml @@ -25,7 +25,7 @@ <source path='/tmp/serial.file'> <seclabel model='dac' relabel='no'/> </source> - <target type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> @@ -33,7 +33,7 @@ <source mode='connect' path='/tmp/serial.sock'> <seclabel model='dac' relabel='no'/> </source> - <target type='isa-serial' port='1'> + <target type='isa' port='1'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml index 267b253b1..2b07ec5e3 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat.xml index 6a52800a3..f5c7078a4 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat2.xml index 8c7bbb768..1edc14c05 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio-many.xml index 1a22b78b8..9c09d32d2 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-driver.xml index 5be590e75..c5acda87b 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml index 049b1472a..b0fd01501 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml @@ -104,12 +104,12 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> <serial type='pty'> - <target type='isa-serial' port='1'> + <target type='isa' port='1'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml index 4ec77d154..9a95ba2f8 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml index ee65c3a5b..b7a017a5b 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml index 56792b999..c7075bfff 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml index fc7b2e39a..8016846eb 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml index 496df0696..eeda93155 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> <address type='spapr-vio' reg='0x30000000'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-serial-dev-chardev.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-serial-dev-chardev.xml index 8f77ef043..dd0ef800e 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-serial-dev-chardev.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-serial-dev-chardev.xml @@ -28,7 +28,7 @@ <controller type='pci' index='0' model='pci-root'/> <serial type='dev'> <source path='/dev/ttyS2'/> - <target type='pci-serial' port='0'> + <target type='pci' port='0'> <model name='pci-serial'/> </target> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml index 9d4c5efe6..ced122581 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> <address type='spapr-vio' reg='0x30000000'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml index 6059859ab..f030f0011 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> <address type='spapr-vio' reg='0x30000000'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml index f3216523e..98d7a2707 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> <address type='spapr-vio' reg='0x30000000'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml index 496df0696..eeda93155 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> <address type='spapr-vio' reg='0x30000000'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml index 496df0696..eeda93155 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> <address type='spapr-vio' reg='0x30000000'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml index 2437fdec4..4b9b8e413 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport-nospice.xml index e1d5cb9d7..6fc74743b 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml index ff92435af..f7adcb7e1 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml index fded758ea..37abc239e 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml @@ -27,17 +27,17 @@ </controller> <controller type='pci' index='0' model='pci-root'/> <serial type='pty'> - <target type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> <serial type='null'> - <target type='isa-serial' port='1'> + <target type='isa' port='1'> <model name='isa-serial'/> </target> </serial> <serial type='stdio'> - <target type='isa-serial' port='2'> + <target type='isa' port='2'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml index 76d894820..07a2e9b31 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-tcp-tlsx509-chardev.xml @@ -29,14 +29,14 @@ <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' 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' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml index df4c67bb4..37ed82209 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml @@ -40,7 +40,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml index 70c6a1a0f..a972a9c81 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml @@ -47,7 +47,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> - <target type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-vhost_queues.xml index 49a7b550b..60558b08f 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 type='isa-serial' port='0'> + <target type='isa' port='0'> <model name='isa-serial'/> </target> </serial> -- 2.14.3

On Tue, Nov 21, 2017 at 05:42:24PM +0100, Andrea Bolognani wrote:
Now that the target type is no longer formatted on the QEMU command line, we don't need the values to match the QEMU device names any longer, so we can shorten the names and reduce redundancy by dropping the -serial suffix: this also has the nice side-effect that target type and address type will now match.
We still need to parse the old names, and format them when preparing a migratable XML, to preserve backwards compatibility.
This would be probably nice to rename, but I'm afraid that we cannot do that. Even though you've made the effort to translate the old name into new name if management application creates the XML using the old name, the issue here is that it will no longer understand what the new name means until the management application is updated. Therefore this change is not backward compatible. Pavel

On Thu, 2017-11-23 at 16:54 +0100, Pavel Hrdina wrote:
On Tue, Nov 21, 2017 at 05:42:24PM +0100, Andrea Bolognani wrote:
Now that the target type is no longer formatted on the QEMU command line, we don't need the values to match the QEMU device names any longer, so we can shorten the names and reduce redundancy by dropping the -serial suffix: this also has the nice side-effect that target type and address type will now match.
We still need to parse the old names, and format them when preparing a migratable XML, to preserve backwards compatibility.
This would be probably nice to rename, but I'm afraid that we cannot do that. Even though you've made the effort to translate the old name into new name if management application creates the XML using the old name, the issue here is that it will no longer understand what the new name means until the management application is updated. Therefore this change is not backward compatible.
Is that so? virt-manager at least doesn't seem to have a problem with the change. Any application that's been coded sensibly will deal with the new values in a graceful manner, eg. displaying "unknown model" or something along the line rather than failing. Moreover, any application that can't deal nicely with the change will certainly have a problem with the new values that we're introducing for aarch64, ppc64 and s390, so it will have to be fixed regardless. -- Andrea Bolognani / Red Hat / Virtualization

On Fri, Nov 24, 2017 at 11:10:42 +0100, Andrea Bolognani wrote:
On Thu, 2017-11-23 at 16:54 +0100, Pavel Hrdina wrote:
On Tue, Nov 21, 2017 at 05:42:24PM +0100, Andrea Bolognani wrote:
Now that the target type is no longer formatted on the QEMU command line, we don't need the values to match the QEMU device names any longer, so we can shorten the names and reduce redundancy by dropping the -serial suffix: this also has the nice side-effect that target type and address type will now match.
We still need to parse the old names, and format them when preparing a migratable XML, to preserve backwards compatibility.
This would be probably nice to rename, but I'm afraid that we cannot do that. Even though you've made the effort to translate the old name into new name if management application creates the XML using the old name, the issue here is that it will no longer understand what the new name means until the management application is updated. Therefore this change is not backward compatible.
Is that so? virt-manager at least doesn't seem to have a problem with the change.
Any application that's been coded sensibly will deal with the new values in a graceful manner, eg. displaying "unknown model" or something along the line rather than failing.
Showing an unknown device and failing is not very different in this case. The application adds a *-serial device and gets something else back. We would need to format the old names in the XML everytime and not in migratable XML only. So this would just add new shorter aliases apps could use when talking to new libvirt. But they wouldn't use them anyway because they would lose compatibility with older libvirt. In other words, NACK to this patch. Jirka

On Fri, 2017-11-24 at 12:12 +0100, Jiri Denemark wrote:
Any application that's been coded sensibly will deal with the new values in a graceful manner, eg. displaying "unknown model" or something along the line rather than failing.
Showing an unknown device and failing is not very different in this case. The application adds a *-serial device and gets something else back. We would need to format the old names in the XML everytime and not in migratable XML only. So this would just add new shorter aliases apps could use when talking to new libvirt. But they wouldn't use them anyway because they would lose compatibility with older libvirt.
Yeah, only parsing it and not formatting it would make no sense at all, so it's either both or neither.
In other words, NACK to this patch.
Well, that's a bummer :( Does it mean we need to drop patch 20/21 as well? With that patch in we would have a similar behavior, eg. a <console> would be created with target type "sclp" but it would be formatted back with target type "serial", and a new <serial> element would be created along with it. Or is it okay in that case because "serial" is a known value? -- Andrea Bolognani / Red Hat / Virtualization

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 diff -w'. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511421 Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/formatdomain.html.in | 11 ++-- docs/schemas/domaincommon.rng | 2 + src/conf/domain_conf.c | 4 ++ src/conf/domain_conf.h | 2 + src/qemu/qemu_command.c | 74 ++++++++++------------ src/qemu/qemu_domain.c | 74 ++++++++++++++++++---- 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, 301 insertions(+), 109 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 2edc61a01..92622d031 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6530,10 +6530,13 @@ qemu-kvm -net nic,model=? /dev/null 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</code>, - then <code>usb</code> and last one is <code>pci</code>. - If <code>type</code> is missing, <code>isa</code> will be used by - default. For <code>usb</code> an optional sub-element + which can be used to pick between <code>isa</code>, <code>usb</code>, + <code>pci</code> and, <span class="since">since 3.10.0</span>, + <code>spapr-vio</code>. + Some values are not compatible with all architecture and machine types; + if the value is missing altogether, libvirt will try to pick an + appropriate default. + For <code>usb</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</code> can be used to attach the device to diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 93beabc5e..b7a13660d 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3585,6 +3585,7 @@ <value>isa</value> <value>usb</value> <value>pci</value> + <value>spapr-vio</value> <!-- Legacy values, for backwards compatibility --> <value>isa-serial</value> <value>usb-serial</value> @@ -3600,6 +3601,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 0d8c88db9..d90acd31e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -452,6 +452,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTarget, "isa", "usb", "pci", + "spapr-vio", ); VIR_ENUM_IMPL(virDomainChrChannelTarget, @@ -479,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, @@ -4051,6 +4053,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. @@ -24091,6 +24094,7 @@ virDomainChrTargetDefFormat(virBufferPtr buf, case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: virBufferAddLit(buf, "-serial"); break; + 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: /* No conversion necessary */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3e74c635b..dc376de49 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1085,6 +1085,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; @@ -1117,6 +1118,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 d49183931..d1dd60d8f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10269,55 +10269,49 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, { virBuffer cmd = VIR_BUFFER_INITIALIZER; - 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); + 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")); + goto error; } - } 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")); - goto error; - } - break; + break; - case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: - break; + 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_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 - * 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")); + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_VTY)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("spapr-vty not supported in this QEMU binary")); 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_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")); + 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 06ce382fa..785a93207 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3491,8 +3491,7 @@ qemuDomainChrSourceDefValidate(const virDomainChrSourceDef *def) static int -qemuDomainChrTargetDefValidate(const virDomainDef *def, - const virDomainChrDef *chr) +qemuDomainChrTargetDefValidate(const virDomainChrDef *chr) { switch ((virDomainChrDeviceType) chr->deviceType) { case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: @@ -3500,11 +3499,6 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def, /* 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", @@ -3534,6 +3528,16 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def, } break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: + if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target type 'spapr-vio' requires address " + "of type 'spapr-vio'")); + return -1; + } + break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: break; @@ -3571,6 +3575,16 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def, } break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: + if (chr->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target model '%s' requires " + "target type 'spapr-vio'"), + virDomainChrSerialTargetModelTypeToString(chr->targetModel)); + return -1; + } + break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: break; @@ -3596,7 +3610,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 && @@ -3606,6 +3620,17 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, return -1; } + if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO || + dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY) && + !qemuDomainIsPSeries(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Serial devices with target type 'spapr-vio' and " + "target model 'spapr-vty' are only supported on " + "pSeries guests")); + return -1; + } + return 0; } @@ -4165,10 +4190,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; } } @@ -4185,6 +4207,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 */ @@ -5090,6 +5115,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..568686dbc --- /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 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..4415ef80d --- /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 target type can only be used for pSeries guests, + so this should be rejected --> + <serial type='pty'> + <target type='spapr-vio'/> + </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..b5fabcdf7 --- /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 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 781c649bf..4196e05a7 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1872,6 +1872,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 eeda93155..7fd8a541b 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' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio' 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 eeda93155..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' 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 ced122581..a59dc3bc5 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' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio' 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 f030f0011..1996a69d9 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' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio' 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 98d7a2707..fe8c67c96 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' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio' 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 eeda93155..7fd8a541b 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' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio' 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 eeda93155..7fd8a541b 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' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio' 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 eeda93155..017e0e8fb 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' port='0'> - <model name='isa-serial'/> + <target type='spapr-vio' 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 99d831c32..9110943b4 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -766,6 +766,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 Tue, Nov 21, 2017 at 05:42:25PM +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 diff -w'.
s/diff/show/ since the change would be most likely committed :).
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511421
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/formatdomain.html.in | 11 ++-- docs/schemas/domaincommon.rng | 2 + src/conf/domain_conf.c | 4 ++ src/conf/domain_conf.h | 2 + src/qemu/qemu_command.c | 74 ++++++++++------------ src/qemu/qemu_domain.c | 74 ++++++++++++++++++---- 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, 301 insertions(+), 109 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 2edc61a01..92622d031 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6530,10 +6530,13 @@ qemu-kvm -net nic,model=? /dev/null 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</code>, - then <code>usb</code> and last one is <code>pci</code>. - If <code>type</code> is missing, <code>isa</code> will be used by - default. For <code>usb</code> an optional sub-element + which can be used to pick between <code>isa</code>, <code>usb</code>, + <code>pci</code> and, <span class="since">since 3.10.0</span>, + <code>spapr-vio</code>. + Some values are not compatible with all architecture and machine types; + if the value is missing altogether, libvirt will try to pick an + appropriate default. + For <code>usb</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</code> can be used to attach the device to diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 93beabc5e..b7a13660d 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3585,6 +3585,7 @@ <value>isa</value> <value>usb</value> <value>pci</value> + <value>spapr-vio</value>
Since we cannot reduce isa-serial into isa, I guest having spapr-vio in addition to other ${BUS}-serial would be weird, so how about spapr-vio-serial or even only spapr-serial?
<!-- Legacy values, for backwards compatibility --> <value>isa-serial</value> <value>usb-serial</value> @@ -3600,6 +3601,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 0d8c88db9..d90acd31e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -452,6 +452,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTarget, "isa", "usb", "pci", + "spapr-vio", );
VIR_ENUM_IMPL(virDomainChrChannelTarget, @@ -479,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, @@ -4051,6 +4053,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. @@ -24091,6 +24094,7 @@ virDomainChrTargetDefFormat(virBufferPtr buf, case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: virBufferAddLit(buf, "-serial"); break; + 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: /* No conversion necessary */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3e74c635b..dc376de49 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1085,6 +1085,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; @@ -1117,6 +1118,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 d49183931..d1dd60d8f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10269,55 +10269,49 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, { virBuffer cmd = VIR_BUFFER_INITIALIZER;
- 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); + 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")); + goto error; } - } 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")); - goto error; - } - break; + break;
- case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL: - break; + 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_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 - * 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")); + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_VTY)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("spapr-vty not supported in this QEMU binary")); 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_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")); + 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 06ce382fa..785a93207 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3491,8 +3491,7 @@ qemuDomainChrSourceDefValidate(const virDomainChrSourceDef *def)
static int -qemuDomainChrTargetDefValidate(const virDomainDef *def, - const virDomainChrDef *chr) +qemuDomainChrTargetDefValidate(const virDomainChrDef *chr) { switch ((virDomainChrDeviceType) chr->deviceType) { case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: @@ -3500,11 +3499,6 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def, /* 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", @@ -3534,6 +3528,16 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def, } break;
+ case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO: + if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target type 'spapr-vio' requires address " + "of type 'spapr-vio'")); + return -1; + } + break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: break; @@ -3571,6 +3575,16 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def, } break;
+ case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: + if (chr->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target model '%s' requires " + "target type 'spapr-vio'"), + virDomainChrSerialTargetModelTypeToString(chr->targetModel)); + return -1; + } + break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: break; @@ -3596,7 +3610,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 && @@ -3606,6 +3620,17 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, return -1; }
+ if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO || + dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY) && + !qemuDomainIsPSeries(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Serial devices with target type 'spapr-vio' and " + "target model 'spapr-vty' are only supported on " + "pSeries guests"));
I know that it's unlikely to happen but what if there will be new model for spapr-vio? I would suggest to split this condition: if (serial && sparp_vio && !pseries) error("spapr-vio is supported only on pSeries machine") if (serial && sparp_vty && !pseries) error("spapr-vio is supported only on pSeries machine") Otherwise the patch looks good. Pavel

On Thu, 2017-11-23 at 17:35 +0100, Pavel Hrdina wrote:
@@ -3585,6 +3585,7 @@ <value>isa</value> <value>usb</value> <value>pci</value> + <value>spapr-vio</value>
Since we cannot reduce isa-serial into isa, I guest having spapr-vio in addition to other ${BUS}-serial would be weird, so how about spapr-vio-serial or even only spapr-serial?
See my other message about how I'm not quite yet convinced we can't drop the -serial suffix from existing values :) In any case the bus name is "spapr-vio" (confirmed with the ppc64 QEMU maintainer), so it will have to be either spapr-vio or spapr-vio-serial. -- Andrea Bolognani / Red Hat / Virtualization

On Fri, Nov 24, 2017 at 11:15:34AM +0100, Andrea Bolognani wrote:
On Thu, 2017-11-23 at 17:35 +0100, Pavel Hrdina wrote:
@@ -3585,6 +3585,7 @@ <value>isa</value> <value>usb</value> <value>pci</value> + <value>spapr-vio</value>
Since we cannot reduce isa-serial into isa, I guest having spapr-vio in addition to other ${BUS}-serial would be weird, so how about spapr-vio-serial or even only spapr-serial?
See my other message about how I'm not quite yet convinced we can't drop the -serial suffix from existing values :)
In any case the bus name is "spapr-vio" (confirmed with the ppc64 QEMU maintainer), so it will have to be either spapr-vio or spapr-vio-serial.
In that case spapr-vio-serial is the correct name. Pavel

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 d1dd60d8f..96ff082d3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9150,15 +9150,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 4196e05a7..bec7036b7 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1881,6 +1881,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..4d740e254 --- /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' 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..84ee2e1fe --- /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' 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 9110943b4..ba10cbe64 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -775,6 +775,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 | 2 +- docs/schemas/domaincommon.rng | 2 + src/conf/domain_conf.c | 4 ++ src/conf/domain_conf.h | 2 + src/qemu/qemu_command.c | 8 +++- src/qemu/qemu_domain.c | 37 ++++++++++++++++++ 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, 507 insertions(+), 4 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 92622d031..1efded6be 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6532,7 +6532,7 @@ qemu-kvm -net nic,model=? /dev/null <code>type</code> attribute <span class="since">since 1.0.2</span> which can be used to pick between <code>isa</code>, <code>usb</code>, <code>pci</code> and, <span class="since">since 3.10.0</span>, - <code>spapr-vio</code>. + <code>spapr-vio</code> and <code>system</code>. Some values are not compatible with all architecture and machine types; if the value is missing altogether, libvirt will try to pick an appropriate default. diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index b7a13660d..949ad38ac 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3586,6 +3586,7 @@ <value>usb</value> <value>pci</value> <value>spapr-vio</value> + <value>system</value> <!-- Legacy values, for backwards compatibility --> <value>isa-serial</value> <value>usb-serial</value> @@ -3602,6 +3603,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 d90acd31e..7b35fbd3d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -453,6 +453,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTarget, "usb", "pci", "spapr-vio", + "system", ); 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, @@ -4054,6 +4056,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. @@ -24095,6 +24098,7 @@ virDomainChrTargetDefFormat(virBufferPtr buf, virBufferAddLit(buf, "-serial"); break; 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: /* No conversion necessary */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index dc376de49..59e292c9c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1086,6 +1086,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; @@ -1119,6 +1120,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 96ff082d3..e6961d7ec 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9151,10 +9151,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 @@ -10288,6 +10291,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, } 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 785a93207..2b7a7dfc9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3538,6 +3538,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; @@ -3585,6 +3595,16 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr) } break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: + if (chr->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target model '%s' requires " + "target type 'system'"), + virDomainChrSerialTargetModelTypeToString(chr->targetModel)); + return -1; + } + break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: break; @@ -3631,6 +3651,17 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, return -1; } + if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM || + dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011) && + !qemuDomainIsVirt(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Serial devices with target type 'system' and " + "target model 'pl011' are only supported on " + "mach-virt guests")); + return -1; + } + return 0; } @@ -4191,6 +4222,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; } } @@ -4210,6 +4243,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 */ @@ -5126,6 +5162,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..0b9acc45a --- /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'> + <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 bec7036b7..258ca72d4 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1895,6 +1895,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..112a72e56 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' 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..7b9bef7a0 --- /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' 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..e73e3b105 --- /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' 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..a33c39cca --- /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' port='0'> + <model name='usb-serial'/> + </target> + </serial> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index ba10cbe64..f2b540f63 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -788,6 +788,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 Tue, Nov 21, 2017 at 05:42:27PM +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
I'm not sure that 'system' is a good name for serial type for mach-virt, it kind of feels like too generic name. Can we use the "apb-serial" for mach-virt? I understand that the "apb" name might not be well known but at least people that work closely with ARM machines have a chance to understand it better than "system" name. Either way, we should document it better than just listing it as a valid value for type, at least mention that it's valid for ARM/mach-virt machine and that it's a system bus or something like that. The standalone "system" doesn't make it clear what it actually is. Otherwise the patch looks good. Pavel

On Thu, 2017-11-23 at 17:43 +0100, Pavel Hrdina wrote:
On Tue, Nov 21, 2017 at 05:42:27PM +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
I'm not sure that 'system' is a good name for serial type for mach-virt, it kind of feels like too generic name. Can we use the "apb-serial" for mach-virt? I understand that the "apb" name might not be well known but at least people that work closely with ARM machines have a chance to understand it better than "system" name.
I was discussing the naming issue with a QEMU developer focusing on aarch64 and he admitted never hearing about "APB" at all ;) Apparently that's a really low-level implementation detail, which is several layer down from a serial device. I know "system" is extremely generic and I don't like it either because of that, but it's what the bus is commonly called among people working on mach-virt, so it's probably the only reasonable option :(
Either way, we should document it better than just listing it as a valid value for type, at least mention that it's valid for ARM/mach-virt machine and that it's a system bus or something like that. The standalone "system" doesn't make it clear what it actually is.
Do you mean in the code (in which case, where exactly?) or in the documentation? Usually we just list the available values without much of an explanation, and I kinda like that because it means we don't need to duplicate in writing the kind of checks that we have already implemented in code, but in this case the options should change infrequently enough and be specific enough that mentioning at least some of the constraints in the documentation as well. -- Andrea Bolognani / Red Hat / Virtualization

On Fri, Nov 24, 2017 at 11:26:32AM +0100, Andrea Bolognani wrote:
On Thu, 2017-11-23 at 17:43 +0100, Pavel Hrdina wrote:
On Tue, Nov 21, 2017 at 05:42:27PM +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
I'm not sure that 'system' is a good name for serial type for mach-virt, it kind of feels like too generic name. Can we use the "apb-serial" for mach-virt? I understand that the "apb" name might not be well known but at least people that work closely with ARM machines have a chance to understand it better than "system" name.
I was discussing the naming issue with a QEMU developer focusing on aarch64 and he admitted never hearing about "APB" at all ;)
Apparently that's a really low-level implementation detail, which is several layer down from a serial device.
I know "system" is extremely generic and I don't like it either because of that, but it's what the bus is commonly called among people working on mach-virt, so it's probably the only reasonable option :(
Either way, we should document it better than just listing it as a valid value for type, at least mention that it's valid for ARM/mach-virt machine and that it's a system bus or something like that. The standalone "system" doesn't make it clear what it actually is.
Do you mean in the code (in which case, where exactly?) or in the documentation? Usually we just list the available values without much of an explanation, and I kinda like that because it means we don't need to duplicate in writing the kind of checks that we have already implemented in code, but in this case the options should change infrequently enough and be specific enough that mentioning at least some of the constraints in the documentation as well.
In documentation, the "system" name is meaningless without mentioning that it is a system bus for mach-virt. It might be clear to mach-virt people but for majority users it will be confusing. The implementation is useless to users as well :). Pavel

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> --- docs/formatdomain.html.in | 2 +- docs/schemas/domaincommon.rng | 3 ++ src/conf/domain_conf.c | 5 ++++ src/conf/domain_conf.h | 3 ++ src/qemu/qemu_command.c | 16 ++++++++++ src/qemu/qemu_domain.c | 30 +++++++++++++++++++ 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, 295 insertions(+), 1 deletion(-) 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 1efded6be..fd85b7633 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6532,7 +6532,7 @@ qemu-kvm -net nic,model=? /dev/null <code>type</code> attribute <span class="since">since 1.0.2</span> which can be used to pick between <code>isa</code>, <code>usb</code>, <code>pci</code> and, <span class="since">since 3.10.0</span>, - <code>spapr-vio</code> and <code>system</code>. + <code>spapr-vio</code>, <code>system</code> and <code>sclp</code>. Some values are not compatible with all architecture and machine types; if the value is missing altogether, libvirt will try to pick an appropriate default. diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 949ad38ac..fe90c78a8 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3587,6 +3587,7 @@ <value>pci</value> <value>spapr-vio</value> <value>system</value> + <value>sclp</value> <!-- Legacy values, for backwards compatibility --> <value>isa-serial</value> <value>usb-serial</value> @@ -3604,6 +3605,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 7b35fbd3d..1dcd0e91a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -454,6 +454,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTarget, "pci", "spapr-vio", "system", + "sclp", ); 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, @@ -4057,6 +4060,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. @@ -24099,6 +24103,7 @@ virDomainChrTargetDefFormat(virBufferPtr buf, break; 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: /* No conversion necessary */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 59e292c9c..b06f40ab8 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1087,6 +1087,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; @@ -1121,6 +1122,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 e6961d7ec..79bae06d8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10291,6 +10291,22 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, } break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCLPCONSOLE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("sclpconsole not supported in this QEMU binary")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCLPLMCONSOLE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("sclplmconsole not supported in this QEMU binary")); + return -1; + } + 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/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2b7a7dfc9..21eb371e7 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3539,6 +3539,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 " @@ -3605,6 +3606,17 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr) } break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE: + if (chr->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target model '%s' requires " + "target type 'sclp'"), + virDomainChrSerialTargetModelTypeToString(chr->targetModel)); + return -1; + } + break; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: break; @@ -3662,6 +3674,18 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, return -1; } + if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + (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) && + !ARCH_IS_S390(def->os.arch)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Serial devices with target type 'sclp' and " + "target model 'sclpconsole' or 'sclplmconsole' " + "are only supported on s390 and s390x guests")); + return -1; + } + return 0; } @@ -4224,6 +4248,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; } } @@ -4246,6 +4272,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 */ @@ -5169,6 +5198,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..d3bcef95a --- /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'> + <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 258ca72d4..ed1c437b8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2046,6 +2046,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..9c7eefd13 --- /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' port='0'> + <model name='sclpconsole'/> + </target> + </serial> + <serial type='pty'> + <target type='sclp' 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..f8f5dec4a --- /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' 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..98395c2d2 --- /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' 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 f2b540f63..40b7467a9 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1155,6 +1155,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

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 | 230 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 172 insertions(+), 58 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index fd85b7633..2abbadd53 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6518,80 +6518,81 @@ 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' port='0'> + <model name='usb-serial'/> + </target> + <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 can be used to pick between <code>isa</code>, <code>usb</code>, - <code>pci</code> and, <span class="since">since 3.10.0</span>, - <code>spapr-vio</code>, <code>system</code> and <code>sclp</code>. - Some values are not compatible with all architecture and machine types; - if the value is missing altogether, libvirt will try to pick an - appropriate default. - For <code>usb</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</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 which indicates what bus the + serial device is connected to: + <span class="since">since 3.10.0</span>, valid values are + <code>isa</code>, <code>usb</code>, <code>pci</code>, + <code>spapr-vio</code>, <code>system</code> and <code>sclp</code>; for + backwards compatibility, <code>isa-serial</code>, + <code>usb-serial</code> and <code>pci-serial</code> (available + <span class="since">since 1.0.2</span>) are accepted as well. </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: + <span class="since">Since 3.10.0</span>, the <code>target</code> + element can have an optional <code>model</code> subelement, whose + <code>name</code> attribute can be used to choose the concrete, + hypervisor-specific device name: valid values are + <code>isa-serial</code>, <code>usb-serial</code>, + <code>pci-serial</code>, <code>spapr-vty</code>, <code>pl011</code>, + <code>sclpconsole</code> and <code>sclplmconsole</code>. </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> + Some of the values listed above are not compatible with all + architecture and machine types, and if the value is missing altogether, + libvirt will try to pick an appropriate default. In general, it's a + good idea to specify neither the target type nor the target model, + leave the task of choosing values up to libvirt, and don't change the + values afterward. + </p> <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'/> @@ -6600,21 +6601,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>, + <code>virtio</code>, <code>xen</code>, <code>lxc</code>, + <code>uml</code> and <code>openvz</code>. The <code>sclp</code> and + <code>sclplm</code> values 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> + 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 Tue, Nov 21, 2017 at 05:42:28PM +0100, Andrea Bolognani wrote:
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> --- docs/formatdomain.html.in | 2 +- docs/schemas/domaincommon.rng | 3 ++ src/conf/domain_conf.c | 5 ++++ src/conf/domain_conf.h | 3 ++ src/qemu/qemu_command.c | 16 ++++++++++ src/qemu/qemu_domain.c | 30 +++++++++++++++++++ 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, 295 insertions(+), 1 deletion(-) 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
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

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 1dcd0e91a..c4497ab0f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3980,7 +3980,8 @@ virDomainDefPostParseMemory(virDomainDefPtr def, static int -virDomainDefAddConsoleCompat(virDomainDefPtr def) +virDomainDefAddConsoleCompat(virDomainDefPtr def, + unsigned int parseFlags ATTRIBUTE_UNUSED) { size_t i; @@ -4941,7 +4942,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) { @@ -22016,9 +22017,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 b06f40ab8..0c2daa81a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2949,7 +2949,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> --- 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 c4497ab0f..027e91bb6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3979,9 +3979,39 @@ virDomainDefPostParseMemory(virDomainDefPtr def, } +static void +virDomainChrConsoleTargetTypeToSerial(virDomainChrConsoleTargetType type, + int *retType, int *retModel) +{ + switch (type) { + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP: + *retType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP; + *retModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE; + break; + + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM: + *retType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP; + *retModel = 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: + *retType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE; + *retModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE; + break; + } +} + + static int virDomainDefAddConsoleCompat(virDomainDefPtr def, - unsigned int parseFlags ATTRIBUTE_UNUSED) + unsigned int parseFlags) { size_t i; @@ -3998,6 +4028,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, @@ -4014,7 +4048,9 @@ 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 && + (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 @@ -4027,6 +4063,8 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def, /* create the serial port definition from the console definition */ if (def->nserials == 0) { + virDomainChrConsoleTargetType type = def->consoles[0]->targetType; + if (VIR_APPEND_ELEMENT(def->serials, def->nserials, def->consoles[0]) < 0) @@ -4034,7 +4072,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(type, + &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 ed1c437b8..a002bdf2f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2062,6 +2062,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

On Tue, 2017-11-21 at 17:42 +0100, Andrea Bolognani wrote:
+static void +virDomainChrConsoleTargetTypeToSerial(virDomainChrConsoleTargetType type, + int *retType, int *retModel)
The last two arguments should be each on a separate line. I'd also prefer the names 'targetType' and 'targetModel'.
@@ -4014,7 +4048,9 @@ 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 && + (parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE)))) {
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM should be included in the check above, or <console/>s with <target type='sclplm'/> will not be converted into <serial/>s.
@@ -4027,6 +4063,8 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def,
/* create the serial port definition from the console definition */ if (def->nserials == 0) { + virDomainChrConsoleTargetType type = def->consoles[0]->targetType; + if (VIR_APPEND_ELEMENT(def->serials, def->nserials, def->consoles[0]) < 0) @@ -4034,7 +4072,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(type, + &def->serials[0]->targetType, + &def->serials[0]->targetModel);
Drop 'type' and just use 'def->consoles[0]->targetType' here. Everything else looks good, so my R-b stands. I can fix all of the above before pushing (assuming a respin won't be necessary). -- Andrea Bolognani / Red Hat / Virtualization

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 21eb371e7..49a613675 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4224,13 +4224,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..677dd11c1 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' 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 f8f5dec4a..98395c2d2 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' 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

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 | 230 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 172 insertions(+), 58 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index fd85b7633..2abbadd53 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6518,80 +6518,81 @@ 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' port='0'> + <model name='usb-serial'/> + </target> + <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 can be used to pick between <code>isa</code>, <code>usb</code>, - <code>pci</code> and, <span class="since">since 3.10.0</span>, - <code>spapr-vio</code>, <code>system</code> and <code>sclp</code>. - Some values are not compatible with all architecture and machine types; - if the value is missing altogether, libvirt will try to pick an - appropriate default. - For <code>usb</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</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 which indicates what bus the + serial device is connected to: + <span class="since">since 3.10.0</span>, valid values are + <code>isa</code>, <code>usb</code>, <code>pci</code>, + <code>spapr-vio</code>, <code>system</code> and <code>sclp</code>; for + backwards compatibility, <code>isa-serial</code>, + <code>usb-serial</code> and <code>pci-serial</code> (available + <span class="since">since 1.0.2</span>) are accepted as well. </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: + <span class="since">Since 3.10.0</span>, the <code>target</code> + element can have an optional <code>model</code> subelement, whose + <code>name</code> attribute can be used to choose the concrete, + hypervisor-specific device name: valid values are + <code>isa-serial</code>, <code>usb-serial</code>, + <code>pci-serial</code>, <code>spapr-vty</code>, <code>pl011</code>, + <code>sclpconsole</code> and <code>sclplmconsole</code>. </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> + Some of the values listed above are not compatible with all + architecture and machine types, and if the value is missing altogether, + libvirt will try to pick an appropriate default. In general, it's a + good idea to specify neither the target type nor the target model, + leave the task of choosing values up to libvirt, and don't change the + values afterward. + </p> <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'/> @@ -6600,21 +6601,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>, + <code>virtio</code>, <code>xen</code>, <code>lxc</code>, + <code>uml</code> and <code>openvz</code>. The <code>sclp</code> and + <code>sclplm</code> values 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> + 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 Wed, Nov 22, 2017 at 04:24:07PM +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 | 230 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 172 insertions(+), 58 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index fd85b7633..2abbadd53 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6518,80 +6518,81 @@ 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' port='0'> + <model name='usb-serial'/> + </target> + <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 can be used to pick between <code>isa</code>, <code>usb</code>, - <code>pci</code> and, <span class="since">since 3.10.0</span>, - <code>spapr-vio</code>, <code>system</code> and <code>sclp</code>. - Some values are not compatible with all architecture and machine types; - if the value is missing altogether, libvirt will try to pick an - appropriate default. - For <code>usb</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</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 which indicates what bus the + serial device is connected to: + <span class="since">since 3.10.0</span>, valid values are + <code>isa</code>, <code>usb</code>, <code>pci</code>, + <code>spapr-vio</code>, <code>system</code> and <code>sclp</code>; for + backwards compatibility, <code>isa-serial</code>, + <code>usb-serial</code> and <code>pci-serial</code> (available + <span class="since">since 1.0.2</span>) are accepted as well.
This part will need some tuning since we cannot rename isa-serial to isa.
</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: + <span class="since">Since 3.10.0</span>, the <code>target</code> + element can have an optional <code>model</code> subelement, whose + <code>name</code> attribute can be used to choose the concrete, + hypervisor-specific device name: valid values are + <code>isa-serial</code>, <code>usb-serial</code>, + <code>pci-serial</code>, <code>spapr-vty</code>, <code>pl011</code>, + <code>sclpconsole</code> and <code>sclplmconsole</code>. </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> + Some of the values listed above are not compatible with all + architecture and machine types, and if the value is missing altogether,
s/architecture/architectures/
+ libvirt will try to pick an appropriate default. In general, it's a + good idea to specify neither the target type nor the target model, + leave the task of choosing values up to libvirt, and don't change the + values afterward.
I would probably rephrase that to something like this: Some of the values listed above are not compatible with all architectures and machine types. If neither the target type nor the target model is specified, libvirt will choose default values, which are in general the best choice. The original wording kind of feels strictly limiting and like you shouldn't try to configure it at all.
+ </p>
<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'/> @@ -6600,21 +6601,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>, + <code>virtio</code>, <code>xen</code>, <code>lxc</code>, + <code>uml</code> and <code>openvz</code>. The <code>sclp</code> and + <code>sclplm</code> values 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> + 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>
Nice job, this new documentation helps a lot with all the mess that we have for serial and console devices. Looks more than good to me :) but as I've mentioned in previous patch, the rewrite should be done as a separate patch without the new elements. Pavel
+ +<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
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Thu, 2017-11-23 at 18:05 +0100, Pavel Hrdina wrote:
On Wed, Nov 22, 2017 at 04:24:07PM +0100, Andrea Bolognani wrote:
+ <p> + Some of the values listed above are not compatible with all + architecture and machine types, and if the value is missing altogether,
s/architecture/architectures/
+ libvirt will try to pick an appropriate default. In general, it's a + good idea to specify neither the target type nor the target model, + leave the task of choosing values up to libvirt, and don't change the + values afterward.
I would probably rephrase that to something like this:
Some of the values listed above are not compatible with all architectures and machine types. If neither the target type nor the target model is specified, libvirt will choose default values, which are in general the best choice.
The original wording kind of feels strictly limiting and like you shouldn't try to configure it at all.
Well, you kinda shouldn't :) When I was writing that paragraph, I had this piece of existing documentation in mind: PCI controllers also have an optional subelement <model> with an attribute name. [...] In almost all cases, you should not manually add a <model> subelement to a controller, nor should you modify one that is automatically generated by libvirt. I believe the same applies here. There's exactly one situation where you'll want to change the model for a PCI controller (using ioh3420 even though pcie-root-port is available) and exactly one situation where you'll want to change the model for a serial device (using sclplmconsole instead of sclpconsole on s390x). In both cases, there's an excape route for the very few people who actually need to make that sort of choice, but everyone else is better off not touching the defaults at all, and the wording IMHO clearly expresses that ("in almost all cases", "in general"). -- Andrea Bolognani / Red Hat / Virtualization

On Fri, Nov 24, 2017 at 11:35:01AM +0100, Andrea Bolognani wrote:
On Thu, 2017-11-23 at 18:05 +0100, Pavel Hrdina wrote:
On Wed, Nov 22, 2017 at 04:24:07PM +0100, Andrea Bolognani wrote:
+ <p> + Some of the values listed above are not compatible with all + architecture and machine types, and if the value is missing altogether,
s/architecture/architectures/
+ libvirt will try to pick an appropriate default. In general, it's a + good idea to specify neither the target type nor the target model, + leave the task of choosing values up to libvirt, and don't change the + values afterward.
I would probably rephrase that to something like this:
Some of the values listed above are not compatible with all architectures and machine types. If neither the target type nor the target model is specified, libvirt will choose default values, which are in general the best choice.
The original wording kind of feels strictly limiting and like you shouldn't try to configure it at all.
Well, you kinda shouldn't :)
When I was writing that paragraph, I had this piece of existing documentation in mind:
PCI controllers also have an optional subelement <model> with an attribute name. [...] In almost all cases, you should not manually add a <model> subelement to a controller, nor should you modify one that is automatically generated by libvirt.
I believe the same applies here. There's exactly one situation where you'll want to change the model for a PCI controller (using ioh3420 even though pcie-root-port is available) and exactly one situation where you'll want to change the model for a serial device (using sclplmconsole instead of sclpconsole on s390x).
It's similar but not the same. In case of PCI I agree that it's best for users not to mangle with the models unless you know what you are doing, but for serial device on s390x we have two valid models where you can pick whichever you like or prefer, the same like we have sound models or video models. That's why I would prefer different wording which is not that restrictive. Pavel

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 5eb0b79d6..abb9b5d0d 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -135,6 +135,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 (4)
-
Andrea Bolognani
-
Jiri Denemark
-
Marc Hartmayer
-
Pavel Hrdina