[libvirt] [PATCH 1/4] libvirt-guest.init: handle domain name with spaces

Daniel P. Berrange berrange at redhat.com
Fri Mar 11 10:55:58 UTC 2011


On Fri, Mar 11, 2011 at 11:38:47AM +0100, Jiri Denemark wrote:
> On Tue, Mar 01, 2011 at 18:57:01 +0100, Philipp Hahn wrote:
> > awk splits the line on consecutive spaces, which breaks getting the name
> > of a domain whose name contains spaces. Use sed instead to strip the
> > "Name:" prefix from the line
> > 
> > Signed-off-by: Philipp Hahn <hahn at univention.de>
> > ---
> >  tools/libvirt-guests.init.sh |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/tools/libvirt-guests.init.sh b/tools/libvirt-guests.init.sh
> > index 8823d06..ea2189e 100644
> > --- a/tools/libvirt-guests.init.sh
> > +++ b/tools/libvirt-guests.init.sh
> > @@ -105,7 +105,7 @@ guest_name() {
> >      uuid=$2
> >  
> >      name=$(run_virsh_c $uri dominfo $uuid 2>/dev/null | \
> > -           awk '/^Name:/{print $2}')
> > +           sed -ne 's/^Name: *//p')
> >      [ -n "$name" ] || name=$uuid
> >  
> >      echo "$name"
> 
> Ah yes, domain names with spaces... I guess we should enhance virsh so that it
> can start domains based on UUID so the we can get rid of the last domain name
> usage when calling virsh in this script.

virsh already *can* start VMs based on UUID.  Any virsh command which
needs an inactive domain can accept either name of UUID interchangably.
Any virsh command which needs an active domain can accept name, UUID
or ID


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list