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

[libvirt] [PATCH 2/2] qemu: implement debugcon-isa chardev



Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy virtuozzo com>
---
 src/libvirt_private.syms                         |  2 ++
 src/qemu/qemu_command.c                          | 10 ++++++++
 src/qemu/qemu_domain.c                           | 20 ++++++++++++++++
 tests/qemuxml2argvdata/channel-debugcon-isa.args | 29 ++++++++++++++++++++++++
 tests/qemuxml2argvtest.c                         |  1 +
 5 files changed, 62 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/channel-debugcon-isa.args

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c3d6306..37cb43a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -203,6 +203,8 @@ virDomainBootTypeFromString;
 virDomainBootTypeToString;
 virDomainCapabilitiesPolicyTypeToString;
 virDomainCapsFeatureTypeToString;
+virDomainChrChannelTargetTypeFromString;
+virDomainChrChannelTargetTypeToString;
 virDomainChrConsoleTargetTypeFromString;
 virDomainChrConsoleTargetTypeToString;
 virDomainChrDefForeach;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e96b1a0..7c28944 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9485,6 +9485,7 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
             break;
 
         case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
+        case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_DEBUGCON_ISA:
             if (!(devstr = qemuBuildChrChardevStr(logManager, secManager,
                                                   cmd, cfg, def,
                                                   channel->source,
@@ -10788,6 +10789,15 @@ qemuBuildChannelChrDeviceStr(char **deviceStr,
         break;
 
     case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_DEBUGCON_ISA:
+        if (chr->info.addr.isa.iobase) {
+            if (virAsprintf(deviceStr, "isa-debugcon,iobase=0x%x,chardev=char%s",
+                            chr->info.addr.isa.iobase, chr->info.alias) < 0)
+                goto cleanup;
+        } else {
+            if (virAsprintf(deviceStr, "isa-debugcon,chardev=char%s",
+                            chr->info.alias) < 0)
+                goto cleanup;
+        }
         break;
 
     case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN:
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 32a43f2..5f53784 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4451,7 +4451,19 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr)
 
     case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
     case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
+        break;
+
     case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL:
+        if (chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_DEBUGCON_ISA &&
+            chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+            chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("Target type 'debugcon-isa' requires "
+                             " address type 'isa'"));
+            return -1;
+        }
+        break;
+
     case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
         /* Nothing to do */
         break;
@@ -4516,6 +4528,14 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev,
         }
     }
 
+    if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
+        dev->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_DEBUGCON_ISA &&
+        !ARCH_IS_X86(def->os.arch)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("debugcon-isa is not supported"));
+        return -1;
+    }
+
     return 0;
 }
 
diff --git a/tests/qemuxml2argvdata/channel-debugcon-isa.args b/tests/qemuxml2argvdata/channel-debugcon-isa.args
new file mode 100644
index 0000000..6b57e60
--- /dev/null
+++ b/tests/qemuxml2argvdata/channel-debugcon-isa.args
@@ -0,0 +1,29 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\
+bootindex=1 \
+-chardev pipe,id=charchannel0,path=/tmp/debugcon-isa \
+-device isa-debugcon,iobase=0x402,chardev=charchannel0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index ba6fd4d..ddcbe41 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1499,6 +1499,7 @@ mymain(void)
     DO_TEST("channel-virtio-auto", NONE);
     DO_TEST("channel-virtio-autoassign", NONE);
     DO_TEST("channel-virtio-autoadd", NONE);
+    DO_TEST("channel-debugcon-isa", NONE);
     DO_TEST("console-virtio", NONE);
     DO_TEST("console-virtio-many",
             QEMU_CAPS_DEVICE_ISA_SERIAL);
-- 
1.8.3.1


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