From: Marc-André Lureau <marcandre.lureau(a)redhat.com>
The USB device redirection works in a similar way as Spice. The
underlying 'dbus' channel is set to "org.qemu.usbredir" by default for
the client to identify the channel purpose (as specified in -display
dbus documentation).
Signed-off-by: Marc-André Lureau <marcandre.lureau(a)redhat.com>
---
src/conf/domain_conf.c | 2 ++
.../graphics-dbus-usbredir.args | 35 ++++++++++++++++++
.../graphics-dbus-usbredir.xml | 36 +++++++++++++++++++
tests/qemuxml2argvtest.c | 4 +++
4 files changed, 77 insertions(+)
create mode 100644 tests/qemuxml2argvdata/graphics-dbus-usbredir.args
create mode 100644 tests/qemuxml2argvdata/graphics-dbus-usbredir.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1fbbcb33d0ca..3385b7960a43 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14556,6 +14556,8 @@ virDomainRedirdevDefParseXML(virDomainXMLOption *xmlopt,
if (def->source->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC)
def->source->data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_USBREDIR;
+ if (def->source->type == VIR_DOMAIN_CHR_TYPE_DBUS &&
!def->source->data.dbus.channel)
+ def->source->data.dbus.channel = g_strdup("org.qemu.usbredir");
if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info,
flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) < 0)
diff --git a/tests/qemuxml2argvdata/graphics-dbus-usbredir.args
b/tests/qemuxml2argvdata/graphics-dbus-usbredir.args
new file mode 100644
index 000000000000..71574512fbaa
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-dbus-usbredir.args
@@ -0,0 +1,35 @@
+LC_ALL=C \
+PATH=/bin \
+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 \
+/usr/bin/qemu-system-i386 \
+-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 \
+-no-user-config \
+-nodefaults \
+-chardev
socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server=on,wait=off
\
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
+-display dbus,p2p=on \
+-device cirrus-vga,id=video0,bus=pci.0,addr=0x2 \
+-chardev dbus,id=charredir0,name=org.qemu.usbredir \
+-device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=1 \
+-chardev dbus,id=charredir1,name=org.qemu.usbredir \
+-device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=2 \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/graphics-dbus-usbredir.xml
b/tests/qemuxml2argvdata/graphics-dbus-usbredir.xml
new file mode 100644
index 000000000000..08a6011902fc
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-dbus-usbredir.xml
@@ -0,0 +1,36 @@
+<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-i386</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='dbus' p2p='yes'/>
+ <redirdev bus='usb' type='dbus'/>
+ <redirdev bus='usb' type='dbus'/>
+ <video>
+ <model type='cirrus' vram='16384' heads='1'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 828c0ed77cfe..8c1ba2a6427f 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1534,6 +1534,10 @@ mymain(void)
QEMU_CAPS_DEVICE_ISA_SERIAL,
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_DISPLAY_DBUS);
+ DO_TEST("graphics-dbus-usbredir",
+ QEMU_CAPS_DEVICE_CIRRUS_VGA,
+ QEMU_CAPS_DISPLAY_DBUS,
+ QEMU_CAPS_USB_REDIR);
DO_TEST_NOCAPS("input-usbmouse");
DO_TEST_NOCAPS("input-usbtablet");
--
2.33.0.721.g106298f7f9