[libvirt] [PATCHv3 0/2] S390: Adding support for SCLP Console

The S390 architecture comes with a native console type (SCLP console) which is now also supported by current QEMU. This series is enabling libvirt to configure S390 domains with SCLP consoles. The domain XML has to be extended for the new console target types 'sclp' and 'sclplm' (line mode = dumb). As usual the QEMU driver must do capability probing in order to find out whether SCLP is supported and format the QEMU command line for the new console type. V2/V3 Changes: Rebased to current master, resolving conflicts. J.B. Joret (2): S390: Add SCLP console front end support S390: Enable SCLP Console in QEMU driver docs/formatdomain.html.in | 19 ++++++- docs/schemas/domaincommon.rng | 2 + src/conf/domain_conf.c | 4 +- src/conf/domain_conf.h | 2 + src/qemu/qemu_capabilities.c | 3 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 59 ++++++++++++++++++++++ .../qemuxml2argv-console-sclp.args | 8 +++ .../qemuxml2argvdata/qemuxml2argv-console-sclp.xml | 24 +++++++++ tests/qemuxml2argvtest.c | 3 ++ 10 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-sclp.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-sclp.xml -- 1.7.12.4

From: "J.B. Joret" <jb@linux.vnet.ibm.com> The SCLP console is the native console type for s390 and is preferred over the virtio console as it doesn't require special drivers and is more efficient. Recent versions of QEMU come with SCLP support which is hereby enabled. The new target types 'sclp' and 'sclplm' can be used to specify a SCLP console. Adding documentation, domain schema and XML processing support. Signed-off-by: J.B. Joret <jb@linux.vnet.ibm.com> Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> --- docs/formatdomain.html.in | 19 ++++++++++++++++++- docs/schemas/domaincommon.rng | 2 ++ src/conf/domain_conf.c | 4 +++- src/conf/domain_conf.h | 2 ++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index c81af8a..082018f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3624,7 +3624,7 @@ qemu-kvm -net nic,model=? /dev/null </p> <ul> - <li>If no <code>targetType</code> attribue is set, then the default + <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 @@ -3638,6 +3638,12 @@ qemu-kvm -net nic,model=? /dev/null <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.1</span> + </li> </ul> <p> @@ -3663,6 +3669,17 @@ qemu-kvm -net nic,model=? /dev/null </devices> ...</pre> +<pre> + ... + <devices> + <!-- KVM s390 sclp console --> + <console type='pty'> + <source path='/dev/pts/1'/> + <target type='sclp' port='0'/> + </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 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 14344e2..f483c4e 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2441,6 +2441,8 @@ <value>virtio</value> <value>lxc</value> <value>openvz</value> + <value>sclp</value> + <value>sclplm</value> </choice> </attribute> </define> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6aa5f79..e0eded2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -350,7 +350,9 @@ VIR_ENUM_IMPL(virDomainChrConsoleTarget, "uml", "virtio", "lxc", - "openvz") + "openvz", + "sclp", + "sclplm") VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST, "parallel", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 7ad5377..a31793b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -905,6 +905,8 @@ enum virDomainChrConsoleTargetType { VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ, + VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP, + VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST }; -- 1.7.12.4

