[libvirt] [PATCHv3 0/5] Implement debugcon chardev

v2: https://www.redhat.com/archives/libvir-list/2019-February/msg00293.html v3: * dropped the pointless isa-prefix * use DO_TEST_CAPS_LATEST * trimmed the XML * compiles with gcc * only make irq optional * autofill iobase Ján Tomko (3): qemu: introduce qemuDomainChrSerialTargetModel qemu: make irq optional when formatting the ISA address qemu: autoadd iobase to debugcon chardev Nikolay Shirokovskiy (2): conf: add debugcon chardev guest interface qemu: implement debugcon chardev docs/formatdomain.html.in | 3 +- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 5 ++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 25 +++++++++++++--- src/qemu/qemu_domain.c | 12 ++++++++ .../isa-serial-debugcon.x86_64-latest.args | 30 +++++++++++++++++++ .../qemuxml2argvdata/isa-serial-debugcon.xml | 21 +++++++++++++ tests/qemuxml2argvtest.c | 1 + .../isa-serial-debugcon.xml | 30 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 ++ 11 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/isa-serial-debugcon.xml create mode 100644 tests/qemuxml2xmloutdata/isa-serial-debugcon.xml -- 2.19.2

Allow adding serial device models that deviate from the perceived semantics of our model attributes blindly copying the hypervisor-specific device name strings. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_command.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 572d3bc20f..94de6b9061 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -185,6 +185,20 @@ VIR_ENUM_IMPL(qemuNumaPolicy, VIR_DOMAIN_NUMATUNE_MEM_LAST, "interleave", ); +VIR_ENUM_DECL(qemuDomainChrSerialTargetModel); +VIR_ENUM_IMPL(qemuDomainChrSerialTargetModel, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST, + "none", + "isa-serial", + "usb-serial", + "pci-serial", + "spapr-vty", + "", /* pl011 is not user-insantiable */ + "sclpconsole", + "sclplmconsole", + "", /* 16550a is not user-instantiable */ +); + /** * qemuBuildMasterKeyCommandLine: @@ -10812,7 +10826,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, } virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s", - virDomainChrSerialTargetModelTypeToString(serial->targetModel), + qemuDomainChrSerialTargetModelTypeToString(serial->targetModel), serial->info.alias, serial->info.alias); if (qemuBuildDeviceAddressStr(&cmd, def, &serial->info, qemuCaps) < 0) -- 2.19.2

On 14.02.2019 14:32, Ján Tomko wrote:
Allow adding serial device models that deviate from the perceived semantics of our model attributes blindly copying the hypervisor-specific device name strings.
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_command.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 572d3bc20f..94de6b9061 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -185,6 +185,20 @@ VIR_ENUM_IMPL(qemuNumaPolicy, VIR_DOMAIN_NUMATUNE_MEM_LAST, "interleave", );
+VIR_ENUM_DECL(qemuDomainChrSerialTargetModel); +VIR_ENUM_IMPL(qemuDomainChrSerialTargetModel, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST, + "none", + "isa-serial", + "usb-serial", + "pci-serial", + "spapr-vty", + "", /* pl011 is not user-insantiable */ + "sclpconsole", + "sclplmconsole", + "", /* 16550a is not user-instantiable */ +); +
/** * qemuBuildMasterKeyCommandLine: @@ -10812,7 +10826,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, }
virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s", - virDomainChrSerialTargetModelTypeToString(serial->targetModel), + qemuDomainChrSerialTargetModelTypeToString(serial->targetModel), serial->info.alias, serial->info.alias);
if (qemuBuildDeviceAddressStr(&cmd, def, &serial->info, qemuCaps) < 0)
Reviewed-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>

From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> This interface can be used for example by firmware to print debug messages. Here is domain xml example: <serial type='pty'> <target type='isa-serial' port='0'> <model name='debugcon'/> </target> <address type='isa' iobase='0x402'/> </serial> Add checks to make sure this new serial type won't be reported as back-compat console. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> --- docs/formatdomain.html.in | 3 +- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 5 ++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 3 ++ src/qemu/qemu_domain.c | 3 ++ .../qemuxml2argvdata/isa-serial-debugcon.xml | 22 ++++++++++++++ .../isa-serial-debugcon.xml | 30 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 ++ 9 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/isa-serial-debugcon.xml create mode 100644 tests/qemuxml2xmloutdata/isa-serial-debugcon.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 2ae5006849..a6d5346d46 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -7089,7 +7089,8 @@ qemu-kvm -net nic,model=? /dev/null <span class="since">Since 3.10.0</span>, the <code>target</code> element can have an optional <code>model</code> subelement; valid values for its <code>name</code> attribute are: - <code>isa-serial</code> (usable with the <code>isa-serial</code> target + <code>isa-serial</code> and <span class="since">since 5.1.0</span>, + <code>debugcon</code>(usable with the <code>isa-serial</code> target type); <code>usb-serial</code> (usable with the <code>usb-serial</code> target type); <code>pci-serial</code> (usable with the <code>pci-serial</code> target type); diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ba80440c72..ca0dd3b7c2 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3763,6 +3763,7 @@ <value>16550a</value> <value>sclpconsole</value> <value>sclplmconsole</value> + <value>debugcon</value> </choice> </attribute> </element> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5d49f4388c..24b002847c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -516,6 +516,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTargetModel, "sclpconsole", "sclplmconsole", "16550a", + "debugcon", ); VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST, @@ -4392,6 +4393,10 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def) switch ((virDomainChrSerialTargetType) def->serials[0]->targetType) { case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: + if (def->serials[0]->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_DEBUGCON) + break; + ATTRIBUTE_FALLTHROUGH; + 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: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2bc3f879f7..9565f065df 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1134,6 +1134,7 @@ typedef enum { VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_16550A, + VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_DEBUGCON, VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST } virDomainChrSerialTargetModel; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 94de6b9061..c28ced6919 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -197,6 +197,7 @@ VIR_ENUM_IMPL(qemuDomainChrSerialTargetModel, "sclpconsole", "sclplmconsole", "", /* 16550a is not user-instantiable */ + "", /* debugcon */ ); @@ -9370,6 +9371,7 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel) case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011: return QEMU_CAPS_DEVICE_PL011; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_16550A: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_DEBUGCON: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: break; @@ -10801,6 +10803,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_DEBUGCON: caps = qemuChrSerialTargetModelToCaps(serial->targetModel); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ac01e861f7..9c4aedb009 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4375,6 +4375,8 @@ qemuDomainChrSerialTargetModelToTargetType(int targetModel) case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE: return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP; + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_DEBUGCON: + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST: break; @@ -4437,6 +4439,7 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr) case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE: case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_16550A: + case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_DEBUGCON: expected = qemuDomainChrSerialTargetModelToTargetType(chr->targetModel); diff --git a/tests/qemuxml2argvdata/isa-serial-debugcon.xml b/tests/qemuxml2argvdata/isa-serial-debugcon.xml new file mode 100644 index 0000000000..6c5de52585 --- /dev/null +++ b/tests/qemuxml2argvdata/isa-serial-debugcon.xml @@ -0,0 +1,22 @@ +<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='i686' machine='pc'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-i686</emulator> + <controller type='usb' model='none'/> + <controller type='pci' index='0' model='pci-root'/> + <serial type='pipe'> + <source path='/tmp/debugcon'/> + <target type='isa-serial' port='0'> + <model name='debugcon'/> + </target> + <address type='isa' iobase='0x402'/> + </serial> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/isa-serial-debugcon.xml b/tests/qemuxml2xmloutdata/isa-serial-debugcon.xml new file mode 100644 index 0000000000..6ad7c3917c --- /dev/null +++ b/tests/qemuxml2xmloutdata/isa-serial-debugcon.xml @@ -0,0 +1,30 @@ +<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='i686' machine='pc'>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-i686</emulator> + <controller type='usb' index='0' model='none'/> + <controller type='pci' index='0' model='pci-root'/> + <serial type='pipe'> + <source path='/tmp/debugcon'/> + <target type='isa-serial' port='0'> + <model name='debugcon'/> + </target> + <address type='isa' iobase='0x402'/> + </serial> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index b38cbd6994..952e98918d 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -477,6 +477,8 @@ mymain(void) DO_TEST("pci-rom-disabled-invalid", NONE); DO_TEST("pci-serial-dev-chardev", NONE); + DO_TEST("isa-serial-debugcon", NONE); + DO_TEST("encrypted-disk", QEMU_CAPS_QCOW2_LUKS); DO_TEST("encrypted-disk-usage", QEMU_CAPS_QCOW2_LUKS); DO_TEST("luks-disks", NONE); -- 2.19.2

