From nobody Thu May 15 09:58:24 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1511526095808930.3980232997422; Fri, 24 Nov 2017 04:21:35 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 9514C61BB4; Fri, 24 Nov 2017 12:21:34 +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 65EA5183F9; Fri, 24 Nov 2017 12:21:34 +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 D84734BB79; Fri, 24 Nov 2017 12:21:33 +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 vAOCLUCe007308 for ; Fri, 24 Nov 2017 07:21:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7062E1802E; Fri, 24 Nov 2017 12:21:30 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id C097C5C88A; Fri, 24 Nov 2017 12:21:29 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 24 Nov 2017 13:21:01 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 1/3] qemu: domain: Refactor control flow in qemuDomainDetermineDiskChain 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 24 Nov 2017 12:21:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Split out clearing of the backing chain prior to other code since it will be required later and optimize few layers of nested conditions and loops. Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2bda4a726b..0e6ebdc0a8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6151,29 +6151,26 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr drive= r, goto cleanup; } - if (virStorageSourceHasBacking(src)) { - if (force_probe) { - virStorageSourceBackingStoreClear(src); - } else { - /* skip to the end of the chain */ - while (virStorageSourceIsBacking(src)) { - if (report_broken && - virStorageFileSupportsAccess(src)) { - - if (qemuDomainStorageFileInit(driver, vm, src, disk->s= rc) < 0) - goto cleanup; - - if (virStorageFileAccess(src, F_OK) < 0) { - virStorageFileReportBrokenChain(errno, src, disk->= src); - virStorageFileDeinit(src); - goto cleanup; - } + if (force_probe) + virStorageSourceBackingStoreClear(src); - virStorageFileDeinit(src); - } - src =3D src->backingStore; + /* skip to the end of the chain if there is any */ + while (virStorageSourceHasBacking(src)) { + if (report_broken && + virStorageFileSupportsAccess(src)) { + + if (qemuDomainStorageFileInit(driver, vm, src, disk->src) < 0) + goto cleanup; + + if (virStorageFileAccess(src, F_OK) < 0) { + virStorageFileReportBrokenChain(errno, src, disk->src); + virStorageFileDeinit(src); + goto cleanup; } + + virStorageFileDeinit(src); } + src =3D src->backingStore; } /* We skipped to the end of the chain. Skip detection if there's the --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list