From patchwork Thu Nov 2 18:06:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 10039135 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F33E2603D7 for ; Thu, 2 Nov 2017 18:09:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC5FA29202 for ; Thu, 2 Nov 2017 18:09:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E15B929226; Thu, 2 Nov 2017 18:09:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 73D3129216 for ; Thu, 2 Nov 2017 18:09:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAJtL-0005Es-15; Thu, 02 Nov 2017 18:06:59 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAJtJ-0005Cu-Q0 for xen-devel@lists.xen.org; Thu, 02 Nov 2017 18:06:57 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id 68/0D-25852-1CE5BF95; Thu, 02 Nov 2017 18:06:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsUyZ7p8oO6BuN+ RBkf+q1ks+biYxYHR4+ju30wBjFGsmXlJ+RUJrBlTJmkXfBerOLTrF1MD41/BLkZODiGBCUwS L5uzuhi5gOw/jBLXZzWzQDgbGCV2fD7FCuF0MUpcmDuPEaSFTUBPovX8Z2YQW0TASKLt+ER2E JtZoEbi6+W1YHFhASeJm02tTCA2i4CqxK6eVrAaXgE7iY77i1lBbAkBeYldbReBbA4OTgF7iQ kzCiAuspPoXrOFHaLEUOLzxqXMExj5FjAyrGLUKE4tKkst0jU21EsqykzPKMlNzMzRNTQw08t NLS5OTE/NSUwq1kvOz93ECAwTBiDYwdi0KPAQoyQHk5Io792NvyKF+JLyUyozEosz4otKc1KL DzHKcHAoSfBujP0dKSRYlJqeWpGWmQMMWJi0BAePkgivGDBohXiLCxJzizPTIVKnGC05jm26/ IeJo+PmXSD5bObrBmYhlrz8vFQpcd67IPMEQBoySvPgxsGi6hKjrJQwLyPQgUI8BalFuZklqP KvGMU5GJWEeb1BpvBk5pXAbX0FdBAT0EFeEj9ADipJREhJNTCqPoi89NRFIFF58ctXx/XmOWt x1IYdMGdhWLxywsXpYXGcgvWJ+gZXRHimFy2z026W7b8pc/Zp5eyEn88fKaxL1asKV35cvz7a zdQ3i//wIVO9p0Zbyld5GVYVzohmSeNezmFouOHYOlGD5Yk+4fU20jM+pDmHP/N4O99UvOyAo oZyclC6gxJLcUaioRZzUXEiACh5rSelAgAA X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1509646014!114315530!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33867 invoked from network); 2 Nov 2017 18:06:56 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-16.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 2 Nov 2017 18:06:56 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vA2I6n2U017816 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Nov 2017 18:06:50 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vA2I6nEU024252 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Nov 2017 18:06:49 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id vA2I6nb5005491; Thu, 2 Nov 2017 18:06:49 GMT Received: from paddy.uk.oracle.com (/10.175.173.7) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 02 Nov 2017 11:06:48 -0700 From: Joao Martins To: Xen Development List Date: Thu, 2 Nov 2017 18:06:14 +0000 Message-Id: <20171102180616.24084-7-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171102180616.24084-1-joao.m.martins@oracle.com> References: <20171102180616.24084-1-joao.m.martins@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: Wei Liu , Joao Martins , Ian Jackson Subject: [Xen-devel] [PATCH RFC 6/8] xl: parse vif backend features parameters X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);