From: "J.B. Joret" <jb@linux.vnet.ibm.com> This is the QEMU backend code for the SCLP console support. It includes SCLP capability detection, QEMU command line generation and a test case. Signed-off-by: J.B. Joret <jb@linux.vnet.ibm.com> Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> --- src/qemu/qemu_capabilities.c | 3 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 59 ++++++++++++++++++++++ .../qemuxml2argv-console-sclp.args | 8 +++ .../qemuxml2argvdata/qemuxml2argv-console-sclp.xml | 24 +++++++++ tests/qemuxml2argvtest.c | 3 ++ 6 files changed, 98 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-sclp.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-sclp.xml diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 01a1b98..7d32314 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -194,6 +194,8 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST, "usb-redir.bootindex", "usb-host.bootindex", "blockdev-snapshot-sync", + "s390-sclp", + ); struct _qemuCaps { @@ -1318,6 +1320,7 @@ struct qemuCapsStringFlags qemuCapsObjectTypes[] = { { "usb-hub", QEMU_CAPS_USB_HUB }, { "ich9-ahci", QEMU_CAPS_ICH9_AHCI }, { "virtio-blk-s390", QEMU_CAPS_VIRTIO_S390 }, + { "sclpconsole", QEMU_CAPS_SCLP_S390 }, { "lsi53c895a", QEMU_CAPS_SCSI_LSI }, { "virtio-scsi-pci", QEMU_CAPS_VIRTIO_SCSI_PCI }, { "spicevmc", QEMU_CAPS_DEVICE_SPICEVMC }, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 3da8672..acbd16a 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -156,6 +156,7 @@ enum qemuCapsFlags { QEMU_CAPS_USB_REDIR_BOOTINDEX = 116, /* usb-redir.bootindex */ QEMU_CAPS_USB_HOST_BOOTINDEX = 117, /* usb-host.bootindex */ QEMU_CAPS_DISK_SNAPSHOT = 118, /* blockdev-snapshot-sync command */ + QEMU_CAPS_SCLP_S390 = 119, /* -device sclp* */ QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9009bd2..6e2ece0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4096,6 +4096,37 @@ error: return NULL; } +static char *qemuBuildSclpDevStr(virDomainChrDefPtr dev) +{ + virBuffer buf = VIR_BUFFER_INITIALIZER; + if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE) { + switch (dev->targetType) { + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP: + virBufferAddLit(&buf, "sclpconsole"); + break; + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM: + virBufferAddLit(&buf, "sclplmconsole"); + break; + } + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cannot use slcp with devices other than console")); + goto error; + } + virBufferAsprintf(&buf, ",chardev=char%s,id=%s", + dev->info.alias, dev->info.alias); + if (virBufferError(&buf)) { + virReportOOMError(); + goto error; + } + + return virBufferContentAndReset(&buf); + +error: + virBufferFreeAndReset(&buf); + return NULL; +} + static char *qemuBuildSmbiosBiosStr(virSysinfoDefPtr def) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -6348,6 +6379,34 @@ qemuBuildCommandLine(virConnectPtr conn, char *devstr; switch (console->targetType) { + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP: + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM: + if (!qemuCapsGet(caps, QEMU_CAPS_DEVICE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("sclp console requires QEMU to support -device")); + goto error; + } + if (!qemuCapsGet(caps, QEMU_CAPS_SCLP_S390)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("sclp console requires QEMU to support s390-sclp")); + goto error; + } + + virCommandAddArg(cmd, "-chardev"); + if (!(devstr = qemuBuildChrChardevStr(&console->source, + console->info.alias, + caps))) + goto error; + virCommandAddArg(cmd, devstr); + VIR_FREE(devstr); + + virCommandAddArg(cmd, "-device"); + if (!(devstr = qemuBuildSclpDevStr(console))) + goto error; + virCommandAddArg(cmd, devstr); + VIR_FREE(devstr); + break; + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO: if (!qemuCapsGet(caps, QEMU_CAPS_DEVICE)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-sclp.args b/tests/qemuxml2argvdata/qemuxml2argv-console-sclp.args new file mode 100644 index 0000000..7dc1c49 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-console-sclp.args @@ -0,0 +1,8 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ +s390-virtio -m 214 -smp 1 -nographic -nodefconfig -nodefaults -chardev \ +socket,id=charmonitor,path=/tmp/test-monitor,server,nowait -mon \ +chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c \ +-usb -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-virtio-disk0 -device \ +virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0 \ +-chardev pty,id=charconsole0 \ +-device sclpconsole,chardev=charconsole0,id=console0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-sclp.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-sclp.xml new file mode 100644 index 0000000..7d28b55 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-console-sclp.xml @@ -0,0 +1,24 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219100</memory> + <currentMemory>219100</currentMemory> + <os> + <type arch='s390x' machine='s390-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</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='virtio'/> + </disk> + <console type='pty'> + <target type='sclp'/> + </console> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index bb233ed..da75ed0 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -677,6 +677,9 @@ mymain(void) DO_TEST("console-virtio-s390", QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DRIVE, QEMU_CAPS_VIRTIO_S390); + DO_TEST("console-sclp", + QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_DRIVE, QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_SCLP_S390); DO_TEST("channel-spicevmc", QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC); -- 1.7.12.4
participants (1)
-
Viktor Mihajlovski