On 14.02.2019 14:32, Ján Tomko wrote:
From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This interface can be used for example by firmware to print debug messages. Here is domain xml example:
<serial type='pty'> <target type='isa-serial' port='0'> <model name='debugcon'/> </target> <address type='isa' iobase='0x402'/> </serial>
Add checks to make sure this new serial type won't be reported as back-compat console.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> --- docs/formatdomain.html.in | 3 +- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 5 ++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 3 ++ src/qemu/qemu_domain.c | 3 ++ .../qemuxml2argvdata/isa-serial-debugcon.xml | 22 ++++++++++++++ .../isa-serial-debugcon.xml | 30 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 ++ 9 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/isa-serial-debugcon.xml create mode 100644 tests/qemuxml2xmloutdata/isa-serial-debugcon.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 2ae5006849..a6d5346d46 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -7089,7 +7089,8 @@ qemu-kvm -net nic,model=? /dev/null <span class="since">Since 3.10.0</span>, the <code>target</code> element can have an optional <code>model</code> subelement; valid values for its <code>name</code> attribute are: - <code>isa-serial</code> (usable with the <code>isa-serial</code> target + <code>isa-serial</code> and <span class="since">since 5.1.0</span>, + <code>debugcon</code>(usable with the <code>isa-serial</code> target
Now it is 5.2.0 Nikolay

