all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [RFC PATCH qemu-server 0/4] allow VMs to start with missing CD-ROM
@ 2026-03-13 13:12 Daniel Herzig
  2026-03-13 13:12 ` [RFC PATCH qemu-server 1/4] drive: Introduce parameter to mark CD-ROM as dissmissable Daniel Herzig
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Daniel Herzig @ 2026-03-13 13:12 UTC (permalink / raw)
  To: pve-devel

Currently VMs refuse to start if a configured CD-ROM is unavailable for
a reason.

1) This is desirable if the CD-ROM is essential for the VM.
2) It can however can be inconvenient, if the CD-ROM was just used at
for initial guest installation (and later on 'forgotten').

If the corresponding ISO e.g. resided on a network share, connectivity
issues to the network share prohibit the VM to start.

This RFC addresses case 2. It allows users to set a parameter
'dismissable' for a drive. If set, and if the drive is a
CD-ROM, the CD-ROM will be removed from the VM configuration
in the case of unavailability. As a consequence, the VM can start.

The removal of the file from the configuration will be logged through
log_warn() to have a backtrace of the process.

The RFC addresses the backend-side of #4225 on bugzilla [0] and
supersedes [1], integrating the valuable on- and offline input
on the topic.

[0] https://bugzilla.proxmox.com/show_bug.cgi?id=4225
[1] https://lore.proxmox.com/pve-devel/20250130113121.157273-1-d.herzig@proxmox.com/

*** BLURB HERE ***

qemu-server: Daniel Herzig (4):
  drive: Introduce parameter to mark CD-ROM as dissmissable
  drive: ignore 'dismissable' parameter for everything but CD-ROMs
  introduce sub 'activate_current_vm_volumes'
  integrate new sub 'activate_current_vm_volumes'

 src/PVE/QemuServer.pm       | 75 ++++++++++++++++++++++++++++++++-----
 src/PVE/QemuServer/Drive.pm | 10 +++++
 2 files changed, 75 insertions(+), 10 deletions(-)

-- 
2.47.3




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC PATCH qemu-server 1/4] drive: Introduce parameter to mark CD-ROM as dissmissable
  2026-03-13 13:12 [RFC PATCH qemu-server 0/4] allow VMs to start with missing CD-ROM Daniel Herzig
@ 2026-03-13 13:12 ` Daniel Herzig
  2026-03-13 13:12 ` [RFC PATCH qemu-server 2/4] drive: ignore 'dismissable' parameter for everything but CD-ROMs Daniel Herzig
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Herzig @ 2026-03-13 13:12 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Daniel Herzig <d.herzig@proxmox.com>
---
 src/PVE/QemuServer/Drive.pm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/PVE/QemuServer/Drive.pm b/src/PVE/QemuServer/Drive.pm
index 10106ebd..8539a1d3 100644
--- a/src/PVE/QemuServer/Drive.pm
+++ b/src/PVE/QemuServer/Drive.pm
@@ -254,6 +254,14 @@ my %drivedesc_base = (
         optional => 1,
         default => 0,
     },
+     dismissable => {
+         type => 'boolean',
+         description => 'Mark CD-ROM as dismissable for starting the VM.',
+         verbose_description =>
+             'If set to 1, file will be removed from config if unavailable.',
+         optional => 1,
+         default => 0,
+    },
 );
 
 my %iothread_fmt = (
-- 
2.47.3




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC PATCH qemu-server 2/4] drive: ignore 'dismissable' parameter for everything but CD-ROMs
  2026-03-13 13:12 [RFC PATCH qemu-server 0/4] allow VMs to start with missing CD-ROM Daniel Herzig
  2026-03-13 13:12 ` [RFC PATCH qemu-server 1/4] drive: Introduce parameter to mark CD-ROM as dissmissable Daniel Herzig
