public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu-server v2 1/5] enable clipboard parameter in vga_fmt
@ 2022-10-20 11:14 Markus Frank
  2022-10-20 11:14 ` [pve-devel] [PATCH qemu-server 2/5] added clipboard variable to return at status/current Markus Frank
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Markus Frank @ 2022-10-20 11:14 UTC (permalink / raw)
  To: pve-devel

added Options to use the qemu vdagent implementation to enable the noVNC clipboard.
When enabled with SPICE the spice-vdagent gets replaced with the qemu
implementation.

This patch does not solve #1406, but does allow copy and paste with
a running X-session, when spice-vdagent is installed.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
v2: added pci address to virtio-serial-pci

With this Patch you have the ability to choose which
clipboard-implementation to use when using Spice.
The alternative would be to only allow noVNC
clipboard if no SPICE is running, because qemu cannot use the same
virtserialport twice. This alternative would also disable the ability
to use the noVNC clipboard with VirtIO/VirGL.

 PVE/QemuServer.pm     | 19 ++++++++++++++++++-
 PVE/QemuServer/PCI.pm |  3 ++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index c706653..333afc2 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -190,6 +190,12 @@ my $vga_fmt = {
 	minimum => 4,
 	maximum => 512,
     },
+    clipboard => {
+	description => "enable clipboard (requires spice-vdagent)",
+	type => 'boolean',
+	optional => 1,
+	default => 0
+    }
 };
 
 my $ivshmem_fmt = {
@@ -3836,6 +3842,13 @@ sub config_to_command {
 	}
     }
 
+    if ($vga->{clipboard} && $vga->{type} =~ /^std|^cirrus|^vmware/) {
+	push @$devices, '-chardev', 'qemu-vdagent,id=vdagent,name=vdagent,clipboard=on';
+	my $pciaddr = print_pci_addr("clipboard", $bridges, $arch, $machine_type);
+	push @$devices, '-device', "virtio-serial-pci$pciaddr";
+	push @$devices, '-device', 'virtserialport,chardev=vdagent,name=com.redhat.spice.0';
+    }
+
     my $rng = $conf->{rng0} ? parse_rng($conf->{rng0}) : undef;
     if ($rng && $version_guard->(4, 1, 2)) {
 	check_rng_source($rng->{source});
@@ -3880,7 +3893,11 @@ sub config_to_command {
 	die "failed to get an ip address of type $pfamily for 'localhost'\n" if !@nodeaddrs;
 
 	push @$devices, '-device', "virtio-serial,id=spice$pciaddr";
-	push @$devices, '-chardev', "spicevmc,id=vdagent,name=vdagent";
+	if ($vga->{clipboard}) {
+	    push @$devices, '-chardev', 'qemu-vdagent,id=vdagent,name=vdagent,clipboard=on';
+	} else {
+	    push @$devices, '-chardev', 'spicevmc,id=vdagent,name=vdagent';
+	}
 	push @$devices, '-device', "virtserialport,chardev=vdagent,name=com.redhat.spice.0";
 
 	my $localhost = PVE::Network::addr_to_ip($nodeaddrs[0]->{addr});
diff --git a/PVE/QemuServer/PCI.pm b/PVE/QemuServer/PCI.pm
index 3d0e70e..7ddabe0 100644
--- a/PVE/QemuServer/PCI.pm
+++ b/PVE/QemuServer/PCI.pm
@@ -138,7 +138,8 @@ sub get_pci_addr_map {
 	scsihw1 => { bus => 0, addr => 6 },
 	ahci0 => { bus => 0, addr => 7 },
 	qga0 => { bus => 0, addr => 8 },
-	spice => { bus => 0, addr => 9 },
+	spice => { bus => 0, addr => 9, conflict_ok => qw(clipboard) },
+	clipboard => { bus => 0, addr => 9, conflict_ok => qw(spice) }, # clipboard is used if spice is not running
 	virtio0 => { bus => 0, addr => 10 },
 	virtio1 => { bus => 0, addr => 11 },
 	virtio2 => { bus => 0, addr => 12 },
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pve-devel] [PATCH qemu-server 2/5] added clipboard variable to return at status/current
  2022-10-20 11:14 [pve-devel] [PATCH qemu-server v2 1/5] enable clipboard parameter in vga_fmt Markus Frank
@ 2022-10-20 11:14 ` Markus Frank
  2022-10-20 11:14 ` [pve-devel] [PATCH novnc 3/5] added show clipboard button patch to series Markus Frank
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Markus Frank @ 2022-10-20 11:14 UTC (permalink / raw)
  To: pve-devel

By that noVNC is able to check if clipboard is active.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 PVE/API2/Qemu.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 99b426e..25f3a1d 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2428,6 +2428,11 @@ __PACKAGE__->register_method({
 		type => 'boolean',
 		optional => 1,
 	    },
+	    clipboard => {
+		description => "Qemu clipboard enabled in config.",
+		type => 'boolean',
+		optional => 1,
+	    },
 	},
     },
     code => sub {
@@ -2446,6 +2451,7 @@ __PACKAGE__->register_method({
 	    my $spice = defined($vga->{type}) && $vga->{type} =~ /^virtio/;
 	    $spice ||= PVE::QemuServer::vga_conf_has_spice($conf->{vga});
 	    $status->{spice} = 1 if $spice;
+	    $status->{clipboard} = $vga->{clipboard};
 	}
 	$status->{agent} = 1 if PVE::QemuServer::get_qga_key($conf, 'enabled');
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pve-devel] [PATCH novnc 3/5] added show clipboard button patch to series
  2022-10-20 11:14 [pve-devel] [PATCH qemu-server v2 1/5] enable clipboard parameter in vga_fmt Markus Frank
  2022-10-20 11:14 ` [pve-devel] [PATCH qemu-server 2/5] added clipboard variable to return at status/current Markus Frank
