[libvirt] [PATCH v2 18/21] conf: add VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP

Andrea Bolognani posted 21 patches 7 years, 5 months ago
There is a newer version of this series
[libvirt] [PATCH v2 18/21] conf: add VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP
Posted by Andrea Bolognani 7 years, 5 months ago
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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 18/21] conf: add VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP
Posted by Pavel Hrdina 7 years, 5 months ago
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>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 22/21] docs: Improve documentation for serial consoles
Posted by Andrea Bolognani 7 years, 5 months ago
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>
 ...
 &lt;devices&gt;
+  &lt;!-- Serial port --&gt;
   &lt;serial type='pty'&gt;
     &lt;source path='/dev/pts/3'/&gt;
     &lt;target port='0'/&gt;
   &lt;/serial&gt;
 &lt;/devices&gt;
+...</pre>
+
+<pre>
+...
+&lt;devices&gt;
+  &lt;!-- USB serial port --&gt;
+  &lt;serial type='pty'&gt;
+    &lt;target type='usb' port='0'&gt;
+      &lt;model name='usb-serial'/&gt;
+    &lt;/target&gt;
+    &lt;address type='usb' bus='0' port='1'/&gt;
+  &lt;/serial&gt;
+&lt;/devices&gt;
 ...</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>&lt;address/&gt;</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>&lt;address/&gt;</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>&lt;serial&gt;</code> element exists, the console
-        element will be copied to the serial element. If a <code>&lt;serial&gt;</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>
 ...
 &lt;devices&gt;
+  &lt;!-- Serial console --&gt;
   &lt;console type='pty'&gt;
-    &lt;source path='/dev/pts/4'/&gt;
-    &lt;target port='0'/&gt;
+    &lt;source path='/dev/pts/2'/&gt;
+    &lt;target type='serial' port='0'/&gt;
   &lt;/console&gt;
+&lt;/devices&gt;
+...</pre>
 
+<pre>
+...
   &lt;!-- KVM virtio console --&gt;
   &lt;console type='pty'&gt;
     &lt;source path='/dev/pts/5'/&gt;
@@ -6600,21 +6601,134 @@ qemu-kvm -net nic,model=? /dev/null
 &lt;/devices&gt;
 ...</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>
 ...
-&lt;devices&gt;
-  &lt;!-- KVM S390 sclp console --&gt;
+&lt;/devices&gt;
+  &lt;console type='pty'&gt;
+    &lt;target type='serial'/&gt;
+  &lt;/console&gt;
   &lt;console type='pty'&gt;
-    &lt;source path='/dev/pts/1'/&gt;
-    &lt;target type='sclp' port='0'/&gt;
+    &lt;target type='virtio'/&gt;
   &lt;/console&gt;
 &lt;/devices&gt;
 ...</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>
+...
+&lt;/devices&gt;
+  &lt;serial type='pty'/&gt;
+&lt;/devices&gt;
+...</pre>
+
+<pre>
+...
+&lt;/devices&gt;
+  &lt;console type='pty'/&gt;
+&lt;/devices&gt;
+...</pre>
+
+<pre>
+...
+&lt;/devices&gt;
+  &lt;serial type='pty'/&gt;
+  &lt;console type='pty'/&gt;
+&lt;/devices&gt;
+...</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