From: Lucas Barros <lucasbarros.kam@gmail.com>
To: pve-devel@lists.proxmox.com
Cc: Lucas Barros <lucasbarros.kam@gmail.com>
Subject: [PATCH container v2 3/5] fix #7173: api: update: delete tags when an empty tag list is set
Date: Sun, 15 Nov 2026 22:00:38 -0300 [thread overview]
Message-ID: <20261116010040.90964-4-lucasbarros.kam@gmail.com> (raw)
In-Reply-To: <20261116010040.90964-1-lucasbarros.kam@gmail.com>
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)
next prev parent reply other threads:[~2026-11-16 1:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Lucas Barros [this message]
2026-11-16 1:00 ` [PATCH container v2 4/5] " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116010040.90964-4-lucasbarros.kam@gmail.com \
--to=lucasbarros.kam@gmail.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox