From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id DA0E31FF0E1 for ; Mon, 16 Nov 2026 02:01:45 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id B4E72217C0; Mon, 16 Nov 2026 02:01:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794790850; x=1795395650; darn=lists.proxmox.com; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=7zY7W3kWjKmWD+fWVcKWNJOvvxQfM8FGuNAq2RxfXiU=; b=y/w4N+PoOlQssmSYnGfFu/he6Y60Rg08unw4fLr8i+sk+FEndyv4IyjGtu9mVik3bt TMNrp05/4scdX/TscPxWtKuzrhRi0zNP1vgYZVgumegLlUhZHr6A6b6UTUOrSIsI3b9k gbiMmogJOxaCX/8q5VPWxeTWIJcc2gQD6VCWMksf8ljO2naGtH053h0vFEkqCZ44Mhiy du4t+9pDo+GqR9zLwT5zLi3C517m0sgQFD7eo2ZTa3QylCCn5nY6A+df4E8yCd+lDaRa QsdjKQy3zH08c3UCsmTy6zAJE3uutd2ChC6BsOmQ2OL+gegJ/bw/pWq0aDLxY3+1linV LfOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794790850; x=1795395650; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7zY7W3kWjKmWD+fWVcKWNJOvvxQfM8FGuNAq2RxfXiU=; b=VtgDmU/sjAnYPyB50k7gakpJJTlX9pqs+XmerRV8bYVI31fbZZv5rk6EF6e05L06ut +w/9Rvqg9C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Oe5ULr9Lul5 cRj0lbPmM8FRYweSkxDS3Nq+AMHvEv9KOJ3qUBRQg X-Received: by 2002:a05:6102:4192:b0:7cc:2bb7:1321 with SMTP id ada2fe7eead31-7d64d8cab8emr2639191137.31.1794790849617; Sun, 15 Nov 2026 17:00:49 -0800 (PST) From: Lucas Barros To: pve-devel@lists.proxmox.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 Message-ID: <20261116010040.90964-3-lucasbarros.kam@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20261116010040.90964-1-lucasbarros.kam@gmail.com> References: <1794390075.ol4qipttrq.astroid@yuna.none> <20261116010040.90964-1-lucasbarros.kam@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.068 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy FREEMAIL_FROM 0.001 Sender email is commonly abused enduser mail provider RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: WSBMSBLXK2SNRSCTKXHW6AOJDIZFGKJ2 X-Message-ID-Hash: WSBMSBLXK2SNRSCTKXHW6AOJDIZFGKJ2 X-MailFrom: lucasbarros.kam@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Lucas Barros X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 Signed-off-by: Lucas Barros --- 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)