[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: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Thu, 1 Jul 2021 10:36:58 +0100
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Ian Jackson" <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Thu, 01 Jul 2021 09:37:10 +0000
  • Ironport-hdrordr: A9a23:aV8rXagP0EaouoqsIqvy4nXxn3BQXtgji2hC6mlwRA09TySZ// rOoB0+726StN9xYgBFpTnuAsW9qB/nmqKdpLNhW4tKPzOW3VdATrsSjrcKqgeIc0aVm9K1l5 0QEZSWYOeAdGSS5vyb3ODXKbgd/OU=
  • Ironport-sdr: D7sASBiW/pQzogWFFQWPVDciAodScg54xMExaFQMaLFKTfiUAVd5vN8t7M99S4jCzohkvw2Kt3 bHMkP4dM/TFe8F7qUIcJ+RlejgCz/IlbSxbuQZuY3TU+pLnx95CvIamn9/YJLU9Zmhbp+Lf91E lKrq1jMS+JiidRfnaICSipkHYoVz73/RiuTdiu7GRf1sT5GoqILTVLzQ1bQ4I6rmY039O3iErN AvIr34ve66y9IkNUqLxvx+pgCF4nj81u3ikbi+p48Y7Tg05sqzoA0LpxVbhi8qISeQbLSdrEod LF8=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Jun 28, 2021 at 01:47:03PM +0200, Jan Beulich wrote:
> The hypervisor may not have enough memory to satisfy the request.
> 
> Requested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> Especially if the request was mostly fulfilled, guests may have done
> fine despite the failure, so there is a risk of perceived regressions
> here. But not checking the error at all was certainly wrong.
> 
> --- 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, 
> XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION,
> -                          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.

> +                                   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?

> +            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.

> +                  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?

Thanks,

-- 
Anthony PERARD



 


Rackspace

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