[pve-devel] applied: [PATCH widget-toolkit] Add hebrew to list of languages

2019-09-03 Thread Thomas Lamprecht
On 23.08.19 11:30, Dominic Jäger wrote:
> Signed-off-by: Dominic Jäger 
> ---
> Tested on PVE and PMG.
> 
>  Utils.js | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/Utils.js b/Utils.js
> index 9b62bf6..533272d 100644
> --- a/Utils.js
> +++ b/Utils.js
> @@ -76,7 +76,8 @@ Ext.define('Proxmox.Utils', { utilities: {
>   ru: 'Russian',
>   sl: 'Slovenian',
>   sv: 'Swedish',
> - tr: 'Turkish'
> + tr: 'Turkish',
> + he: 'Hebrew',
>  },
>  
>  render_language: function (value) {
> 

applied, thanks!


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


Re: [pve-devel] [PATCH v2 storage 1/2] fix #2216: Allow .img files in 'iso' type storages

2019-09-03 Thread Thomas Lamprecht
On 22.08.19 14:39, Stefan Reiter wrote:
> To maintain full (backwards) compatibility, leave the type name as
> 'iso' - this makes this patch work without changing every consumer of
> storage APIs.
> 
> Note that currently these files can only be attached as a CDROM/DVD
> drive, so USB-only images can be uploaded but might not work in VMs.
> 
> Signed-off-by: Stefan Reiter 
> ---
> 
> v1 -> v2:
> * Refactored regex into variable
> 
> I left the [Ii][Ss]... since we don't know if the variable is used with //i
> or not.

1. used my instead of our scope, but used the variable in another module,
   that cannot work... Now it was poassed a undefined regex value to all
   out-of-module users and thus the ending wasn't checked at all anymore,
   effectively allowing all endings..

2. You could just added the case insensitive flag to the base regex?

perl -we 'my $re = qr/foo/i; "Foo" =~ /^$re/ or die "not matched\n"'
works just fine...

Applied, with 1. and 2. fixed as followup...

> 
>  PVE/API2/Storage/Status.pm | 4 ++--
>  PVE/Storage.pm | 4 +++-
>  PVE/Storage/Plugin.pm  | 4 ++--
>  3 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/PVE/API2/Storage/Status.pm b/PVE/API2/Storage/Status.pm
> index ce7e040..91946ac 100644
> --- a/PVE/API2/Storage/Status.pm
> +++ b/PVE/API2/Storage/Status.pm
> @@ -408,8 +408,8 @@ __PACKAGE__->register_method ({
>   my $path;
>  
>   if ($content eq 'iso') {
> - if ($filename !~ m![^/]+\.[Ii][Ss][Oo]$!) {
> - raise_param_exc({ filename => "missing '.iso' extension" });
> + if ($filename !~ m![^/]+$PVE::Storage::iso_extension_re$!) {
> + raise_param_exc({ filename => "missing '.iso' or '.img' 
> extension" });
>   }
>   $path = PVE::Storage::get_iso_dir($cfg, $param->{storage});
>   } elsif ($content eq 'vztmpl') {
> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
> index 755eca8..08b6e14 100755
> --- a/PVE/Storage.pm
> +++ b/PVE/Storage.pm
> @@ -99,6 +99,8 @@ PVE::Storage::Plugin->init();
>  
>  my $UDEVADM = '/sbin/udevadm';
>  
> +my $iso_extension_re = qr/\.(?:[Ii][Ss][Oo]|[Ii][Mm][Gg])/;
> +
>  #  PVE::Storage utility functions
>  
>  sub config {
> @@ -501,7 +503,7 @@ sub path_to_volume_id {
>   return ('images', $info->{volid});
>   }
>   }
> - } elsif ($path =~ m!^$isodir/([^/]+\.[Ii][Ss][Oo])$!) {
> + } elsif ($path =~ m!^$isodir/([^/]+$iso_extension_re)$!) {
>   my $name = $1;
>   return ('iso', "$sid:iso/$name");
>   } elsif ($path =~ m!^$tmpldir/([^/]+\.tar\.gz)$!) {
> diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
> index 27f832f..9a419f1 100644
> --- a/PVE/Storage/Plugin.pm
> +++ b/PVE/Storage/Plugin.pm
> @@ -415,7 +415,7 @@ sub parse_volname {
>   my ($vmid, $name) = ($1, $2);
>   my (undef, $format, $isBase) = parse_name_dir($name);
>   return ('images', $name, $vmid, undef, undef, $isBase, $format);
> -} elsif ($volname =~ m!^iso/([^/]+\.[Ii][Ss][Oo])$!) {
> +} elsif ($volname =~ m!^iso/([^/]+$PVE::Storage::iso_extension_re)$!) {
>   return ('iso', $1);
>  } elsif ($volname =~ m!^vztmpl/([^/]+\.tar\.[gx]z)$!) {
>   return ('vztmpl', $1);
> @@ -915,7 +915,7 @@ my $get_subdir_files = sub {
>   my $info;
>  
>   if ($tt eq 'iso') {
> - next if $fn !~ m!/([^/]+\.iso)$!i;
> + next if $fn !~ m!/([^/]+$PVE::Storage::iso_extension_re)$!i;
>  
>   $info = { volid => "$sid:iso/$1", format => 'iso' };
>  
> 


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


[pve-devel] applied: [PATCH v2 manager 2/2] Show supported file types in upload file selector

2019-09-03 Thread Thomas Lamprecht
On 22.08.19 14:39, Stefan Reiter wrote:
> By default, all file types are shown, but the user now has the option of
> filtering only by supported types in the file selector dialog.
> 
> Signed-off-by: Stefan Reiter 
> Acked-by: Dominik Csapak 
> ---
> 
> I found it weird too, but also couldn't find a different way to go about it...
> 
>  www/manager6/storage/ContentView.js | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/www/manager6/storage/ContentView.js 
> b/www/manager6/storage/ContentView.js
> index 3677f8ad..b72fc88d 100644
> --- a/www/manager6/storage/ContentView.js
> +++ b/www/manager6/storage/ContentView.js
> @@ -218,7 +218,14 @@ Ext.define('PVE.storage.Upload', {
>   xtype: 'filefield',
>   name: 'filename',
>   buttonText: gettext('Select File...'),
> - allowBlank: false
> + allowBlank: false,
> + listeners: {
> + afterrender: function(cmp) {
> + cmp.fileInputEl.set({
> + accept: '.img, .iso'
> + });
> + }
> + }
>   },
>   pbar
>   ]
> 

applied, but this is not case insensitive..

If that's not easily possible to do as single flag, I'd maybe
add .IMG and .ISO to cover at least most reasonable cases.

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


Re: [pve-devel] applied: [PATCH v2 manager 2/2] Show supported file types in upload file selector

2019-09-03 Thread Stefan Reiter

On 9/3/19 9:53 AM, Thomas Lamprecht wrote:

On 22.08.19 14:39, Stefan Reiter wrote:

By default, all file types are shown, but the user now has the option of
filtering only by supported types in the file selector dialog.

Signed-off-by: Stefan Reiter 
Acked-by: Dominik Csapak 
---

I found it weird too, but also couldn't find a different way to go about it...

  www/manager6/storage/ContentView.js | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/www/manager6/storage/ContentView.js 
b/www/manager6/storage/ContentView.js
index 3677f8ad..b72fc88d 100644
--- a/www/manager6/storage/ContentView.js
+++ b/www/manager6/storage/ContentView.js
@@ -218,7 +218,14 @@ Ext.define('PVE.storage.Upload', {
xtype: 'filefield',
name: 'filename',
buttonText: gettext('Select File...'),
-   allowBlank: false
+   allowBlank: false,
+   listeners: {
+   afterrender: function(cmp) {
+   cmp.fileInputEl.set({
+   accept: '.img, .iso'
+   });
+   }
+   }
},
pbar
]



applied, but this is not case insensitive..

If that's not easily possible to do as single flag, I'd maybe
add .IMG and .ISO to cover at least most reasonable cases.



It ignores casing for me... Tested on Chromium 76 and Firefox 70.

And thanks for the fixup on the other patch, didn't know partial regexes 
could have their own flags.


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


[pve-devel] [PATCH ifupdown2] add patch to add arp-accept option

2019-09-03 Thread Alexandre Derumier
needed for bgp-evpn

upstream pull request:
https://github.com/CumulusNetworks/ifupdown2/pull/121

Signed-off-by: Alexandre Derumier 
---
 .../pve/0009-add-arp-accept-option.patch  | 55 +++
 debian/patches/series |  1 +
 2 files changed, 56 insertions(+)
 create mode 100644 debian/patches/pve/0009-add-arp-accept-option.patch

diff --git a/debian/patches/pve/0009-add-arp-accept-option.patch 
b/debian/patches/pve/0009-add-arp-accept-option.patch
new file mode 100644
index 000..dd27ffb
--- /dev/null
+++ b/debian/patches/pve/0009-add-arp-accept-option.patch
@@ -0,0 +1,55 @@
+From 45db39f606e09486889128b93f1942639620d2aa Mon Sep 17 00:00:00 2001
+From: Alexandre Derumier 
+Date: Tue, 3 Sep 2019 09:43:38 +0200
+Subject: [PATCH] add arp-accept option.
+
+Currently, the only way to enable arp-accept is to enable
+a policy with l3_intf_arp_accept.
+
+But this enable arp-accept for all bridges.
+
+This option allow to define it for specific bridge.
+
+This is needed with bgp-evpn and vm migration
+https://github.com/FRRouting/frr/issues/4904
+---
+ ifupdown2/addons/address.py | 9 -
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/ifupdown2/addons/address.py b/ifupdown2/addons/address.py
+index f576dc0..762c58c 100644
+--- a/ifupdown2/addons/address.py
 b/ifupdown2/addons/address.py
+@@ -96,6 +96,11 @@ class address(moduleBase):
+   'dual connected VxLANs',
+   'validvals' : ['', ],
+   'example'  : ['clagd-vxlan-anycast-ip 
36.0.0.11']},
++  'arp-accept' :
++{ 'help': 'Allow gratuitous arp to update arp 
table',
++  'validvals': ['on', 'off', 'yes', 'no', '0', 
'1'],
++  'default' : 'off',
++  'example' : ['arp-accept on']},
+   'ip-forward' :
+ { 'help': 'ip forwarding flag',
+   'validvals': ['on', 'off', 'yes', 'no', '0', 
'1'],
+@@ -272,6 +277,8 @@ class address(moduleBase):
+ def _process_bridge(self, ifaceobj, up):
+ hwaddress = self._get_hwaddress(ifaceobj)
+ addrs = ifaceobj.get_attr_value_first('address')
++arp_accept = ifaceobj.get_attr_value_first('arp-accept')
++arp_accept = utils.boolean_support_binary(arp_accept)
+ is_vlan_dev_on_vlan_aware_bridge = False
+ is_bridge = self.ipcmd.is_bridge(ifaceobj.name)
+ if not is_bridge:
+@@ -290,7 +297,7 @@ class address(moduleBase):
+ self.write_file('/proc/sys/net/ipv4/conf/%s' % 
ifaceobj.name +
+ '/arp_accept', '0')
+ else:
+-self.write_file('/proc/sys/net/ipv4/conf/%s/arp_accept' % 
ifaceobj.name, '0')
++self.write_file('/proc/sys/net/ipv4/conf/%s/arp_accept' % 
ifaceobj.name, arp_accept)
+ if hwaddress and is_vlan_dev_on_vlan_aware_bridge:
+if up:
+   self.ipcmd.bridge_fdb_add(bridgename, hwaddress, vlan)
+-- 
+2.20.1
+
diff --git a/debian/patches/series b/debian/patches/series
index feea3bc..a66998f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -6,3 +6,4 @@ pve/0005-don-t-remove-bridge-is-tap-veth-are-still-plugged.patch
 pve/0006-add-uplink-id-option.patch
 pve/0007-ifreload-down-up-vxlan-interfaces-when-ifreload_down.patch
 pve/0008-config-tuning.patch
+pve/0009-add-arp-accept-option.patch
-- 
2.20.1

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


[pve-devel] [PATCH storage v2] Fix #2346: rbd storage shows wrong %-usage

2019-09-03 Thread Alwin Antreich
The patch uses the value from the field 'stored' if it is available.

In Ceph 14.2.2 the storage calculation changed to a per pool basis. This
introduced an additional field 'stored' that holds the amount of data
that has been written to the pool. While the field 'used' now has the
data after replication for the pool.

The new calculation will be used only if all OSDs are running with the
on-disk format introduced by Ceph 14.2.2.

Signed-off-by: Alwin Antreich 
---
v1 -> v2: checks now if key is defined and not for just truth

 PVE/Storage/RBDPlugin.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 8433715..214b732 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -521,7 +521,7 @@ sub status {
 # max_avail -> max available space for data w/o replication in the pool
 # bytes_used -> data w/o replication in the pool
 my $free = $d->{stats}->{max_avail};
-my $used = $d->{stats}->{bytes_used};
+my $used = $d->{stats}->{stored} // $d->{stats}->{bytes_used};
 my $total = $used + $free;
 my $active = 1;
 
-- 
2.20.1


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


Re: [pve-devel] applied: [PATCH v2 manager 2/2] Show supported file types in upload file selector

2019-09-03 Thread Thomas Lamprecht
On 03.09.19 10:06, Stefan Reiter wrote:
> On 9/3/19 9:53 AM, Thomas Lamprecht wrote:
>> On 22.08.19 14:39, Stefan Reiter wrote:
>>> By default, all file types are shown, but the user now has the option of
>>> filtering only by supported types in the file selector dialog.
>>>
>>> Signed-off-by: Stefan Reiter 
>>> Acked-by: Dominik Csapak 
>>> ---
>>>
>>> I found it weird too, but also couldn't find a different way to go about 
>>> it...
>>>
>>>   www/manager6/storage/ContentView.js | 9 -
>>>   1 file changed, 8 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/www/manager6/storage/ContentView.js 
>>> b/www/manager6/storage/ContentView.js
>>> index 3677f8ad..b72fc88d 100644
>>> --- a/www/manager6/storage/ContentView.js
>>> +++ b/www/manager6/storage/ContentView.js
>>> @@ -218,7 +218,14 @@ Ext.define('PVE.storage.Upload', {
>>>   xtype: 'filefield',
>>>   name: 'filename',
>>>   buttonText: gettext('Select File...'),
>>> -    allowBlank: false
>>> +    allowBlank: false,
>>> +    listeners: {
>>> +    afterrender: function(cmp) {
>>> +    cmp.fileInputEl.set({
>>> +    accept: '.img, .iso'
>>> +    });
>>> +    }
>>> +    }
>>>   },
>>>   pbar
>>>   ]
>>>
>>
>> applied, but this is not case insensitive..
>>
>> If that's not easily possible to do as single flag, I'd maybe
>> add .IMG and .ISO to cover at least most reasonable cases.
>>
> 
> It ignores casing for me... Tested on Chromium 76 and Firefox 70.

It does not depend on the internet browser but on the file browser used, AFAICT.
But yes, I had a bad test here, Thunar seems to work fine indeed.

> 
> And thanks for the fixup on the other patch, didn't know partial regexes 
> could have their own flags.

# perldoc perlretut
# perldoc perlre
and https://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators

are good references, there's really a lot possible with perl regular
expressions :)


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


[pve-devel] applied: [PATCH storage v2] Fix #2346: rbd storage shows wrong %-usage

2019-09-03 Thread Thomas Lamprecht
On 03.09.19 10:13, Alwin Antreich wrote:
> The patch uses the value from the field 'stored' if it is available.
> 
> In Ceph 14.2.2 the storage calculation changed to a per pool basis. This
> introduced an additional field 'stored' that holds the amount of data
> that has been written to the pool. While the field 'used' now has the
> data after replication for the pool.
> 
> The new calculation will be used only if all OSDs are running with the
> on-disk format introduced by Ceph 14.2.2.
> 
> Signed-off-by: Alwin Antreich 
> ---
> v1 -> v2: checks now if key is defined and not for just truth
> 
>  PVE/Storage/RBDPlugin.pm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
> index 8433715..214b732 100644
> --- a/PVE/Storage/RBDPlugin.pm
> +++ b/PVE/Storage/RBDPlugin.pm
> @@ -521,7 +521,7 @@ sub status {
>  # max_avail -> max available space for data w/o replication in the pool
>  # bytes_used -> data w/o replication in the pool
>  my $free = $d->{stats}->{max_avail};
> -my $used = $d->{stats}->{bytes_used};
> +my $used = $d->{stats}->{stored} // $d->{stats}->{bytes_used};
>  my $total = $used + $free;
>  my $active = 1;
>  
> 

applied, thanks!

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


Re: [pve-devel] applied-series: [PATCH v2 pve-network 00/13] pve-network improvements

2019-09-03 Thread Alexandre DERUMIER
Hi,

>>I updated the mirror to current master, and pushed out the frr-7.1 frr-7.0.1 
>>and frr-6.0.3 tags, so ideally we'd update it to 7.1 if you say that's 
>>working 
>>good for this. 

I have found a bug in 7.1 tag release,
It's currently fixed in the stable/7.1 branch

https://github.com/FRRouting/frr/issues/4905

Not sure if you want to wait for 7.1.1 or 7.2 ?


- Mail original -
De: "Thomas Lamprecht" 
À: "pve-devel" , "aderumier" 
Envoyé: Mardi 3 Septembre 2019 08:38:03
Objet: applied-series: [pve-devel] [PATCH v2 pve-network 00/13] pve-network 
improvements

Hi, 

On 29.08.19 12:32, Alexandre Derumier wrote: 
> pve-network is now able to generate bgp evpn configuration, 
> so we have a true anycast routable vxlan sdn now :) 

great! 

> 
> It's still missing configuration for outside gateway, 
> but 2vms in 2differents vnet/subnet should be already able to communicate. 
> 
> Frr6 from debian buster official repo seem to be buggy, 
> but it's working with frr7 buster deb from https://deb.frrouting.org/ 
> 
> Here the packages: 
> https://deb.frrouting.org/frr/pool/frr-stable/f/frr/frr_7.1-1~deb10u1_amd64.deb
>  
> https://deb.frrouting.org/frr/pool/frr-stable/f/frr/frr-pythontools_7.1-1~deb10u1_all.deb
>  
> (pythontools is needed for frr reload) 

So, we have our own FRR package, but it did not got updated in the last 7 
months.. Would you like to take a look at this, or should I give it a try, 
either myself or maybe "convinging" someone else here :) 

Packasge repo is here: https://git.proxmox.com/?p=frr.git;a=summary 
FRR soure mirror repo: https://git.proxmox.com/?p=mirror_frr.git;a=summary 

I updated the mirror to current master, and pushed out the frr-7.1 frr-7.0.1 
and frr-6.0.3 tags, so ideally we'd update it to 7.1 if you say that's working 
good for this. 

Applied, with some all over the place trailing whitespace cleanups, 
much thanks! 

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


[pve-devel] applied-series: [PATCH pve-manager 0/5] sdn apis endpoint

2019-09-03 Thread Thomas Lamprecht
On 21.08.19 05:22, Alexandre Derumier wrote:
> Based on my last pve-manager series from June.
> 
> changelog:
> add new api to retrieve status of transportzone && vnets on local node

applied, thanks! Should be soon in a bumped package.

> 
> Alexandre Derumier (5):
>   api2 : cluster: add sdn api endpoint
>   api2: network reload : generate local sdn config
>   pvestatd : broadcast sdn transportzone status
>   api : cluster ressources : add sdn
>   api2 : nodes : sdn status endpoint
> 
>  PVE/API2/Cluster.pm | 45 +++--
>  PVE/API2/Network.pm | 11 ++
>  PVE/API2/Nodes.pm   | 13 
>  PVE/Service/pvestatd.pm | 22 
>  4 files changed, 89 insertions(+), 2 deletions(-)
> 


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


Re: [pve-devel] applied-series: [PATCH v2 pve-network 00/13] pve-network improvements

2019-09-03 Thread Thomas Lamprecht
On 03.09.19 10:42, Alexandre DERUMIER wrote:
>>> I updated the mirror to current master, and pushed out the frr-7.1 
>>> frr-7.0.1 
>>> and frr-6.0.3 tags, so ideally we'd update it to 7.1 if you say that's 
>>> working 
>>> good for this. 
> 
> I have found a bug in 7.1 tag release,
> It's currently fixed in the stable/7.1 branch
> 
> https://github.com/FRRouting/frr/issues/4905
> 

Ah, ok, thanks for the notice.

> Not sure if you want to wait for 7.1.1 or 7.2 ?
> 

Hmm, I saw that there were many commits since 7.1 and the last releases
were only a few months apart, so 7.2 could come soon.

I can work with both.. The release notes mention that the Debian
packaging was overhauled for 7.0 so either way it could be a bit
work for us to ensure we can cope with the rework (not sure how much
changed and I did not checked how exactly we do things now in our FRR
repo)..

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


[pve-devel] [PATCH pve-network 2/2] vxlan: add ip-forward|ip6-forward|arp-accept for routing

2019-09-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 PVE/Network/SDN/VxlanPlugin.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/PVE/Network/SDN/VxlanPlugin.pm b/PVE/Network/SDN/VxlanPlugin.pm
index ec1729c..733412e 100644
--- a/PVE/Network/SDN/VxlanPlugin.pm
+++ b/PVE/Network/SDN/VxlanPlugin.pm
@@ -128,6 +128,9 @@ sub generate_sdn_config {
 push @iface_config, "bridge_fd 0";
 push @iface_config, "mtu $mtu" if $mtu;
 push @iface_config, "alias $alias" if $alias;
+push @iface_config, "ip-forward on" if $ipv4;
+push @iface_config, "ip6-forward on" if $ipv6;
+push @iface_config, "arp-accept on" if $ipv4||$ipv6;
 push @iface_config, "vrf $vrf" if $vrf;
 push(@{$config->{$vnetid}}, @iface_config) if !$config->{$vnetid};
 
-- 
2.20.1

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


[pve-devel] [PATCH pve-network 1/2] vxlan: add gateway-nodes option

2019-09-03 Thread Alexandre Derumier
Allow to define 1 or more gateway node,
to route the traffic to the outside world

import vrf is bugged in frr 7.1
works fine with current stable/7.1 branch
https://github.com/FRRouting/frr/issues/4905

Signed-off-by: Alexandre Derumier 
---
 PVE/Network/SDN/VxlanPlugin.pm | 56 +-
 test/documentation.txt |  2 +-
 2 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/PVE/Network/SDN/VxlanPlugin.pm b/PVE/Network/SDN/VxlanPlugin.pm
index 18ed629..ec1729c 100644
--- a/PVE/Network/SDN/VxlanPlugin.pm
+++ b/PVE/Network/SDN/VxlanPlugin.pm
@@ -4,6 +4,8 @@ use strict;
 use warnings;
 use PVE::Network::SDN::Plugin;
 use PVE::Tools;
+use PVE::INotify;
+use PVE::JSONSchema qw(get_standard_option);
 
 use base('PVE::Network::SDN::Plugin');
 
@@ -46,6 +48,7 @@ sub properties {
type => 'string',
description => "Frr router name",
},
+   'gateway-nodes' => get_standard_option('pve-node-list'),
 };
 }
 
@@ -59,6 +62,7 @@ sub options {
 'vrf' => { optional => 1 },
 'vrf-vxlan' => { optional => 1 },
 'router' => { optional => 1 },
+'gateway-nodes' => { optional => 1 },
 };
 }
 
@@ -164,17 +168,9 @@ sub generate_frr_config {
 
 my $vrf = $plugin_config->{'vrf'};
 my $vrfvxlan = $plugin_config->{'vrf-vxlan'};
-return if !$vrf || !$vrfvxlan;
-
-my $uplink = $plugin_config->{'uplink-id'};
+my $gatewaynodes = $plugin_config->{'gateway-nodes'};
 
-my $iface = "uplink$uplink";
-my $ifaceip = "";
-
-if($uplinks->{$uplink}->{name}) {
-$iface = $uplinks->{$uplink}->{name};
-$ifaceip = 
PVE::Network::SDN::Plugin::get_first_local_ipv4_from_interface($iface);
-}
+return if !$vrf || !$vrfvxlan;
 
 #vrf
 my @router_config = ();
@@ -183,18 +179,36 @@ sub generate_frr_config {
 push(@{$config->{vrf}->{"vrf $vrf"}}, @router_config);
 
 
-#vrf router
 @router_config = ();
-push @router_config, "bgp router-id $ifaceip";
-push @router_config, "!";
-push @router_config, "address-family ipv4 unicast";
-push @router_config, " redistribute connected";
-push @router_config, "exit-address-family";
-push @router_config, "!";
-push @router_config, "address-family l2vpn evpn";
-push @router_config, " advertise ipv4 unicast";
-push @router_config, "exit-address-family";
-push(@{$config->{router}->{"router bgp $asn vrf $vrf"}}, @router_config);
+
+my $is_gateway = undef;
+my $local_node = PVE::INotify::nodename();
+
+foreach my $gatewaynode (PVE::Tools::split_list($gatewaynodes)) {
+   $is_gateway = 1 if $gatewaynode eq $local_node;
+}
+
+if ($is_gateway) {
+
+   @router_config = ();
+   #import /32 routes of evpn network from vrf1 to default vrf (for packet 
return)
+   #frr 7.1 tag is bugged -> works fine with 7.1 stable 
branch(20190829-02-g6ba76bbc1)
+   #https://github.com/FRRouting/frr/issues/4905
+   push @router_config, "!";
+   push @router_config, "address-family ipv4 unicast";
+   push @router_config, " import vrf $vrf";
+   push @router_config, "exit-address-family";
+   push(@{$config->{router}->{"router bgp $asn"}}, @router_config);
+
+   @router_config = ();
+
+   #add default originate to announce 0.0.0.0/0 type5 route in evpn
+   push @router_config, "!";
+   push @router_config, "address-family l2vpn evpn";
+   push @router_config, " default-originate ipv4";
+   push @router_config, "exit-address-family";
+   push(@{$config->{router}->{"router bgp $asn vrf $vrf"}}, 
@router_config);
+}
 
 return $config;
 }
diff --git a/test/documentation.txt b/test/documentation.txt
index 567b798..d1ae031 100644
--- a/test/documentation.txt
+++ b/test/documentation.txt
@@ -18,7 +18,7 @@ pvesh create /cluster/sdn/ --sdn frrrouter1 --type frr 
--uplink-id 1 --peers 192
 pvesh create /cluster/sdn/ --sdn layer2evpnzone --type vxlan --uplink-id 1 
--router frrrouter1
 
 #create a layer3 routable vxlan bgpevpn transportzone
-pvesh create /cluster/sdn/ --sdn layer3evpnzone --type vxlan --uplink-id 1 
--router frrrouter1 --vrf vrf1 --vrf-vxlan 4000
+pvesh create /cluster/sdn/ --sdn layer3evpnzone --type vxlan --uplink-id 1 
--router frrrouter1 --vrf vrf1 --vrf-vxlan 4000 --gateway-nodes pxnode1,pxnode2
 
 
 #create a vnet in the transportzone
-- 
2.20.1

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


[pve-devel] [PATCH pve-network 0/2] vxlan bgp-evpn : add gateway-nodes options

2019-09-03 Thread Alexandre Derumier
Add a gateway-nodes options to define exit nodes to outside work
also add sysctl forwarding option to network interfaces

Alexandre Derumier (2):
  vxlan: add gateway-nodes option
  vxlan: add ip-forward|ip6-forward|arp-accept for routing

 PVE/Network/SDN/VxlanPlugin.pm | 59 ++
 test/documentation.txt |  2 +-
 2 files changed, 39 insertions(+), 22 deletions(-)

-- 
2.20.1

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


[pve-devel] [PATCH manager v2] Close #2262: Add noVNC scale setting

2019-09-03 Thread Dominic Jäger
Add a setting to choose the scale mode of the noVNC pop-up as well as
the embedded console in the content panel to "My Settings". Having both
set to local scaling was the most important use-case for the users. One
setting for both places is the simplest solution making this possible.

The new section (fieldset) makes adding further options such as
"Local Cursor" easy.

Co-developed-by: Thomas Lamprecht 
Signed-off-by: Dominic Jäger 
---
Please view with -w option. I did gg=G after moving some elements around.
v1->v2:
 - Reference name without hyphen
 - radiogroup instead of radiofields to get and set values
 - Move noVNC settings into their own section

 www/manager6/Utils.js   |   3 +-
 www/manager6/VNCConsole.js  |   3 +-
 www/manager6/window/Settings.js | 336 ++--
 3 files changed, 199 insertions(+), 143 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 6838ef2f..36732a37 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -960,13 +960,14 @@ Ext.define('PVE.Utils', { utilities: {
 },
 
 openVNCViewer: function(vmtype, vmid, nodename, vmname, cmd) {
+   var sp = Ext.state.Manager.getProvider();
var url = Ext.Object.toQueryString({
console: vmtype, // kvm, lxc, upgrade or shell
novnc: 1,
vmid: vmid,
vmname: vmname,
node: nodename,
-   resize: 'off',
+   resize: sp.get('novnc-scaling'),
cmd: cmd
});
var nw = window.open("?" + url, '_blank', 
"innerWidth=745,innerheight=427");
diff --git a/www/manager6/VNCConsole.js b/www/manager6/VNCConsole.js
index cd8fa243..22c82257 100644
--- a/www/manager6/VNCConsole.js
+++ b/www/manager6/VNCConsole.js
@@ -41,12 +41,13 @@ Ext.define('PVE.noVncConsole', {
items: box,
listeners: {
activate: function() {
+   var sp = Ext.state.Manager.getProvider();
var queryDict = {
console: me.consoleType, // kvm, lxc, upgrade or shell
vmid: me.vmid,
node: me.nodename,
cmd: me.cmd,
-   resize: 'scale'
+   resize: sp.get('novnc-scaling'),
};
queryDict[type] = 1;
PVE.Utils.cleanEmptyObjectKeys(queryDict);
diff --git a/www/manager6/window/Settings.js b/www/manager6/window/Settings.js
index 1a4d8599..91a07169 100644
--- a/www/manager6/window/Settings.js
+++ b/www/manager6/window/Settings.js
@@ -37,6 +37,10 @@ Ext.define('PVE.window.Settings', {
 
var username = sp.get('login-username') || Proxmox.Utils.noneText;
me.lookupReference('savedUserName').setValue(username);
+   var vncMode = sp.get('novnc-scaling');
+   if (vncMode !== undefined) {
+   me.lookupReference('noVNCScalingGroup').setValue(vncMode);
+   }
 
var settings = ['fontSize', 'fontFamily', 'letterSpacing', 
'lineHeight'];
settings.forEach(function(setting) {
@@ -164,162 +168,212 @@ Ext.define('PVE.window.Settings', {
 },
 
 items: [{
-   xtype: 'fieldset',
-   width: '50%',
-   title: gettext('Webinterface Settings'),
-   margin: '5',
-   layout: {
-   type: 'vbox',
-   align: 'left'
-   },
-   defaults: {
-   width: '100%',
-   margin: '0 0 10 0'
+   xtype: 'fieldset',
+   width: '50%',
+   title: gettext('Webinterface Settings'),
+   margin: '5',
+   layout: {
+   type: 'vbox',
+   align: 'left'
+   },
+   defaults: {
+   width: '100%',
+   margin: '0 0 10 0'
+   },
+   items: [
+   {
+   xtype: 'displayfield',
+   fieldLabel: gettext('Dashboard Storages'),
+   labelAlign: 'left',
+   labelWidth: '50%'
},
-   items: [
-   {
-   xtype: 'displayfield',
-   fieldLabel: gettext('Dashboard Storages'),
-   labelAlign: 'left',
-   labelWidth: '50%'
+   {
+   xtype: 'grid',
+   maxHeight: 150,
+   reference: 'dashboard-storages',
+   selModel: {
+   selType: 'checkboxmodel'
},
-   {
-   xtype: 'grid',
-   maxHeight: 150,
-   reference: 'dashboard-storages',
-   selModel: {
-   selType: 'checkboxmodel'
-   },
-   columns: [{
-   header: gettext('Name'),
-   dataIndex: 'storage',
-   flex: 1
-   },{
-   header: gettext('Node'),
-   

[pve-devel] [PATCH common] add postinst hook to fix /etc/aliases whitespace error

2019-09-03 Thread Thomas Lamprecht
This was wrongly shipped by our ISO since quite a bit (AFAICT, at
least 4.x), so fix it up in a versioned postinst snippet.

Do so by usind sed with the following pattern:
 # sed -E -i -e 's/^www:(\w)/www: \1/' /etc/aliases
proposed by Musee Ullah[0]. It even catches a bit more than exactly
our misstep, may help if one copied this line, or added some other
addresses to this specific aliases entry.

Do this here, in pve-common, as it makes it sligthly simpler to roll
the change out to both, PVE and PMG.

[0]: https://pve.proxmox.com/pipermail/pve-user/2019-September/170998.html

Reported-by: Uwe Sauter 
Signed-off-by: Thomas Lamprecht 
---

One could even add to the proposed solution to make it more general:
 # sed -E -i -e 's/^([^\s:]+):(\w)/\1: \2/' /etc/aliases

but I think that's not in our responsibility..
Open for different place to add this, but shared between PMG and PVE
/is/ really nice, IMO.

 debian/postinst | 20 
 1 file changed, 20 insertions(+)
 create mode 100644 debian/postinst

diff --git a/debian/postinst b/debian/postinst
new file mode 100644
index 000..5a19c69
--- /dev/null
+++ b/debian/postinst
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+set -e
+
+#DEBHELPER#
+
+case "$1" in
+  configure)
+if test -n "$2"; then
+
+# TODO: remove once PVE 7.0 is released
+if dpkg --compare-versions "$2" 'lt' '6.0-5'; then
+sed -E -i -e 's/^www:(\w)/www: \1/' /etc/aliases
+   fi
+fi
+;;
+
+esac
+
+exit 0
-- 
2.20.1


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


[pve-devel] applied-series: [PATCH pve-network 0/2] vxlan bgp-evpn : add gateway-nodes options

2019-09-03 Thread Thomas Lamprecht
On 03.09.19 11:14, Alexandre Derumier wrote:
> Add a gateway-nodes options to define exit nodes to outside work
> also add sysctl forwarding option to network interfaces

applied series, thanks!

> 
> Alexandre Derumier (2):
>   vxlan: add gateway-nodes option
>   vxlan: add ip-forward|ip6-forward|arp-accept for routing
> 
>  PVE/Network/SDN/VxlanPlugin.pm | 59 ++
>  test/documentation.txt |  2 +-
>  2 files changed, 39 insertions(+), 22 deletions(-)
> 

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


Re: [pve-devel] [PATCH qemu-server 1/1] Add support for up to 10 PCI(e) devices

2019-09-03 Thread Dominik Csapak

this breaks live migration of vms with q35 (without passthrough)

we should be able to add those rootports on demand (if a 'hostpciX' 
exists, for X >= 4) via qemu commandline


i do not really want to extend the default setup to include that many 
root ports (should do no harm really, but is unncecessary)


also i would prefer to avoid another versioned config file for this

we can add a sub (like usb controllers) 'get_pcie_root_ports' which
returns the necessary devices for the commandline

this way we can add them without breaking live migration and
can add additional ports more easily in the future
(also i would for now set it to something like 16; should be enough for 
some time)


On 9/2/19 12:50 PM, Aaron Lauterer wrote:

Signed-off-by: Aaron Lauterer 
---
  PVE/QemuServer.pm |  2 +-
  PVE/QemuServer/PCI.pm | 18 +
  pve-q35-4.0.cfg   | 60 +++
  3 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 6e3b19e..451fcda 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -769,7 +769,7 @@ my $MAX_SATA_DISKS = 6;
  my $MAX_USB_DEVICES = 5;
  my $MAX_NETS = 32;
  my $MAX_UNUSED_DISKS = 256;
-my $MAX_HOSTPCI_DEVICES = 4;
+my $MAX_HOSTPCI_DEVICES = 10;
  my $MAX_SERIAL_PORTS = 4;
  my $MAX_PARALLEL_PORTS = 3;
  my $MAX_NUMA = 8;
diff --git a/PVE/QemuServer/PCI.pm b/PVE/QemuServer/PCI.pm
index 9c72f3a..abfa462 100644
--- a/PVE/QemuServer/PCI.pm
+++ b/PVE/QemuServer/PCI.pm
@@ -80,6 +80,12 @@ my $devices = {
  'virtio15' => { bus => 2, addr => 10 },
  'ivshmem' => { bus => 2, addr => 11 },
  'audio0' => { bus => 2, addr => 12 },
+hostpci4 => { bus => 2, addr => 13 },
+hostpci5 => { bus => 2, addr => 14 },
+hostpci6 => { bus => 2, addr => 15 },
+hostpci7 => { bus => 2, addr => 16 },
+hostpci8 => { bus => 2, addr => 17 },
+hostpci9 => { bus => 2, addr => 18 },
  'virtioscsi0' => { bus => 3, addr => 1 },
  'virtioscsi1' => { bus => 3, addr => 2 },
  'virtioscsi2' => { bus => 3, addr => 3 },
@@ -147,12 +153,24 @@ sub print_pcie_addr {
hostpci1 => { bus => "ich9-pcie-port-2", addr => 0 },
hostpci2 => { bus => "ich9-pcie-port-3", addr => 0 },
hostpci3 => { bus => "ich9-pcie-port-4", addr => 0 },
+   hostpci4 => { bus => "ich9-pcie-port-5", addr => 0 },
+   hostpci5 => { bus => "ich9-pcie-port-6", addr => 0 },
+   hostpci6 => { bus => "ich9-pcie-port-7", addr => 0 },
+   hostpci7 => { bus => "ich9-pcie-port-8", addr => 0 },
+   hostpci8 => { bus => "ich9-pcie-port-9", addr => 0 },
+   hostpci9 => { bus => "ich9-pcie-port-10", addr => 0 },
# win7 is picky about pcie assignments
hostpci0bus0 => { bus => "pcie.0", addr => 16 },
hostpci1bus0 => { bus => "pcie.0", addr => 17 },
hostpci2bus0 => { bus => "pcie.0", addr => 18 },
hostpci3bus0 => { bus => "pcie.0", addr => 19 },
ivshmem => { bus => 'pcie.0', addr => 20 },
+   hostpci4bus0 => { bus => "pcie.0", addr => 21 },
+   hostpci5bus0 => { bus => "pcie.0", addr => 22 },
+   hostpci6bus0 => { bus => "pcie.0", addr => 23 },
+   hostpci7bus0 => { bus => "pcie.0", addr => 24 },
+   hostpci8bus0 => { bus => "pcie.0", addr => 25 },
+   hostpci9bus0 => { bus => "pcie.0", addr => 26 },
  };
  
  if (defined($devices->{$id}->{bus}) && defined($devices->{$id}->{addr})) {

diff --git a/pve-q35-4.0.cfg b/pve-q35-4.0.cfg
index c931417..307fd10 100644
--- a/pve-q35-4.0.cfg
+++ b/pve-q35-4.0.cfg
@@ -107,6 +107,66 @@
port = "4"
chassis = "4"
  
+[device "ich9-pcie-port-5"]

+  driver = "pcie-root-port"
+  x-speed = "16"
+  x-width = "32"
+  multifunction = "on"
+  bus = "pcie.0"
+  addr = "1c.4"
+  port = "5"
+  chassis = "5"
+
+[device "ich9-pcie-port-6"]
+  driver = "pcie-root-port"
+  x-speed = "16"
+  x-width = "32"
+  multifunction = "on"
+  bus = "pcie.0"
+  addr = "1c.5"
+  port = "6"
+  chassis = "6"
+
+[device "ich9-pcie-port-7"]
+  driver = "pcie-root-port"
+  x-speed = "16"
+  x-width = "32"
+  multifunction = "on"
+  bus = "pcie.0"
+  addr = "1c.6"
+  port = "7"
+  chassis = "7"
+
+[device "ich9-pcie-port-8"]
+  driver = "pcie-root-port"
+  x-speed = "16"
+  x-width = "32"
+  multifunction = "on"
+  bus = "pcie.0"
+  addr = "1c.7"
+  port = "8"
+  chassis = "8"
+
+[device "ich9-pcie-port-9"]
+  driver = "pcie-root-port"
+  x-speed = "16"
+  x-width = "32"
+  multifunction = "on"
+  bus = "pcie.0"
+  addr = "1d.4"
+  port = "9"
+  chassis = "9"
+
+[device "ich9-pcie-port-10"]
+  driver = "pcie-root-port"
+  x-speed = "16"
+  x-width = "32"
+  multifunction = "on"
+  bus = "pcie.0"
+  addr = "1d.5"
+  port = "10"
+  chassis = "10"
+
  ##
  # Example PCIe switch with two downstream ports
  #






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


[pve-devel] [PATCH pve-network] don't regenerate frr config if no router is defined

2019-09-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 PVE/Network/SDN.pm | 2 ++
 test/generateconfig.pl | 8 +---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/PVE/Network/SDN.pm b/PVE/Network/SDN.pm
index 1e89d97..1d84a32 100644
--- a/PVE/Network/SDN.pm
+++ b/PVE/Network/SDN.pm
@@ -195,6 +195,8 @@ sub generate_frr_config {
}
 }
 
+return undef if !$frr_cfg;
+
 #generate configuration
 my $config = {};
 
diff --git a/test/generateconfig.pl b/test/generateconfig.pl
index 04e930b..dda9b8e 100644
--- a/test/generateconfig.pl
+++ b/test/generateconfig.pl
@@ -15,6 +15,8 @@ print "\n";
 
 
 my $frr_config = PVE::Network::SDN::generate_frr_config();
-PVE::Network::SDN::write_frr_config($frr_config);
-print "/etc/frr/frr.conf\n";
-print $frr_config;
+if ($frr_config) {
+PVE::Network::SDN::write_frr_config($frr_config);
+print "/etc/frr/frr.conf\n";
+print $frr_config;
+}
-- 
2.20.1

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


[pve-devel] [PATCH pve-manager] api2: network reload: add frr config generation and reload

2019-09-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 PVE/API2/Network.pm | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm
index 07c3e6d3..d50a808d 100644
--- a/PVE/API2/Network.pm
+++ b/PVE/API2/Network.pm
@@ -561,8 +561,10 @@ __PACKAGE__->register_method({
rename($new_config_file, $current_config_file) if -e 
$new_config_file;
 
if ($have_sdn) {
-   my $rawconfig = 
PVE::Network::SDN::generate_etc_network_config();
-   PVE::Network::SDN::write_etc_network_config($rawconfig);
+   my $network_config = 
PVE::Network::SDN::generate_etc_network_config();
+   PVE::Network::SDN::write_etc_network_config($network_config);
+   my $frr_config = PVE::Network::SDN::generate_frr_config();
+   PVE::Network::SDN::write_frr_config($frr_config) if $frr_config;
}
 
my $cmd = ['ifreload', '-a'];
@@ -575,6 +577,7 @@ __PACKAGE__->register_method({
};
 
PVE::Tools::run_command($cmd,errfunc => $err);
+   PVE::Tools::run_command(['systemctl', 'reload', 'frr']) if -e 
"/usr/lib/frr/frr-reload.py";
};
return $rpcenv->fork_worker('srvreload', 'networking', $authuser, 
$worker);
}});
-- 
2.20.1

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


Re: [pve-devel] [PATCH qemu-server] fix #1934: add qemu fw_cfg variables via 'tags'

2019-09-03 Thread Dominik Csapak

On 9/2/19 2:14 PM, Fabian Grünbichler wrote:

On August 23, 2019 2:03 pm, Dominik Csapak wrote:

this add the 'tags' property to vms, which has the format:


why 'tags'? seems rather generic for what it does ;)


because the request in the bugreport was a more general one
(users wanted to simply set some tags for the vm
which are not in the description)

i just wanted to also use them besides simply having them in
the config ;)





key=value(;key=value)*

each value will be set as

-fw_cfg 'name=opt/com.proxmox/$key,string=$value'
(qemu recommends using a unique rfqdn)

this way, users can tag the vm with that information available inside
e.g. under linux the value can be read under

/sys/firmware/qemu_fw_cfg/by_name/opt/com.proxmox./$key/raw

see the file docs/specs/fw_cfg.txt in the qemu repository for more
details


if we introduce this, wouldn't it also make sense to allow to pass in
snippet files via this interface (via file=$path instead of string=$value)?


yeah one possibility would be to add a seperate config entry, such as
'tags-files' (or $name-files if tags is not wanted)
which would be a 'key=' syntax

i just wanted to keep it simple for now, because afaics this
would already satisfy the need for most of the users in the bugreport





maybe we can also use this in the future to show/set in the gui
e.g. some grouping/ordering etc.

Signed-off-by: Dominik Csapak 
---
  PVE/QemuServer.pm | 37 +
  1 file changed, 37 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 9f5bf56..d55a1ae 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -232,6 +232,29 @@ my $watchdog_fmt = {
  };
  PVE::JSONSchema::register_format('pve-qm-watchdog', $watchdog_fmt);
  
+PVE::JSONSchema::register_format('pve-qm-tags', \&verify_tag_format);

+sub verify_tag_format {
+my ($tagstring, $noerr) = @_;
+
+if (!$tagstring) {
+   return '';
+}
+
+# forbid all characters not in range 0x20-0x7E
+for my $tag (split(';', $tagstring)) {
+   my ($key, $value) = ($tag =~ m/^(.*)=(.*)$/);
+   if ($key =~ m/[\x00-\x1F\x7F-\xFF]/) {
+   die "invalid character in tag key\n" if !$noerr;
+   return undef;
+   }
+   if ($value =~ m/[\x00-\x1F\x7F-\xFF]/) {
+   die "invalid character in tag value\n" if !$noerr;
+   return undef;
+   }
+}
+
+return $tagstring;
+}
  my $agent_fmt = {
  enabled => {
description => "Enable/disable Qemu GuestAgent.",
@@ -672,6 +695,13 @@ EODESCR
description => "Configure a audio device, useful in combination with 
QXL/Spice.",
optional => 1
  },
+tags => {
+   description => "Specify key/value pairs to be added to qemu fw_cfg.",
+   type => 'string',
+   maxLength => 4096,
+   format => 'pve-qm-tags',
+   optional => 1,
+},
  };
  
  my $cicustom_fmt = {

@@ -4152,6 +4182,13 @@ sub config_to_command {
push @$cmd, '-loadstate', $statepath;
  }
  
+if ($conf->{tags}) {

+   for my $tag (split(';', $conf->{tags})) {
+   my ($key, $value) = ($tag =~ m/^(.*)=(.*)$/);
+   push @$cmd, '-fw_cfg', "name=opt/com.proxmox/$key,string=$value";
+   }
+}
+
  # add custom args
  if ($conf->{args}) {
my $aa = PVE::Tools::split_args($conf->{args});
--
2.20.1


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




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




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


Re: [pve-devel] [PATCH qemu-server] fix #1934: add qemu fw_cfg variables via 'tags'

2019-09-03 Thread Dominik Csapak

On 9/2/19 2:27 PM, Thomas Lamprecht wrote:

On 9/2/19 2:14 PM, Fabian Grünbichler wrote:

On August 23, 2019 2:03 pm, Dominik Csapak wrote:

this add the 'tags' property to vms, which has the format:


why 'tags'? seems rather generic for what it does ;)


Second, tags is a NAK from me. Maybe just "fw_cfg" (or a variation), the 
Webinterface
can show a full name and link to docs anyway (if it'd be added there, someday), 
and for
the CLI we have the CLI help, man pages and the fact that it's named the same 
as the QEMU
option, which helps a lot to associated both together (even if the sematic how 
values are
passed differs, which is IMO totally fine).


see my other mail for why i named it tags, but i am fine with 'fw_cfg' 
or something else also






key=value(;key=value)*

each value will be set as

-fw_cfg 'name=opt/com.proxmox/$key,string=$value'
(qemu recommends using a unique rfqdn)

this way, users can tag the vm with that information available inside
e.g. under linux the value can be read under

/sys/firmware/qemu_fw_cfg/by_name/opt/com.proxmox./$key/raw

see the file docs/specs/fw_cfg.txt in the qemu repository for more
details


if we introduce this, wouldn't it also make sense to allow to pass in
snippet files via this interface (via file=$path instead of string=$value)?


How do you want to differentiate between? Would need a special syntax to
detect that "file" is not meant to be a key for fw_cfg but a hint for PVE..


see my other mail for a proposal







maybe we can also use this in the future to show/set in the gui
e.g. some grouping/ordering etc.

Signed-off-by: Dominik Csapak 
---
  PVE/QemuServer.pm | 37 +
  1 file changed, 37 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 9f5bf56..d55a1ae 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -232,6 +232,29 @@ my $watchdog_fmt = {
  };
  PVE::JSONSchema::register_format('pve-qm-watchdog', $watchdog_fmt);
  
+PVE::JSONSchema::register_format('pve-qm-tags', \&verify_tag_format);

+sub verify_tag_format {
+my ($tagstring, $noerr) = @_;
+
+if (!$tagstring) {
+   return '';
+}
+
+# forbid all characters not in range 0x20-0x7E
+for my $tag (split(';', $tagstring)) {
+   my ($key, $value) = ($tag =~ m/^(.*)=(.*)$/);
+   if ($key =~ m/[\x00-\x1F\x7F-\xFF]/) {
+   die "invalid character in tag key\n" if !$noerr;
+   return undef;
+   }
+   if ($value =~ m/[\x00-\x1F\x7F-\xFF]/) {
+   die "invalid character in tag value\n" if !$noerr;
+   return undef;
+   }
+}
+
+return $tagstring;
+}
  my $agent_fmt = {
  enabled => {
description => "Enable/disable Qemu GuestAgent.",
@@ -672,6 +695,13 @@ EODESCR
description => "Configure a audio device, useful in combination with 
QXL/Spice.",
optional => 1
  },
+tags => {
+   description => "Specify key/value pairs to be added to qemu fw_cfg.",
+   type => 'string',
+   maxLength => 4096,
+   format => 'pve-qm-tags',
+   optional => 1,
+},
  };
  
  my $cicustom_fmt = {

@@ -4152,6 +4182,13 @@ sub config_to_command {
push @$cmd, '-loadstate', $statepath;
  }
  
+if ($conf->{tags}) {

+   for my $tag (split(';', $conf->{tags})) {
+   my ($key, $value) = ($tag =~ m/^(.*)=(.*)$/);


what do I do when I need a ";" in a value or a "=" in a key?


would not work as it is, but if we allow for files, a user
could do this there then

another approach would be to base64 encode it (or sthg similar), but
then the config is not that readable anymore, and we probably
would want to provide an api call that returns the tags in a
'formatted' way (when i think about this, we probably want such an api 
call anyway)





+   push @$cmd, '-fw_cfg', "name=opt/com.proxmox/$key,string=$value";
+   }
+}
+
  # add custom args
  if ($conf->{args}) {
my $aa = PVE::Tools::split_args($conf->{args});
--
2.20.1



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




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