mirror of
git://git.proxmox.com/git/qemu-server.git
synced 2025-01-22 22:03:55 +03:00
fix #1905: Allow moving unused disks
In the past, moving unused disks to another storage was prohibited due to oversights in the handling of unused disks. This commit rectifies this limitation by allowing the movement of unused disks. Historical context: * 16 Sep 2010 r5164 qemu-server/pve2: The disknames sub was removed. * 17 Sep 2010 r5170 qemu-server/pve2: Unused disks were introduced. * 28 Jan 2011 r5461 qemu-server/pve2: The same disknames sub that was removed in r5164 was brought back. Since unused disks were not around yet in r5164 the disknames sub did not consider unused disks. * 6-8 Aug 2012 c1175c92..f91b2e45 qemu-server.git: Disk resize was introduced. In commit c1175c92 in sub qemu_block_resize unused disks were not taken into account and in commit 2f48a4f5 (8 Aug 2012) the resize API call was changed to only allow disks matching the ones in the disknames sub. Since sub disknames did not contain any unused disks, those were not allowed at all in the resize API call. * 27 May 2013 586bfa78 qemu-server.git: Disk move was introduced. The API call implementation borrowed heavily from disk resize, including the behaviour of not taking unused disks into account. Thus, unused disk could not be moved, which persists to this day. In summary, this behaviour was introduced because the handling of unused disks was overlooked and it was never changed. There is no inherent reason why unused disks should be restricted from being moved to another storage. These disks cannot use the qemu_drive_mirror, but they can still be moved with qemu_img_convert, the same way as any other disk of a stopped VM. Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
This commit is contained in:
parent
2db4c27283
commit
1f743141e3
@ -4365,9 +4365,6 @@ __PACKAGE__->register_method({
|
||||
} elsif ($storeid) {
|
||||
$rpcenv->check($authuser, "/storage/$storeid", ['Datastore.AllocateSpace']);
|
||||
|
||||
die "cannot move disk '$disk', only configured disks can be moved to another storage\n"
|
||||
if $disk =~ m/^unused\d+$/;
|
||||
|
||||
$load_and_check_move->(); # early checks before forking/locking
|
||||
|
||||
my $realcmd = sub {
|
||||
|
@ -8154,7 +8154,8 @@ sub clone_disk {
|
||||
my ($newvmid, $dst_drivename, $efisize) = $dest->@{qw(vmid drivename efisize)};
|
||||
my ($storage, $format) = $dest->@{qw(storage format)};
|
||||
|
||||
my $use_drive_mirror = $full && $running && $src_drivename && !$snapname;
|
||||
my $unused = $src_drivename =~ /^unused/;
|
||||
my $use_drive_mirror = $full && $running && $src_drivename && !$snapname && !$unused;
|
||||
|
||||
if ($src_drivename && $dst_drivename && $src_drivename ne $dst_drivename) {
|
||||
die "cloning from/to EFI disk requires EFI disk\n"
|
||||
@ -8260,7 +8261,7 @@ no_data_clone:
|
||||
my $disk = dclone($drive);
|
||||
delete $disk->{format};
|
||||
$disk->{file} = $newvolid;
|
||||
$disk->{size} = $size if defined($size);
|
||||
$disk->{size} = $size if defined($size) && !$unused;
|
||||
|
||||
return $disk;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user