@ 2022-10-20 11:14 ` Markus Frank
  2022-10-20 11:14 ` [pve-devel] [PATCH manager 4/5] added clipboard checkbox to DisplayEdit Markus Frank
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Markus Frank @ 2022-10-20 11:14 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 .../patches/0019-show-clipboard-button.patch  | 31 +++++++++++++++++++
 debian/patches/series                         |  1 +
 2 files changed, 32 insertions(+)
 create mode 100644 debian/patches/0019-show-clipboard-button.patch

diff --git a/debian/patches/0019-show-clipboard-button.patch b/debian/patches/0019-show-clipboard-button.patch
new file mode 100644
index 0000000..fec35e2
--- /dev/null
+++ b/debian/patches/0019-show-clipboard-button.patch
@@ -0,0 +1,31 @@
+From 3808828104af3383e6d20e90ea47983c5cd70c28 Mon Sep 17 00:00:00 2001
+From: Markus Frank <m.frank@proxmox.com>
+Date: Fri, 2 Sep 2022 14:35:34 +0200
+Subject: [PATCH] show clipboard button
+
+show button when clipboard at status/current is true
+
+Signed-off-by: Markus Frank <m.frank@proxmox.com>
+---
+ app/pve.js | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/app/pve.js b/app/pve.js
+index 3eeaa47..697d059 100644
+--- a/app/pve.js
++++ b/app/pve.js
+@@ -411,6 +411,11 @@ PVEUI.prototype = {
+ 			document.getElementById('pve_start_dlg')
+ 			    .classList.add("noVNC_open");
+ 		    }
++		    let clipboard = result.data.clipboard;
++		    if (clipboard) {
++			document.getElementById('noVNC_clipboard_button')
++			    .classList.remove('pve_hidden');
++		    }
+ 		},
+ 		failure: function(msg) {
+ 		    me.UI.showStatus(msg, 'error');
+-- 
+2.30.2
+
diff --git a/debian/patches/series b/debian/patches/series
index ef9e9df..1eb50db 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -17,3 +17,4 @@ extra/0001-Ignore-ResizeObserver-errors.patch
 0016-hide-fullscreen-button-on-isFullscreen-get-variable.patch
 0017-make-error-hideable.patch
 0018-show-start-button-on-not-running-vm-ct.patch
+0019-show-clipboard-button.patch
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pve-devel] [PATCH manager 4/5] added clipboard checkbox to DisplayEdit
  2022-10-20 11:14 [pve-devel] [PATCH qemu-server v2 1/5] enable clipboard parameter in vga_fmt Markus Frank
  2022-10-20 11:14 ` [pve-devel] [PATCH qemu-server 2/5] added clipboard variable to return at status/current Markus Frank
  2022-10-20 11:14 ` [pve-devel] [PATCH novnc 3/5] added show clipboard button patch to series Markus Frank
