[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v3 23/28] conf: convert sclp/sclplm <console> as <serial>



From: Pino Toscano <ptoscano redhat com>

In case we are allowed to break the ABI of a s390/s390x guest, then
convert the first sclp/sclplm console from <console> to <serial>, just
like it is done on other architectures.

Signed-off-by: Pino Toscano <ptoscano redhat com>
Reviewed-by: Andrea Bolognani <abologna redhat com>
Reviewed-by: Bjoern Walk <bwalk linux vnet ibm com>
---
This patch might need to be dropped. See

  https://www.redhat.com/archives/libvir-list/2017-November/msg00996.html

 src/conf/domain_conf.c                             | 46 ++++++++++++++++++++--
 .../qemuxml2argv-s390-console2serial.args          | 22 +++++++++++
 .../qemuxml2argv-s390-console2serial.xml           | 19 +++++++++
 tests/qemuxml2argvtest.c                           |  6 +++
 4 files changed, 90 insertions(+), 3 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-console2serial.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-console2serial.xml

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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]