devargs: use a comma instead of semicolon to separate key/values
authorOlivier Matz <olivier.matz@6wind.com>
Fri, 28 Feb 2014 17:25:47 +0000 (18:25 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Thu, 10 Apr 2014 13:50:11 +0000 (15:50 +0200)
This commit changes the API of --use-device command line argument.
It changes the separators from ';' to ','. Indeed, ';' is not the best
choice as this character is also used to separate shell commands,
forcing the user to surround arguments with quotes.

This commit impacts both devargs and kvargs as each of them define
a separator in --use-device argument:

- devargs defines the separator between the device name or pci_id and
   its arguments
- kvargs defines the separator between each key/value pairs in
   arguments for drivers using the kvargs API to parse their arguments

The modification of devargs and kvargs is done in one commit to keep
the coherency of --use-device.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
app/test/test_devargs.c
app/test/test_eal_flags.c
app/test/test_kvargs.c
lib/librte_eal/common/eal_common_devargs.c
lib/librte_eal/common/include/rte_devargs.h
lib/librte_eal/linuxapp/eal/eal.c
lib/librte_kvargs/rte_kvargs.h

index 035ed59f3d9e9183b13ad112cff0168273d6314b..63eee0b58037faa68c4896fbae317a14555f1896 100644 (file)
@@ -67,7 +67,7 @@ test_devargs(void)
                goto fail;
        if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "0000:5:00.0") < 0)
                goto fail;
-       if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "04:00.0;arg=val") < 0)
+       if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "04:00.0,arg=val") < 0)
                goto fail;
        if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "0000:01:00.1") < 0)
                goto fail;
@@ -79,20 +79,20 @@ test_devargs(void)
                goto fail;
        if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "eth_ring0") < 0)
                goto fail;
-       if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "eth_ring1;key=val;k2=val2") < 0)
+       if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "eth_ring1,key=val,k2=val2") < 0)
                goto fail;
        if (rte_eal_devargs_type_count(RTE_DEVTYPE_VIRTUAL) != 2)
                goto fail;
        free_devargs_list();
 
        /* check virtual device with argument parsing */
-       if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "eth_ring1;k1=val;k2=val2") < 0)
+       if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "eth_ring1,k1=val,k2=val2") < 0)
                goto fail;
        devargs = TAILQ_FIRST(&devargs_list);
        if (strncmp(devargs->virtual.drv_name, "eth_ring1",
                        sizeof(devargs->virtual.drv_name) != 0))
                goto fail;
-       if (strncmp(devargs->args, "k1=val;k2=val2", sizeof(devargs->args) != 0))
+       if (strncmp(devargs->args, "k1=val,k2=val2", sizeof(devargs->args) != 0))
                goto fail;
        free_devargs_list();
 
@@ -116,7 +116,7 @@ test_devargs(void)
                goto fail;
        if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "foo") == 0)
                goto fail;
-       if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, ";") == 0)
+       if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, ",") == 0)
                goto fail;
        if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "000f:0:0") == 0)
                goto fail;
