libxl: return an error if connection to xenstore fails
authorIan Campbell <ian.campbell@citrix.com>
Fri, 10 Dec 2010 18:29:50 +0000 (18:29 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 10 Dec 2010 18:29:50 +0000 (18:29 +0000)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl_device.c

index ad7f8bc1135ab98a8d8fb5627c44b5c7d671b08e..7d1796b2e7189cf484ab4ac9fb6b9a83c2170318 100644 (file)
@@ -429,6 +429,11 @@ int libxl__wait_for_device_model(libxl_ctx *ctx,
     char **l = NULL;
 
     xsh = xs_daemon_open();
+    if (xsh == NULL) {
+        LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Unable to open xenstore connection");
+        goto err;
+    }
+
     path = libxl__sprintf(&gc, "/local/domain/0/device-model/%d/state", domid);
     xs_watch(xsh, path, path);
     tv.tv_sec = LIBXL_DEVICE_MODEL_START_TIMEOUT;
@@ -469,6 +474,7 @@ again:
     xs_unwatch(xsh, path, path);
     xs_daemon_close(xsh);
     LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Device Model not ready");
+err:
     libxl__free_all(&gc);
     return -1;
 }