mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-08-08 02:51:13 +00:00
cloud-init: clone/move support
move: don't error out with "you can't move a cdrom" clone: always full-clone cloud-init images They get completely replaced anyway at the next start, so there's no point in keeping them. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
3351aacc70
commit
931432bd2d
@ -2601,10 +2601,10 @@ __PACKAGE__->register_method({
|
|||||||
} elsif (PVE::QemuServer::is_valid_drivename($opt)) {
|
} elsif (PVE::QemuServer::is_valid_drivename($opt)) {
|
||||||
my $drive = PVE::QemuServer::parse_drive($opt, $value);
|
my $drive = PVE::QemuServer::parse_drive($opt, $value);
|
||||||
die "unable to parse drive options for '$opt'\n" if !$drive;
|
die "unable to parse drive options for '$opt'\n" if !$drive;
|
||||||
if (PVE::QemuServer::drive_is_cdrom($drive)) {
|
if (PVE::QemuServer::drive_is_cdrom($drive, 1)) {
|
||||||
$newconf->{$opt} = $value; # simply copy configuration
|
$newconf->{$opt} = $value; # simply copy configuration
|
||||||
} else {
|
} else {
|
||||||
if ($param->{full}) {
|
if ($param->{full} || PVE::QemuServer::drive_is_cloudinit($drive)) {
|
||||||
die "Full clone feature is not supported for drive '$opt'\n"
|
die "Full clone feature is not supported for drive '$opt'\n"
|
||||||
if !PVE::Storage::volume_has_feature($storecfg, 'copy', $drive->{file}, $snapname, $running);
|
if !PVE::Storage::volume_has_feature($storecfg, 'copy', $drive->{file}, $snapname, $running);
|
||||||
$fullclone->{$opt} = 1;
|
$fullclone->{$opt} = 1;
|
||||||
@ -2812,7 +2812,7 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
my $old_volid = $drive->{file} || die "disk '$disk' has no associated volume\n";
|
my $old_volid = $drive->{file} || die "disk '$disk' has no associated volume\n";
|
||||||
|
|
||||||
die "you can't move a cdrom\n" if PVE::QemuServer::drive_is_cdrom($drive);
|
die "you can't move a cdrom\n" if PVE::QemuServer::drive_is_cdrom($drive, 1);
|
||||||
|
|
||||||
my $oldfmt;
|
my $oldfmt;
|
||||||
my ($oldstoreid, $oldvolname) = PVE::Storage::parse_volume_id($old_volid);
|
my ($oldstoreid, $oldvolname) = PVE::Storage::parse_volume_id($old_volid);
|
||||||
|
@ -6395,7 +6395,17 @@ sub clone_disk {
|
|||||||
my ($size) = PVE::Storage::volume_size_info($storecfg, $drive->{file}, 3);
|
my ($size) = PVE::Storage::volume_size_info($storecfg, $drive->{file}, 3);
|
||||||
|
|
||||||
print "create full clone of drive $drivename ($drive->{file})\n";
|
print "create full clone of drive $drivename ($drive->{file})\n";
|
||||||
$newvolid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $newvmid, $dst_format, undef, ($size/1024));
|
my $name = undef;
|
||||||
|
if (drive_is_cloudinit($drive)) {
|
||||||
|
$name = "vm-$newvmid-cloudinit";
|
||||||
|
# cloudinit only supports raw and qcow2 atm:
|
||||||
|
if ($dst_format eq 'qcow2') {
|
||||||
|
$name .= '.qcow2';
|
||||||
|
} elsif ($dst_format ne 'raw') {
|
||||||
|
die "clone: unhandled format for cloudinit image\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$newvolid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $newvmid, $dst_format, $name, ($size/1024));
|
||||||
push @$newvollist, $newvolid;
|
push @$newvollist, $newvolid;
|
||||||
|
|
||||||
PVE::Storage::activate_volumes($storecfg, [$newvolid]);
|
PVE::Storage::activate_volumes($storecfg, [$newvolid]);
|
||||||
|
Loading…
Reference in New Issue
Block a user