@ 2022-10-20 11:14 ` Markus Frank
  2022-10-20 11:14 ` [pve-devel] [PATCH docs 5/5] added noVNC clipboard documentation Markus Frank
  2022-10-21 12:45 ` [pve-devel] [PATCH qemu-server v2 1/5] enable clipboard parameter in vga_fmt Dominik Csapak
  4 siblings, 0 replies; 8+ messages in thread
From: Markus Frank @ 2022-10-20 11:14 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 www/manager6/qemu/DisplayEdit.js | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/www/manager6/qemu/DisplayEdit.js b/www/manager6/qemu/DisplayEdit.js
index 9bb1763e..77434b7e 100644
--- a/www/manager6/qemu/DisplayEdit.js
+++ b/www/manager6/qemu/DisplayEdit.js
@@ -33,7 +33,9 @@ Ext.define('PVE.qemu.DisplayInputPanel', {
 		    return;
 		}
 		let memoryfield = this.up('panel').down('field[name=memory]');
+		let clipboardbox = this.up('panel').down('field[name=clipboard]');
 		let disableMemoryField = false;
+		let disableClipboardBox = false;
 
 		if (val === "cirrus") {
 		    memoryfield.setEmptyText("4");
@@ -44,11 +46,13 @@ Ext.define('PVE.qemu.DisplayInputPanel', {
 		} else if (val.match(/^(serial\d|none)$/)) {
 		    memoryfield.setEmptyText("N/A");
 		    disableMemoryField = true;
+		    disableClipboardBox = true;
 		} else {
 		    console.debug("unexpected display type", val);
 		    memoryfield.setEmptyText(Proxmox.Utils.defaultText);
 		}
 		memoryfield.setDisabled(disableMemoryField);
+		clipboardbox.setDisabled(disableClipboardBox);
 	    },
 	},
     },
@@ -60,6 +64,11 @@ Ext.define('PVE.qemu.DisplayInputPanel', {
 	maxValue: 512,
 	step: 4,
 	name: 'memory',
+    },
+    {
+        xtype: 'proxmoxcheckbox',
+        fieldLabel: gettext('noVNC clipboard'),
+        name: 'clipboard',
     }],
 });
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pve-devel] [PATCH docs 5/5] added noVNC clipboard documentation
  2022-10-20 11:14 [pve-devel] [PATCH qemu-server v2 1/5] enable clipboard parameter in vga_fmt Markus Frank
                   ` (2 preceding siblings ...)
  2022-10-20 11:14 ` [pve-devel] [PATCH manager 4/5] added clipboard checkbox to DisplayEdit Markus Frank
@ 2022-10-20 11:14 ` Markus Frank
  2022-10-21 12:47   ` Dominik Csapak
  2022-10-21 12:45 ` [pve-devel] [PATCH qemu-server v2 1/5] enable clipboard parameter in vga_fmt Dominik Csapak
  4 siblings, 1 reply; 8+ messages in thread
From: Markus Frank @ 2022-10-20 11:14 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 qm.adoc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/qm.adoc b/qm.adoc
index 4d0c7c4..38bc788 100644
--- a/qm.adoc
+++ b/qm.adoc
@@ -693,6 +693,14 @@ Selecting `serialX` as display 'type' disables the VGA output, and redirects
 the Web Console to the selected serial port. A configured display 'memory'
 setting will be ignored in that case.
 
+You can enable the noVNC clipboard by setting 'clipboard' to 1.
+To use this, you need to install and enable spice-vdagent on the VM Guest.
+Doing this will give you the ability to use the clipboard button on the left
+side of the noVNC console. However, when using SPICE, the default SPICE clipboard
+implementation will be replaced by the qemu-vdagent implementation, which means
+you cannot simply copy and paste in a SPICE session and instead need to use the
+noVNC Button.
+
 [[qm_usb_passthrough]]
 USB Passthrough
 ~~~~~~~~~~~~~~~
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [pve-devel] [PATCH qemu-server v2 1/5] enable clipboard parameter in vga_fmt
  2022-10-20 11:14 [pve-devel] [PATCH qemu-server v2 1/5] enable clipboard parameter in vga_fmt Markus Frank
                   ` (3 preceding siblings ...)
  2022-10-20 11:14 ` [pve-devel] [PATCH docs 5/5] added noVNC clipboard documentation Markus Frank
@ 2022-10-21 12:45 ` Dominik Csapak
  4 siblings, 0 replies; 8+ messages in thread
From: Dominik Csapak @ 2022-10-21 12:45 UTC (permalink / raw)
  To: Proxmox VE development discussion, Markus Frank

High level comments after playing around with it:

is it really not possible to have c&p working for both novnc and spice?

AFAICS the qemu-vdagent chardev replaces spicevmc, but that means one
can either have c&p in spice OR vnc, but never both at the same time
(shame really, since i don't think it would be much work.. but of course
i'm not very familiar with the qemu code for this)

in that case, i would either:

* not allow to enable this when SPICE is selected as a gpu
or
* make it *very* clear in the ui and documentation that both
   simultaneously don't work (e.g. put a yellow warning under the checkbox)

also, it should be much clearer in the GUI  (and option documentation) that
it's necessary to install the spice client in the guest for this to work.
As it is, we'd get many confused users asking 'why doesn't it work' just
because they don't know it only works with the spice guest tools + a
graphical ui in the vm

A smaller (but important) thing is that i'd like to see a new cfg2cmd test
for new options. it should be enough to enable that option for an existing
test and adapt the output (or make a new test case).




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [pve-devel] [PATCH docs 5/5] added noVNC clipboard documentation
  2022-10-20 11:14 ` [pve-devel] [PATCH docs 5/5] added noVNC clipboard documentation Markus Frank