@ 2026-03-13 13:12 ` Daniel Herzig
  2026-03-13 13:12 ` [RFC PATCH qemu-server 3/4] introduce sub 'activate_current_vm_volumes' Daniel Herzig
  2026-03-13 13:12 ` [RFC PATCH qemu-server 4/4] integrate new " Daniel Herzig
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Herzig @ 2026-03-13 13:12 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Daniel Herzig <d.herzig@proxmox.com>
---
 src/PVE/QemuServer/Drive.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/PVE/QemuServer/Drive.pm b/src/PVE/QemuServer/Drive.pm
index 8539a1d3..43f89aae 100644
--- a/src/PVE/QemuServer/Drive.pm
+++ b/src/PVE/QemuServer/Drive.pm
@@ -854,6 +854,8 @@ sub parse_drive {
     if ($res->{media} && ($res->{media} eq 'cdrom')) {
         return if $res->{snapshot} || $res->{format};
         return if $res->{interface} eq 'virtio';
+    } else {
+	return if $res->{dismissable};
     }
 
     if (my $size = $res->{size}) {
-- 
2.47.3




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC PATCH qemu-server 3/4] introduce sub 'activate_current_vm_volumes'
  2026-03-13 13:12 [RFC PATCH qemu-server 0/4] allow VMs to start with missing CD-ROM Daniel Herzig
  2026-03-13 13:12 ` [RFC PATCH qemu-server 1/4] drive: Introduce parameter to mark CD-ROM as dissmissable Daniel Herzig
  2026-03-13 13:12 ` [RFC PATCH qemu-server 2/4] drive: ignore 'dismissable' parameter for everything but CD-ROMs Daniel Herzig
@ 2026-03-13 13:12 ` Daniel Herzig
  2026-03-13 13:12 ` [RFC PATCH qemu-server 4/4] integrate new " Daniel Herzig
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Herzig @ 2026-03-13 13:12 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Daniel Herzig <d.herzig@proxmox.com>
---
 src/PVE/QemuServer.pm | 54 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 09e7a19b..a7b98e01 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -6068,6 +6068,60 @@ sub get_current_vm_volumes {
     return $volumes;
 }
 
+=head3 activate_current_vm_volumes($storecfg, $conf, $vmid [, $statefile_volume])
+Activates VM volumes (With -blockdev, it is necessary to activate the volumes
+before generating the command line).
+
+NOTE: If $drive->{dismissable} is specified for a CD-ROM, C<$conf> may change.
+If $drive->{file} is unavailable, $drive->{file} will be set to 'none', and
+the entries $drive->{size} and $drive->{format} will be deleted.
+This will be written out to C<$conf>.
+
+=cut
+sub activate_current_vm_volumes {
+    my ($storecfg, $conf, $vmid, $statefile_volume, $storage_hints) = @_;
+    my $volumes_to_be_activated = [];
+    my $activated_volumes = [];
+
+    if ($statefile_volume) {
+	push $volumes_to_be_activated->@*, $statefile_volume;
+    }
+    PVE::QemuConfig->foreach_volume_full(
+        $conf,
+        { extra_keys => ['vmstate'] },
+        sub {
+            my ($ds, $drive) = @_;
+	    my $volid = $drive->{file};
+	    if (PVE::Storage::parse_volume_id($volid, 1)) {
+		check_volume_storage_type($storecfg, $volid);
+		if ($drive->{dismissable}) {
+		    eval { PVE::Storage::activate_volumes($storecfg, [$volid]) };
+		    if ($@) {
+			log_warn($@);
+			log_warn("removing dismissable CD-ROM from VM configuration: ". $volid);
+			$drive->{file} = "none";
+			delete $drive->{size};
+			delete $drive->{format};
+			$conf->{$ds} = print_drive($drive);
+			PVE::QemuConfig->write_config($vmid, $conf);
+		    } else {
+			push $activated_volumes->@*, $volid;
+		    }
+		} else {
+		    push $volumes_to_be_activated->@*, $volid;
+		}
+	    }
+	}
+    );
+    eval { PVE::Storage::activate_volumes($storecfg, $volumes_to_be_activated, undef, $storage_hints) };
+    if ($@) {
+	die $@;
+    } else {
+	push $activated_volumes->@*, $volumes_to_be_activated;
+    }
+    return $activated_volumes;
+}
+
 sub cleanup_pci_devices {
     my ($vmid, $conf) = @_;
 
-- 
2.47.3




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC PATCH qemu-server 4/4] integrate new sub 'activate_current_vm_volumes'
  2026-03-13 13:12 [RFC PATCH qemu-server 0/4] allow VMs to start with missing CD-ROM Daniel Herzig
                   ` (2 preceding siblings ...)
  2026-03-13 13:12 ` [RFC PATCH qemu-server 3/4] introduce sub 'activate_current_vm_volumes' Daniel Herzig
@ 2026-03-13 13:12 ` Daniel Herzig
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Herzig @ 2026-03-13 13:12 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Daniel Herzig <d.herzig@proxmox.com>
---
 src/PVE/QemuServer.pm | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index a7b98e01..8b4510d6 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -5598,16 +5598,18 @@ sub vm_start_nolock {
         $state_cmdline = ['-S'];
     }
 
