All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gianni Tedesco <gianni.tedesco@citrix.com>
To: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Cc: Christoph Egger <Christoph.Egger@amd.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: Re: [PATCH, v2]: xl: Check domain existance when doing domain identifier lookups
Date: Mon, 24 Jan 2011 18:53:14 +0000	[thread overview]
Message-ID: <1295895194.28333.34.camel@qabil.uk.xensource.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1101241838500.7277@kaball-desktop>

On Mon, 2011-01-24 at 18:39 +0000, Stefano Stabellini wrote:
> On Mon, 24 Jan 2011, Gianni Tedesco wrote:
> > It occurs to me that the last patch won't fix it for anything but
> > destroy. We should bail with a nice error for any command looking up a
> > domain that doesn't exist and be consistent with name vs. numeric ID.
> > 
> > --
> > xl: Check domain existance when doing domain identifier lookups
> > 
> > Also fix a mis-formatted error message in xl destroy command.
> > 
> > Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
> > 
> > diff -r b59f04eb8978 tools/libxl/xl_cmdimpl.c
> > --- a/tools/libxl/xl_cmdimpl.c	Fri Jan 21 18:06:23 2011 +0000
> > +++ b/tools/libxl/xl_cmdimpl.c	Mon Jan 24 17:58:20 2011 +0000
> > @@ -143,11 +143,24 @@ static int qualifier_to_id(const char *p
> >  static int domain_qualifier_to_domid(const char *p, uint32_t *domid_r,
> >                                       int *was_name_r)
> >  {
> > -    int was_name;
> > +    libxl_dominfo dominfo;
> > +    int was_name, rc;
> >  
> >      was_name = qualifier_to_id(p, domid_r);
> > -    if (was_name_r) *was_name_r = was_name;
> > -    return was_name ? libxl_name_to_domid(&ctx, p, domid_r) : 0;
> > +    if (was_name_r)
> > +        *was_name_r = was_name;
> > +
> > +    if ( was_name ) {
> > +        rc = libxl_name_to_domid(&ctx, p, domid_r);
> > +        if ( rc )
> > +            return rc;
> > +    }
> > +
> > +    rc = libxl_domain_info(&ctx, &dominfo, *domid_r);
> > +    if ( rc )
> > +        return rc;
> > +
> > +    return 0;
> 
> is this really needed?
> libxl_name_to_domid should have returned error already if the domain doesn't exist.

Only if was_name is true... If they pass a number then we need to check
explicitly. Perhaps it would be better to put that check in an else {}
statement though.

Gianni

--
xl: Check domain existance when doing domain identifier lookups

Also fix a mis-formatted error message in xl destroy command.

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>

diff -r b59f04eb8978 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Fri Jan 21 18:06:23 2011 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Mon Jan 24 18:50:32 2011 +0000
@@ -143,11 +143,24 @@ static int qualifier_to_id(const char *p
 static int domain_qualifier_to_domid(const char *p, uint32_t *domid_r,
                                      int *was_name_r)
 {
-    int was_name;
+    int was_name, rc;
 
     was_name = qualifier_to_id(p, domid_r);
-    if (was_name_r) *was_name_r = was_name;
-    return was_name ? libxl_name_to_domid(&ctx, p, domid_r) : 0;
+    if (was_name_r)
+        *was_name_r = was_name;
+
+    if ( was_name ) {
+        rc = libxl_name_to_domid(&ctx, p, domid_r);
+        if ( rc )
+            return rc;
+    }else{
+        libxl_dominfo dominfo;
+        rc = libxl_domain_info(&ctx, &dominfo, *domid_r);
+        if ( rc )
+            return rc;
+    }
+
+    return 0;
 }
 
 static int cpupool_qualifier_to_cpupoolid(const char *p, uint32_t *poolid_r,
@@ -2176,7 +2189,7 @@ static void destroy_domain(const char *p
         exit(-1);
     }
     rc = libxl_domain_destroy(&ctx, domid, 0);
-    if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n.",rc); exit(-1); }
+    if (rc) { fprintf(stderr,"destroy failed (rc=%d).\n",rc); exit(-1); }
 }
 
 static void shutdown_domain(const char *p, int wait)

  reply	other threads:[~2011-01-24 18:53 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Acu6GEBstpnTfIH/TdeQZvf0FjUZ0Q==>
2011-01-22  9:39 ` Xen 4.1 rc1 test report Zheng, Shaohui
2011-01-24 17:05   ` Xen 4.1 rc1 test report (xl bits) Gianni Tedesco
2011-01-24 17:27     ` Christoph Egger
2011-01-24 17:43       ` [PATCH]: xl: Check a domain exists before destroying it Gianni Tedesco
2011-01-24 18:18         ` [PATCH, v2]: xl: Check domain existance when doing domain identifier lookups Gianni Tedesco
2011-01-24 18:39           ` Stefano Stabellini
2011-01-24 18:53             ` Gianni Tedesco [this message]
2011-01-24 19:05               ` Stefano Stabellini
2011-01-25 17:29               ` Ian Jackson
2011-01-25 17:28           ` Ian Jackson
2011-01-25 17:35             ` Gianni Tedesco
2011-01-25 18:28               ` Ian Jackson
2011-01-25 17:07         ` [PATCH]: xl: Check a domain exists before destroying it Ian Jackson
2011-01-25 17:17           ` Gianni Tedesco
2011-01-25 18:25             ` Ian Jackson
2011-01-24 18:35     ` Xen 4.1 rc1 test report (xl bits) Stefano Stabellini
2011-01-25 14:04     ` Gianni Tedesco
2011-01-26  3:47       ` Zhang, Yang Z
2011-01-25  6:24   ` Xen 4.1 rc1 test report Haitao Shan
2011-01-25  8:00     ` Zheng, Shaohui
2011-01-25  8:43     ` Keir Fraser
2011-01-25 11:43     ` Ian Campbell
2011-01-26  0:47       ` Haitao Shan
2011-01-26 10:57         ` libxc: maintain a small, per-handle, cache of hypercall buffer memory (Was: Re: Xen 4.1 rc1 test report) Ian Campbell
2011-01-27  9:47           ` Ian Campbell
2011-01-31  0:58             ` Haitao Shan
2011-01-31  3:06           ` Haitao Shan
2011-01-31  8:30             ` Ian Campbell
2011-01-31  8:57               ` Haitao Shan
2011-01-31  9:32                 ` Ian Campbell
2011-01-31 12:07                   ` Haitao Shan
2011-02-01  4:40                     ` Haitao Shan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1295895194.28333.34.camel@qabil.uk.xensource.com \
    --to=gianni.tedesco@citrix.com \
    --cc=Christoph.Egger@amd.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.