From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server v5 12/16] check type: require schema as an argument
Date: Mon, 27 Jan 2025 12:29:19 +0100 [thread overview]
Message-ID: <20250127112923.31703-13-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250127112923.31703-1-f.ebner@proxmox.com>
In preparation to re-use the helper with a dedicated schema for a
'fleecing' special section.
No functional change intended.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
PVE/QemuServer.pm | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 8c26fbc3..7711014d 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2081,11 +2081,13 @@ sub cloudinit_pending_properties {
}
sub check_type {
- my ($key, $value) = @_;
+ my ($key, $value, $schema) = @_;
- die "unknown setting '$key'\n" if !$confdesc->{$key};
+ die "check_type: no schema defined\n" if !$schema;
- my $type = $confdesc->{$key}->{type};
+ die "unknown setting '$key'\n" if !$schema->{$key};
+
+ my $type = $schema->{$key}->{type};
if (!defined($value)) {
die "got undefined value\n";
@@ -2106,7 +2108,7 @@ sub check_type {
return $value if $value =~ m/^(\d+)(\.\d+)?$/;
die "type check ('number') failed - got '$value'\n";
} elsif ($type eq 'string') {
- if (my $fmt = $confdesc->{$key}->{format}) {
+ if (my $fmt = $schema->{$key}->{format}) {
PVE::JSONSchema::check_format($fmt, $value);
return $value;
}
@@ -2301,7 +2303,7 @@ sub parse_vm_config {
$conf->{$key} = $value;
next;
}
- eval { $value = check_type($key, $value); };
+ eval { $value = check_type($key, $value, $confdesc); };
if ($@) {
$handle_error->("vm $vmid - unable to parse value of '$key' - $@");
} else {
@@ -2368,7 +2370,7 @@ sub write_vm_config {
# fixme: check syntax?
next;
}
- eval { $value = check_type($key, $value); };
+ eval { $value = check_type($key, $value, $confdesc); };
die "unable to parse value of '$key' - $@" if $@;
$cref->{$key} = $value;
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-01-27 11:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-27 11:29 [pve-devel] [PATCH-SERIES qemu-server v5 00/16] more robust handling of fleecing images Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 01/16] migration: remove unused variable Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 02/16] test: avoid duplicate mock module in restore config test Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 03/16] test: add parse config tests Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 04/16] parse config: be precise about section type checks Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 05/16] test: add test case exposing issue with unknown sections Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 06/16] parse config: skip unknown sections and warn about their presence Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 07/16] vzdump: anchor matches for pending and special sections Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 08/16] vzdump: skip all " Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 09/16] config: make special section handling generic Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 10/16] test: parse config: test config with duplicate sections Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 11/16] parse config: warn about " Fiona Ebner
2025-01-27 11:29 ` Fiona Ebner [this message]
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 13/16] config: add fleecing section Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 14/16] fix #5440: vzdump: better cleanup fleecing images after hard errors Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 15/16] migration: attempt to clean up potential left-over fleecing images Fiona Ebner
2025-01-27 11:29 ` [pve-devel] [PATCH qemu-server v5 16/16] destroy vm: " Fiona Ebner
2025-03-07 10:45 ` [pve-devel] [PATCH-SERIES qemu-server v5 00/16] more robust handling of " Fiona Ebner
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=20250127112923.31703-13-f.ebner@proxmox.com \
--to=f.ebner@proxmox.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