-    my $vollist = get_current_vm_volumes($storecfg, $conf);
-    push $vollist->@*, $statefile if $statefile_is_a_volume;
+    my $storage_hints = generate_storage_hints($conf, 1);
+    my $activated_vollist;
+    if ($statefile_is_a_volume) {
+	$activated_vollist = activate_current_vm_volumes($storecfg, $conf, $vmid, $statefile, $storage_hints);
+    } else {
+	$activated_vollist = activate_current_vm_volumes($storecfg, $conf, $vmid, undef, $storage_hints);
+    }
 
     my ($cmd, $spice_port, $start_timeout);
     my $pci_reserve_list = [];
     eval {
-        # With -blockdev, it is necessary to activate the volumes before generating the command line
         # Plugins can safely deactivate already-active volumes here if needed
-        my $storage_hints = generate_storage_hints($conf, 1);
-        PVE::Storage::activate_volumes($storecfg, $vollist, undef, $storage_hints);
 
         check_efi_vars($storecfg, $vmid, $conf) if $conf->{bios} && $conf->{bios} eq 'ovmf';
 
@@ -5673,7 +5675,7 @@ sub vm_start_nolock {
         push @$cmd, '-uuid', $uuid if defined($uuid);
     };
     if (my $err = $@) {
-        eval { PVE::Storage::deactivate_volumes($storecfg, $vollist); };
+        eval { PVE::Storage::deactivate_volumes($storecfg, $activated_vollist); };
         warn $@ if $@;
         eval { cleanup_pci_devices($vmid, $conf) };
         warn $@ if $@;
@@ -5804,7 +5806,7 @@ sub vm_start_nolock {
 
     if (my $err = $@) {
         # deactivate volumes if start fails
-        eval { PVE::Storage::deactivate_volumes($storecfg, $vollist); };
+        eval { PVE::Storage::deactivate_volumes($storecfg, $activated_vollist); };
         warn $@ if $@;
         eval { cleanup_pci_devices($vmid, $conf) };
         warn $@ if $@;
@@ -5994,12 +5996,11 @@ sub vm_commandline {
     my $defaults = load_defaults();
 
     my $running = PVE::QemuServer::Helpers::vm_running_locally($vmid);
-    my $volumes = [];
+    my $activated_volumes = [];
 
     # With -blockdev, it is necessary to activate the volumes before generating the command line
     if (!$running) {
-        $volumes = get_current_vm_volumes($storecfg, $conf);
-        PVE::Storage::activate_volumes($storecfg, $volumes);
+        $activated_volumes = activate_current_vm_volumes($storecfg, $conf);
     }
 
     # There might be concurrent operations on the volumes, so do not deactivate.
-- 
2.47.3




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-13 13:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-13 13:12 [RFC PATCH qemu-server 0/4] allow VMs to start with missing CD-ROM Daniel Herzig
2026-03-13 13:12 ` [RFC PATCH qemu-server 1/4] drive: Introduce parameter to mark CD-ROM as dissmissable Daniel Herzig
2026-03-13 13:12 ` [RFC PATCH qemu-server 2/4] drive: ignore 'dismissable' parameter for everything but CD-ROMs Daniel Herzig
2026-03-13 13:12 ` [RFC PATCH qemu-server 3/4] introduce sub 'activate_current_vm_volumes' Daniel Herzig
2026-03-13 13:12 ` [RFC PATCH qemu-server 4/4] integrate new " Daniel Herzig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal