From 763a2292f34a0def83307a7b185e8e00e7b154fd Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 6 Mar 2024 15:14:05 +0100 Subject: [PATCH] import: return skipped/ignored volumes in get_create_args Signed-off-by: Wolfgang Bumiller --- src/PVE/API2/Storage/Status.pm | 7 +------ src/PVE/Storage/ESXiPlugin.pm | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/PVE/API2/Storage/Status.pm b/src/PVE/API2/Storage/Status.pm index 84bb605..9198d4d 100644 --- a/src/PVE/API2/Storage/Status.pm +++ b/src/PVE/API2/Storage/Status.pm @@ -736,15 +736,10 @@ __PACKAGE__->register_method({ PVE::Storage::check_volume_access($rpcenv, $authuser, $cfg, undef, $volid); - my $create_args = PVE::Tools::run_with_timeout(30, sub { + return PVE::Tools::run_with_timeout(30, sub { my $import = PVE::Storage::get_import_metadata($cfg, $volid); return $import->get_create_args($target); }); - - return { - type => 'vm', # currently we only have this - 'create-args' => $create_args, - }; }}); 1; diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm index 940e776..2ce3ce4 100644 --- a/src/PVE/Storage/ESXiPlugin.pm +++ b/src/PVE/Storage/ESXiPlugin.pm @@ -898,6 +898,7 @@ sub get_create_args { my $manifest = $self->manifest; my $create_args = {}; + my $ignored_volumes = {}; my ($cores, $sockets) = $self->cpu_info(); $create_args->{cores} = $cores if $cores != 1; @@ -973,7 +974,14 @@ sub get_create_args { } my $count = $counts{$bus}++; - $create_args->{"${bus}${count}"} = "$default_storage:0,import-from=$storeid:$path"; + if ($kind eq 'cdrom') { + # We currently do not pass cdroms through via the esxi storage. + # Users should adapt import these from the storages directly/manually. + $create_args->{"${bus}${count}"} = "none,media=cdrom"; + $ignored_volumes->{"${bus}${count}"} = "$storeid:$path"; + } else { + $create_args->{"${bus}${count}"} = "$default_storage:0,import-from=$storeid:$path"; + } $boot_order .= ';' if length($boot_order); $boot_order .= $bus.$count; @@ -1009,7 +1017,11 @@ sub get_create_args { $create_args->{name} = $name if length($name); } - return $create_args; + return { + type => 'vm', + 'create-args' => $create_args, + 'ignored-volumes' => $ignored_volumes, + }; } 1;