[pve-devel] [PATCH proxmox-apt 1/2] fallback to Release file for Origin retrieval

2023-04-12 Thread Fabian Grünbichler
APT will not store the InRelease file in some cases, and some repositories
might not even have one in the first place.

Signed-off-by: Fabian Grünbichler 
---
 src/repositories/repository.rs | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/repositories/repository.rs b/src/repositories/repository.rs
index a5e3015..7a19af4 100644
--- a/src/repositories/repository.rs
+++ b/src/repositories/repository.rs
@@ -315,10 +315,13 @@ impl APTRepository {
 pub fn get_cached_origin(&self) -> Result, Error> {
 for uri in self.uris.iter() {
 for suite in self.suites.iter() {
-let file = in_release_filename(uri, suite);
+let mut file = release_filename(uri, suite, false);
 
 if !file.exists() {
-continue;
+file = release_filename(uri, suite, true);
+if !file.exists() {
+continue;
+}
 }
 
 let raw = std::fs::read(&file)
@@ -354,17 +357,19 @@ impl APTRepository {
 }
 }
 
-/// Get the path to the cached InRelease file.
-fn in_release_filename(uri: &str, suite: &str) -> PathBuf {
+/// Get the path to the cached (In)Release file.
+fn release_filename(uri: &str, suite: &str, detached: bool) -> PathBuf {
 let mut path = PathBuf::from(&crate::config::get().dir_state);
 path.push(&crate::config::get().dir_state_lists);
 
-let filename = uri_to_filename(uri);
+let encoded_uri = uri_to_filename(uri);
+let filename = if detached { "Release" } else { "InRelease" };
 
 path.push(format!(
-"{}_dists_{}_InRelease",
-filename,
+"{}_dists_{}_{}",
+encoded_uri,
 suite.replace('/', "_"), // e.g. for buster/updates
+filename,
 ));
 
 path
-- 
2.30.2



___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


[pve-devel] [PATCH proxmox-apt 2/2] fix #4653: (In)Release file: improve handling of special suites

2023-04-12 Thread Fabian Grünbichler
APT doesn't mind a repository with either "/" or "./" as suite/distribution,
such as

 deb https://example.com/debian ./

in that case, the 'dists' part of the URL and the trailing slash (which would
be encoded as '_') is dropped in the file name in '/var/lib/apt/lists/'.

Other suite values with a trailing or leading '/' are rejected with an error by 
APT:

 E: Malformed entry 1 in sources file /etc/apt/sources.list.d/test.list 
(absolute Suite Component)
 E: The list of sources could not be read.

so this should be the only special case requiring handling.

Signed-off-by: Fabian Grünbichler 
---
 src/repositories/repository.rs | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/repositories/repository.rs b/src/repositories/repository.rs
index 7a19af4..ef77186 100644
--- a/src/repositories/repository.rs
+++ b/src/repositories/repository.rs
@@ -365,12 +365,18 @@ fn release_filename(uri: &str, suite: &str, detached: 
bool) -> PathBuf {
 let encoded_uri = uri_to_filename(uri);
 let filename = if detached { "Release" } else { "InRelease" };
 
-path.push(format!(
-"{}_dists_{}_{}",
-encoded_uri,
-suite.replace('/', "_"), // e.g. for buster/updates
-filename,
-));
+if suite == "/" {
+path.push(format!("{encoded_uri}_{filename}"));
+} else if suite == "./" {
+path.push(format!("{encoded_uri}_._{filename}"));
+} else {
+path.push(format!(
+"{}_dists_{}_{}",
+encoded_uri,
+suite.replace('/', "_"), // e.g. for buster/updates
+filename,
+));
+}
 
 path
 }
-- 
2.30.2



___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


[pve-devel] [PATCH pve-network] fix #4662 : frr: fix config generation ordering

2023-04-12 Thread Alexandre Derumier
vrf and router bgp vrf need to be ordered by vrf name

ip protocol need to be at the end

Signed-off-by: Alexandre Derumier 
---
 PVE/Network/SDN/Controllers/BgpPlugin.pm  |  2 +-
 PVE/Network/SDN/Controllers/EvpnPlugin.pm | 67 ---
 .../ebgp_loopback/expected_controller_config  |  3 +-
 .../expected_controller_config|  3 +-
 .../multiplezones/expected_controller_config  | 49 +++
 .../multiplezones/expected_sdn_interfaces | 81 +++
 test/zones/evpn/multiplezones/interfaces  |  7 ++
 test/zones/evpn/multiplezones/sdn_config  | 37 +
 8 files changed, 217 insertions(+), 32 deletions(-)
 create mode 100644 test/zones/evpn/multiplezones/expected_controller_config
 create mode 100644 test/zones/evpn/multiplezones/expected_sdn_interfaces
 create mode 100644 test/zones/evpn/multiplezones/interfaces
 create mode 100644 test/zones/evpn/multiplezones/sdn_config

diff --git a/PVE/Network/SDN/Controllers/BgpPlugin.pm 
b/PVE/Network/SDN/Controllers/BgpPlugin.pm
index 0b8cf1a..e001faa 100644
--- a/PVE/Network/SDN/Controllers/BgpPlugin.pm
+++ b/PVE/Network/SDN/Controllers/BgpPlugin.pm
@@ -119,7 +119,7 @@ sub generate_controller_config {
 
 if ($loopback) {
$config->{frr_prefix_list}->{loopbacks_ips}->{10} = "permit 0.0.0.0/0 
le 32";
-   push(@{$config->{frr}->{''}}, "ip protocol bgp route-map correct_src");
+   push(@{$config->{frr_ip_protocol}}, "ip protocol bgp route-map 
correct_src");
 
my $routemap_config = ();
push @{$routemap_config}, "match ip address prefix-list loopbacks_ips";
diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm 
b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index 9d39b9b..1944178 100644
--- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -247,7 +247,7 @@ sub generate_controller_vnet_config {
my $cidr = $subnet->{cidr};
push @controller_config, "ip route $cidr 10.255.255.2 xvrf_$zoneid";
 }
-push(@{$config->{frr}->{''}}, @controller_config);
+push(@{$config->{frr_ip_protocol}}, @controller_config);
 }
 
 sub on_delete_hook {
@@ -291,41 +291,14 @@ sub find_bgp_controller {
 }
 
 
-sub sort_frr_config {
-my $order = {};
-$order->{''} = 0;
-$order->{'vrf'} = 1;
-$order->{'ipv4 unicast'} = 1;
-$order->{'ipv6 unicast'} = 2;
-$order->{'l2vpn evpn'} = 3;
-
-my $a_val = 100;
-my $b_val = 100;
-
-$a_val = $order->{$a} if defined($order->{$a});
-$b_val = $order->{$b} if defined($order->{$b});
-
-if ($a =~ /bgp (\d+)$/) {
-   $a_val = 2;
-}
-
-if ($b =~ /bgp (\d+)$/) {
-   $b_val = 2;
-}
-
-return $a_val <=> $b_val;
-}
-
 sub generate_frr_recurse{
my ($final_config, $content, $parentkey, $level) = @_;
 
my $keylist = {};
-   $keylist->{vrf} = 1;
$keylist->{'address-family'} = 1;
$keylist->{router} = 1;
 
my $exitkeylist = {};
-   $exitkeylist->{vrf} = 1;
$exitkeylist->{'address-family'} = 1;
 
my $simple_exitkeylist = {};
@@ -343,7 +316,8 @@ sub generate_frr_recurse{
$padding = ' ' x ($paddinglevel) if $paddinglevel;
 
if (ref $content eq  'HASH') {
-   foreach my $key (sort sort_frr_config keys %$content) {
+   foreach my $key (sort keys %$content) {
+   next if $key eq 'vrf';
if ($parentkey && defined($keylist->{$parentkey})) {
push @{$final_config}, $padding."!";
push @{$final_config}, $padding."$parentkey $key";
@@ -364,6 +338,39 @@ sub generate_frr_recurse{
 }
 }
 
+sub generate_frr_vrf {
+   my ($final_config, $vrfs) = @_;
+
+   return if !$vrfs;
+
+   my @config = ();
+
+   foreach my $id (sort keys %$vrfs) {
+   my $vrf = $vrfs->{$id};
+   push @config, "!";
+   push @config, "vrf $id";
+   foreach my $rule (@$vrf) {
+   push @config, " $rule";
+
+   }
+   push @config, "exit-vrf";
+}
+
+push @{$final_config}, @config;
+}
+
+sub generate_frr_ip_protocol {
+   my ($final_config, $ips) = @_;
+
+   return if !$ips;
+
+   my @config = ();
+   push @{$final_config}, "!";
+   foreach my $rule (sort @$ips) {
+   push @{$final_config}, $rule;
+   }
+}
+
 sub generate_frr_routemap {
my ($final_config, $routemaps) = @_;
 
@@ -422,10 +429,12 @@ sub generate_controller_rawconfig {
parse_merge_frr_local_config($config, $local_conf);
 }
 
+generate_frr_vrf($final_config, $config->{frr}->{vrf});
 generate_frr_recurse($final_config, $config->{frr}, undef, 0);
 generate_frr_list($final_config, $config->{frr_access_list}, 
"access-list");
 generate_frr_list($final_config, $config->{frr_prefix_list}, "ip 
prefix-list");
 generate_frr_routemap($final_config, $config->{frr_routemap});
+generate_frr_ip_protocol($final_config, $config->{frr_ip_protocol});
 
 push @{$final_config}, "!";
 push @{$final_config}, "line vty";
diff --git a/test/zones/evpn/ebgp_loopback/expected_control

[pve-devel] [PATCH pve-network] fix #4389 : evpn: exit nodes : null routes subnets from other zones

2023-04-12 Thread Alexandre Derumier
We don't want to routes subnets betwen differents when same exit
node is used

Signed-off-by: Alexandre Derumier 
---
 PVE/Network/SDN/Controllers/EvpnPlugin.pm | 15 ++-
 PVE/Network/SDN/Vnets.pm  |  4 +-
 .../expected_controller_config| 98 +++
 .../exitnodenullroute/expected_sdn_interfaces | 81 +++
 test/zones/evpn/exitnodenullroute/interfaces  |  7 ++
 test/zones/evpn/exitnodenullroute/sdn_config  | 42 
 6 files changed, 242 insertions(+), 5 deletions(-)
 create mode 100644 test/zones/evpn/exitnodenullroute/expected_controller_config
 create mode 100644 test/zones/evpn/exitnodenullroute/expected_sdn_interfaces
 create mode 100644 test/zones/evpn/exitnodenullroute/interfaces
 create mode 100644 test/zones/evpn/exitnodenullroute/sdn_config

diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm 
b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index 1944178..b1eb845 100644
--- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -144,10 +144,23 @@ sub generate_controller_zone_config {
 return if !$vrf || !$vrfvxlan || !$asn;
 
 my ($ifaceip, $interface) = 
PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers, 
$loopback);
+my $is_gateway = $exitnodes->{$local_node};
 
 # vrf
 my @controller_config = ();
 push @controller_config, "vni $vrfvxlan";
+#avoid to routes between nodes through the exit nodes
+#null routes subnets of other zones
+if ($is_gateway) {
+   my $subnets = PVE::Network::SDN::Vnets::get_subnets();
+   foreach my $subnetid (sort keys %{$subnets}) {
+   my $subnet = $subnets->{$subnetid};
+   my $cidr = $subnet->{cidr};
+   my $zone = $subnet->{zone};
+   push @controller_config, "ip route $cidr null0" if $zone ne $id;
+   }
+}
+
 push(@{$config->{frr}->{vrf}->{"$vrf"}}, @controller_config);
 
 #main vrf router
@@ -161,8 +174,6 @@ sub generate_controller_zone_config {
push(@{$config->{frr}->{router}->{"bgp $asn vrf 
$vrf"}->{"address-family"}->{"l2vpn evpn"}}, "route-target export 
$autortas:$vrfvxlan");
 }
 
-my $is_gateway = $exitnodes->{$local_node};
-
 if ($is_gateway) {
 
if (!$exitnodes_primary || $exitnodes_primary eq $local_node) {
diff --git a/PVE/Network/SDN/Vnets.pm b/PVE/Network/SDN/Vnets.pm
index 0b32c58..1106c9f 100644
--- a/PVE/Network/SDN/Vnets.pm
+++ b/PVE/Network/SDN/Vnets.pm
@@ -70,13 +70,11 @@ sub get_vnet {
 sub get_subnets {
 my ($vnetid) = @_;
 
-return if !$vnetid;
-
 my $subnets = undef;
 my $subnets_cfg = PVE::Network::SDN::Subnets::config();
 foreach my $subnetid (sort keys %{$subnets_cfg->{ids}}) {
my $subnet = 
PVE::Network::SDN::Subnets::sdn_subnets_config($subnets_cfg, $subnetid);
-   next if !$subnet->{vnet} || $subnet->{vnet} ne $vnetid;
+   next if !$subnet->{vnet} || ($vnetid && $subnet->{vnet} ne $vnetid);
$subnets->{$subnetid} = $subnet;
 }
 return $subnets;
diff --git a/test/zones/evpn/exitnodenullroute/expected_controller_config 
b/test/zones/evpn/exitnodenullroute/expected_controller_config
new file mode 100644
index 000..f461f1e
--- /dev/null
+++ b/test/zones/evpn/exitnodenullroute/expected_controller_config
@@ -0,0 +1,98 @@
+frr version 8.2.2
+frr defaults datacenter
+hostname localhost
+log syslog informational
+service integrated-vtysh-config
+!
+!
+vrf vrf_myzone
+ vni 1000
+ ip route 172.16.0.0/24 null0
+ ip route 172.16.1.0/24 null0
+exit-vrf
+!
+vrf vrf_myzone2
+ vni 1001
+ ip route 10.0.0.0/24 null0
+exit-vrf
+!
+router bgp 65000
+ bgp router-id 192.168.0.1
+ no bgp default ipv4-unicast
+ coalesce-time 1000
+ neighbor VTEP peer-group
+ neighbor VTEP remote-as 65000
+ neighbor VTEP bfd
+ neighbor 192.168.0.2 peer-group VTEP
+ neighbor 192.168.0.3 peer-group VTEP
+ !
+ address-family ipv4 unicast
+  import vrf vrf_myzone
+  import vrf vrf_myzone2
+ exit-address-family
+ !
+ address-family ipv6 unicast
+  import vrf vrf_myzone
+  import vrf vrf_myzone2
+ exit-address-family
+ !
+ address-family l2vpn evpn
+  neighbor VTEP route-map MAP_VTEP_IN in
+  neighbor VTEP route-map MAP_VTEP_OUT out
+  neighbor VTEP activate
+  advertise-all-vni
+ exit-address-family
+exit
+!
+router bgp 65000 vrf vrf_myzone
+ bgp router-id 192.168.0.1
+ !
+ address-family ipv4 unicast
+  redistribute connected
+ exit-address-family
+ !
+ address-family ipv6 unicast
+  redistribute connected
+ exit-address-family
+ !
+ address-family l2vpn evpn
+  default-originate ipv4
+  default-originate ipv6
+ exit-address-family
+exit
+!
+router bgp 65000 vrf vrf_myzone2
+ bgp router-id 192.168.0.1
+ !
+ address-family ipv4 unicast
+  redistribute connected
+ exit-address-family
+ !
+ address-family ipv6 unicast
+  redistribute connected
+ exit-address-family
+ !
+ address-family l2vpn evpn
+  default-originate ipv4
+  default-originate ipv6
+ exit-address-family
+exit
+!
+route-map 

[pve-devel] [PATCH qemu-server] net: Skip and warn of interfaces without bridge

2023-04-12 Thread Christian Ebner
Handle and warn about network interfaces which are not attached to
any bridge because the user actively removed it from the VM config.

Signed-off-by: Christian Ebner 
---
 PVE/QemuServer.pm | 4 
 1 file changed, 4 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index c1d0fd2..3a6c120 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -8574,6 +8574,10 @@ sub add_nets_bridge_fdb {
}
 
my $bridge = $net->{bridge};
+   if (!$bridge) {
+   log_warn("Interface '$iface' not attached to any bridge.");
+   next;
+   }
if ($have_sdn) {
PVE::Network::SDN::Zones::add_bridge_fdb($iface, $mac, $bridge, 
$net->{firewall});
} elsif (-d "/sys/class/net/$bridge/bridge") { # avoid fdb management 
with OVS for now
-- 
2.30.2



___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] [PATCH docs v5 5/5] added noVNC clipboard documentation

2023-04-12 Thread Markus Frank
Signed-off-by: Markus Frank 
---
 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  -vga ,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



___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] [PATCH novnc v5 3/5] added show clipboard button patch to series

2023-04-12 Thread Markus Frank
Signed-off-by: Markus Frank 
---
 .../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 000..4816450
--- /dev/null
+++ b/debian/patches/0019-show-clipboard-button.patch
@@ -0,0 +1,30 @@
+From  Mon Sep 17 00:00:00 2001
+From: Markus Frank 
+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 
+---
+ 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



___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] [PATCH manager v5 4/5] added clipboard checkbox to VM Options

2023-04-12 Thread Markus Frank
Signed-off-by: Markus Frank 
---
 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



___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] [PATCH qemu-server/manager/novnc/docs v5 0/5] Feature noVNC-Clipboard

2023-04-12 Thread Markus Frank
qemu-server:

changes v5:
* removed return of regex check in the assertion-function for the clipboard 
config
* moved clipboard code into spice-if-block

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   | 68 ++---
 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, 116 insertions(+), 21 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



___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] [PATCH qemu-server v5 1/5] enable clipboard parameter in vga_fmt

2023-04-12 Thread Markus Frank
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 
---
 PVE/API2/Qemu.pm  | 13 +
 PVE/QemuServer.pm | 68 ---
 2 files changed, 60 insertions(+), 21 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 587bb22..9de04cb 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::assert_clipboard_config($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::assert_clipboard_config($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..8a3f7c6 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,14 @@ sub pve_verify_hotplug_features {
 die "unable to parse hotplug option\n";
 }
 
+sub assert_clipboard_config {
+my ($vga) = @_;
+
+if ($vga->{clipboard} && $vga->{type} !~ $clipboardregex) {
+   die "vga type $vga->{type} is not compatible with clipboard\n";
+}
+}
+
 sub scsi_inquiry {
 my($fh, $noerr) = @_;
 
@@ -3933,9 +3949,13 @@ sub config_to_command {
push @$devices, '-device', 
"virtio-rng-pci,rng=rng0$limiter_str$rng_addr";
 }
 
+my $spicedevices = [];
 my $spice_port;
 
-if ($qxlnum || $vga->{type} =~ /^virtio/) {
+assert_clipboard_config($vga);
+
+if ($qxlnum || $vga->{type} =~ /^virtio/
+   || ($vga->{clipboard} && $vga->{type} =~ $clipboardregex)) {
if ($qxlnum > 1) {
if ($winversion){
for (my $i = 1; $i < $qxlnum; $i++){
@@ -3953,34 +3973,40 @@ sub config_to_command {
push @$cmd, '-global', "qxl-vga.vram_size=$vram";
}
}
-
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 @$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,charde

[pve-devel] [PATCH qemu-server v5 2/5] test cases for clipboard spice & std

2023-04-12 Thread Markus Frank
added one test case for a spice display and one for std

Signed-off-by: Markus Frank 
---
 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 000..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 000..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 000..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 000..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



___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] applied: [PATCH manager] configs: blacklist: fix typo

2023-04-12 Thread Thomas Lamprecht
Am 31/03/2023 um 14:45 schrieb Lukas Wagner:
> Signed-off-by: Lukas Wagner 
> ---
>  configs/pve-blacklist.conf | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
>

applied, thanks!


___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] applied: [PATCH manager] api: ceph: mon create: remove superfluous verification call

2023-04-12 Thread Thomas Lamprecht
Am 03/04/2023 um 11:35 schrieb Fiona Ebner:
> The pve_verify_cidr{,v4,v6} functions were originally intended for
> the /etc/network/interfaces API endpoints and thus are a bit
> restrictive. For example, as reported in the community forum[0],
> pve_verify_cidr() does not consider '0::/0' and '0::/1' to be valid.
> 
> The error message in this scenario being
>> value does not look like a valid CIDR network
> is also confusing, as the first thought of users will be that it comes
> from the passed-in monitor address.
> 
> The public networks are not written here and read from the Ceph config
> and via a RADOS mon command, so no need to try and verify them. If
> something really would go wrong during parsing, the
> get_local_ip_from_cidr() call would complain afterwards.
> 
> [0]: https://forum.proxmox.com/threads/125226/
> 
> Suggested-by: Wolfgang Bumiller 
> Signed-off-by: Fiona Ebner 
> ---
>  PVE/API2/Ceph/MON.pm | 4 
>  1 file changed, 4 deletions(-)
> 
>

applied, thanks!


___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] applied: [PATCH manager] fix #4627: ui: backup edit: don't deselect all vms on load

2023-04-12 Thread Thomas Lamprecht
Am 31/03/2023 um 12:03 schrieb Dominik Csapak:
> 'selectPoolMembers' will be called when the poolid field changes.
> (That can even happen when the mode is not even 'pool')
> Due to how the fields are set, there is a race condition that this
> will be called after the remaining fields were set up, including
> the vm list that might have entires selected.
> 
> Since the first thing we do here is to deselect all, this wiped
> the vm selection sometimes.
> 
> To fix it, check if we're actually in the correct mode before doing
> anything.
> 
> Signed-off-by: Dominik Csapak 
> ---
>  www/manager6/dc/Backup.js | 6 ++
>  1 file changed, 6 insertions(+)
> 
>

applied, thanks!


___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] applied: [PATCH widget-toolkit] form: combo grid: use correct method to initialize the picker

2023-04-12 Thread Thomas Lamprecht
Am 31/03/2023 um 12:04 schrieb Dominik Csapak:
> 'createPicker' does create the picker, but not all necessary
> initialization for the combobox (namely it does not set the owner field,
> but that's only an implementation detail). Instead 'getPicker' should be
> used for that, since that does all the necessary initialization and is
> the same function used when trying to open it.
> 
> Without this patch, we leak the picker that was created with this
> call every time a combogrid is created.
> 
> Signed-off-by: Dominik Csapak 
> ---
>  src/form/ComboGrid.js | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
>

applied, but reworded to clarify that the actual issue was that the created
picker was not saved to the field's me.picker state variable (which the
field's doDestroy checks for), thanks!


___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] [PATCH http-server] file upload: don't calculate MD5

2023-04-12 Thread Matthias Heiserer
Until now, we calculated the MD5 hash of any uploaded file during the upload, 
regardless
of whether the user chose to provide a hash sum and algorithm.
The hash was only logged in the syslog.

As the user can provide a hash algorithm and a checksum when uploading a file,
which gets automatically checked (after the upload), this is not needed anymore.
Instead, the file name is logged.

Depending on the speed of the network and the cpu, upload speed or CPU usage 
might improve:
All tests were made by uploading a 3.6GB iso from the PVE host to a local VM.
First line is with md5, second without.

no networklimit
multipart upload complete (size: 3826831360B time: 20.310s rate: 179.69MiB/s 
md5sum: 8c651682056205967d530697c98d98c3)
multipart upload complete (size: 3826831360B time: 16.169s rate: 225.72MiB/s 
filename: ubuntu-22.04.1-desktop-amd64.iso)

125MB/s network
In this test, pveproxy worker used x % CPU during the upload. As you can see, 
the reduced CPU usage is noticable in slower networks.
~75% CPU: multipart upload complete (size: 3826831360B time: 30.764s rate: 
118.63MiB/s md5sum: 8c651682056205967d530697c98d98c3)
~60% CPU: multipart upload complete (size: 3826831360B time: 30.763s rate: 
118.64MiB/s filename: ubuntu-22.04.1-desktop-amd64.iso)

qemu64 cpu, no network limit
multipart upload complete (size: 3826831360B time: 46.113s rate: 79.14MiB/s 
md5sum: 8c651682056205967d530697c98d98c3)
multipart upload complete (size: 3826831360B time: 41.492s rate: 87.96MiB/s 
filename: ubuntu-22.04.1-desktop-amd64.iso)

qemu64, -aes, 1 core, 0.7 cpu
multipart upload complete (size: 3826831360B time: 79.875s rate: 45.69MiB/s 
md5sum: 8c651682056205967d530697c98d98c3)
multipart upload complete (size: 3826831360B time: 66.364s rate: 54.99MiB/s 
filename: ubuntu-22.04.1-desktop-amd64.iso)

Signed-off-by: Matthias Heiserer 
---
 src/PVE/APIServer/AnyEvent.pm | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm
index ac48899..2fa74d2 100644
--- a/src/PVE/APIServer/AnyEvent.pm
+++ b/src/PVE/APIServer/AnyEvent.pm
@@ -1245,15 +1245,14 @@ sub file_upload_multipart {
if ($write_length > 0) {
syswrite($rstate->{outfh}, $data) == $write_length or die 
"write to temporary file failed - $!\n";
$rstate->{bytes} += $write_length;
-   $rstate->{ctx}->add($data);
}
}
 
if ($rstate->{phase} == 100) { # Phase 100 - transfer finished
-   $rstate->{md5sum} = $rstate->{ctx}->hexdigest;
my $elapsed = tv_interval($rstate->{starttime});
-   syslog('info', "multipart upload complete (size: %dB time: %.3fs 
rate: %.2fMiB/s md5sum: %s)",
-   $rstate->{bytes}, $elapsed, $rstate->{bytes} / ($elapsed * 1024 
* 1024), $rstate->{md5sum}
+   syslog('info', "multipart upload complete (size: %dB time: %.3fs 
rate: %.2fMiB/s filename: %s)",
+   $rstate->{bytes}, $elapsed, $rstate->{bytes} / ($elapsed * 1024 
* 1024),
+   $rstate->{params}->{filename}
);
$self->handle_api2_request($reqstate, $auth, $method, $path, 
$rstate);
}
@@ -1563,7 +1562,6 @@ sub authenticate_and_handle_request {
my $state = {
size => $len,
boundary => $boundary,
-   ctx => Digest::MD5->new,
boundlen =>  $boundlen,
maxheader => 2048 + $boundlen, # should be large enough
params => decode_urlencoded($request->url->query()),
-- 
2.30.2



___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel