[pve-devel] [PATCH v3 storage qemu-server container 0/9] move disk or volume to other guests

Fabian Ebner f.ebner at proxmox.com
Wed Oct 27 13:55:34 CEST 2021


Nice work! For all patches except #8 it's only nits from my side, so 
those are:

Reviewed-by: Fabian Ebner <f.ebner at proxmox.com>
Tested-by: Fabian Ebner <f.ebner at proxmox.com>


I did run into one strange issue with RBD upon destroying a VM, but it 
didn't pop up consistently and maybe it's just my cluster (all VMs were 
powered off):

root at pve701 ~ # qm clone 12345 142
/dev/rbd0
create linked clone of drive scsi0 (rbdkvm:base-12345-disk-0)
clone base-12345-disk-0: base-12345-disk-0 snapname __base__ to 
vm-142-disk-0
root at pve701 ~ # qm move_disk 142 scsi0 --target-vmid 111 --target-disk scsi3
moving disk 'scsi0' from VM '142' to '111'
removing disk 'scsi0' from VM '142' config
update VM 111: -scsi3 rbdkvm:base-12345-disk-0/vm-111-disk-0,size=4G
/dev/rbd1
root at pve701 ~ # qm move_disk 111 scsi3 --target-vmid 142 --target-disk scsi3
moving disk 'scsi3' from VM '111' to '142'
removing disk 'scsi3' from VM '111' config
update VM 142: -scsi3 rbdkvm:base-12345-disk-0/vm-142-disk-0,size=4G
/dev/rbd2
root at pve701 ~ # qm destroy 142
2021-10-27T12:17:13.202+0200 7f8b00d0e700 -1 
librbd::image::PreRemoveRequest: 0x55e08f1cac30 check_image_watchers: 
image has watchers - not removing
Removing image: 0% complete...failed.
rbd: error: image still has watchers
Could not remove disk 'rbdkvm:base-12345-disk-0/vm-142-disk-0', check 
manually: rbd rm 'base-12345-disk-0/vm-142-disk-0' error: rbd: error: 
image still has watchers


Am 21.10.21 um 13:30 schrieb Aaron Lauterer:
> This is the continuation of 'disk-reassign' but instead of a separate
> API endpoint we now follow the approach to make it part of the
> 'move-disk' and 'move-volume' endpoints for VMs and containers.
> 
> The main idea is to make it easy to move a disk/volume to another guest.
> Currently this is a manual and error prone process that requires
> knowledge of how PVE handles disks/volumes and the mapping which guest
> they belong to.
> 
> With this, the 'qm move-disk' and 'pct move-volume' are changed in the
> way that the storage parameter is optional as well as the new
> target-vmid and target-{disk,volume}. This will keep old calls to move the
> disk/volume to another storage working. To move to another guest, the
> storage needs to be omitted.
> 
> Major changes since the last iteration as dedicated API endpoint [0] are
> that the storage layer only implements the renaming itself. The layer
> above (qemu-server and pve-container) define the name of the new
> volume/disk.  Therefore it was necessary to expose the new
> 'find_free_volname' function.  The rename function on the storage layer
> handles possible template references and the creation of the new volid
> as that is highly dependent on the actual storage.
> 
> The following storage types are implemented at the moment:
> * dir based ones
> * ZFS
> * (thin) LVM
> * Ceph RBD
> 
> 
> Most parts of the disk-reassign code has been taken and moved into the
> 'move_disk' and 'move_volume' endpoints with conditional checking if the
> reassign code or the move to other storage code is meant to run
> depending on the given parameters.
> 
> Changes since v2:
> * fixed base image handling
> * fixed code style issues
> 
> Changes since v1 [2] (thx @ Fabian_E for the reviews!):
> * drop exposed 'find_free_diskname' method
> * drop 'wants_fmt_suffix' method (not needed anymore)
> * introduce 'find_free_volname' which decides if only the diskname is
>    needed or the longer path for directory based storages
> * use $source_volname instead of $source_volid -> avoids some extra
>    calls to get to $source_volname again
> * make --target-{disk,volume} optional and fall back to source key
> * smaller fixes in code quality and using existing functions like
>    'parse_volname' instead of a custom regex (possible with the new
>    changes)
> 
> 
> Changes since the RFC [1]:
> * added check if target guest is replicated and fail if storage does not
>    support replication
> * only pass minimum of needed parameters to the storage layer and infer
>    other needed information from that
> * lock storage and check if the volume aready exists (handling a
>    possible race condition between calling find_free_disk and the actual
>    renaming)
> * use a helper method to determine if the plugin needs the fmt suffix
>    in the volume name
> * getting format of the source and pass it to find_free_disk
> * style fixes (long lines, multiline post-if, ...)
> 
> [0] https://lists.proxmox.com/pipermail/pve-devel/2021-April/047481.html
> [1] https://lists.proxmox.com/pipermail/pve-devel/2021-June/048400.html
> [2] https://lists.proxmox.com/pipermail/pve-devel/2021-July/049445.html
> 
> storage: Aaron Lauterer (2):
>    storage: add new find_free_volname
>    add disk rename feature
> 
>   PVE/Storage.pm               | 29 +++++++++++++++++--
>   PVE/Storage/LVMPlugin.pm     | 24 ++++++++++++++++
>   PVE/Storage/LvmThinPlugin.pm |  1 +
>   PVE/Storage/Plugin.pm        | 54 ++++++++++++++++++++++++++++++++++++
>   PVE/Storage/RBDPlugin.pm     | 28 +++++++++++++++++++
>   PVE/Storage/ZFSPoolPlugin.pm | 23 +++++++++++++++
>   6 files changed, 157 insertions(+), 2 deletions(-)
> 
> 
> qemu-server: Aaron Lauterer (4):
>    cli: qm: change move_disk to move-disk
>    Drive: add valid_drive_names_with_unused
>    api: move-disk: add move to other VM
>    api: move-disk: cleanup very long lines
> 
>   PVE/API2/Qemu.pm        | 242 ++++++++++++++++++++++++++++++++++++++--
>   PVE/CLI/qm.pm           |   3 +-
>   PVE/QemuServer/Drive.pm |   4 +
>   3 files changed, 238 insertions(+), 11 deletions(-)
> 
> 
> container: Aaron Lauterer (3):
>    cli: pct: change move_volume to move-volume
>    api: move-volume: add move to another container
>    api: move-volume: cleanup very long lines
> 
>   src/PVE/API2/LXC.pm | 286 +++++++++++++++++++++++++++++++++++++++-----
>   src/PVE/CLI/pct.pm  |   3 +-
>   2 files changed, 261 insertions(+), 28 deletions(-)
> 
> 





More information about the pve-devel mailing list