index 9bab1a5ab00af607cd50c54dcf19662525650f35..45d3d02ad05f7c08ad0982a1b96a49b09fb8f216 100644 (file)
@@ -313,8 +313,8 @@ test_whitelist_flag(void)
        const char *wlval2[] = {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
                        use_device, "09:0B.3", use_device, "0a:0b.1"};
        const char *wlval3[] = {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
-                       use_device, "09:0B.3;type=test",
-                       use_device, "08:00.1;type=normal"};
+                       use_device, "09:0B.3,type=test",
+                       use_device, "08:00.1,type=normal"};
 
        for (i = 0; i < sizeof(wlinval) / sizeof(wlinval[0]); i++) {
                if (launch_proc(wlinval[i]) == 0) {
index 2db9d08ddee38bf8cfaa610d27ff2339abab7a93..c417ba23485b5bee7acbb01f93531a50fb26abba 100644 (file)
@@ -84,7 +84,7 @@ static int test_valid_kvargs(void)
        rte_kvargs_free(kvlist);
 
        /* first test without valid_keys */
-       args = "foo=1234;check=value0;check=value1";
+       args = "foo=1234,check=value0,check=value1";
        valid_keys = NULL;
        kvlist = rte_kvargs_parse(args, valid_keys);
        if (kvlist == NULL) {
@@ -145,7 +145,7 @@ static int test_valid_kvargs(void)
        rte_kvargs_free(kvlist);
 
        /* second test using valid_keys */
-       args = "foo=droids;check=value0;check=value1;check=wrong_value";
+       args = "foo=droids,check=value0,check=value1,check=wrong_value";
        valid_keys = valid_keys_list;
        kvlist = rte_kvargs_parse(args, valid_keys);
        if (kvlist == NULL) {
@@ -190,11 +190,11 @@ static int test_invalid_kvargs(void)
        /* list of argument that should fail */
        const char *args_list[] = {
                "wrong-key=x",     /* key not in valid_keys_list */
-               "foo=1;foo=",      /* empty value */
-               "foo=1;;foo=2",    /* empty key/value */
-               "foo=1;foo",       /* no value */
-               "foo=1;=2",        /* no key */
-               ";=",              /* also test with a smiley */
+               "foo=1,foo=",      /* empty value */
+               "foo=1,,foo=2",    /* empty key/value */
+               "foo=1,foo",       /* no value */
+               "foo=1,=2",        /* no key */
+               ",=",              /* also test with a smiley */
                NULL };
        const char **args;
        const char *valid_keys_list[] = { "foo", "check", NULL };
index 52f5cc76696ae4d68345a5b044c54b628bf5d81e..c497ea31a86c3f10f9a118049f7873dd8fc05a3e 100644 (file)
@@ -69,8 +69,8 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
        memset(devargs, 0, sizeof(*devargs));
        devargs->type = devtype;
 
-       /* set the first ';' to '\0' to split name and arguments */
-       sep = strchr(buf, ';');
+       /* set the first ',' to '\0' to split name and arguments */
+       sep = strchr(buf, ',');
        if (sep != NULL) {
                sep[0] = '\0';
                snprintf(devargs->args, sizeof(devargs->args), "%s", sep + 1);
index 2e6e1f39e95162474308b2ad7ca3e3263b51d5e4..c093c171b7fb6957a54582a357d2cd720032d307 100644 (file)
@@ -101,12 +101,12 @@ extern struct rte_devargs_list devargs_list;
  * Add a device to the user device list
  *
  * For PCI devices, the format of arguments string is "PCI_ADDR" or
- * "PCI_ADDR;key=val;key2=val2;...". Examples: "08:00.1", "0000:5:00.0",
- * "04:00.0;arg=val".
+ * "PCI_ADDR,key=val,key2=val2,...". Examples: "08:00.1", "0000:5:00.0",
+ * "04:00.0,arg=val".
  *
  * For virtual devices, the format of arguments string is "DRIVER_NAME*"
- * or "DRIVER_NAME*;key=val;key2=val2;...". Examples: "eth_ring",
- * "eth_ring0", "eth_pmdAnything;arg=0:arg2=1". The validity of the
+ * or "DRIVER_NAME*,key=val,key2=val2,...". Examples: "eth_ring",
+ * "eth_ring0", "eth_pmdAnything,arg=0:arg2=1". The validity of the
  * driver name is not checked by this function, it is done when probing
  * the drivers.
  *
index 78737cfb85fcc05be01f9c2f7e828e51bca801fa..f5f02e96baf4192f7c2943a96f195684f1bdea1f 100644 (file)
@@ -612,7 +612,7 @@ eal_parse_use_device(const char *optarg)
                return -1;
 
        /* remove arguments in 'dup' string */
-       sep = strchr(dup, ';');
+       sep = strchr(dup, ',');
        if (sep != NULL)
                *sep = '\0';
 
index 71c9630d9d78889d2abd129c70b2baf95cb4e850..ef4efabfb50ea6227259d05d6d11941a0299e320 100644 (file)
@@ -40,7 +40,7 @@
  * RTE Argument parsing
  *
  * This module can be used to parse arguments whose format is
- * key1=value1;key2=value2;key3=value3;...
+ * key1=value1,key2=value2,key3=value3,...
  *
  * The same key can appear several times with the same or a different
  * value. Indeed, the arguments are stored as a list of key/values
@@ -58,7 +58,7 @@ extern "C" {
 #define RTE_KVARGS_MAX 32
 
 /** separator character used between each pair */
-#define RTE_KVARGS_PAIRS_DELIM ";"
+#define RTE_KVARGS_PAIRS_DELIM ","
 
 /** separator character used between key and value */
 #define RTE_KVARGS_KV_DELIM    "="
@@ -83,7 +83,7 @@ struct rte_kvargs {
  * Allocate a rte_kvargs and store key/value associations from a string
  *
  * The function allocates and fills a rte_kvargs structure from a given
- * string whose format is key1=value1;key2=value2;...
+ * string whose format is key1=value1,key2=value2,...
  *
  * The structure can be freed with rte_kvargs_free().
  *