virt-install: add support for qemu-vdagent channel

This allows support for host/guest clipboard sharing when using vnc
guests (and possibly other graphics types in the future). This channel
is similar to the spicevmc channel, but it contains a couple additional
options to enable/disable clipboard sharing and specify the mouse mode.
In the case of spice, these settings are specified on the 'graphics'
element, but for qemu-vdagent, they are specified on the channel. For
example:

   --channel=qemu-vdagent,source.clipboard.copypaste=on,source.mouse.mode=client

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Jonathon Jongsma 2022-05-18 17:03:29 -05:00 committed by Cole Robinson
parent 0533bb8189
commit 44355e5ed0
5 changed files with 28 additions and 3 deletions

View File

@ -1761,6 +1761,15 @@ Some of the types of character device redirection are:
and can be any string, such as the default com.redhat.spice.0 that
specifies how the guest will see the channel.
``--channel qemu-vdagent,target.type=virtio[,target.name=NAME]``
Communication channel for QEMU vd agent, using virtio serial (requires
2.6.34 or later host and guest). This allows copy/paste functionality with
VNC guests. Note that the guest clipboard integration is implemented via
spice-vdagent, which must be running even when the guest does not use spice
graphics. NAME is optional metadata that specifies how the guest will see
the channel, and should be left as the default com.redhat.spice.0 unless you
know what you are doing.
Use --channel=? to see a list of all available sub options.
Complete details at https://libvirt.org/formatdomain.html#elementsCharChannel

View File

@ -647,6 +647,13 @@
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<channel type="qemu-vdagent">
<source>
<clipboard copypaste="yes"/>
<mouse mode="client"/>
</source>
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<input type="keyboard" bus="usb"/>
<input type="tablet" bus="usb"/>
<input type="mouse" bus="ps2"/>

View File

@ -674,6 +674,7 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
--channel pty,target_type=virtio,name=org.linux-kvm.port1
--channel pty,target.type=virtio,target.name=org.linux-kvm.port2
--channel spicevmc
--channel qemu-vdagent,source.clipboard.copypaste=on,source.mouse.mode=client
--console pty,target_type=virtio
@ -739,7 +740,7 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
--rng /dev/random
--rng device=/dev/urandom,backend.protocol.type=,backend.log.file=,backend.log.append=
--rng device=/dev/urandom,backend.protocol.type=,backend.log.file=,backend.log.append=,backend.source.clipboard.copypaste=,backend.source.mouse.mode=
--rng type=egd,backend.type=nmdm,backend.source.master=/dev/foo1,backend.source.slave=/dev/foo2
--rng egd,backend_host=127.0.0.1,backend_service=8000,backend_type=udp,backend_mode=bind,backend_connect_host=foo,backend_connect_service=708,rate.bytes=1234,rate.period=1000,model=virtio
@ -791,7 +792,7 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
--xml xpath.delete=./deleteme/deleteme2
""", "many-devices", predefine_check="7.4.0")
""", "many-devices", predefine_check="8.4.0")
# Specific XML test cases #1

View File

@ -3404,6 +3404,8 @@ def _add_char_source_args(cls, prefix=""):
_add_arg("protocol.type", "source.protocol")
_add_arg("log.file", "source.log_file")
_add_arg("log.append", "source.log_append", is_onoff=True)
_add_arg("source.clipboard.copypaste", "source.clipboard_copypaste", is_onoff=True)
_add_arg("source.mouse.mode", "source.mouse_mode")
##################

View File

@ -45,6 +45,10 @@ class CharSource(XMLBuilder):
slave = XMLProperty("./@slave")
mode = XMLProperty("./@mode")
# for qemu-vdagent channel
clipboard_copypaste = XMLProperty("./clipboard/@copypaste", is_yesno=True)
mouse_mode = XMLProperty("./mouse/@mode")
# It's weird to track these properties here, since the XML is set on
# the parent, but this is how libvirt does it internally, which means
# everything that shares a charsource has these values too.
@ -80,6 +84,7 @@ class _DeviceChar(Device):
TYPE_SPICEVMC = "spicevmc"
TYPE_SPICEPORT = "spiceport"
TYPE_NMDM = "nmdm"
TYPE_QEMUVDAGENT = "qemu-vdagent"
CHANNEL_NAME_SPICE = "com.redhat.spice.0"
CHANNEL_NAME_QEMUGA = "org.qemu.guest_agent.0"
@ -117,7 +122,8 @@ class _DeviceChar(Device):
self.source.mode = "bind"
if not self.target_type and self.DEVICE_TYPE == "channel":
self.target_type = "virtio"
if not self.target_name and self.type == self.TYPE_SPICEVMC:
if not self.target_name and (self.type == self.TYPE_SPICEVMC or
self.type == self.TYPE_QEMUVDAGENT):
self.target_name = self.CHANNEL_NAME_SPICE