From nobody Mon Feb 9 03:12:14 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615978858; cv=none; d=zohomail.com; s=zohoarc; b=fyYkMUAgbGDHjgPf6GFWD6GEQ4XqlGA6MAYiNBvv0m3jWee7JUKcv0VGAZ60We/2JluRQwR5ZEcGugF2MdXDEXo/4OKw7hYkhi775gYerCyj95cx8y4dlQCAli/iSgRmgBOmWhs4oNh5BhFXS622J2TwcnbUvYV4mXUlU9AJW9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615978858; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nfWv/vXSo+tTsn4zgTUHOnrXHiZRHjpRCWkbjlhn7Jg=; b=B3p+R35nZ9n+TxEqTtWjfD4MUJKr9OeQdh5zhqDg5tlzCZgQVUGfzh0gjwte3fJQGjUiCuVltZ4qA6MkRfy0kOS8ijMUwDfiCan2RFOeeatW2XHoqhuOWO2eMsjBjAIMefoV38x5IdTe3C45YNfVDxf1J75+VWspro2xZO8f8I8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1615978858123788.3656316262992; Wed, 17 Mar 2021 04:00:58 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-uQacFHo0NzyyGvnMv36H5Q-1; Wed, 17 Mar 2021 07:00:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 71E7A801817; Wed, 17 Mar 2021 11:00:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 456B863BB8; Wed, 17 Mar 2021 11:00:46 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9DB414BB7C; Wed, 17 Mar 2021 11:00:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12HB0gYW022224 for ; Wed, 17 Mar 2021 07:00:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id E521310151F0; Wed, 17 Mar 2021 11:00:41 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E030010F8E3A for ; Wed, 17 Mar 2021 11:00:38 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B3431811E9B for ; Wed, 17 Mar 2021 11:00:38 +0000 (UTC) Received: from mo4-p02-ob.smtp.rzone.de (mo4-p02-ob.smtp.rzone.de [85.215.255.83]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-348-D_ndsmFHN-SEQAfd1qULAA-1; Wed, 17 Mar 2021 07:00:35 -0400 Received: from sender by smtp.strato.de (RZmta 47.21.0 SBL|AUTH) with ESMTPSA id k0a44fx2HAvc10T (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)) (Client did not present a certificate); Wed, 17 Mar 2021 11:57:38 +0100 (CET) X-MC-Unique: uQacFHo0NzyyGvnMv36H5Q-1 X-MC-Unique: D_ndsmFHN-SEQAfd1qULAA-1 X-RZG-AUTH: ":P2EQZWCpfu+qG7CngxMFH1J+3q8wa/QXkBR9MXjAuzBW/OdlBZQ4AHSS325Pjw==" X-RZG-CLASS-ID: mo00 From: Olaf Hering To: libvir-list@redhat.com Subject: [PATCH v1 11/12] libxl: add API wrapper for libxl_set_memory_target Date: Wed, 17 Mar 2021 11:57:27 +0100 Message-Id: <20210317105728.3745-12-olaf@aepfle.de> In-Reply-To: <20210317105728.3745-1-olaf@aepfle.de> References: <20210317105728.3745-1-olaf@aepfle.de> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Olaf Hering X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Upcoming changes will use different LIBXL_API_VERSION variants. Prepare libxl_set_memory_target, which changed the storage size of parameter "target_memkb" in Xen 4.8. No functional change intended. Signed-off-by: Olaf Hering --- src/libxl/libxl_api.h | 29 +++++++++++++++++++++++++++++ src/libxl/libxl_domain.c | 4 ++-- src/libxl/libxl_driver.c | 2 +- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/libxl/libxl_api.h b/src/libxl/libxl_api.h index c7174f5133..1507dbd38e 100644 --- a/src/libxl/libxl_api.h +++ b/src/libxl/libxl_api.h @@ -20,6 +20,7 @@ =20 #pragma once =20 +#include #include =20 static inline int @@ -188,3 +189,31 @@ Libxl_Send_Trigger(libxl_ctx *ctx, =20 return ret; } + +static inline int +Libxl_Set_Memory_Target(libxl_ctx *ctx, + uint32_t domid, + uint64_t target_memkb, + int relative, + int enforce) +{ + int ret =3D -1; + + /* Technically this guard could be LIBXL_HAVE_MEMKB_64BITS */ +#if LIBXL_API_VERSION < 0x040800 + if (target_memkb < UINT_MAX) + { + uint32_t val32 =3D target_memkb; + + ret =3D libxl_set_memory_target(ctx, domid, val32, relative, enfor= ce); + } +#else + if (target_memkb < LLONG_MAX) + { + int64_t val64 =3D target_memkb; + ret =3D libxl_set_memory_target(ctx, domid, val64, relative, enfor= ce); + } +#endif + + return ret; +} diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 264a730c6c..0b0c3865fa 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1010,7 +1010,7 @@ libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_confi= g *d_config) { uint64_t needed_mem; uint64_t free_mem; - int32_t target_mem; + uint64_t target_mem; int tries =3D 3; int wait_secs =3D 10; =20 @@ -1025,7 +1025,7 @@ libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_confi= g *d_config) return 0; =20 target_mem =3D free_mem - needed_mem; - if (libxl_set_memory_target(ctx, 0, target_mem, + if (Libxl_Set_Memory_Target(ctx, 0, target_mem, /* relative */ 1, 0) < 0) goto error; =20 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index cf3a2d9775..97aed9949d 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1695,7 +1695,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned = long newmem, =20 /* Unlock virDomainObj while ballooning memory */ virObjectUnlock(vm); - res =3D libxl_set_memory_target(cfg->ctx, vm->def->id, newmem,= 0, + res =3D Libxl_Set_Memory_Target(cfg->ctx, vm->def->id, newmem,= 0, /* force */ 1); virObjectLock(vm); if (res < 0) {