[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 4/6] xl/libxl: add a blkdev_start parameter



Introduce a blkdev_start in xl.conf and pass it to
libxl_domain_create_* and all the way through libxl_run_bootloader and
libxl__device_disk_local_attach.

blkdev_start specifies the first block device to be used for temporary
block device allocations by the toolstack.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 tools/examples/xl.conf         |    3 +++
 tools/libxl/libxl.h            |   10 +++++++---
 tools/libxl/libxl_bootloader.c |    6 ++++--
 tools/libxl/libxl_create.c     |   18 ++++++++++++------
 tools/libxl/libxl_internal.c   |    3 ++-
 tools/libxl/libxl_internal.h   |    3 ++-
 tools/libxl/xl.c               |    3 +++
 tools/libxl/xl.h               |    1 +
 tools/libxl/xl_cmdimpl.c       |    5 +++--
 9 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/tools/examples/xl.conf b/tools/examples/xl.conf
index 56d3b3b..ebf057c 100644
--- a/tools/examples/xl.conf
+++ b/tools/examples/xl.conf
@@ -12,3 +12,6 @@
 
 # default output format used by "xl list -l"
 #output_format="json"
+
+# first block device to be used for temporary VM disk mounts
+#blkdev_start="xvda"
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 1e7b1b9..60a775e 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -382,8 +382,11 @@ int libxl_ctx_postfork(libxl_ctx *ctx);
 
 /* domain related functions */
 typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv);
-int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, 
libxl_console_ready cb, void *priv, uint32_t *domid);
-int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, 
libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd);
+int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,
+               libxl_console_ready cb, void *priv, uint32_t *domid, char* 
blkdev_start);
+int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,
+               libxl_console_ready cb, void *priv, uint32_t *domid, int 
restore_fd,
+               char *blkdev_start);
 void libxl_domain_config_dispose(libxl_domain_config *d_config);
 int libxl_domain_suspend(libxl_ctx *ctx, libxl_domain_suspend_info *info,
                           uint32_t domid, int fd);
@@ -411,7 +414,8 @@ int libxl_get_max_cpus(libxl_ctx *ctx);
 int libxl_run_bootloader(libxl_ctx *ctx,
                          libxl_domain_build_info *info,
                          libxl_device_disk *disk,
-                         uint32_t domid);
+                         uint32_t domid,
+                         char *blkdev_start);
 
   /* 0 means ERROR_ENOMEM, which we have logged */
 
diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c
index 429253d..fe56615 100644
--- a/tools/libxl/libxl_bootloader.c
+++ b/tools/libxl/libxl_bootloader.c
@@ -323,7 +323,8 @@ static void parse_bootloader_result(libxl__gc *gc,
 int libxl_run_bootloader(libxl_ctx *ctx,
                          libxl_domain_build_info *info,
                          libxl_device_disk *disk,
-                         uint32_t domid)
+                         uint32_t domid,
+                         char *blkdev_start)
 {
     GC_INIT(ctx);
     int ret, rc = 0;
@@ -387,7 +388,8 @@ int libxl_run_bootloader(libxl_ctx *ctx,
         goto out_close;
     }
 
-    diskpath = libxl__device_disk_local_attach(gc, disk, &tmpdisk);
+    diskpath = libxl__device_disk_local_attach(gc, disk, &tmpdisk,
+            blkdev_start);
     if (!diskpath) {
         goto out_close;
     }
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index dbff02c..03348d2 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -531,7 +531,8 @@ static int store_libxl_entry(libxl__gc *gc, uint32_t domid,
 
 static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
                             libxl_console_ready cb, void *priv,
-                            uint32_t *domid_out, int restore_fd)
+                            uint32_t *domid_out, int restore_fd,
+                                                       char* blkdev_start)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     libxl__spawner_starting *dm_starting = 0;
@@ -568,7 +569,9 @@ static int do_domain_create(libxl__gc *gc, 
libxl_domain_config *d_config,
     }
 
     if ( restore_fd < 0 ) {
-        ret = libxl_run_bootloader(ctx, &d_config->b_info, d_config->num_disks 
> 0 ? &d_config->disks[0] : NULL, domid);
+        ret = libxl_run_bootloader(ctx, &d_config->b_info,
+                d_config->num_disks > 0 ? &d_config->disks[0] : NULL,
+                domid, blkdev_start);
         if (ret) {
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                        "failed to run bootloader: %d", ret);
@@ -722,21 +725,24 @@ error_out:
 }
 
 int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,
