public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu-server/manager/novnc/docs v4 0/5] Feature noVNC-Clipboard
@ 2023-03-14 11:09 Markus Frank
  2023-03-14 11:09 ` [pve-devel] [PATCH qemu-server v4 1/5] enable clipboard parameter in vga_fmt Markus Frank
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Markus Frank @ 2023-03-14 11:09 UTC (permalink / raw)
  To: pve-devel

qemu-server:

changes v4:
* removed duplicate code and created a spicedevices variable to store
spice/vdagent devices.
* clipboard_check_compatibility function

changes v3:
* added hint to make clearer that the spice guest tools are required for
 the noVNC-clipboard
* Checkbox changes to ComboBox when a spice device is selected to make
 clear that only one clipboard can be used at a time.
* added 2 test-cases

changes v2:
* added pci address to virtio-serial-pci

Markus Frank (2):
  enable clipboard parameter in vga_fmt
  test cases for clipboard spice & std

 PVE/API2/Qemu.pm                            | 13 ++++++
 PVE/QemuServer.pm                           | 47 +++++++++++++++++----
 test/cfg2cmd/noVNC-clipboard-spice.conf     |  1 +
 test/cfg2cmd/noVNC-clipboard-spice.conf.cmd | 27 ++++++++++++
 test/cfg2cmd/noVNC-clipboard-std.conf       |  1 +
 test/cfg2cmd/noVNC-clipboard-std.conf.cmd   | 27 ++++++++++++
 6 files changed, 107 insertions(+), 9 deletions(-)
 create mode 100644 test/cfg2cmd/noVNC-clipboard-spice.conf
 create mode 100644 test/cfg2cmd/noVNC-clipboard-spice.conf.cmd
 create mode 100644 test/cfg2cmd/noVNC-clipboard-std.conf
 create mode 100644 test/cfg2cmd/noVNC-clipboard-std.conf.cmd


novnc-pve:

Markus Frank (1):
  added show clipboard button patch to series

 .../patches/0019-show-clipboard-button.patch  | 30 +++++++++++++++++++
 debian/patches/series                         |  1 +
 2 files changed, 31 insertions(+)
 create mode 100644 debian/patches/0019-show-clipboard-button.patch


pve-manager:

changes v4:
* moved clipboard option from Display settings in Hardware to Options

Markus Frank (1):
  added clipboard checkbox to VM Options

 www/manager6/qemu/DisplayEdit.js |  6 ++++++
 www/manager6/qemu/Options.js     | 34 ++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)


pve-docs:

changes v4:
* rewrote entire Text
* added command example to set clipboard to 1

Markus Frank (1):
  added noVNC clipboard documentation

 qm.adoc | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

-- 
2.30.2





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

* [pve-devel] [PATCH qemu-server v4 1/5] enable clipboard parameter in vga_fmt
  2023-03-14 11:09 [pve-devel] [PATCH qemu-server/manager/novnc/docs v4 0/5] Feature noVNC-Clipboard Markus Frank
@ 2023-03-14 11:09 ` Markus Frank
  2023-04-07 12:25   ` Dominik Csapak
  2023-03-14 11:09 ` [pve-devel] [PATCH qemu-server v4 2/5] test cases for clipboard spice & std Markus Frank
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Markus Frank @ 2023-03-14 11:09 UTC (permalink / raw)
  To: pve-devel

added option 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 on the guest.

