All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xl: Check for dependencies in xl
@ 2011-01-13 16:57 Kamala Narasimhan
  2011-01-14 17:51 ` Ian Campbell
  0 siblings, 1 reply; 16+ messages in thread
From: Kamala Narasimhan @ 2011-01-13 16:57 UTC (permalink / raw)
  To: xen-devel

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@citrix.com>

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);

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-01-25 17:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-13 16:57 [PATCH] xl: Check for dependencies in xl Kamala Narasimhan
2011-01-14 17:51 ` Ian Campbell
2011-01-14 18:57   ` Kamala Narasimhan
2011-01-14 19:19     ` Ian Campbell
2011-01-14 19:33       ` Kamala Narasimhan
2011-01-19 18:46         ` Kamala Narasimhan
2011-01-20 11:01           ` Stefano Stabellini
2011-01-20 14:10             ` Kamala Narasimhan
2011-01-20 14:15               ` Stefano Stabellini
2011-01-21 17:34               ` Ian Jackson
2011-01-21 17:37                 ` Stefano Stabellini
2011-01-22  2:34                   ` Kamala Narasimhan
2011-01-24 16:37           ` Gianni Tedesco
2011-01-24 17:26             ` Kamala Narasimhan
2011-01-24 17:32               ` Gianni Tedesco
2011-01-25 17:00                 ` Ian Jackson

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.