* [PATCH container v10 01/10] fix #3711: warn about storage errors during mountpoint delete
2026-07-01 14:13 [PATCH container/qemu-server v10 00/10] fix #3711 and adapt drive detach/remove behavior Michael Köppl
@ 2026-07-01 14:13 ` Michael Köppl
2026-07-01 14:13 ` [PATCH container v10 02/10] destroy_lxc, delete_mp_volume: rename $volume to $volid Michael Köppl
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Köppl @ 2026-07-01 14:13 UTC (permalink / raw)
To: pve-devel
Errors during deletion of a mountpoint volume should not stop users from
destroying a container. Instead of failing, a warning is printed and the
destruction of the container continues.
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Originally-by: Stefan Hrdlicka <s.hrdlicka@proxmox.com>
[ MK: remove ignore-storage-errors param ]
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/LXC.pm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index a9e9be9a..aa5ff315 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1032,7 +1032,8 @@ sub destroy_lxc_container {
return if $volids->{$volume};
$volids->{$volume} = 1;
- delete_mountpoint_volume($storage_cfg, $vmid, $volume);
+ eval { delete_mountpoint_volume($storage_cfg, $vmid, $volume); };
+ PVE::RESTEnvironment::log_warn("failed to delete mountpoint volume $volume: $@") if $@;
};
PVE::LXC::Config->foreach_volume_full($conf, { include_unused => 1 }, $remove_volume);
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH container v10 02/10] destroy_lxc, delete_mp_volume: rename $volume to $volid
2026-07-01 14:13 [PATCH container/qemu-server v10 00/10] fix #3711 and adapt drive detach/remove behavior Michael Köppl
2026-07-01 14:13 ` [PATCH container v10 01/10] fix #3711: warn about storage errors during mountpoint delete Michael Köppl
@ 2026-07-01 14:13 ` Michael Köppl
2026-07-01 14:13 ` [PATCH container v10 03/10] config: ensure valid volid through parse_volume() Michael Köppl
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Köppl @ 2026-07-01 14:13 UTC (permalink / raw)
To: pve-devel
$volid states more clearly that it's a volume ID, avoiding confusion
about the values these variables hold.
No functional change intended.
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/LXC.pm | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index aa5ff315..e76da29f 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1007,16 +1007,16 @@ sub get_primary_ips {
}
sub delete_mountpoint_volume {
- my ($storage_cfg, $vmid, $volume) = @_;
+ my ($storage_cfg, $vmid, $volid) = @_;
- return if PVE::LXC::Config->classify_mountpoint($volume) ne 'volume';
+ return if PVE::LXC::Config->classify_mountpoint($volid) ne 'volume';
- my ($vtype, $name, $owner) = PVE::Storage::parse_volname($storage_cfg, $volume);
+ my ($vtype, $name, $owner) = PVE::Storage::parse_volname($storage_cfg, $volid);
if ($vmid == $owner) {
- PVE::Storage::vdisk_free($storage_cfg, $volume);
+ PVE::Storage::vdisk_free($storage_cfg, $volid);
} else {
- warn "ignore deletion of '$volume', CT $vmid isn't the owner!\n";
+ warn "ignore deletion of '$volid', CT $vmid isn't the owner!\n";
}
}
@@ -1027,13 +1027,13 @@ sub destroy_lxc_container {
my $remove_volume = sub {
my ($ms, $mountpoint) = @_;
- my $volume = $mountpoint->{volume};
+ my $volid = $mountpoint->{volume};
- return if $volids->{$volume};
- $volids->{$volume} = 1;
+ return if $volids->{$volid};
+ $volids->{$volid} = 1;
- eval { delete_mountpoint_volume($storage_cfg, $vmid, $volume); };
- PVE::RESTEnvironment::log_warn("failed to delete mountpoint volume $volume: $@") if $@;
+ eval { delete_mountpoint_volume($storage_cfg, $vmid, $volid); };
+ PVE::RESTEnvironment::log_warn("failed to delete mountpoint volume $volid: $@") if $@;
};
PVE::LXC::Config->foreach_volume_full($conf, { include_unused => 1 }, $remove_volume);
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH container v10 03/10] config: ensure valid volid through parse_volume()
2026-07-01 14:13 [PATCH container/qemu-server v10 00/10] fix #3711 and adapt drive detach/remove behavior Michael Köppl
2026-07-01 14:13 ` [PATCH container v10 01/10] fix #3711: warn about storage errors during mountpoint delete Michael Köppl
2026-07-01 14:13 ` [PATCH container v10 02/10] destroy_lxc, delete_mp_volume: rename $volume to $volid Michael Köppl
@ 2026-07-01 14:13 ` Michael Köppl
2026-07-01 14:13 ` [PATCH container v10 04/10] lxc config: add helper for parsing volid and checking if storage exists Michael Köppl
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Köppl @ 2026-07-01 14:13 UTC (permalink / raw)
To: pve-devel
Even though the value in $conf->{$opt} contains a volume ID for unused
mount points at the moment, this is not guaranteed to be true in the
future. To ensure that a valid volume ID is used here, run call
parse_volume() first.
No functional change is intended here as the values of $conf->{$opt}
and $mp->{volume} are identical for unused mount points at the moment.
Also add FIXME for the is_volume_in_use() check for the branch that
handles mountpoint volumes that are in use. Currently, the check only
works by accident. The value in $conf->{$opt} isn’t just a volume ID -
it contains other things as well (such as mp=<path>). However, the
check only considers 'rootfs' and entries like 'mp0', 'mp1', etc. as
valid volume IDs. As a result, the volume is not detected to be in use.
Using a valid volume id with the current implementation, the check would
always report that the volume is in use and the mountpoint volume would
not be deleted. The correct behavior should use a valid volume id to
ensure that the volume can be safely removed.
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/LXC/Config.pm | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index 80942d34..c8098538 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -1662,8 +1662,9 @@ sub vmconfig_hotplug_pending {
if ($LXC_FASTPLUG_OPTIONS->{$opt}) {
# pass
} elsif ($opt =~ m/^unused(\d+)$/) {
- PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $conf->{$opt})
- if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1);
+ my $volid = $class->parse_volume($opt, $conf->{$opt})->{volume};
+ PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $volid)
+ if !$class->is_volume_in_use($conf, $volid, 1, 1);
} elsif ($opt eq 'swap') {
$hotplug_memory->(undef, 0);
} elsif ($opt eq 'cpulimit') {
@@ -1764,12 +1765,14 @@ sub vmconfig_apply_pending {
if ($opt =~ m/^mp(\d+)$/) {
my $mp = $class->parse_volume($opt, $conf->{$opt});
if ($mp->{type} eq 'volume') {
+ # FIXME: use $mp->{volume} for is_volume_in_use, fix conditions for check
$class->add_unused_volume($conf, $mp->{volume})
if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1);
}
} elsif ($opt =~ m/^unused(\d+)$/) {
- PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $conf->{$opt})
- if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1);
+ my $volid = $class->parse_volume($opt, $conf->{$opt})->{volume};
+ PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $volid)
+ if !$class->is_volume_in_use($conf, $volid, 1, 1);
} elsif ($opt =~ m/^net(\d+)$/) {
if ($have_sdn) {
my $net = $class->parse_lxc_network($conf->{$opt});
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH container v10 04/10] lxc config: add helper for parsing volid and checking if storage exists
2026-07-01 14:13 [PATCH container/qemu-server v10 00/10] fix #3711 and adapt drive detach/remove behavior Michael Köppl
` (2 preceding siblings ...)
2026-07-01 14:13 ` [PATCH container v10 03/10] config: ensure valid volid through parse_volume() Michael Köppl
@ 2026-07-01 14:13 ` Michael Köppl
2026-07-01 14:13 ` [PATCH container v10 05/10] allow pending mount point changes if storage is gone Michael Köppl
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Köppl @ 2026-07-01 14:13 UTC (permalink / raw)
To: pve-devel
Add a helper function to avoid repetition across multiple call sites
where a volume id is parsed and functions check for the existence of the
given storage, log a warning and return if it does not exist, and
perform some action otherwise (e.g. adding a disk as unused).
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/LXC/Config.pm | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index c8098538..57c93e8a 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -11,6 +11,7 @@ use PVE::DataCenterConfig;
use PVE::GuestHelpers;
use PVE::INotify;
use PVE::JSONSchema qw(get_standard_option);
+use PVE::RESTEnvironment;
use PVE::Tools;
use PVE::LXC;
@@ -1609,6 +1610,20 @@ sub calculate_memory_constraints {
return ($memory_max, $memory_high);
}
+# Skip and warn if a volume's backing storage was already removed from the storage config, so
+# guest/volume removal can still proceed.
+sub with_checked_volid {
+ my ($storecfg, $volid, $callback) = @_;
+
+ my ($storeid) = PVE::Storage::parse_volume_id($volid);
+ if (PVE::Storage::storage_config($storecfg, $storeid, 1)) {
+ $callback->();
+ } else {
+ PVE::RESTEnvironment::log_warn(
+ "storage '$storeid' no longer exists, volume '$volid' will be removed");
+ }
+}
+
my $LXC_FASTPLUG_OPTIONS = {
'description' => 1,
'onboot' => 1,
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH container v10 05/10] allow pending mount point changes if storage is gone
2026-07-01 14:13 [PATCH container/qemu-server v10 00/10] fix #3711 and adapt drive detach/remove behavior Michael Köppl
` (3 preceding siblings ...)
2026-07-01 14:13 ` [PATCH container v10 04/10] lxc config: add helper for parsing volid and checking if storage exists Michael Köppl
@ 2026-07-01 14:13 ` Michael Köppl
2026-07-01 14:13 ` [PATCH container v10 06/10] destroy template: add early check for linked clones of volumes Michael Köppl
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Köppl @ 2026-07-01 14:13 UTC (permalink / raw)
To: pve-devel
Previously, applying a pending removal of an unused volume whose
backing storage was already removed would fail with "unable to apply
pending change unusedN", leaving a dangling reference that could never
be cleaned up.
Guard the volume deletion in vmconfig_apply_pending and
vmconfig_hotplug_pending with a check to ensure that the storage
exists. If the storage is gone, drop the entry with a warning instead of
trying to free a volume that no longer exists.
Apply the same check when a detached mount point is turned into an
'unusedN' entry, so a volume on a removed storage is not re-added as a
dangling unused entry, matching VM behavior.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/LXC/Config.pm | 42 +++++++++++++++++++++++++++++++++---------
1 file changed, 33 insertions(+), 9 deletions(-)
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index 57c93e8a..8c99c931 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -1678,8 +1678,14 @@ sub vmconfig_hotplug_pending {
# pass
} elsif ($opt =~ m/^unused(\d+)$/) {
my $volid = $class->parse_volume($opt, $conf->{$opt})->{volume};
- PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $volid)
- if !$class->is_volume_in_use($conf, $volid, 1, 1);
+ with_checked_volid(
+ $storecfg,
+ $volid,
+ sub {
+ PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $volid)
+ if !$class->is_volume_in_use($conf, $volid, 1, 1);
+ },
+ );
} elsif ($opt eq 'swap') {
$hotplug_memory->(undef, 0);
} elsif ($opt eq 'cpulimit') {
@@ -1780,14 +1786,26 @@ sub vmconfig_apply_pending {
if ($opt =~ m/^mp(\d+)$/) {
my $mp = $class->parse_volume($opt, $conf->{$opt});
if ($mp->{type} eq 'volume') {
- # FIXME: use $mp->{volume} for is_volume_in_use, fix conditions for check
- $class->add_unused_volume($conf, $mp->{volume})
- if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1);
+ with_checked_volid(
+ $storecfg,
+ $mp->{volume},
+ sub {
+ # FIXME: use $mp->{volume} for is_volume_in_use, fix conditions for check
+ $class->add_unused_volume($conf, $mp->{volume})
+ if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1);
+ },
+ );
}
} elsif ($opt =~ m/^unused(\d+)$/) {
my $volid = $class->parse_volume($opt, $conf->{$opt})->{volume};
- PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $volid)
- if !$class->is_volume_in_use($conf, $volid, 1, 1);
+ with_checked_volid(
+ $storecfg,
+ $volid,
+ sub {
+ PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $volid)
+ if !$class->is_volume_in_use($conf, $volid, 1, 1);
+ },
+ );
} elsif ($opt =~ m/^net(\d+)$/) {
if ($have_sdn) {
my $net = $class->parse_lxc_network($conf->{$opt});
@@ -1906,8 +1924,14 @@ sub apply_pending_mountpoint {
if (defined($old)) {
my $mp = $class->parse_volume($opt, $old);
if ($mp->{type} eq 'volume') {
- $class->add_unused_volume($conf, $mp->{volume})
- if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1);
+ with_checked_volid(
+ $storecfg,
+ $mp->{volume},
+ sub {
+ $class->add_unused_volume($conf, $mp->{volume})
+ if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1);
+ },
+ );
}
}
}
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH container v10 06/10] destroy template: add early check for linked clones of volumes
2026-07-01 14:13 [PATCH container/qemu-server v10 00/10] fix #3711 and adapt drive detach/remove behavior Michael Köppl
` (4 preceding siblings ...)
2026-07-01 14:13 ` [PATCH container v10 05/10] allow pending mount point changes if storage is gone Michael Köppl
@ 2026-07-01 14:13 ` Michael Köppl
2026-07-01 14:13 ` [PATCH qemu-server v10 07/10] adapt linked clone check to not die if an error occurs during check Michael Köppl
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Köppl @ 2026-07-01 14:13 UTC (permalink / raw)
To: pve-devel
This check matches the behavior already implemented for VMs and prevents
partial storage deletion if a container template has a linked clone. In
such cases, the destruction of the container template will now fail,
informing the user that the base volume is still in use by the linked
clone. In case of a storage error (such as the underlying storage not
existing anymore), a warning will be printed and execution continues,
mimicking the handling of storage errors in later stages of
destroy_lxc_container().
Originally-by: Stefan Hrdlicka <s.hrdlicka@proxmox.com>
[ MK: use classify_mountpoint instead of pattern matching
display warning for storage errors during linked clone check
resolve style nit ]
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/LXC.pm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index e76da29f..3d217f24 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1024,6 +1024,28 @@ sub destroy_lxc_container {
my ($storage_cfg, $vmid, $conf, $replacement_conf, $purge_unreferenced) = @_;
my $volids = {};
+
+ if ($conf->{template}) {
+ PVE::LXC::Config->foreach_volume_full(
+ $conf,
+ { include_unused => 1 },
+ sub {
+ my ($ms, $mountpoint) = @_;
+ my $volid = $mountpoint->{volume};
+ return if !$volid || PVE::LXC::Config->classify_mountpoint($volid) ne 'volume';
+ my $result =
+ eval { PVE::Storage::volume_is_base_and_used($storage_cfg, $volid) };
+ if ($@) {
+ # early check, removal of volume will fail later anyway, so warning here is fine
+ PVE::RESTEnvironment::log_warn(
+ "failed to check if volume '$volid' is used by linked clones: $@");
+ }
+
+ die "base volume '$volid' is still in use by linked clone\n" if $result;
+ },
+ );
+ }
+
my $remove_volume = sub {
my ($ms, $mountpoint) = @_;
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH qemu-server v10 07/10] adapt linked clone check to not die if an error occurs during check
2026-07-01 14:13 [PATCH container/qemu-server v10 00/10] fix #3711 and adapt drive detach/remove behavior Michael Köppl
` (5 preceding siblings ...)
2026-07-01 14:13 ` [PATCH container v10 06/10] destroy template: add early check for linked clones of volumes Michael Köppl
@ 2026-07-01 14:13 ` Michael Köppl
2026-07-01 14:13 ` [PATCH qemu-server v10 08/10] fix #3711: make removal of VM possible if store does not exist anymore Michael Köppl
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Michael Köppl @ 2026-07-01 14:13 UTC (permalink / raw)
To: pve-devel
Align error handling behavior when checking for linked clones with the
rest of destroy_vm's error handling approach. In case an error occurred,
a warning is printed and the execution continues, since:
1. The same validation occurs later in the process
2. The VM removal will still be blocked if the volume has linked clones
Originally-by: Stefan Hrdlicka <s.hrdlicka@proxmox.com>
[ MK: log_warn if check fails instead of ignoring
resolve style nits ]
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/QemuServer.pm | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index cdf66e89..50fd66a5 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -1838,8 +1838,11 @@ sub destroy_vm {
my $volid = $drive->{file};
return if !$volid || $volid =~ m|^/|;
- die "base volume '$volid' is still in use by linked cloned\n"
- if PVE::Storage::volume_is_base_and_used($storecfg, $volid);
+ my $result = eval { PVE::Storage::volume_is_base_and_used($storecfg, $volid) };
+ # early check, removal of volume will fail later anyway, so warning here is fine
+ log_warn("failed to check if volume '$volid' is used by linked clones: $@")
+ if $@;
+ die "base volume '$volid' is still in use by linked cloned\n" if $result;
},
);
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH qemu-server v10 08/10] fix #3711: make removal of VM possible if store does not exist anymore
2026-07-01 14:13 [PATCH container/qemu-server v10 00/10] fix #3711 and adapt drive detach/remove behavior Michael Köppl
` (6 preceding siblings ...)
2026-07-01 14:13 ` [PATCH qemu-server v10 07/10] adapt linked clone check to not die if an error occurs during check Michael Köppl
@ 2026-07-01 14:13 ` Michael Köppl
2026-07-01 14:13 ` [PATCH qemu-server v10 09/10] destroy_vm: use log_warn for vdisk_free errors for consistency Michael Köppl
2026-07-01 14:13 ` [PATCH qemu-server v10 10/10] display warnings for storage errors or if storage no longer exists Michael Köppl
9 siblings, 0 replies; 11+ messages in thread
From: Michael Köppl @ 2026-07-01 14:13 UTC (permalink / raw)
To: pve-devel
Similar to the handling of storage errors in other parts of
destroy_vm(), an error during the call to PVE::Storage::path() should
not stop the VM from being destroyed. Instead, the user should be warned
and the function should continue.
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Originally-by: Stefan Hrdlicka <s.hrdlicka@proxmox.com>
[ MK: log_warn if check fails instead of ignoring error ]
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/QemuServer.pm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 50fd66a5..b69af937 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -1857,7 +1857,8 @@ sub destroy_vm {
return if !$volid || $volid =~ m|^/|;
return if $volids->{$volid};
- my ($path, $owner) = PVE::Storage::path($storecfg, $volid);
+ my ($path, $owner) = eval { PVE::Storage::path($storecfg, $volid) };
+ log_warn("failed to get path and owner of volume '$volid': $@") if $@;
return if !$path || !$owner || ($owner != $vmid);
$volids->{$volid} = 1;
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH qemu-server v10 09/10] destroy_vm: use log_warn for vdisk_free errors for consistency
2026-07-01 14:13 [PATCH container/qemu-server v10 00/10] fix #3711 and adapt drive detach/remove behavior Michael Köppl
` (7 preceding siblings ...)
2026-07-01 14:13 ` [PATCH qemu-server v10 08/10] fix #3711: make removal of VM possible if store does not exist anymore Michael Köppl
@ 2026-07-01 14:13 ` Michael Köppl
2026-07-01 14:13 ` [PATCH qemu-server v10 10/10] display warnings for storage errors or if storage no longer exists Michael Köppl
9 siblings, 0 replies; 11+ messages in thread
From: Michael Köppl @ 2026-07-01 14:13 UTC (permalink / raw)
To: pve-devel
To make warnings visually consistent with the handling of other storage
errors in destroy_vm(), replace the use of warn with log_warn.
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/QemuServer.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index b69af937..3fb499a9 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -1863,7 +1863,7 @@ sub destroy_vm {
$volids->{$volid} = 1;
eval { PVE::Storage::vdisk_free($storecfg, $volid) };
- warn "Could not remove disk '$volid', check manually: $@" if $@;
+ log_warn("Could not remove disk '$volid', check manually: $@") if $@;
};
# only remove disks owned by this VM (referenced in the config)
@@ -1889,7 +1889,7 @@ sub destroy_vm {
sub {
my ($volid, $sid, $volname, $d) = @_;
eval { PVE::Storage::vdisk_free($storecfg, $volid) };
- warn $@ if $@;
+ log_warn($@) if $@;
},
);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH qemu-server v10 10/10] display warnings for storage errors or if storage no longer exists
2026-07-01 14:13 [PATCH container/qemu-server v10 00/10] fix #3711 and adapt drive detach/remove behavior Michael Köppl
` (8 preceding siblings ...)
2026-07-01 14:13 ` [PATCH qemu-server v10 09/10] destroy_vm: use log_warn for vdisk_free errors for consistency Michael Köppl
@ 2026-07-01 14:13 ` Michael Köppl
9 siblings, 0 replies; 11+ messages in thread
From: Michael Köppl @ 2026-07-01 14:13 UTC (permalink / raw)
To: pve-devel
Instead of continuing without informing the user, a warning will now be
displayed if the owner of a volume could not be determined due to a
storage error. In addition, an explicit check for the existence of the
underlying storage is added before the ownership check. If the storage
no longer exists, a warning will be displayed, consistent with the
handling of this scenario in other functions.
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/QemuServer.pm | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 3fb499a9..1ca4e911 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -1557,6 +1557,7 @@ sub vm_is_volid_owner {
if ($volid !~ m|^/|) {
my ($path, $owner);
eval { ($path, $owner) = PVE::Storage::path($storecfg, $volid); };
+ log_warn("ownership of volume '$volid' could not be determined: $@") if $@;
if ($owner && ($owner == $vmid)) {
return 1;
}
@@ -1574,8 +1575,13 @@ sub vmconfig_register_unused_drive {
delete $conf->{'special-sections'}->{cloudinit};
} elsif (!drive_is_cdrom($drive)) {
my $volid = $drive->{file};
- if (vm_is_volid_owner($storecfg, $vmid, $volid)) {
- PVE::QemuConfig->add_unused_volume($conf, $volid, $vmid);
+ my ($storeid, undef) = PVE::Storage::parse_volume_id($volid);
+ if (PVE::Storage::storage_config($storecfg, $storeid, 1)) {
+ if (vm_is_volid_owner($storecfg, $vmid, $volid)) {
+ PVE::QemuConfig->add_unused_volume($conf, $volid, $vmid);
+ }
+ } else {
+ log_warn("storage '$storeid' no longer exists, volume '$volid' will be removed");
}
}
}
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread