* [PATCH qemu-server] fix #7173: config: do not write out an empty tag list
@ 2026-11-09 13:56 Lucas Barros
2026-11-11 9:53 ` Fabian Grünbichler
0 siblings, 1 reply; 8+ messages in thread
From: Lucas Barros @ 2026-11-09 13:56 UTC (permalink / raw)
To: pve-devel
Removing the last tag of a VM, for example in the web UI, sets 'tags'
to an empty string, which then ends up as an empty 'tags:' line in the
VM config and in the output of 'qm config'. This carries no
information, is inconsistent with how unset options are handled and
confuses tools that consume the config, as they need to special case
an empty tag list.
Drop the key when writing the config if the tag list is empty, which
also cleans up configs that already contain such a line on the next
write. The pending section is left alone, as an empty value there is
still needed to apply the change.
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
---
A matching patch for pve-container is sent separately.
Only the main section is touched. In [PENDING] the empty value is still
needed so that applying the pending change removes the tags, and it is
dropped from the main section on the write that follows.
The new parse-config test input contains the 'tags: ' line with the
trailing space that the writer produces today, so 'git am' warns about
trailing whitespace there. Without the trailing space the line would
not match the config parser at all.
An alternative would be to turn an empty 'tags' value into a deletion
in the update API, but that would not cover other paths that end up
with an empty value (create, clone, restore, 'qm set --tags ""').
Tested on a PVE 9 node (qemu-server 9.2.15, pve-container 6.1.18),
adding and then removing the only tag of a VM and of a container:
without the patches:
$ qm set 9901 --tags foo; pvesh set /nodes/<node>/qemu/9901/config --tags ''
$ grep -n tags /etc/pve/qemu-server/9901.conf | cat -A
6:tags: $
$ pct set 9902 --tags foo; pct set 9902 --tags ''
$ grep -n tags /etc/pve/lxc/9902.conf | cat -A
7:tags: $
$ pvesh get /nodes/<node>/qemu/9901/config --output-format json | jq -c '{tags}'
{"tags":" "}
with the patches:
$ grep -c tags /etc/pve/qemu-server/9901.conf /etc/pve/lxc/9902.conf
/etc/pve/qemu-server/9901.conf:0
/etc/pve/lxc/9902.conf:0
$ pvesh get /nodes/<node>/qemu/9901/config --output-format json | jq -c '{tags}'
{"tags":null}
An existing empty 'tags:' line goes away on the next write of the
config, removing the tag of a running VM leaves no line and no
[PENDING] entry, and 'tags: a;b' is still written as before.
'make test' (run with 16 CPUs in /proc/cpuinfo, the cfg2cmd tests need
more vCPUs than the test machine has) passes before and after; the
parse-config tests go from 20 to 22, and the new empty-tags case fails
without the change to QemuServer.pm. proxmox-perltidy reports no
changes.
This patch was prepared with the help of an LLM based coding assistant;
I reviewed the change and ran the tests mentioned above myself.
src/PVE/QemuServer.pm | 3 +++
src/test/parse-config-expected/empty-tags.conf | 11 +++++++++++
src/test/parse-config-input/empty-tags.conf | 12 ++++++++++++
src/test/run_parse_config_tests.pl | 2 +-
4 files changed, 27 insertions(+), 1 deletion(-)
create mode 100644 src/test/parse-config-expected/empty-tags.conf
create mode 100644 src/test/parse-config-input/empty-tags.conf
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 8045c07e..22621e63 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -2067,6 +2067,9 @@ sub write_vm_config {
delete $conf->{smp};
}
+ # an empty tag list carries no information, so do not write out the key
+ delete $conf->{tags} if defined($conf->{tags}) && $conf->{tags} =~ m/^[\s,;]*$/;
+
my $used_volids = {};
my $cleanup_config = sub {
diff --git a/src/test/parse-config-expected/empty-tags.conf b/src/test/parse-config-expected/empty-tags.conf
new file mode 100644
index 00000000..a5b02f2c
--- /dev/null
+++ b/src/test/parse-config-expected/empty-tags.conf
@@ -0,0 +1,11 @@
+# VM with an empty tag list left behind after removing the last tag
+bootdisk: scsi0
+cores: 1
+memory: 512
+name: apache
+ostype: l26
+scsi0: mydir:142/vm-142-disk-0.qcow2,size=4G
+scsihw: virtio-scsi-pci
+smbios1: uuid=ddf91b3f-a597-42be-9a7e-fb6421dcd5cd
+sockets: 1
+vmgenid: 0
diff --git a/src/test/parse-config-input/empty-tags.conf b/src/test/parse-config-input/empty-tags.conf
new file mode 100644
index 00000000..a37a9c2d
--- /dev/null
+++ b/src/test/parse-config-input/empty-tags.conf
@@ -0,0 +1,12 @@
+# VM with an empty tag list left behind after removing the last tag
+bootdisk: scsi0
+cores: 1
+memory: 512
+name: apache
+ostype: l26
+scsi0: mydir:142/vm-142-disk-0.qcow2,size=4G
+scsihw: virtio-scsi-pci
+smbios1: uuid=ddf91b3f-a597-42be-9a7e-fb6421dcd5cd
+sockets: 1
+tags:
+vmgenid: 0
diff --git a/src/test/run_parse_config_tests.pl b/src/test/run_parse_config_tests.pl
index f68abc06..c30aad99 100755
--- a/src/test/run_parse_config_tests.pl
+++ b/src/test/run_parse_config_tests.pl
@@ -25,7 +25,7 @@ my $INPUT_DIR = './parse-config-input';
my $EXPECTED_DIR = './parse-config-expected';
# NOTE update when you add/remove tests
-plan tests => 2 * 10;
+plan tests => 2 * 11;
sub run_tests {
my ($strict) = @_;
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH qemu-server] fix #7173: config: do not write out an empty tag list
2026-11-09 13:56 [PATCH qemu-server] fix #7173: config: do not write out an empty tag list Lucas Barros
@ 2026-11-11 9:53 ` Fabian Grünbichler
2026-11-16 1:00 ` [PATCH qemu-server/container/manager v2 0/5] fix #7173: do not keep an empty tag list in guest configs Lucas Barros
0 siblings, 1 reply; 8+ messages in thread
From: Fabian Grünbichler @ 2026-11-11 9:53 UTC (permalink / raw)
To: Lucas Barros, pve-devel
On November 9, 2026 2:56 pm, Lucas Barros wrote:
> Removing the last tag of a VM, for example in the web UI, sets 'tags'
> to an empty string, which then ends up as an empty 'tags:' line in the
> VM config and in the output of 'qm config'. This carries no
> information, is inconsistent with how unset options are handled and
> confuses tools that consume the config, as they need to special case
> an empty tag list.
We could consider changing this and rejecting empty `-list` parameters,
and instead require properly deleting? e.g., switch over to use
`--delete tags` if the last to-be-set tag list is empty, make the parser
ignore keys without a value, and then with 10.0 make empty (either by
virtue of being an empty string, or just delimiters) list parameters
invalid?
It seems like these two patches just add a hacky workaround on top (with
rather subtle semantics about adding the invalid value to pending but
not to the `current` config)..
> Drop the key when writing the config if the tag list is empty, which
> also cleans up configs that already contain such a line on the next
> write. The pending section is left alone, as an empty value there is
> still needed to apply the change.
>
> Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
> ---
> A matching patch for pve-container is sent separately.
>
> Only the main section is touched. In [PENDING] the empty value is still
> needed so that applying the pending change removes the tags, and it is
> dropped from the main section on the write that follows.
>
> The new parse-config test input contains the 'tags: ' line with the
> trailing space that the writer produces today, so 'git am' warns about
> trailing whitespace there. Without the trailing space the line would
> not match the config parser at all.
>
> An alternative would be to turn an empty 'tags' value into a deletion
> in the update API, but that would not cover other paths that end up
> with an empty value (create, clone, restore, 'qm set --tags ""').
>
> Tested on a PVE 9 node (qemu-server 9.2.15, pve-container 6.1.18),
> adding and then removing the only tag of a VM and of a container:
>
> without the patches:
> $ qm set 9901 --tags foo; pvesh set /nodes/<node>/qemu/9901/config --tags ''
> $ grep -n tags /etc/pve/qemu-server/9901.conf | cat -A
> 6:tags: $
> $ pct set 9902 --tags foo; pct set 9902 --tags ''
> $ grep -n tags /etc/pve/lxc/9902.conf | cat -A
> 7:tags: $
> $ pvesh get /nodes/<node>/qemu/9901/config --output-format json | jq -c '{tags}'
> {"tags":" "}
>
> with the patches:
> $ grep -c tags /etc/pve/qemu-server/9901.conf /etc/pve/lxc/9902.conf
> /etc/pve/qemu-server/9901.conf:0
> /etc/pve/lxc/9902.conf:0
> $ pvesh get /nodes/<node>/qemu/9901/config --output-format json | jq -c '{tags}'
> {"tags":null}
>
> An existing empty 'tags:' line goes away on the next write of the
> config, removing the tag of a running VM leaves no line and no
> [PENDING] entry, and 'tags: a;b' is still written as before.
>
> 'make test' (run with 16 CPUs in /proc/cpuinfo, the cfg2cmd tests need
> more vCPUs than the test machine has) passes before and after; the
> parse-config tests go from 20 to 22, and the new empty-tags case fails
> without the change to QemuServer.pm. proxmox-perltidy reports no
> changes.
>
> This patch was prepared with the help of an LLM based coding assistant;
> I reviewed the change and ran the tests mentioned above myself.
>
> src/PVE/QemuServer.pm | 3 +++
> src/test/parse-config-expected/empty-tags.conf | 11 +++++++++++
> src/test/parse-config-input/empty-tags.conf | 12 ++++++++++++
> src/test/run_parse_config_tests.pl | 2 +-
> 4 files changed, 27 insertions(+), 1 deletion(-)
> create mode 100644 src/test/parse-config-expected/empty-tags.conf
> create mode 100644 src/test/parse-config-input/empty-tags.conf
>
> diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
> index 8045c07e..22621e63 100644
> --- a/src/PVE/QemuServer.pm
> +++ b/src/PVE/QemuServer.pm
> @@ -2067,6 +2067,9 @@ sub write_vm_config {
> delete $conf->{smp};
> }
>
> + # an empty tag list carries no information, so do not write out the key
> + delete $conf->{tags} if defined($conf->{tags}) && $conf->{tags} =~ m/^[\s,;]*$/;
nit: if we keep this approach, this should `split_list` and check that
the result is empty, else it risks going out of sync (it already is
w.r.t. \0-delimited lists).
> +
> my $used_volids = {};
>
> my $cleanup_config = sub {
> diff --git a/src/test/parse-config-expected/empty-tags.conf b/src/test/parse-config-expected/empty-tags.conf
> new file mode 100644
> index 00000000..a5b02f2c
> --- /dev/null
> +++ b/src/test/parse-config-expected/empty-tags.conf
> @@ -0,0 +1,11 @@
> +# VM with an empty tag list left behind after removing the last tag
> +bootdisk: scsi0
> +cores: 1
> +memory: 512
> +name: apache
> +ostype: l26
> +scsi0: mydir:142/vm-142-disk-0.qcow2,size=4G
> +scsihw: virtio-scsi-pci
> +smbios1: uuid=ddf91b3f-a597-42be-9a7e-fb6421dcd5cd
> +sockets: 1
> +vmgenid: 0
> diff --git a/src/test/parse-config-input/empty-tags.conf b/src/test/parse-config-input/empty-tags.conf
> new file mode 100644
> index 00000000..a37a9c2d
> --- /dev/null
> +++ b/src/test/parse-config-input/empty-tags.conf
> @@ -0,0 +1,12 @@
> +# VM with an empty tag list left behind after removing the last tag
> +bootdisk: scsi0
> +cores: 1
> +memory: 512
> +name: apache
> +ostype: l26
> +scsi0: mydir:142/vm-142-disk-0.qcow2,size=4G
> +scsihw: virtio-scsi-pci
> +smbios1: uuid=ddf91b3f-a597-42be-9a7e-fb6421dcd5cd
> +sockets: 1
> +tags:
> +vmgenid: 0
> diff --git a/src/test/run_parse_config_tests.pl b/src/test/run_parse_config_tests.pl
> index f68abc06..c30aad99 100755
> --- a/src/test/run_parse_config_tests.pl
> +++ b/src/test/run_parse_config_tests.pl
> @@ -25,7 +25,7 @@ my $INPUT_DIR = './parse-config-input';
> my $EXPECTED_DIR = './parse-config-expected';
>
> # NOTE update when you add/remove tests
> -plan tests => 2 * 10;
> +plan tests => 2 * 11;
>
> sub run_tests {
> my ($strict) = @_;
> --
> 2.47.3
>
>
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH qemu-server/container/manager v2 0/5] fix #7173: do not keep an empty tag list in guest configs
2026-11-11 9:53 ` Fabian Grünbichler
@ 2026-11-16 1:00 ` Lucas Barros
2026-11-16 1:00 ` [PATCH qemu-server v2 1/5] fix #7173: api: update: delete tags when an empty tag list is set Lucas Barros
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Lucas Barros @ 2026-11-16 1:00 UTC (permalink / raw)
To: pve-devel; +Cc: Lucas Barros
Removing the last tag of a guest leaves an empty 'tags:' line in its
config, which the API returns as a tag list with a single space.
v1 dropped the empty value when writing the config. Fabian found that
hacky [0] and suggested to delete the option instead and to make the
parser ignore it. v2 does that:
* 1/5, 3/5: the update API turns an empty tag list (checked with
split_list(), so delimiters only count as empty too) into a deletion
* 2/5, 4/5: the parsers skip an empty 'tags' line, so old configs read
as having no tags and lose the line on the next write
* 5/5: the web UI sends 'delete: tags' when the last tag is removed
I first made the parsers skip every key without a value, but that is
not safe in general:
* 'boot: ' means that no device gets a boot index, while no 'boot' at
all means the default order. The cfg2cmd test bootorder-empty.conf
fails with that change.
* in qemu-server, update_vm_api() reloads the config between writing a
pending change and applying it, so 'qm set --searchdomain ""' on a
stopped VM was silently lost.
So 2/5 and 4/5 only handle 'tags'. Making empty list parameters invalid
for 10.0 is not part of this series.
Tested on a PVE 9 node (qemu-server 9.2.15, pve-container 6.1.18, the
.pm files patched in place):
removing the last tag (VM and CT, via 'tags=' as the UI sends today)
before: 'tags: ' line in the config, API returns "tags":" "
after: no line, API returns no tags
--tags ';,' same as above
existing 'tags: ' / 'tags:' before: " " / "unable to parse config"
after: no tags, line gone on next write
'tags: a;b', running VM, '--tags "" --delete tags' unchanged
'boot: ', '--searchdomain ""' unchanged
qemu-server 'make test' (with 16 CPUs in /proc/cpuinfo): 280 ok before,
282 after, the new parse-config case fails without 2/5. pve-container
'make test' passes before and after, the new subtest fails without 4/5.
proxmox-perltidy and proxmox-biome report no changes.
v1:
https://lore.proxmox.com/pve-devel/20261109135613.94692-1-lucasbarros.kam@gmail.com/
https://lore.proxmox.com/pve-devel/20261109135640.94964-1-lucasbarros.kam@gmail.com/
[0] https://lore.proxmox.com/pve-devel/1794390075.ol4qipttrq.astroid@yuna.none/
This series was prepared with the help of an LLM based coding
assistant; I reviewed the changes and ran the tests mentioned above
myself.
qemu-server:
Lucas Barros (2):
fix #7173: api: update: delete tags when an empty tag list is set
config: ignore an empty tag list when parsing
src/PVE/API2/Qemu.pm | 9 +++++++++
src/PVE/QemuServer.pm | 3 +++
src/test/parse-config-expected/empty-tags.conf | 11 +++++++++++
src/test/parse-config-input/empty-tags.conf | 12 ++++++++++++
src/test/run_parse_config_tests.pl | 2 +-
5 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 src/test/parse-config-expected/empty-tags.conf
create mode 100644 src/test/parse-config-input/empty-tags.conf
container:
Lucas Barros (2):
fix #7173: api: update: delete tags when an empty tag list is set
config: ignore an empty tag list when parsing
src/PVE/API2/LXC/Config.pm | 9 +++++++++
src/PVE/LXC/Config.pm | 3 +++
src/test/config_tests.pl | 21 +++++++++++++++++++++
3 files changed, 33 insertions(+)
manager:
Lucas Barros (1):
fix #7173: ui: guest: delete tags when removing the last tag
www/manager6/lxc/Config.js | 4 +---
www/manager6/qemu/Config.js | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)
Summary over all repositories:
10 files changed, 71 insertions(+), 7 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH qemu-server v2 1/5] fix #7173: api: update: delete tags when an empty tag list is set
2026-11-16 1:00 ` [PATCH qemu-server/container/manager v2 0/5] fix #7173: do not keep an empty tag list in guest configs Lucas Barros
@ 2026-11-16 1:00 ` Lucas Barros
2026-11-16 1:00 ` [PATCH qemu-server v2 2/5] config: ignore an empty tag list when parsing Lucas Barros
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Lucas Barros @ 2026-11-16 1:00 UTC (permalink / raw)
To: pve-devel; +Cc: Lucas Barros
Setting 'tags' to an empty string, as the web UI does when removing the
last tag of a VM, stores the empty value in the config and leaves an
empty 'tags:' line behind, instead of removing the option.
Handle an empty tag list like a deletion of 'tags', so that the option
goes through the regular delete path, including the tag permission
checks, and nothing is left in the config. Use split_list() to decide
whether the list is empty, so a value consisting only of delimiters is
handled the same way.
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
---
changes since v1:
* new patch: turn an empty tag list into 'delete tags' in the API,
instead of dropping it when writing the config (v1)
This patch was prepared with the help of an LLM based coding assistant;
I reviewed the change and ran the tests mentioned in the cover letter
myself.
src/PVE/API2/Qemu.pm | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index 7830d09b..bb3f1fdd 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -2191,6 +2191,15 @@ my $update_vm_api = sub {
push @delete, $opt;
}
+ # an empty tag list means no tags, so remove the option instead of setting an empty value
+ if (defined($param->{tags})) {
+ my @tags = PVE::Tools::split_list($param->{tags});
+ if (!scalar(@tags)) {
+ delete $param->{tags};
+ push @delete, 'tags';
+ }
+ }
+
my $repl_conf = PVE::ReplicationConfig->new();
my $is_replicated = $repl_conf->check_for_existing_jobs($vmid, 1);
my $check_replication = sub {
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH qemu-server v2 2/5] config: ignore an empty tag list when parsing
2026-11-16 1:00 ` [PATCH qemu-server/container/manager v2 0/5] fix #7173: do not keep an empty tag list in guest configs Lucas Barros
2026-11-16 1:00 ` [PATCH qemu-server v2 1/5] fix #7173: api: update: delete tags when an empty tag list is set Lucas Barros
@ 2026-11-16 1:00 ` Lucas Barros
2026-11-16 1:00 ` [PATCH container v2 3/5] fix #7173: api: update: delete tags when an empty tag list is set Lucas Barros
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Lucas Barros @ 2026-11-16 1:00 UTC (permalink / raw)
To: pve-devel; +Cc: Lucas Barros
Configs of VMs whose last tag was removed before the previous commit
still contain a 'tags: ' line. It is read as a tag list consisting of a
single space and shows up as such in the API, while a 'tags:' line
without the trailing space is reported as a line that cannot be parsed.
An empty tag list is the same as having no tags, so skip such a line
when parsing, like an unset option. Use split_list() to decide whether
the list is empty, so a value consisting only of delimiters is handled
the same way. Configs that contain such a line lose it on the next
write.
This is limited to 'tags' on purpose, other options can carry meaning
with an empty value. For example, with an empty 'boot' no device gets a
boot index, while an unset 'boot' means the default boot order.
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
---
changes since v1:
* new patch, replaces the writer change of v1
* only for 'tags', see the cover letter for why not for all keys
The new test uses 'tags:' without a trailing space, so 'git am' does
not warn about whitespace. It fails without the change to the parser
(strict mode reports the line as unparsable).
This patch was prepared with the help of an LLM based coding assistant;
I reviewed the change and ran the tests mentioned in the cover letter
myself.
src/PVE/QemuServer.pm | 3 +++
src/test/parse-config-expected/empty-tags.conf | 11 +++++++++++
src/test/parse-config-input/empty-tags.conf | 12 ++++++++++++
src/test/run_parse_config_tests.pl | 2 +-
4 files changed, 27 insertions(+), 1 deletion(-)
create mode 100644 src/test/parse-config-expected/empty-tags.conf
create mode 100644 src/test/parse-config-input/empty-tags.conf
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 005fcb6e..59d8adde 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -2017,6 +2017,9 @@ sub parse_vm_config {
} else {
$handle_error->("vm $vmid - property 'delete' is only allowed in [PENDING]\n");
}
+ } elsif ($line =~ m/^tags:\s*(.*?)\s*$/ && !PVE::Tools::split_list($1)) {
+ # an empty tag list is the same as no tags
+ next;
} elsif ($line =~ m/^([a-z][a-z_\-]*\d*):\s*(.+?)\s*$/) {
my $key = $1;
my $value = $2;
diff --git a/src/test/parse-config-expected/empty-tags.conf b/src/test/parse-config-expected/empty-tags.conf
new file mode 100644
index 00000000..74901b45
--- /dev/null
+++ b/src/test/parse-config-expected/empty-tags.conf
@@ -0,0 +1,11 @@
+# VM with an empty tag list, like the one left behind after removing the last tag
+bootdisk: scsi0
+cores: 1
+memory: 512
+name: apache
+ostype: l26
+scsi0: mydir:142/vm-142-disk-0.qcow2,size=4G
+scsihw: virtio-scsi-pci
+smbios1: uuid=ddf91b3f-a597-42be-9a7e-fb6421dcd5cd
+sockets: 1
+vmgenid: 0
diff --git a/src/test/parse-config-input/empty-tags.conf b/src/test/parse-config-input/empty-tags.conf
new file mode 100644
index 00000000..1a8851c6
--- /dev/null
+++ b/src/test/parse-config-input/empty-tags.conf
@@ -0,0 +1,12 @@
+# VM with an empty tag list, like the one left behind after removing the last tag
+bootdisk: scsi0
+cores: 1
+memory: 512
+name: apache
+ostype: l26
+scsi0: mydir:142/vm-142-disk-0.qcow2,size=4G
+scsihw: virtio-scsi-pci
+smbios1: uuid=ddf91b3f-a597-42be-9a7e-fb6421dcd5cd
+sockets: 1
+tags:
+vmgenid: 0
diff --git a/src/test/run_parse_config_tests.pl b/src/test/run_parse_config_tests.pl
index f68abc06..c30aad99 100755
--- a/src/test/run_parse_config_tests.pl
+++ b/src/test/run_parse_config_tests.pl
@@ -25,7 +25,7 @@ my $INPUT_DIR = './parse-config-input';
my $EXPECTED_DIR = './parse-config-expected';
# NOTE update when you add/remove tests
-plan tests => 2 * 10;
+plan tests => 2 * 11;
sub run_tests {
my ($strict) = @_;
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH container v2 3/5] fix #7173: api: update: delete tags when an empty tag list is set
2026-11-16 1:00 ` [PATCH qemu-server/container/manager v2 0/5] fix #7173: do not keep an empty tag list in guest configs Lucas Barros
2026-11-16 1:00 ` [PATCH qemu-server v2 1/5] fix #7173: api: update: delete tags when an empty tag list is set Lucas Barros
2026-11-16 1:00 ` [PATCH qemu-server v2 2/5] config: ignore an empty tag list when parsing Lucas Barros
@ 2026-11-16 1:00 ` Lucas Barros
2026-11-16 1:00 ` [PATCH container v2 4/5] config: ignore an empty tag list when parsing Lucas Barros
2026-11-16 1:00 ` [PATCH manager v2 5/5] fix #7173: ui: guest: delete tags when removing the last tag Lucas Barros
4 siblings, 0 replies; 8+ messages in thread
From: Lucas Barros @ 2026-11-16 1:00 UTC (permalink / raw)
To: pve-devel; +Cc: Lucas Barros
Setting 'tags' to an empty string, as the web UI does when removing the
last tag of a container, stores the empty value in the config and
leaves an empty 'tags:' line behind, instead of removing the option.
Handle an empty tag list like a deletion of 'tags', so that the option
goes through the regular delete path, including the tag permission
checks, and nothing is left in the config. Use split_list() to decide
whether the list is empty, so a value consisting only of delimiters is
handled the same way.
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
---
changes since v1:
* new patch, same as 1/5 for containers
This patch was prepared with the help of an LLM based coding assistant;
I reviewed the change and ran the tests mentioned in the cover letter
myself.
src/PVE/API2/LXC/Config.pm | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/PVE/API2/LXC/Config.pm b/src/PVE/API2/LXC/Config.pm
index 805eac0..7a6c1bb 100644
--- a/src/PVE/API2/LXC/Config.pm
+++ b/src/PVE/API2/LXC/Config.pm
@@ -165,6 +165,15 @@ __PACKAGE__->register_method({
my $revert_str = extract_param($param, 'revert');
my @revert = PVE::Tools::split_list($revert_str);
+ # an empty tag list means no tags, so remove the option instead of setting an empty value
+ if (defined($param->{tags}) && !grep { $_ eq 'tags' } @delete) {
+ my @tags = PVE::Tools::split_list($param->{tags});
+ if (!scalar(@tags)) {
+ delete $param->{tags};
+ push @delete, 'tags';
+ }
+ }
+
$param->{cpuunits} = PVE::CGroup::clamp_cpu_shares($param->{cpuunits})
if defined($param->{cpuunits}); # clamp value depending on cgroup version
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH container v2 4/5] config: ignore an empty tag list when parsing
2026-11-16 1:00 ` [PATCH qemu-server/container/manager v2 0/5] fix #7173: do not keep an empty tag list in guest configs Lucas Barros
` (2 preceding siblings ...)
2026-11-16 1:00 ` [PATCH container v2 3/5] fix #7173: api: update: delete tags when an empty tag list is set Lucas Barros
@ 2026-11-16 1:00 ` Lucas Barros
2026-11-16 1:00 ` [PATCH manager v2 5/5] fix #7173: ui: guest: delete tags when removing the last tag Lucas Barros
4 siblings, 0 replies; 8+ messages in thread
From: Lucas Barros @ 2026-11-16 1:00 UTC (permalink / raw)
To: pve-devel; +Cc: Lucas Barros
Configs of containers whose last tag was removed before the previous
commit still contain a 'tags: ' line. It is read as a tag list
consisting of a single space and shows up as such in the API, while a
'tags:' line without the trailing space is reported as a line that
cannot be parsed.
An empty tag list is the same as having no tags, so skip such a line
when parsing, like an unset option. Use split_list() to decide whether
the list is empty, so a value consisting only of delimiters is handled
the same way. Configs that contain such a line lose it on the next
write.
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
---
changes since v1:
* new patch, replaces the writer change of v1
The new subtest builds the config in a string, so the 'tags: ' case
with the trailing space is covered without trailing whitespace in the
test file.
This patch was prepared with the help of an LLM based coding assistant;
I reviewed the change and ran the tests mentioned in the cover letter
myself.
src/PVE/LXC/Config.pm | 3 +++
src/test/config_tests.pl | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index 7052509..2d47228 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -1199,6 +1199,9 @@ sub parse_pct_config {
} else {
$handle_error->("vm $vmid - property 'delete' is only allowed in [pve:pending]\n");
}
+ } elsif ($line =~ m/^tags:\s*(.*?)\s*$/ && !PVE::Tools::split_list($1)) {
+ # an empty tag list is the same as no tags
+ next;
} elsif ($line =~ m/^([a-z][a-z_]*\d*):\s*(.+?)\s*$/) {
my $key = $1;
my $value = $2;
diff --git a/src/test/config_tests.pl b/src/test/config_tests.pl
index fbf1771..855681e 100755
--- a/src/test/config_tests.pl
+++ b/src/test/config_tests.pl
@@ -151,4 +151,25 @@ subtest 'parsing drops keys outside of the schema' => sub {
is($conf->{memory}, 'invalid', 'invalid value of a known key is kept');
};
+subtest 'parsing ignores an empty tag list' => sub {
+ # 'tags: ' with the trailing space is what got written after removing the last tag
+ for my $tags ('', ' ', ' ;, ') {
+ my $raw = "hostname: ct100\ntags:$tags\n";
+
+ my $conf;
+ {
+ my $warnings = '';
+ local $SIG{__WARN__} = sub { $warnings .= $_[0] };
+ $conf = PVE::LXC::Config::parse_pct_config('/lxc/100.conf', $raw);
+ is($warnings, '', "no warning for 'tags:$tags'");
+ }
+
+ is($conf->{hostname}, 'ct100', 'valid key is kept');
+ ok(!exists($conf->{tags}), "'tags:$tags' is dropped");
+ }
+
+ my $conf = PVE::LXC::Config::parse_pct_config('/lxc/100.conf', "tags: a;b\n");
+ is($conf->{tags}, 'a;b', 'non-empty tag list is kept');
+};
+
done_testing();
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH manager v2 5/5] fix #7173: ui: guest: delete tags when removing the last tag
2026-11-16 1:00 ` [PATCH qemu-server/container/manager v2 0/5] fix #7173: do not keep an empty tag list in guest configs Lucas Barros
` (3 preceding siblings ...)
2026-11-16 1:00 ` [PATCH container v2 4/5] config: ignore an empty tag list when parsing Lucas Barros
@ 2026-11-16 1:00 ` Lucas Barros
4 siblings, 0 replies; 8+ messages in thread
From: Lucas Barros @ 2026-11-16 1:00 UTC (permalink / raw)
To: pve-devel; +Cc: Lucas Barros
Removing the last tag of a guest in the tag editor of the guest panel
sends an empty 'tags' value, which is stored as an empty 'tags:' line in
the guest config.
Delete the option instead when no tag is left, which is what the
removal of the last tag means and also works with backends that do not
turn an empty tag list into a deletion themselves.
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
---
changes since v1:
* new patch
Works on its own against nodes without patches 1/5 and 3/5, as
deleting 'tags' was always possible.
This patch was prepared with the help of an LLM based coding assistant;
I reviewed the change and ran the tests mentioned in the cover letter
myself.
www/manager6/lxc/Config.js | 4 +---
www/manager6/qemu/Config.js | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js
index 3a99d6a7..536ea557 100644
--- a/www/manager6/lxc/Config.js
+++ b/www/manager6/lxc/Config.js
@@ -208,9 +208,7 @@ Ext.define('PVE.lxc.Config', {
Proxmox.Utils.API2Request({
url: base_url + '/config',
method: 'PUT',
- params: {
- tags,
- },
+ params: tags ? { tags } : { delete: 'tags' },
success: function () {
me.statusStore.load();
},
diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js
index 842d35de..85a5e78e 100644
--- a/www/manager6/qemu/Config.js
+++ b/www/manager6/qemu/Config.js
@@ -255,9 +255,7 @@ Ext.define('PVE.qemu.Config', {
Proxmox.Utils.API2Request({
url: base_url + '/config',
method: 'PUT',
- params: {
- tags,
- },
+ params: tags ? { tags } : { delete: 'tags' },
success: function () {
me.statusStore.load();
},
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-16 1:01 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09 13:56 [PATCH qemu-server] fix #7173: config: do not write out an empty tag list Lucas Barros
2026-11-11 9:53 ` Fabian Grünbichler
2026-11-16 1:00 ` [PATCH qemu-server/container/manager v2 0/5] fix #7173: do not keep an empty tag list in guest configs Lucas Barros
2026-11-16 1:00 ` [PATCH qemu-server v2 1/5] fix #7173: api: update: delete tags when an empty tag list is set Lucas Barros
2026-11-16 1:00 ` [PATCH qemu-server v2 2/5] config: ignore an empty tag list when parsing Lucas Barros
2026-11-16 1:00 ` [PATCH container v2 3/5] fix #7173: api: update: delete tags when an empty tag list is set Lucas Barros
2026-11-16 1:00 ` [PATCH container v2 4/5] config: ignore an empty tag list when parsing Lucas Barros
2026-11-16 1:00 ` [PATCH manager v2 5/5] fix #7173: ui: guest: delete tags when removing the last tag Lucas Barros
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.