From nobody Fri May 3 10:54:37 2024 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=1610979375; cv=none; d=zohomail.com; s=zohoarc; b=R8xLcT/+y/IitNz582Axbmrwqa22zl23TCiUhidcnLvXEV4SOtcOKgOdilQa8XUjWfgxJQIqj5IUDAcBE8UC5y4kK6ZX/OQb4eNQb20m0xCcfk5Z/vgA2I1aj+FDd84hhDs2gXBBVAwGG2K5WRqlIqXTjpZFfUCvfhXoPxxYXA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610979375; 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=FyaJ5YJ/4lN9HiCYVy5yEi/p+TdSATTFWbDGcoCek/A=; b=imyeolPt+SuW2OqiT+497gWQOYIf+f3mJ/+bKupadaAjffz7d4dL5fJb4S8XT+8vGyA7PEqJIAo5N1KY+R0BZqApf3DDi0O9wuxHCzwt9QtN3IK5M8MPRlWpZAMTzxAEwYX4gwLb9yie7Xgz5N/vspUulvtfOyXgf68E37tczP4= 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 1610979375076494.25974780333934; Mon, 18 Jan 2021 06:16:15 -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-218-jhEzF7N7NSmyK-a3rdtjlw-1; Mon, 18 Jan 2021 09:16:10 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1AD4107ACE3; Mon, 18 Jan 2021 14:16:04 +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 6C7006268E; Mon, 18 Jan 2021 14:16:04 +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 74AF84BB7B; Mon, 18 Jan 2021 14:16:02 +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 10IEG0Hh024803 for ; Mon, 18 Jan 2021 09:16:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9F51D60622; Mon, 18 Jan 2021 14:16:00 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 213C360861 for ; Mon, 18 Jan 2021 14:15:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610979373; 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=FyaJ5YJ/4lN9HiCYVy5yEi/p+TdSATTFWbDGcoCek/A=; b=OOD4uDfimWM7bnsMAK5xu0FDRpQXpxhCpPz1I87H2O/VCiZxAB1MlHsNzciQD5rBZdMrMy qJxQ3CUhZmP3R2KSUAOrwi6WnZuDH57vgBLLbT52Q0COac4DwD3o7uY+FAF1NgCMEx+ymT sRLz8d+aJQPkRXepk1Et8TprMCs9REk= X-MC-Unique: jhEzF7N7NSmyK-a3rdtjlw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] conf: Turn @uuid member of _virDomainMemoryDef struct into a pointer Date: Mon, 18 Jan 2021 15:15:53 +0100 Message-Id: <12c42c4795305e40dd64f845be10119f883abcc8.1610979285.git.mprivozn@redhat.com> 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.15 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" The _virDomainMemoryDef structure has @uuid member which is needed for PPC64 guests. No other architectures use it. Since the member is VIR_UUID_BUFLEN bytes long, the structure is unnecessary big. If the member is just a pointer then we can also replace some calls of virUUIDIsValid() with plain test against NULL. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 14 ++++++++------ src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ff3b7cbfc8..a2ddfcf947 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3116,6 +3116,7 @@ void virDomainMemoryDefFree(virDomainMemoryDefPtr def) =20 VIR_FREE(def->nvdimmPath); virBitmapFree(def->sourceNodes); + VIR_FREE(def->uuid); virDomainDeviceInfoClear(&def->info); VIR_FREE(def); } @@ -15530,6 +15531,7 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr xm= lopt, /* Extract nvdimm uuid or generate a new one */ tmp =3D virXPathString("string(./uuid[1])", ctxt); =20 + def->uuid =3D g_new0(unsigned char, VIR_UUID_BUFLEN); if (!tmp) { if (virUUIDGenerate(def->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -22808,7 +22810,9 @@ virDomainMemoryDefCheckABIStability(virDomainMemory= DefPtr src, return false; } =20 - if (memcmp(src->uuid, dst->uuid, VIR_UUID_BUFLEN) !=3D 0) { + if ((src->uuid || dst->uuid) && + !(src->uuid && dst->uuid && + memcmp(src->uuid, dst->uuid, VIR_UUID_BUFLEN) =3D=3D 0)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Target NVDIMM UUID doesn't match source NVDI= MM")); return false; @@ -26560,7 +26564,6 @@ virDomainMemoryTargetDefFormat(virBufferPtr buf, static int virDomainMemoryDefFormat(virBufferPtr buf, virDomainMemoryDefPtr def, - const virDomainDef *dom, unsigned int flags) { const char *model =3D virDomainMemoryModelTypeToString(def->model); @@ -26575,8 +26578,7 @@ virDomainMemoryDefFormat(virBufferPtr buf, virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); =20 - if (def->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && - ARCH_IS_PPC64(dom->os.arch)) { + if (def->uuid) { char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 virUUIDFormat(def->uuid, uuidstr); @@ -28974,7 +28976,7 @@ virDomainDefFormatInternalSetRootName(virDomainDefP= tr def, virDomainShmemDefFormat(buf, def->shmems[n], flags); =20 for (n =3D 0; n < def->nmems; n++) { - if (virDomainMemoryDefFormat(buf, def->mems[n], def, flags) < 0) + if (virDomainMemoryDefFormat(buf, def->mems[n], flags) < 0) return -1; } =20 @@ -30091,7 +30093,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, rc =3D 0; break; case VIR_DOMAIN_DEVICE_MEMORY: - rc =3D virDomainMemoryDefFormat(&buf, src->data.memory, def, flags= ); + rc =3D virDomainMemoryDefFormat(&buf, src->data.memory, flags); break; case VIR_DOMAIN_DEVICE_SHMEM: virDomainShmemDefFormat(&buf, src->data.shmem, flags); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f59d972c85..6645282bf6 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2331,7 +2331,7 @@ struct _virDomainMemoryDef { bool readonly; /* valid only for NVDIMM */ =20 /* required for QEMU NVDIMM ppc64 support */ - unsigned char uuid[VIR_UUID_BUFLEN]; + unsigned char *uuid; =20 virDomainDeviceInfo info; }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 99761c217d..2506248866 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3319,7 +3319,7 @@ qemuBuildMemoryDeviceStr(const virDomainDef *def, if (mem->labelsize) virBufferAsprintf(&buf, "label-size=3D%llu,", mem->labelsize * 102= 4); =20 - if (virUUIDIsValid(mem->uuid)) { + if (mem->uuid) { char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 virUUIDFormat(mem->uuid, uuidstr); --=20 2.26.2 From nobody Fri May 3 10:54:37 2024 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