put the file with a .qcow2 extension somewhere on a dir-based storage, so that
pvesm list STORAGE
lists it. if you want to re-use it for multiple VMs you can assign it a special VMID that is not actually used, e.g. vm-999999-disk-xenial-server-cloudimg-amd64.qcow2. this step is not possible via the API, you need to use ssh/NFS/... access.
Step 1: POST to
nodes/NODE/qemu/VMID/config with the appropriate drive key set, e.g.
scsi0 => STORAGE:VOLID
to add the volume to the VM config (this is the equivalent of
qm set XXX -scsi0 STORAGE:VOLID
, it will not actually do anything to the image but just add it to the config file.
Step 2: POST to
nodes/NODE/qemu/VMID/move_disk to move it to the actual target storage and optionally, convert it to some other format. the source disk will be added as unused volume if it is owned by the VM and the 'delete' parameter is not set.
Step3: OPTIONALLY you can use the POST to the
config
API call from step 1 with
delete => unusedX
if it was added and you want to physically delete the imported source volume. if it was not added as unused volume and you want to delete it anyway, you can use DELETE on
nodes/NODE/storage/STORAGE/content/VOLUME