From: Lucas Barros <lucasbarros.kam@gmail.com>
To: pve-devel@lists.proxmox.com
Cc: Lucas Barros <lucasbarros.kam@gmail.com>
Subject: [PATCH qemu-server v2 2/5] config: ignore an empty tag list when parsing
Date: Sun, 15 Nov 2026 22:00:37 -0300 [thread overview]
Message-ID: <20261116010040.90964-3-lucasbarros.kam@gmail.com> (raw)
In-Reply-To: <20261116010040.90964-1-lucasbarros.kam@gmail.com>
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)
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 ` Lucas Barros [this message]
2026-11-16 1:00 ` [PATCH container v2 3/5] " 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
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-3-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