From nobody Sun Feb 8 16:11:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1606999026; cv=none; d=zohomail.com; s=zohoarc; b=m0X0c9G/gznUBONoZ4lg+ecIK6wmOuTmlaXf9KfKSrwmtFEAR6KIlPCSAd7TEuHauJezCPPFqW9sBGx8P0YKOuAk89502meNR+mj+wucsig1F69m2Nyz4VsgrAC0kGtgJRXAKGxpADu/yXDaxTn2KHgasfLvXVwSGYYNCEHxrkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606999026; 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=buXagntCbzq225jqRiz/1AMqZDro93ICvgq5w4gKnJ0=; b=RUHSJB7MgBecOuMoPELtEnNE6ojePte3jk2rgcFbFlVonXfLTKw0PaqVqDUmNf3ZIsgnvnOY8pFTKJNH8CeQnnjcZcyP4Qcic3Y+ylLLe9t5m0BLMPj6J2QBzMnbpVZuzC/PZ/m+d11BBDKy8OHQQis6TSQYVuU5HBacf5Rjp8c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1606999025992305.60657007341524; Thu, 3 Dec 2020 04:37:05 -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-252-xQY7lZxEMLyYitpdQiU-FA-1; Thu, 03 Dec 2020 07:37:02 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6EC6A185E4A2; Thu, 3 Dec 2020 12:36:56 +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 4C8E25D9D7; Thu, 3 Dec 2020 12:36:56 +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 D49614E58E; Thu, 3 Dec 2020 12:36:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B3CaqhY002954 for ; Thu, 3 Dec 2020 07:36:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 420FB5C1C2; Thu, 3 Dec 2020 12:36:52 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7EDD5C1CF for ; Thu, 3 Dec 2020 12:36:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606999024; 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=buXagntCbzq225jqRiz/1AMqZDro93ICvgq5w4gKnJ0=; b=bMC8W1jztF6reOPvLQYDCtTe6EOl9gAsPRwCA4hQIlepdEGzmZ8iG9K1fSFjm+bTsJ6Wkq XzlTwLu5vkmDU/uoPtgINiXppbXo1eyXSDZmChcpjqcNzfvzGb+yha90+xDnWXl+Vx0+op n0Tb52mUUiidrZWvnnrykf/8IWiQwNo= X-MC-Unique: xQY7lZxEMLyYitpdQiU-FA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 06/27] conf: Require nvdimm path in validate step Date: Thu, 3 Dec 2020 13:36:09 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@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.14 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 Reviewed-by: Peter Krempa --- 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 d8df18b542..da14760e2d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6694,6 +6694,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")); @@ -16690,11 +16696,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