From nobody Mon May 6 00:32:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1588765446; cv=none; d=zohomail.com; s=zohoarc; b=mw7G+FHBV4pQ0cHwpXkHDT5DBwewHk31b6wf22Fhar50/1nVlyrQB9tKk2g+mLLalYetF8jUT1w2OohiutSABl4AsM1iRCkBYFIvWE2kTPyZfnMc1uOgt1xkw/KGrlszkHm6ls3ne4y/LKsWd1YYGQL4LxL/gQCvF+C8mDqwjjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588765446; h=Content-Type:Content-Transfer-Encoding:Cc: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; bh=CSQUJPuShq6WMAsZ5pwLwISBDjh8EsKOFOIkzVg8Yqg=; b=d/+VEQ0AXuzTSUM70CNHciRoCb6yN70JFW9rkHzJ8dVcCaFkLnJqFB4QcsnMPrsErrmLPFYvhCOrE3ZRLTK+PXsqchX6kwXNF+w7Er20a7Spkx0uXQbzrAzTUxgqOjIF3Y2JCZcH6GPc2XrIzSk+RiW0fZvlVIb2/Em2+/pyAdA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1588765446013728.4356138896504; Wed, 6 May 2020 04:44:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-270-cX36qWV5PIOkzGSziKmN8g-1; Wed, 06 May 2020 07:44:02 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 483D98064D8; Wed, 6 May 2020 11:43:57 +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 2480E5C1BD; Wed, 6 May 2020 11:43:57 +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 D2EA74CAA0; Wed, 6 May 2020 11:43:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046BgT89026736 for ; Wed, 6 May 2020 07:42:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 833201002389; Wed, 6 May 2020 11:42:29 +0000 (UTC) Received: from ibm-p8-15-fsp.mgmt.pnr.lab.eng.rdu2.redhat.com (unknown [10.40.195.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id C223710013D9; Wed, 6 May 2020 11:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588765444; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CSQUJPuShq6WMAsZ5pwLwISBDjh8EsKOFOIkzVg8Yqg=; b=HmcvJDRzl87pWwalBUB51FuXNo/ucUNKB4WIcCSLTd5KKhyvuSTzdN4kG3osUOITmUvkQz 4J103Dpppi9pccuAWYWzhD4NNO2ePKy7IkFASOHBvm8yoiuCsdsIstnMm2Q2WcFnPLFyaD WSsoVhcy5VP5/kwzZVvjxqyqXKNZ8Zw= X-MC-Unique: cX36qWV5PIOkzGSziKmN8g-1 From: Pavel Mores To: libvir-list@redhat.com Subject: [libvirt PATCH v2 01/10] qemu: block: factor implementation out of qemuDomainBlockCommit() Date: Wed, 6 May 2020 13:42:17 +0200 Message-Id: <20200506114226.2538196-2-pmores@redhat.com> In-Reply-To: <20200506114226.2538196-1-pmores@redhat.com> References: <20200506114226.2538196-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Mores 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We'll need blockcommit to be callable from within the QEMU driver where we have no virDomain instance available, just virDomainObj. Signed-off-by: Pavel Mores --- src/qemu/qemu_driver.c | 78 ++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1c7c87128d..b642b24fa2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -154,6 +154,15 @@ static int qemuOpenFileAs(uid_t fallback_uid, gid_t fa= llback_gid, =20 static virQEMUDriverPtr qemu_driver; =20 +static int +qemuDomainBlockCommitImpl(virDomainObjPtr vm, + virQEMUDriverPtr driver, + const char *path, + const char *base, + const char *top, + unsigned long bandwidth, + unsigned int flags); + /* Looks up the domain object from snapshot and unlocks the * driver. The returned domain object is locked and ref'd and the * caller must call virDomainObjEndAPI() on it. */ @@ -18431,18 +18440,16 @@ qemuDomainBlockPull(virDomainPtr dom, const char = *path, unsigned long bandwidth, return qemuDomainBlockPullCommon(vm, path, NULL, bandwidth, flags); } =20 - static int -qemuDomainBlockCommit(virDomainPtr dom, - const char *path, - const char *base, - const char *top, - unsigned long bandwidth, - unsigned int flags) +qemuDomainBlockCommitImpl(virDomainObjPtr vm, + virQEMUDriverPtr driver, + const char *path, + const char *base, + const char *top, + unsigned long bandwidth, + unsigned int flags) { - virQEMUDriverPtr driver =3D dom->conn->privateData; - qemuDomainObjPrivatePtr priv; - virDomainObjPtr vm =3D NULL; + qemuDomainObjPrivatePtr priv =3D vm->privateData; const char *device =3D NULL; const char *jobname =3D NULL; int ret =3D -1; @@ -18466,22 +18473,6 @@ qemuDomainBlockCommit(virDomainPtr dom, g_autoptr(virJSONValue) bitmapDisableActions =3D NULL; VIR_AUTOSTRINGLIST bitmapDisableList =3D NULL; =20 - virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW | - VIR_DOMAIN_BLOCK_COMMIT_ACTIVE | - VIR_DOMAIN_BLOCK_COMMIT_RELATIVE | - VIR_DOMAIN_BLOCK_COMMIT_DELETE | - VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES, -1); - - if (!(vm =3D qemuDomainObjFromDomain(dom))) - goto cleanup; - priv =3D vm->privateData; - - if (virDomainBlockCommitEnsureACL(dom->conn, vm->def) < 0) - goto cleanup; - - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) - goto cleanup; - if (virDomainObjCheckActive(vm) < 0) goto endjob; =20 @@ -18730,6 +18721,40 @@ qemuDomainBlockCommit(virDomainPtr dom, virErrorRestore(&orig_err); } qemuBlockJobStartupFinalize(vm, job); + + return ret; +} + + +static int +qemuDomainBlockCommit(virDomainPtr dom, + const char *path, + const char *base, + const char *top, + unsigned long bandwidth, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainObjPtr vm =3D NULL; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW | + VIR_DOMAIN_BLOCK_COMMIT_ACTIVE | + VIR_DOMAIN_BLOCK_COMMIT_RELATIVE | + VIR_DOMAIN_BLOCK_COMMIT_DELETE | + VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES, -1); + + if (!(vm =3D qemuDomainObjFromDomain(dom))) + goto cleanup; + + if (virDomainBlockCommitEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + + ret =3D qemuDomainBlockCommitImpl(vm, driver, path, base, top, bandwid= th, flags); + qemuDomainObjEndJob(driver, vm); =20 cleanup: @@ -18737,6 +18762,7 @@ qemuDomainBlockCommit(virDomainPtr dom, return ret; } =20 + static int qemuDomainOpenGraphics(virDomainPtr dom, unsigned int idx, --=20 2.24.1 From nobody Mon May 6 00:32:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1588765377; cv=none; d=zohomail.com; s=zohoarc; b=jjFCQvSYgmapDZBcv0YqkPrYVUesLB1j/BVqR44h18G66fUf63syQ04LVynbxl1lxUxb7jJ+KTz8CVZlQziYKvsFWr4otI+FDF9opjo7Sv5zlbsqq5YE9QUQQYeVJua/yjLtfFD4d0wNzKaNjpjfV9f1I7jpaf0NW9Lqo8KENzE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588765377; h=Content-Type:Content-Transfer-Encoding:Cc: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; bh=ho7psWlXG5mz7OkTPBT0HD1tyGpYW7JA0CSMcgH/3mg=; b=bkFygnJLvj1KQ9oQxDNUjPBMcFDyRgvQX5E3Yv+gmzFYHMgg3O45/CiYsB6B2PR7NzOt+Gjh8q7tzyFrM/AanpkBlQQAxHxq/IDrR5BfxHSXIHmWQH85ZZbrxS2DdzLO5hOI+0b9l1el7HRCtgJKiSAcCpy9bDOr/iGa/w9IHZM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1588765376999663.4632108527986; Wed, 6 May 2020 04:42:56 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-175-NOKFZ0oUOhiPFweu7z5krQ-1; Wed, 06 May 2020 07:42:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BFB7B18B6490; Wed, 6 May 2020 11:42:36 +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 3DB1A60E3E; Wed, 6 May 2020 11:42:36 +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 7D4621809542; Wed, 6 May 2020 11:42:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046BgUbD026748 for ; Wed, 6 May 2020 07:42:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id A068A10021B3; Wed, 6 May 2020 11:42:30 +0000 (UTC) Received: from ibm-p8-15-fsp.mgmt.pnr.lab.eng.rdu2.redhat.com (unknown [10.40.195.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEEBF10013D9; Wed, 6 May 2020 11:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588765375; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ho7psWlXG5mz7OkTPBT0HD1tyGpYW7JA0CSMcgH/3mg=; b=fiB5RFz+yBraTHOBzalQDevNTfqqe13AerGo4blqFJcBReHAqMcMWRpEqjJqoMkJNCHXMd rd5a+n8eSb7lLeeI7A3NXKNCltcX/eQeJF7kPH4jujT8dlFDuSEnmMcoQXeCizkIOw/SEY PTAmkMiy4+mRru7GcBfYBkY6tN8xdWU= X-MC-Unique: NOKFZ0oUOhiPFweu7z5krQ-1 From: Pavel Mores To: libvir-list@redhat.com Subject: [libvirt PATCH v2 02/10] qemu: block: refactor blockcommit so that it's callable with storage sources Date: Wed, 6 May 2020 13:42:18 +0200 Message-Id: <20200506114226.2538196-3-pmores@redhat.com> In-Reply-To: <20200506114226.2538196-1-pmores@redhat.com> References: <20200506114226.2538196-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Mores 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" So far, only paths could be used to specify blockcommit's base and top images. However, this is not general enough as paths have limitations (most notably they can only work for file-based storage sources). This commit preserves the path-based interface but factors out the core of blockcommit implementation into a separate function that takes its base and top as virStorageSources. The path-based interface basically just converts the paths into virStorageSource just as it was done before and calls the virStorageSource-based implementation core. Signed-off-by: Pavel Mores --- src/qemu/qemu_driver.c | 108 +++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 43 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b642b24fa2..09300c1e90 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18441,25 +18441,27 @@ qemuDomainBlockPull(virDomainPtr dom, const char = *path, unsigned long bandwidth, } =20 static int -qemuDomainBlockCommitImpl(virDomainObjPtr vm, - virQEMUDriverPtr driver, - const char *path, - const char *base, - const char *top, - unsigned long bandwidth, - unsigned int flags) +qemuDomainBlockCommitCommon(virDomainObjPtr vm, + virQEMUDriverPtr driver, + virDomainDiskDefPtr disk, + virStorageSourcePtr baseSource, + virStorageSourcePtr topSource, + virStorageSourcePtr topParentSource, + unsigned long bandwidth, + unsigned int flags) { qemuDomainObjPrivatePtr priv =3D vm->privateData; const char *device =3D NULL; const char *jobname =3D NULL; int ret =3D -1; - virDomainDiskDefPtr disk =3D NULL; - virStorageSourcePtr topSource; - unsigned int topIndex =3D 0; - virStorageSourcePtr baseSource =3D NULL; - unsigned int baseIndex =3D 0; - virStorageSourcePtr top_parent =3D NULL; bool clean_access =3D false; + /* TODO the following 2 are just for error reporting. Originally these + * could have been either paths or indexed identifiers (like 'vda[1]'). + * Now the error reporting will always use paths instead of what the + * user originally specified. Find out if this is fine, find a soluti= on + * if it isn't. */ + const char *path =3D disk->src->path; + const char *base =3D baseSource->path; g_autofree char *topPath =3D NULL; g_autofree char *basePath =3D NULL; g_autofree char *backingPath =3D NULL; @@ -18473,9 +18475,6 @@ qemuDomainBlockCommitImpl(virDomainObjPtr vm, g_autoptr(virJSONValue) bitmapDisableActions =3D NULL; VIR_AUTOSTRINGLIST bitmapDisableList =3D NULL; =20 - if (virDomainObjCheckActive(vm) < 0) - goto endjob; - blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); =20 /* Convert bandwidth MiB to bytes, if necessary */ @@ -18489,9 +18488,6 @@ qemuDomainBlockCommitImpl(virDomainObjPtr vm, speed <<=3D 20; } =20 - if (!(disk =3D qemuDomainDiskByName(vm->def, path))) - goto endjob; - if (virStorageSourceIsEmpty(disk->src)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk %s has no source file to be committed"), @@ -18511,14 +18507,6 @@ qemuDomainBlockCommitImpl(virDomainObjPtr vm, goto endjob; } =20 - if (!top || STREQ(top, disk->dst)) - topSource =3D disk->src; - else if (virStorageFileParseChainIndex(disk->dst, top, &topIndex) < 0 = || - !(topSource =3D virStorageFileChainLookup(disk->src, NULL, - top, topIndex, - &top_parent))) - goto endjob; - if (topSource =3D=3D disk->src) { if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_ACTIVE_COMMIT)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -18546,13 +18534,6 @@ qemuDomainBlockCommitImpl(virDomainObjPtr vm, goto endjob; } =20 - if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW)) - baseSource =3D topSource->backingStore; - else if (virStorageFileParseChainIndex(disk->dst, base, &baseIndex) < = 0 || - !(baseSource =3D virStorageFileChainLookup(disk->src, topSour= ce, - base, baseIndex, NUL= L))) - goto endjob; - if ((flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW) && baseSource !=3D topSource->backingStore) { virReportError(VIR_ERR_INVALID_ARG, @@ -18580,8 +18561,8 @@ qemuDomainBlockCommitImpl(virDomainObjPtr vm, goto endjob; } =20 - if (blockdev && top_parent && - qemuBlockUpdateRelativeBacking(vm, top_parent, disk->src) < 0) + if (blockdev && topParentSource && + qemuBlockUpdateRelativeBacking(vm, topParentSource, disk->src)= < 0) goto endjob; =20 if (virStorageFileGetRelativeBackingPath(topSource, baseSource, @@ -18607,11 +18588,11 @@ qemuDomainBlockCommitImpl(virDomainObjPtr vm, false, false, false) < 0) goto endjob; =20 - if (top_parent && top_parent !=3D disk->src) { - /* While top_parent is topmost image, we don't need to remember its + if (topParentSource && topParentSource !=3D disk->src) { + /* While topParentSource is topmost image, we don't need to rememb= er its * owner as it will be overwritten upon finishing the commit. Henc= e, * pass chainTop =3D false. */ - if (qemuDomainStorageSourceAccessAllow(driver, vm, top_parent, + if (qemuDomainStorageSourceAccessAllow(driver, vm, topParentSource, false, false, false) < 0) goto endjob; } @@ -18637,7 +18618,7 @@ qemuDomainBlockCommitImpl(virDomainObjPtr vm, } } =20 - if (!(job =3D qemuBlockJobDiskNewCommit(vm, disk, top_parent, topSourc= e, + if (!(job =3D qemuBlockJobDiskNewCommit(vm, disk, topParentSource, top= Source, baseSource, &bitmapDisableList, flags & VIR_DOMAIN_BLOCK_COMMIT_= DELETE, flags))) @@ -18657,7 +18638,7 @@ qemuDomainBlockCommitImpl(virDomainObjPtr vm, nodetop =3D topSource->nodeformat; nodebase =3D baseSource->nodeformat; device =3D qemuDomainDiskGetTopNodename(disk); - if (!backingPath && top_parent && + if (!backingPath && topParentSource && !(backingPath =3D qemuBlockGetBackingStoreString(baseSource, f= alse))) goto endjob; =20 @@ -18714,8 +18695,8 @@ qemuDomainBlockCommitImpl(virDomainObjPtr vm, /* Revert access to read-only, if possible. */ qemuDomainStorageSourceAccessAllow(driver, vm, baseSource, true, false, false); - if (top_parent && top_parent !=3D disk->src) - qemuDomainStorageSourceAccessAllow(driver, vm, top_parent, + if (topParentSource && topParentSource !=3D disk->src) + qemuDomainStorageSourceAccessAllow(driver, vm, topParentSource, true, false, false); =20 virErrorRestore(&orig_err); @@ -18725,6 +18706,47 @@ qemuDomainBlockCommitImpl(virDomainObjPtr vm, return ret; } =20 +static int +qemuDomainBlockCommitImpl(virDomainObjPtr vm, + virQEMUDriverPtr driver, + const char *path, + const char *base, + const char *top, + unsigned long bandwidth, + unsigned int flags) +{ + virDomainDiskDefPtr disk =3D NULL; + virStorageSourcePtr topSource; + unsigned int topIndex =3D 0; + virStorageSourcePtr baseSource =3D NULL; + unsigned int baseIndex =3D 0; + virStorageSourcePtr top_parent =3D NULL; + + if (virDomainObjCheckActive(vm) < 0) + return -1; + + if (!(disk =3D qemuDomainDiskByName(vm->def, path))) + return -1; + + if (!top || STREQ(top, disk->dst)) + topSource =3D disk->src; + else if (virStorageFileParseChainIndex(disk->dst, top, &topIndex) < 0 = || + !(topSource =3D virStorageFileChainLookup(disk->src, NULL, + top, topIndex, + &top_parent))) + return -1; + + if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW)) + baseSource =3D topSource->backingStore; + else if (virStorageFileParseChainIndex(disk->dst, base, &baseIndex) < = 0 || + !(baseSource =3D virStorageFileChainLookup(disk->src, topSour= ce, + base, baseIndex, NUL= L))) + return -1; + + return qemuDomainBlockCommitCommon(vm, driver, disk, baseSource, topSo= urce, + top_parent, bandwidth, flags); +} + =20 static int qemuDomainBlockCommit(virDomainPtr dom, --=20 2.24.1 From nobody Mon May 6 00:32:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1588765376; cv=none; d=zohomail.com; s=zohoarc; b=EH/W9F1lCV7c1K9lBasPaK1GpDgKjrtT3EtIuCUIzEErMd1TBr5ytVu7f2VH5xQpnYwdqnPGRvyLkZU9YwmUTJlaQSAdc6PL+1DqXbOoibAkzb1RHdOgRlrXVynxvz3gZY6x7n7uVvn/NxZcZxxDj+AmJKIDJZIWRAbHvnheQHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588765376; h=Content-Type:Content-Transfer-Encoding:Cc: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; bh=dM6DuqoeohFVz2baOT3hCi9xkDzHrDrG7MPo77by3Ts=; b=Exevq+icv30Og2szykjSZ5n+hD5q0xTY/BDOmoU31PhykrFqwH/x8PZoozaLyVzdaXKgc+LbnjpJ8Dr1UPOifrGAAXW8m+yqcxTfTH0EQXMsuWWOKtYgtNeCkMPdvEBCHOKibLrRmmIwIsPHu4uwNgjManjzwlz2zptdsrO/x1U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1588765376123326.81554197829996; Wed, 6 May 2020 04:42:56 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-424-o70iKMFoP0eMSMnujOIxNQ-1; Wed, 06 May 2020 07:42:51 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6CB18B1345; Wed, 6 May 2020 11:42:37 +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 9ED092E172; Wed, 6 May 2020 11:42:37 +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 DBE311809554; Wed, 6 May 2020 11:42:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046BgVdY026758 for ; Wed, 6 May 2020 07:42:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id CA5CE1053B1F; Wed, 6 May 2020 11:42:31 +0000 (UTC) Received: from ibm-p8-15-fsp.mgmt.pnr.lab.eng.rdu2.redhat.com (unknown [10.40.195.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0732210013D9; Wed, 6 May 2020 11:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588765373; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dM6DuqoeohFVz2baOT3hCi9xkDzHrDrG7MPo77by3Ts=; b=VbAL3XbSH5kN90isTRv1V641E0/O4tGcMBD/DmhdfpvoTi2vfEZDygCsY3copem9R1uD07 nxOrvl2gGbqY6N6xYx5L7huEUOZMGTwqzXmsEHjPUG2hucCp1aTARlBzH6L0iaOg6zs+BP S13OOZfAAc7BL8InqECaYJORNPIqMvo= X-MC-Unique: o70iKMFoP0eMSMnujOIxNQ-1 From: Pavel Mores To: libvir-list@redhat.com Subject: [libvirt PATCH v2 03/10] qemu: block: factor implementation out of qemuDomainBlockJobAbort() Date: Wed, 6 May 2020 13:42:19 +0200 Message-Id: <20200506114226.2538196-4-pmores@redhat.com> In-Reply-To: <20200506114226.2538196-1-pmores@redhat.com> References: <20200506114226.2538196-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Mores 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Just as with the qemuDomainBlockCommit() refactor in the commit before the previous one, the motivation is primarily to make blockjob abortion callable from within the QEMU driver where only virDomainObj instance is available but no virDomain. Signed-off-by: Pavel Mores --- src/qemu/qemu_driver.c | 62 ++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 09300c1e90..6ffd53503b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -163,6 +163,12 @@ qemuDomainBlockCommitImpl(virDomainObjPtr vm, unsigned long bandwidth, unsigned int flags); =20 +static int +qemuDomainBlockJobAbortImpl(virQEMUDriverPtr driver, + virDomainObjPtr vm, + const char *path, + unsigned int flags); + /* Looks up the domain object from snapshot and unlocks the * driver. The returned domain object is locked and ref'd and the * caller must call virDomainObjEndAPI() on it. */ @@ -17541,45 +17547,31 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm, return ret; } =20 - static int -qemuDomainBlockJobAbort(virDomainPtr dom, - const char *path, - unsigned int flags) +qemuDomainBlockJobAbortImpl(virQEMUDriverPtr driver, + virDomainObjPtr vm, + const char *path, + unsigned int flags) { - virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainDiskDefPtr disk =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); bool pivot =3D !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT); bool async =3D !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC); g_autoptr(qemuBlockJobData) job =3D NULL; - virDomainObjPtr vm; qemuDomainObjPrivatePtr priv =3D NULL; bool blockdev =3D false; int ret =3D -1; =20 - virCheckFlags(VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC | - VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT, -1); - - if (!(vm =3D qemuDomainObjFromDomain(dom))) - return -1; - - if (virDomainBlockJobAbortEnsureACL(dom->conn, vm->def) < 0) - goto cleanup; - - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) - goto cleanup; - if (virDomainObjCheckActive(vm) < 0) - goto endjob; + return -1; =20 if (!(disk =3D qemuDomainDiskByName(vm->def, path))) - goto endjob; + return -1; =20 if (!(job =3D qemuBlockJobDiskGetJob(disk))) { virReportError(VIR_ERR_INVALID_ARG, _("disk %s does not have an active block job"), dis= k->dst); - goto endjob; + return -1; } =20 priv =3D vm->privateData; @@ -17650,6 +17642,34 @@ qemuDomainBlockJobAbort(virDomainPtr dom, endjob: if (job && !async) qemuBlockJobSyncEnd(vm, job, QEMU_ASYNC_JOB_NONE); + + return ret; +} + + +static int +qemuDomainBlockJobAbort(virDomainPtr dom, + const char *path, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainObjPtr vm; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC | + VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT, -1); + + if (!(vm =3D qemuDomainObjFromDomain(dom))) + return -1; + + if (virDomainBlockJobAbortEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + + ret =3D qemuDomainBlockJobAbortImpl(driver, vm, path, flags); + qemuDomainObjEndJob(driver, vm); =20 cleanup: --=20 2.24.1 From nobody Mon May 6 00:32:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1588765381; cv=none; d=zohomail.com; s=zohoarc; b=HeL+u75N0EmvzmUo1T3IMdNHg42VXdwtNI7aT5bI23xqD8QzZZ/nWuClHaybE9f9C73ODyjK/FV2tKfOlcHOC2zPXYvfNj27d1RIG+yv5V7IdxqWihDU55WSLU4YuBqXHw5uLi9qc8XCPd5Xeozh4LkALrWAQrM4aaMzzarKKIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588765381; h=Content-Type:Content-Transfer-Encoding:Cc: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; bh=nr2pwrNgydJIWA4m45k9lwiYd5kmERgP+medAX9O0ss=; b=PeaaI20jS/lXvWHsjn9amAY5ewJyK984vrKVfnPEzkpXxKau5tVzW8tos7QSnYro/w8Rp3OvaM6Jh/oysxfLFvIvpTQMsqh7hjXCZh4vrXysnYK5xOWLFZ7AK6kzSt9RFqL4JjyZ7tiUVMLut0eaeQvVd/+EimC4wwEOgJ0i58k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1588765381186947.3468261868642; Wed, 6 May 2020 04:43:01 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-43-xQVPHpjnPwWzcmBNjPfMvw-1; Wed, 06 May 2020 07:42:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2CC57345CB; Wed, 6 May 2020 11:42:46 +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 08E8B60BF4; Wed, 6 May 2020 11:42:45 +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 AD3E31809561; Wed, 6 May 2020 11:42:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046BgWZT026769 for ; Wed, 6 May 2020 07:42:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id EEF861002389; Wed, 6 May 2020 11:42:32 +0000 (UTC) Received: from ibm-p8-15-fsp.mgmt.pnr.lab.eng.rdu2.redhat.com (unknown [10.40.195.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34E2010013D9; Wed, 6 May 2020 11:42:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588765379; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nr2pwrNgydJIWA4m45k9lwiYd5kmERgP+medAX9O0ss=; b=QJgGA45mcGG4WTtngGEXEvWIbe5KEBI6Vd0VBwOCmzyc6GtRac67ato8V5o/ZpSgzSLJff y60PkLsbI0qNxEo069JaCRQiiRt8kCZHyw9aOgnlU3CUzjNUMLOXirlNqtEz5UD/kFkHju dvQvu8j4xJrjw91Kf2aSiwNqTcsqbc0= X-MC-Unique: xQVPHpjnPwWzcmBNjPfMvw-1 From: Pavel Mores To: libvir-list@redhat.com Subject: [libvirt PATCH v2 04/10] conf: rename virDomainMomentFindLeaf() to virDomainMomentObjListFindLeaf() Date: Wed, 6 May 2020 13:42:20 +0200 Message-Id: <20200506114226.2538196-5-pmores@redhat.com> In-Reply-To: <20200506114226.2538196-1-pmores@redhat.com> References: <20200506114226.2538196-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Mores 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We'll need the original name for a function that finds leaf for a single virDomainMomentObj. The new name properly advertises that the function actually works on a virDomainMomentObjList, as some (but not all) of existing functions operating on lists do. Signed-off-by: Pavel Mores Reviewed-by: Peter Krempa --- src/conf/virdomaincheckpointobjlist.c | 2 +- src/conf/virdomainmomentobjlist.c | 2 +- src/conf/virdomainmomentobjlist.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf/virdomaincheckpointobjlist.c b/src/conf/virdomainchec= kpointobjlist.c index a4942ea706..2df1c426a2 100644 --- a/src/conf/virdomaincheckpointobjlist.c +++ b/src/conf/virdomaincheckpointobjlist.c @@ -186,7 +186,7 @@ virDomainCheckpointUpdateRelations(virDomainCheckpointO= bjListPtr checkpoints, int ret =3D virDomainMomentUpdateRelations(checkpoints->base); =20 if (ret =3D=3D 0) - *leaf =3D virDomainMomentFindLeaf(checkpoints->base); + *leaf =3D virDomainMomentObjListFindLeaf(checkpoints->base); return ret; } =20 diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentob= jlist.c index 18dbd434fb..41e887ba18 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -588,7 +588,7 @@ virDomainMomentCheckCycles(virDomainMomentObjListPtr li= st, =20 /* If there is exactly one leaf node, return that node. */ virDomainMomentObjPtr -virDomainMomentFindLeaf(virDomainMomentObjListPtr list) +virDomainMomentObjListFindLeaf(virDomainMomentObjListPtr list) { virDomainMomentObjPtr moment =3D &list->metaroot; =20 diff --git a/src/conf/virdomainmomentobjlist.h b/src/conf/virdomainmomentob= jlist.h index 75198909ba..cab51edbc4 100644 --- a/src/conf/virdomainmomentobjlist.h +++ b/src/conf/virdomainmomentobjlist.h @@ -121,4 +121,4 @@ int virDomainMomentUpdateRelations(virDomainMomentObjLi= stPtr moments); int virDomainMomentCheckCycles(virDomainMomentObjListPtr list, virDomainMomentDefPtr def, const char *domname); -virDomainMomentObjPtr virDomainMomentFindLeaf(virDomainMomentObjListPtr li= st); +virDomainMomentObjPtr virDomainMomentObjListFindLeaf(virDomainMomentObjLis= tPtr list); --=20 2.24.1 From nobody Mon May 6 00:32:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1588765444; cv=none; d=zohomail.com; s=zohoarc; b=U6asWEw+0cmPyFSePC3Vt5Y5bDXSt3Nnyz/k1SoNV4Jwb+WbuTun7h+sgzNN+jzJL61ItM4rr+eAHfF8R34oFbfZs+XeY3U2dWkAQeOQJjzW125zHj9QFlNzgNXKfcu24pgxIXMKAiIO4F/OcTSxBbdXY37C2WDS61vWytT72Yc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588765444; h=Content-Type:Content-Transfer-Encoding:Cc: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; bh=IAi5mZE8wl3L/h0Oz6o3QjaZlGLJfTQuwmSKGzd6wQQ=; b=UfnEzmNczJ8BDZ65T2gxm84uE2CnsRtjR0ZzDJyiFJ9jDitW1yd2vs8UNjN1N+MGh0fgig20zdOzlTELwoXLcduUJiGxLC47j3RJ+ByN4opTU9dOF3NDwzp+i3vYspFqneCz5EOZOcszp5+xadyamXiGV2jcrnl8an1FQmVbC+Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1588765444112155.8491506653188; Wed, 6 May 2020 04:44:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-20-ws8GVlewOXWz5AtehDSPRw-1; Wed, 06 May 2020 07:43:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B98884620B; Wed, 6 May 2020 11:42:48 +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 6235D60E3E; Wed, 6 May 2020 11:42:48 +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 23D6B1809563; Wed, 6 May 2020 11:42:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046BgYfJ026782 for ; Wed, 6 May 2020 07:42:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 19EF11002389; Wed, 6 May 2020 11:42:34 +0000 (UTC) Received: from ibm-p8-15-fsp.mgmt.pnr.lab.eng.rdu2.redhat.com (unknown [10.40.195.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5455B10013D9; Wed, 6 May 2020 11:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588765442; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=IAi5mZE8wl3L/h0Oz6o3QjaZlGLJfTQuwmSKGzd6wQQ=; b=aIp7ckkFVg8gNxOJZkaRoLgMOCW7voeFoQPCciucGjXkPyhyuORW2VSepHRGgPpXwbJoR9 tKnirA2nyeMP7hiyD4iT30diw0cQu0awH1+B+/pNrriKXU/y0VzpuhXIqhzTVXdcULWMOF RNp8w090XEtafBuzBG7vYL4rnveg4jw= X-MC-Unique: ws8GVlewOXWz5AtehDSPRw-1 From: Pavel Mores To: libvir-list@redhat.com Subject: [libvirt PATCH v2 05/10] conf: add virDomainMomentFindLeaf() which operates on virDomainMomentObjPtr Date: Wed, 6 May 2020 13:42:21 +0200 Message-Id: <20200506114226.2538196-6-pmores@redhat.com> In-Reply-To: <20200506114226.2538196-1-pmores@redhat.com> References: <20200506114226.2538196-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Mores 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The new function operates on virDomainMomentObjPtr which is indicated by its name. To avoid code duplication, virDomainMomentObjListFindLeaf() was reimplemented in terms of the new function. Signed-off-by: Pavel Mores Reviewed-by: Peter Krempa --- src/conf/virdomainmomentobjlist.c | 25 +++++++++++++++---------- src/conf/virdomainmomentobjlist.h | 1 + 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentob= jlist.c index 41e887ba18..c57d9cc787 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -207,6 +207,20 @@ virDomainMomentMoveChildren(virDomainMomentObjPtr from, } =20 =20 +/* If there is exactly one leaf node, return that node. */ +virDomainMomentObjPtr +virDomainMomentFindLeaf(virDomainMomentObjPtr moment) +{ + if (moment->nchildren !=3D 1) + return NULL; + while (moment->nchildren =3D=3D 1) + moment =3D moment->first_child; + if (moment->nchildren =3D=3D 0) + return moment; + return NULL; +} + + static virDomainMomentObjPtr virDomainMomentObjNew(void) { @@ -586,17 +600,8 @@ virDomainMomentCheckCycles(virDomainMomentObjListPtr l= ist, return 0; } =20 -/* If there is exactly one leaf node, return that node. */ virDomainMomentObjPtr virDomainMomentObjListFindLeaf(virDomainMomentObjListPtr list) { - virDomainMomentObjPtr moment =3D &list->metaroot; - - if (moment->nchildren !=3D 1) - return NULL; - while (moment->nchildren =3D=3D 1) - moment =3D moment->first_child; - if (moment->nchildren =3D=3D 0) - return moment; - return NULL; + return virDomainMomentFindLeaf(&list->metaroot); } diff --git a/src/conf/virdomainmomentobjlist.h b/src/conf/virdomainmomentob= jlist.h index cab51edbc4..9c2d01ff8f 100644 --- a/src/conf/virdomainmomentobjlist.h +++ b/src/conf/virdomainmomentobjlist.h @@ -62,6 +62,7 @@ void virDomainMomentMoveChildren(virDomainMomentObjPtr fr= om, virDomainMomentObjPtr to); void virDomainMomentLinkParent(virDomainMomentObjListPtr moments, virDomainMomentObjPtr moment); +virDomainMomentObjPtr virDomainMomentFindLeaf(virDomainMomentObjPtr moment= ); =20 virDomainMomentObjListPtr virDomainMomentObjListNew(void); void virDomainMomentObjListFree(virDomainMomentObjListPtr moments); --=20 2.24.1 From nobody Mon May 6 00:32:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1588765516; cv=none; d=zohomail.com; s=zohoarc; b=OoA2sJwZZidbY3NZ6In5dQA/JDgd/cD22rrbIhSvAkRVml+M2EIlw0jKIYxTAQREOaBfcit4WoE20Z5magZIQMtI4yGjkE4KvlzsES1Zc60xNN2yxTpA66/ht90hsfcTzxZMAlGY8pH3P40PUxu+qc7V51gb/ajnIkZX8pNXWeQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588765516; h=Content-Type:Content-Transfer-Encoding:Cc: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; bh=Z5Sh6cdOJLEX0NG2FwBStNznf2ECP8Ql+siwrL3Efp0=; b=jhA9BIsNkvfkMd0L7L1o4mwi8FORNJ1MpXcYr8FsiGmHJ8ChI+l0a60exuWXqj4EH6JKN4n/FxvJjSE20IXFijrnVJZ+4CQHOa5nwwIwyP6yDp95AlWCSSXDta6r1zn8JmujFru+NdI90z7IAt8Ul7i3SYFoyDDjvB+prkwLRBA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1588765516800497.0253567155837; Wed, 6 May 2020 04:45:16 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-67-GArdb_QxN4GEyj28K8NNSw-1; Wed, 06 May 2020 07:42:59 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 26F501937FDE; Wed, 6 May 2020 11:42:45 +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 020786298E; Wed, 6 May 2020 11:42:45 +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 AB1C94CAA0; Wed, 6 May 2020 11:42:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046BgZaG026790 for ; Wed, 6 May 2020 07:42:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3AE62100239A; Wed, 6 May 2020 11:42:35 +0000 (UTC) Received: from ibm-p8-15-fsp.mgmt.pnr.lab.eng.rdu2.redhat.com (unknown [10.40.195.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7800C10013D9; Wed, 6 May 2020 11:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588765515; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Z5Sh6cdOJLEX0NG2FwBStNznf2ECP8Ql+siwrL3Efp0=; b=GchCkUuNI6ELqRaJ69FC8Vs4hJPQCeW7JNcebfBDvrYzISCg50xKeAZFfgHm0XCwrhKIZx nwHOxn0aXMbs+GfAiJuOduTLvF4CdMnDCTcn5XmKS/hUNyPnC65VHBYG3Vi2rbC1k71RM7 mgMBZjv113g+7b6GIrHymghzaG1m0BQ= X-MC-Unique: GArdb_QxN4GEyj28K8NNSw-1 From: Pavel Mores To: libvir-list@redhat.com Subject: [libvirt PATCH v2 06/10] qemu: block: add function to collect blockcommit params and verify them Date: Wed, 6 May 2020 13:42:22 +0200 Message-Id: <20200506114226.2538196-7-pmores@redhat.com> In-Reply-To: <20200506114226.2538196-1-pmores@redhat.com> References: <20200506114226.2538196-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Mores 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Snapshot deletion is implemented as a three-phase process - first we collect specifications of blockcommits used to perform the deletion and run sanity checks to verify that the whole operation is reasonably safe, then we launch the blockcommits and finally we wait for them to finish and check the results. This commit implements the first phase. All information necessary to launch and finish a blockcommit job per disk included in the snapshot is collected in a blockcommit descriptor structure and checked to verify the job makes sense and has a reasonable chance to succeed. Broadly speaking, the checks aim to ensure that the disks in the current running VM are the same as they were when the snapshot was created. Signed-off-by: Pavel Mores --- src/qemu/qemu_driver.c | 154 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6ffd53503b..dc1176bd9c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16752,6 +16752,160 @@ qemuDomainMomentReparentChildren(void *payload, } =20 =20 +/* Blockcommit operation descriptor. Holds data required to launch and + * conclude an individual blockcommit job. Generic parameters + * (virDomainObjPtr, virQEMUDriverPtr) are not stored as they are assumed = to be + * available at the point of blockcommit invocation. */ + +typedef struct { + virDomainDiskDefPtr disk; + virStorageSourcePtr baseSource; + virStorageSourcePtr topSource; + virStorageSourcePtr topParentSource; + int blockCommitFlags; + bool isActive; /* used to find out if pivot is needed to finish the j= ob */ +} virBlockCommitDesc; + +/* Transforms a snapshot into an array of descriptors of blockcommit jobs + * required to delete the snapshot, one descriptor per affected disk. Also + * runs sanity checks for each affected disk and each individual job to ma= ke + * sure the deletion is safe to perform. Returns NULL if safety cannot be + * guaranteed. + * + * (A snapshot is considered safe to delete if, loosely speaking, we can be + * reasonably sure that all disks it touches are still those that were the= re + * when the snapshot was created. For instance, a different disk might be + * attached to the VM under the same target name, or a disk included in the + * snapshot might be reattached to the VM under a different target name. = If + * any such thing happens between the times of snapshot creation and delet= ion, + * that shapshot would not be considered safe to delete.) */ + +static virBlockCommitDesc * +qemuDomainSnapshotDeleteExternalGetJobDescriptors(virDomainObjPtr vm, + virDomainMomentObjPtr snap, + unsigned int flags) +{ + size_t i; + bool isActive; + virDomainSnapshotDefPtr snapdef =3D virDomainSnapshotObjGetDef(snap); + virDomainMomentObjPtr parent =3D snap->parent; + virDomainSnapshotDefPtr parentdef =3D virDomainSnapshotObjGetDef(paren= t); + g_autofree virBlockCommitDesc *blockCommitDescs =3D g_new(virBlockComm= itDesc, snapdef->ndisks); + int blockCommitFlags =3D VIR_DOMAIN_BLOCK_COMMIT_DELETE; + + if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | + VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) { + isActive =3D true; + } else { + isActive =3D snap =3D=3D virDomainSnapshotGetCurrent(vm->snapshots= ); + } + + if (isActive) + blockCommitFlags |=3D VIR_DOMAIN_BLOCK_COMMIT_ACTIVE; + + for (i =3D 0; i < snapdef->ndisks; i++) { + virDomainSnapshotDiskDefPtr snapDisk =3D &(snapdef->disks[i]); + const char *diskName =3D snapDisk->name; + virStorageSourcePtr baseSource =3D NULL; + virStorageSourcePtr topSource =3D NULL; + virStorageSourcePtr topParentSource =3D NULL; + virDomainDiskDefPtr domDiskNow; + virDomainDiskDefPtr domDiskThen =3D virDomainDiskByTarget(snapdef-= >parent.dom, diskName); + virStorageSourcePtr snapSource =3D NULL; + virStorageSourcePtr snapParentSource =3D NULL; + unsigned int snapIndex; + + if (!(domDiskNow =3D qemuDomainDiskByName(vm->def, diskName))) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("can't delete %s, disk '%s' not found in runn= ing VM"), + snapdef->parent.name, diskName); + return NULL; + } + if (snapDisk->src->type !=3D VIR_STORAGE_TYPE_FILE || + domDiskNow->src->type !=3D VIR_STORAGE_TYPE_FILE) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("can't delete %s, only storage type 'file' is= supported"), + snapdef->parent.name); + return NULL; + } + + /* TODO Apr 24, 2020: this is not great long-term as it still look= s up + * essentially just by path (or target[index]), far from a full + * comparison operator for virStorageSources */ + if (virStorageFileParseChainIndex(domDiskNow->dst, snapDisk->src->= path, &snapIndex) < 0 || + !(snapSource =3D virStorageFileChainLookup(domDiskNow->sr= c, NULL, + snapDisk->src->p= ath, snapIndex, + &snapParentSourc= e))) + return NULL; + + if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) { + baseSource =3D snapSource; + } else { + if (parentdef =3D=3D NULL) { + baseSource =3D virStorageFileChainLookup(domDiskNow->src, = NULL, NULL, 0, NULL); + if (!baseSource) + return NULL; + } else { + baseSource =3D snapSource->backingStore; + } + } + + if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | VIR_DOMAIN_SNAP= SHOT_DELETE_CHILDREN_ONLY)) { + topSource =3D domDiskNow->src; + } else { + topSource =3D snapSource; + topParentSource =3D snapParentSource; + } + + if (topSource =3D=3D NULL) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("can't delete %s, couldn't find top (TODO imp= rove this message)"), + snapdef->parent.name); + return NULL; + } + + if (baseSource =3D=3D NULL) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("can't delete %s, couldn't find base (TODO im= prove this message)"), + snapdef->parent.name); + return NULL; + } + + /* Check if the disk called 'diskName' is the same as it was at the + * point 'snap' was created. This is more of a heuristic test as + * virStorageSources don't seem to be well equipped for establishi= ng + * identity. The idea is based on the assumption that snapshots c= an + * only be removed mid-chain, not added. If that holds, the curre= ntly + * running chain has to be the same as it was when 'snap' was crea= ted + * *minus* the snapshots that were deleted in the meantime, if any= . In + * other words, the chain back at the time of 'snap's creation has= to + * be an ordered superset of the currently running disk's chain. */ + virStorageSourcePtr chainNow =3D snapSource->backingStore; + virStorageSourcePtr chainThen =3D NULL; + for (; virStorageSourceIsBacking(chainNow); chainNow =3D chainNow-= >backingStore) { + chainThen =3D virStorageFileChainLookup(domDiskThen->src, + chainThen, chainNow->pat= h, 0, NULL); + if (!chainThen) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("can't delete %s, disk '%s' doesn't seem = the same as when it was created (%s is in %s's backing chain now but it was= n't when the snapshot was created)"), + snapdef->parent.name, diskName, chainNow->p= ath, + snapdef->parent.name); + return NULL; + } + } + + blockCommitDescs[i].disk =3D domDiskNow; + blockCommitDescs[i].baseSource =3D baseSource; + blockCommitDescs[i].topSource =3D topSource; + blockCommitDescs[i].topParentSource =3D topParentSource; + blockCommitDescs[i].blockCommitFlags =3D blockCommitFlags; + blockCommitDescs[i].isActive =3D isActive; + } + + return g_steal_pointer(&blockCommitDescs); +} + + static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags) --=20 2.24.1 From nobody Mon May 6 00:32:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1588765450; cv=none; d=zohomail.com; s=zohoarc; b=VD0/jsK80d0fGsZouXY5qTDdV/bfGmYIm97JrWF3CftJLvMllHwfj0Csaw9cAL7FnqggxlmE9o5G/qeqSzq0c/d3u7fyD62kqXW6DlgS8JHR3P7N0Y5UoKrPFGDckxSaw/TSXcRFzagQXdJye16/pTLPtasJklihLpBLfbtfzdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588765450; h=Content-Type:Content-Transfer-Encoding:Cc: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; bh=3meF0gRpvBrYpl80orEdWahJ9MudOWm7wJq/uTxrcR8=; b=YnDmGabdxOO0kzSjry6wbgcWhz6OaaLrCZfPq5I9GLkRSKO8KEOdKU5ayS7fpn9IjuA9BE16YOHRZ36gi2VIMZG5OHglyNsGDM/KlFd0SNsSEVT2vxhjtpDFFhNuy2nhntQBcAoLJvnx0SAMsDAckBLkNa7Rua9uTLyjgyxHmnw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1588765450526569.5712886527036; Wed, 6 May 2020 04:44:10 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-472-5r2bfmpRNoOLRod9R65G3g-1; Wed, 06 May 2020 07:44:07 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D3321107ACF6; Wed, 6 May 2020 11:44:01 +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 9B1C86607F; Wed, 6 May 2020 11:44:01 +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 4A9FF1809543; Wed, 6 May 2020 11:44:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046BgaGR026801 for ; Wed, 6 May 2020 07:42:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 57A1210021B3; Wed, 6 May 2020 11:42:36 +0000 (UTC) Received: from ibm-p8-15-fsp.mgmt.pnr.lab.eng.rdu2.redhat.com (unknown [10.40.195.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96BD710013D9; Wed, 6 May 2020 11:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588765449; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=3meF0gRpvBrYpl80orEdWahJ9MudOWm7wJq/uTxrcR8=; b=GsK2zQLC6kP71HEQ4SfOnU5hdjrJMIDDxhAIG0a8Z77wU4tSxmG6kagQnd+IywrnZFF/y9 ZLEJUxCErhHaT7TYDzW/7BmwtmAS1/295l4IMxhQwv8brgSHx10p6YDGiOoYwmqyf5/Anh 8mSp7jwWJNWZ9m5tR6HyfUwifVH8f6g= X-MC-Unique: 5r2bfmpRNoOLRod9R65G3g-1 From: Pavel Mores To: libvir-list@redhat.com Subject: [libvirt PATCH v2 07/10] qemu: block: add function to launch all prepared blockcommits Date: Wed, 6 May 2020 13:42:23 +0200 Message-Id: <20200506114226.2538196-8-pmores@redhat.com> In-Reply-To: <20200506114226.2538196-1-pmores@redhat.com> References: <20200506114226.2538196-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Mores 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This is the second phase of snapshot deletion. We have all information necessary to delete the snapshot by running blockcommits and we haven't detected any problems that would make the deletion unsafe. Now we just launch the blockcommits in parallel. Signed-off-by: Pavel Mores --- src/qemu/qemu_driver.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index dc1176bd9c..35b7fb69d5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -154,6 +154,16 @@ static int qemuOpenFileAs(uid_t fallback_uid, gid_t fa= llback_gid, =20 static virQEMUDriverPtr qemu_driver; =20 +static int +qemuDomainBlockCommitCommon(virDomainObjPtr vm, + virQEMUDriverPtr driver, + virDomainDiskDefPtr disk, + virStorageSourcePtr baseSource, + virStorageSourcePtr topSource, + virStorageSourcePtr topParentSource, + unsigned long bandwidth, + unsigned int flags); + static int qemuDomainBlockCommitImpl(virDomainObjPtr vm, virQEMUDriverPtr driver, @@ -16906,6 +16916,31 @@ qemuDomainSnapshotDeleteExternalGetJobDescriptors(= virDomainObjPtr vm, } =20 =20 +static int +qemuDomainSnapshotDeleteExternalLaunchJobs(virDomainObjPtr vm, + virQEMUDriverPtr driver, + const virBlockCommitDesc *block= CommitDescs, + int numDescs) +{ + size_t i; + + for (i =3D 0; i < numDescs; i++) { + virDomainDiskDefPtr disk =3D blockCommitDescs[i].disk; + virStorageSourcePtr baseSource =3D blockCommitDescs[i].baseSource; + virStorageSourcePtr topSource =3D blockCommitDescs[i].topSource; + virStorageSourcePtr topParentSource =3D blockCommitDescs[i].topPar= entSource; + int blockCommitFlags =3D blockCommitDescs[i].blockCommitFlags; + + if (qemuDomainBlockCommitCommon(vm, driver, disk, baseSource, + topSource, topParentSource, + 0, blockCommitFlags) < 0) + return -1; + } + + return 0; +} + + static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags) --=20 2.24.1 From nobody Mon May 6 00:32:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1588765444; cv=none; d=zohomail.com; s=zohoarc; b=nUXag6mIl5dT33dCYB/O9O347jKqyOUZKKmoSah9n2vbbxUhRBZo52QTmO0Y/0WFwYjffdg4PKAzk4EhvosBsN7nVcBNzdBMWEDe80wOlWrMumxa/SR4ib5h8QL9Q65GWzJcMR4R/MHZOdxeCrBNroTp8IdVgmjLVf35FcHyCr4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588765444; h=Content-Type:Content-Transfer-Encoding:Cc: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; bh=PXT0fH5mUSTU09qQp5y8mWPp8+SbEeiJMV/XzqiRKhs=; b=PJQzbRvaNHdIJ+jzQuIKI4BlhaG0kPn5cntJuXU7pzwsCH/uQ3dZK0zuNELgdyoy7kTZ/jew0y03GX34fIx1NL52IvIHB0RCus93Eh0qesf099hCfQPC8P6+9NdPKEOXqFExZglvtCbOe4cv0wOgv4IHOI0adMRTXRq6DPxvi9M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 158876544453763.8909184213843; Wed, 6 May 2020 04:44:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-20-_sPVsUH9OXiT8Dm1Zz3dGw-1; Wed, 06 May 2020 07:43:03 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 78A1E107ACCA; Wed, 6 May 2020 11:42:55 +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 51E3A10013D9; Wed, 6 May 2020 11:42:55 +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 0A5431809563; Wed, 6 May 2020 11:42:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046Bgb5c026812 for ; Wed, 6 May 2020 07:42:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7A9FF10021B3; Wed, 6 May 2020 11:42:37 +0000 (UTC) Received: from ibm-p8-15-fsp.mgmt.pnr.lab.eng.rdu2.redhat.com (unknown [10.40.195.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id B260E1002398; Wed, 6 May 2020 11:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588765443; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=PXT0fH5mUSTU09qQp5y8mWPp8+SbEeiJMV/XzqiRKhs=; b=EnVZheOmsFTWbYJunmvA0UMgOuXQ8yro3vKuS+FT4m3puwLNpb5aWVe6o2wlYHZIWs1tk4 DlTyUKx6nm9DboLgLzh/7kbOVANui6htAvzqsBxHswwEwN16WXllwzHj6aL85UQtCWrmEq sYWDPc/5bjf+PbsPdBKiwrQ6KFr6W2A= X-MC-Unique: _sPVsUH9OXiT8Dm1Zz3dGw-1 From: Pavel Mores To: libvir-list@redhat.com Subject: [libvirt PATCH v2 08/10] qemu: block: add function to wait for blockcommits and collect results Date: Wed, 6 May 2020 13:42:24 +0200 Message-Id: <20200506114226.2538196-9-pmores@redhat.com> In-Reply-To: <20200506114226.2538196-1-pmores@redhat.com> References: <20200506114226.2538196-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Mores 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This is the third phase of snapshot deletion. Blockcommits to delete the snapshot have been launched and now we can wait for them to finish, check results and report errors if any. Signed-off-by: Pavel Mores --- src/qemu/qemu_driver.c | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 35b7fb69d5..a2629e9002 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16941,6 +16941,65 @@ qemuDomainSnapshotDeleteExternalLaunchJobs(virDoma= inObjPtr vm, } =20 =20 +static int +qemuDomainSnapshotDeleteExternalWaitForJobs(virDomainObjPtr vm, + virQEMUDriverPtr driver, + const virBlockCommitDesc *bloc= kCommitDescs, + int numDescs) +{ + size_t i; + + for (i =3D 0; i < numDescs; i++) { + virDomainDiskDefPtr disk =3D blockCommitDescs[i].disk; + bool isActive =3D blockCommitDescs[i].isActive; + + /* wait for the blockcommit job to finish (in particular, reach + * one of the finished QEMU_BLOCKJOB_STATE_* states)... */ + g_autoptr(qemuBlockJobData) job =3D NULL; + + if (!(job =3D qemuBlockJobDiskGetJob(disk))) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("disk %s does not have an active block job"), di= sk->dst); + return -1; + } + + qemuBlockJobSyncBegin(job); + qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE); + while (job->state !=3D QEMU_BLOCKJOB_STATE_READY && + job->state !=3D QEMU_BLOCKJOB_STATE_FAILED && + job->state !=3D QEMU_BLOCKJOB_STATE_CANCELLED && + job->state !=3D QEMU_BLOCKJOB_STATE_COMPLETED) { + + if (virDomainObjWait(vm) < 0) + return -1; + qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE); + } + qemuBlockJobSyncEnd(vm, job, QEMU_ASYNC_JOB_NONE); + + if ((isActive && job->state !=3D QEMU_BLOCKJOB_STATE_READY) || + (!isActive && job->state !=3D QEMU_BLOCKJOB_STATE_COMPLETED)) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("blockcomit job failed for disk %s"), disk->dst); + /* TODO Apr 30, 2020: how to handle this? Bailing out doesn't + * seem an obvious option in this case as all blockjobs are now + * created and running - if any of them are to fail they will, + * regardless of whether we break here. It might make more + * sense to continue and at least report all errors. */ + /*return -1;*/ + } + + /* ... and pivot if necessary */ + if (isActive) { + if (qemuDomainBlockJobAbortImpl(driver, vm, disk->dst, + VIR_DOMAIN_BLOCK_JOB_ABORT_PIV= OT) < 0) + return -1; + } + } + + return 0; +} + + static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags) --=20 2.24.1 From nobody Mon May 6 00:32:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1588765389; cv=none; d=zohomail.com; s=zohoarc; b=fVKKwmRGnm0MIL4FqrNbj5NgkMeEyfmLta1hVVDGpHTR7J71Q1nX8ghP8TsIiBo1YXzeSQovUwg8LxuxA7rYiyXJyaR3ID8LxhKRyuV+sZrnrxPVdzo0YpQ0HMxFn/Pe1qTd41/YZuTPaqulfitVbWRVaE4bkS0Ey32Mkgd2uYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588765389; h=Content-Type:Content-Transfer-Encoding:Cc: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; bh=4VBEPpVclKw/bSdKgq0HigI16KCALYLYi3jeNfR7C7c=; b=a0Lnm6a8kKgmRSToEp4bQUZKbzcHJ+fodhWaQLJAFhfc9gfC8SDVMfwdiaf3SMHfhGQLsxPFCSqw3eEF98LXO0EZSzZHmSq0xQ7yZV6n9++dTF0uxDw6C96Zp9gLqx8+pyzd2xy3XiOELRuz+4ZfIumf1pHEXvabWRggvwqcWJU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1588765389299369.67269012925976; Wed, 6 May 2020 04:43:09 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-wqd6mypTMpSJ_wXGgrBA4Q-1; Wed, 06 May 2020 07:43:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C831B1B18BC0; Wed, 6 May 2020 11:42:58 +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 A337C5D9C5; Wed, 6 May 2020 11:42:58 +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 653E64CAA7; Wed, 6 May 2020 11:42:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046Bgc1i026822 for ; Wed, 6 May 2020 07:42:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id B2113100239A; Wed, 6 May 2020 11:42:38 +0000 (UTC) Received: from ibm-p8-15-fsp.mgmt.pnr.lab.eng.rdu2.redhat.com (unknown [10.40.195.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAFFB10013D9; Wed, 6 May 2020 11:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588765388; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4VBEPpVclKw/bSdKgq0HigI16KCALYLYi3jeNfR7C7c=; b=Gi6tZJDwxJwDFmLaMAJ2Hn65fKy4J/LnOBlMEn9PH/yInDstWvm+YQJYbei5n85L+ZgmSz GU8Zr3t3gJqCOjnace+VunLLMfXhPuke0s/oQUUCub4K/j/2zHlLoNtEyNw8gTUIoGVwyf Ct2iDpnjsd6Xc4HXBZpvHuRCtPtM7lc= X-MC-Unique: wqd6mypTMpSJ_wXGgrBA4Q-1 From: Pavel Mores To: libvir-list@redhat.com Subject: [libvirt PATCH v2 09/10] qemu: block: add external snapshot-delete top-level algorithm Date: Wed, 6 May 2020 13:42:25 +0200 Message-Id: <20200506114226.2538196-10-pmores@redhat.com> In-Reply-To: <20200506114226.2538196-1-pmores@redhat.com> References: <20200506114226.2538196-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Mores 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This uses the helpers introduced in previous three commits and assembles the top-level snapshot deletion algorithm in their terms. Note that the third phase - waiting for blockcommits to finish - is conceptually optional and a flag/parameter might be exposed to the user in the future to skip the third phase. This would make the whole operation asynchronous and let the user deal with concluding the blockcommits manually, using the generic blockjob tools. Signed-off-by: Pavel Mores --- src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 64 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 935ef7303b..f68eb500ec 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1049,6 +1049,7 @@ virDomainListCheckpoints; # conf/virdomainmomentobjlist.h virDomainMomentDropChildren; virDomainMomentDropParent; +virDomainMomentFindLeaf; virDomainMomentForEachChild; virDomainMomentForEachDescendant; virDomainMomentMoveChildren; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a2629e9002..57e81e3720 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17000,6 +17000,70 @@ qemuDomainSnapshotDeleteExternalWaitForJobs(virDom= ainObjPtr vm, } =20 =20 +static int +qemuDomainSnapshotDeleteExternal(virDomainObjPtr vm, + virQEMUDriverPtr driver, + virDomainMomentObjPtr snap, + unsigned int flags) +{ + /* TODO Apr 29, 2020: ultimately, use 'flags' to set this. Until that + * is supported, just run always synchronously. */ + bool async =3D false; + virDomainSnapshotDefPtr snapdef =3D virDomainSnapshotObjGetDef(snap); + virDomainMomentObjPtr leaf =3D snap->nchildren ? virDomainMomentFindLe= af(snap) : snap; + virDomainMomentObjPtr parent =3D snap->parent; + g_autofree virBlockCommitDesc *blockCommitDescs =3D NULL; + int numBlockCommits =3D snapdef->ndisks; + + /* This function only works if the chain below 'snap' is linear. If + * there's no unique leaf it means the chain of 'snap's children + * branches at some point. Also, if there *is* a leaf but it's not + * the current snapshot, bail out as well. */ + if (leaf =3D=3D NULL) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("can't delete '%s', snapshot chain branches"), + snapdef->parent.name); + return -1; + } + if (leaf !=3D virDomainSnapshotGetCurrent(vm->snapshots)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("can't delete '%s', leaf snapshot is not current"= ), + snapdef->parent.name); + return -1; + } + if (parent->nchildren > 1) { + /* TODO 'snap's parent has multiple children, meaning it's a + * branching point in snapshot tree. This means we can't + * delete 'snap' by commiting into its parent as doing so would + * corrupt the other branches rooted in the parent. We might + * still be able to delete 'snap' though by pulling into its + * child/children. */ + + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("can't delete %s, its parent has multiple childre= n"), + snapdef->parent.name); + return -1; + } + + if (!virDomainObjIsActive(vm)) + return -1; + + blockCommitDescs =3D qemuDomainSnapshotDeleteExternalGetJobDescriptors= (vm, snap, flags); + if (blockCommitDescs =3D=3D NULL) + return -1; + + if (qemuDomainSnapshotDeleteExternalLaunchJobs(vm, driver, blockCommit= Descs, numBlockCommits) < 0) + return -1; + + if (!async) { + if (qemuDomainSnapshotDeleteExternalWaitForJobs(vm, driver, blockC= ommitDescs, numBlockCommits) < 0) + return -1; + } + + return 0; +} + + static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags) --=20 2.24.1 From nobody Mon May 6 00:32:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1588765385; cv=none; d=zohomail.com; s=zohoarc; b=dvPJjA8UD8JTmQ7WvFCmQjiWixpKVj71icDcXatGxzqapbHpyrDYmrYWfLW6sBfEwMD6imKLRxOIc4H2DeGiILXP0PIllchaCG9dzjBanBENrprrKGccA6D/CWUzlT4OAQF/G1CNjxDARgWTxvSKByiWLmu2r8jE8slC3eQ0r4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588765385; h=Content-Type:Content-Transfer-Encoding:Cc: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; bh=1a5SiXJy/T2COg9U3vTwwRuS1kMVa1/eUUjRFVLTfwU=; b=KY0Cd9pZoWhl9m/KAZBZUBDNEOeSx/RPAT09sN8ZzfduXg0b4qFSExR4X0g4Y/gFsdN81GA0OCt7jcoJGNOJtpz0+nZrMfUwxu42ou+YJN2V3QqDJ3YBhKdc/6QpvA+BTNhcGg1sxnrofFfIiwvnsZd/mKXuNcBt9sd7O8UYPd0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1588765385386220.9133199192903; Wed, 6 May 2020 04:43:05 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-233-d4R3Pl4DPCCE_jLxD123Jg-1; Wed, 06 May 2020 07:43:02 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 82EEC100D02E; Wed, 6 May 2020 11:42:48 +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 3B0ED1036D11; Wed, 6 May 2020 11:42:48 +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 EA0784CAA8; Wed, 6 May 2020 11:42:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046BgdeZ026833 for ; Wed, 6 May 2020 07:42:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id C623D1000079; Wed, 6 May 2020 11:42:39 +0000 (UTC) Received: from ibm-p8-15-fsp.mgmt.pnr.lab.eng.rdu2.redhat.com (unknown [10.40.195.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1091810013D9; Wed, 6 May 2020 11:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588765384; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1a5SiXJy/T2COg9U3vTwwRuS1kMVa1/eUUjRFVLTfwU=; b=AyXE/GmlyxgE6UgABTb+72Ncm3fxUt5JE8QODGg4HKvogKW34261NqCYf9HRC/jqXwh/fc vub5xbDLUZiU2K91y6D1VFbY9rMBVXd/14IAHI8QaCJs8cNNoLAH3tZbNWZqJFOkrgJ11M DMvYpCqruwCDRslbR7hdTjZ/vPSlrBQ= X-MC-Unique: d4R3Pl4DPCCE_jLxD123Jg-1 From: Pavel Mores To: libvir-list@redhat.com Subject: [libvirt PATCH v2 10/10] qemu: block: add actual invocation of external snapshot-delete Date: Wed, 6 May 2020 13:42:26 +0200 Message-Id: <20200506114226.2538196-11-pmores@redhat.com> In-Reply-To: <20200506114226.2538196-1-pmores@redhat.com> References: <20200506114226.2538196-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Mores 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Plug in the external snapshot deletion framework built in previous commits. Signed-off-by: Pavel Mores --- src/qemu/qemu_driver.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 57e81e3720..34c0e27eb9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17106,10 +17106,8 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snap= shot, qemuDomainSnapshotCountExtern= al, &external); if (external) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("deletion of %d external disk snapshots not " - "supported yet"), external); - goto endjob; + if (qemuDomainSnapshotDeleteExternal(vm, driver, snap, flags) = < 0) + goto endjob; } } =20 --=20 2.24.1