From nobody Mon Feb 9 14:17:03 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=1567611269; cv=none; d=zoho.com; s=zohoarc; b=hQjqY31dusOneU/c9CXMpfShPeqWyHbrllHKhj/37+0KvO8MyEaGxKNGqUDPu//w6+QBPxh4NAq3XMj8ouFieZ61hGWpevNanBXcPaMEZrKrZUwum0+x1QUEoAqUdGYBRiFdywgHajiBCxkngz5LvCFbbrlRA1ZaTI2cJuZSwsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567611269; 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=YrLY98sCmcHmELFIGI51Mcx+pcfthqeeC6gJYJjDkqI=; b=AalhK1KQkJAbS9qTwDAhf5L0Xp5BzFxUqPzBEbZO2kxp0XO/o0E3pkM6MbtUTSSHF2tfT5F933xyLG7AJBqbiTYiBhjNgtzWc2ykhyoJjWpgFwR2cidRg/AmQbGfpnCXdGEcVX7KoD49LqTxzLDuXg7WU3KZPBq+jGlJp7PjUWA= 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 1567611269855711.0599897807218; Wed, 4 Sep 2019 08:34:29 -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 ECA2B11A03; Wed, 4 Sep 2019 15:34:27 +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 9654560C57; Wed, 4 Sep 2019 15:34:27 +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 20AD5EEFE; Wed, 4 Sep 2019 15:34:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x84FYO3g028577 for ; Wed, 4 Sep 2019 11:34:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 07B0C60127; Wed, 4 Sep 2019 15:34:24 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 857ED600CD for ; Wed, 4 Sep 2019 15:34:23 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 4 Sep 2019 17:34:18 +0200 Message-Id: <202e67910d79b3f9cd6c9fc33f4f414071d90e74.1567611165.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] qemu: domain: Refactor cleanup 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: , 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.28]); Wed, 04 Sep 2019 15:34:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Use VIR_AUTOUNREF and get rid of the cleanup label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c7eb0b5e9a..8cb5e14ea4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10006,21 +10006,18 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr dri= ver, virStorageSourcePtr disksrc, bool report_broken) { - virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg =3D virQEMUDriverGetConfig(d= river); virStorageSourcePtr src; /* iterator for the backing chain declared in= XML */ virStorageSourcePtr n; /* iterator for the backing chain detected from= disk */ qemuDomainObjPrivatePtr priv =3D vm->privateData; - int ret =3D -1; uid_t uid; gid_t gid; if (!disksrc) disksrc =3D disk->src; - if (virStorageSourceIsEmpty(disksrc)) { - ret =3D 0; - goto cleanup; - } + if (virStorageSourceIsEmpty(disksrc)) + return 0; /* There is no need to check the backing chain for disks without backi= ng * support */ @@ -10032,13 +10029,13 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr dri= ver, if (report_broken) virStorageFileReportBrokenChain(errno, disksrc, disksrc); - goto cleanup; + return -1; } /* terminate the chain for such images as the code below would do = */ if (!disksrc->backingStore && !(disksrc->backingStore =3D virStorageSourceNew())) - goto cleanup; + return -1; /* host cdrom requires special treatment in qemu, so we need to ch= eck * whether a block device is a cdrom */ @@ -10048,8 +10045,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr drive= r, virFileIsCDROM(disksrc->path) =3D=3D 1) disksrc->hostcdrom =3D true; - ret =3D 0; - goto cleanup; + return 0; } src =3D disksrc; @@ -10059,16 +10055,16 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr dri= ver, int rv =3D virStorageFileSupportsAccess(src); if (rv < 0) - goto cleanup; + return -1; if (rv > 0) { if (qemuDomainStorageFileInit(driver, vm, src, disksrc) < = 0) - goto cleanup; + return -1; if (virStorageFileAccess(src, F_OK) < 0) { virStorageFileReportBrokenChain(errno, src, disksrc); virStorageFileDeinit(src); - goto cleanup; + return -1; } virStorageFileDeinit(src); @@ -10079,33 +10075,27 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr dri= ver, /* We skipped to the end of the chain. Skip detection if there's the * terminator. (An allocated but empty backingStore) */ - if (src->backingStore) { - ret =3D 0; - goto cleanup; - } + if (src->backingStore) + return 0; qemuDomainGetImageIds(cfg, vm, src, disksrc, &uid, &gid); if (virStorageFileGetMetadata(src, uid, gid, report_broken) < 0) - goto cleanup; + return -1; for (n =3D src->backingStore; virStorageSourceIsBacking(n); n =3D n->b= ackingStore) { if (qemuDomainValidateStorageSource(n, priv->qemuCaps) < 0) - goto cleanup; + return -1; if (qemuDomainPrepareDiskSourceData(disk, n, cfg, priv->qemuCaps) = < 0) - goto cleanup; + return -1; if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) && qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg) < 0) - goto cleanup; + return -1; } - ret =3D 0; - - cleanup: - virObjectUnref(cfg); - return ret; + return 0; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list