[libvirt-users] how to know one domain is defined or not

Gao Yongwei itxx00 at gmail.com
Fri Jan 18 00:27:34 UTC 2013


2013/1/17 Michal Privoznik <mprivozn at redhat.com>

> On 17.01.2013 10:37, lei yang wrote:
> > Hi experts
> >
> > I want to write a script to determine one domain named "vm1" is
> > defined or not, if defined, I will undefine it.
> >
> > The question is how could I know it define or not ?
>
> either you can 'virsh list --persistent --all | grep $vm' or you can try
> 'virsh undefine $vm' which will throw an error if there's no such domain
> as $vm.
>
> I think ‘virsh domstate $vm’ is better than 'list --all | grep $vm'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20130118/824dd735/attachment.htm>


More information about the libvirt-users mailing list