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

[Xen-devel] [PATCH RFC 6/8] xl: parse vif backend features parameters



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

An example would be a config containing:

...
vcpus = 8
vif = ["bridge=br0,require-multi-queue-max-queues=2"]
...

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

Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx>
---
 tools/xl/xl_parse.c | 37 +++++++++++++++++++++++++++++++++++++
 tools/xl/xl_parse.h |  2 ++
 2 files changed, 39 insertions(+)

diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 9a692d5ae6..007df694d8 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -401,6 +401,29 @@ void replace_string(char **str, const char *val)
     *str = xstrdup(val);
 }
 
+static void add_to_kvlist(libxl_key_value_list *sl, char *key, char *val)
+{
+    size_t count = libxl_key_value_list_length(sl);
+    libxl_key_value_list array = *sl;
+    int i;
+
+    array = xcalloc((count+1) * 2 + 1, sizeof(char*));
+
+    for (i = 0; i < count * 2; i++) {
+        if ((*sl)[i])
+            array[i] = xstrdup((*sl)[i]);
+    }
+    array[i] = NULL;
+    libxl_key_value_list_dispose(sl);
+
+    count *= 2;
+    array[count++] = xstrdup(key);
+    array[count++] = xstrdup(val);
+    array[count] = NULL;
+
+    *sl = array;
+}
+
 int match_option_size(const char *prefix, size_t len,
                       char *arg, char **argopt)
 {
@@ -559,6 +582,20 @@ int parse_nic_config(libxl_device_nic *nic, XLU_Config 
**config, char *token)
         fprintf(stderr, "the accel parameter for vifs is currently not 
supported\n");
     } else if (MATCH_OPTION("devid", token, oparg)) {
         nic->devid = parse_ulong(oparg);
+    } else if (MATCH_FEATURE("require", token, oparg)) {
+        char *key = NULL, *value = NULL;
+        int rc;
+
+        rc = split_string_into_pair(oparg, "=", &key, &value);
+        if (rc != 0) {
+            fprintf(stderr, "failed to parse vif backend feature %s", oparg);
+            return 1;
+        }
+
+        add_to_kvlist(&nic->backend_features, key, value);
+
+        free(key);
+        free(value);
     } else {
         fprintf(stderr, "unrecognized argument `%s'\n", token);
         return 1;
diff --git a/tools/xl/xl_parse.h b/tools/xl/xl_parse.h
index cc459fb43f..aea07394cc 100644
--- a/tools/xl/xl_parse.h
+++ b/tools/xl/xl_parse.h
@@ -40,6 +40,8 @@ int match_option_size(const char *prefix, size_t len,
 #define MATCH_OPTION(prefix, arg, oparg) \
     match_option_size((prefix "="), sizeof((prefix)), (arg), &(oparg))
 
+#define MATCH_FEATURE(prefix, arg, oparg) \
+    match_option_size((prefix "-"), sizeof((prefix)), (arg), &(oparg))
 
 void split_string_into_string_list(const char *str, const char *delim,
                                    libxl_string_list *psl);
-- 
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®.