@ 2022-10-21 12:47   ` Dominik Csapak
  0 siblings, 0 replies; 8+ messages in thread
From: Dominik Csapak @ 2022-10-21 12:47 UTC (permalink / raw)
  To: Proxmox VE development discussion, Markus Frank

comment inline

On 10/20/22 13:14, Markus Frank wrote:
> Signed-off-by: Markus Frank <m.frank@proxmox.com>
> ---
>   qm.adoc | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/qm.adoc b/qm.adoc
> index 4d0c7c4..38bc788 100644
> --- a/qm.adoc
> +++ b/qm.adoc
> @@ -693,6 +693,14 @@ Selecting `serialX` as display 'type' disables the VGA output, and redirects
>   the Web Console to the selected serial port. A configured display 'memory'
>   setting will be ignored in that case.
>   
> +You can enable the noVNC clipboard by setting 'clipboard' to 1.
> +To use this, you need to install and enable spice-vdagent on the VM Guest.
> +Doing this will give you the ability to use the clipboard button on the left
> +side of the noVNC console. However, when using SPICE, the default SPICE clipboard
> +implementation will be replaced by the qemu-vdagent implementation, which means
> +you cannot simply copy and paste in a SPICE session and instead need to use the
> +noVNC Button.

just to note: the novnc menu does not have to be on the left side, it's actually
possible to drag it over to the right side ;) i'd just omit that part and
say 'the clipboard button of the novnc console'

> +
>   [[qm_usb_passthrough]]
>   USB Passthrough
>   ~~~~~~~~~~~~~~~





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pve-devel] [PATCH qemu-server 2/5] added clipboard variable to return at status/current
  2022-09-07  9:17 [pve-devel] [PATCH qemu-server " Markus Frank
@ 2022-09-07  9:17 ` Markus Frank
  0 siblings, 0 replies; 8+ messages in thread
From: Markus Frank @ 2022-09-07  9:17 UTC (permalink / raw)
  To: pve-devel

By that noVNC is able to check if clipboard is active.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 PVE/API2/Qemu.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 99b426e..25f3a1d 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2428,6 +2428,11 @@ __PACKAGE__->register_method({
 		type => 'boolean',
 		optional => 1,
 	    },
+	    clipboard => {
+		description => "Qemu clipboard enabled in config.",
+		type => 'boolean',
+		optional => 1,
+	    },
 	},
     },
     code => sub {
@@ -2446,6 +2451,7 @@ __PACKAGE__->register_method({
 	    my $spice = defined($vga->{type}) && $vga->{type} =~ /^virtio/;
 	    $spice ||= PVE::QemuServer::vga_conf_has_spice($conf->{vga});
 	    $status->{spice} = 1 if $spice;
+	    $status->{clipboard} = $vga->{clipboard};
 	}
 	$status->{agent} = 1 if PVE::QemuServer::get_qga_key($conf, 'enabled');
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-10-21 12:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-20 11:14 [pve-devel] [PATCH qemu-server v2 1/5] enable clipboard parameter in vga_fmt Markus Frank
2022-10-20 11:14 ` [pve-devel] [PATCH qemu-server 2/5] added clipboard variable to return at status/current Markus Frank
2022-10-20 11:14 ` [pve-devel] [PATCH novnc 3/5] added show clipboard button patch to series Markus Frank
2022-10-20 11:14 ` [pve-devel] [PATCH manager 4/5] added clipboard checkbox to DisplayEdit Markus Frank
2022-10-20 11:14 ` [pve-devel] [PATCH docs 5/5] added noVNC clipboard documentation Markus Frank
2022-10-21 12:47   ` Dominik Csapak
2022-10-21 12:45 ` [pve-devel] [PATCH qemu-server v2 1/5] enable clipboard parameter in vga_fmt Dominik Csapak
  -- strict thread matches above, loose matches on Subject: below --
2022-09-07  9:17 [pve-devel] [PATCH qemu-server " Markus Frank
2022-09-07  9:17 ` [pve-devel] [PATCH qemu-server 2/5] added clipboard variable to return at status/current Markus Frank

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal