我在libvirt中有多个不活动的域,我想全部删除它们:
# virsh list --inactive Id Name State ---------------------------------- - instance-0000000c shut off - instance-0000000f shut off - instance-00000010 shut off
有一个简单的方法来告诉libvirt删除所有不活动的域,或者我必须手动执行:
# virsh undefine instance-0000000c # virsh undefine ...
像这样的东西应该工作:
$ virsh list --inactive | grep instance | cut -d " " -f 4 | xargs -n 1 virsh undefine
如果你想在杀死他们之前查看这个列表:
$ virsh list --inactive | grep instance | cut -d " " -f 4 > inactive_domains $ vi inactive_domains
那么如果一切看起来都不错
$ cat inactive_domains | xargs -n 1 virsh undefine