From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 876D21FF183 for <inbox@lore.proxmox.com>; Wed, 18 Jun 2025 15:02:11 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 704F7122EC; Wed, 18 Jun 2025 15:02:21 +0200 (CEST) From: Fiona Ebner <f.ebner@proxmox.com> To: pve-devel@lists.proxmox.com Date: Wed, 18 Jun 2025 15:01:43 +0200 Message-Id: <20250618130209.90649-7-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618130209.90649-1-f.ebner@proxmox.com> References: <20250618130209.90649-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.031 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu-server v2 06/32] drive: parse: use hash argument for optional parameters X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> In preparation to add a new one. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> --- No changes in v2. src/PVE/API2/Qemu.pm | 15 ++++++++++----- src/PVE/QemuServer/Drive.pm | 6 ++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm index ce6f362d..9b07db25 100644 --- a/src/PVE/API2/Qemu.pm +++ b/src/PVE/API2/Qemu.pm @@ -89,7 +89,8 @@ my $foreach_volume_with_alloc = sub { for my $opt (sort keys $param->%*) { next if !PVE::QemuServer::is_valid_drivename($opt); - my $drive = PVE::QemuServer::Drive::parse_drive($opt, $param->{$opt}, 1); + my $drive = + PVE::QemuServer::Drive::parse_drive($opt, $param->{$opt}, { 'with-alloc' => 1 }); next if !$drive; $func->($opt, $drive); @@ -102,7 +103,7 @@ my $check_drive_param = sub { for my $opt (sort keys $param->%*) { next if !PVE::QemuServer::is_valid_drivename($opt); - my $drive = PVE::QemuServer::parse_drive($opt, $param->{$opt}, 1); + my $drive = PVE::QemuServer::parse_drive($opt, $param->{$opt}, { 'with-alloc' => 1 }); raise_param_exc({ $opt => "unable to parse drive options" }) if !$drive; if ($drive->{'import-from'}) { @@ -969,7 +970,7 @@ my $check_vm_modify_config_perm = sub { sub assert_scsi_feature_compatibility { my ($opt, $conf, $storecfg, $drive_attributes) = @_; - my $drive = PVE::QemuServer::Drive::parse_drive($opt, $drive_attributes, 1); + my $drive = PVE::QemuServer::Drive::parse_drive($opt, $drive_attributes, { 'with-alloc' => 1 }); my $machine_type = PVE::QemuServer::Machine::get_vm_machine($conf, undef, $conf->{arch}); my $machine_version = PVE::QemuServer::Machine::extract_version( @@ -2144,7 +2145,7 @@ my $update_vm_api = sub { my $check_drive_perms = sub { my ($opt, $val) = @_; - my $drive = PVE::QemuServer::parse_drive($opt, $val, 1); + my $drive = PVE::QemuServer::parse_drive($opt, $val, { 'with-alloc' => 1 }); if (PVE::QemuServer::drive_is_cloudinit($drive)) { $rpcenv->check_vm_perm( $authuser, @@ -2311,7 +2312,11 @@ my $update_vm_api = sub { # default legacy boot order implies all cdroms anyway if (@bootorder) { # append new CD drives to bootorder to mark them bootable - my $drive = PVE::QemuServer::parse_drive($opt, $param->{$opt}, 1); + my $drive = PVE::QemuServer::parse_drive( + $opt, + $param->{$opt}, + { 'with-alloc' => 1 }, + ); if ( PVE::QemuServer::drive_is_cdrom($drive, 1) && !grep(/^$opt$/, @bootorder) diff --git a/src/PVE/QemuServer/Drive.pm b/src/PVE/QemuServer/Drive.pm index 0947b9ed..b9ceb130 100644 --- a/src/PVE/QemuServer/Drive.pm +++ b/src/PVE/QemuServer/Drive.pm @@ -770,7 +770,9 @@ sub drive_is_read_only { # [,iothread=on][,serial=serial][,model=model] sub parse_drive { - my ($key, $data, $with_alloc) = @_; + my ($key, $data, $parse_opts) = @_; + + $parse_opts //= {}; my ($interface, $index); @@ -781,7 +783,7 @@ sub parse_drive { return; } - my $desc_hash = $with_alloc ? $drivedesc_hash_with_alloc : $drivedesc_hash; + my $desc_hash = $parse_opts->{'with-alloc'} ? $drivedesc_hash_with_alloc : $drivedesc_hash; if (!defined($desc_hash->{$key})) { warn "invalid drive key: $key\n"; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel