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

[PATCH v3 01/13] libxl: don't ignore the return value from xc_cpuid_apply_policy


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Fri, 30 Apr 2021 17:51:59 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=Qgb30KFYcBaUuDasLfF1eBFyIimrl8aSOAVxfb7Zs3E=; b=WjJx4oZy6hRLrLgo1lK2iX4xx/iR75htJThriuiY08Ld4Mgct0b0sKDRFoqTnZGrIZSltfWbd/zW81OHCbQOIkLDEdQSuH+bUJ4JGzgE0ksNe7QUzt62FE3Cfsa2xLhLPKjbprlcwTt/zofIIAXcyN5++ifT4pmK2v/V7IdZiAiR8c/EkPsStyULR0zVg9AFspA6uiN9X6varaxn8MzI77Vi6OEFNA2+wMQGUZJn/b+MuFnuQ6Zwwr3Hxk4LJRPE7+lzqRnPKVM47BcI0dlbZ/0OOq5cQIBlil+GwMxaGiGIqyXNyDwKK4Y1ZXbuehd1zvwgY2VeuOEXDXGHBwGQmw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jkBWrQJskZdbF3bwRGFqRxUm4BUhF5+duVbTnaV8lC9uHbfC4w7l8dZi7sodtOyzmG1D8oySR+Tfy2b7w0GBMTvxk+YVje8AkE9UVyyoVemUrqBPG8IqLyJfL8K7wUs3XrA9JKUpPNSlcwxMYMd1WScnbDjaUbAzfBBYQ1seMmww/0CI/Wo3waMxRIps0vOXQqQ5syFBhmKhCxhkKjPNiYaxhaDEtWfYfNJ68HI446ZAQl9m8KAtOxPvZzunMzQLYH6BJICT+ZJwH2Gi+Hq72pLNhDn7bOGdRr1IcQiL1ldhGSHhGwotVhhbU2HZBpp2doODRY8D20YIWTXu9/ePmg==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Fri, 30 Apr 2021 15:53:53 +0000
  • Ironport-hdrordr: A9a23:fEGxaqi0mfSDLtg5CfoFV0q8SnBQX11w3DAbvn1ZSRFFG/Gwv/ uF2NwGyB75jysQUnk8mdaGfJKNW2/Y6IQd2+csFJ+Ydk3DtHGzJI9vqbHjzTrpBjHk+odmup tIW5NVTOf9BV0St6rHySGlDtctx8SG+qi0heHYi0xgVx1udrsI1WdEIyywe3cGIzVuL5w/CZ aa+457vDKmY3sadYCWAXMCUujFqbTw5e3bSDQBAAMq7xTLsCOw5NfBYmSl9zo9cxcK+7ct9m DZjxf0j5/Dj9iXwgLRvlWjlqh+t8DmzrJ4damxo+gTbg7hkwO5ILlmMofyxgwdhMGKxBIUnM LXoxEmVv4DmE/5Wm2uuxPi103B/V8Vmgff4GSVi3fivsD1LQhSY6Eq6PM7A3mpnnYIh91y3L lG2GiUrfNsfG79tR/w+sTSUFVSnle0yEBS4dI7tWBVUocVddZq3Ooi1X5Sea1weB7S2cQMFe ljC9zk//BGcV+WRGCxhBgf/PWcGls0BRuIWU4Ep4i81CVXhmlwyw8iyNUYhWpozuNzd7B0o8 D/doh4nrBHScEbKYp7Gec6WMOyTkjAWwjFPm6+KUnufZt3dU7lmtrS2vEY9euqcJsHwN8Zg5 LaSm5VsmY0ZgbHFdCO9IcjyGGPfEyNGRDWju1O7Zlwvb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Bk9XVEdayKXa8Ec/Hcs5H/UAR6/ScYLqBbQUkFeDyGDsDnL+D WwwyLZ3kY+Kt+hFMXuT7RTYd5xwtJa59aH+Tmhf5QvXMls9VY3QN713GBijZ7QoLYwVGxRGHLC I2b11ZXKB6MN9u0HrAF486hMEr6As8gjhvjZZy252sobb7wFItS0purJnoWhnVQD0NX5kFgLqC +baL8mrNen7zmf9RG5TO3txNWBd/xr1F5nWZQ6Y9AD2Nibg1kPt9WI7XYe1gRo3jygJ/F0TaMU feM=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Also change libxl__cpuid_legacy to propagate the error from
xc_cpuid_apply_policy into callers.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Changes since v2:
 - Use 'r' for xc_cpuid_apply_policy return value.
 - Use LOGEVD to print error message.

Changes since v1:
 - Return ERROR_FAIL on error.
