[QUESTION PVE-API / qemu-server] Detach disk from VM without deleting it

Robin KERDILES robin.kerdiles at emanrisk.leclerc
Mon Jan 2 13:34:49 CET 2023


Hello PVE developers,

Is there any reason why detaching the disks from the VM but still keeping
these in the storage doesn't seem to be supported ?

I had to lookup to the different repositories to find that in qemu-server
only specific scenarios are supported :

   - "Unlinking" a drive which is currently attached/used (not in an
   unused slot)
   pvesh set /nodes/{node}/qemu/{vmid}/unlink --idlist scsi0
   This command is currently using the same source code as the one below
   pvesh create /nodes/{node}/qemu/{vmid}/config --delete scsi0
   Will detach the disk and place it in an unused slot
   - "Unlinking" a drive which is currently in an unused slot
   pvesh set /nodes/{node}/qemu/{vmid}/unlink --idlist unused0
   Will remove it from the configuration and delete it from the storage

The only "supported" way to do it would be to edit the configuration file
and I would like to do it through the API so that I can manage my virtual
disks through IaC tools.

Would it be possible to allow detaching the disks from a VM without
deleting the disk image so that the disk is not referenced in the
configuration anymore ?

Would it be a possible and accepted contribution in the source code to add
this feature through a flag in the CLI/API calls ?

I'm suggesting these flags :

pvesh create /nodes/{node}/qemu/{vmid}/config --unlink scsi0
pvesh set /nodes/{node}/qemu/{vmid}/unlink --idlist scsi0 --unregister true



More information about the pve-devel mailing list