mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-04 05:39:26 +00:00
cloud-init: delete cloudinit images as if they weren't cdroms
This commit is contained in:
parent
3db6e4ab70
commit
9c52f5edb6
@ -45,6 +45,8 @@ my $qemu_snap_storage = {rbd => 1, sheepdog => 1};
|
|||||||
|
|
||||||
my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
|
my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
|
||||||
|
|
||||||
|
my $QEMU_FORMAT_RE = qr/raw|cow|qcow|qcow2|qed|vmdk|cloop/;
|
||||||
|
|
||||||
# Note about locking: we use flock on the config file protect
|
# Note about locking: we use flock on the config file protect
|
||||||
# against concurent actions.
|
# against concurent actions.
|
||||||
# Aditionaly, we have a 'lock' setting in the config file. This
|
# Aditionaly, we have a 'lock' setting in the config file. This
|
||||||
@ -1879,7 +1881,9 @@ sub print_cpu_device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub drive_is_cdrom {
|
sub drive_is_cdrom {
|
||||||
my ($drive) = @_;
|
my ($drive, $exclude_cloudinit) = @_;
|
||||||
|
|
||||||
|
return 0 if $exclude_cloudinit && $drive->{file} =~ m@[:/]vm-\d+-cloudinit(?:\.$QEMU_FORMAT_RE)?$@;
|
||||||
|
|
||||||
return $drive && $drive->{media} && ($drive->{media} eq 'cdrom');
|
return $drive && $drive->{media} && ($drive->{media} eq 'cdrom');
|
||||||
|
|
||||||
@ -2053,7 +2057,7 @@ sub vmconfig_undelete_pending_option {
|
|||||||
sub vmconfig_register_unused_drive {
|
sub vmconfig_register_unused_drive {
|
||||||
my ($storecfg, $vmid, $conf, $drive) = @_;
|
my ($storecfg, $vmid, $conf, $drive) = @_;
|
||||||
|
|
||||||
if (!drive_is_cdrom($drive)) {
|
if (!drive_is_cdrom($drive, 1)) {
|
||||||
my $volid = $drive->{file};
|
my $volid = $drive->{file};
|
||||||
if (vm_is_volid_owner($storecfg, $vmid, $volid)) {
|
if (vm_is_volid_owner($storecfg, $vmid, $volid)) {
|
||||||
PVE::QemuConfig->add_unused_volume($conf, $volid, $vmid);
|
PVE::QemuConfig->add_unused_volume($conf, $volid, $vmid);
|
||||||
@ -2287,7 +2291,7 @@ sub destroy_vm {
|
|||||||
foreach_drive($conf, sub {
|
foreach_drive($conf, sub {
|
||||||
my ($ds, $drive) = @_;
|
my ($ds, $drive) = @_;
|
||||||
|
|
||||||
return if drive_is_cdrom($drive);
|
return if drive_is_cdrom($drive, 1);
|
||||||
|
|
||||||
my $volid = $drive->{file};
|
my $volid = $drive->{file};
|
||||||
|
|
||||||
@ -6157,7 +6161,7 @@ sub qemu_img_convert {
|
|||||||
sub qemu_img_format {
|
sub qemu_img_format {
|
||||||
my ($scfg, $volname) = @_;
|
my ($scfg, $volname) = @_;
|
||||||
|
|
||||||
if ($scfg->{path} && $volname =~ m/\.(raw|cow|qcow|qcow2|qed|vmdk|cloop)$/) {
|
if ($scfg->{path} && $volname =~ m/\.($QEMU_FORMAT_RE)$/) {
|
||||||
return $1;
|
return $1;
|
||||||
} else {
|
} else {
|
||||||
return "raw";
|
return "raw";
|
||||||
|
Loading…
Reference in New Issue
Block a user