On 14.02.2019 14:32, Ján Tomko wrote:
From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This interface can be used for example by firmware to print debug messages. Here is domain xml example:
<serial type='pty'> <target type='isa-serial' port='0'> <model name='debugcon'/> </target> <address type='isa' iobase='0x402'/> </serial>
Add checks to make sure this new serial type won't be reported as back-compat console.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> --- docs/formatdomain.html.in | 3 +- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 5 ++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 3 ++ src/qemu/qemu_domain.c | 3 ++ .../qemuxml2argvdata/isa-serial-debugcon.xml | 22 ++++++++++++++ .../isa-serial-debugcon.xml | 30 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 ++ 9 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/isa-serial-debugcon.xml create mode 100644 tests/qemuxml2xmloutdata/isa-serial-debugcon.xml
And here is missing in previous reply: Reviewed-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>

Some devices (e.g. debugcon) only use the iobase. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_command.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c28ced6919..17237e4fc6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -408,9 +408,9 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, info->addr.ccw.ssid, info->addr.ccw.devno); } else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) { - virBufferAsprintf(buf, ",iobase=0x%x,irq=0x%x", - info->addr.isa.iobase, - info->addr.isa.irq); + virBufferAsprintf(buf, ",iobase=0x%x", info->addr.isa.iobase); + if (info->addr.isa.irq) + virBufferAsprintf(buf, ",irq=0x%x", info->addr.isa.irq); } ret = 0; -- 2.19.2

On 14.02.2019 14:32, Ján Tomko wrote:
Some devices (e.g. debugcon) only use the iobase.
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_command.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c28ced6919..17237e4fc6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -408,9 +408,9 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, info->addr.ccw.ssid, info->addr.ccw.devno); } else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) { - virBufferAsprintf(buf, ",iobase=0x%x,irq=0x%x", - info->addr.isa.iobase, - info->addr.isa.irq); + virBufferAsprintf(buf, ",iobase=0x%x", info->addr.isa.iobase); + if (info->addr.isa.irq) + virBufferAsprintf(buf, ",irq=0x%x", info->addr.isa.irq); }
ret = 0;
Reviewed-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>

