[libvirt] [PATCH] repeat lookup by name in LookupByID

Daniel P. Berrange berrange at redhat.com
Thu Jul 17 09:30:19 UTC 2008


On Thu, Jul 17, 2008 at 01:20:59PM +0400, Evgeniy Sokolov wrote:
> Daniel Veillard ?????:
> >On Wed, Jul 16, 2008 at 08:10:21PM +0100, Daniel P. Berrange wrote:
> >>Yes, the documentation is wrong - all inactive VMs have an ID
> >>of -1, and thus lookup-by-ID is nonsensical for inactive VMs. 
> >>
> >>If any application did make use of this change which falls back to
> >>lookup-by-name, then it would only ever work with OpenVZ and not
> >>any of the other libvirt drivers, which isn't useful behaviour.
> >[...]
> >>>  Then the virLookupById description must be updated, I'm not against it,
> >>>but we need to be coherent.
> >>Indeed, the docs need to be clarified.
> >
> >  okay, what about
> >   * Try to find a domain based on the hypervisor ID number
> >   * Note that this won't work for inactive domains which have an ID of -1,
> >   * in that case a lookup based on the Name or UUId need to be done 
> >   instead.
> Ok.
> In that case we may disable lookup-by-id in undefine subcommand.

Ahhhh, so that's why you were seeing the error. Yes, this makes sens
because a VM has to be shutoff before undefine is allowed.

> Index: virsh.c
> ===================================================================
> RCS file: /data/cvs/libvirt/src/virsh.c,v
> retrieving revision 1.155
> diff -u -p -r1.155 virsh.c
> --- virsh.c	29 May 2008 14:56:12 -0000	1.155
> +++ virsh.c	17 Jul 2008 09:04:17 -0000
> @@ -978,7 +978,8 @@ cmdUndefine(vshControl * ctl, vshCmd * c
>      if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
>          return FALSE;
>  
> -    if (!(dom = vshCommandOptDomain(ctl, cmd, "domain", &name)))
> +    if (!(dom = vshCommandOptDomainBy(ctl, cmd, "domain", &name,
> +                                      VSH_BYNAME|VSH_BYUUID)))
>          return FALSE;
>  
>      if (virDomainUndefine(dom) == 0) {

ACK

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list