Andrea Bolognani <abologna(a)redhat.com> [2017-11-15, 12:50PM +0100]:
From: Pino Toscano <ptoscano(a)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(a)redhat.com>
---
src/conf/domain_conf.c | 39 ++++++++++++++++++++--
.../qemuxml2argv-s390-console2serial.args | 22 ++++++++++++
.../qemuxml2argv-s390-console2serial.xml | 19 +++++++++++
tests/qemuxml2argvtest.c | 6 ++++
4 files changed, 83 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 9a3cdc777..14b611602 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3966,9 +3966,35 @@ virDomainDefPostParseMemory(virDomainDefPtr def,
}
+static virDomainChrSerialTargetType
+virDomainChrConsoleTargetTypeToSerial(virDomainChrConsoleTargetType type)
+{
+ switch (type) {
+ case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP:
+ return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP;
+
+ case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM:
+ return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLPLM;
+
+ 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:
+ /* Return the default at the end, to please strict compilers. */
+ break;
+ }
+
+ return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE;
+}
+
+
static int
virDomainDefAddConsoleCompat(virDomainDefPtr def,
- unsigned int parseFlags ATTRIBUTE_UNUSED)
+ unsigned int parseFlags)
{
size_t i;
@@ -3985,6 +4011,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,
@@ -4001,7 +4031,10 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def,
}
if (def->nconsoles > 0 && def->os.type == VIR_DOMAIN_OSTYPE_HVM
&&
(def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL
||
- def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE))
{
+ def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE
||
+ ((def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP
||
+ def->consoles[0]->targetType ==
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM) &&
+ (parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE)))) {
This gets a bit hard to parse, maybe we can extract the conditional?
/* If there isn't a corresponding serial port:
* - create one and set, the console to be an alias for it
@@ -4021,7 +4054,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_NONE;
+ def->serials[0]->targetType =
virDomainChrConsoleTargetTypeToSerial(def->serials[0]->targetType);
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 a280a8a85..6cc7731a7 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2061,6 +2061,12 @@ mymain(void)
QEMU_CAPS_VIRTIO_CCW,
QEMU_CAPS_VIRTIO_S390,
QEMU_CAPS_SCLP_S390);
+ 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_SCLP_S390);
DO_TEST("ppc-dtb",
QEMU_CAPS_KVM,
--
2.13.6
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Rest looks fine and initial smoke testing was all good.
Reviewed-by: Bjoern Walk <bwalk(a)linux.vnet.ibm.com>
--
IBM Systems
Linux on z Systems & Virtualization Development
------------------------------------------------------------------------
IBM Deutschland
Schönaicher Str. 220
71032 Böblingen
Phone: +49 7031 16 1819
E-Mail: bwalk(a)de.ibm.com
------------------------------------------------------------------------
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