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

[Xen-devel] [PATCH RFC 5/8] libxlu: parse disk backend features parameters



Any option name preceded by "require-" means a backend feature
to be set. This is stored in key value structure which libxl will parse
and tell blkback to override the specified features.

An example would be a config containing:

...
vcpus = 8
disk = [ "phy:/path/to/disk,hda,w,require-multi-queue-max-queues=1" ]
...

Which would set the number of queues to 2 as opposed to e.g. the global
blkback defined xen_blkback.max_queues parameter.

Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx>
---
 tools/libxl/libxlu_disk_l.l | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/tools/libxl/libxlu_disk_l.l b/tools/libxl/libxlu_disk_l.l
index 97039a2800..4530c6c4fc 100644
--- a/tools/libxl/libxlu_disk_l.l
+++ b/tools/libxl/libxlu_disk_l.l
@@ -62,6 +62,9 @@ void xlu__disk_yyset_column(int  column_no, yyscan_t 
yyscanner);
 /* For actions whose patterns contain '=', finds the start of the value */
 #define FROMEQUALS (strchr(yytext,'=')+1)
 
+/* For actions whose patterns contain '-', finds the start of the value */
+#define FROMMINUS (strchr(yytext,'-')+1)
+
 /* Chops the delimiter off, modifying yytext and yyleng. */
 #define STRIP(delim) do{                                                \
        if (yyleng>0 && yytext[yyleng-1]==(delim))                      \
@@ -114,6 +117,37 @@ static void setbackendtype(DiskParseContext *dpc, const 
char *str) {
     else xlu__disk_err(dpc,str,"unknown value for backendtype");
 }
 
+static int addbackendfeature(DiskParseContext *dpc, const char *key)
+{
+    libxl_key_value_list *sl = &dpc->disk->backend_features;
+    size_t count = libxl_key_value_list_length(sl);
+    libxl_key_value_list array = *sl;
+    char *eql = strchr(key,'=');
+    char *val = eql + 1;
+    int i;
+
+    array = calloc((count+1) * 2 + 1, sizeof(char*));
+    if (!array)
+        return -ENOMEM;
+
+    for (i = 0; i < count * 2; i++) {
+        if ((*sl)[i])
+            array[i] = strdup((*sl)[i]);
+    }
+    array[i] = NULL;
+    libxl_key_value_list_dispose(sl);
+
+    *eql = 0;
+    count *= 2;
+    array[count++] = strdup(key);
+    array[count++] = strdup(val);
+    array[count] = NULL;
+    *eql = '=';
+
+    *sl = array;
+    return 0;
+}
+
 /* Sets ->colo-port from the string.  COLO need this. */
 static void setcoloport(DiskParseContext *dpc, const char *str) {
     int port = atoi(str);
@@ -187,6 +221,14 @@ script=[^,]*,?     { STRIP(','); SAVESTRING("script", 
script, FROMEQUALS); }
 direct-io-safe,? { DPC->disk->direct_io_safe = 1; }
 discard,?      { libxl_defbool_set(&DPC->disk->discard_enable, true); }
 no-discard,?   { libxl_defbool_set(&DPC->disk->discard_enable, false); }
+require-[a-z][-a-z0-9]*=[^,],? {
+   STRIP(',');
+   if (addbackendfeature(DPC, FROMMINUS)) {
+       xlu__disk_err(DPC,yytext,"unable to parse feature");
+       return 0;
+   }
+}
+
  /* Note that the COLO configuration settings should be considered unstable.
   * They may change incompatibly in future versions of Xen. */
 colo,?         { libxl_defbool_set(&DPC->disk->colo_enable, true); }
-- 
2.11.0


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

 


Rackspace

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