[pve-devel] qemu-server : add new qm import_disk feature

Fabian Gr├╝nbichler f.gruenbichler at proxmox.com
Thu Jan 19 10:08:34 CET 2017


On Thu, Jan 19, 2017 at 07:17:29AM +0100, Alexandre Derumier wrote:
> We had discuted last year about a method to import external image (vmware,xen,hyperv) to a proxmox vm
> http://pve.proxmox.com/pipermail/pve-devel/2016-January/018757.html
> 
> This mostly the feature that all my training students wants each time. (because they don't known how to create target volume manually and qemu-img syntax)
> 
> This patches serie add a new method "qm import_disk $vmid $image $targetstorage"
> 

definite NACK in this form. passing arbitrary paths via the API without
limiting to root at pam is a grave security risk, even when just passing
them to qemu-img for reading. so such functionality should be limited to
the CLI, where what you want to achieve is already possible:

1.) put disk in place on dir storage

put disk image on directory storage with a name like "vm-ID-whatever":
# pvesm alloc local 105 vm-105-disk-import-test.raw 1G

(or with cp, scp, rsync, ... for an actual existing image)

but now it is not yet in the VM config:
# qm config 105 | grep -c disk-import-test
0

2.) rescan disks

so tell PVE to add matching non-referenced disks as unused:
# qm rescan -vmid 105

now it is added as unused:
# qm config 105 | grep disk-import-test
unused0: local:105/vm-105-disk-import-test.raw

3.) use disk

and you can re-add it as used disk and move disk (this part is possible
for regular users on the GUI as well):

# qm set 105 -scsi0 local:105/vm-105-disk-import-test.raw
update VM 105: -scsi0 local:105/vm-105-disk-import-test.raw

# qm move_disk 105 scsi0 bigpool
create full clone of drive scsi0 (local:105/vm-105-disk-import-test.raw)
transferred: 0 bytes remaining: 1073741824 bytes total: 1073741824 bytes progression: 0.00 %
transferred: 1073741824 bytes remaining: 0 bytes total: 1073741824 bytes progression: 100.00 %



More information about the pve-devel mailing list