From nobody Sun Feb 8 17:28:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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=1606489630; cv=none; d=zohomail.com; s=zohoarc; b=lfoOLW64WOicQkr/0kic5wzypUBN8XrCMmM9SahAhZaKtiRnSngKbcVNNGIJvVUl1fKWLD9C37u2rAwWUCXMq/bj+Sqgc1qUUU38EeONRy0tJK7DJdEcfWQavApmLQRle1fK/lhgz/kzBzAalm2eP/vAQYUYTDprSpYZogmKqxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606489630; 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=GWdkx4PSp7356M0RPXOYN75DICpXXfLV0oCU5uvxz2w=; b=lxkbOkLKyy1uWKc0QZaO7Di/WSzTQXUaiy0ma6mt8mytjJRMz67g/zAy0N3SqcKaeqOcVPMsXgrmWILGnGtDRMVYxVJ4bAgMOhYlswoqid0zbLVcvaT3fQW+/q2kAnDPGy0xXNdqY6TiLz0kKRCgDE+qm1mk9FV+Q59cY0OrsYA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= 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 1606489629342654.8624439368008; Fri, 27 Nov 2020 07:07:09 -0800 (PST) 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-423-LfQYI4h6NRq4PKfDxerD4Q-1; Fri, 27 Nov 2020 10:07:04 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5E81F8A8F2A; Fri, 27 Nov 2020 15:06:52 +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 335FC60867; Fri, 27 Nov 2020 15:06:52 +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 E4F0C50035; Fri, 27 Nov 2020 15:06:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ARF46Dl030694 for ; Fri, 27 Nov 2020 10:04:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9D4235D9CC; Fri, 27 Nov 2020 15:04:06 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id D48CE5D9DE; Fri, 27 Nov 2020 15:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606489627; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=GWdkx4PSp7356M0RPXOYN75DICpXXfLV0oCU5uvxz2w=; b=Shgwn10UhhFYFE/f9XgdCyMM9z0To9GOW907iPUPKreC974OLTbrvXuPhPZ+UItfms24rg 9RuMSCEeM1d9MeQDI1xJ8STEpDRddqRjzRkoDbsjzyGOIGwL4aw+UKT97WmaPHWdcKGLFb LI98bkNh37HhNDB1RM0YhSQudJD3rk0= X-MC-Unique: LfQYI4h6NRq4PKfDxerD4Q-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v1 06/26] conf: Require nvdimm path in validate step Date: Fri, 27 Nov 2020 16:02:52 +0100 Message-Id: <5ae39f7f4424aab4a6046d19f07242f2a6aed86f.1606489221.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: david@redhat.com 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.13 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Our code expects that a nvdimm has a path defined always. And the parser does check for that. Well, not fully - only when parsing (which is an optional element). So if the element is not in the XML then the check is not performed and the assumption is broken. Verify in the memory def validator that a path was set. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 12 +++++++----- src/security/security_apparmor.c | 6 ------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 631165c3fa..6c1fa93b0a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6699,6 +6699,12 @@ virDomainMemoryDefValidate(const virDomainMemoryDef = *mem, const virDomainDef *def) { if (mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM) { + if (!mem->nvdimmPath) { + virReportError(VIR_ERR_XML_DETAIL, "%s", + _("path is required for model 'nvdimm'")); + return -1; + } + if (mem->discard =3D=3D VIR_TRISTATE_BOOL_YES) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("discard is not supported for nvdimms")); @@ -16713,11 +16719,7 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node, break; =20 case VIR_DOMAIN_MEMORY_MODEL_NVDIMM: - if (!(def->nvdimmPath =3D virXPathString("string(./path)", ctxt)))= { - virReportError(VIR_ERR_XML_DETAIL, "%s", - _("path is required for model 'nvdimm'")); - return -1; - } + def->nvdimmPath =3D virXPathString("string(./path)", ctxt); =20 if (virDomainParseMemory("./alignsize", "./alignsize/@unit", ctxt, &def->alignsize, false, false) < 0) diff --git a/src/security/security_apparmor.c b/src/security/security_appar= mor.c index c2d86c6940..f306af8dd3 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -686,12 +686,6 @@ AppArmorSetMemoryLabel(virSecurityManagerPtr mgr, =20 switch ((virDomainMemoryModel) mem->model) { case VIR_DOMAIN_MEMORY_MODEL_NVDIMM: - if (mem->nvdimmPath =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("%s: nvdimm without a path"), - __func__); - return -1; - } if (!virFileExists(mem->nvdimmPath)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: \'%s\' does not exist"), --=20 2.26.2