From patchwork Thu Nov 2 18:06:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 10039127 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 039C3600C5 for ; Thu, 2 Nov 2017 18:09:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0DA6290DE for ; Thu, 2 Nov 2017 18:09:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E588229216; Thu, 2 Nov 2017 18:09:11 +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 383EE29202 for ; Thu, 2 Nov 2017 18:09:09 +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 1eAJtG-00059k-It; Thu, 02 Nov 2017 18:06:54 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAJtF-00058l-Kf for xen-devel@lists.xen.org; Thu, 02 Nov 2017 18:06:53 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id 59/65-13910-DBE5BF95; Thu, 02 Nov 2017 18:06:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeJIrShJLcpLzFFi42LpnVTnqrsn7ne kwdJN0hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0brszlMBe0SFR9vvGJrYFwl3MXIxSEkMIlJ 4vKsuUwQzh9Gic3r1rJDOBsYJWZ/W8AK4XQxSnx+PgUow8nBJqAn0Xr+MzOILSJgJNF2fCJYn FmgRuLr5bVgcWEBd4ltt7axgNgsAqoSG5/NBIvzCthJTHjdCWZLCMhL7Gq7CLSAg4NTwF5iwo wCkLAQUEn3mi3sECXGEu1vL7JNYORbwMiwilGjOLWoLLVI18hYL6koMz2jJDcxM0fX0MBMLze 1uDgxPTUnMalYLzk/dxMjMFQYgGAH45/5gYcYJTmYlER57278FSnEl5SfUpmRWJwRX1Sak1p8 iFGGg0NJgndj7O9IIcGi1PTUirTMHGDQwqQlOHiURHjvgKR5iwsSc4sz0yFSpxiNOTpu3v3Dx PFs5usGZiGWvPy8VClx3gyQUgGQ0ozSPLhBsGi6xCgrJczLCHSaEE9BalFuZgmq/CtGcQ5GJW HeIyBTeDLzSuD2vQI6hQnoFC+JHyCnlCQipKQaGKfXix1TfLniX5KdfKL0x5/SSgJpqvcVt3E tPpUrEpe6pLam8j/75or1KW5iE75tXsxd7a1VF5r+xGlizL97fJ7WZ3ffzfJhufT09N9TiWzp 8Y0fJA0evSz/UTY3aZlAdpr8X/UbfVk8HfYr0/mffLuqt2OtNuvpbXx/jpxf8TXCyWrJrUy+R 0osxRmJhlrMRcWJAD2//a+hAgAA X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1509646010!80034645!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25062 invoked from network); 2 Nov 2017 18:06:52 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-9.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 2 Nov 2017 18:06:52 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vA2I6mXL018508 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Nov 2017 18:06:48 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vA2I6m3c009693 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Nov 2017 18:06:48 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vA2I6lVj007983; Thu, 2 Nov 2017 18:06:47 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:46 -0700 From: Joao Martins To: Xen Development List Date: Thu, 2 Nov 2017 18:06:13 +0000 Message-Id: <20171102180616.24084-6-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: aserv0022.oracle.com [141.146.126.234] Cc: Wei Liu , Joao Martins , Ian Jackson Subject: [Xen-devel] [PATCH RFC 5/8] libxlu: parse disk 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 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 --- 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); }