[pve-devel] [PATCH qemu-server 2/3] cfg2cmd: only warn on non-existant ISO image

Stefan Reiter s.reiter at proxmox.com
Thu Jul 8 13:25:34 CEST 2021


...instead of hard failing. Requires a RPCEnvironment to issue the
warnings, so init a dummy one in run_config2command_tests.

Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---
 PVE/QemuServer.pm                | 10 ++++++++++
 test/run_config2command_tests.pl |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 0d8affa..4082e69 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3195,6 +3195,8 @@ sub config_to_command {
     my $kvm = $conf->{kvm};
     my $nodename = nodename();
 
+    my $rpcenv = PVE::RPCEnvironment::get();
+
     my $arch = get_vm_arch($conf);
     my $kvm_binary = get_command_for_arch($arch);
     my $kvmver = kvm_user_version($kvm_binary);
@@ -3635,6 +3637,14 @@ sub config_to_command {
     PVE::QemuConfig->foreach_volume($conf, sub {
 	my ($ds, $drive) = @_;
 
+	if (drive_is_cdrom($drive)) {
+	    my $iso_path = get_iso_path($storecfg, $vmid, $drive->{file});
+	    if ($iso_path ne '' && ! -e $iso_path) {
+		$rpcenv->warn("$ds: image '$iso_path' doesn't exist, ignoring for CDROM");
+		$drive->{file} = 'none';
+	    }
+	}
+
 	if (PVE::Storage::parse_volume_id($drive->{file}, 1)) {
 	    check_volume_storage_type($storecfg, $drive->{file});
 	    push @$vollist, $drive->{file};
diff --git a/test/run_config2command_tests.pl b/test/run_config2command_tests.pl
index 04df9d9..a2c3be3 100755
--- a/test/run_config2command_tests.pl
+++ b/test/run_config2command_tests.pl
@@ -404,6 +404,8 @@ sub do_test($) {
 
 print "testing config to command stabillity\n";
 
+PVE::RPCEnvironment->init('cli');
+
 # exec tests
 if (my $file = shift) {
     do_test $file;
-- 
2.30.2






More information about the pve-devel mailing list