WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xl: Check for dependencies in xl

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xl: Check for dependencies in xl
From: Kamala Narasimhan <kamala.narasimhan@xxxxxxxxx>
Date: Thu, 13 Jan 2011 11:57:24 -0500
Delivery-date: Thu, 13 Jan 2011 08:58:29 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=Kff5krZ9JRwpaB81+jf2tBGp6b3O9rtCc4zHZImbuNg=; b=mPWs8ohp5bopTb1sZxLE6yYjUmohJzi1XobQdhPOr97CjUJL6TzG7+E2Z2M0n3Mm9j CSc31pgfn5AOWElRRw0vCcelswiqbYH/wWQGPlu/f+vHvAW4ymPk32E1n5/bpsMPrDkZ UIpmxy0WrGAC5lvAsketsFY7J4ae76y8pyxYA=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=gS7tir6Cm/5ZswWXiHxX1sFDziHj3bEY183znsCcGp3xYqHjbwtvMoKz+edgLWrDfT rH2xJnS4Gm5exr3dQNsVmOexdiKQFPUfolYF7E4aun9HAIAMLgCMibTxVoDhfrfc9DgH OS2+/hTPhEjdtjUoUzQMAVcU5la8UfFIyiVp4=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
If I fail to start xencommons before starting a vm, I get a non
obvious "failed to free memory for the domain" error!  This patch
checks for dependencies when xl is invoked.

Note:  Currently I am checking for xenstore daemon only.  More checks
could be added if necessary.  Also, I am performing the check
irrespective of the kind of command being invoked through xl.
Example. xl info, list etc.  doesn't require that xenstored be
running.  But expecting xenstored be running before invoking the
toolstack seem like a reasonable expectation in general.  Please
consider this for inclusion or feel free to tweak it as necessary.

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@xxxxxxxxxx>

Kamala

diff -r ce208811f540 tools/libxl/xl.c
--- a/tools/libxl/xl.c  Thu Jan 13 01:26:44 2011 +0000
+++ b/tools/libxl/xl.c  Thu Jan 13 11:26:35 2011 -0500
@@ -74,6 +74,27 @@ static void parse_global_config(const ch

     xlu_cfg_destroy(config);
 }
+
+static int check_dependencies(void)
+{
+    struct xs_handle *xsh;
+
+    xsh = xs_daemon_open();
+    if ( !xsh )
+    {
+        fprintf(stderr, "xs_daemon_open failed!\n");
+        return 0;
+    }
+
+    if ( xs_read(xsh, XBT_NULL, "/local/domain/0/name", NULL) == NULL )
+    {
+        fprintf(stderr, "Xenstore daemon is not running or not
initialized properly!\n");
+        return 0;
+    }
+
+    xs_daemon_close(xsh);
+    return 1;
+}

 int main(int argc, char **argv)
 {
@@ -103,6 +124,9 @@ int main(int argc, char **argv)
         exit(1);
     }
     opterr = 0;
+
+    if ( !check_dependencies() )
+        exit(1);

     logger = xtl_createlogger_stdiostream(stderr, minmsglevel,  0);
     if (!logger) exit(1);

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