From nobody Sun Feb 8 11:41:05 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=1610979379; cv=none; d=zohomail.com; s=zohoarc; b=J2sSBt+ollIkYEHxUJNXXfWXxapAS+/j1ijJ8CVGsp6BeGWJ8AL3H+2HUrxu4tEmlQorJcWB3qqd6loyuk6IjcrxnZTqo0mqygAPYUSt2ZTTTbwjHkByEEKk9GqC5qGO0JjvfpuVZmj6zwA7Sw08Vc593yKLjfcbmOGaordqXDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610979379; 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=YC2m4mvwuL569NG2a6pLKCTHm9GXBkJq/XhXXZuiU8M=; b=V7BAiA+iZMo3H/FYtr20rQb68NB5nacLu9zjnmY7pmoiqA8N+YjZbFCdQd2DUR/6HxySdGPWn5h1oqHltG6R7H/hB3kYMw4Vpb6JmW2tqOCCEILrMtw/C1f/VMgyU2f/75tW8lwIFA4y2rsRNp85Zf3wG//kr1IXtejXZgV+wsU= 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 1610979379445118.07026135266813; Mon, 18 Jan 2021 06:16:19 -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-603-XQf_-eAHOQqkB-qPosFUlg-1; Mon, 18 Jan 2021 09:16:15 -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 DDA53802B42; Mon, 18 Jan 2021 14:16:09 +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 AE5D060861; Mon, 18 Jan 2021 14:16:09 +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 7B7495002F; Mon, 18 Jan 2021 14:16:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10IEG4hq024829 for ; Mon, 18 Jan 2021 09:16:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4B3BF60861; Mon, 18 Jan 2021 14:16:04 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id C103760CCD for ; Mon, 18 Jan 2021 14:16:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610979378; 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=YC2m4mvwuL569NG2a6pLKCTHm9GXBkJq/XhXXZuiU8M=; b=Et2nB2onIM4mifX4Zh+8+Te8JXB+T5tkb34dadaz8DRPzkJUozU4MOlp/tTcyWKsOZkbcV U67HpuZM3azqZSJgag5vzZr/DwQAkvQC4xwYBbQcJlDV/lLjdbNfNhFkixFprKVvIrU0Lp 9yCne3WpDNs9ZE/vqur71456ENdoQ2E= X-MC-Unique: XQf_-eAHOQqkB-qPosFUlg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] conf: Move generation of NVDIMM UUID into post parse callback Date: Mon, 18 Jan 2021 15:15:54 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.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" It's better to fill in missing values in post parse callbacks than during parsing. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a2ddfcf947..4f0798de45 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5334,7 +5334,8 @@ virDomainVsockDefPostParse(virDomainVsockDefPtr vsock) =20 =20 static int -virDomainMemoryDefPostParse(virDomainMemoryDefPtr mem) +virDomainMemoryDefPostParse(virDomainMemoryDefPtr mem, + const virDomainDef *def) { switch (mem->model) { case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM: @@ -5345,6 +5346,19 @@ virDomainMemoryDefPostParse(virDomainMemoryDefPtr me= m) break; =20 case VIR_DOMAIN_MEMORY_MODEL_NVDIMM: + /* If no NVDIMM UUID was provided in XML, generate one. */ + if (ARCH_IS_PPC64(def->os.arch) && + !mem->uuid) { + + mem->uuid =3D g_new0(unsigned char, VIR_UUID_BUFLEN); + if (virUUIDGenerate(mem->uuid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Failed to generate UUID")); + return -1; + } + } + break; + case VIR_DOMAIN_MEMORY_MODEL_DIMM: case VIR_DOMAIN_MEMORY_MODEL_NONE: case VIR_DOMAIN_MEMORY_MODEL_LAST: @@ -5401,7 +5415,7 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefP= tr dev, break; =20 case VIR_DOMAIN_DEVICE_MEMORY: - ret =3D virDomainMemoryDefPostParse(dev->data.memory); + ret =3D virDomainMemoryDefPostParse(dev->data.memory, def); break; =20 case VIR_DOMAIN_DEVICE_LEASE: @@ -15526,24 +15540,19 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr = xmlopt, } VIR_FREE(tmp); =20 + /* Extract NVDIMM UUID. */ if (def->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && - ARCH_IS_PPC64(dom->os.arch)) { - /* Extract nvdimm uuid or generate a new one */ - tmp =3D virXPathString("string(./uuid[1])", ctxt); - + ARCH_IS_PPC64(dom->os.arch) && + (tmp =3D virXPathString("string(./uuid[1])", ctxt))) { def->uuid =3D g_new0(unsigned char, VIR_UUID_BUFLEN); - if (!tmp) { - if (virUUIDGenerate(def->uuid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Failed to generate UUID")); - goto error; - } - } else if (virUUIDParse(tmp, def->uuid) < 0) { + + if (virUUIDParse(tmp, def->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed uuid element")); goto error; } } + VIR_FREE(tmp); =20 /* source */ if ((node =3D virXPathNode("./source", ctxt)) && --=20 2.26.2