From nobody Mon Feb 9 08:29:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615978683; cv=none; d=zohomail.com; s=zohoarc; b=XooK7N8gKTmNvL8MgAufCmYv11FFn/PEo374tUR9pA3L26rTk0QKaVluohVqPgnsVfqX6DIgdwravNlN+ypqIKpSq8HGTPM1ir/LwXo6gc5SKCiUlX//BOZ7vUO/NbtPMPkypHmdIfaDV/xi7jnni9m7dC5q6BYquuScn61tgsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615978683; 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=mfPZ3j7+jdS1TuPLRCO82F/S6d4h8xqC6Rrb+SrzRVc=; b=BGhFR5IXR7Ljog6fcmyXqsGnZlVmbR9D81CVuheoge1+LKUqyR5jBggad4DIc4d4zUe4IZ5dM00rjfE/DY+Of4ONB8AVwtaW7S/rEZKX/L7MGtGpPkO130AV9VWsoWwzuq0b9gjBedBQivNy35lLntrTwyh4LeY8MVuh150k6lA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1615978683611389.4788483037511; Wed, 17 Mar 2021 03:58:03 -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-36-ETDTGa31MaOrzSoX_fXZEQ-1; Wed, 17 Mar 2021 06:57:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 69EC4108BD0B; Wed, 17 Mar 2021 10:57:51 +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 43A4D50FAF; Wed, 17 Mar 2021 10:57:51 +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 07B854A7CB; Wed, 17 Mar 2021 10:57:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12HAvgh2021608 for ; Wed, 17 Mar 2021 06:57:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 76FEDE56A8; Wed, 17 Mar 2021 10:57:42 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7147FE56A7 for ; Wed, 17 Mar 2021 10:57:42 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 59D4F101A531 for ; Wed, 17 Mar 2021 10:57:42 +0000 (UTC) Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [85.215.255.53]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-47Er0IbFN7WyDEReDuDdNA-1; Wed, 17 Mar 2021 06:57:39 -0400 Received: from sender by smtp.strato.de (RZmta 47.21.0 SBL|AUTH) with ESMTPSA id k0a44fx2HAvb10O (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)) (Client did not present a certificate); Wed, 17 Mar 2021 11:57:37 +0100 (CET) X-MC-Unique: ETDTGa31MaOrzSoX_fXZEQ-1 X-MC-Unique: 47Er0IbFN7WyDEReDuDdNA-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 07/12] libxl: add API wrapper for libxl_domain_need_memory Date: Wed, 17 Mar 2021 11:57:23 +0100 Message-Id: <20210317105728.3745-8-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.79 on 10.11.54.5 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.11 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_domain_need_memory, which changed the storage size of "need_memkb" in Xen 4.8. With Xen 4.12 the libxl_domain_config parameter was changed No functional change intended. Signed-off-by: Olaf Hering --- src/libxl/libxl_api.h | 24 ++++++++++++++++++++++++ src/libxl/libxl_domain.c | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/libxl/libxl_api.h b/src/libxl/libxl_api.h index 86d2d64b37..5c1545c3c0 100644 --- a/src/libxl/libxl_api.h +++ b/src/libxl/libxl_api.h @@ -114,3 +114,27 @@ Libxl_Domain_Unpause(libxl_ctx *ctx, uint32_t domid) =20 return ret; } + +#define INVALID_DOMID ~0 +static inline int +Libxl_Domain_Need_Memory(libxl_ctx *ctx, + libxl_domain_config *d_config, + uint64_t *need_memkb) +{ + int ret; + +#if LIBXL_API_VERSION < 0x040800 + { + uint32_t val32 =3D 0; + + ret =3D libxl_domain_need_memory(ctx, &d_config->b_info, &val32); + *need_memkb =3D val32; + } +#elif LIBXL_API_VERSION < 0x041300 + ret =3D libxl_domain_need_memory(ctx, &d_config->b_info, need_memkb); +#else + ret =3D libxl_domain_need_memory(ctx, d_config, INVALID_DOMID, need_me= mkb); +#endif + + return ret; +} diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 6eca7027eb..337764b5c7 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1008,13 +1008,13 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr = driver, virDomainObjPtr vm) static int libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config) { - uint32_t needed_mem; + uint64_t needed_mem; uint32_t free_mem; int32_t target_mem; int tries =3D 3; int wait_secs =3D 10; =20 - if (libxl_domain_need_memory(ctx, &d_config->b_info, &needed_mem) < 0) + if (Libxl_Domain_Need_Memory(ctx, d_config, &needed_mem) < 0) goto error; =20 do {