From nobody Tue Feb 10 13:34:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1536742678263879.8372697885764; Wed, 12 Sep 2018 01:57:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F0F183001933; Wed, 12 Sep 2018 08:57:55 +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 AA9062007828; Wed, 12 Sep 2018 08:57:55 +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 44ADF4A46D; Wed, 12 Sep 2018 08:57:55 +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 w8C8vit0018831 for ; Wed, 12 Sep 2018 04:57:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 334B010075D3; Wed, 12 Sep 2018 08:57:44 +0000 (UTC) Received: from dahmer.brq.redhat.com (unknown [10.43.2.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6D3010CD78C; Wed, 12 Sep 2018 08:57:43 +0000 (UTC) From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Wed, 12 Sep 2018 10:57:34 +0200 Message-Id: <20180912085736.27456-3-fidencio@redhat.com> In-Reply-To: <20180912085736.27456-1-fidencio@redhat.com> References: <20180912085736.27456-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [libvirt PATCH v2 2/4] domain_conf: split out virDomainMemtune and virDomainHugePage definitions 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 12 Sep 2018 08:57:56 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Let's move those to their own newly created header (src/util/virmem.h) as this will help us to easily start sharing the cgroup code that's duplicated between QEMU and LXC. Signed-off-by: Fabiano Fid=C3=AAncio --- src/conf/domain_conf.c | 11 +++---- src/conf/domain_conf.h | 43 ++------------------------- src/qemu/qemu_command.c | 4 +-- src/util/virmem.h | 66 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 48 deletions(-) create mode 100644 src/util/virmem.h diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6ce50f712a..bd22ce6e7d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -60,6 +60,7 @@ #include "virhostdev.h" #include "virmdev.h" #include "virblkio.h" +#include "virmem.h" =20 #define VIR_FROM_THIS VIR_FROM_DOMAIN =20 @@ -6166,7 +6167,7 @@ virDomainDefLifecycleActionValidate(const virDomainDe= f *def) static int virDomainDefMemtuneValidate(const virDomainDef *def) { - const virDomainMemtune *mem =3D &(def->mem); + const virMemTune *mem =3D &(def->mem); size_t i; ssize_t pos =3D virDomainNumaGetNodeCount(def->numa) - 1; =20 @@ -18197,7 +18198,7 @@ virDomainDefMaybeAddInput(virDomainDefPtr def, static int virDomainHugepagesParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt, - virDomainHugePagePtr hugepage) + virMemHugePagePtr hugepage) { int ret =3D -1; xmlNodePtr oldnode =3D ctxt->node; @@ -26841,7 +26842,7 @@ virDomainResourceDefFormat(virBufferPtr buf, =20 static int virDomainHugepagesFormatBuf(virBufferPtr buf, - virDomainHugePagePtr hugepage) + virMemHugePagePtr hugepage) { int ret =3D -1; =20 @@ -26865,7 +26866,7 @@ virDomainHugepagesFormatBuf(virBufferPtr buf, =20 static void virDomainHugepagesFormat(virBufferPtr buf, - virDomainHugePagePtr hugepages, + virMemHugePagePtr hugepages, size_t nhugepages) { size_t i; @@ -27403,7 +27404,7 @@ virDomainIOMMUDefFormat(virBufferPtr buf, =20 static int virDomainMemtuneFormat(virBufferPtr buf, - const virDomainMemtune *mem) + const virMemTune *mem) { virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; int ret =3D -1; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e9e6b6d6c4..10acc39861 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -58,6 +58,7 @@ # include "virsavecookie.h" # include "virresctrl.h" # include "virblkio.h" +# include "virmem.h" =20 /* forward declarations of all device types, required by * virDomainDeviceDef @@ -2180,14 +2181,6 @@ struct _virDomainResourceDef { char *partition; }; =20 -typedef struct _virDomainHugePage virDomainHugePage; -typedef virDomainHugePage *virDomainHugePagePtr; - -struct _virDomainHugePage { - virBitmapPtr nodemask; /* guest's NUMA node mask */ - unsigned long long size; /* hugepage size in KiB */ -}; - # define VIR_DOMAIN_CPUMASK_LEN 1024 =20 typedef struct _virDomainIOThreadIDDef virDomainIOThreadIDDef; @@ -2247,38 +2240,6 @@ struct _virDomainVcpuDef { virObjectPtr privateData; }; =20 -typedef struct _virDomainMemtune virDomainMemtune; -typedef virDomainMemtune *virDomainMemtunePtr; - -struct _virDomainMemtune { - /* total memory size including memory modules in kibibytes, this field - * should be accessed only via accessors */ - unsigned long long total_memory; - unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks - to virDomainGetInfo */ - - virDomainHugePagePtr hugepages; - size_t nhugepages; - - /* maximum supported memory for a guest, for hotplugging */ - unsigned long long max_memory; /* in kibibytes */ - unsigned int memory_slots; /* maximum count of RAM memory slots */ - - bool nosharepages; - bool locked; - int dump_core; /* enum virTristateSwitch */ - unsigned long long hard_limit; /* in kibibytes, limit at off_t bytes */ - unsigned long long soft_limit; /* in kibibytes, limit at off_t bytes */ - unsigned long long min_guarantee; /* in kibibytes, limit at off_t byte= s */ - unsigned long long swap_hard_limit; /* in kibibytes, limit at off_t by= tes */ - - int source; /* enum virDomainMemorySource */ - int access; /* enum virDomainMemoryAccess */ - int allocation; /* enum virDomainMemoryAllocation */ - - virTristateBool discard; -}; - typedef struct _virDomainPowerManagement virDomainPowerManagement; typedef virDomainPowerManagement *virDomainPowerManagementPtr; =20 @@ -2380,7 +2341,7 @@ struct _virDomainDef { char *description; =20 virBlkioTune blkio; - virDomainMemtune mem; + virMemTune mem; =20 virDomainVcpuDefPtr *vcpus; size_t maxvcpus; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ff9589f593..3511505389 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3202,8 +3202,8 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendP= rops, mode =3D VIR_DOMAIN_NUMATUNE_MEM_STRICT; =20 if (pagesize =3D=3D 0) { - virDomainHugePagePtr master_hugepage =3D NULL; - virDomainHugePagePtr hugepage =3D NULL; + virMemHugePagePtr master_hugepage =3D NULL; + virMemHugePagePtr hugepage =3D NULL; bool thisHugepage =3D false; =20 /* Find the huge page size we want to use */ diff --git a/src/util/virmem.h b/src/util/virmem.h new file mode 100644 index 0000000000..8f73218ac8 --- /dev/null +++ b/src/util/virmem.h @@ -0,0 +1,66 @@ +/* + * virmem.h: Memory definitions and helpers + * + * Copyright (C) 2018 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * Author: Fabiano Fid=C3=AAncio + */ + +#ifndef __VIR_MEM_H__ +# define __VIR_MEM_H__ + +#include "virutil.h" + +typedef struct _virMemHugePage virMemHugePage; +typedef virMemHugePage *virMemHugePagePtr; +struct _virMemHugePage { + virBitmapPtr nodemask; /* guest's NUMA node mask */ + unsigned long long size; /* hugepage size in KiB */ +}; + +typedef struct _virMemTune virMemTune; +typedef virMemTune *virMemTunePtr; +struct _virMemTune { + /* total memory size including memory modules in kibibytes, this field + * should be accessed only via accessors */ + unsigned long long total_memory; + unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks + to virDomainGetInfo */ + + virMemHugePagePtr hugepages; + size_t nhugepages; + + /* maximum supported memory for a guest, for hotplugging */ + unsigned long long max_memory; /* in kibibytes */ + unsigned int memory_slots; /* maximum count of RAM memory slots */ + + bool nosharepages; + bool locked; + int dump_core; /* enum virTristateSwitch */ + unsigned long long hard_limit; /* in kibibytes, limit at off_t bytes */ + unsigned long long soft_limit; /* in kibibytes, limit at off_t bytes */ + unsigned long long min_guarantee; /* in kibibytes, limit at off_t byte= s */ + unsigned long long swap_hard_limit; /* in kibibytes, limit at off_t by= tes */ + + int source; /* enum virDomainMemorySource */ + int access; /* enum virDomainMemoryAccess */ + int allocation; /* enum virDomainMemoryAllocation */ + + virTristateBool discard; +}; + +#endif /* __VIR_MEM_H__ */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list