qemu: add usbredir type 'dbus'

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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Marc-André Lureau 2022-05-13 20:38:19 +02:00 committed by Michal Privoznik
parent 53905292f9
commit 3fa987cc42
4 changed files with 70 additions and 0 deletions

View File

@ -14411,6 +14411,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)

View File

@ -0,0 +1,34 @@
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,usb=off,dump-guest-core=off \
-accel tcg \
-m 214 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-no-user-config \
-nodefaults \
-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc \
-no-shutdown \
-no-acpi \
-boot strict=on \
-usb \
-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

View File

@ -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-i386</emulator>
<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>

View File

@ -1543,6 +1543,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");