From patchwork Fri Sep 30 18:11:52 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: 9358723 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 D53D160757 for ; Fri, 30 Sep 2016 18:14:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE3472A14C for ; Fri, 30 Sep 2016 18:14:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C30742A153; Fri, 30 Sep 2016 18:14:28 +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 66F662A14C for ; Fri, 30 Sep 2016 18:14:28 +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 1bq2IL-0005fC-To; Fri, 30 Sep 2016 18:12:25 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bq2IK-0005au-7y for xen-devel@lists.xenproject.org; Fri, 30 Sep 2016 18:12:24 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 2B/AC-09160-70BAEE75; Fri, 30 Sep 2016 18:12:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsXSO6nOVZd99bt wgzcLWCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oy379YyFtySqlj8eRpLA+Me4S5GLg4hgYlM EjMenWaGcH4zSmw4+gHK2cgocffnTEYIZwKjxL6mb0AZDg42AROJN6scuxg5OUQETCW2TzzJA lLDLDCNUeLTqSNMIAlhgQiJw92LGUFsFgFVidnH77GD2LwCrhK7uvaBzZEQkJd4drseJMwp4C Zxe8s0sHIhoJLOPydYQWwJAUOJzxuXMk9g5FvAyLCKUb04tagstUjXQi+pKDM9oyQ3MTNH19D AWC83tbg4MT01JzGpWC85P3cTIzBQGIBgB+OFdudDjJIcTEqivLJH34YL8SXlp1RmJBZnxBeV 5qQWH2KU4eBQkuB9uPJduJBgUWp6akVaZg4wZGHSEhw8SiK8EiBp3uKCxNzizHSI1ClGRSlx3 pUgCQGQREZpHlwbLE4uMcpKCfMyAh0ixFOQWpSbWYIq/4pRnINRSZj3I8gUnsy8Erjpr4AWMw Etzj/6BmRxSSJCSqqB0X5aVuyV/1yhbItqDJWkpOLen5097YiZ3/mwd/NDTnX6HOZptD3Wdz/ sz9XFE58We8w56WvJ4nntIiv3Cvt51xndJDsyysX1P3jpnxFay9Lio77tcvnO9xHJUgKlQdoP Qq9PPKH/cJFeb+W69TIz7q+8XXJh3h5XJ6YUj0Oup0OPvDrw0tklWomlOCPRUIu5qDgRAIZqZ n+OAgAA X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1475259141!63881806!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 63300 invoked from network); 30 Sep 2016 18:12:22 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-8.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 30 Sep 2016 18:12:22 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8UICIsC005529 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Sep 2016 18:12:18 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u8UICIK2017870 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Sep 2016 18:12:18 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8UICHYr016543; Fri, 30 Sep 2016 18:12:17 GMT Received: from localhost.us.oracle.com (/10.154.132.195) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 30 Sep 2016 11:12:17 -0700 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, konrad@kernel.org Date: Fri, 30 Sep 2016 14:11:52 -0400 Message-Id: <1475259114-8693-8-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1475259114-8693-1-git-send-email-konrad.wilk@oracle.com> References: <1475259114-8693-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: Wei Liu , Ian Jackson , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v2 7/9] 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. Acked-by: Wei Liu Signed-off-by: Konrad Rzeszutek Wilk Acked-by: Andrew Cooper --- Cc: Ian Jackson Cc: Wei Liu v1: First submission v2: Rework return value for XEN_SYSCTL_TMEM_OP_RESTORE_BEGIN if couldn't allocate tmem components. Added Wei's Ack. --- tools/libxc/xc_tmem.c | 14 +++++++++++--- xen/common/tmem.c | 17 +++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/tools/libxc/xc_tmem.c b/tools/libxc/xc_tmem.c index 7c06841..6c7ad93 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_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..510d11c 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; + if ( client == NULL ) + rc = client_create(cli_id) ? 0 : -ENOMEM; + else + rc = -EEXIST; break; case XEN_SYSCTL_TMEM_OP_SAVE_END: if ( client == NULL )