From: Daniel Herzig <d.herzig@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [RFC PATCH qemu-server 4/4] integrate new sub 'activate_current_vm_volumes'
Date: Fri, 13 Mar 2026 14:12:06 +0100 [thread overview]
Message-ID: <20260313131206.277195-5-d.herzig@proxmox.com> (raw)
In-Reply-To: <20260313131206.277195-1-d.herzig@proxmox.com>
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
prev parent reply other threads:[~2026-03-13 13:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Daniel Herzig [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260313131206.277195-5-d.herzig@proxmox.com \
--to=d.herzig@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.