From b24a9f3e129a7be68e9266d87fdfcf407e509616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20J=C3=B6rg?= Date: Wed, 23 May 2012 07:50:02 +0200 Subject: [PATCH] Fix for parallel port passthrough for QEMU 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 (cherry picked from commit 7508338ff3b75b39ee9654e3d83bc58c858dc92a) --- AUTHORS | 1 + src/qemu/qemu_command.c | 5 ++-- ...qemuxml2argv-parallel-parport-chardev.args | 7 +++++ .../qemuxml2argv-parallel-parport-chardev.xml | 29 +++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 5 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-parallel-parport-chardev.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-parallel-parport-chardev.xml diff --git a/AUTHORS b/AUTHORS index 3fefd64ad7..752873c058 100644 --- a/AUTHORS +++ b/AUTHORS @@ -234,6 +234,7 @@ Patches have also been contributed by: Jan Kiszka Ryan Woodsmall Radu Caragea + Beat Jörg [....send patches to get your name here....] diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6f6ef04d8f..8ac4ee4c06 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -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 index 0000000000..48f968aba5 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-parallel-parport-chardev.args @@ -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 index 0000000000..b495cdc67c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-parallel-parport-chardev.xml @@ -0,0 +1,29 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3529c37640..a32d4f89a6 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -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); -- GitLab