From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xenproject.org, konrad@kernel.org
Cc: Wei Liu <wei.liu2@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH v1 10/12] tmem: Unify XEN_SYSCTL_TMEM_OP_[[SAVE_[BEGIN|END]|RESTORE_BEGIN]
Date: Wed, 28 Sep 2016 05:42:24 -0400 [thread overview]
Message-ID: <1475055746-22401-11-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1475055746-22401-1-git-send-email-konrad.wilk@oracle.com>
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 <konrad.wilk@oracle.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
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 )
--
2.4.11
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-09-28 9:42 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-28 9:42 [PATCH v1] Tmem cleanups/improvements for v4.8 Konrad Rzeszutek Wilk
2016-09-28 9:42 ` [PATCH v1 01/12] libxc/tmem/restore: Remove call to XEN_SYSCTL_TMEM_OP_SAVE_GET_VERSION Konrad Rzeszutek Wilk
2016-09-28 11:00 ` Wei Liu
2016-09-28 9:42 ` [PATCH v1 02/12] tmem: Retire XEN_SYSCTL_TMEM_OP_[SET_CAP|SAVE_GET_CLIENT_CAP] Konrad Rzeszutek Wilk
2016-09-28 11:00 ` Wei Liu
2016-09-28 15:03 ` Konrad Rzeszutek Wilk
2016-09-28 12:10 ` Jan Beulich
2016-09-30 14:04 ` Konrad Rzeszutek Wilk
2016-09-28 9:42 ` [PATCH v1 03/12] tmem: Wrap tmem dedup code with CONFIG_TMEM_DEDUP Konrad Rzeszutek Wilk
2016-09-28 12:18 ` Jan Beulich
2016-09-28 9:42 ` [PATCH v1 04/12] tmem: Wrap tmem tze code with CONFIG_TMEM_TZE Konrad Rzeszutek Wilk
2016-09-28 12:19 ` Jan Beulich
2016-09-28 9:42 ` [PATCH v1 05/12] tmem: Delete deduplication (and tze) code Konrad Rzeszutek Wilk
2016-09-28 12:34 ` Jan Beulich
2016-09-28 15:05 ` Konrad Rzeszutek Wilk
2016-09-28 9:42 ` [PATCH v1 06/12] tmem: Move client weight, frozen, live_migrating, and compress Konrad Rzeszutek Wilk
2016-09-28 12:39 ` Jan Beulich
2016-09-28 9:42 ` [PATCH v1 07/12] tmem/libxc: Squash XEN_SYSCTL_TMEM_OP_[SET|SAVE] Konrad Rzeszutek Wilk
2016-09-28 11:06 ` Wei Liu
2016-09-28 12:50 ` Jan Beulich
2016-09-28 9:42 ` [PATCH v1 08/12] tmem: Handle 'struct tmem_info' as a seperate field in the Konrad Rzeszutek Wilk
2016-09-28 11:00 ` Wei Liu
2016-09-28 12:56 ` Jan Beulich
2016-09-30 14:36 ` Konrad Rzeszutek Wilk
2016-09-30 14:56 ` Jan Beulich
2016-09-30 16:51 ` Konrad Rzeszutek Wilk
2016-09-28 9:42 ` [PATCH v1 09/12] tmem: Check version and maxpools when XEN_SYSCTL_TMEM_SET_CLIENT_INFO Konrad Rzeszutek Wilk
2016-09-28 11:00 ` Wei Liu
2016-09-28 12:58 ` Jan Beulich
2016-09-28 9:42 ` Konrad Rzeszutek Wilk [this message]
2016-09-28 11:06 ` [PATCH v1 10/12] tmem: Unify XEN_SYSCTL_TMEM_OP_[[SAVE_[BEGIN|END]|RESTORE_BEGIN] Wei Liu
2016-09-28 13:00 ` Jan Beulich
2016-09-28 9:42 ` [PATCH v1 11/12] tmem/xc_tmem_control: Rename 'arg1' to 'len' and 'arg2' to arg Konrad Rzeszutek Wilk
2016-09-28 11:07 ` Wei Liu
2016-09-28 9:42 ` [PATCH v1 12/12] tmem: Batch and squash XEN_SYSCTL_TMEM_OP_SAVE_GET_POOL_[FLAGS, NPAGES, UUID] in one sub-call: XEN_SYSCTL_TMEM_OP_GET_POOLS Konrad Rzeszutek Wilk
2016-09-28 11:07 ` Wei Liu
2016-09-28 13:11 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1475055746-22401-11-git-send-email-konrad.wilk@oracle.com \
--to=konrad.wilk@oracle.com \
--cc=ian.jackson@eu.citrix.com \
--cc=konrad@kernel.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).