From patchwork Wed Sep 28 09:42:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 9353673 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 B28F16077A for ; Wed, 28 Sep 2016 09:45:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A10EC29478 for ; Wed, 28 Sep 2016 09:45:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95D442947C; Wed, 28 Sep 2016 09:45:05 +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 098192947B for ; Wed, 28 Sep 2016 09:45:05 +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 1bpBO9-0000Gg-GY; Wed, 28 Sep 2016 09:42:53 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpBO8-0000Db-D2 for xen-devel@lists.xenproject.org; Wed, 28 Sep 2016 09:42:52 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 14/13-29563-B909BE75; Wed, 28 Sep 2016 09:42:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsXSO6nOVXf2hNf hBl/6BSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozbu1vYCn5JVLzqOMzWwNgu1MXIxSEkMJlJ YtHZLcwQzjdGiT9d05kgnI2MEve/bWeEcCYwSlzc0MTWxcjBwSZgIvFmlWMXIyeHiICpxPaJJ 1lAapgFpjFKfDp1hAmkRlggSmLH5wiQGhYBVYnur8sZQWxeAXeJjbu7WEBKJATkJZ7drgcxOY HC9w/7glQICbhJfG94zAJiSwgYS7S/vcg2gZFvASPDKkb14tSistQiXSO9pKLM9IyS3MTMHF1 DAzO93NTi4sT01JzEpGK95PzcTYzAIGEAgh2My/46HWKU5GBSEuXdHP46XIgvKT+lMiOxOCO+ qDQntfgQowwHh5IEr0I/UE6wKDU9tSItMwcYrjBpCQ4eJRHeSJA0b3FBYm5xZjpE6hSjopQ4b yVIQgAkkVGaB9cGi5FLjLJSwryMQIcI8RSkFuVmlqDKv2IU52BUEuZdDDKFJzOvBG76K6DFTE CLl554AbK4JBEhJdXAqO46451gza6XQnN/9DjbGXxI8ddIPNv17pvJjaXK6RLz/+hYtYq0KFi W5ElmHZmyIWX5pB0LNnbcf/2rI8N56anXStLyGfPfmXBw124Oua+ofDVn2rJTobJBdrHZri0d 289XiSbLtUi57Cl6MlVMT0q/y92ozb1lz7rCRfHyE44yrZiUyBCtxFKckWioxVxUnAgAAIEV8 YwCAAA= X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1475055769!61585175!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: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24841 invoked from network); 28 Sep 2016 09:42:50 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-3.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 28 Sep 2016 09:42:50 -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 u8S9gjUB028808 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Sep 2016 09:42:45 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 u8S9gjuq002823 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Sep 2016 09:42:45 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u8S9ggCr019429; Wed, 28 Sep 2016 09:42:43 GMT Received: from localhost.localdomain.com (/209.6.196.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Sep 2016 02:42:42 -0700 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, konrad@kernel.org Date: Wed, 28 Sep 2016 05:42:24 -0400 Message-Id: <1475055746-22401-11-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1475055746-22401-1-git-send-email-konrad.wilk@oracle.com> References: <1475055746-22401-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: Wei Liu , Ian Jackson , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v1 10/12] tmem: Unify XEN_SYSCTL_TMEM_OP_[[SAVE_[BEGIN|END]|RESTORE_BEGIN] 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 return values. For success they used to be 1 ([SAVE,RESTORE]_BEGIN), 0 if guest did not have any tmem (but only for SAVE_BEGIN), and -1 for any type of failure. And SAVE_END (which you would think would mirror SAVE_BEGIN) had 0 for success and -1 if guest did not any tmem enabled for it. This is confusing. Now the code will return 0 if the operation was success. Various XEN_EXX values are returned if tmem is not enabled or the operation could not performed. The xc_tmem.c code only needs one place to check - where we use SAVE_BEGIN. The place where RESTORE_BEGIN is used will have errno with the proper error value and return will be -1, so will still fail properly. Signed-off-by: Konrad Rzeszutek Wilk Acked-by: Wei Liu --- Cc: Ian Jackson Cc: Wei Liu v1: First submission --- tools/libxc/xc_tmem.c | 14 +++++++++++--- xen/common/tmem.c | 15 ++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/tools/libxc/xc_tmem.c b/tools/libxc/xc_tmem.c index 7873674..a843210 100644 --- a/tools/libxc/xc_tmem.c +++ b/tools/libxc/xc_tmem.c @@ -216,15 +216,23 @@ int xc_tmem_save(xc_interface *xch, int dom, int io_fd, int live, int field_marker) { int marker = field_marker; - int i, j; + int i, j, rc; uint32_t flags; uint32_t minusone = -1; uint32_t pool_id; struct tmem_handle *h; xen_sysctl_tmem_client_t info; - if ( xc_tmem_control(xch,0,XEN_SYSCTL_TMEM_OP_SAVE_BEGIN,dom,live,0,NULL) <= 0 ) - return 0; + rc = xc_tmem_control(xch, 0, XEN_SYSCTL_TMEM_OP_SAVE_BEGIN, + dom, live, 0, NULL); + if ( rc ) + { + /* Nothing to save - no tmem enabled. */ + if ( errno == ENOENT ) + return 0; + + return rc; + } if ( write_exact(io_fd, &marker, sizeof(marker)) ) return -1; diff --git a/xen/common/tmem.c b/xen/common/tmem.c index ab354b6..997f2b0 100644 --- a/xen/common/tmem.c +++ b/xen/common/tmem.c @@ -1656,30 +1656,31 @@ static int tmemc_save_subop(int cli_id, uint32_t pool_id, struct client *client = tmem_client_from_cli_id(cli_id); uint32_t p; struct tmem_page_descriptor *pgp, *pgp2; - int rc = -1; + int rc = -ENOENT; switch(subop) { case XEN_SYSCTL_TMEM_OP_SAVE_BEGIN: if ( client == NULL ) - return 0; + break; for (p = 0; p < MAX_POOLS_PER_DOMAIN; p++) if ( client->pools[p] != NULL ) break; + if ( p == MAX_POOLS_PER_DOMAIN ) - { - rc = 0; break; - } + client->was_frozen = client->info.flags.u.frozen; client->info.flags.u.frozen = 1; if ( arg1 != 0 ) client->info.flags.u.migrating = 1; - rc = 1; + rc = 0; break; case XEN_SYSCTL_TMEM_OP_RESTORE_BEGIN: if ( client == NULL && (client = client_create(cli_id)) != NULL ) - return 1; + rc = 0; + else + rc = -EEXIST; break; case XEN_SYSCTL_TMEM_OP_SAVE_END: if ( client == NULL )