From nobody Sun Apr 28 19:11:21 2024 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 1536824930717921.3009622491163; Thu, 13 Sep 2018 00:48:50 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 31C7F3082B56; Thu, 13 Sep 2018 07:48:48 +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 B00405D6AA; Thu, 13 Sep 2018 07:48: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 9618218005DF; Thu, 13 Sep 2018 07:48:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8D7mOAl027153 for ; Thu, 13 Sep 2018 03:48:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1529A9A311; Thu, 13 Sep 2018 07:48:24 +0000 (UTC) Received: from dahmer.redhat.com (ovpn-204-17.brq.redhat.com [10.40.204.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E1D69A324; Thu, 13 Sep 2018 07:48:23 +0000 (UTC) From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Thu, 13 Sep 2018 09:48:11 +0200 Message-Id: <20180913074814.9697-2-fidencio@redhat.com> In-Reply-To: <20180913074814.9697-1-fidencio@redhat.com> References: <20180913074814.9697-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [libvirt PATCH v3 1/4] domain_conf: split out virBlkioDevice and virDomainBlkiotune 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.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 13 Sep 2018 07:48:48 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Let's move those to their own newly created files (src/util/virblkio.{c,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 | 27 ++------------------- src/libvirt_private.syms | 5 +++- src/util/Makefile.inc.am | 2 ++ src/util/virblkio.c | 37 ++++++++++++++++++++++++++++ src/util/virblkio.h | 52 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 98 insertions(+), 36 deletions(-) create mode 100644 src/util/virblkio.c create mode 100644 src/util/virblkio.h diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 409a2291ff..3384a36d76 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -59,6 +59,7 @@ #include "virnetdevmacvlan.h" #include "virhostdev.h" #include "virmdev.h" +#include "virblkio.h" =20 #define VIR_FROM_THIS VIR_FROM_DOMAIN =20 @@ -1205,16 +1206,6 @@ virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPt= r xmlopt) } =20 =20 -void -virBlkioDeviceArrayClear(virBlkioDevicePtr devices, - int ndevices) -{ - size_t i; - - for (i =3D 0; i < ndevices; i++) - VIR_FREE(devices[i].path); -} - /** * virDomainBlkioDeviceParseXML * diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e30a4b2fe7..e9e6b6d6c4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -57,6 +57,7 @@ # include "virtypedparam.h" # include "virsavecookie.h" # include "virresctrl.h" +# include "virblkio.h" =20 /* forward declarations of all device types, required by * virDomainDeviceDef @@ -2084,17 +2085,6 @@ struct _virDomainClockDef { }; =20 =20 -typedef struct _virBlkioDevice virBlkioDevice; -typedef virBlkioDevice *virBlkioDevicePtr; -struct _virBlkioDevice { - char *path; - unsigned int weight; - unsigned int riops; - unsigned int wiops; - unsigned long long rbps; - unsigned long long wbps; -}; - typedef enum { VIR_DOMAIN_RNG_MODEL_VIRTIO, =20 @@ -2184,9 +2174,6 @@ struct _virDomainPanicDef { }; =20 =20 -void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights, - int ndevices); - typedef struct _virDomainResourceDef virDomainResourceDef; typedef virDomainResourceDef *virDomainResourceDefPtr; struct _virDomainResourceDef { @@ -2260,16 +2247,6 @@ struct _virDomainVcpuDef { virObjectPtr privateData; }; =20 -typedef struct _virDomainBlkiotune virDomainBlkiotune; -typedef virDomainBlkiotune *virDomainBlkiotunePtr; - -struct _virDomainBlkiotune { - unsigned int weight; - - size_t ndevices; - virBlkioDevicePtr devices; -}; - typedef struct _virDomainMemtune virDomainMemtune; typedef virDomainMemtune *virDomainMemtunePtr; =20 @@ -2402,7 +2379,7 @@ struct _virDomainDef { char *title; char *description; =20 - virDomainBlkiotune blkio; + virBlkioTune blkio; virDomainMemtune mem; =20 virDomainVcpuDefPtr *vcpus; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a0d229a79f..bf1536ea57 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -190,7 +190,6 @@ virSEVCapabilitiesFree; =20 =20 # conf/domain_conf.h -virBlkioDeviceArrayClear; virDiskNameParse; virDiskNameToBusDeviceIndex; virDiskNameToIndex; @@ -1471,6 +1470,10 @@ virBitmapToDataBuf; virBitmapToString; =20 =20 +# util/virblkio.h +virBlkioDeviceArrayClear; + + # util/virbuffer.h virBufferAdd; virBufferAddBuffer; diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am index a22265606c..13f415b23c 100644 --- a/src/util/Makefile.inc.am +++ b/src/util/Makefile.inc.am @@ -17,6 +17,8 @@ UTIL_SOURCES =3D \ util/virauthconfig.h \ util/virbitmap.c \ util/virbitmap.h \ + util/virblkio.c \ + util/virblkio.h \ util/virbuffer.c \ util/virbuffer.h \ util/virperf.c \ diff --git a/src/util/virblkio.c b/src/util/virblkio.c new file mode 100644 index 0000000000..9711077ee8 --- /dev/null +++ b/src/util/virblkio.c @@ -0,0 +1,37 @@ +/* + * virblkio.c: Block IO 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 + * . + * + * Authors: + * Fabiano Fid=C3=AAncio + */ + +#include + +#include "viralloc.h" +#include "virblkio.h" + +void +virBlkioDeviceArrayClear(virBlkioDevicePtr devices, + int ndevices) +{ + size_t i; + + for (i =3D 0; i < ndevices; i++) + VIR_FREE(devices[i].path); +} diff --git a/src/util/virblkio.h b/src/util/virblkio.h new file mode 100644 index 0000000000..aa9788636d --- /dev/null +++ b/src/util/virblkio.h @@ -0,0 +1,52 @@ +/* + * virblkio.h: Block IO 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_BLKIO_H__ +# define __VIR_BLKIO_H__ + +# include "virutil.h" + +typedef struct _virBlkioDevice virBlkioDevice; +typedef virBlkioDevice *virBlkioDevicePtr; +struct _virBlkioDevice { + char *path; + unsigned int weight; + unsigned int riops; + unsigned int wiops; + unsigned long long rbps; + unsigned long long wbps; +}; + + +typedef struct _virBlkioTune virBlkioTune; +typedef virBlkioTune *virBlkioTunePtr; +struct _virBlkioTune { + unsigned int weight; + + size_t ndevices; + virBlkioDevicePtr devices; +}; + +void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights, + int ndevices); + +#endif /* __VIR_BLKIO_H__ */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 19:11:21 2024 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 1536824955435880.8951550113525; Thu, 13 Sep 2018 00:49:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E5B93082E08; Thu, 13 Sep 2018 07:49:13 +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 92CAF10021B1; Thu, 13 Sep 2018 07:49:12 +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 3CD574A460; Thu, 13 Sep 2018 07:49:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8D7mPNr027161 for ; Thu, 13 Sep 2018 03:48:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3DF819A313; Thu, 13 Sep 2018 07:48:25 +0000 (UTC) Received: from dahmer.redhat.com (ovpn-204-17.brq.redhat.com [10.40.204.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D1B49A311; Thu, 13 Sep 2018 07:48:24 +0000 (UTC) From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Thu, 13 Sep 2018 09:48:12 +0200 Message-Id: <20180913074814.9697-3-fidencio@redhat.com> In-Reply-To: <20180913074814.9697-1-fidencio@redhat.com> References: <20180913074814.9697-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [libvirt PATCH v3 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 13 Sep 2018 07:49:14 +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 | 5 ++-- src/qemu/qemu_domain.c | 3 +- src/util/virmem.h | 66 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 49 deletions(-) create mode 100644 src/util/virmem.h diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3384a36d76..78db2a6c2c 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 @@ -6174,7 +6175,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 @@ -18188,7 +18189,7 @@ virDomainDefMaybeAddInput(virDomainDefPtr def, static int virDomainHugepagesParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt, - virDomainHugePagePtr hugepage) + virMemHugePagePtr hugepage) { int ret =3D -1; xmlNodePtr oldnode =3D ctxt->node; @@ -26832,7 +26833,7 @@ virDomainResourceDefFormat(virBufferPtr buf, =20 static int virDomainHugepagesFormatBuf(virBufferPtr buf, - virDomainHugePagePtr hugepage) + virMemHugePagePtr hugepage) { int ret =3D -1; =20 @@ -26856,7 +26857,7 @@ virDomainHugepagesFormatBuf(virBufferPtr buf, =20 static void virDomainHugepagesFormat(virBufferPtr buf, - virDomainHugePagePtr hugepages, + virMemHugePagePtr hugepages, size_t nhugepages) { size_t i; @@ -27394,7 +27395,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 0a353f87ba..968234b82a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -60,6 +60,7 @@ #include "virnuma.h" #include "virgic.h" #include "virmdev.h" +#include "virmem.h" #if defined(__linux__) # include #endif @@ -3202,8 +3203,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/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e12f05f9d1..661d78f77e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -54,6 +54,7 @@ #include "vircrypto.h" #include "virrandom.h" #include "virsystemd.h" +#include "virmem.h" #include "secret_util.h" #include "logging/log_manager.h" #include "locking/domain_lock.h" @@ -3953,7 +3954,7 @@ static int qemuDomainDefValidateMemory(const virDomainDef *def) { const long system_page_size =3D virGetSystemPageSizeKB(); - const virDomainMemtune *mem =3D &def->mem; + const virMemTune *mem =3D &def->mem; =20 if (mem->nhugepages =3D=3D 0) return 0; diff --git a/src/util/virmem.h b/src/util/virmem.h new file mode 100644 index 0000000000..1cd077f04b --- /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 From nobody Sun Apr 28 19:11:21 2024 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 1536824954566427.5256219360334; Thu, 13 Sep 2018 00:49:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 782E88CDD; Thu, 13 Sep 2018 07:49:12 +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 35B6D9A325; Thu, 13 Sep 2018 07:49:12 +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 D3F644BB75; Thu, 13 Sep 2018 07:49:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8D7mQTw027171 for ; Thu, 13 Sep 2018 03:48:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id A4B3F9A311; Thu, 13 Sep 2018 07:48:26 +0000 (UTC) Received: from dahmer.redhat.com (ovpn-204-17.brq.redhat.com [10.40.204.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id A09609A324; Thu, 13 Sep 2018 07:48:25 +0000 (UTC) From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Thu, 13 Sep 2018 09:48:13 +0200 Message-Id: <20180913074814.9697-4-fidencio@redhat.com> In-Reply-To: <20180913074814.9697-1-fidencio@redhat.com> References: <20180913074814.9697-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [libvirt PATCH v3 3/4] vircgroup: Add virCgroupSetupBlkioTune() 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.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 13 Sep 2018 07:49:13 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 virCgroupSetupBlkioTune() has been introduced in order to remove the code duplication present between virLXCCgroupSetupBlkioTune() and qemuSetupBlkioCgroup(). Signed-off-by: Fabiano Fid=C3=AAncio --- src/libvirt_private.syms | 1 + src/lxc/lxc_cgroup.c | 49 +----------------------------------- src/qemu/qemu_cgroup.c | 47 +--------------------------------- src/util/vircgroup.c | 54 ++++++++++++++++++++++++++++++++++++++++ src/util/vircgroup.h | 3 +++ 5 files changed, 60 insertions(+), 94 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bf1536ea57..5df48f88f4 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1579,6 +1579,7 @@ virCgroupSetMemoryHardLimit; virCgroupSetMemorySoftLimit; virCgroupSetMemSwapHardLimit; virCgroupSetOwner; +virCgroupSetupBlkioTune; virCgroupSupportsCpuBW; virCgroupTerminateMachine; =20 diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index d93a19d684..4a95f2a8b0 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -106,54 +106,7 @@ static int virLXCCgroupSetupCpusetTune(virDomainDefPtr= def, static int virLXCCgroupSetupBlkioTune(virDomainDefPtr def, virCgroupPtr cgroup) { - size_t i; - - if (def->blkio.weight && - virCgroupSetBlkioWeight(cgroup, def->blkio.weight) < 0) - return -1; - - if (def->blkio.ndevices) { - for (i =3D 0; i < def->blkio.ndevices; i++) { - virBlkioDevicePtr dev =3D &def->blkio.devices[i]; - - if (dev->weight && - (virCgroupSetBlkioDeviceWeight(cgroup, dev->path, - dev->weight) < 0 || - virCgroupGetBlkioDeviceWeight(cgroup, dev->path, - &dev->weight) < 0)) - return -1; - - if (dev->riops && - (virCgroupSetBlkioDeviceReadIops(cgroup, dev->path, - dev->riops) < 0 || - virCgroupGetBlkioDeviceReadIops(cgroup, dev->path, - &dev->riops) < 0)) - return -1; - - if (dev->wiops && - (virCgroupSetBlkioDeviceWriteIops(cgroup, dev->path, - dev->wiops) < 0 || - virCgroupGetBlkioDeviceWriteIops(cgroup, dev->path, - &dev->wiops) < 0)) - return -1; - - if (dev->rbps && - (virCgroupSetBlkioDeviceReadBps(cgroup, dev->path, - dev->rbps) < 0 || - virCgroupGetBlkioDeviceReadBps(cgroup, dev->path, - &dev->rbps) < 0)) - return -1; - - if (dev->wbps && - (virCgroupSetBlkioDeviceWriteBps(cgroup, dev->path, - dev->wbps) < 0 || - virCgroupGetBlkioDeviceWriteBps(cgroup, dev->path, - &dev->wbps) < 0)) - return -1; - } - } - - return 0; + return virCgroupSetupBlkioTune(cgroup, &def->blkio); } =20 =20 diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 43e17d786e..0e53678faa 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -514,7 +514,6 @@ static int qemuSetupBlkioCgroup(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - size_t i; =20 if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)) { @@ -527,51 +526,7 @@ qemuSetupBlkioCgroup(virDomainObjPtr vm) } } =20 - if (vm->def->blkio.weight !=3D 0 && - virCgroupSetBlkioWeight(priv->cgroup, vm->def->blkio.weight) < 0) - return -1; - - if (vm->def->blkio.ndevices) { - for (i =3D 0; i < vm->def->blkio.ndevices; i++) { - virBlkioDevicePtr dev =3D &vm->def->blkio.devices[i]; - if (dev->weight && - (virCgroupSetBlkioDeviceWeight(priv->cgroup, dev->path, - dev->weight) < 0 || - virCgroupGetBlkioDeviceWeight(priv->cgroup, dev->path, - &dev->weight) < 0)) - return -1; - - if (dev->riops && - (virCgroupSetBlkioDeviceReadIops(priv->cgroup, dev->path, - dev->riops) < 0 || - virCgroupGetBlkioDeviceReadIops(priv->cgroup, dev->path, - &dev->riops) < 0)) - return -1; - - if (dev->wiops && - (virCgroupSetBlkioDeviceWriteIops(priv->cgroup, dev->path, - dev->wiops) < 0 || - virCgroupGetBlkioDeviceWriteIops(priv->cgroup, dev->path, - &dev->wiops) < 0)) - return -1; - - if (dev->rbps && - (virCgroupSetBlkioDeviceReadBps(priv->cgroup, dev->path, - dev->rbps) < 0 || - virCgroupGetBlkioDeviceReadBps(priv->cgroup, dev->path, - &dev->rbps) < 0)) - return -1; - - if (dev->wbps && - (virCgroupSetBlkioDeviceWriteBps(priv->cgroup, dev->path, - dev->wbps) < 0 || - virCgroupGetBlkioDeviceWriteBps(priv->cgroup, dev->path, - &dev->wbps) < 0)) - return -1; - } - } - - return 0; + return virCgroupSetupBlkioTune(priv->cgroup, &vm->def->blkio); } =20 =20 diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 64507bf8aa..a08b6f4869 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -4820,3 +4820,57 @@ virCgroupDelThread(virCgroupPtr cgroup, =20 return 0; } + + +int +virCgroupSetupBlkioTune(virCgroupPtr cgroup, + virBlkioTunePtr blkio) +{ + size_t i; + + if (blkio->weight !=3D 0 && + virCgroupSetBlkioWeight(cgroup, blkio->weight) < 0) + return -1; + + if (blkio->ndevices) { + for (i =3D 0; i < blkio->ndevices; i++) { + virBlkioDevicePtr dev =3D &blkio->devices[i]; + if (dev->weight && + (virCgroupSetBlkioDeviceWeight(cgroup, dev->path, + dev->weight) < 0 || + virCgroupGetBlkioDeviceWeight(cgroup, dev->path, + &dev->weight) < 0)) + return -1; + + if (dev->riops && + (virCgroupSetBlkioDeviceReadIops(cgroup, dev->path, + dev->riops) < 0 || + virCgroupGetBlkioDeviceReadIops(cgroup, dev->path, + &dev->riops) < 0)) + return -1; + + if (dev->wiops && + (virCgroupSetBlkioDeviceWriteIops(cgroup, dev->path, + dev->wiops) < 0 || + virCgroupGetBlkioDeviceWriteIops(cgroup, dev->path, + &dev->wiops) < 0)) + return -1; + + if (dev->rbps && + (virCgroupSetBlkioDeviceReadBps(cgroup, dev->path, + dev->rbps) < 0 || + virCgroupGetBlkioDeviceReadBps(cgroup, dev->path, + &dev->rbps) < 0)) + return -1; + + if (dev->wbps && + (virCgroupSetBlkioDeviceWriteBps(cgroup, dev->path, + dev->wbps) < 0 || + virCgroupGetBlkioDeviceWriteBps(cgroup, dev->path, + &dev->wbps) < 0)) + return -1; + } + } + + return 0; +} diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index ee3b7c7222..2908f70372 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -27,6 +27,7 @@ =20 # include "virutil.h" # include "virbitmap.h" +# include "virblkio.h" =20 struct _virCgroup; typedef struct _virCgroup virCgroup; @@ -286,4 +287,6 @@ int virCgroupSetOwner(virCgroupPtr cgroup, int virCgroupHasEmptyTasks(virCgroupPtr cgroup, int controller); =20 bool virCgroupControllerAvailable(int controller); + +int virCgroupSetupBlkioTune(virCgroupPtr cgroup, virBlkioTunePtr blkio); #endif /* __VIR_CGROUP_H__ */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 19:11:21 2024 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 1536824980910223.7212009329594; Thu, 13 Sep 2018 00:49:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D964D81F0D; Thu, 13 Sep 2018 07:49:38 +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 99F3A5C21E; Thu, 13 Sep 2018 07:49:38 +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 53FA018005D0; Thu, 13 Sep 2018 07:49:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8D7mRVM027178 for ; Thu, 13 Sep 2018 03:48:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id CE97A9A311; Thu, 13 Sep 2018 07:48:27 +0000 (UTC) Received: from dahmer.redhat.com (ovpn-204-17.brq.redhat.com [10.40.204.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E04E9A313; Thu, 13 Sep 2018 07:48:26 +0000 (UTC) From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Thu, 13 Sep 2018 09:48:14 +0200 Message-Id: <20180913074814.9697-5-fidencio@redhat.com> In-Reply-To: <20180913074814.9697-1-fidencio@redhat.com> References: <20180913074814.9697-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [libvirt PATCH v3 4/4] vircgroup: Add virCgroupSetupMemTune() 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 13 Sep 2018 07:49:39 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 virCgroupSetupMemTune() has been introduced in order to remove the code duplication present between virLXCCgroupSetupMemTune() and qemuSetupMemoryCgroup(). Signed-off-by: Fabiano Fid=C3=AAncio --- src/libvirt_private.syms | 1 + src/lxc/lxc_cgroup.c | 20 ++------------------ src/qemu/qemu_cgroup.c | 14 +------------- src/util/vircgroup.c | 20 ++++++++++++++++++++ src/util/vircgroup.h | 2 ++ 5 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5df48f88f4..94044c60ec 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1580,6 +1580,7 @@ virCgroupSetMemorySoftLimit; virCgroupSetMemSwapHardLimit; virCgroupSetOwner; virCgroupSetupBlkioTune; +virCgroupSetupMemTune; virCgroupSupportsCpuBW; virCgroupTerminateMachine; =20 diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index 4a95f2a8b0..95311fde9e 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -113,26 +113,10 @@ static int virLXCCgroupSetupBlkioTune(virDomainDefPtr= def, static int virLXCCgroupSetupMemTune(virDomainDefPtr def, virCgroupPtr cgroup) { - int ret =3D -1; - if (virCgroupSetMemory(cgroup, virDomainDefGetMemoryInitial(def)) < 0) - goto cleanup; - - if (virMemoryLimitIsSet(def->mem.hard_limit)) - if (virCgroupSetMemoryHardLimit(cgroup, def->mem.hard_limit) < 0) - goto cleanup; - - if (virMemoryLimitIsSet(def->mem.soft_limit)) - if (virCgroupSetMemorySoftLimit(cgroup, def->mem.soft_limit) < 0) - goto cleanup; - - if (virMemoryLimitIsSet(def->mem.swap_hard_limit)) - if (virCgroupSetMemSwapHardLimit(cgroup, def->mem.swap_hard_limit)= < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return virCgroupSetupMemTune(cgroup, &def->mem); } =20 =20 diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 0e53678faa..205098ec30 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -547,19 +547,7 @@ qemuSetupMemoryCgroup(virDomainObjPtr vm) } } =20 - if (virMemoryLimitIsSet(vm->def->mem.hard_limit)) - if (virCgroupSetMemoryHardLimit(priv->cgroup, vm->def->mem.hard_li= mit) < 0) - return -1; - - if (virMemoryLimitIsSet(vm->def->mem.soft_limit)) - if (virCgroupSetMemorySoftLimit(priv->cgroup, vm->def->mem.soft_li= mit) < 0) - return -1; - - if (virMemoryLimitIsSet(vm->def->mem.swap_hard_limit)) - if (virCgroupSetMemSwapHardLimit(priv->cgroup, vm->def->mem.swap_h= ard_limit) < 0) - return -1; - - return 0; + return virCgroupSetupMemTune(priv->cgroup, &vm->def->mem); } =20 =20 diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index a08b6f4869..3973f6da61 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -4874,3 +4874,23 @@ virCgroupSetupBlkioTune(virCgroupPtr cgroup, =20 return 0; } + + +int +virCgroupSetupMemTune(virCgroupPtr cgroup, + virMemTunePtr mem) +{ + if (virMemoryLimitIsSet(mem->hard_limit)) + if (virCgroupSetMemoryHardLimit(cgroup, mem->hard_limit) < 0) + return -1; + + if (virMemoryLimitIsSet(mem->soft_limit)) + if (virCgroupSetMemorySoftLimit(cgroup, mem->soft_limit) < 0) + return -1; + + if (virMemoryLimitIsSet(mem->swap_hard_limit)) + if (virCgroupSetMemSwapHardLimit(cgroup, mem->swap_hard_limit) < 0) + return -1; + + return 0; +} diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index 2908f70372..c01422ec84 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -28,6 +28,7 @@ # include "virutil.h" # include "virbitmap.h" # include "virblkio.h" +# include "virmem.h" =20 struct _virCgroup; typedef struct _virCgroup virCgroup; @@ -289,4 +290,5 @@ int virCgroupHasEmptyTasks(virCgroupPtr cgroup, int con= troller); bool virCgroupControllerAvailable(int controller); =20 int virCgroupSetupBlkioTune(virCgroupPtr cgroup, virBlkioTunePtr blkio); +int virCgroupSetupMemTune(virCgroupPtr cgroup, virMemTunePtr mem); #endif /* __VIR_CGROUP_H__ */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list