From nobody Wed Apr 24 22:03:37 2024 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=1565280188; cv=none; d=zoho.com; s=zohoarc; b=OnA/gV9P3uFj5KKGDcnLeHEwhe0WU+OZHDvDYu8SH9DEEWDZ1r8prn/N18jypPkiuJCBT1IW7M+dmEc2PhXuYaGs4GH9i4TjPKOqItO7zMsQnLkRZmdiwEI/tslj7zledJ9tOqXsrWA+Awhu4BCJ7ukZ6muMidnJd3cWW6st+IY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565280188; 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=E+McT9fnrWkpmM5bMf3djMhQosa+eBfQbgxDQJWd6Xw=; b=iqt6BUdRp1HzeQcskHZHiclF/MNfxBL+HmLE5d61bJW1LvRnoSG3GeSbgB8p5VQo8n0C3gSWhyS9zYJ8va1yXFrsAv9/5vou2B3QcMVhlbJOJyt33zmWLKmCrNE4lGNpNPuro/XLrnPbBJMlioHd4tNqRXj05TYZBorq7WKovkI= 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 1565280188018133.8476138328591; Thu, 8 Aug 2019 09:03:08 -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 9D28230C0619; Thu, 8 Aug 2019 16:03:06 +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 64DFE60A35; Thu, 8 Aug 2019 16:03:06 +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 D603E18005C7; Thu, 8 Aug 2019 16:03:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78G0lhU005360 for ; Thu, 8 Aug 2019 12:00:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3FC9C165D9; Thu, 8 Aug 2019 16:00:47 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE4BDF6EE for ; Thu, 8 Aug 2019 16:00:46 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:00:31 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/12] qemu: domain: Allow formatting top source only in qemuDomainObjPrivateXMLFormatBlockjobFormatChain 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.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 08 Aug 2019 16:03:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rename qemuDomainObjPrivateXMLFormatBlockjobFormatChain to qemuDomainObjPrivateXMLFormatBlockjobFormatSource and add a 'chain' parameter which allows controlling whether the backing chain is formatted. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0555caa6ab..e1da0661e6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2315,10 +2315,11 @@ typedef struct qemuDomainPrivateBlockJobFormatData { static int -qemuDomainObjPrivateXMLFormatBlockjobFormatChain(virBufferPtr buf, - const char *chainname, - virStorageSourcePtr src, - virDomainXMLOptionPtr xml= opt) +qemuDomainObjPrivateXMLFormatBlockjobFormatSource(virBufferPtr buf, + const char *element, + virStorageSourcePtr src, + virDomainXMLOptionPtr xm= lopt, + bool chain) { VIR_AUTOCLEAN(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; VIR_AUTOCLEAN(virBuffer) childBuf =3D VIR_BUFFER_INITIALIZER; @@ -2333,10 +2334,11 @@ qemuDomainObjPrivateXMLFormatBlockjobFormatChain(vi= rBufferPtr buf, if (virDomainDiskSourceFormat(&childBuf, src, "source", 0, true, xmlfl= ags, xmlopt) < 0) return -1; - if (virDomainDiskBackingStoreFormat(&childBuf, src, xmlopt, xmlflags) = < 0) + if (chain && + virDomainDiskBackingStoreFormat(&childBuf, src, xmlopt, xmlflags) = < 0) return -1; - if (virXMLFormatElement(buf, chainname, &attrBuf, &childBuf) < 0) + if (virXMLFormatElement(buf, element, &attrBuf, &childBuf) < 0) return -1; return 0; @@ -2375,17 +2377,19 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void = *payload, virBufferAddLit(&childBuf, "/>\n"); } else { if (job->chain && - qemuDomainObjPrivateXMLFormatBlockjobFormatChain(&chainsBuf, - "disk", - job->chain, - data->xmlopt)= < 0) + qemuDomainObjPrivateXMLFormatBlockjobFormatSource(&chainsBuf, + "disk", + job->chain, + data->xmlopt, + true) < 0) return -1; if (job->mirrorChain && - qemuDomainObjPrivateXMLFormatBlockjobFormatChain(&chainsBuf, - "mirror", - job->mirrorCh= ain, - data->xmlopt)= < 0) + qemuDomainObjPrivateXMLFormatBlockjobFormatSource(&chainsBuf, + "mirror", + job->mirrorC= hain, + data->xmlopt, + true) < 0) return -1; if (virXMLFormatElement(&childBuf, "chains", NULL, &chainsBuf) < 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 22:03:37 2024 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=1565280193; cv=none; d=zoho.com; s=zohoarc; b=PasSCf01jMA9KjUYm0HCEsj4VxW18ICwCX5Gm6fZtvYp5fHYkzBmGJpwKUAHo2KWOiD7iRkxi7GKYrTZ5O+7LuwWyTWy1QiAnih4qqhGJTh/jPNHgAFbZkndbCvg0KRzP++/Vs+S249fcVpUosYcauqI5AwxyWMi+twhwBnrMgs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565280193; 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=PiKSWqkMxgLhILaq/vhGUy0EB+KXlLRFKmUE6CUtU0w=; b=SLEj1BCUGAnWaVNOg9Ja8jY7yYfp/cy2FkYz3qvZt22cRMBiz+zATSE0ogyW/GwLXbPTIAlS/80L8ZUtF8bsjQPKe4MhlgQdp9Xyazgyy3npUIICZblp20hBcaaCrGcH6znYwE3Yr2qM86GDV39ltXmhzDpTUP269eoCgnu4g8E= 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 1565280193220564.6582125829436; Thu, 8 Aug 2019 09:03:13 -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 B74748E592; Thu, 8 Aug 2019 16:03:11 +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 742E060A35; Thu, 8 Aug 2019 16:03:11 +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 1B2262551D; Thu, 8 Aug 2019 16:03:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78G0msE005370 for ; Thu, 8 Aug 2019 12:00:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E859F6F9; Thu, 8 Aug 2019 16:00:48 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D0E93DB4 for ; Thu, 8 Aug 2019 16:00:47 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:00:32 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/12] qemu: Fix logic in qemuDomainBlockCopyCommonValidateUserMirrorBackingStore 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.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 08 Aug 2019 16:03:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Allow reusing original backing chain when doing a shallow copy without reuse of external image. The existing logic didn't allow it but it will be possible. Also add a note to explain that logic. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ff83d1c024..3e0aa1b90f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18263,19 +18263,23 @@ qemuDomainBlockCopyCommonValidateUserMirrorBackin= gStore(virStorageSourcePtr mirr { /* note that if original disk does not have backing chain, shallow is = cleared */ bool shallow =3D flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW; - bool reuse =3D flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT; - if (!mirror->backingStore) { - /* deep copy won't need backing store so we can terminate it */ - if (!shallow && + if (!virStorageSourceHasBacking(mirror)) { + /* for deep copy there won't be backing chain so we can terminate = it */ + if (!mirror->backingStore && + !shallow && !(mirror->backingStore =3D virStorageSourceNew())) return -1; - return 0; - } - - /* validate user provided backing store */ - if (virStorageSourceHasBacking(mirror)) { + /* When reusing an external image we document that the user must e= nsure + * that the image must expose data as the original image = did + * either by providing correct chain or prepopulating the image. T= his + * means we can't validate this any more regardless of whether sha= llow + * copy is requested. + * + * For a copy when we are not reusing external image requesting sh= allow + * is okay and will inherit the original backing chain */ + } else { if (!blockdev) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("backingStore of mirror target is not support= ed by this qemu")); @@ -18287,13 +18291,6 @@ qemuDomainBlockCopyCommonValidateUserMirrorBacking= Store(virStorageSourcePtr mirr _("backingStore of mirror without VIR_DOMAIN_BL= OCK_COPY_SHALLOW doesn't make sense")); return -1; } - } else { - /* shallow copy without reuse requires some kind of backing data */ - if (!reuse && shallow) { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("VIR_DOMAIN_BLOCK_COPY_SHALLOW implies backin= g chain for mirror")); - return -1; - } } return 0; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 22:03:37 2024 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=1565280053; cv=none; d=zoho.com; s=zohoarc; b=JIkO4CusSwWd6h1mvHHnzHbxMMfoPbgHuFm7TevRD6d+cALUzPb0xIirSn52QQcDlBZG7SbZOv8G95f12/OzETOuZLWDFQ1oY6PhbNynt4w2jbkMHFQ24e57CbmcuENu+2/aeGEHyBpnSQlU6joIrw69f++TbTbAQ6Bp1oOoHFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565280053; 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=KBQmakl2ncREByVsAJ11TYSx1LKQa817pr/Qt7lLJo8=; b=GmhfJyHtGhs0bWA/sPUMdnwLsbFH7iXmYxSQ1dDqOARGn6PE4nD+/3hPo7kqg4wxKSN65cb2xznRP1ZAVYLoPxY9tRmclV6kSOAEETk9oBq7TBg0iccgNYgDdVjB3++EwTMG017AwPDu96Fv6xkUCE5YOHulH44EsHhYHmqLzDc= 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 1565280053603951.2943886066794; Thu, 8 Aug 2019 09:00:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8980A309BF1D; Thu, 8 Aug 2019 16:00:51 +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 4EB92F6E6; Thu, 8 Aug 2019 16:00:51 +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 58D2B24F33; Thu, 8 Aug 2019 16:00:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78G0m2T005376 for ; Thu, 8 Aug 2019 12:00:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id D1AB03DB4; Thu, 8 Aug 2019 16:00:48 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B4A3F6F9 for ; Thu, 8 Aug 2019 16:00:48 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:00:33 +0200 Message-Id: <27e76fc625b183824f0a2dfd0eb1322199625d9e.1565279921.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/12] qemu: fix broken handling of shallow flag in qemuDomainBlockCopyCommon 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 08 Aug 2019 16:00:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Commit 16ca234b56fac82 refactored how the 'shallow' and 'reuse' flags are accessed but neglected to fix the clearing of 'shallow' in case when the disk has no backing chain. This means that we'd request a shallow copy even without backing chain and also a few checks would work wrong. Fix it by using the extracted variable everywhere. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3e0aa1b90f..2c03cc5dff 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18258,12 +18258,9 @@ qemuDomainBlockCopyValidateMirror(virStorageSource= Ptr mirror, */ static int qemuDomainBlockCopyCommonValidateUserMirrorBackingStore(virStorageSourcePt= r mirror, - unsigned int flags, + bool shallow, bool blockdev) { - /* note that if original disk does not have backing chain, shallow is = cleared */ - bool shallow =3D flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW; - if (!virStorageSourceHasBacking(mirror)) { /* for deep copy there won't be backing chain so we can terminate = it */ if (!mirror->backingStore && @@ -18376,9 +18373,10 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, /* clear the _SHALLOW flag if there is only one layer */ if (!virStorageSourceHasBacking(disk->src)) - flags &=3D ~VIR_DOMAIN_BLOCK_COPY_SHALLOW; + mirror_shallow =3D false; - if (qemuDomainBlockCopyCommonValidateUserMirrorBackingStore(mirror, fl= ags, + if (qemuDomainBlockCopyCommonValidateUserMirrorBackingStore(mirror, + mirror_sha= llow, blockdev) = < 0) goto endjob; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 22:03:37 2024 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=1565280064; cv=none; d=zoho.com; s=zohoarc; b=MwvuEl/Nu1Q60+QRoWO+Y6ZSDMRBNGsJry3DyRZlEbbmKswX50iwI5xImJWBFI/GG40xtMj+B/UkdQ/gLTgOhVkYRTaGK8BgVxUsfxyZgheFRuy0g4hEF/3poVshuI9xBTZbmlqhMAAhhSeC8MABf+ADBC+qdifUnzLsVomFxLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565280064; 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=P9bLiNmL1RdKj77bxTCSRpUFzc+4XOM2HKhyai8tih0=; b=lbL7utScOSwu44oSWPWDDJ/9Y7txRGStn6dmSGj1dxD3f9ImLiDuQhKU7AlSqa24072/vy/33DOxDhtQgJxEodgAYVhwt/M13ZPpQL1JHr9hiRJHwhpBBh3ud5ku//KkBqg0sw8285ilYzTgGZIxFkl6Ync5VijLlG6ml2Ck1N8= 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 15652800647951000.8435250755285; Thu, 8 Aug 2019 09:01:04 -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 C733030A7BA7; Thu, 8 Aug 2019 16:01:02 +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 70EB060610; Thu, 8 Aug 2019 16:01:02 +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 DFE64180B536; Thu, 8 Aug 2019 16:01:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78G0npM005385 for ; Thu, 8 Aug 2019 12:00:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id A06C0166BB; Thu, 8 Aug 2019 16:00:49 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A7E6166A7 for ; Thu, 8 Aug 2019 16:00:49 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:00:34 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/12] util: storage: Refactor logic for using virStorageFileGetBackendForSupportCheck 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.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 08 Aug 2019 16:01:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Modify the return value so that callers don't have to repeat logic. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index a6de6a1e45..5882d470de 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4411,6 +4411,14 @@ virStorageFileIsInitialized(const virStorageSource *= src) } +/** + * virStorageFileGetBackendForSupportCheck: + * @src: storage source to check support for + * @backend: pointer to the storage backend for @src if it's supported + * + * Returns 0 if @src is not supported by any storage backend currently lin= ked + * 1 if it is supported and -1 on error with an error reported. + */ static int virStorageFileGetBackendForSupportCheck(const virStorageSource *src, virStorageFileBackendPtr *backend) @@ -4425,7 +4433,7 @@ virStorageFileGetBackendForSupportCheck(const virStor= ageSource *src, if (src->drv) { *backend =3D src->drv->backend; - return 0; + return 1; } actualType =3D virStorageSourceGetActualType(src); @@ -4433,7 +4441,10 @@ virStorageFileGetBackendForSupportCheck(const virSto= rageSource *src, if (virStorageFileBackendForType(actualType, src->protocol, false, bac= kend) < 0) return -1; - return 0; + if (!*backend) + return 0; + + return 1; } @@ -4443,12 +4454,8 @@ virStorageFileSupportsBackingChainTraversal(virStora= geSourcePtr src) virStorageFileBackendPtr backend; int rv; - rv =3D virStorageFileGetBackendForSupportCheck(src, &backend); - if (rv < 0) - return -1; - - if (!backend) - return 0; + if ((rv =3D virStorageFileGetBackendForSupportCheck(src, &backend)) < = 1) + return rv; return backend->storageFileGetUniqueIdentifier && backend->storageFileRead && @@ -4470,11 +4477,8 @@ virStorageFileSupportsSecurityDriver(const virStorag= eSource *src) virStorageFileBackendPtr backend; int rv; - rv =3D virStorageFileGetBackendForSupportCheck(src, &backend); - if (rv < 0) - return -1; - if (backend =3D=3D NULL) - return 0; + if ((rv =3D virStorageFileGetBackendForSupportCheck(src, &backend)) < = 1) + return rv; return backend->storageFileChown ? 1 : 0; } @@ -4492,13 +4496,10 @@ int virStorageFileSupportsAccess(const virStorageSource *src) { virStorageFileBackendPtr backend; - int ret; + int rv; - ret =3D virStorageFileGetBackendForSupportCheck(src, &backend); - if (ret < 0) - return -1; - if (backend =3D=3D NULL) - return 0; + if ((rv =3D virStorageFileGetBackendForSupportCheck(src, &backend)) < = 1) + return rv; return backend->storageFileAccess ? 1 : 0; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 22:03:37 2024 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=1565280070; cv=none; d=zoho.com; s=zohoarc; b=dUJ0Ox8x9IVKs/Q4BnbuLtUywx7dMLup12XaHguRPN+6jl+ecFuB5xsMY9EPWSq6NgJhXHqOcpyoPUX9BkdL3zI2v2cFWA8Q5FGCH614K4QTTx90BJic4O5ZZWEa2FlpDOy4ap+r2zYgBh9uh2isns7mqjJu6t4mfQ6k5mwCqrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565280070; 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=2gjvtOSyogxIPf73wP4J/DvF7/zLOVfU/F8R9694n1A=; b=AOOZY/OfqNtT42iOOMGKSoste2GwRGIP9n+CnnMfRjaUzOymieIK3wN4Nlw3opGUZzyG81w9TaJJMhyg+9K/Ha+NP8iYHy9lTSxgF5HZtk0t6puGW4sF8xP2Rn1B254mY7d6l2szQXNms6/1E1ot0vp4dHuGA02zUrfKj8nLVOo= 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 1565280070796866.001623169421; Thu, 8 Aug 2019 09:01:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C72FC99C42; Thu, 8 Aug 2019 16:01:08 +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 8E1A661F27; Thu, 8 Aug 2019 16:01:08 +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 0CAD324F37; Thu, 8 Aug 2019 16:01:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78G0oih005393 for ; Thu, 8 Aug 2019 12:00:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 70354F6E6; Thu, 8 Aug 2019 16:00:50 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE70A16BE2 for ; Thu, 8 Aug 2019 16:00:49 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:00:35 +0200 Message-Id: <0f899ac954e3b037b3507b214ed46e01f3a34044.1565279921.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/12] util: storage: Allow checking whether virStorageFileCreate is supported 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 08 Aug 2019 16:01:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add virStorageFileSupportsCreate which allows silent check whether virStorageFileCreate is implemented. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/util/virstoragefile.c | 20 ++++++++++++++++++++ src/util/virstoragefile.h | 1 + 3 files changed, 22 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index cae8febf8d..b86868e954 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2995,6 +2995,7 @@ virStorageFileReportBrokenChain; virStorageFileResize; virStorageFileStat; virStorageFileSupportsAccess; +virStorageFileSupportsCreate; virStorageFileSupportsSecurityDriver; virStorageFileUnlink; virStorageIsFile; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 5882d470de..ba56f452e9 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4505,6 +4505,26 @@ virStorageFileSupportsAccess(const virStorageSource = *src) } +/** + * virStorageFileSupportsCreate: + * @src: a storage file structure + * + * Check if the storage driver supports creating storage described by @src + * via virStorageFileCreate. + */ +int +virStorageFileSupportsCreate(const virStorageSource *src) +{ + virStorageFileBackendPtr backend; + int rv; + + if ((rv =3D virStorageFileGetBackendForSupportCheck(src, &backend)) < = 1) + return rv; + + return backend->storageFileCreate ? 1 : 0; +} + + void virStorageFileDeinit(virStorageSourcePtr src) { diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 38ba901858..2882bacf3e 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -532,6 +532,7 @@ int virStorageFileChown(const virStorageSource *src, ui= d_t uid, gid_t gid); int virStorageFileSupportsSecurityDriver(const virStorageSource *src); int virStorageFileSupportsAccess(const virStorageSource *src); +int virStorageFileSupportsCreate(const virStorageSource *src); int virStorageFileGetMetadata(virStorageSourcePtr src, uid_t uid, gid_t gid, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 22:03:37 2024 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=1565280063; cv=none; d=zoho.com; s=zohoarc; b=S4ahEfuQ6mK9/+8TagiT4fmQbElLzWzNYXEZx+fBX2Vnw+Av1+hBlhKNzy91kkkzbsAsxnAIEHv10DH76nRS2ZZJaY2Uoi7LtuBgMY2wy8W1pACDyP25ft8u5nyMCjHO6dmZ1fMVBlcAdq2hf3ru7XktwIIgHp9FULd68OS8Kqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565280063; 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=K1F+miJqsVjq2X6bxLdnfl3Aj7yT2u+ERruKJsSyvu8=; b=gXPktqj+5hTrpoxPWmMvKMngmz3/O4OIfWbh3VaA2jglzlwHkdr5XCs5BrMC5kVwvTl6ItmorV7c59B3MQ7fS/bQ6ctSTO3ReZnuGh1NTr8JN/+4eeyqqqqzCLlz00tzQUWHZ/+Xu4/HbN+0Qew0qvqLEm6JTtrh+1ukKlLmTlk= 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 1565280063967980.8855370281964; Thu, 8 Aug 2019 09:01:03 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 87874309BF02; Thu, 8 Aug 2019 16:01:02 +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 2F923600CC; Thu, 8 Aug 2019 16:01:02 +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 920541806B01; Thu, 8 Aug 2019 16:01:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78G0pg7005406 for ; Thu, 8 Aug 2019 12:00:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 44BC3166A7; Thu, 8 Aug 2019 16:00:51 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD100F6E6 for ; Thu, 8 Aug 2019 16:00:50 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:00:36 +0200 Message-Id: <484eefa24b1a446c0f47ad1bd09714b6561c06f8.1565279921.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/12] qemu: blockjob: Remove qemuBlockJobDiskRegisterMirror 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 08 Aug 2019 16:01:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The utility of the function is extremely limited as for block copy we need to register the mirror chain earlier than when it's set with the disk. This means that it would be open-coded in that case. Avoid any weird usage and just open-code the only current usage, remove the function, and reword the docs. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 20 +------------------- src/qemu/qemu_blockjob.h | 4 ---- src/qemu/qemu_domain.c | 2 +- 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index a5b558b9ab..8303567aed 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -129,7 +129,7 @@ qemuBlockJobDataNew(qemuBlockJobType type, * xml (if @savestatus is true). * * Note that if @job also references a separate chain e.g. for disk mirror= ing, - * then qemuBlockJobDiskRegisterMirror should be used separately. + * then job->mirrorchain needs to be set manually. */ int qemuBlockJobRegister(qemuBlockJobDataPtr job, @@ -274,24 +274,6 @@ qemuBlockJobDiskNewCommit(virDomainObjPtr vm, } -/** - * qemuBlockJobDiskRegisterMirror: - * @job: block job to register 'mirror' chain on - * - * In cases when the disk->mirror attribute references a separate storage = chain - * such as for block-copy, this function registers it with the job. Note - * that this function does not save the status XML and thus must be used b= efore - * qemuBlockJobRegister or qemuBlockJobStarted to properly track the chain - * in the status XML. - */ -void -qemuBlockJobDiskRegisterMirror(qemuBlockJobDataPtr job) -{ - if (job->disk) - job->mirrorChain =3D virObjectRef(job->disk->mirror); -} - - /** * qemuBlockJobDiskGetJob: * @disk: disk definition diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index 8139a1a324..5b740db5a8 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -134,10 +134,6 @@ qemuBlockJobDiskNew(virDomainObjPtr vm, const char *jobname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4); -void -qemuBlockJobDiskRegisterMirror(qemuBlockJobDataPtr job) - ATTRIBUTE_NONNULL(1); - qemuBlockJobDataPtr qemuBlockJobDiskNewPull(virDomainObjPtr vm, virDomainDiskDefPtr disk, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e1da0661e6..50dc4f3764 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2976,7 +2976,7 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObj= Ptr vm, job->disk =3D disk; if (mirror) - qemuBlockJobDiskRegisterMirror(job); + job->mirrorChain =3D virObjectRef(job->disk->mirror); qemuDomainObjPrivateXMLParseBlockjobDataSpecific(job, ctxt); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 22:03:37 2024 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=1565280077; cv=none; d=zoho.com; s=zohoarc; b=i78GLfpL3QBz4OnzuNG4WnaCks7PFUzPV0S5Fk2cnkIBpOt0OzuJsqMefAQRK9/LI0DNLLg2p1Yt3vvqJ5qsbc7DsBWTjtEVdeThm9QZ04/b93Y30JmGxmbD3S3MKZ3i3yU0g5ynmr0lQMnrwbig5eNG9nOcTbn0dFqDp/neGzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565280077; 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=QsR2LMgIYDTKc9jadSBbxfWucQrmEbD13hLMchaNNKM=; b=JEq18XytQ4qXXOX4Q2pc7aIC8V4BUUk8i4Rx/etLpqU8B5QhgV8qX5vpW3Nw9lNWycJG1ep3Y+NLPoU54XTl7NDpuxcgQdW1J6KtM9FiM3zx00MfmnSi/8ku6Xv7faKyiVGOuseTNS6bVwOCrY8K9agM39X04ymljkPbICcxcVc= 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 1565280077060212.4973579685916; Thu, 8 Aug 2019 09:01:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ABA01306F4AE; Thu, 8 Aug 2019 16:01:14 +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 6EDC360127; Thu, 8 Aug 2019 16:01:14 +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 0D5E0180BA9E; Thu, 8 Aug 2019 16:01:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78G0qPi005415 for ; Thu, 8 Aug 2019 12:00:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1037C3DB4; Thu, 8 Aug 2019 16:00:52 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BEBF16BE2 for ; Thu, 8 Aug 2019 16:00:51 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:00:37 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/12] qemu: domain: Add 'break' after formatting commit job status XML 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 08 Aug 2019 16:01:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In commit 3f93884a4d0 where the job handling of commit jobs with blockdev was added I've forgot to add a 'break' in the switch fomatting the status XML. Thankfully this would not be a problem as the cases where this fell through didn't have any code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 50dc4f3764..2e722f4ee4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2410,6 +2410,8 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void *p= ayload, virBufferAsprintf(&childBuf, "\n", job->= data.commit.top->nodeformat); if (job->data.commit.topparent) virBufferAsprintf(&childBuf, "\n",= job->data.commit.topparent->nodeformat); + break; + case QEMU_BLOCKJOB_TYPE_COPY: case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 22:03:37 2024 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=1565280197; cv=none; d=zoho.com; s=zohoarc; b=DMFVG12cYaoz8eqM+GnK7v3oC5BAM7eLz1foEtCmai9FDEkjOys6wbp12smiDapIWexQu/lmsFMJNolaIOkaGkMoQQFmYPUn3CTlBczs+c6odvcYV3HsPedMZC2zRaT1tUPJgTZ8cDPFD/zeVStrM+iGbFjv0tFy7EcidVlLpgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565280197; 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=5HokFdBAGhos3x361U58Y19YsZYYELkngBhViTrWgPs=; b=E1gLGULEl5iKuoTSrcncOolmbOs0MhfAucsTAknrfOqmDN1/ox9ZYqmRwJ4oAF4l7CdBnq2Drg/v95fXK46eWXBRCxCszCg+yrJpZ6OujnbvsyObuvnqO8PcPUVlqBpMWBprEklSiv9L/C+sBH8L/8BOATzV2U14Mwp9qig6qyU= 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 1565280197740982.5421021653558; Thu, 8 Aug 2019 09:03:17 -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 6969D30B27A3; Thu, 8 Aug 2019 16:03:16 +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 2C02F608AB; Thu, 8 Aug 2019 16:03:16 +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 DE5DF18005C7; Thu, 8 Aug 2019 16:03:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78G0qmO005430 for ; Thu, 8 Aug 2019 12:00:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id D0048F6E6; Thu, 8 Aug 2019 16:00:52 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AA9D166BE for ; Thu, 8 Aug 2019 16:00:52 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:00:38 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/12] conf: domain: Parse backingStore with VIR_DOMAIN_DEF_PARSE_DISK_SOURCE 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.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 08 Aug 2019 16:03:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The only code path which calls the parser with the VIR_DOMAIN_DEF_PARSE_DISK_SOURCE is from qemuDomainBlockCopy. Since that code path can properly handle backing chains for the disk and it's desired to pass the parsed chains to the block copy code remove the condition which prevents parsing the element. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0456369d55..52a3dd4064 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10293,10 +10293,8 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xml= opt, VIR_STEAL_PTR(def->vendor, vendor); VIR_STEAL_PTR(def->product, product); - if (!(flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)) { - if (virDomainDiskBackingStoreParse(ctxt, def->src, flags, xmlopt) = < 0) - goto error; - } + if (virDomainDiskBackingStoreParse(ctxt, def->src, flags, xmlopt) < 0) + goto error; if (flags & VIR_DOMAIN_DEF_PARSE_STATUS && virDomainDiskDefParsePrivateData(ctxt, def, xmlopt) < 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 22:03:37 2024 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=1565280202; cv=none; d=zoho.com; s=zohoarc; b=hRu2rzRCwchKOlHHKkz570f5P/HshyjhplSZmlmWfKObusfDUwQT2DPvWFp21jGkxUXKVI/qyeVQ/Knw7R17OE6YYxxH9+OimjxtcEj+FU1x6paMuIjMWZDl4PLbIQCaybOFhYUq86A9FLEj8ZhiGkyawxfdSJRGnIlGOjTSsbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565280202; 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=PD0RaN+PEXEpoibuUOPcCpqcoSnhrUfjRvvrpyM6dBA=; b=R0vJ9ygsBF5q0E4sDpdBE1rlLjF2eHDwkFC8DcRPGMgMkhgXhP3u+GhhTeiU9vdH+CpcTzzrYh+VwchihYkaV6+aP1DVLobMPz42tepuKx4x7PICy4KAUn2lDmHO7oOh89CjgLevEpNEZgZSjED+UNNeeSD3eer5M6IbTDiFQ48= 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 1565280202049543.5489742577284; Thu, 8 Aug 2019 09:03:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B028EC0546D5; Thu, 8 Aug 2019 16:03:20 +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 76AFB5D70D; Thu, 8 Aug 2019 16:03:20 +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 292A5180BA9D; Thu, 8 Aug 2019 16:03:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78G0rCU005437 for ; Thu, 8 Aug 2019 12:00:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9F9D7165D9; Thu, 8 Aug 2019 16:00:53 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A635194BB for ; Thu, 8 Aug 2019 16:00:52 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:00:39 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/12] qemu: blockjob: Copy non-detected chain fully in qemuBlockJobRewriteConfigDiskSource 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 08 Aug 2019 16:03:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rather than copying just the top level image, let's copy the full user provided backing chain. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 8303567aed..6ac60e86d7 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -521,6 +521,7 @@ qemuBlockJobRewriteConfigDiskSource(virDomainObjPtr vm, { virDomainDiskDefPtr persistDisk =3D NULL; VIR_AUTOUNREF(virStorageSourcePtr) copy =3D NULL; + virStorageSourcePtr n; if (!vm->newDef) return; @@ -531,14 +532,24 @@ qemuBlockJobRewriteConfigDiskSource(virDomainObjPtr v= m, if (!virStorageSourceIsSameLocation(disk->src, persistDisk->src)) return; - if (!(copy =3D virStorageSourceCopy(newsrc, false)) || + if (!(copy =3D virStorageSourceCopy(newsrc, true)) || virStorageSourceInitChainElement(copy, persistDisk->src, true) < 0= ) { VIR_WARN("Unable to update persistent definition on vm %s after bl= ock job", vm->def->name); return; } - qemuBlockJobCleanStorageSourceRuntime(copy); + for (n =3D copy; virStorageSourceIsBacking(n); n =3D n->backingStore) { + qemuBlockJobCleanStorageSourceRuntime(n); + + /* discard any detected backing store */ + if (virStorageSourceIsBacking(n->backingStore) && + n->backingStore->detected) { + virObjectUnref(n->backingStore); + n->backingStore =3D NULL; + break; + } + } virObjectUnref(persistDisk->src); VIR_STEAL_PTR(persistDisk->src, copy); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 22:03:37 2024 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=1565280206; cv=none; d=zoho.com; s=zohoarc; b=JcZqEMTxzCwuqmZdDTpq/JdXFGa3lOSHrzSHVuuC8/fAZ+geLFyms6X9QsKpH2oSdR4IjZ+0PTDDdXJ3XXltY6XOEEuJXNnhfPIQRav8EWL2tIFV95VMZohFyhCdQYJIL/NOIJcsRqrl+M9A+4mGYaJ0K/1FEqq+ri+M7G2rgBs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565280206; 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=UYTqszyeXPEudkVMKxxilQ664Gs8sQJk8GUacgML9u0=; b=ft/b5ne8/pyhIDF2MqoQd2lJeogzQ56U3vAS6SnKtZ6r+lcMuGFdHZbfGYpRtRSlXkA1JbM/0PZiM6ECkooN3eYVMvJHRIvfDd2LhOkATYpRpq9ED6BVd4ghu66U0m2kIiFjVH7r6EqyRUfgcthpX+EiA5ICqPvZfAo1R9iwLEs= 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 1565280206197943.382815198477; Thu, 8 Aug 2019 09:03:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04FD630A922D; Thu, 8 Aug 2019 16:03:25 +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 D16695D772; Thu, 8 Aug 2019 16:03:24 +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 7FF6918005C7; Thu, 8 Aug 2019 16:03:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78G0sXH005442 for ; Thu, 8 Aug 2019 12:00:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 93CBB165D9; Thu, 8 Aug 2019 16:00:54 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECF3216BE2 for ; Thu, 8 Aug 2019 16:00:53 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:00:40 +0200 Message-Id: <43fa65cd8fbc232f4076bb2d770af96147630452.1565279921.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/12] qemu: Introduce code for blockdev-create 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 08 Aug 2019 16:03:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" QEMU finally exposes an interface which allows us to instruct it to format or create arbitrary images. This is required for blockdev integration of block copy and snapshots as we need to pre-format images prior to use with blockdev-add. This path introduces job handling and also helpers for formatting and attaching a whole image described by a virStorageSource. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 250 ++++++++++++++++++ src/qemu/qemu_block.h | 14 + src/qemu/qemu_blockjob.c | 88 +++++- src/qemu/qemu_blockjob.h | 17 ++ src/qemu/qemu_domain.c | 34 ++- src/qemu/qemu_driver.c | 1 + .../blockjob-blockdev-in.xml | 45 ++++ 7 files changed, 446 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 47661fb8bd..cb9a085e5d 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2379,3 +2379,253 @@ qemuBlockStorageSourceCreateGetStorageProps(virStor= ageSourcePtr src, return 0; } + + +static int +qemuBlockStorageSourceCreateGeneric(virDomainObjPtr vm, + virJSONValuePtr createProps, + virStorageSourcePtr src, + virStorageSourcePtr chain, + bool storageCreate, + qemuDomainAsyncJob asyncJob) +{ + VIR_AUTOPTR(virJSONValue) props =3D createProps; + qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuBlockJobDataPtr job =3D NULL; + int ret =3D -1; + int rc; + + if (!(job =3D qemuBlockJobNewCreate(vm, src, chain, storageCreate))) + return -1; + + qemuBlockJobSyncBegin(job); + + if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0) + goto cleanup; + + rc =3D qemuMonitorBlockdevCreate(priv->mon, job->name, props); + props =3D NULL; + + if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + goto cleanup; + + qemuBlockJobStarted(job, vm); + + qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE); + while (qemuBlockJobIsRunning(job)) { + if (virDomainObjWait(vm) < 0) + goto cleanup; + qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE); + } + + if (job->state =3D=3D QEMU_BLOCKJOB_STATE_FAILED || + job->state =3D=3D QEMU_BLOCKJOB_STATE_CANCELLED) { + if (job->state =3D=3D QEMU_BLOCKJOB_STATE_CANCELLED && !job->errms= g) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("blockdev-create job was cancelled")); + } else { + virReportError(VIR_ERR_OPERATION_FAILED, + _("failed to format image: '%s'"), NULLSTR(job-= >errmsg)); + } + goto cleanup; + } + + ret =3D 0; + + cleanup: + qemuBlockJobStartupFinalize(vm, job); + return ret; +} + + +static int +qemuBlockStorageSourceCreateStorage(virDomainObjPtr vm, + virStorageSourcePtr src, + virStorageSourcePtr chain, + qemuDomainAsyncJob asyncJob) +{ + int actualType =3D virStorageSourceGetActualType(src); + VIR_AUTOPTR(virJSONValue) createstorageprops =3D NULL; + int ret; + + /* we need to do stuff only for remote storage and local raw files */ + if (actualType !=3D VIR_STORAGE_TYPE_NETWORK && + !(actualType =3D=3D VIR_STORAGE_TYPE_FILE && src->format =3D=3D VI= R_STORAGE_FILE_RAW)) + return 0; + + if (qemuBlockStorageSourceCreateGetStorageProps(src, &createstoragepro= ps) < 0) + return -1; + + if (!createstorageprops) { + /* we can always try opening it to see whether it was existing */ + return 0; + } + + ret =3D qemuBlockStorageSourceCreateGeneric(vm, createstorageprops, sr= c, chain, + true, asyncJob); + createstorageprops =3D NULL; + + return ret; +} + + +static int +qemuBlockStorageSourceCreateFormat(virDomainObjPtr vm, + virStorageSourcePtr src, + virStorageSourcePtr backingStore, + virStorageSourcePtr chain, + qemuDomainAsyncJob asyncJob) +{ + VIR_AUTOPTR(virJSONValue) createformatprops =3D NULL; + int ret; + + if (src->format =3D=3D VIR_STORAGE_FILE_RAW) + return 0; + + if (qemuBlockStorageSourceCreateGetFormatProps(src, backingStore, + &createformatprops) < 0) + return -1; + + if (!createformatprops) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("can't create storage format '%s'"), + virStorageFileFormatTypeToString(src->format)); + return -1; + } + + ret =3D qemuBlockStorageSourceCreateGeneric(vm, createformatprops, src= , chain, + false, asyncJob); + createformatprops =3D NULL; + + return ret; +} + + +/** + * qemuBlockStorageSourceCreate: + * @vm: domain object + * @src: storage source definition to create + * @backingStore: backingStore of the new image (used only in image metada= ta) + * @chain: backing chain to unplug in case of a long-running job failure + * @data: qemuBlockStorageSourceAttachData for @src so that it can be atta= ched + * @asyncJob: qemu asynchronous job type + * + * Creates and formats a storage volume according to @src and attaches it = to @vm. + * @data must provide attachment data as if @src was existing. @src is att= ached + * after successful return of this function. If libvirtd is restarted duri= ng + * the create job @chain is unplugged, otherwise it's left for the caller. + * If @backingStore is provided, the new image will refer to it as it's ba= cking + * store. + */ +int +qemuBlockStorageSourceCreate(virDomainObjPtr vm, + virStorageSourcePtr src, + virStorageSourcePtr backingStore, + virStorageSourcePtr chain, + qemuBlockStorageSourceAttachDataPtr data, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + int ret =3D -1; + int rc; + + if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0) + goto cleanup; + + rc =3D qemuBlockStorageSourceAttachApplyStorageDeps(priv->mon, data); + + if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + goto cleanup; + + if (qemuBlockStorageSourceCreateStorage(vm, src, chain, asyncJob) < 0) + goto cleanup; + + if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0) + goto cleanup; + + rc =3D qemuBlockStorageSourceAttachApplyStorage(priv->mon, data); + + if (rc =3D=3D 0) + rc =3D qemuBlockStorageSourceAttachApplyFormatDeps(priv->mon, data= ); + + if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + goto cleanup; + + if (qemuBlockStorageSourceCreateFormat(vm, src, backingStore, chain, + asyncJob) < 0) + goto cleanup; + + if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0) + goto cleanup; + + rc =3D qemuBlockStorageSourceAttachApplyFormat(priv->mon, data); + + if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + if (ret < 0 && + virDomainObjIsActive(vm) && + qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) =3D=3D = 0) { + + qemuBlockStorageSourceAttachRollback(priv->mon, data); + ignore_value(qemuDomainObjExitMonitor(priv->driver, vm)); + } + + return ret; +} + + +/** + * qemuBlockStorageSourceCreateDetectSize: + * @vm: domain object + * @src: storage source to update size/capacity on + * @templ: storage source template + * @asyncJob: qemu asynchronous job type + * + * When creating a storage source via blockdev-create we need to know the = size + * and capacity of the original volume (e.g. when creating a snapshot or c= opy). + * This function updates @src's 'capacity' and 'physical' attributes accor= ding + * to the detected sizes from @templ. + */ +int +qemuBlockStorageSourceCreateDetectSize(virDomainObjPtr vm, + virStorageSourcePtr src, + virStorageSourcePtr templ, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + VIR_AUTOPTR(virHashTable) stats =3D NULL; + qemuBlockStatsPtr entry; + int rc; + + if (!(stats =3D virHashCreate(10, virHashValueFree))) + return -1; + + if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0) + return -1; + + rc =3D qemuMonitorBlockStatsUpdateCapacityBlockdev(priv->mon, stats); + + if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + return -1; + + if (!(entry =3D virHashLookup(stats, templ->nodeformat))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to update capacity data for block node '%= s'"), + templ->nodeformat); + return -1; + } + + if (src->format =3D=3D VIR_STORAGE_FILE_RAW) { + src->physical =3D entry->capacity; + } else { + src->physical =3D entry->physical; + } + + src->capacity =3D entry->capacity; + + return 0; +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index ab6b9dc791..a5e970fa1e 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -182,3 +182,17 @@ int qemuBlockStorageSourceCreateGetStorageProps(virStorageSourcePtr src, virJSONValuePtr *props) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + +int +qemuBlockStorageSourceCreate(virDomainObjPtr vm, + virStorageSourcePtr src, + virStorageSourcePtr backingStore, + virStorageSourcePtr chain, + qemuBlockStorageSourceAttachDataPtr data, + qemuDomainAsyncJob asyncJob); + +int +qemuBlockStorageSourceCreateDetectSize(virDomainObjPtr vm, + virStorageSourcePtr src, + virStorageSourcePtr templ, + qemuDomainAsyncJob asyncJob); diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 6ac60e86d7..70550d17e7 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -65,7 +65,8 @@ VIR_ENUM_IMPL(qemuBlockjob, "copy", "commit", "active-commit", - ""); + "", + "create"); static virClassPtr qemuBlockJobDataClass; @@ -78,6 +79,9 @@ qemuBlockJobDataDispose(void *obj) virObjectUnref(job->chain); virObjectUnref(job->mirrorChain); + if (job->type =3D=3D QEMU_BLOCKJOB_TYPE_CREATE) + virObjectUnref(job->data.create.src); + VIR_FREE(job->name); VIR_FREE(job->errmsg); } @@ -274,6 +278,37 @@ qemuBlockJobDiskNewCommit(virDomainObjPtr vm, } +qemuBlockJobDataPtr +qemuBlockJobNewCreate(virDomainObjPtr vm, + virStorageSourcePtr src, + virStorageSourcePtr chain, + bool storage) +{ + VIR_AUTOUNREF(qemuBlockJobDataPtr) job =3D NULL; + VIR_AUTOFREE(char *) jobname =3D NULL; + const char *nodename =3D src->nodeformat; + + if (storage) + nodename =3D src->nodestorage; + + if (virAsprintf(&jobname, "create-%s", nodename) < 0) + return NULL; + + if (!(job =3D qemuBlockJobDataNew(QEMU_BLOCKJOB_TYPE_CREATE, jobname))) + return NULL; + + if (virStorageSourceIsBacking(chain)) + job->chain =3D virObjectRef(chain); + + job->data.create.src =3D virObjectRef(src); + + if (qemuBlockJobRegister(job, vm, NULL, true) < 0) + return NULL; + + VIR_RETURN_PTR(job); +} + + /** * qemuBlockJobDiskGetJob: * @disk: disk definition @@ -1007,6 +1042,49 @@ qemuBlockJobProcessEventCompletedActiveCommit(virQEM= UDriverPtr driver, job->disk->mirror =3D NULL; } + +static void +qemuBlockJobProcessEventConcludedCreate(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuBlockJobDataPtr job, + qemuDomainAsyncJob asyncJob) +{ + VIR_AUTOPTR(qemuBlockStorageSourceAttachData) backend =3D NULL; + + /* if there is a synchronous client waiting for this job that means th= at + * it will handle further hotplug of the created volume and also that + * the 'chain' which was registered is under their control */ + if (job->synchronous) { + virObjectUnref(job->chain); + job->chain =3D NULL; + return; + } + + if (!job->data.create.src) + return; + + if (!(backend =3D qemuBlockStorageSourceDetachPrepare(job->data.create= .src, NULL))) + return; + + /* the format node part was not attached yet, so we don't need to deta= ch it */ + backend->formatAttached =3D false; + if (job->data.create.storage) { + backend->storageAttached =3D false; + VIR_FREE(backend->encryptsecretAlias); + } + + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return; + + qemuBlockStorageSourceAttachRollback(qemuDomainGetMonitor(vm), backend= ); + + if (qemuDomainObjExitMonitor(driver, vm) < 0) + return; + + qemuDomainStorageSourceAccessRevoke(driver, vm, job->data.create.src); +} + + static void qemuBlockJobEventProcessConcludedTransition(qemuBlockJobDataPtr job, virQEMUDriverPtr driver, @@ -1028,6 +1106,10 @@ qemuBlockJobEventProcessConcludedTransition(qemuBloc= kJobDataPtr job, qemuBlockJobProcessEventCompletedActiveCommit(driver, vm, job,= asyncJob); break; + case QEMU_BLOCKJOB_TYPE_CREATE: + qemuBlockJobProcessEventConcludedCreate(driver, vm, job, async= Job); + break; + case QEMU_BLOCKJOB_TYPE_COPY: case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: @@ -1051,6 +1133,10 @@ qemuBlockJobEventProcessConcludedTransition(qemuBloc= kJobDataPtr job, } break; + case QEMU_BLOCKJOB_TYPE_CREATE: + qemuBlockJobProcessEventConcludedCreate(driver, vm, job, async= Job); + break; + case QEMU_BLOCKJOB_TYPE_COPY: case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index 5b740db5a8..ff3c4a9eb7 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -62,6 +62,7 @@ typedef enum { QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT =3D VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_= COMMIT, /* Additional enum values local to qemu */ QEMU_BLOCKJOB_TYPE_INTERNAL, + QEMU_BLOCKJOB_TYPE_CREATE, QEMU_BLOCKJOB_TYPE_LAST } qemuBlockJobType; verify((int)QEMU_BLOCKJOB_TYPE_INTERNAL =3D=3D VIR_DOMAIN_BLOCK_JOB_TYPE_L= AST); @@ -87,6 +88,15 @@ struct _qemuBlockJobCommitData { }; +typedef struct _qemuBlockJobCreateData qemuBlockJobCreateData; +typedef qemuBlockJobCreateData *qemuBlockJobDataCreatePtr; + +struct _qemuBlockJobCreateData { + bool storage; + virStorageSourcePtr src; +}; + + typedef struct _qemuBlockJobData qemuBlockJobData; typedef qemuBlockJobData *qemuBlockJobDataPtr; @@ -102,6 +112,7 @@ struct _qemuBlockJobData { union { qemuBlockJobPullData pull; qemuBlockJobCommitData commit; + qemuBlockJobCreateData create; } data; int type; /* qemuBlockJobType */ @@ -146,6 +157,12 @@ qemuBlockJobDiskNewCommit(virDomainObjPtr vm, virStorageSourcePtr top, virStorageSourcePtr base); +qemuBlockJobDataPtr +qemuBlockJobNewCreate(virDomainObjPtr vm, + virStorageSourcePtr src, + virStorageSourcePtr chain, + bool storage); + qemuBlockJobDataPtr qemuBlockJobDiskGetJob(virDomainDiskDefPtr disk) ATTRIBUTE_NONNULL(1); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2e722f4ee4..8f32f8a035 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2412,6 +2412,19 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void *= payload, virBufferAsprintf(&childBuf, "\n",= job->data.commit.topparent->nodeformat); break; + case QEMU_BLOCKJOB_TYPE_CREATE: + if (job->data.create.storage) + virBufferAddLit(&childBuf, "\n"); + + if (job->data.create.src && + qemuDomainObjPrivateXMLFormatBlockjobFormatSource(&childBu= f, + "src", + job->dat= a.create.src, + data->xm= lopt, + false) <= 0) + return -1; + break; + case QEMU_BLOCKJOB_TYPE_COPY: case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: @@ -2856,8 +2869,12 @@ qemuDomainObjPrivateXMLParseBlockjobNodename(qemuBlo= ckJobDataPtr job, static void qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qemuBlockJobDataPtr job, - xmlXPathContextPtr ctxt) + xmlXPathContextPtr ctxt, + virDomainXMLOptionPtr xml= opt) { + VIR_AUTOFREE(char *) createmode =3D NULL; + xmlNodePtr tmp; + switch ((qemuBlockJobType) job->type) { case QEMU_BLOCKJOB_TYPE_PULL: qemuDomainObjPrivateXMLParseBlockjobNodename(job, @@ -2891,6 +2908,19 @@ qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qem= uBlockJobDataPtr job, goto broken; break; + case QEMU_BLOCKJOB_TYPE_CREATE: + if (!(tmp =3D virXPathNode("./src", ctxt)) || + !(job->data.create.src =3D qemuDomainObjPrivateXMLParseBlo= ckjobChain(tmp, ctxt, xmlopt))) + goto broken; + + if ((createmode =3D virXPathString("string(./create/@mode)", c= txt))) { + if (STRNEQ(createmode, "storage")) + goto broken; + + job->data.create.storage =3D true; + } + break; + case QEMU_BLOCKJOB_TYPE_COPY: case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: @@ -2980,7 +3010,7 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObj= Ptr vm, if (mirror) job->mirrorChain =3D virObjectRef(job->disk->mirror); - qemuDomainObjPrivateXMLParseBlockjobDataSpecific(job, ctxt); + qemuDomainObjPrivateXMLParseBlockjobDataSpecific(job, ctxt, xmlopt); if (qemuBlockJobRegister(job, vm, disk, false) < 0) return -1; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2c03cc5dff..e358c6a1c4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17730,6 +17730,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, case QEMU_BLOCKJOB_TYPE_PULL: case QEMU_BLOCKJOB_TYPE_COMMIT: case QEMU_BLOCKJOB_TYPE_INTERNAL: + case QEMU_BLOCKJOB_TYPE_CREATE: virReportError(VIR_ERR_OPERATION_INVALID, _("job type '%s' does not support pivot"), qemuBlockjobTypeToString(job->type)); diff --git a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml b/tests/q= emustatusxml2xmldata/blockjob-blockdev-in.xml index d06bbb7059..408e9269db 100644 --- a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml +++ b/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml @@ -243,6 +243,23 @@ + + + + + + + + + + + + + + + + + @@ -252,6 +269,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 22:03:37 2024 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=1565280070; cv=none; d=zoho.com; s=zohoarc; b=V4oEMzFVRtegOxI0mRSUPmmYfm6xYItvyKYW+hzm+ZkuHGzfP1k++0FtZGH15hsS93SWdIeo4Fax6yd0aRrwcAjaIvZfOWGIXl8goE1c2p6YO95uh75HyAbnQ9pzzapI532YXVwC279x7sRzReaIZ2JXKsQVwVpFSoJS152KyzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565280070; 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=qGrbA7DiWthnEKCB/kF3a3w7FGFKykEeSyrYCBEmOj8=; b=l5lMcN+ySGaTQ65Gy6vRbuXw9vG4+qVHD3o0cNY7cSZHxY2AjNh5G7yM7KwHrqD6A69mkXq7/yWRh81lPgagkqk7/qsMqcRD6dLQ+ntNZSvgxMoDZKCYL0g5p1yZ4Bhd+/Io9Z6E1ghvmXsrx+fZb/6z/nsAcQuBuQ61kK7bejw= 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 1565280070663324.71160444261864; Thu, 8 Aug 2019 09:01:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C9C230C746E; Thu, 8 Aug 2019 16:01:09 +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 15ADC5C226; Thu, 8 Aug 2019 16:01:09 +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 A06F3180BA98; Thu, 8 Aug 2019 16:01:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78G0tGx005455 for ; Thu, 8 Aug 2019 12:00:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 89001166A7; Thu, 8 Aug 2019 16:00:55 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1FBC165D9 for ; Thu, 8 Aug 2019 16:00:54 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:00:41 +0200 Message-Id: <356b3e02383365a1fdfa57732ddb30c70e6c0aa5.1565279921.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/12] qemu: Add blockdev support for the block copy job 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 08 Aug 2019 16:01:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Implement job handling for the block copy job (drive/blockdev-mirror) when using -blockdev. In contrast to the previously implemented blockjobs the block copy job introduces new images to the running qemu instance, thus requires a bit more handling. When copying to new images the code now makes use of blockdev-create to format the images explicitly rather than depending on automagic qemu behaviour. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 87 +++++++++++++++++ src/qemu/qemu_blockjob.h | 16 +++ src/qemu/qemu_domain.c | 13 +++ src/qemu/qemu_driver.c | 97 ++++++++++++++++--- .../blockjob-blockdev-in.xml | 14 +++ 5 files changed, 216 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 70550d17e7..3003e9c518 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -309,6 +309,40 @@ qemuBlockJobNewCreate(virDomainObjPtr vm, } +qemuBlockJobDataPtr +qemuBlockJobDiskNewCopy(virDomainObjPtr vm, + virDomainDiskDefPtr disk, + virStorageSourcePtr mirror, + bool shallow, + bool reuse) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + VIR_AUTOUNREF(qemuBlockJobDataPtr) job =3D NULL; + VIR_AUTOFREE(char *) jobname =3D NULL; + + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) { + if (virAsprintf(&jobname, "copy-%s-%s", disk->dst, disk->src->node= format) < 0) + return NULL; + } else { + if (!(jobname =3D qemuAliasDiskDriveFromDisk(disk))) + return NULL; + } + + if (!(job =3D qemuBlockJobDataNew(QEMU_BLOCKJOB_TYPE_COPY, jobname))) + return NULL; + + job->mirrorChain =3D virObjectRef(mirror); + + if (shallow && !reuse) + job->data.copy.shallownew =3D true; + + if (qemuBlockJobRegister(job, vm, disk, true) < 0) + return NULL; + + VIR_RETURN_PTR(job); +} + + /** * qemuBlockJobDiskGetJob: * @disk: disk definition @@ -1043,6 +1077,50 @@ qemuBlockJobProcessEventCompletedActiveCommit(virQEM= UDriverPtr driver, } +static void +qemuBlockJobProcessEventConcludedCopyPivot(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuBlockJobDataPtr job, + qemuDomainAsyncJob asyncJob) +{ + VIR_DEBUG("copy job '%s' on VM '%s' pivoted", job->name, vm->def->name= ); + + if (!job->disk) + return; + + /* for shallow copy without reusing external image the user can either= not + * specify the backing chain in which case libvirt will open and use t= he + * chain the user provided or not specify a chain in which case we'll + * inherit the rest of the chain */ + if (job->data.copy.shallownew && + !virStorageSourceIsBacking(job->disk->mirror->backingStore)) + VIR_STEAL_PTR(job->disk->mirror->backingStore, job->disk->src->bac= kingStore); + + qemuBlockJobRewriteConfigDiskSource(vm, job->disk, job->disk->mirror); + + qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob, job= ->disk->src); + virObjectUnref(job->disk->src); + VIR_STEAL_PTR(job->disk->src, job->disk->mirror); +} + + +static void +qemuBlockJobProcessEventConcludedCopyAbort(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuBlockJobDataPtr job, + qemuDomainAsyncJob asyncJob) +{ + VIR_DEBUG("copy job '%s' on VM '%s' aborted", job->name, vm->def->name= ); + + if (!job->disk) + return; + + qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob, job= ->disk->mirror); + virObjectUnref(job->disk->mirror); + job->disk->mirror =3D NULL; +} + + static void qemuBlockJobProcessEventConcludedCreate(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -1111,6 +1189,12 @@ qemuBlockJobEventProcessConcludedTransition(qemuBloc= kJobDataPtr job, break; case QEMU_BLOCKJOB_TYPE_COPY: + if (job->state =3D=3D QEMU_BLOCKJOB_STATE_PIVOTING) + qemuBlockJobProcessEventConcludedCopyPivot(driver, vm, job= , asyncJob); + else + qemuBlockJobProcessEventConcludedCopyAbort(driver, vm, job= , asyncJob); + break; + case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: case QEMU_BLOCKJOB_TYPE_LAST: @@ -1138,6 +1222,9 @@ qemuBlockJobEventProcessConcludedTransition(qemuBlock= JobDataPtr job, break; case QEMU_BLOCKJOB_TYPE_COPY: + qemuBlockJobProcessEventConcludedCopyAbort(driver, vm, job, as= yncJob); + break; + case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: case QEMU_BLOCKJOB_TYPE_LAST: diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index ff3c4a9eb7..41a5cd91f8 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -97,6 +97,14 @@ struct _qemuBlockJobCreateData { }; +typedef struct _qemuBlockJobCopyData qemuBlockJobCopyData; +typedef qemuBlockJobCopyData *qemuBlockJobDataCopyPtr; + +struct _qemuBlockJobCopyData { + bool shallownew; +}; + + typedef struct _qemuBlockJobData qemuBlockJobData; typedef qemuBlockJobData *qemuBlockJobDataPtr; @@ -113,6 +121,7 @@ struct _qemuBlockJobData { qemuBlockJobPullData pull; qemuBlockJobCommitData commit; qemuBlockJobCreateData create; + qemuBlockJobCopyData copy; } data; int type; /* qemuBlockJobType */ @@ -163,6 +172,13 @@ qemuBlockJobNewCreate(virDomainObjPtr vm, virStorageSourcePtr chain, bool storage); +qemuBlockJobDataPtr +qemuBlockJobDiskNewCopy(virDomainObjPtr vm, + virDomainDiskDefPtr disk, + virStorageSourcePtr mirror, + bool shallow, + bool reuse); + qemuBlockJobDataPtr qemuBlockJobDiskGetJob(virDomainDiskDefPtr disk) ATTRIBUTE_NONNULL(1); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8f32f8a035..364046a456 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2426,6 +2426,10 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void *= payload, break; case QEMU_BLOCKJOB_TYPE_COPY: + if (job->data.copy.shallownew) + virBufferAddLit(&attrBuf, " shallownew=3D'yes'"); + break; + case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: case QEMU_BLOCKJOB_TYPE_LAST: @@ -2873,6 +2877,7 @@ qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qemu= BlockJobDataPtr job, virDomainXMLOptionPtr xml= opt) { VIR_AUTOFREE(char *) createmode =3D NULL; + VIR_AUTOFREE(char *) shallownew =3D NULL; xmlNodePtr tmp; switch ((qemuBlockJobType) job->type) { @@ -2922,6 +2927,14 @@ qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qem= uBlockJobDataPtr job, break; case QEMU_BLOCKJOB_TYPE_COPY: + if ((shallownew =3D virXPathString("string(./@shallownew)", c= txt))) { + if (STRNEQ(shallownew, "yes")) + goto broken; + + job->data.copy.shallownew =3D true; + } + break; + case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: case QEMU_BLOCKJOB_TYPE_LAST: diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e358c6a1c4..261a4167b5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18310,7 +18310,6 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, { virQEMUDriverPtr driver =3D conn->privateData; qemuDomainObjPrivatePtr priv =3D vm->privateData; - VIR_AUTOFREE(char *) device =3D NULL; virDomainDiskDefPtr disk =3D NULL; int ret =3D -1; bool need_unlink =3D false; @@ -18322,6 +18321,11 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, qemuBlockJobDataPtr job =3D NULL; VIR_AUTOUNREF(virStorageSourcePtr) mirror =3D mirrorsrc; bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); + VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; + VIR_AUTOPTR(qemuBlockStorageSourceChainData) crdata =3D NULL; + virStorageSourcePtr n; + virStorageSourcePtr mirrorBacking =3D NULL; + int rc =3D 0; /* Preliminaries: find the disk we are editing, sanity checks */ virCheckFlags(VIR_DOMAIN_BLOCK_COPY_SHALLOW | @@ -18351,9 +18355,6 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, if (!(disk =3D qemuDomainDiskByName(vm->def, path))) goto endjob; - if (!(device =3D qemuAliasDiskDriveFromDisk(disk))) - goto endjob; - if (qemuDomainDiskBlockJobIsActive(disk)) goto endjob; @@ -18428,7 +18429,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, goto endjob; } - /* pre-create the image file */ + /* pre-create the image file. In case when 'blockdev' is used this is + * required so that libvirt can properly label the image for access by= qemu */ if (!existing) { if (virStorageFileCreate(mirror) < 0) { virReportSystemError(errno, "%s", _("failed to create copy tar= get")); @@ -18445,6 +18447,15 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, keepParentLabel) < 0) goto endjob; + /* we must initialize XML-provided chain prior to detecting to keep se= mantics + * with VM startup */ + if (blockdev) { + for (n =3D mirror; virStorageSourceIsBacking(n); n =3D n->backingS= tore) { + if (qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg)= < 0) + goto endjob; + } + } + /* If reusing an external image that includes a backing file but the u= ser * did not enumerate the chain in the XML we need to detect the chain = */ if (mirror_reuse && @@ -18456,18 +18467,72 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, if (qemuDomainStorageSourceChainAccessAllow(driver, vm, mirror) < 0) goto endjob; - if (!(job =3D qemuBlockJobDiskNew(vm, disk, QEMU_BLOCKJOB_TYPE_COPY, d= evice))) + if (blockdev) { + if (mirror_reuse) { + if (!(data =3D qemuBuildStorageSourceChainAttachPrepareBlockde= v(mirror, + = priv->qemuCaps))) + goto endjob; + } else { + if (qemuBlockStorageSourceCreateDetectSize(vm, mirror, disk->s= rc, QEMU_ASYNC_JOB_NONE) < 0) + goto endjob; + + if (mirror_shallow) { + /* if external backing store is populated we'll need to op= en it */ + if (virStorageSourceHasBacking(mirror)) { + if (!(data =3D qemuBuildStorageSourceChainAttachPrepar= eBlockdev(mirror->backingStore, + = priv->qemuCaps))) + goto endjob; + + mirrorBacking =3D mirror->backingStore; + } else { + /* backing store of original image will be reused, but= the + * new image must refer to it in the metadata */ + mirrorBacking =3D disk->src->backingStore; + } + } + + if (!(crdata =3D qemuBuildStorageSourceChainAttachPrepareBlock= devTop(mirror, + = priv->qemuCaps))) + goto endjob; + } + + if (data) { + qemuDomainObjEnterMonitor(driver, vm); + rc =3D qemuBlockStorageSourceChainAttach(priv->mon, data); + if (qemuDomainObjExitMonitor(driver, vm) < 0) + goto endjob; + + if (rc < 0) + goto endjob; + } + + if (crdata && + qemuBlockStorageSourceCreate(vm, mirror, mirrorBacking, mirror= ->backingStore, + crdata->srcdata[0], QEMU_ASYNC_JO= B_NONE) < 0) + goto endjob; + } + + if (!(job =3D qemuBlockJobDiskNewCopy(vm, disk, mirror, mirror_shallow= , mirror_reuse))) goto endjob; disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_NONE; /* Actually start the mirroring */ qemuDomainObjEnterMonitor(driver, vm); - /* qemuMonitorDriveMirror needs to honor the REUSE_EXT flag as specifi= ed - * by the user */ - ret =3D qemuMonitorDriveMirror(priv->mon, device, mirror->path, format, - bandwidth, granularity, buf_size, - mirror_shallow, mirror_reuse); + + if (blockdev) { + ret =3D qemuMonitorBlockdevMirror(priv->mon, job->name, true, + disk->src->nodeformat, + mirror->nodeformat, bandwidth, + granularity, buf_size, mirror_shal= low); + } else { + /* qemuMonitorDriveMirror needs to honor the REUSE_EXT flag as spe= cified + * by the user */ + ret =3D qemuMonitorDriveMirror(priv->mon, job->name, mirror->path,= format, + bandwidth, granularity, buf_size, + mirror_shallow, mirror_reuse); + } + virDomainAuditDisk(vm, NULL, mirror, "mirror", ret >=3D 0); if (qemuDomainObjExitMonitor(driver, vm) < 0) ret =3D -1; @@ -18484,6 +18549,16 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, qemuBlockJobStarted(job, vm); endjob: + if (rc < 0 && + virDomainObjIsActive(vm) && + (data || crdata)) { + qemuDomainObjEnterMonitor(driver, vm); + if (data) + qemuBlockStorageSourceChainDetach(priv->mon, data); + if (crdata) + qemuBlockStorageSourceAttachRollback(priv->mon, crdata->srcdat= a[0]); + ignore_value(qemuDomainObjExitMonitor(driver, vm)); + } if (need_unlink && virStorageFileUnlink(mirror) < 0) VIR_WARN("%s", _("unable to remove just-created copy target")); virStorageFileDeinit(mirror); diff --git a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml b/tests/q= emustatusxml2xmldata/blockjob-blockdev-in.xml index 408e9269db..67252a3729 100644 --- a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml +++ b/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml @@ -260,6 +260,9 @@ + + + @@ -571,6 +574,17 @@ + + + + + + + + + + +
--=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 22:03:37 2024 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=1565280082; cv=none; d=zoho.com; s=zohoarc; b=e6O7zDc8P3mPwii428PehTZkqd27nHMuYa8+3NfYHycwA2OvCmJvqJV91p9uj70miabq7n0t0hiqnd/9nFlCJBtY4ps9yincMVqpYIeArcdIHCQ9LP0/N41mfNVmaz9LSA8LaEtn/n9/L4m87S/O4dymbeLxCYX+zNIO+FrZ05M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565280082; 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=fevLk8+JIXWPxtj2LviuodyUQGdjUU3HrwTPJgaDY7k=; b=JwDtATmbSNEYS3ulzJxqh26ioxMjsdiI+tyipgApcvsVBXmZi7/kYkaQCdpMHRjmDlLrs6NgB0dl7ii2DfkOJLB9WEI/5wzy7PlwHAIUBI/g9Y/4d4PLrn6rG7VCpI4UwmFSGGWngjjgggjBTqR9oRBz67rsbpv+wOlbsDcxalo= 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 1565280082529992.4456125307655; Thu, 8 Aug 2019 09:01:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF2EE30ADBBF; Thu, 8 Aug 2019 16:01:20 +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 4F11E6013A; Thu, 8 Aug 2019 16:01:20 +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 E2B35180BAA1; Thu, 8 Aug 2019 16:01:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78G0u5u005467 for ; Thu, 8 Aug 2019 12:00:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 57B753DB4; Thu, 8 Aug 2019 16:00:56 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id D70BD165D9 for ; Thu, 8 Aug 2019 16:00:55 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:00:42 +0200 Message-Id: <9f4120845dc0149a298092d6d91a718419ca3c96.1565279921.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/12] qemu: driver: allow remote destinations for block copy 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 08 Aug 2019 16:01:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Now that we support blockdev for qemuDomainBlockCopy we can allow copying to remote destinations as well. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 47 ++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 261a4167b5..b4eecdd8be 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18195,6 +18195,9 @@ qemuDomainBlockCopyValidateMirror(virStorageSourceP= tr mirror, int desttype =3D virStorageSourceGetActualType(mirror); struct stat st; + if (!virStorageSourceIsLocalStorage(mirror)) + return 0; + if (virStorageFileAccess(mirror, F_OK) < 0) { if (errno !=3D ENOENT) { virReportSystemError(errno, "%s", @@ -18321,6 +18324,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, qemuBlockJobDataPtr job =3D NULL; VIR_AUTOUNREF(virStorageSourcePtr) mirror =3D mirrorsrc; bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); + bool mirror_initialized =3D false; VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; VIR_AUTOPTR(qemuBlockStorageSourceChainData) crdata =3D NULL; virStorageSourcePtr n; @@ -18393,15 +18397,19 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, } /* Prepare the destination file. */ - /* XXX Allow non-file mirror destinations */ - if (!virStorageSourceIsLocalStorage(mirror)) { + if (!blockdev && + !virStorageSourceIsLocalStorage(mirror)) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("non-file destination not supported yet")); goto endjob; } - if (qemuDomainStorageFileInit(driver, vm, mirror, NULL) < 0) - goto endjob; + if (virStorageFileSupportsCreate(mirror) =3D=3D 1) { + if (qemuDomainStorageFileInit(driver, vm, mirror, NULL) < 0) + goto endjob; + + mirror_initialized =3D true; + } if (qemuDomainBlockCopyValidateMirror(mirror, disk->dst, &existing) < = 0) goto endjob; @@ -18410,12 +18418,19 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, if (!mirror_reuse) { mirror->format =3D disk->src->format; } else { - /* If the user passed the REUSE_EXT flag, then either they - * can also pass the RAW flag or use XML to tell us the format. - * So if we get here, we assume it is safe for us to probe the - * format from the file that we will be using. */ - mirror->format =3D virStorageFileProbeFormat(mirror->path, cfg= ->user, - cfg->group); + if (mirror_initialized && + virStorageSourceIsLocalStorage(mirror)) { + /* If the user passed the REUSE_EXT flag, then either they + * can also pass the RAW flag or use XML to tell us the fo= rmat. + * So if we get here, we assume it is safe for us to probe= the + * format from the file that we will be using. */ + mirror->format =3D virStorageFileProbeFormat(mirror->path,= cfg->user, + cfg->group); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("reused mirror destination format must be= specified")); + goto endjob; + } } } @@ -18432,12 +18447,14 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, /* pre-create the image file. In case when 'blockdev' is used this is * required so that libvirt can properly label the image for access by= qemu */ if (!existing) { - if (virStorageFileCreate(mirror) < 0) { - virReportSystemError(errno, "%s", _("failed to create copy tar= get")); - goto endjob; - } + if (mirror_initialized) { + if (virStorageFileCreate(mirror) < 0) { + virReportSystemError(errno, "%s", _("failed to create copy= target")); + goto endjob; + } - need_unlink =3D true; + need_unlink =3D true; + } } if (mirror->format > 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list