From nobody Sat Nov 23 01:58:32 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=1686152923; cv=none; d=zohomail.com; s=zohoarc; b=FltyR106v1Vw7KvcL7LIS3URby1g6JGqZyIJ1tFakHQyXWPQ+QaNExfhBfFQvATrm53Y5h5NXX+TlJVYJ1Oy/QFL5iUlPJFwfmCETgbDEgyEtwFF/zopyCtEk5flWqxV30f22zuSLidZH6BapfHPvw/b6m+HMdN5AMpE8X/x1kw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686152923; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=sjlGxhpr1VKyj/TU8vSw5HWPKZ4b0y7PDBB/a6Bkd2I=; b=Khq1jbegRizNLv2PL9mfwuJp/3sE1IfaCNr+zIrXxIuRpMlow9uYqspxw9dmEK78NNxQL/Yp46Tx8jublczNn/2iOU96t+itL1Zbay8vo4X4gDIO8xNIVauG6WflI7QBQHifbaORe78mbV85Kwg+ls58pXbFTOtqjBB5Kl4vHVU= 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 1686152923930681.363288982409; Wed, 7 Jun 2023 08:48:43 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-304-MQpxibbVPayk6_lmWHX7dw-1; Wed, 07 Jun 2023 11:48:39 -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 84A583C13A1A; Wed, 7 Jun 2023 15:48:36 +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 9167F403367; Wed, 7 Jun 2023 15:48:34 +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 420ED19452C3; Wed, 7 Jun 2023 15:48:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 562D219465BA for ; Wed, 7 Jun 2023 15:43:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 343D51121315; Wed, 7 Jun 2023 15:43:40 +0000 (UTC) Received: from fedora.. (unknown [10.43.2.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF97F1121314 for ; Wed, 7 Jun 2023 15:43:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686152922; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sjlGxhpr1VKyj/TU8vSw5HWPKZ4b0y7PDBB/a6Bkd2I=; b=gb0oVc0g4Oq0Dy7ZV+heMweoaVZNi5MoKiks7z8YPeS5PyfPADYGkfApObhUXEaFGMgr1P QnHuUTMHqcDxqFR0QhZKf21NyP2O4FtOgXpCQ0kLPMfgDdzCjmX5roSGtAyvQzkuJaAgK2 9+7F1Ql53HDTaEogJ57iR5J+S09Fxjo= X-MC-Unique: MQpxibbVPayk6_lmWHX7dw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH] conf: virtiofs: validate that the target dir is unique even for hotplug Date: Wed, 7 Jun 2023 17:43:37 +0200 Message-Id: <5d4e3371a74c4636dc850129a7ee5260916a90c2.1686152610.git.jtomko@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1686152924260100001 https://bugzilla.redhat.com/show_bug.cgi?id=3D2171384 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/conf/domain_validate.c | 28 ++++++++++++++++++++-------- src/conf/domain_validate.h | 2 ++ src/libvirt_private.syms | 1 + 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 80d6a2ffd9..4c76eb7f46 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1735,8 +1735,9 @@ virDomainDefIOMMUValidate(const virDomainDef *def) } =20 =20 -static int -virDomainDefFSValidate(const virDomainDef *def) +int +virDomainDefFSValidate(const virDomainDef *def, + const virDomainFSDef *newfs) { size_t i; g_autoptr(GHashTable) dsts =3D virHashNew(NULL); @@ -1754,8 +1755,18 @@ virDomainDefFSValidate(const virDomainDef *def) return -1; } =20 - if (virHashAddEntry(dsts, fs->dst, (void *) 0x1) < 0) + if (virHashAddEntry(dsts, fs->dst, (void *) fs) < 0) + return -1; + } + + if (newfs) { + const virDomainFSDef *fs =3D g_hash_table_lookup(dsts, newfs->dst); + if (fs && fs !=3D newfs) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("filesystem target '%1$s' specified twice"), + newfs->dst); return -1; + } } =20 return 0; @@ -1856,9 +1867,6 @@ virDomainDefValidateInternal(const virDomainDef *def, if (virDomainNumaDefValidate(def->numa) < 0) return -1; =20 - if (virDomainDefFSValidate(def) < 0) - return -1; - if (virDomainDefValidateIOThreads(def) < 0) return -1; =20 @@ -2573,7 +2581,8 @@ virDomainShmemDefValidate(const virDomainShmemDef *sh= mem) } =20 static int -virDomainFSDefValidate(const virDomainFSDef *fs) +virDomainFSDefValidate(const virDomainDef *def, + const virDomainFSDef *fs) { if (fs->dst =3D=3D NULL) { const char *source =3D fs->src->path; @@ -2592,6 +2601,9 @@ virDomainFSDefValidate(const virDomainFSDef *fs) return -1; } =20 + if (virDomainDefFSValidate(def, fs) < 0) + return -1; + return 0; } =20 @@ -2885,7 +2897,7 @@ virDomainDeviceDefValidateInternal(const virDomainDev= iceDef *dev, return virDomainShmemDefValidate(dev->data.shmem); =20 case VIR_DOMAIN_DEVICE_FS: - return virDomainFSDefValidate(dev->data.fs); + return virDomainFSDefValidate(def, dev->data.fs); =20 case VIR_DOMAIN_DEVICE_AUDIO: return virDomainAudioDefValidate(def, dev->data.audio); diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index fc441cef5b..437cbe4d2e 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -47,3 +47,5 @@ int virDomainDiskDefSourceLUNValidate(const virStorageSou= rce *src); =20 int virDomainDefOSValidate(const virDomainDef *def, virDomainXMLOption *xmlopt); +int virDomainDefFSValidate(const virDomainDef *def, + const virDomainFSDef *newfs); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 436d5a0770..65089c1aaa 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -793,6 +793,7 @@ virDomainDefPostParse; =20 # conf/domain_validate.h virDomainActualNetDefValidate; +virDomainDefFSValidate; virDomainDefOSValidate; virDomainDefValidate; virDomainDeviceValidateAliasForHotplug; --=20 2.40.1