[SOLVED] Deleting non-existent storage doesn't return an error code


New Member
Nov 8, 2023
When I attempt to delete non-existent storage, the command line doesn't return a non-zero exit code. Is this a bug?

$ sudo qm set 148 --delete scsi0
update VM 148: -delete scsi0
cannot delete 'scsi0' - not set in current configuration!
$ echo $?

How can I check that the storage is successfully removed? I'm running this in a pipeline and want to be able to tell when it fails.

IMHO it's debatable if it's a bug, because if the command finishes successfully, the option won't be set in the config anymore. Changing the return value might trip up existing users expecting the current behavior. You can check the configuration if you need to ensure the option is set before trying to delete it.

If removing actually fails, the command will throw an error, e.g.
root@pve8a1 ~ # qm set 120 --delete scsi0
update VM 120: -delete scsi0
400 Parameter verification failed.
scsi0: hotplug problem - can't unplug bootdisk 'scsi0'

qm set <vmid> [OPTIONS]
root@pve8a1 ~ # echo $?
Thanks, I'm glad to know that if removing actually fails then an error will be thrown. That was my main concern :)


The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!