From nobody Sun Feb 8 22:07:47 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 ARC-Seal: i=1; a=rsa-sha256; t=1567519731; cv=none; d=zoho.com; s=zohoarc; b=McN3BJzWEfYAE/qIIUJuheIhGV47w7w/ogl/N2LRV+iSkhAT1FLDIJVvdZ9/JTgYRDZHe3Cpxu6aH9lq5Hw7iDDbFoGVWjPpQidBnKPx0cd92Pb3FY832ooZTjX/7aRf7C6lRmagN+QNa26E/GCQUs9wtGbHUQCgPUPNmgNW2L0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519731; 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:ARC-Authentication-Results; bh=vpe4ww9j2sLwramv6kkXbdmk4agviRVdAxLOl3Co3x8=; b=h21uI8eusIcaXWelBHZ9i51kr6sA4UicfrnpL1//jOeSlsirMnrspVBb36rseREnhigB1L7IHbK5N98U+I4DCUdTGBFd8PD8AuddCxivJp6+Dpyplt5U8VvWvFi7AM+NB+VTaKDAJfX8dlWIbl/LS0FhlNZcy3bVldSRBWE+3Pg= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1567519731370969.1887377631172; Tue, 3 Sep 2019 07:08:51 -0700 (PDT) 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 4528418C4290; Tue, 3 Sep 2019 14:08:50 +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 1595C60619; Tue, 3 Sep 2019 14:08:50 +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 CA56924F32; Tue, 3 Sep 2019 14:08:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8Kvs009576 for ; Tue, 3 Sep 2019 10:08:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 451DC100195C; Tue, 3 Sep 2019 14:08:20 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C237D10016EB for ; Tue, 3 Sep 2019 14:08:19 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:07:59 +0200 Message-Id: <6482fcab146af699bc7bf4a939f93da06897a64b.1567519340.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 06/18] qemu: command: Refactor qemuBuildStorageSourceChainAttachPrepareBlockdevInternal 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: , 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.6.2 (mx1.redhat.com [10.5.110.62]); Tue, 03 Sep 2019 14:08:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Extract the loop and supporting infrastructure to the caller as only one of the two callers actually cares about looping and rename the helper to qemuBuildStorageSourceChainAttachPrepareBlockdevOne. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 57 +++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1ca1ecd2f0..05c35919bf 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10720,33 +10720,23 @@ qemuBuildStorageSourceChainAttachPrepareDrive(vir= DomainDiskDefPtr disk, } -static qemuBlockStorageSourceChainDataPtr -qemuBuildStorageSourceChainAttachPrepareBlockdevInternal(virStorageSourceP= tr top, - virQEMUCapsPtr qe= muCaps, - bool onlyTop) +static int +qemuBuildStorageSourceChainAttachPrepareBlockdevOne(qemuBlockStorageSource= ChainData *data, + virStorageSourcePtr sr= c, + virQEMUCapsPtr qemuCap= s) { VIR_AUTOPTR(qemuBlockStorageSourceAttachData) elem =3D NULL; - VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; - virStorageSourcePtr n; - - if (VIR_ALLOC(data) < 0) - return NULL; - - for (n =3D top; virStorageSourceIsBacking(n); n =3D n->backingStore) { - if (!(elem =3D qemuBlockStorageSourceAttachPrepareBlockdev(n, true= ))) - return NULL; - if (qemuBuildStorageSourceAttachPrepareCommon(n, elem, qemuCaps) <= 0) - return NULL; + if (!(elem =3D qemuBlockStorageSourceAttachPrepareBlockdev(src, true))) + return -1; - if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem) < 0) - return NULL; + if (qemuBuildStorageSourceAttachPrepareCommon(src, elem, qemuCaps) < 0) + return -1; - if (onlyTop) - break; - } + if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem) < 0) + return -1; - VIR_RETURN_PTR(data); + return 0; } @@ -10762,8 +10752,18 @@ qemuBlockStorageSourceChainDataPtr qemuBuildStorageSourceChainAttachPrepareBlockdev(virStorageSourcePtr top, virQEMUCapsPtr qemuCaps) { - return qemuBuildStorageSourceChainAttachPrepareBlockdevInternal(top, q= emuCaps, - false); + VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; + virStorageSourcePtr n; + + if (VIR_ALLOC(data) < 0) + return NULL; + + for (n =3D top; virStorageSourceIsBacking(n); n =3D n->backingStore) { + if (qemuBuildStorageSourceChainAttachPrepareBlockdevOne(data, n, q= emuCaps) < 0) + return NULL; + } + + VIR_RETURN_PTR(data); } @@ -10779,6 +10779,13 @@ qemuBlockStorageSourceChainDataPtr qemuBuildStorageSourceChainAttachPrepareBlockdevTop(virStorageSourcePtr to= p, virQEMUCapsPtr qemuCap= s) { - return qemuBuildStorageSourceChainAttachPrepareBlockdevInternal(top, q= emuCaps, - true); + VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; + + if (VIR_ALLOC(data) < 0) + return NULL; + + if (qemuBuildStorageSourceChainAttachPrepareBlockdevOne(data, top, qem= uCaps) < 0) + return NULL; + + VIR_RETURN_PTR(data); } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list