In preparation to add a new one.

Signed-off-by: Fiona Ebner <f.eb...@proxmox.com>
---
 PVE/API2/Qemu.pm        | 12 +++++++-----
 PVE/QemuServer/Drive.pm |  6 ++++--
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 626cce45..003934ef 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -88,7 +88,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);
@@ -101,7 +102,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'}) {
@@ -917,7 +918,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(
@@ -2028,7 +2029,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, $vmid, undef, 
['VM.Config.Cloudinit', 'VM.Config.CDROM']);
                } elsif (PVE::QemuServer::drive_is_cdrom($drive, 1)) { # CDROM
@@ -2165,7 +2166,8 @@ 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)) {
                            push @bootorder, $opt;
                            $conf->{pending}->{boot} = 
PVE::QemuServer::print_bootorder(\@bootorder);
diff --git a/PVE/QemuServer/Drive.pm b/PVE/QemuServer/Drive.pm
index 878e1faa..eaa77234 100644
--- a/PVE/QemuServer/Drive.pm
+++ b/PVE/QemuServer/Drive.pm
@@ -707,7 +707,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);
 
@@ -718,7 +720,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

Reply via email to