From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Format the device on QEMU command line. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_command.c | 2 +- .../isa-serial-debugcon.x86_64-latest.args | 30 +++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 17237e4fc6..7b7abc7aed 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -197,7 +197,7 @@ VIR_ENUM_IMPL(qemuDomainChrSerialTargetModel, "sclpconsole", "sclplmconsole", "", /* 16550a is not user-instantiable */ - "", /* debugcon */ + "isa-debugcon", ); diff --git a/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args b/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args new file mode 100644 index 0000000000..f6a68277c4 --- /dev/null +++ b/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args @@ -0,0 +1,30 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i686 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-chardev pipe,id=charserial0,path=/tmp/debugcon \ +-device isa-debugcon,chardev=charserial0,id=serial0,iobase=0x402 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index dd4f73a5fb..178e36ad36 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1419,6 +1419,7 @@ mymain(void) QEMU_CAPS_DEVICE_ISA_SERIAL); DO_TEST("pci-serial-dev-chardev", QEMU_CAPS_DEVICE_PCI_SERIAL); + DO_TEST_CAPS_LATEST("isa-serial-debugcon"); DO_TEST("channel-guestfwd", NONE); DO_TEST_CAPS_VER("channel-unix-guestfwd", "2.5.0"); -- 2.19.2

On 14.02.2019 14:32, Ján Tomko wrote:
From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Format the device on QEMU command line.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_command.c | 2 +- .../isa-serial-debugcon.x86_64-latest.args | 30 +++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 17237e4fc6..7b7abc7aed 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -197,7 +197,7 @@ VIR_ENUM_IMPL(qemuDomainChrSerialTargetModel, "sclpconsole", "sclplmconsole", "", /* 16550a is not user-instantiable */ - "", /* debugcon */ + "isa-debugcon", );
diff --git a/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args b/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args new file mode 100644 index 0000000000..f6a68277c4 --- /dev/null +++ b/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args @@ -0,0 +1,30 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i686 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-chardev pipe,id=charserial0,path=/tmp/debugcon \ +-device isa-debugcon,chardev=charserial0,id=serial0,iobase=0x402 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index dd4f73a5fb..178e36ad36 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1419,6 +1419,7 @@ mymain(void) QEMU_CAPS_DEVICE_ISA_SERIAL); DO_TEST("pci-serial-dev-chardev", QEMU_CAPS_DEVICE_PCI_SERIAL); + DO_TEST_CAPS_LATEST("isa-serial-debugcon");
DO_TEST("channel-guestfwd", NONE); DO_TEST_CAPS_VER("channel-unix-guestfwd", "2.5.0");
Need the below hunk to be in touch with upstream, besides this: Reviewed-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> diff --git a/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args b/tests/qemuxml2argvdata/isa-serial-debugco index c31c991..a08df30 100644 --- a/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args +++ b/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args @@ -1,8 +1,11 @@ LC_ALL=C \ PATH=/bin \ -HOME=/home/test \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ USER=test \ LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ QEMU_AUDIO_DRV=none \ /usr/bin/qemu-system-i686 \ -name guest=QEMUGuest1,debug-threads=on \

If no address was provided, use QEMU's default of 0xE9 and reflect it in the domain XML. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_domain.c | 9 +++++++++ .../isa-serial-debugcon.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/isa-serial-debugcon.xml | 1 - tests/qemuxml2xmloutdata/isa-serial-debugcon.xml | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9c4aedb009..7f8f8baa60 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6554,6 +6554,15 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, } } + if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA && + chr->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_DEBUGCON) { + if (chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { + chr->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA; + chr->info.addr.isa.iobase = 0xE9; + } + } + return 0; } diff --git a/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args b/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args index f6a68277c4..c31c9910ff 100644 --- a/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args +++ b/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args @@ -24,7 +24,7 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -no-acpi \ -boot strict=on \ -chardev pipe,id=charserial0,path=/tmp/debugcon \ --device isa-debugcon,chardev=charserial0,id=serial0,iobase=0x402 \ +-device isa-debugcon,chardev=charserial0,id=serial0,iobase=0xe9 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/isa-serial-debugcon.xml b/tests/qemuxml2argvdata/isa-serial-debugcon.xml index 6c5de52585..2c66cd9915 100644 --- a/tests/qemuxml2argvdata/isa-serial-debugcon.xml +++ b/tests/qemuxml2argvdata/isa-serial-debugcon.xml @@ -15,7 +15,6 @@ <target type='isa-serial' port='0'> <model name='debugcon'/> </target> - <address type='isa' iobase='0x402'/> </serial> <memballoon model='none'/> </devices> diff --git a/tests/qemuxml2xmloutdata/isa-serial-debugcon.xml b/tests/qemuxml2xmloutdata/isa-serial-debugcon.xml index 6ad7c3917c..4a575cac13 100644 --- a/tests/qemuxml2xmloutdata/isa-serial-debugcon.xml +++ b/tests/qemuxml2xmloutdata/isa-serial-debugcon.xml @@ -21,7 +21,7 @@ <target type='isa-serial' port='0'> <model name='debugcon'/> </target> - <address type='isa' iobase='0x402'/> + <address type='isa' iobase='0xe9'/> </serial> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> -- 2.19.2