-                            libxl_console_ready cb, void *priv, uint32_t 
*domid)
+                            libxl_console_ready cb, void *priv, uint32_t 
*domid,
+                                                       char* blkdev_start)
 {
     GC_INIT(ctx);
     int rc;
-    rc = do_domain_create(gc, d_config, cb, priv, domid, -1);
+    rc = do_domain_create(gc, d_config, cb, priv, domid, -1, blkdev_start);
     GC_FREE;
     return rc;
 }
 
 int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,
-                                libxl_console_ready cb, void *priv, uint32_t 
*domid, int restore_fd)
+                                libxl_console_ready cb, void *priv, uint32_t 
*domid,
+                                                               int restore_fd, 
char *blkdev_start)
 {
     GC_INIT(ctx);
     int rc;
-    rc = do_domain_create(gc, d_config, cb, priv, domid, restore_fd);
+    rc = do_domain_create(gc, d_config, cb, priv, domid, restore_fd,
+                       blkdev_start);
     GC_FREE;
     return rc;
 }
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index 43ce31b..a21c9c1 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -482,7 +482,8 @@ out:
 
 _hidden char * libxl__device_disk_local_attach(libxl__gc *gc,
         const libxl_device_disk *disk,
-        libxl_device_disk **new_disk)
+        libxl_device_disk **new_disk,
+        char *blkdev_start)
 {
     libxl_ctx *ctx = gc->owner;
     char *dev = NULL;
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 429624d..584f22d 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -996,7 +996,8 @@ _hidden int libxl__device_disk_add_t(libxl__gc *gc, 
uint32_t domid,
  */
 _hidden char * libxl__device_disk_local_attach(libxl__gc *gc,
         const libxl_device_disk *disk,
-        libxl_device_disk **new_disk);
+        libxl_device_disk **new_disk,
+        char *blkdev_start);
 _hidden int libxl__device_disk_local_detach(libxl__gc *gc,
         libxl_device_disk *disk);
 
diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c
index df9b1e7..5352bb2 100644
--- a/tools/libxl/xl.c
+++ b/tools/libxl/xl.c
@@ -36,6 +36,7 @@
 xentoollog_logger_stdiostream *logger;
 int dryrun_only;
 int autoballoon = 1;
+char *blkdev_start = "xvda";
 char *lockfile;
 char *default_vifscript = NULL;
 char *default_bridge = NULL;
@@ -92,6 +93,8 @@ static void parse_global_config(const char *configfile,
             fprintf(stderr, "invalid default output format \"%s\"\n", buf);
         }
     }
+    if (!xlu_cfg_get_string (config, "blkdev_start", &buf, 0))
+        blkdev_start = strdup(buf);
     xlu_cfg_destroy(config);
 }
 
diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h
index 702b208..4a384fb 100644
--- a/tools/libxl/xl.h
+++ b/tools/libxl/xl.h
@@ -111,6 +111,7 @@ extern int dryrun_only;
 extern char *lockfile;
 extern char *default_vifscript;
 extern char *default_bridge;
+extern char *blkdev_start;
 
 enum output_format {
     OUTPUT_FORMAT_JSON,
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 1d59b89..439e9bc 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -1636,7 +1636,7 @@ start:
     if ( restore_file ) {
         ret = libxl_domain_create_restore(ctx, &d_config,
                                             cb, &child_console_pid,
-                                            &domid, restore_fd);
+                                            &domid, restore_fd, blkdev_start);
         /*
          * On subsequent reboot etc we should create the domain, not
          * restore/migrate-receive it again.
@@ -1644,7 +1644,8 @@ start:
         restore_file = NULL;
     }else{
         ret = libxl_domain_create_new(ctx, &d_config,
-                                        cb, &child_console_pid, &domid);
+                                        cb, &child_console_pid, &domid,
+                                                                               
blkdev_start);
     }
     if ( ret )
         goto error_out;
-- 
1.7.2.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.