]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix for parallel port passthrough for QEMU
authorBeat Jörg <Beat.Joerg@ssatr.ch>
Wed, 23 May 2012 05:50:02 +0000 (07:50 +0200)
committerCole Robinson <crobinso@redhat.com>
Thu, 14 Jun 2012 22:38:26 +0000 (18:38 -0400)
I came across a bug that the command line generated for passthrough
of the host parallel port /dev/parport0 by libvirt for QEMU is incorrect.

It currently produces:
-chardev tty,id=charparallel0,path=/dev/parport0
-device isa-parallel,chardev=charparallel0,id=parallel0

The first parameter is "tty". It sould be "parport".

If I launch qemu with -chardev parport,... it works as expected.

I have already filled a bug report (
https://bugzilla.redhat.com/show_bug.cgi?id=823879 ), the topic was
already on the list some months ago:

https://www.redhat.com/archives/libvirt-users/2011-September/msg00095.html

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 7508338ff3b75b39ee9654e3d83bc58c858dc92a)

AUTHORS
src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-parallel-parport-chardev.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-parallel-parport-chardev.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c

diff --git a/AUTHORS b/AUTHORS
index 3fefd64ad7927da8cc58f50817d8cb1842f11033..752873c0580102afe560fc870c74890e2c012b1a 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -234,6 +234,7 @@ Patches have also been contributed by:
   Jan Kiszka           <jan.kiszka@siemens.com>
   Ryan Woodsmall       <rwoodsmall@gmail.com>
   Radu Caragea         <dmns_serp@yahoo.com>
+  Beat Jörg            <Beat.Joerg@ssatr.ch>
 
   [....send patches to get your name here....]
 
index 6f6ef04d8fe1102e7a0cfbadfbee5400cf07a82a..8ac4ee4c06bb93e09788181965cc12215e7bf1b4 100644 (file)
@@ -3293,8 +3293,9 @@ qemuBuildChrChardevStr(virDomainChrSourceDefPtr dev, const char *alias,
         break;
 
     case VIR_DOMAIN_CHR_TYPE_DEV:
-        virBufferAsprintf(&buf, "tty,id=char%s,path=%s", alias,
-                          dev->data.file.path);
+        virBufferAsprintf(&buf, "%s,id=char%s,path=%s",
+                          STRPREFIX(alias, "parallel") ? "parport" : "tty",
+                          alias, dev->data.file.path);
         break;
 
     case VIR_DOMAIN_CHR_TYPE_FILE:
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-parallel-parport-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-parallel-parport-chardev.args
new file mode 100644 (file)
index 0000000..48f968a
--- /dev/null
@@ -0,0 +1,7 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+pc -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 -hda /dev/HostVG/QEMUGuest1 \
+-chardev parport,id=charparallel0,path=/dev/parport0 -device \
+isa-parallel,chardev=charparallel0,id=parallel0 -usb -device \
+virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-parallel-parport-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-parallel-parport-chardev.xml
new file mode 100644 (file)
index 0000000..b495cdc
--- /dev/null
@@ -0,0 +1,29 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</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</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <parallel type='dev'>
+      <source path='/dev/parport0'/>
+      <target port='0'/>
+    </parallel>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
index 3529c3764070df6248f232451a126d1ac30848dd..a32d4f89a67db3b9d253d172712e528cc89f904b 100644 (file)
@@ -595,6 +595,8 @@ mymain(void)
             QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
     DO_TEST("parallel-tcp-chardev", false,
             QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
+    DO_TEST("parallel-parport-chardev", false,
+            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
     DO_TEST("console-compat-chardev", false,
             QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);