From nobody Sun Apr 28 19:42:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665571097; cv=none; d=zohomail.com; s=zohoarc; b=BX3nOcI6S8aL54Q7NvFouNuNW0/2c3S8RNruBWJJ1nQqLpneMKOqG48V+KYU/FcR4GZGyXqfhCDjO5S+1ZOHbSL45S8gnASvs6ePHiXC7zUY649wtD5kMaSXk7xcoCus7PFXL+CF3ScUwokq6TQXqmudS9f5FlUYF46nbFUwMgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665571097; h=Content-Type:Content-Transfer-Encoding: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=BuMlVc9KeCjw86ApmT3tCfGj58dIORa+mbw6CggpE2U=; b=awHCjWR9ZQupdGD0SpKc9YFRhMjnubKSH/QizzMwhBD73lYj28XbfHDCMHen+fSLIZOy7dw9bEF/ZfgggMiVzW8lU9BblCF0LZZ0l8l15zMaHftbDjs8+wffVQFfNG/O/9f4j+oTs73PJ+ndH9Ivto1AXIUgH40TCITafHbRf/E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1665571097468705.6517607350197; Wed, 12 Oct 2022 03:38:17 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-552-rTEYHdByMV2qTu4d6b2JjQ-1; Wed, 12 Oct 2022 06:38:14 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC4BC185A792; Wed, 12 Oct 2022 10:38:12 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57F5F492B05; Wed, 12 Oct 2022 10:38:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 238E5194658F; Wed, 12 Oct 2022 10:38:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 38C381946588 for ; Wed, 12 Oct 2022 10:38:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0F22F40C206B; Wed, 12 Oct 2022 10:38:02 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id A877440E993E for ; Wed, 12 Oct 2022 10:38:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665571096; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BuMlVc9KeCjw86ApmT3tCfGj58dIORa+mbw6CggpE2U=; b=DqA1OJ3ZXtjC6VIcw49aoW5mf1SyGbItEYG9lUIQvOYAZPzsc9Lf9QqSsouafRdJOGwBd4 +JT0zz+y3rK/v5bxcJP/mZwovaT/OykZS8ZJ/d4nYhpCIXm1RhuyQ0zUMJIqMdynq66oYw vFSCGkdHUQ6BluZmk6SqIRo6/WOi/dM= X-MC-Unique: rTEYHdByMV2qTu4d6b2JjQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] qemu: Separate out hugepages basedir making Date: Wed, 12 Oct 2022 12:37:58 +0200 Message-Id: <267c49d9774818d630c9aaaeb7fca4971feb08e2.1665571064.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665571097980100001 Content-Type: text/plain; charset="utf-8"; x-default="true" During its initialization, the QEMU driver iterates over hugetlbfs mount points, creating the driver specific path in each of them ($prefix/libvirt/qemu). This path is created with very wide mode (0777) because per-domain directories are then created under it. Separate this code into a function so that it can be re-used. Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/qemu/qemu_conf.c | 27 +++++++++++++++++++++++++++ src/qemu/qemu_conf.h | 3 +++ src/qemu/qemu_driver.c | 17 +---------------- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 4f59e5fb07..c20fec26ba 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1576,3 +1576,30 @@ qemuGetMemoryBackingPath(virQEMUDriver *driver, *memPath =3D g_strdup_printf("%s/%s", domainPath, alias); return 0; } + + +int +qemuMkdirBaseHugepage(virQEMUDriver *driver, + virHugeTLBFS *hugepage) +{ + + g_autofree char *hugepagePath =3D NULL; + + hugepagePath =3D qemuGetBaseHugepagePath(driver, hugepage); + + if (!hugepagePath) + return -1; + + if (g_mkdir_with_parents(hugepagePath, 0777) < 0) { + virReportSystemError(errno, + _("unable to create hugepage path %s"), + hugepagePath); + return -1; + } + + if (driver->privileged && + virFileUpdatePerm(hugepage->mnt_dir, 0, S_IXGRP | S_IXOTH) < 0) + return -1; + + return 0; +} diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index c40c452f58..f9314e23a3 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -359,3 +359,6 @@ int qemuGetMemoryBackingPath(virQEMUDriver *driver, const virDomainDef *def, const char *alias, char **memPath); + +int qemuMkdirBaseHugepage(virQEMUDriver *driver, + virHugeTLBFS *hugepage); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 40d23b5723..744661f0f7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -837,22 +837,7 @@ qemuStateInitialize(bool privileged, * it, since we can't assume the root mount point has permissions that * will let our spawned QEMU instances use it. */ for (i =3D 0; i < cfg->nhugetlbfs; i++) { - g_autofree char *hugepagePath =3D NULL; - - hugepagePath =3D qemuGetBaseHugepagePath(qemu_driver, &cfg->hugetl= bfs[i]); - - if (!hugepagePath) - goto error; - - if (g_mkdir_with_parents(hugepagePath, 0777) < 0) { - virReportSystemError(errno, - _("unable to create hugepage path %s"), - hugepagePath); - goto error; - } - if (privileged && - virFileUpdatePerm(cfg->hugetlbfs[i].mnt_dir, - 0, S_IXGRP | S_IXOTH) < 0) + if (qemuMkdirBaseHugepage(qemu_driver, &cfg->hugetlbfs[i]) < 0) goto error; } =20 --=20 2.35.1 From nobody Sun Apr 28 19:42:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665571107; cv=none; d=zohomail.com; s=zohoarc; b=hnKfeZegiN5CVkm8hIvGVPOHpJFZDyyHEKoilG5nMTy8FPeKy+nMhoEUh50AikpVHqvpo84YQixC6saOCQ3kVnY1MpD4TBzucLCM49b73gdxXZhK7G69oTED8FUAHAKbGK7nqzpyxry2LFiOSInlNcG0Db8vzMq4WInkC8dU6KY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665571107; h=Content-Type:Content-Transfer-Encoding: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=Nf50uKq9dh1LO+qTdcrtYz1L+t+L3dMBYvOiAZJLyhs=; b=JTMhrXK+hhQqyfHM6x8xlMf/OnEwb31I6be4GfuSGEeVMM22J77NEECgwGlSHrX0rkJxbwCFuFojWObhrcsTdw9H+9R45sxKdwQnnybfprwfD/ozo+DsH3zX5pAF+SXCiSOpE9GfZsbroICUGHsqtaWECgF7gLjPza1DyI6nySo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1665571107287219.22983037432118; Wed, 12 Oct 2022 03:38:27 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-425-req6roDvNQuvFRWcMOMqXg-1; Wed, 12 Oct 2022 06:38:22 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 30024185A7A9; Wed, 12 Oct 2022 10:38:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1959749BB64; Wed, 12 Oct 2022 10:38:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 928221946A4A; Wed, 12 Oct 2022 10:38:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BC7171946588 for ; Wed, 12 Oct 2022 10:38:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A01B640E993C; Wed, 12 Oct 2022 10:38:02 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 471EA40C206B for ; Wed, 12 Oct 2022 10:38:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665571106; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Nf50uKq9dh1LO+qTdcrtYz1L+t+L3dMBYvOiAZJLyhs=; b=AnSTJTsXkowdeBbrPFJSPHNznofgNDTIElpJlLsUk47f9be8cOaEUEli3E+V6U+QOf1Yyf 5IqU0rg13wYTHgQV5us9odbQJGRifnSy477Ud+8GSZ+KeTPjTRpMWsSQmDmuzkx8zbhPwC Bmm5AsHQn4OPoH8lpSVOqcHW469ULe8= X-MC-Unique: req6roDvNQuvFRWcMOMqXg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] qemu: Create base hugepages path on memory hotplug Date: Wed, 12 Oct 2022 12:37:59 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665571108046100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Users can play all sorts of games with mount points. For instance, they can unmount and mount back a hugetlbfs and only after that attempt to hotplug memory. This has an unfortunate consequence though. During memory hotplug, when qemuProcessBuildDestroyMemoryPaths() is called the path is created with very restrictive mode (0700) because under the hood g_mkdir_with_parents(path, 0700) is called. Therefore, create the driver generic portion of the path separately. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2134009 Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/qemu/qemu_process.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d78e91efed..9420201466 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4015,6 +4015,10 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriver *dr= iver, if (!path) return -1; =20 + if (build && + qemuMkdirBaseHugepage(driver, &cfg->hugetlbfs[i]) < 0) + return -1; + if (qemuProcessBuildDestroyMemoryPathsImpl(driver, vm, path, build) < 0) return -1; --=20 2.35.1