From: Pino Toscano <ptoscano@xxxxxxxxxx> 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@xxxxxxxxxx> Reviewed-by: Andrea Bolognani <abologna@xxxxxxxxxx> Reviewed-by: Bjoern Walk <bwalk@xxxxxxxxxxxxxxxxxx> --- 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 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list