"cannot undefine domain with nvram" Displayed During VM Deletion
Symptom
When virsh undefine vm2 is executed, the following information is displayed:
error: Requested operation is not valid: cannot undefine domain with nvram

Key Process and Cause Analysis
The nvram file is used during the VM startup, the nvram processing policy needs to be specified when destroying the VM.
Conclusion and Solution
Add the --nvram parameter to the command so that the corresponding NVRAM file is deleted when the VM is destroyed. Run the following command to delete the VM:
virsh undefine vm2 --nvram

Parent topic: KVM Virtualization