![How to use the command "qm cleanup" (with examples)](/images/commands/general-4_huf75f6643724b4a3ad4c9b8b27a19e2cb_14070_1110x0_resize_q90_h2_lanczos_2.webp)
How to use the command "qm cleanup" (with examples)
The “qm cleanup” command is used to clean up resources on the QEMU/KVM Virtual Machine Manager, such as tap devices and VGPUs. It is typically called after a virtual machine (VM) shuts down, crashes, or is otherwise no longer in use. The command helps to free up resources and ensure a clean state for the next use of the VM.
Use case 1: Clean up resources
Code:
qm cleanup vm_id clean-shutdown guest-requested
MOTIVATION: This use case is useful when you want to clean up the resources associated with a specific virtual machine that has undergone a clean shutdown and was requested to be cleaned up by the guest OS.
EXPLANATION:
qm cleanup
- The command to clean up resources.vm_id
- The ID of the virtual machine for which you want to clean up resources.clean-shutdown
- This argument indicates that the virtual machine was shut down in a clean manner.guest-requested
- This argument signifies that the clean-up request was initiated by the guest OS.
Example output:
Cleaning up resources for VM with ID 123...
Successfully cleaned up tap devices and VGPUs.
In this example, the command is used to clean up the resources associated with a virtual machine with ID 123. The virtual machine had a clean shutdown and the request for clean-up came from the guest OS. The command successfully cleans up the tap devices and VGPUs associated with the virtual machine.
Conclusion:
The “qm cleanup” command is a useful tool for cleaning up resources on the QEMU/KVM Virtual Machine Manager. It allows you to free up resources and ensure a clean state for your virtual machines. By following the provided use cases, you can easily utilize the command for your specific needs.