All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@amd.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Ian Campbell <Ian.Campbell@eu.citrix.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH]: xl: catch invalid numeric domain ID
Date: Mon, 24 Jan 2011 23:12:21 +0100	[thread overview]
Message-ID: <4D3DF945.4070307@amd.com> (raw)
In-Reply-To: <19769.55433.742234.824540@mariner.uk.xensource.com>

[-- Attachment #1: Type: text/plain, Size: 1402 bytes --]

On 01/21/2011 08:03 PM, Ian Jackson wrote:
> Andre Przywara writes ("[PATCH]: xl: catch invalid numeric domain ID"):
>> if you run any domain specific xl command with an invalid (aka
>> non-existing) numeric domain ID, the command does not abort, but
>> proceeds with some bogus number:
>
> Thanks, but I'm not 100% convinced that it is impossible to ever get
> into a situation where a domain exists but has no name.  In that case,
> this patch of yours would leave an undestroyable domain.
>
> I think the right answer is to use libxl_domain_info to check whether
> the domain exists.  It returns ERROR_INVAL, without logging anything,
> if the domain does not exist.  On other failures xl destroy should
> probably carry on and attempt to destroy the domain.
OK, I looked around the bit, libxl_domain_info really seems to be the 
easiest solution. So please consider the attached patch. I am not 100% 
happy with it, actually I think find_domain should return an error 
value. In this case we could abort the commands gracefully (like xl list 
does) and avoid the rather impolite exit(2).
On the other hand I am not sure if fixing the 30 or so callers of 
find_domain() is appropriate in this state of development.
Please tell me if you prefer this more elaborated version and I will 
send a patch.

Regards,
Andre.

-- 
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany


[-- Attachment #2: xl_fix_bad_numeric_id_v2.path --]
[-- Type: text/plain, Size: 1273 bytes --]

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 359970b..deae3f7 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -163,12 +163,18 @@ static int cpupool_qualifier_to_cpupoolid(const char *p, uint32_t *poolid_r,
 static void find_domain(const char *p)
 {
     int rc, was_name;
+    libxl_dominfo info_buf;
 
     rc = domain_qualifier_to_domid(p, &domid, &was_name);
     if (rc) {
         fprintf(stderr, "%s is an invalid domain identifier (rc=%d)\n", p, rc);
         exit(2);
     }
+    rc = libxl_domain_info(&ctx, &info_buf, domid);
+    if (rc == ERROR_INVAL) {
+        fprintf(stderr, "Error: Domain \'%d\' does not exist.\n", domid);
+        exit(2);
+    }
     common_domname = was_name ? p : libxl_domid_to_name(&ctx, domid);
 }
 
@@ -3149,11 +3155,6 @@ int main_list(int argc, char **argv)
     } else if (optind == argc-1) {
         find_domain(argv[optind]);
         rc = libxl_domain_info(&ctx, &info_buf, domid);
-        if (rc == ERROR_INVAL) {
-            fprintf(stderr, "Error: Domain \'%s\' does not exist.\n",
-                argv[optind]);
-            return -rc;
-        }
         if (rc) {
             fprintf(stderr, "libxl_domain_info failed (code %d).\n", rc);
             return -rc;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

      reply	other threads:[~2011-01-24 22:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-21 16:16 [PATCH]: xl: catch invalid numeric domain ID Andre Przywara
2011-01-21 19:03 ` Ian Jackson
2011-01-24 22:12   ` Andre Przywara [this message]

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=4D3DF945.4070307@amd.com \
    --to=andre.przywara@amd.com \
    --cc=Ian.Campbell@eu.citrix.com \
    --cc=Ian.Jackson@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.