From nobody Mon Feb 9 03:00:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522324314732607.5900596257768; Thu, 29 Mar 2018 04:51:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF62A13AA1; Thu, 29 Mar 2018 11:51:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B578F5E9CF; Thu, 29 Mar 2018 11:51:22 +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 2E273181BA05; Thu, 29 Mar 2018 11:51:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TBpIw6016277 for ; Thu, 29 Mar 2018 07:51:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E77F10B00A0; Thu, 29 Mar 2018 11:51:18 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CA1C10B00A2; Thu, 29 Mar 2018 11:51:17 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:50:59 +0200 Message-Id: <778cb51ba78d511ec9864aab1c154966a217c022.1522323985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 02/14] conf: Refactor/rename virDomainDiskDefSourceParse 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 29 Mar 2018 11:51:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make the function more usable by returning the full disk definition and fix the only caller for the new semantics. The new name for the function is virDomainDiskDefParse. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 33 ++++++++++++--------------------- src/conf/domain_conf.h | 8 ++++---- src/libvirt_private.syms | 2 +- src/qemu/qemu_driver.c | 9 +++++++-- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ae7c0d9b71..e2bad48cc8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15864,44 +15864,35 @@ virDomainDeviceDefParse(const char *xmlStr, } -virStorageSourcePtr -virDomainDiskDefSourceParse(const char *xmlStr, - const virDomainDef *def, - virDomainXMLOptionPtr xmlopt, - unsigned int flags) +virDomainDiskDefPtr +virDomainDiskDefParse(const char *xmlStr, + const virDomainDef *def, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) { xmlDocPtr xml; - xmlNodePtr node; xmlXPathContextPtr ctxt =3D NULL; virDomainDiskDefPtr disk =3D NULL; - virStorageSourcePtr ret =3D NULL; if (!(xml =3D virXMLParseStringCtxt(xmlStr, _("(disk_definition)"), &c= txt))) goto cleanup; - node =3D ctxt->node; - if (!virXMLNodeNameEqual(node, "disk")) { + if (!virXMLNodeNameEqual(ctxt->node, "disk")) { virReportError(VIR_ERR_XML_ERROR, _("expecting root element of 'disk', not '%s'"), - node->name); + ctxt->node->name); goto cleanup; } - flags |=3D VIR_DOMAIN_DEF_PARSE_DISK_SOURCE; - if (!(disk =3D virDomainDiskDefParseXML(xmlopt, node, ctxt, - NULL, def->seclabels, - def->nseclabels, - flags))) - goto cleanup; - - ret =3D disk->src; - disk->src =3D NULL; + disk =3D virDomainDiskDefParseXML(xmlopt, ctxt->node, ctxt, + NULL, def->seclabels, + def->nseclabels, + flags); cleanup: - virDomainDiskDefFree(disk); xmlFreeDoc(xml); xmlXPathFreeContext(ctxt); - return ret; + return disk; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 61379e50fe..650901c1f4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2935,10 +2935,10 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(const= char *xmlStr, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, unsigned int flags); -virStorageSourcePtr virDomainDiskDefSourceParse(const char *xmlStr, - const virDomainDef *def, - virDomainXMLOptionPtr xmlo= pt, - unsigned int flags); +virDomainDiskDefPtr virDomainDiskDefParse(const char *xmlStr, + const virDomainDef *def, + virDomainXMLOptionPtr xmlopt, + unsigned int flags); virDomainDefPtr virDomainDefParseString(const char *xmlStr, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 03fe3b315f..96a0a6de52 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -315,7 +315,7 @@ virDomainDiskDefCheckDuplicateInfo; virDomainDiskDefForeachPath; virDomainDiskDefFree; virDomainDiskDefNew; -virDomainDiskDefSourceParse; +virDomainDiskDefParse; virDomainDiskDetectZeroesTypeFromString; virDomainDiskDetectZeroesTypeToString; virDomainDiskDeviceTypeToString; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7bcc4936de..4e9add0ef7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17456,6 +17456,7 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *d= isk, const char *destxml, unsigned long long bandwidth =3D 0; unsigned int granularity =3D 0; unsigned long long buf_size =3D 0; + virDomainDiskDefPtr diskdef =3D NULL; virStorageSourcePtr dest =3D NULL; size_t i; @@ -17508,14 +17509,18 @@ qemuDomainBlockCopy(virDomainPtr dom, const char = *disk, const char *destxml, } } - if (!(dest =3D virDomainDiskDefSourceParse(destxml, vm->def, driver->x= mlopt, - VIR_DOMAIN_DEF_PARSE_INACTIVE= ))) + if (!(diskdef =3D virDomainDiskDefParse(destxml, vm->def, driver->xmlo= pt, + VIR_DOMAIN_DEF_PARSE_INACTIVE | + VIR_DOMAIN_DEF_PARSE_DISK_SOURCE= ))) goto cleanup; + VIR_STEAL_PTR(dest, diskdef->src); + ret =3D qemuDomainBlockCopyCommon(vm, dom->conn, disk, dest, bandwidth, granularity, buf_size, flags, false); cleanup: + virDomainDiskDefFree(diskdef); virDomainObjEndAPI(&vm); return ret; } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list