* [pve-devel] [PATCH v3 qemu-server] fix #4201: delete cloud-init disk on rollback
@ 2022-11-11 15:46 Mira Limbeck
2022-11-11 18:27 ` [pve-devel] applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Mira Limbeck @ 2022-11-11 15:46 UTC (permalink / raw)
To: pve-devel
If the config doesn't contain the cloud-init disk anymore after the
rollback, we have to clean it up since otherwise no further disk can be
attached unless the one still existing on the storage is deleted.
Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
v3:
- rebased on top of master
- added R-b/T-b tags from v2
v2:
- chose the add_unused_volume way as @fiona recommended, the
implementation is a lot cleaner, but contains a cloudinit regex
- removed the 2nd patch for reusing already existing disks when
adding a cloudinit disk
PVE/QemuConfig.pm | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm
index 0939538..051382c 100644
--- a/PVE/QemuConfig.pm
+++ b/PVE/QemuConfig.pm
@@ -498,7 +498,7 @@ sub __snapshot_rollback_get_unused {
$class->foreach_volume($conf, sub {
my ($vs, $volume) = @_;
- return if PVE::QemuServer::drive_is_cdrom($volume);
+ return if PVE::QemuServer::drive_is_cdrom($volume, 1);
my $found = 0;
my $volid = $volume->{file};
@@ -507,7 +507,7 @@ sub __snapshot_rollback_get_unused {
my ($ds, $drive) = @_;
return if $found;
- return if PVE::QemuServer::drive_is_cdrom($drive);
+ return if PVE::QemuServer::drive_is_cdrom($drive, 1);
$found = 1
if ($drive->{file} && $drive->{file} eq $volid);
@@ -519,6 +519,19 @@ sub __snapshot_rollback_get_unused {
return $unused;
}
+sub add_unused_volume {
+ my ($class, $config, $volid) = @_;
+
+ if ($volid =~ m/vm-\d+-cloudinit/) {
+ print "found unused cloudinit disk '$volid', removing it\n";
+ my $storecfg = PVE::Storage::config();
+ PVE::Storage::vdisk_free($storecfg, $volid);
+ return undef;
+ } else {
+ return $class->SUPER::add_unused_volume($config, $volid);
+ }
+}
+
sub load_current_config {
my ($class, $vmid, $current) = @_;
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pve-devel] applied: [PATCH v3 qemu-server] fix #4201: delete cloud-init disk on rollback
2022-11-11 15:46 [pve-devel] [PATCH v3 qemu-server] fix #4201: delete cloud-init disk on rollback Mira Limbeck
@ 2022-11-11 18:27 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2022-11-11 18:27 UTC (permalink / raw)
To: Proxmox VE development discussion, Mira Limbeck
Am 11/11/2022 um 16:46 schrieb Mira Limbeck:
> If the config doesn't contain the cloud-init disk anymore after the
> rollback, we have to clean it up since otherwise no further disk can be
> attached unless the one still existing on the storage is deleted.
>
> Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
> Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
> Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
> ---
> v3:
> - rebased on top of master
> - added R-b/T-b tags from v2
> v2:
> - chose the add_unused_volume way as @fiona recommended, the
> implementation is a lot cleaner, but contains a cloudinit regex
>
> - removed the 2nd patch for reusing already existing disks when
> adding a cloudinit disk
>
> PVE/QemuConfig.pm | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
>
applied, thanks to both of you!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-11 18:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-11 15:46 [pve-devel] [PATCH v3 qemu-server] fix #4201: delete cloud-init disk on rollback Mira Limbeck
2022-11-11 18:27 ` [pve-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox