From nobody Mon Feb 9 02:13:06 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=1615978674; cv=none; d=zohomail.com; s=zohoarc; b=j09vJ6GV7BRxsaZfqcx+UAn6DqlB6lmc0ayCGVf/x4DfYLmY6sHTzRTC8qac1FW2z7gTkMEueWvZZ4OQ8QOg2qVMucN4HG879JHsayyYTJBQXZzY2FsvN+hrQkZMYWO2prTWuEgbgndkfYFM/uSh8COMXQH4462SzoIHFkgr6TQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615978674; 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=suNyHaiFtA+2n3hE+93XCUJ1qic80FICH4K10lFCVpk=; b=Iu/5uRpuNxpywvTqrl6d25HVIXiqzV6kmzuQsRc7EytC4gU+v9TiH6SiCS5f3G81WRP9RlUt5a3wZHzXqltrtId94UDqjJXEvl08ddlSJOnjiCzZplbBMXEIHnAp4hv6l5rFhYHNn2xPiO3CVP54LUeVfz5n3gkWYvTb69m9w3U= 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 1615978674297853.8922719563222; Wed, 17 Mar 2021 03:57:54 -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-215--7CDqRhAOuOxv33E1aUIeQ-1; Wed, 17 Mar 2021 06:57:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5C0FA81621; Wed, 17 Mar 2021 10:57:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 307A05D9C0; Wed, 17 Mar 2021 10:57:45 +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 14C821809C84; Wed, 17 Mar 2021 10:57:44 +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 12HAvgWr021609 for ; Wed, 17 Mar 2021 06:57:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8DCDAE2030; Wed, 17 Mar 2021 10:57:42 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 88BD0E56A7 for ; Wed, 17 Mar 2021 10:57:42 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7203280B91F 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-280-SKK6fe0ZPhOPSS9Ji8k6Kg-1; Wed, 17 Mar 2021 06:57:40 -0400 Received: from sender by smtp.strato.de (RZmta 47.21.0 SBL|AUTH) with ESMTPSA id k0a44fx2HAvb10Q (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: -7CDqRhAOuOxv33E1aUIeQ-1 X-MC-Unique: SKK6fe0ZPhOPSS9Ji8k6Kg-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 08/12] libxl: add API wrapper for libxl_get_free_memory Date: Wed, 17 Mar 2021 11:57:24 +0100 Message-Id: <20210317105728.3745-9-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.14 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_get_free_memory, which changed storage size of parameter "memkb" in Xen 4.8. No functional change intended. Signed-off-by: Olaf Hering --- src/libxl/libxl_api.h | 19 +++++++++++++++++++ src/libxl/libxl_conf.c | 5 +++-- src/libxl/libxl_domain.c | 4 ++-- tests/libxlmock.c | 7 ++++++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/libxl/libxl_api.h b/src/libxl/libxl_api.h index 5c1545c3c0..1c13781ae6 100644 --- a/src/libxl/libxl_api.h +++ b/src/libxl/libxl_api.h @@ -138,3 +138,22 @@ Libxl_Domain_Need_Memory(libxl_ctx *ctx, =20 return ret; } + +static inline int +Libxl_Get_Free_Memory(libxl_ctx *ctx, uint64_t *memkb) +{ + int ret; + +#if LIBXL_API_VERSION < 0x040800 + { + uint32_t val32 =3D 0; + + ret =3D libxl_get_free_memory(ctx, &val32); + *memkb =3D val32; + } +#else + ret =3D libxl_get_free_memory(ctx, memkb); +#endif + + return ret; +} diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 4b6a7e6096..74551ff804 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -36,6 +36,7 @@ #include "viruuid.h" #include "vircommand.h" #include "virsocketaddr.h" +#include "libxl_api.h" #include "libxl_domain.h" #include "libxl_conf.h" #include "libxl_utils.h" @@ -1785,7 +1786,7 @@ libxlDriverConfigNew(void) int libxlDriverConfigInit(libxlDriverConfigPtr cfg) { - unsigned int free_mem; + uint64_t free_mem; =20 if (g_mkdir_with_parents(cfg->logDir, 0777) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1817,7 +1818,7 @@ libxlDriverConfigInit(libxlDriverConfigPtr cfg) =20 /* This will fill xenstore info about free and dom0 memory if missing, * should be called before starting first domain */ - if (libxl_get_free_memory(cfg->ctx, &free_mem)) { + if (Libxl_Get_Free_Memory(cfg->ctx, &free_mem)) { VIR_ERROR(_("Unable to configure libxl's memory management paramet= ers")); return -1; } diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 337764b5c7..264a730c6c 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1009,7 +1009,7 @@ static int libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config) { uint64_t needed_mem; - uint32_t free_mem; + uint64_t free_mem; int32_t target_mem; int tries =3D 3; int wait_secs =3D 10; @@ -1018,7 +1018,7 @@ libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_confi= g *d_config) goto error; =20 do { - if (libxl_get_free_memory(ctx, &free_mem) < 0) + if (Libxl_Get_Free_Memory(ctx, &free_mem) < 0) goto error; =20 if (free_mem >=3D needed_mem) diff --git a/tests/libxlmock.c b/tests/libxlmock.c index a36ca135f6..7a43f9196b 100644 --- a/tests/libxlmock.c +++ b/tests/libxlmock.c @@ -67,7 +67,12 @@ VIR_MOCK_IMPL_RET_ARGS(libxl_get_version_info, VIR_MOCK_STUB_RET_ARGS(libxl_get_free_memory, int, 0, libxl_ctx *, ctx, - uint32_t *, memkb); +#if LIBXL_API_VERSION < 0x040800 + uint32_t *, +#else + uint64_t *, +#endif + memkb); =20 VIR_MOCK_STUB_RET_ARGS(xc_interface_close, int, 0,