[PATCH 2/4] tools/libxc: Delete ENOSYS squashing in xc_domain_claim_pages()

Andrew Cooper posted 4 patches 1 day, 15 hours ago
[PATCH 2/4] tools/libxc: Delete ENOSYS squashing in xc_domain_claim_pages()
Posted by Andrew Cooper 1 day, 15 hours ago
It's not acceptable to hide this from the caller; the effect of doing so is to
break an atomicity expectation.

Only the caller can know what the appropriate safety action is in the case
that the claim hypercall isn't available.

Fixes: fc67e9dc0c1f ("xc: use XENMEM_claim_pages hypercall during guest creation.")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
---
 tools/libs/ctrl/xc_domain.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/tools/libs/ctrl/xc_domain.c b/tools/libs/ctrl/xc_domain.c
index 2ddc3f4f426d..01c0669c8863 100644
--- a/tools/libs/ctrl/xc_domain.c
+++ b/tools/libs/ctrl/xc_domain.c
@@ -1074,7 +1074,6 @@ int xc_domain_claim_pages(xc_interface *xch,
                                uint32_t domid,
                                unsigned long nr_pages)
 {
-    int err;
     struct xen_memory_reservation reservation = {
         .nr_extents   = nr_pages,
         .extent_order = 0,
@@ -1082,13 +1081,7 @@ int xc_domain_claim_pages(xc_interface *xch,
         .domid        = domid
     };
 
-    set_xen_guest_handle(reservation.extent_start, HYPERCALL_BUFFER_NULL);
-
-    err = xc_memory_op(xch, XENMEM_claim_pages, &reservation, sizeof(reservation));
-    /* Ignore it if the hypervisor does not support the call. */
-    if (err == -1 && errno == ENOSYS)
-        err = errno = 0;
-    return err;
+    return xc_memory_op(xch, XENMEM_claim_pages, &reservation, sizeof(reservation));
 }
 
 int xc_domain_populate_physmap(xc_interface *xch,
-- 
2.39.5


Re: [PATCH 2/4] tools/libxc: Delete ENOSYS squashing in xc_domain_claim_pages()
Posted by Roger Pau Monné 15 hours ago
On Tue, Dec 16, 2025 at 04:32:28PM +0000, Andrew Cooper wrote:
> It's not acceptable to hide this from the caller; the effect of doing so is to
> break an atomicity expectation.
> 
> Only the caller can know what the appropriate safety action is in the case
> that the claim hypercall isn't available.
> 
> Fixes: fc67e9dc0c1f ("xc: use XENMEM_claim_pages hypercall during guest creation.")
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks, Roger.