On 14.02.2019 14:32, Ján Tomko wrote:
If no address was provided, use QEMU's default of 0xE9 and reflect it in the domain XML.
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_domain.c | 9 +++++++++ .../isa-serial-debugcon.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/isa-serial-debugcon.xml | 1 - tests/qemuxml2xmloutdata/isa-serial-debugcon.xml | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9c4aedb009..7f8f8baa60 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6554,6 +6554,15 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, } }
+ if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA && + chr->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_DEBUGCON) { + if (chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { + chr->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA; + chr->info.addr.isa.iobase = 0xE9; + } + } + return 0; }
diff --git a/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args b/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args index f6a68277c4..c31c9910ff 100644 --- a/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args +++ b/tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args @@ -24,7 +24,7 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -no-acpi \ -boot strict=on \ -chardev pipe,id=charserial0,path=/tmp/debugcon \ --device isa-debugcon,chardev=charserial0,id=serial0,iobase=0x402 \ +-device isa-debugcon,chardev=charserial0,id=serial0,iobase=0xe9 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/isa-serial-debugcon.xml b/tests/qemuxml2argvdata/isa-serial-debugcon.xml index 6c5de52585..2c66cd9915 100644 --- a/tests/qemuxml2argvdata/isa-serial-debugcon.xml +++ b/tests/qemuxml2argvdata/isa-serial-debugcon.xml @@ -15,7 +15,6 @@ <target type='isa-serial' port='0'> <model name='debugcon'/> </target> - <address type='isa' iobase='0x402'/> </serial> <memballoon model='none'/> </devices> diff --git a/tests/qemuxml2xmloutdata/isa-serial-debugcon.xml b/tests/qemuxml2xmloutdata/isa-serial-debugcon.xml index 6ad7c3917c..4a575cac13 100644 --- a/tests/qemuxml2xmloutdata/isa-serial-debugcon.xml +++ b/tests/qemuxml2xmloutdata/isa-serial-debugcon.xml @@ -21,7 +21,7 @@ <target type='isa-serial' port='0'> <model name='debugcon'/> </target> - <address type='isa' iobase='0x402'/> + <address type='isa' iobase='0xe9'/> </serial> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/>
I donno, does it make sense to add new testcase for default address instead of fixing existent? Reviewed-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>

On 14.02.2019 14:32, Ján Tomko wrote:
v2: https://www.redhat.com/archives/libvir-list/2019-February/msg00293.html v3: * dropped the pointless isa-prefix * use DO_TEST_CAPS_LATEST * trimmed the XML * compiles with gcc * only make irq optional * autofill iobase
Ján Tomko (3): qemu: introduce qemuDomainChrSerialTargetModel qemu: make irq optional when formatting the ISA address qemu: autoadd iobase to debugcon chardev
Nikolay Shirokovskiy (2): conf: add debugcon chardev guest interface qemu: implement debugcon chardev
docs/formatdomain.html.in | 3 +- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 5 ++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 25 +++++++++++++--- src/qemu/qemu_domain.c | 12 ++++++++ .../isa-serial-debugcon.x86_64-latest.args | 30 +++++++++++++++++++ .../qemuxml2argvdata/isa-serial-debugcon.xml | 21 +++++++++++++ tests/qemuxml2argvtest.c | 1 + .../isa-serial-debugcon.xml | 30 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 ++ 11 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/isa-serial-debugcon.xml create mode 100644 tests/qemuxml2xmloutdata/isa-serial-debugcon.xml
I forget to mention that there is still an issue with console alias that need to be addressed: https://www.redhat.com/archives/libvir-list/2019-February/msg00608.html I could send it. Nikolay