---
 tools/libs/light/libxl_cpuid.c    | 15 +++++++++++----
 tools/libs/light/libxl_create.c   |  5 +++--
 tools/libs/light/libxl_dom.c      |  2 +-
 tools/libs/light/libxl_internal.h |  4 ++--
 tools/libs/light/libxl_nocpuid.c  |  5 +++--
 5 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c
index f32c5d3a6f6..eb6feaa96d1 100644
--- a/tools/libs/light/libxl_cpuid.c
+++ b/tools/libs/light/libxl_cpuid.c
@@ -426,11 +426,13 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list 
*cpuid,
     return 0;
 }
 
-void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore,
-                         libxl_domain_build_info *info)
+int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore,
+                        libxl_domain_build_info *info)
 {
+    GC_INIT(ctx);
     bool pae = true;
     bool itsc;
+    int r;
 
     /*
      * Gross hack.  Using libxl_defbool_val() here causes libvirt to crash in
@@ -469,8 +471,13 @@ void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, 
bool restore,
     itsc = (libxl_defbool_val(info->disable_migrate) ||
             info->tsc_mode == LIBXL_TSC_MODE_ALWAYS_EMULATE);
 
-    xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0,
-                          pae, itsc, nested_virt, info->cpuid);
+    r = xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0,
+                              pae, itsc, nested_virt, info->cpuid);
+    if (r)
+        LOGEVD(ERROR, -r, domid, "Failed to apply CPUID policy");
+
+    GC_FREE;
+    return r ? ERROR_FAIL : 0;
 }
 
 static const char *input_names[2] = { "leaf", "subleaf" };
diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
index 43e9ba9c634..e356b2106d4 100644
--- a/tools/libs/light/libxl_create.c
+++ b/tools/libs/light/libxl_create.c
@@ -1434,6 +1434,7 @@ int libxl__srm_callout_callback_static_data_done(unsigned 
int missing,
 
     libxl_domain_config *d_config = dcs->guest_config;
     libxl_domain_build_info *info = &d_config->b_info;
+    int rc = 0;
 
     /*
      * CPUID/MSR information is not present in pre Xen-4.14 streams.
@@ -1443,9 +1444,9 @@ int libxl__srm_callout_callback_static_data_done(unsigned 
int missing,
      * stream doesn't contain any CPUID data.
      */
     if (missing & XGR_SDD_MISSING_CPUID)
-        libxl__cpuid_legacy(ctx, dcs->guest_domid, true, info);
+        rc = libxl__cpuid_legacy(ctx, dcs->guest_domid, true, info);
 
-    return 0;
+    return rc;
 }
 
 void libxl__srm_callout_callback_restore_results(xen_pfn_t store_mfn,
diff --git a/tools/libs/light/libxl_dom.c b/tools/libs/light/libxl_dom.c
index 842a51c86cb..e9f58ee4b2b 100644
--- a/tools/libs/light/libxl_dom.c
+++ b/tools/libs/light/libxl_dom.c
@@ -384,7 +384,7 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
      * being migrated-in/restored have CPUID handled during the
      * static_data_done() callback. */
     if (!state->restore)
-        libxl__cpuid_legacy(ctx, domid, false, info);
+        rc = libxl__cpuid_legacy(ctx, domid, false, info);
 
     return rc;
 }
diff --git a/tools/libs/light/libxl_internal.h 
b/tools/libs/light/libxl_internal.h
index c6a4a187f5b..44a2f3c8fe3 100644
--- a/tools/libs/light/libxl_internal.h
+++ b/tools/libs/light/libxl_internal.h
@@ -2052,8 +2052,8 @@ typedef yajl_gen_status 
(*libxl__gen_json_callback)(yajl_gen hand, void *);
 _hidden char *libxl__object_to_json(libxl_ctx *ctx, const char *type,
                                     libxl__gen_json_callback gen, void *p);
 
-_hidden void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool retore,
-                                 libxl_domain_build_info *info);
+_hidden int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool retore,
+                                libxl_domain_build_info *info);
 
 /* Calls poll() again - useful to check whether a signaled condition
  * is still true.  Cannot fail.  Returns currently-true revents. */
diff --git a/tools/libs/light/libxl_nocpuid.c b/tools/libs/light/libxl_nocpuid.c
index f47336565b9..0630959e760 100644
--- a/tools/libs/light/libxl_nocpuid.c
+++ b/tools/libs/light/libxl_nocpuid.c
@@ -34,9 +34,10 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list 
*cpuid,
     return 0;
 }
 
-void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore,
-                         libxl_domain_build_info *info)
+int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore,
+                        libxl_domain_build_info *info)
 {
+    return 0;
 }
 
 yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand,
-- 
2.31.1




 


Rackspace

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