From nobody Tue Jul 1 07:52:21 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 1499788006216361.68612751762316; Tue, 11 Jul 2017 08:46:46 -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 3978EC04B92B; Tue, 11 Jul 2017 15:46:44 +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 CCAF077DE0; Tue, 11 Jul 2017 15:46:43 +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 0164E1853E31; Tue, 11 Jul 2017 15:46:42 +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 v6BFkeQn026829 for ; Tue, 11 Jul 2017 11:46:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6B41A177F2; Tue, 11 Jul 2017 15:46:40 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAD11177DA; Tue, 11 Jul 2017 15:46:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3978EC04B92B Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3978EC04B92B From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 11 Jul 2017 17:46:38 +0200 Message-Id: <30e2308692334c7278e784900710e53e0456aef3.1499787961.git.pkrempa@redhat.com> 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/5] qemu: driver: Split out access to VIR_DOMAIN_BLOCK_COPY_REUSE_EXT 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.31]); Tue, 11 Jul 2017 15:46:45 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Extract the presence of the flag into a boolean to simplify conditions and allow further manipulation of the state of the flag. Reviewed-by: John Ferlan --- src/qemu/qemu_driver.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a7019c53c..d03a9dbc3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16709,6 +16709,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, const char *format =3D NULL; int desttype =3D virStorageSourceGetActualType(mirror); virErrorPtr monitor_error =3D NULL; + bool reuse =3D !!(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT); /* Preliminaries: find the disk we are editing, sanity checks */ virCheckFlags(VIR_DOMAIN_BLOCK_COPY_SHALLOW | @@ -16769,8 +16770,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, /* unless the user provides a pre-created file, shallow copy into a raw * file is not possible */ - if ((flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW) && - !(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT) && + if ((flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW) && !reuse && mirror->format =3D=3D VIR_STORAGE_FILE_RAW) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("shallow copy of disk '%s' into a raw file " @@ -16791,15 +16791,14 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, virReportSystemError(errno, _("unable to stat for disk %s: %s"= ), disk->dst, mirror->path); goto endjob; - } else if (flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT || - desttype =3D=3D VIR_STORAGE_TYPE_BLOCK) { + } else if (reuse || desttype =3D=3D VIR_STORAGE_TYPE_BLOCK) { virReportSystemError(errno, _("missing destination file for disk %s: = %s"), disk->dst, mirror->path); goto endjob; } } else if (!S_ISBLK(st.st_mode)) { - if (st.st_size && !(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT)) { + if (st.st_size && !reuse) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("external destination file for disk %s alread= y " "exists and is not a block device: %s"), @@ -16816,7 +16815,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, } if (!mirror->format) { - if (!(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT)) { + if (!reuse) { mirror->format =3D disk->src->format; } else { /* If the user passed the REUSE_EXT flag, then either they @@ -16829,7 +16828,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, } /* pre-create the image file */ - if (!(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT)) { + if (!reuse) { int fd =3D qemuOpenFile(driver, vm, mirror->path, O_WRONLY | O_TRUNC | O_CREAT, &need_unlink, NULL); --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list