added clipboard variable to return at status/current

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

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 PVE/API2/Qemu.pm  | 13 +++++++++++++
 PVE/QemuServer.pm | 47 ++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 587bb22..747eb62 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -970,6 +970,9 @@ __PACKAGE__->register_method({
 			$conf->{boot} = PVE::QemuServer::print_bootorder($devs);
 		    }
 
+		    my $vga = PVE::QemuServer::parse_vga($conf->{vga});
+		    PVE::QemuServer::clipboard_check_compatibility($vga);
+
 		    # auto generate uuid if user did not specify smbios1 option
 		    if (!$conf->{smbios1}) {
 			$conf->{smbios1} = PVE::QemuServer::generate_smbios1_uuid();
@@ -1760,6 +1763,10 @@ my $update_vm_api  = sub {
 			die "only root can modify '$opt' config for real devices\n";
 		    }
 		    $conf->{pending}->{$opt} = $param->{$opt};
+		} elsif ($opt eq 'vga') {
+		    my $vga = PVE::QemuServer::parse_vga($param->{$opt});
+		    PVE::QemuServer::clipboard_check_compatibility($vga);
+		    $conf->{pending}->{$opt} = $param->{$opt};
 		} elsif ($opt =~ m/^usb\d+/) {
 		    if ((!defined($conf->{$opt}) || $conf->{$opt} =~ m/spice/) && $param->{$opt} =~ m/spice/) {
 			$rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.HWType']);
@@ -2580,6 +2587,11 @@ __PACKAGE__->register_method({
 		type => 'boolean',
 		optional => 1,
 	    },
+	    clipboard => {
+		description => "QEMU clipboard for noVNC is enabled in config.",
+		type => 'boolean',
+		optional => 1,
+	    },
 	},
     },
     code => sub {
@@ -2598,6 +2610,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');
 
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 40be44d..461fe8f 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -193,8 +193,16 @@ my $vga_fmt = {
 	minimum => 4,
 	maximum => 512,
     },
+    clipboard => {
+	description => "enable clipboard (requires spice tools in the guest)",
+	type => 'boolean',
+	optional => 1,
+	default => 0
+    }
 };
 
+my $clipboardregex = qr/^(std|cirrus|vmware|virtio|qxl)/;
+
 my $ivshmem_fmt = {
     size => {
 	type => 'integer',
@@ -1405,6 +1413,16 @@ sub pve_verify_hotplug_features {
     die "unable to parse hotplug option\n";
 }
 
+sub clipboard_check_compatibility {
+    my ($vga) = @_;
+
+    if ($vga->{clipboard} && $vga->{type} !~ $clipboardregex) {
+	die "vga type $vga->{type} is not compatible with clipboard\n";
+    }
+
+    return $vga->{type} =~ $clipboardregex;
+}
+
 sub scsi_inquiry {
     my($fh, $noerr) = @_;
 
@@ -3933,6 +3951,21 @@ sub config_to_command {
 	push @$devices, '-device', "virtio-rng-pci,rng=rng0$limiter_str$rng_addr";
     }
 
+    my $clipboardable = clipboard_check_compatibility($vga);
+    my $spicedevices = [];
+
+    if (($vga->{clipboard} && $clipboardable)
+	|| ($vga->{type} =~ /^virtio/ || $qxlnum)) {
+	my $pciaddr = print_pci_addr("spice", $bridges, $arch, $machine_type);
+	push @$spicedevices, '-device', "virtio-serial,id=spice$pciaddr";
+	if ($vga->{clipboard}) {
+	    push @$spicedevices, '-chardev', 'qemu-vdagent,id=vdagent,name=vdagent,clipboard=on';
+	} elsif ($vga->{type} =~ /^virtio/ || $qxlnum) {
+	    push @$spicedevices, '-chardev', 'spicevmc,id=vdagent,name=vdagent';
+	}
+	push @$spicedevices, '-device', "virtserialport,chardev=vdagent,name=com.redhat.spice.0";
+    }
+
     my $spice_port;
 
     if ($qxlnum || $vga->{type} =~ /^virtio/) {
@@ -3954,33 +3987,29 @@ sub config_to_command {
 	    }
 	}
 
-	my $pciaddr = print_pci_addr("spice", $bridges, $arch, $machine_type);
-
 	my $pfamily = PVE::Tools::get_host_address_family($nodename);
 	my @nodeaddrs = PVE::Tools::getaddrinfo_all('localhost', family => $pfamily);
 	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";
-	push @$devices, '-device', "virtserialport,chardev=vdagent,name=com.redhat.spice.0";
-
 	my $localhost = PVE::Network::addr_to_ip($nodeaddrs[0]->{addr});
 	$spice_port = PVE::Tools::next_spice_port($pfamily, $localhost);
 
 	my $spice_enhancement_str = $conf->{spice_enhancements} // '';
 	my $spice_enhancement = parse_property_string($spice_enhancements_fmt, $spice_enhancement_str);
 	if ($spice_enhancement->{foldersharing}) {
-	    push @$devices, '-chardev', "spiceport,id=foldershare,name=org.spice-space.webdav.0";
-	    push @$devices, '-device', "virtserialport,chardev=foldershare,name=org.spice-space.webdav.0";
+	    push @$spicedevices, '-chardev', "spiceport,id=foldershare,name=org.spice-space.webdav.0";
+	    push @$spicedevices, '-device', "virtserialport,chardev=foldershare,name=org.spice-space.webdav.0";
 	}
 
 	my $spice_opts = "tls-port=${spice_port},addr=$localhost,tls-ciphers=HIGH,seamless-migration=on";
 	$spice_opts .= ",streaming-video=$spice_enhancement->{videostreaming}"
 	    if $spice_enhancement->{videostreaming};
 
-	push @$devices, '-spice', "$spice_opts";
+	push @$spicedevices, '-spice', "$spice_opts";
     }
 
+    push @$devices, @$spicedevices;
+
     # enable balloon by default, unless explicitly disabled
     if (!defined($conf->{balloon}) || $conf->{balloon}) {
 	my $pciaddr = print_pci_addr("balloon0", $bridges, $arch, $machine_type);
-- 
2.30.2





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

* [pve-devel] [PATCH qemu-server v4 2/5] test cases for clipboard spice & std
  2023-03-14 11:09 [pve-devel] [PATCH qemu-server/manager/novnc/docs v4 0/5] Feature noVNC-Clipboard Markus Frank
  2023-03-14 11:09 ` [pve-devel] [PATCH qemu-server v4 1/5] enable clipboard parameter in vga_fmt Markus Frank
@ 2023-03-14 11:09 ` Markus Frank
  2023-03-14 11:09 ` [pve-devel] [PATCH novnc v4 3/5] added show clipboard button patch to series Markus Frank
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Markus Frank @ 2023-03-14 11:09 UTC (permalink / raw)
  To: pve-devel

added one test case for a spice display and one for std

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 test/cfg2cmd/noVNC-clipboard-spice.conf     |  1 +
 test/cfg2cmd/noVNC-clipboard-spice.conf.cmd | 27 +++++++++++++++++++++
 test/cfg2cmd/noVNC-clipboard-std.conf       |  1 +
 test/cfg2cmd/noVNC-clipboard-std.conf.cmd   | 27 +++++++++++++++++++++
 4 files changed, 56 insertions(+)
 create mode 100644 test/cfg2cmd/noVNC-clipboard-spice.conf
 create mode 100644 test/cfg2cmd/noVNC-clipboard-spice.conf.cmd
 create mode 100644 test/cfg2cmd/noVNC-clipboard-std.conf
 create mode 100644 test/cfg2cmd/noVNC-clipboard-std.conf.cmd

diff --git a/test/cfg2cmd/noVNC-clipboard-spice.conf b/test/cfg2cmd/noVNC-clipboard-spice.conf
new file mode 100644
index 0000000..d9d933d
--- /dev/null
+++ b/test/cfg2cmd/noVNC-clipboard-spice.conf
@@ -0,0 +1 @@
+vga: qxl,clipboard=1
diff --git a/test/cfg2cmd/noVNC-clipboard-spice.conf.cmd b/test/cfg2cmd/noVNC-clipboard-spice.conf.cmd
new file mode 100644
index 0000000..f24cc7f
--- /dev/null
+++ b/test/cfg2cmd/noVNC-clipboard-spice.conf.cmd
@@ -0,0 +1,27 @@
+/usr/bin/kvm \
+  -id 8006 \
+  -name 'vm8006,debug-threads=on' \
+  -no-shutdown \
+  -chardev 'socket,id=qmp,path=/var/run/qemu-server/8006.qmp,server=on,wait=off' \
+  -mon 'chardev=qmp,mode=control' \
+  -chardev 'socket,id=qmp-event,path=/var/run/qmeventd.sock,reconnect=5' \
+  -mon 'chardev=qmp-event,mode=control' \
+  -pidfile /var/run/qemu-server/8006.pid \
+  -daemonize \
+  -smp '1,sockets=1,cores=1,maxcpus=1' \
+  -nodefaults \
+  -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' \
+  -vnc 'unix:/var/run/qemu-server/8006.vnc,password=on' \
+  -cpu kvm64,enforce,+kvm_pv_eoi,+kvm_pv_unhalt,+lahf_lm,+sep \
+  -m 512 \
+  -device 'pci-bridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e' \
+  -device 'pci-bridge,id=pci.2,chassis_nr=2,bus=pci.0,addr=0x1f' \
+  -device 'piix3-usb-uhci,id=uhci,bus=pci.0,addr=0x1.0x2' \
+  -device 'qxl-vga,id=vga,max_outputs=4,bus=pci.0,addr=0x2' \
+  -device 'virtio-serial,id=spice,bus=pci.0,addr=0x9' \
+  -chardev 'qemu-vdagent,id=vdagent,name=vdagent,clipboard=on' \
+  -device 'virtserialport,chardev=vdagent,name=com.redhat.spice.0' \
+  -spice 'tls-port=61000,addr=127.0.0.1,tls-ciphers=HIGH,seamless-migration=on' \
+  -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3,free-page-reporting=on' \
+  -iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \
+  -machine 'type=pc+pve0'
diff --git a/test/cfg2cmd/noVNC-clipboard-std.conf b/test/cfg2cmd/noVNC-clipboard-std.conf
new file mode 100644
index 0000000..ec84637
--- /dev/null
+++ b/test/cfg2cmd/noVNC-clipboard-std.conf
@@ -0,0 +1 @@
+vga: std,clipboard=1
diff --git a/test/cfg2cmd/noVNC-clipboard-std.conf.cmd b/test/cfg2cmd/noVNC-clipboard-std.conf.cmd
new file mode 100644
index 0000000..c0c6cd2
--- /dev/null
+++ b/test/cfg2cmd/noVNC-clipboard-std.conf.cmd
@@ -0,0 +1,27 @@
+/usr/bin/kvm \
+  -id 8006 \
+  -name 'vm8006,debug-threads=on' \
+  -no-shutdown \
+  -chardev 'socket,id=qmp,path=/var/run/qemu-server/8006.qmp,server=on,wait=off' \
+  -mon 'chardev=qmp,mode=control' \
+  -chardev 'socket,id=qmp-event,path=/var/run/qmeventd.sock,reconnect=5' \
+  -mon 'chardev=qmp-event,mode=control' \
+  -pidfile /var/run/qemu-server/8006.pid \
+  -daemonize \
+  -smp '1,sockets=1,cores=1,maxcpus=1' \
+  -nodefaults \
+  -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' \
+  -vnc 'unix:/var/run/qemu-server/8006.vnc,password=on' \
+  -cpu kvm64,enforce,+kvm_pv_eoi,+kvm_pv_unhalt,+lahf_lm,+sep \
+  -m 512 \
+  -device 'pci-bridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e' \
+  -device 'pci-bridge,id=pci.2,chassis_nr=2,bus=pci.0,addr=0x1f' \
+  -device 'piix3-usb-uhci,id=uhci,bus=pci.0,addr=0x1.0x2' \
+  -device 'usb-tablet,id=tablet,bus=uhci.0,port=1' \
+  -device 'VGA,id=vga,bus=pci.0,addr=0x2' \
+  -device 'virtio-serial,id=spice,bus=pci.0,addr=0x9' \
+  -chardev 'qemu-vdagent,id=vdagent,name=vdagent,clipboard=on' \
+  -device 'virtserialport,chardev=vdagent,name=com.redhat.spice.0' \
+  -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3,free-page-reporting=on' \
+  -iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \
+  -machine 'type=pc+pve0'
-- 
2.30.2





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

* [pve-devel] [PATCH novnc v4 3/5] added show clipboard button patch to series
  2023-03-14 11:09 [pve-devel] [PATCH qemu-server/manager/novnc/docs v4 0/5] Feature noVNC-Clipboard Markus Frank
  2023-03-14 11:09 ` [pve-devel] [PATCH qemu-server v4 1/5] enable clipboard parameter in vga_fmt Markus Frank
  2023-03-14 11:09 ` [pve-devel] [PATCH qemu-server v4 2/5] test cases for clipboard spice & std Markus Frank
@ 2023-03-14 11:09 ` Markus Frank
  2023-03-14 11:09 ` [pve-devel] [PATCH manager v4 4/5] added clipboard checkbox to VM Options Markus Frank
  2023-03-14 11:09 ` [pve-devel] [PATCH docs v4 5/5] added noVNC clipboard documentation Markus Frank
  4 siblings, 0 replies; 7+ messages in thread
From: Markus Frank @ 2023-03-14 11:09 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 .../patches/0019-show-clipboard-button.patch  | 30 +++++++++++++++++++
 debian/patches/series                         |  1 +
 2 files changed, 31 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..4816450
--- /dev/null
+++ b/debian/patches/0019-show-clipboard-button.patch
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Markus Frank <m.frank@proxmox.com>
+Date: Fri, 28 Oct 2022 13:57:57 +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 | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/app/pve.js b/app/pve.js
+index 287615f..93ff4ca 100644
+--- a/app/pve.js
++++ b/app/pve.js
+@@ -411,6 +411,10 @@ PVEUI.prototype = {
+ 			document.getElementById('pve_start_dlg')
+ 			    .classList.add("noVNC_open");
+ 		    }
++		    if (result.data.clipboard) {
++			document.getElementById('noVNC_clipboard_button')
++			    .classList.remove('pve_hidden');
++		    }
+ 		},
+ 		failure: function(msg, code) {
+ 		    if (code === 403) {
+-- 
+2.30.2
+
diff --git a/debian/patches/series b/debian/patches/series
index 085e2b4..212add7 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -16,3 +16,4 @@
 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] 7+ messages in thread

* [pve-devel] [PATCH manager v4 4/5] added clipboard checkbox to VM Options
  2023-03-14 11:09 [pve-devel] [PATCH qemu-server/manager/novnc/docs v4 0/5] Feature noVNC-Clipboard Markus Frank
                   ` (2 preceding siblings ...)
  2023-03-14 11:09 ` [pve-devel] [PATCH novnc v4 3/5] added show clipboard button patch to series Markus Frank
@ 2023-03-14 11:09 ` Markus Frank
  2023-03-14 11:09 ` [pve-devel] [PATCH docs v4 5/5] added noVNC clipboard documentation Markus Frank
  4 siblings, 0 replies; 7+ messages in thread
From: Markus Frank @ 2023-03-14 11:09 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 www/manager6/qemu/DisplayEdit.js |  6 ++++++
 www/manager6/qemu/Options.js     | 34 ++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/www/manager6/qemu/DisplayEdit.js b/www/manager6/qemu/DisplayEdit.js
index 9bb1763e..05f12eed 100644
--- a/www/manager6/qemu/DisplayEdit.js
+++ b/www/manager6/qemu/DisplayEdit.js
@@ -4,6 +4,7 @@ Ext.define('PVE.qemu.DisplayInputPanel', {
     onlineHelp: 'qm_display',
 
     onGetValues: function(values) {
+	values = Ext.apply(this.originalConfig, values);
 	let ret = PVE.Parser.printPropertyString(values, 'type');
 	if (ret === '') {
 	    return { 'delete': 'vga' };
@@ -11,6 +12,11 @@ Ext.define('PVE.qemu.DisplayInputPanel', {
 	return { vga: ret };
     },
 
+    onSetValues: function(values) {
+	this.originalConfig = values;
+	return values;
+    },
+
     items: [{
 	name: 'type',
 	xtype: 'proxmoxKVComboBox',
diff --git a/www/manager6/qemu/Options.js b/www/manager6/qemu/Options.js
index 7b112400..58fd8a65 100644
--- a/www/manager6/qemu/Options.js
+++ b/www/manager6/qemu/Options.js
@@ -154,6 +154,40 @@ Ext.define('PVE.qemu.Options', {
 		    },
 		} : undefined,
 	    },
+	    vga: {
+		header: gettext('Use noVNC clipboard'),
+		defaultValue: false,
+		renderer: function(value) {
+		    let vga = PVE.Parser.parsePropertyString(value, 'type');
+		    return vga.clipboard ? Proxmox.Utils.yesText : Proxmox.Utils.noText;
+		},
+		editor: caps.vms['VM.Config.HWType'] ? {
+		    xtype: 'proxmoxWindowEdit',
+		    subject: gettext('Use noVNC clipboard'),
+		    onlineHelp: 'qm_display',
+		    items: {
+			xtype: 'pveDisplayInputPanel',
+			items: {
+			    xtype: 'proxmoxcheckbox',
+			    name: 'clipboard',
+			    uncheckedValue: 0,
+			    defaultValue: 0,
+			    itemId: 'clipboardBox',
+			    fieldLabel: gettext('Enabled'),
+			},
+			onGetValues: function(values) {
+			    values = Ext.apply(this.originalConfig, values);
+			    PVE.Utils.delete_if_default(values, 'clipboard', 0, 1);
+			    let ret = PVE.Parser.printPropertyString(values, 'type');
+			    return { vga: ret };
+			},
+			onSetValues: function(values) {
+			    this.originalConfig = PVE.Parser.parsePropertyString(values.vga, 'type');
+			    return this.originalConfig;
+			},
+		    },
+		} : undefined,
+	    },
 	    hotplug: {
 		header: gettext('Hotplug'),
 		defaultValue: 'disk,network,usb',
-- 
2.30.2





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

* [pve-devel] [PATCH docs v4 5/5] added noVNC clipboard documentation
  2023-03-14 11:09 [pve-devel] [PATCH qemu-server/manager/novnc/docs v4 0/5] Feature noVNC-Clipboard Markus Frank
                   ` (3 preceding siblings ...)
  2023-03-14 11:09 ` [pve-devel] [PATCH manager v4 4/5] added clipboard checkbox to VM Options Markus Frank
@ 2023-03-14 11:09 ` Markus Frank
  4 siblings, 0 replies; 7+ messages in thread
From: Markus Frank @ 2023-03-14 11:09 UTC (permalink / raw)
  To: pve-devel

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

diff --git a/qm.adoc b/qm.adoc
index bd535a2..6b95518 100644
--- a/qm.adoc
+++ b/qm.adoc
@@ -717,6 +717,23 @@ 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.
 
+.noVNC clipboard
+You can enable the noVNC clipboard by setting `clipboard` to 1.
+
+----
+# qm set <vmid> -vga <displaytype>,clipboard=1
+----
+
+In order to use the clipboard feature, you must first install the
+spice guest tools. On Debian-based distributions, this can be achieved
+by installing `spice-vdagent`.
+
+Once you have installed the spice guest tools, you can use the clipboard
+function in the noVNC console. However, if you're using SPICE, virtio or virgl,
+you'll need to choose which clipboard to use. This is because the
+default *SPICE* clipboard will be replaced by the *noVNC* clipboard,
+if `clipboard` is set to 1.
+
 [[qm_usb_passthrough]]
 USB Passthrough
 ~~~~~~~~~~~~~~~
-- 
2.30.2





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

* Re: [pve-devel] [PATCH qemu-server v4 1/5] enable clipboard parameter in vga_fmt
  2023-03-14 11:09 ` [pve-devel] [PATCH qemu-server v4 1/5] enable clipboard parameter in vga_fmt Markus Frank
@ 2023-04-07 12:25   ` Dominik Csapak
  0 siblings, 0 replies; 7+ messages in thread
From: Dominik Csapak @ 2023-04-07 12:25 UTC (permalink / raw)
  To: Proxmox VE development discussion, Markus Frank

comments inline:

On 3/14/23 12:09, Markus Frank wrote:
> added option 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 on the guest.
> 
> added clipboard variable to return at status/current
> 
> By that noVNC is able to check if clipboard is active.
> 
> Signed-off-by: Markus Frank <m.frank@proxmox.com>
> ---
>   PVE/API2/Qemu.pm  | 13 +++++++++++++
>   PVE/QemuServer.pm | 47 ++++++++++++++++++++++++++++++++++++++---------
>   2 files changed, 51 insertions(+), 9 deletions(-)
> 
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 587bb22..747eb62 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -970,6 +970,9 @@ __PACKAGE__->register_method({
>   			$conf->{boot} = PVE::QemuServer::print_bootorder($devs);
>   		    }
>   
> +		    my $vga = PVE::QemuServer::parse_vga($conf->{vga});
> +		    PVE::QemuServer::clipboard_check_compatibility($vga);
> +
>   		    # auto generate uuid if user did not specify smbios1 option
>   		    if (!$conf->{smbios1}) {
>   			$conf->{smbios1} = PVE::QemuServer::generate_smbios1_uuid();
> @@ -1760,6 +1763,10 @@ my $update_vm_api  = sub {
>   			die "only root can modify '$opt' config for real devices\n";
>   		    }
>   		    $conf->{pending}->{$opt} = $param->{$opt};
> +		} elsif ($opt eq 'vga') {
> +		    my $vga = PVE::QemuServer::parse_vga($param->{$opt});
> +		    PVE::QemuServer::clipboard_check_compatibility($vga);
> +		    $conf->{pending}->{$opt} = $param->{$opt};
>   		} elsif ($opt =~ m/^usb\d+/) {
>   		    if ((!defined($conf->{$opt}) || $conf->{$opt} =~ m/spice/) && $param->{$opt} =~ m/spice/) {
>   			$rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.HWType']);
> @@ -2580,6 +2587,11 @@ __PACKAGE__->register_method({
>   		type => 'boolean',
>   		optional => 1,
>   	    },
> +	    clipboard => {
> +		description => "QEMU clipboard for noVNC is enabled in config.",
> +		type => 'boolean',
> +		optional => 1,
> +	    },
>   	},
>       },
>       code => sub {
> @@ -2598,6 +2610,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');
>   
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 40be44d..461fe8f 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -193,8 +193,16 @@ my $vga_fmt = {
>   	minimum => 4,
>   	maximum => 512,
>       },
> +    clipboard => {
> +	description => "enable clipboard (requires spice tools in the guest)",
> +	type => 'boolean',
> +	optional => 1,
> +	default => 0
> +    }
>   };
>   
> +my $clipboardregex = qr/^(std|cirrus|vmware|virtio|qxl)/;
> +
>   my $ivshmem_fmt = {
>       size => {
>   	type => 'integer',
> @@ -1405,6 +1413,16 @@ sub pve_verify_hotplug_features {
>       die "unable to parse hotplug option\n";
>   }
>   
> +sub clipboard_check_compatibility {
> +    my ($vga) = @_;
> +
> +    if ($vga->{clipboard} && $vga->{type} !~ $clipboardregex) {
> +	die "vga type $vga->{type} is not compatible with clipboard\n";
> +    }
> +
> +    return $vga->{type} =~ $clipboardregex;
> +}

not really a fan of this function. it basically does two things at once
in a non-obvious way:

1. it asserts that the vga config is valid
2. it returns if the type would be compatible with the clipboard setting

my suggestion would be to have 2 methods here (disregard the names, were
just the first ones that came to mind, we should find better ones)

----8<----
# returns if the vga type can have the clipboard setting on
sub can_have_clipboard {
my ($type) = @_;
...
}

# dies if the vga setting regarding clipboard is invalid
sub assert_valid_clipboard_setting {
my ($vga) = @_;
...
}
---->8----

the assert method can ofc call the first one to check for that

> +
>   sub scsi_inquiry {
>       my($fh, $noerr) = @_;
>   
> @@ -3933,6 +3951,21 @@ sub config_to_command {
>   	push @$devices, '-device', "virtio-rng-pci,rng=rng0$limiter_str$rng_addr";
>       }
>   
> +    my $clipboardable = clipboard_check_compatibility($vga);

since you use that only one time, you could inline it in the if condition

> +    my $spicedevices = [];
> +
> +    if (($vga->{clipboard} && $clipboardable)
> +	|| ($vga->{type} =~ /^virtio/ || $qxlnum)) {
> +	my $pciaddr = print_pci_addr("spice", $bridges, $arch, $machine_type);
> +	push @$spicedevices, '-device', "virtio-serial,id=spice$pciaddr";
> +	if ($vga->{clipboard}) {
> +	    push @$spicedevices, '-chardev', 'qemu-vdagent,id=vdagent,name=vdagent,clipboard=on';
> +	} elsif ($vga->{type} =~ /^virtio/ || $qxlnum) {
> +	    push @$spicedevices, '-chardev', 'spicevmc,id=vdagent,name=vdagent';
> +	}
> +	push @$spicedevices, '-device', "virtserialport,chardev=vdagent,name=com.redhat.spice.0";
> +    }

i get why you did it this way (i assume to keep the order of the devices the same)
but i think there is a better way

if the code enters the below block, it will always have entered above block

so if we modify the condition to the block below to include
'$vga->{clipboard} && $clipboardable', then we only have to put the few spice related things
into their own 'if (qxlnum....' block and we can scrape the spicedevices list and
simply push into the devices one

so i'd imagine the finished code to look like this:

if ($qxlnum || $vga... || ($vga->{clipboard} && $clipboardable) {
     if  ($qxlnum > 1) {
         ....
     }

    <code from above block here>

     if (qxlnum || $vga...) {
         ....
     }
)

in that case we might want to have a seperate function to check for
spice, then we don't have to have 2 conditions in sync

> +
>       my $spice_port;
>   
>       if ($qxlnum || $vga->{type} =~ /^virtio/) {
> @@ -3954,33 +3987,29 @@ sub config_to_command {
>   	    }
>   	}
>   
> -	my $pciaddr = print_pci_addr("spice", $bridges, $arch, $machine_type);
> -
>   	my $pfamily = PVE::Tools::get_host_address_family($nodename);
>   	my @nodeaddrs = PVE::Tools::getaddrinfo_all('localhost', family => $pfamily);
>   	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";
> -	push @$devices, '-device', "virtserialport,chardev=vdagent,name=com.redhat.spice.0";
> -
>   	my $localhost = PVE::Network::addr_to_ip($nodeaddrs[0]->{addr});
>   	$spice_port = PVE::Tools::next_spice_port($pfamily, $localhost);
>   
>   	my $spice_enhancement_str = $conf->{spice_enhancements} // '';
>   	my $spice_enhancement = parse_property_string($spice_enhancements_fmt, $spice_enhancement_str);
>   	if ($spice_enhancement->{foldersharing}) {
> -	    push @$devices, '-chardev', "spiceport,id=foldershare,name=org.spice-space.webdav.0";
> -	    push @$devices, '-device', "virtserialport,chardev=foldershare,name=org.spice-space.webdav.0";
> +	    push @$spicedevices, '-chardev', "spiceport,id=foldershare,name=org.spice-space.webdav.0";
> +	    push @$spicedevices, '-device', "virtserialport,chardev=foldershare,name=org.spice-space.webdav.0";
>   	}
>   
>   	my $spice_opts = "tls-port=${spice_port},addr=$localhost,tls-ciphers=HIGH,seamless-migration=on";
>   	$spice_opts .= ",streaming-video=$spice_enhancement->{videostreaming}"
>   	    if $spice_enhancement->{videostreaming};
>   
> -	push @$devices, '-spice', "$spice_opts";
> +	push @$spicedevices, '-spice', "$spice_opts";
>       }
>   
> +    push @$devices, @$spicedevices;
> +
>       # enable balloon by default, unless explicitly disabled
>       if (!defined($conf->{balloon}) || $conf->{balloon}) {
>   	my $pciaddr = print_pci_addr("balloon0", $bridges, $arch, $machine_type);





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

end of thread, other threads:[~2023-04-07 12:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-14 11:09 [pve-devel] [PATCH qemu-server/manager/novnc/docs v4 0/5] Feature noVNC-Clipboard Markus Frank
2023-03-14 11:09 ` [pve-devel] [PATCH qemu-server v4 1/5] enable clipboard parameter in vga_fmt Markus Frank
2023-04-07 12:25   ` Dominik Csapak
2023-03-14 11:09 ` [pve-devel] [PATCH qemu-server v4 2/5] test cases for clipboard spice & std Markus Frank
2023-03-14 11:09 ` [pve-devel] [PATCH novnc v4 3/5] added show clipboard button patch to series Markus Frank
2023-03-14 11:09 ` [pve-devel] [PATCH manager v4 4/5] added clipboard checkbox to VM Options Markus Frank
2023-03-14 11:09 ` [pve-devel] [PATCH docs v4 5/5] added noVNC clipboard documentation 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