Re: [libvirt PATCH v2 3/4] conf: add qemu-vdagent channel

2022-03-25 Thread Marc-André Lureau
Hi


On Thu, Mar 24, 2022 at 11:26 PM Jonathon Jongsma  wrote:
>
> Add the ability to configure a qemu-vdagent in guest domains. This
> device is similar to the spice vdagent channel except that qemu handles
> the spice-vdagent protocol messages itself rather than routing them over
> a spice protocol channel.
>
> The qemu-vdagent device has two notable configuration options which
> determine whether qemu will handle particular vdagent features:
> 'clipboard' and 'mouse'.
>
> The 'clipboard' option allows qemu to synchronize its internal clipboard
> manager with the guest clipboard, which enables client<->guest clipboard
> synchronization for non-spice guests such as vnc.
>
> The 'mouse' option allows absolute mouse positioning to be sent over the
> vdagent channel rather than using a usb or virtio tablet device.
>
> Sample configuration:
>   
> 
> 
>   
>   
> 
>   
>
> Signed-off-by: Jonathon Jongsma 

I guess you could have added some domain XML tests here, but the next
patch covers it, so

Reviewed-by: Marc-André Lureau 

> ---
>  docs/formatdomain.rst | 23 
>  src/conf/domain_conf.c| 62 ++-
>  src/conf/domain_conf.h| 20 ++
>  src/conf/domain_validate.c|  1 +
>  src/conf/schemas/domaincommon.rng | 51 -
>  src/qemu/qemu_command.c   |  3 ++
>  src/qemu/qemu_monitor_json.c  |  1 +
>  src/qemu/qemu_process.c   |  1 +
>  src/qemu/qemu_validate.c  |  1 +
>  src/security/security_apparmor.c  |  2 +
>  src/security/security_dac.c   |  2 +
>  tests/testutilsqemu.c |  1 +
>  12 files changed, 140 insertions(+), 28 deletions(-)
>
> diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
> index e492532004..75339c2fda 100644
> --- a/docs/formatdomain.rst
> +++ b/docs/formatdomain.rst
> @@ -6662,6 +6662,29 @@ types have different ``target`` attributes.
> ``name='com.redhat.spice.0'``. The optional ``address`` element can tie 
> the
> channel to a particular ``type='virtio-serial'`` controller. :since:`Since
> 0.8.8`
> +``qemu-vdagent``
> +   Paravirtualized qemu vdagent channel. This channel implements the SPICE
> +   vdagent protocol, but is handled internally by qemu and therefore does not
> +   require a SPICE graphics device. Like the spicevmc channel, the ``target``
> +   element must be present, with attribute ``type='virtio'``; an optional
> +   attribute ``name`` controls how the guest will have access to the channel,
> +   and defaults to ``name='com.redhat.spice.0'``. The optional ``address``
> +   element can tie the channel to a particular ``type='virtio-serial'``
> +   controller. Certain vdagent protocol features can by enabled or disabled
> +   using the ``source`` element.
> +
> +   Copy & Paste functionality is set by the ``clipboard`` element. It is
> +   disabled by default, and can be enabled by setting the ``copypaste``
> +   property to ``yes``. This allows the guest's clipboard to be synchronized
> +   with the qemu clipboard manager. This can enable copy and paste between a
> +   guest and a client when using a VNC `graphics device 
> <#elementsGraphics>`__
> +   (when using a VNC client that supports the copy/paste feature) or other
> +   graphics types that support the qemu clipboard manager.
> +
> +   Mouse mode is set by the ``mouse`` element, setting its ``mode`` attribute
> +   to one of ``server`` or ``client``. If no mode is specified, the qemu
> +   default will be used (client mode).
> +   :since:`Since 8.2.0`
>
>  :anchor:``
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 6f9954638c..3b97de89f4 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -713,6 +713,7 @@ VIR_ENUM_IMPL(virDomainChr,
>"spicevmc",
>"spiceport",
>"nmdm",
> +  "qemu-vdagent",
>  );
>
>  VIR_ENUM_IMPL(virDomainChrTcpProtocol,
> @@ -2698,6 +2699,7 @@ virDomainChrSourceDefGetPath(virDomainChrSourceDef *chr)
>  case VIR_DOMAIN_CHR_TYPE_STDIO:
>  case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
>  case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
> +case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
>  case VIR_DOMAIN_CHR_TYPE_LAST:
>  return NULL;
>  }
> @@ -2807,6 +2809,11 @@ virDomainChrSourceDefCopy(virDomainChrSourceDef *dest,
>  dest->data.spiceport.channel = g_strdup(src->data.spiceport.channel);
>  break;
>
> +case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
> +dest->data.qemuVdagent.clipboard = src->data.qemuVdagent.clipboard;
> +dest->data.qemuVdagent.mouse = src->data.qemuVdagent.mouse;
> +break;
> +
>  case VIR_DOMAIN_CHR_TYPE_NULL:
>  case VIR_DOMAIN_CHR_TYPE_VC:
>  case VIR_DOMAIN_CHR_TYPE_STDIO:
> @@ -2888,6 +2895,10 @@ virDomainChrSourceDefIsEqual(const 
> virDomainChrSourceDef *src,
>  case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
>  return src->data.spicevmc == tgt

[libvirt PATCH v2 3/4] conf: add qemu-vdagent channel

2022-03-24 Thread Jonathon Jongsma
Add the ability to configure a qemu-vdagent in guest domains. This
device is similar to the spice vdagent channel except that qemu handles
the spice-vdagent protocol messages itself rather than routing them over
a spice protocol channel.

The qemu-vdagent device has two notable configuration options which
determine whether qemu will handle particular vdagent features:
'clipboard' and 'mouse'.

The 'clipboard' option allows qemu to synchronize its internal clipboard
manager with the guest clipboard, which enables client<->guest clipboard
synchronization for non-spice guests such as vnc.

The 'mouse' option allows absolute mouse positioning to be sent over the
vdagent channel rather than using a usb or virtio tablet device.

Sample configuration:
  


  
  

  

Signed-off-by: Jonathon Jongsma 
---
 docs/formatdomain.rst | 23 
 src/conf/domain_conf.c| 62 ++-
 src/conf/domain_conf.h| 20 ++
 src/conf/domain_validate.c|  1 +
 src/conf/schemas/domaincommon.rng | 51 -
 src/qemu/qemu_command.c   |  3 ++
 src/qemu/qemu_monitor_json.c  |  1 +
 src/qemu/qemu_process.c   |  1 +
 src/qemu/qemu_validate.c  |  1 +
 src/security/security_apparmor.c  |  2 +
 src/security/security_dac.c   |  2 +
 tests/testutilsqemu.c |  1 +
 12 files changed, 140 insertions(+), 28 deletions(-)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index e492532004..75339c2fda 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -6662,6 +6662,29 @@ types have different ``target`` attributes.
``name='com.redhat.spice.0'``. The optional ``address`` element can tie the
channel to a particular ``type='virtio-serial'`` controller. :since:`Since
0.8.8`
+``qemu-vdagent``
+   Paravirtualized qemu vdagent channel. This channel implements the SPICE
+   vdagent protocol, but is handled internally by qemu and therefore does not
+   require a SPICE graphics device. Like the spicevmc channel, the ``target``
+   element must be present, with attribute ``type='virtio'``; an optional
+   attribute ``name`` controls how the guest will have access to the channel,
+   and defaults to ``name='com.redhat.spice.0'``. The optional ``address``
+   element can tie the channel to a particular ``type='virtio-serial'``
+   controller. Certain vdagent protocol features can by enabled or disabled
+   using the ``source`` element.
+
+   Copy & Paste functionality is set by the ``clipboard`` element. It is
+   disabled by default, and can be enabled by setting the ``copypaste``
+   property to ``yes``. This allows the guest's clipboard to be synchronized
+   with the qemu clipboard manager. This can enable copy and paste between a
+   guest and a client when using a VNC `graphics device <#elementsGraphics>`__
+   (when using a VNC client that supports the copy/paste feature) or other
+   graphics types that support the qemu clipboard manager.
+
+   Mouse mode is set by the ``mouse`` element, setting its ``mode`` attribute
+   to one of ``server`` or ``client``. If no mode is specified, the qemu
+   default will be used (client mode).
+   :since:`Since 8.2.0`
 
 :anchor:``
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6f9954638c..3b97de89f4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -713,6 +713,7 @@ VIR_ENUM_IMPL(virDomainChr,
   "spicevmc",
   "spiceport",
   "nmdm",
+  "qemu-vdagent",
 );
 
 VIR_ENUM_IMPL(virDomainChrTcpProtocol,
@@ -2698,6 +2699,7 @@ virDomainChrSourceDefGetPath(virDomainChrSourceDef *chr)
 case VIR_DOMAIN_CHR_TYPE_STDIO:
 case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
 case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
 case VIR_DOMAIN_CHR_TYPE_LAST:
 return NULL;
 }
@@ -2807,6 +2809,11 @@ virDomainChrSourceDefCopy(virDomainChrSourceDef *dest,
 dest->data.spiceport.channel = g_strdup(src->data.spiceport.channel);
 break;
 
+case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
+dest->data.qemuVdagent.clipboard = src->data.qemuVdagent.clipboard;
+dest->data.qemuVdagent.mouse = src->data.qemuVdagent.mouse;
+break;
+
 case VIR_DOMAIN_CHR_TYPE_NULL:
 case VIR_DOMAIN_CHR_TYPE_VC:
 case VIR_DOMAIN_CHR_TYPE_STDIO:
@@ -2888,6 +2895,10 @@ virDomainChrSourceDefIsEqual(const virDomainChrSourceDef 
*src,
 case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
 return src->data.spicevmc == tgt->data.spicevmc;
 
+case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
+return src->data.qemuVdagent.clipboard == 
tgt->data.qemuVdagent.clipboard &&
+src->data.qemuVdagent.mouse == tgt->data.qemuVdagent.mouse;
+
 case VIR_DOMAIN_CHR_TYPE_NULL:
 case VIR_DOMAIN_CHR_TYPE_VC:
 case VIR_DOMAIN_CHR_TYPE_STDIO:
@@ -11244,6 +11255,33 @@ virDomainChrSourceDefParseLog(virDomainChrSourc