From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 0ED9AA0E99 for ; Fri, 10 Nov 2023 10:34:20 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D309C1D85F for ; Fri, 10 Nov 2023 10:33:49 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 10 Nov 2023 10:33:49 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id D187247A89; Fri, 10 Nov 2023 10:33:48 +0100 (CET) Message-ID: Date: Fri, 10 Nov 2023 10:33:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta To: Proxmox VE development discussion , Markus Frank References: <20230921114758.352377-1-m.frank@proxmox.com> <20230921114758.352377-2-m.frank@proxmox.com> Content-Language: en-US From: Dominik Csapak In-Reply-To: <20230921114758.352377-2-m.frank@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.017 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemuserver.pm, qemu.pm] Subject: Re: [pve-devel] [PATCH qemu-sever v13 1/6] enable VNC clipboard parameter in vga_fmt X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Nov 2023 09:34:20 -0000 one nit inline: On 9/21/23 13:47, Markus Frank wrote: > add option to use the qemu vdagent implementation to enable the VNC > 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. > > Signed-off-by: Markus Frank > --- > PVE/API2/Qemu.pm | 7 +++++ > PVE/QemuServer.pm | 66 ++++++++++++++++++++++++++++++++++------------- > 2 files changed, 55 insertions(+), 18 deletions(-) > > diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm > index 9606e72..8a2fdef 100644 > --- a/PVE/API2/Qemu.pm > +++ b/PVE/API2/Qemu.pm > @@ -1034,6 +1034,9 @@ __PACKAGE__->register_method({ > $conf->{boot} = PVE::QemuServer::print_bootorder($devs); > } > > + my $vga = PVE::QemuServer::parse_vga($conf->{vga}); > + PVE::QemuServer::assert_clipboard_config($vga); > + > # auto generate uuid if user did not specify smbios1 option > if (!$conf->{smbios1}) { > $conf->{smbios1} = PVE::QemuServer::generate_smbios1_uuid(); > @@ -1856,6 +1859,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::assert_clipboard_config($vga); > + $conf->{pending}->{$opt} = $param->{$opt}; > } elsif ($opt =~ m/^usb\d+/) { > if (my $olddevice = $conf->{$opt}) { > check_usb_perm($rpcenv, $authuser, $vmid, undef, $opt, $conf->{$opt}); > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm > index bf1de17..2b84ed8 100644 > --- a/PVE/QemuServer.pm > +++ b/PVE/QemuServer.pm > @@ -195,6 +195,13 @@ my $vga_fmt = { > minimum => 4, > maximum => 512, > }, > + clipboard => { > + description => 'Enable a specific clipboard. If not set, depending on' > + .' the display type the SPICE one will be added.', > + type => 'string', > + enum => ['vnc'], > + optional => 1, > + }, > }; > > my $ivshmem_fmt = { > @@ -1375,6 +1382,21 @@ sub pve_verify_hotplug_features { > die "unable to parse hotplug option\n"; > } > > +sub assert_clipboard_config { > + my ($vga) = @_; > + > + my $clipboard_regex = qr/^(std|cirrus|vmware|virtio|qxl)/; > + > + if ( > + $vga->{'clipboard'} > + && $vga->{'clipboard'} eq 'vnc' > + && $vga->{type} > + && $vga->{type} !~ $clipboard_regex nit: there are trailing spaces here > + ) { > + die "vga type $vga->{type} is not compatible with VNC clipboard\n"; > + } > +} > + > sub scsi_inquiry { > my($fh, $noerr) = @_; > > @@ -3945,7 +3967,10 @@ sub config_to_command { > > my $spice_port; > > - if ($qxlnum || $vga->{type} =~ /^virtio/) { > + assert_clipboard_config($vga); > + my $is_spice = $qxlnum || $vga->{type} =~ /^virtio/; > + > + if ($is_spice || ($vga->{'clipboard'} && $vga->{'clipboard'} eq 'vnc')) { > if ($qxlnum > 1) { > if ($winversion){ > for (my $i = 1; $i < $qxlnum; $i++){ > @@ -3966,29 +3991,34 @@ 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"; > + if ($vga->{'clipboard'} && $vga->{'clipboard'} eq 'vnc') { > + 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}); > - $spice_port = PVE::Tools::next_spice_port($pfamily, $localhost); > + if ($is_spice) { > + 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; > > - 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"; > - } > + my $localhost = PVE::Network::addr_to_ip($nodeaddrs[0]->{addr}); > + $spice_port = PVE::Tools::next_spice_port($pfamily, $localhost); > > - 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}; > + 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 @$devices, '-spice', "$spice_opts"; > + 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"; > + } > } > > # enable balloon by default, unless explicitly disabled