From nobody Thu May 15 07:24:26 2025 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 1527684167648792.2589992665618; Wed, 30 May 2018 05:42:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 024D1FCAC9; Wed, 30 May 2018 12:42:46 +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 B5AB2308BDAA; Wed, 30 May 2018 12:42:45 +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 1CA954A470; Wed, 30 May 2018 12:42:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4UCfwC7027562 for ; Wed, 30 May 2018 08:41:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id A03EB217B40A; Wed, 30 May 2018 12:41:58 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4505D217B409 for ; Wed, 30 May 2018 12:41:58 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 30 May 2018 14:41:14 +0200 Message-Id: <6c02f2c4d93eff8deec81839f1aad37fcf9399fc.1527683836.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 18/38] qemu: domain: don't loop through images in qemuDomainPrepareDiskSourceChain 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.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 30 May 2018 12:42:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Convert the function to just prepare data for the disk. Callers need to do the looping since there's more to do than just copy the data around. The code path in qemuDomainPrepareDiskSource doesn't need to loop over the chain yet, since there currently is no chain at this point. This will be addressed later in the blockdev series where we will setup much more stuff. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_domain.c | 63 +++++++++++++++++++++++-----------------------= ---- src/qemu/qemu_domain.h | 8 +++---- tests/qemublocktest.c | 6 ++--- 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e459e1eeee..d327440ec4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8017,6 +8017,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, { virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); virStorageSourcePtr src =3D disk->src; + virStorageSourcePtr n; qemuDomainObjPrivatePtr priv =3D vm->privateData; int ret =3D -1; uid_t uid; @@ -8099,9 +8100,10 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, report_broken) < 0) goto cleanup; - /* fill in data for the rest of the chain */ - if (qemuDomainPrepareDiskSourceChain(disk, src, cfg, priv->qemuCaps) <= 0) - goto cleanup; + for (n =3D src; virStorageSourceIsBacking(n); n =3D n->backingStore) { + if (qemuDomainPrepareDiskSourceData(disk, n, cfg, priv->qemuCaps) = < 0) + goto cleanup; + } ret =3D 0; @@ -12382,51 +12384,44 @@ qemuDomainCheckCCWS390AddressSupport(const virDom= ainDef *def, /** - * qemuDomainPrepareDiskSourceChain: + * qemuDomainPrepareDiskSourceData: * * @disk: Disk config object * @src: source to start from * @cfg: qemu driver config object * - * Prepares various aspects of the disk source and it's backing chain. This - * function should be also called for detected backing chains. If @src is = NULL - * the root source is used. + * Prepares various aspects of a storage source belonging to a disk backing + * chain. This function should be also called for detected backing chain + * members. */ int -qemuDomainPrepareDiskSourceChain(virDomainDiskDefPtr disk, - virStorageSourcePtr src, - virQEMUDriverConfigPtr cfg, - virQEMUCapsPtr qemuCaps) +qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk, + virStorageSourcePtr src, + virQEMUDriverConfigPtr cfg, + virQEMUCapsPtr qemuCaps) { - virStorageSourcePtr n; - - if (!src) - src =3D disk->src; - /* transfer properties valid only for the top level image */ if (src =3D=3D disk->src) src->detect_zeroes =3D disk->detect_zeroes; - for (n =3D src; virStorageSourceIsBacking(n); n =3D n->backingStore) { - if (cfg && - n->type =3D=3D VIR_STORAGE_TYPE_NETWORK && - n->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL)) { - n->debug =3D true; - n->debugLevel =3D cfg->glusterDebugLevel; - } + if (cfg && + src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && + src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL)) { + src->debug =3D true; + src->debugLevel =3D cfg->glusterDebugLevel; + } - if (qemuDomainValidateStorageSource(n, qemuCaps) < 0) - return -1; + if (qemuDomainValidateStorageSource(src, qemuCaps) < 0) + return -1; - /* transfer properties valid for the full chain */ - n->iomode =3D disk->iomode; - n->cachemode =3D disk->cachemode; - n->discard =3D disk->discard; + /* transfer properties valid for the full chain */ + src->iomode =3D disk->iomode; + src->cachemode =3D disk->cachemode; + src->discard =3D disk->discard; - if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) - n->floppyimg =3D true; - } + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) + src->floppyimg =3D true; return 0; } @@ -12476,7 +12471,7 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr dis= k, if (qemuDomainSecretDiskPrepare(priv, disk) < 0) return -1; - if (qemuDomainPrepareDiskSourceChain(disk, NULL, cfg, priv->qemuCaps) = < 0) + if (qemuDomainPrepareDiskSourceData(disk, disk->src, cfg, priv->qemuCa= ps) < 0) return -1; if (qemuDomainPrepareStorageSourcePR(disk->src, priv, disk->info.alias= ) < 0) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 3e139e0c57..36b000be60 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1003,10 +1003,10 @@ bool qemuDomainCheckCCWS390AddressSupport(const vir= DomainDef *def, const char *devicename); int -qemuDomainPrepareDiskSourceChain(virDomainDiskDefPtr disk, - virStorageSourcePtr src, - virQEMUDriverConfigPtr cfg, - virQEMUCapsPtr qemuCaps) +qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk, + virStorageSourcePtr src, + virQEMUDriverConfigPtr cfg, + virQEMUCapsPtr qemuCaps) ATTRIBUTE_RETURN_CHECK; int diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index d671505969..7f39f61018 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -215,13 +215,13 @@ testQemuDiskXMLToProps(const void *opaque) goto cleanup; } - if (qemuDomainPrepareDiskSourceChain(disk, NULL, NULL, data->qemuCaps)= < 0) - goto cleanup; - for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backingSt= ore) { if (testQemuDiskXMLToJSONFakeSecrets(n) < 0) goto cleanup; + if (qemuDomainPrepareDiskSourceData(disk, n, NULL, data->qemuCaps)= < 0) + goto cleanup; + if (!(formatProps =3D qemuBlockStorageSourceGetBlockdevProps(n)) || !(storageProps =3D qemuBlockStorageSourceGetBackendProps(n, fa= lse))) { if (!data->fail) { --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list