[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] libxl/x86: check return value of SHADOW_OP_SET_ALLOCATION domctl

  • To: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 2 Jul 2021 14:29:31 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OXCXkoq7qZBEYwgC4hG+ro2jpvJk8JLQN6Z4zTZq0hQ=; b=VOHuIxbCpg5GR8qL0gR41u7D2F1Cg4TwWivihmQV4vQsdtsxBlZ5yDgNmsba33qgXpjCG/5Xo2L4cE+LyoE/wFA/shuM3R7Rl+P4w7k5e7qRXn5lMgYB08XB3bwK50t5bpX5Uwz4NEZ8miL0Gc2iFO0nD96NnqSSwGEIeXkKKz/K3XsiEu2Eo+jE1Dm1ph0BROlKEF0OsSBJyF9JtP5tFex8C4bYhRHblEb7BsdohngBAjzXREkJrrmaQzjNv0BbDhqccqpf0J6RRSCB8UsMLTUJ52VRCfwibcU/0JkXhrpK9RFUjL4j3EpFvwXYj0Wlj2CizK86vD37ri/Tjhpr6Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P8bN8gQjkon8mrsXNk5pu8YrATEWXhKBB7d79E4HJOXut9fJeZzyhXI1/wXiz+4CNQGMAkXiv8x1svRVx644n2K80k7hVojrpwAPrphXqjxW9TzRicvKLbrEudlaamrbQ0b9YCkpicjgow5JaA+nbFl6v1rmjJBUfdWkbUOUCV2yCSJHAy8XZCMKmxjMkgSs+PSVPz4BWy6ewHwvCqORN3u1eqpBZhRyClHQrZB3oqDz6PhWDvZ8k4F+Fb4yZ3aiM3AoXK5xDf1vtuhEqv+kHLRuEohCLIsG/jU128lO7AL+lsbrASzF00dkVz1ouGB5QOGIN97OZ4FHAHzpaXew9g==
  • Authentication-results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Fri, 02 Jul 2021 12:29:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 01.07.2021 11:36, Anthony PERARD wrote:
> On Mon, Jun 28, 2021 at 01:47:03PM +0200, Jan Beulich wrote:
>> --- a/tools/libs/light/libxl_x86.c
>> +++ b/tools/libs/light/libxl_x86.c
>> @@ -531,8 +531,18 @@ int libxl__arch_domain_create(libxl__gc
>>      if (d_config->b_info.type != LIBXL_DOMAIN_TYPE_PV) {
>>          unsigned long shadow = DIV_ROUNDUP(d_config->b_info.shadow_memkb,
>>                                             1024);
>> -        xc_shadow_control(ctx->xch, domid, 
>> -                          NULL, 0, &shadow, 0, NULL);
>> +        int rc = xc_shadow_control(ctx->xch, domid,
> Could you use 'r' instead of 'rc' ? The later is reserved for libxl
> error codes while the former is for system and libxc calls.

Of course I can, but I did look at the rest of the function and
found that it uses "ret" for the purpose of what you now say
"rc" ought to be used for. Seeing "ret", I decided to avoid it
(knowing you use different names for different kinds of return
values). While I've switched to "r" for now, I'd be rather
inclined to re-use "ret" instead. (Or actually, as per the
remark further down, I can get away without any local variable

>> +                                   XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION,
>> +                                   NULL, 0, &shadow, 0, NULL);
>> +
>> +        if (rc) {
> xc_shadow_control seems to return "domctl.u.shadow_op.pages" in some
> cases, are all non-zero return value errors?

Indeed it does, but (a) we pass in zero here and (b) this
operation doesn't alter (nor even care about) the value. So I'd
prefer to stick to what I have, but if you tell me to switch to
"... < 0", I will.

>> +            LOGED(ERROR, domid,
>> +                  "Failed to set %s allocation: %d (errno:%d)\n",
> LOGED already prints prints the meaning of the "errno" value, so we
> don't need to log it.

I see. Please note that again I took neighboring code (a few lines
down) for reference. Judging from other call sites (not the one
right below here) I infer I also shouldn't have \n in the format

>> +                  libxl_defbool_val(d_config->c_info.hap) ? "HAP" : 
>> "shadow",
>> +                  rc, errno);
> Is the return value of xc_shadow_control() actually useful when errno is
> already logged?

I don't know. Again what I had matches what can be found a few
lines down in the same function. But looking at other uses (in
other files) I'm getting the impression that it's useless -




Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.