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

[Xen-devel] [PATCH] xl: Support backend domain ID for disks



Allow specification of backend domains for disks, either in the config
file or via block-attach

Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
---
 tools/libxl/libxlu_disk.c   |    3 ++-
 tools/libxl/libxlu_disk_i.h |    3 ++-
 tools/libxl/libxlu_disk_l.l |    8 ++++++++
 tools/libxl/libxlutil.h     |    2 +-
 tools/libxl/xl_cmdimpl.c    |    2 +-
 5 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxlu_disk.c b/tools/libxl/libxlu_disk.c
index f8a1ba3..3342099 100644
--- a/tools/libxl/libxlu_disk.c
+++ b/tools/libxl/libxlu_disk.c
@@ -47,7 +47,7 @@ static void dpc_dispose(DiskParseContext *dpc) {
 
 int xlu_disk_parse(XLU_Config *cfg,
                    int nspecs, const char *const *specs,
-                   libxl_device_disk *disk) {
+                   libxl_device_disk *disk, libxl_ctx *ctx) {
     DiskParseContext dpc;
     int i, e;
 
@@ -55,6 +55,7 @@ int xlu_disk_parse(XLU_Config *cfg,
     dpc.cfg = cfg;
     dpc.scanner = 0;
     dpc.disk = disk;
+    dpc.ctx = ctx;
 
     disk->readwrite = 1;
 
diff --git a/tools/libxl/libxlu_disk_i.h b/tools/libxl/libxlu_disk_i.h
index 578920a..00988fa 100644
--- a/tools/libxl/libxlu_disk_i.h
+++ b/tools/libxl/libxlu_disk_i.h
@@ -2,7 +2,7 @@
 #define LIBXLU_DISK_I_H
 
 #include "libxlu_internal.h"
-
+#include "libxl_utils.h"
 
 typedef struct {
     XLU_Config *cfg;
@@ -12,6 +12,7 @@ typedef struct {
     libxl_device_disk *disk;
     int access_set, had_depr_prefix;
     const char *spec;
+    libxl_ctx *ctx;
 } DiskParseContext;
 
 void xlu__disk_err(DiskParseContext *dpc, const char *erroneous,
diff --git a/tools/libxl/libxlu_disk_l.l b/tools/libxl/libxlu_disk_l.l
index a3e7180..446ea65 100644
--- a/tools/libxl/libxlu_disk_l.l
+++ b/tools/libxl/libxlu_disk_l.l
@@ -108,6 +108,13 @@ static void setbackendtype(DiskParseContext *dpc, const 
char *str) {
     else xlu__disk_err(dpc,str,"unknown value for backendtype");
 }
 
+/* Sets ->backend_domid from the string. */
+static void setbackend(DiskParseContext *dpc, const char *str) {
+    if (libxl_name_to_domid(dpc->ctx, str, &dpc->disk->backend_domid)) {
+        xlu__disk_err(dpc,str,"unknown domain for backend");
+    }
+}
+
 #define DEPRECATE(usewhatinstead) /* not currently reported */
 
 %}
@@ -140,6 +147,7 @@ devtype=[^,]*,?     { xlu__disk_err(DPC,yytext,"unknown 
value for type"); }
 
 access=[^,]*,? { STRIP(','); setaccess(DPC, FROMEQUALS); }
 backendtype=[^,]*,? { STRIP(','); setbackendtype(DPC,FROMEQUALS); }
+backend=[^,]*,? { STRIP(','); setbackend(DPC,FROMEQUALS); }
 
 vdev=[^,]*,?   { STRIP(','); SAVESTRING("vdev", vdev, FROMEQUALS); }
 script=[^,]*,? { STRIP(','); SAVESTRING("script", script, FROMEQUALS); }
diff --git a/tools/libxl/libxlutil.h b/tools/libxl/libxlutil.h
index c20de1d..482c5a0 100644
--- a/tools/libxl/libxlutil.h
+++ b/tools/libxl/libxlutil.h
@@ -64,7 +64,7 @@ const char *xlu_cfg_get_listitem(const XLU_ConfigList*, int 
entry);
  */
 
 int xlu_disk_parse(XLU_Config *cfg, int nspecs, const char *const *specs,
-                  libxl_device_disk *disk);
+                  libxl_device_disk *disk, libxl_ctx *ctx);
   /* disk must have been initialised.
    *
    * On error, returns errno value.  Bad strings cause EINVAL and
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 99e3c49..d2749da 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -501,7 +501,7 @@ static void parse_disk_config_multistring(XLU_Config 
**config,
        if (!*config) { perror("xlu_cfg_init"); exit(-1); }
     }
 
-    e = xlu_disk_parse(*config, nspecs, specs, disk);
+    e = xlu_disk_parse(*config, nspecs, specs, disk, ctx);
     if (e == EINVAL) exit(-1);
     if (e) {
        fprintf(stderr,"xlu_disk_parse failed: %s\n",strerror(errno));
-- 
1.7.6.4


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


 


Rackspace

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