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

[PATCH v2 01/13] libxl/x86: check return value of SHADOW_OP_SET_ALLOCATION domctl


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 5 Jul 2021 17:11: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=AcLhpKAZnmoAxFsMXWPBvUtE43UW7eAar8znGWUZKyw=; b=ON+KynClQBccv0jFvPU81/NGcVK8MLpotaL6Ayq+ZYjBfNXSki9B/UU56Q3fd3HPt3AAtN2S/kYqmWAQ/eDlxmiEd3kgbBjiAbt8SuhPalfI/cBU50E3p8EMPJkUypDdTBtBiKLf9r7OsaqpiLJVAGoi7HEkrnLUVfumBNCR59tFrhLLeA36dDVQto40L5MkJaUu3Anv4kKBNEdxAYBj92dmixfJ3l+n5FQ/WseF3blyRVMxclN7hqRoGVj3um9Z4sIymIcnOv4+J4QcPYrnlKRpfFEw6kH9pfbxd65bVZt2Pp7Gr6dbyfCqIExJoGv8hoWkCzcBa4dz3QELKoYiSQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jlvKvdqYLYu7h/KlKE3pgNssHdz0OXu/LBVV8aYbKrWZq4LTZ7y5SJ2RiuvBFsddmFWUFqtWXVfMS73GOnH8+Bh3gGV6MpimR2Ezq+JxgZiSkwj+dm+4HpAUmAkMUaU+AkIv6EQTztmsa0z2ioKoa2GD7VtcPj/HQIiD10ZdjLtv7MZ4Fau9EwqcxI+Une5mleSM7VFLSz1xFqiQjRYy2t/RDEgupqNXunlWLyW8vD0S9KkL9r6I0by5DtOeiCxWjV8ZZg+4dnsl68DL4PkYPXrRTn0zyV0vETS59D24hwi7kzN/qbkiyPGKgWvuOizMzFNqYj8I4HNaNEJoDbU/Yw==
  • Authentication-results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Mon, 05 Jul 2021 15:11:40 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The hypervisor may not have enough memory to satisfy the request. While
there, make the unit of the value clear by renaming the local variable.

Requested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
v2: Rename local variables. Also log requested value. Don't log errno
    explicitly in LOGED() (nor function return value). Integrate into
    series.
---
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
@@ -529,10 +529,20 @@ int libxl__arch_domain_create(libxl__gc
         xc_domain_set_time_offset(ctx->xch, domid, rtc_timeoffset);
 
     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);
+        unsigned long shadow_mb = DIV_ROUNDUP(d_config->b_info.shadow_memkb,
+                                              1024);
+        int r = xc_shadow_control(ctx->xch, domid,
+                                  XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION,
+                                  NULL, 0, &shadow_mb, 0, NULL);
+
+        if (r) {
+            LOGED(ERROR, domid,
+                  "Failed to set %lu MiB %s allocation",
+                  shadow_mb,
+                  libxl_defbool_val(d_config->c_info.hap) ? "HAP" : "shadow");
+            ret = ERROR_FAIL;
+            goto out;
+        }
     }
 
     if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV &&




 


Rackspace

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