On 04.04.2019 15:23, Nikolay Shirokovskiy wrote:
On 14.02.2019 14:32, Ján Tomko wrote:
v2: https://www.redhat.com/archives/libvir-list/2019-February/msg00293.html v3: * dropped the pointless isa-prefix * use DO_TEST_CAPS_LATEST * trimmed the XML * compiles with gcc * only make irq optional * autofill iobase
Ján Tomko (3): qemu: introduce qemuDomainChrSerialTargetModel qemu: make irq optional when formatting the ISA address qemu: autoadd iobase to debugcon chardev
Nikolay Shirokovskiy (2): conf: add debugcon chardev guest interface qemu: implement debugcon chardev
docs/formatdomain.html.in | 3 +- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 5 ++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 25 +++++++++++++--- src/qemu/qemu_domain.c | 12 ++++++++ .../isa-serial-debugcon.x86_64-latest.args | 30 +++++++++++++++++++ .../qemuxml2argvdata/isa-serial-debugcon.xml | 21 +++++++++++++ tests/qemuxml2argvtest.c | 1 + .../isa-serial-debugcon.xml | 30 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 ++ 11 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/isa-serial-debugcon.xml create mode 100644 tests/qemuxml2xmloutdata/isa-serial-debugcon.xml
I forget to mention that there is still an issue with console alias that need to be addressed:
https://www.redhat.com/archives/libvir-list/2019-February/msg00608.html
I could send it.
Next patch fixes the issue by inserting extra serial if the first one is debugcon. diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b2dd281..1d69c88 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4394,7 +4394,8 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def) (def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL || def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)) { - /* If there isn't a corresponding serial port: + /* If there isn't a corresponding serial port or the first serial port + * is used for debugcon: * - create one and set, the console to be an alias for it * * If there is a corresponding serial port: @@ -4404,8 +4405,11 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def) */ /* create the serial port definition from the console definition */ - if (def->nserials == 0) { - if (VIR_APPEND_ELEMENT(def->serials, + if (def->nserials == 0 || + (def->serials[0]->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA && + def->serials[0]->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_DEBUGCON)) { + if (VIR_INSERT_ELEMENT(def->serials, + 0, def->nserials, def->consoles[0]) < 0) return -1;

ping On 14.02.2019 14:32, Ján Tomko wrote:
v2: https://www.redhat.com/archives/libvir-list/2019-February/msg00293.html v3: * dropped the pointless isa-prefix * use DO_TEST_CAPS_LATEST * trimmed the XML * compiles with gcc * only make irq optional * autofill iobase
Ján Tomko (3): qemu: introduce qemuDomainChrSerialTargetModel qemu: make irq optional when formatting the ISA address qemu: autoadd iobase to debugcon chardev
Nikolay Shirokovskiy (2): conf: add debugcon chardev guest interface qemu: implement debugcon chardev
docs/formatdomain.html.in | 3 +- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 5 ++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 25 +++++++++++++--- src/qemu/qemu_domain.c | 12 ++++++++ .../isa-serial-debugcon.x86_64-latest.args | 30 +++++++++++++++++++ .../qemuxml2argvdata/isa-serial-debugcon.xml | 21 +++++++++++++ tests/qemuxml2argvtest.c | 1 + .../isa-serial-debugcon.xml | 30 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 ++ 11 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 tests/qemuxml2argvdata/isa-serial-debugcon.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/isa-serial-debugcon.xml create mode 100644 tests/qemuxml2xmloutdata/isa-serial-debugcon.xml
participants (2)
-
Ján Tomko
-
Nikolay Shirokovskiy