From nobody Fri May 3 06:59:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1559088166; cv=none; d=zoho.com; s=zohoarc; b=Pcsur2vd02eVgcSMoUrZqU5n4yd2LAxW782n0gZMSK9opdYHpWEDv1UoJU02Ve/xIFpWTIGyvBmgXaWzV/Fu6P+UI04yhEHMA0LDrRhq63hHlbulaUaxeSmmnbxADEghRh7Lw1z0f3OhmlUwreatdIEkb55/z27bnLZd3G5jtLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559088166; 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:ARC-Authentication-Results; bh=Tm+sFMO1gngkaw/+H/zzqiOJjSQTYj5vmAInZNFt1tg=; b=f/ZJtn85ow8//R3yB3+Zb0sffCMY5mkK9hvRootuMdzvmF5pDK7nA04W2b+FPrfFTnp7uAj89ChoI9JfLp8rGh10r5boyy9SoaTUwu7fJfixEykXcEwN0bSVcqX3SoqVnJTGdpztHUqc4UyXijQBRNoTrU9I4eozbfh9FtKr1OQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559088166705979.2257175208349; Tue, 28 May 2019 17:02:46 -0700 (PDT) Received: from localhost ([127.0.0.1]:44416 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVm3D-0000LZ-MR for importer@patchew.org; Tue, 28 May 2019 20:02:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVlzi-0006Q6-90 for qemu-devel@nongnu.org; Tue, 28 May 2019 19:59:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVlzg-0001Ip-DB for qemu-devel@nongnu.org; Tue, 28 May 2019 19:59:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54562) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hVlzc-0001GP-F2; Tue, 28 May 2019 19:58:56 -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 mx1.redhat.com (Postfix) with ESMTPS id 35D6F305B418; Tue, 28 May 2019 23:58:54 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-187.bos.redhat.com [10.18.17.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FDA05F9D5; Tue, 28 May 2019 23:58:45 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Date: Tue, 28 May 2019 19:58:40 -0400 Message-Id: <20190528235842.29453-2-jsnow@redhat.com> In-Reply-To: <20190528235842.29453-1-jsnow@redhat.com> References: <20190528235842.29453-1-jsnow@redhat.com> MIME-Version: 1.0 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.47]); Tue, 28 May 2019 23:58:54 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/3] migration/dirty-bitmaps: change bitmap enumeration method X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Vladimir Sementsov-Ogievskiy , aihua liang , qemu-block@nongnu.org, qemu-stable@nongnu.org, Stefan Hajnoczi , jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Shift from looking at every root BDS to *every* BDS. This will migrate bitmaps that are attached to blockdev created nodes instead of just ones attached to emulated storage devices. Note that this will not migrate anonymous or internal-use bitmaps, as those are defined as having no name. This will also fix the Coverity issues Peter Maydell has been asking about for the past several releases, as well as fixing a real bug. Reported-by: Peter Maydell Reported-by: Coverity =F0=9F=98=85 Reported-by: aihua liang Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: John Snow Message-id: 20190514201926.10407-1-jsnow@redhat.com Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1652490 Fixes: Coverity CID 1390625 CC: Stefan Hajnoczi Signed-off-by: John Snow --- migration/block-dirty-bitmap.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index d1bb863cb6..4a896a09eb 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -273,7 +273,6 @@ static int init_dirty_bitmap_migration(void) BlockDriverState *bs; BdrvDirtyBitmap *bitmap; DirtyBitmapMigBitmapState *dbms; - BdrvNextIterator it; Error *local_err =3D NULL; =20 dirty_bitmap_mig_state.bulk_completed =3D false; @@ -281,13 +280,8 @@ static int init_dirty_bitmap_migration(void) dirty_bitmap_mig_state.prev_bitmap =3D NULL; dirty_bitmap_mig_state.no_bitmaps =3D false; =20 - for (bs =3D bdrv_first(&it); bs; bs =3D bdrv_next(&it)) { - const char *drive_name =3D bdrv_get_device_or_node_name(bs); - - /* skip automatically inserted nodes */ - while (bs && bs->drv && bs->implicit) { - bs =3D backing_bs(bs); - } + for (bs =3D bdrv_next_all_states(NULL); bs; bs =3D bdrv_next_all_state= s(bs)) { + const char *name =3D bdrv_get_device_or_node_name(bs); =20 for (bitmap =3D bdrv_dirty_bitmap_next(bs, NULL); bitmap; bitmap =3D bdrv_dirty_bitmap_next(bs, bitmap)) @@ -296,7 +290,7 @@ static int init_dirty_bitmap_migration(void) continue; } =20 - if (drive_name =3D=3D NULL) { + if (!name || strcmp(name, "") =3D=3D 0) { error_report("Found bitmap '%s' in unnamed node %p. It can= 't " "be migrated", bdrv_dirty_bitmap_name(bitmap)= , bs); goto fail; @@ -313,7 +307,7 @@ static int init_dirty_bitmap_migration(void) =20 dbms =3D g_new0(DirtyBitmapMigBitmapState, 1); dbms->bs =3D bs; - dbms->node_name =3D drive_name; + dbms->node_name =3D name; dbms->bitmap =3D bitmap; dbms->total_sectors =3D bdrv_nb_sectors(bs); dbms->sectors_per_chunk =3D CHUNK_SIZE * 8 * --=20 2.20.1 From nobody Fri May 3 06:59:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1559088072; cv=none; d=zoho.com; s=zohoarc; b=Lxj2P4pLiH4Y6+0OJLpEkUhM9yY+dfSjWORoDicckNBUXb9KGWmQzfCWZlhTnuxmloIz7ZLgFEZmiGk304cqxYA9OYeJmYDwKE6rHqjf7Quc1QfzJL8i1oZ+3dcGECIBbplHef3cDFBsEDGG+IpQTJp5NfgxZtgO3aBXEZD15Os= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559088072; h=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:ARC-Authentication-Results; bh=2d2IBxlX1zBZY04K5obGAHVRlG0weVdnrut+MNXK0XE=; b=MmvHdVwTQrN5H3LAbmeuoBWnP7g+dq1hoxgWtB7p6J9Tfk51r9nyAU4K2DU8GMjYraioOI5dMNFOsiiQcHflZHkl9iS89lM8QUZam753m35kMvrZOoaXWaRAVypKa8PPxgKd9zMCR+ECWH/I/RQtY2ovszKU4jqx5oaydMRCXoc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559088072013244.77808938553392; Tue, 28 May 2019 17:01:12 -0700 (PDT) Received: from localhost ([127.0.0.1]:44399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVm1b-0007Yo-U3 for importer@patchew.org; Tue, 28 May 2019 20:00:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVlzn-0006Ui-4r for qemu-devel@nongnu.org; Tue, 28 May 2019 19:59:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVlzi-0001OA-88 for qemu-devel@nongnu.org; Tue, 28 May 2019 19:59:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60052) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hVlze-0001HC-H1; Tue, 28 May 2019 19:58:58 -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 mx1.redhat.com (Postfix) with ESMTPS id CE3A530C1AE7; Tue, 28 May 2019 23:58:56 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-187.bos.redhat.com [10.18.17.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 579CB5FC01; Tue, 28 May 2019 23:58:54 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Date: Tue, 28 May 2019 19:58:41 -0400 Message-Id: <20190528235842.29453-3-jsnow@redhat.com> In-Reply-To: <20190528235842.29453-1-jsnow@redhat.com> References: <20190528235842.29453-1-jsnow@redhat.com> MIME-Version: 1.0 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.40]); Tue, 28 May 2019 23:58:56 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/3] qapi: support external bitmaps in block-dirty-bitmap-merge X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Vladimir Sementsov-Ogievskiy , jsnow@redhat.com, qemu-stable@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Add new optional parameter making possible to merge bitmaps from different nodes. It is needed to maintain external snapshots during incremental backup chain history. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: John Snow Message-id: 20190517152111.206494-2-vsementsov@virtuozzo.com Signed-off-by: John Snow --- qapi/block-core.json | 22 ++++++++++++++++--- block/dirty-bitmap.c | 9 +++++--- blockdev.c | 50 +++++++++++++++++++++++++++++--------------- 3 files changed, 58 insertions(+), 23 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 7ccbfff9d0..dcc935d655 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2003,19 +2003,35 @@ 'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32', '*persistent': 'bool', '*autoload': 'bool', '*disabled': 'bool= ' } } =20 +## +# @BlockDirtyBitmapMergeSource: +# +# @local: name of the bitmap, attached to the same node as target bitmap. +# +# @external: bitmap with specified node +# +# Since: 4.1 +## +{ 'alternate': 'BlockDirtyBitmapMergeSource', + 'data': { 'local': 'str', + 'external': 'BlockDirtyBitmap' } } + ## # @BlockDirtyBitmapMerge: # -# @node: name of device/node which the bitmap is tracking +# @node: name of device/node which the @target bitmap is tracking # # @target: name of the destination dirty bitmap # -# @bitmaps: name(s) of the source dirty bitmap(s) +# @bitmaps: name(s) of the source dirty bitmap(s) at @node and/or fully +# specifed BlockDirtyBitmap elements. The latter are supported +# since 4.1. # # Since: 4.0 ## { 'struct': 'BlockDirtyBitmapMerge', - 'data': { 'node': 'str', 'target': 'str', 'bitmaps': ['str'] } } + 'data': { 'node': 'str', 'target': 'str', + 'bitmaps': ['BlockDirtyBitmapMergeSource'] } } =20 ## # @block-dirty-bitmap-add: diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 59e6ebb861..49646a30e6 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -816,10 +816,10 @@ void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, c= onst BdrvDirtyBitmap *src, { bool ret; =20 - /* only bitmaps from one bds are supported */ - assert(dest->mutex =3D=3D src->mutex); - qemu_mutex_lock(dest->mutex); + if (src->mutex !=3D dest->mutex) { + qemu_mutex_lock(src->mutex); + } =20 if (bdrv_dirty_bitmap_check(dest, BDRV_BITMAP_DEFAULT, errp)) { goto out; @@ -845,4 +845,7 @@ void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, con= st BdrvDirtyBitmap *src, =20 out: qemu_mutex_unlock(dest->mutex); + if (src->mutex !=3D dest->mutex) { + qemu_mutex_unlock(src->mutex); + } } diff --git a/blockdev.c b/blockdev.c index 79fbac8450..64ccef735b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2112,11 +2112,10 @@ static void block_dirty_bitmap_disable_abort(BlkAct= ionState *common) } } =20 -static BdrvDirtyBitmap *do_block_dirty_bitmap_merge(const char *node, - const char *target, - strList *bitmaps, - HBitmap **backup, - Error **errp); +static BdrvDirtyBitmap *do_block_dirty_bitmap_merge( + const char *node, const char *target, + BlockDirtyBitmapMergeSourceList *bitmaps, + HBitmap **backup, Error **errp); =20 static void block_dirty_bitmap_merge_prepare(BlkActionState *common, Error **errp) @@ -2965,15 +2964,14 @@ void qmp_block_dirty_bitmap_disable(const char *nod= e, const char *name, bdrv_disable_dirty_bitmap(bitmap); } =20 -static BdrvDirtyBitmap *do_block_dirty_bitmap_merge(const char *node, - const char *target, - strList *bitmaps, - HBitmap **backup, - Error **errp) +static BdrvDirtyBitmap *do_block_dirty_bitmap_merge( + const char *node, const char *target, + BlockDirtyBitmapMergeSourceList *bitmaps, + HBitmap **backup, Error **errp) { BlockDriverState *bs; BdrvDirtyBitmap *dst, *src, *anon; - strList *lst; + BlockDirtyBitmapMergeSourceList *lst; Error *local_err =3D NULL; =20 dst =3D block_dirty_bitmap_lookup(node, target, &bs, errp); @@ -2988,11 +2986,28 @@ static BdrvDirtyBitmap *do_block_dirty_bitmap_merge= (const char *node, } =20 for (lst =3D bitmaps; lst; lst =3D lst->next) { - src =3D bdrv_find_dirty_bitmap(bs, lst->value); - if (!src) { - error_setg(errp, "Dirty bitmap '%s' not found", lst->value); - dst =3D NULL; - goto out; + switch (lst->value->type) { + const char *name, *node; + case QTYPE_QSTRING: + name =3D lst->value->u.local; + src =3D bdrv_find_dirty_bitmap(bs, name); + if (!src) { + error_setg(errp, "Dirty bitmap '%s' not found", name); + dst =3D NULL; + goto out; + } + break; + case QTYPE_QDICT: + node =3D lst->value->u.external.node; + name =3D lst->value->u.external.name; + src =3D block_dirty_bitmap_lookup(node, name, NULL, errp); + if (!src) { + dst =3D NULL; + goto out; + } + break; + default: + abort(); } =20 bdrv_merge_dirty_bitmap(anon, src, NULL, &local_err); @@ -3012,7 +3027,8 @@ static BdrvDirtyBitmap *do_block_dirty_bitmap_merge(c= onst char *node, } =20 void qmp_block_dirty_bitmap_merge(const char *node, const char *target, - strList *bitmaps, Error **errp) + BlockDirtyBitmapMergeSourceList *bitmaps, + Error **errp) { do_block_dirty_bitmap_merge(node, target, bitmaps, NULL, errp); } --=20 2.20.1 From nobody Fri May 3 06:59:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1559088190; cv=none; d=zoho.com; s=zohoarc; b=JrORRLbwcJwkGsxVrrnjVYmkEPQyMijIeTmVeytTRVZqGzcFvhOZ+HV2YedNSLo4V7msAP3YTAU6eQx2G5QwtMIBpNJsnJsoNrEx2wnBAmCVEsWCXLXWaNn0DUjtsMpNoB9ZLZytfshiY8UxikTX7t6KEH6GGRq2e+dtElfAm/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559088190; h=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:ARC-Authentication-Results; bh=pEEfKlCgXRezMgj+DiWnylhNMZAYPTdZtIoVUwcEiUQ=; b=c6ZMF75Hw4lGmZD9L2DxVeo8NuoEP6QOukInWUzZofS7txUhl2Qiu3WrmO5AlSLujjkwAMqBGI7/CVGHvYSOzBfm8ihaYwj8Pzrr5JIPLsoQnh03fBZU9ABzGWjEjB6EiG62w2XShGbij3UgwuS85zswoD1s6O0f7nL/vAe36Wk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559088190878418.67545440573474; Tue, 28 May 2019 17:03:10 -0700 (PDT) Received: from localhost ([127.0.0.1]:44418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVm3f-0000dF-0K for importer@patchew.org; Tue, 28 May 2019 20:03:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVlzp-0006Wh-IY for qemu-devel@nongnu.org; Tue, 28 May 2019 19:59:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVlzo-0001Uw-AA for qemu-devel@nongnu.org; Tue, 28 May 2019 19:59:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54582) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hVlzg-0001IM-Eo; Tue, 28 May 2019 19:59:01 -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 mx1.redhat.com (Postfix) with ESMTPS id 0E109301988B; Tue, 28 May 2019 23:58:59 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-187.bos.redhat.com [10.18.17.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id F07201715C; Tue, 28 May 2019 23:58:56 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Date: Tue, 28 May 2019 19:58:42 -0400 Message-Id: <20190528235842.29453-4-jsnow@redhat.com> In-Reply-To: <20190528235842.29453-1-jsnow@redhat.com> References: <20190528235842.29453-1-jsnow@redhat.com> MIME-Version: 1.0 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.47]); Tue, 28 May 2019 23:58:59 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/3] iotests: test external snapshot with bitmap copying X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Vladimir Sementsov-Ogievskiy , jsnow@redhat.com, qemu-stable@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy This test shows that external snapshots and incremental backups are friends. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: John Snow Message-id: 20190517152111.206494-3-vsementsov@virtuozzo.com Signed-off-by: John Snow --- tests/qemu-iotests/254 | 52 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/254.out | 52 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 105 insertions(+) create mode 100755 tests/qemu-iotests/254 create mode 100644 tests/qemu-iotests/254.out diff --git a/tests/qemu-iotests/254 b/tests/qemu-iotests/254 new file mode 100755 index 0000000000..33cb80a512 --- /dev/null +++ b/tests/qemu-iotests/254 @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# +# Test external snapshot with bitmap copying. +# +# Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import iotests +from iotests import qemu_img_create, file_path, log + +disk, top =3D file_path('disk', 'top') +size =3D 1024 * 1024 + +qemu_img_create('-f', iotests.imgfmt, disk, str(size)) + +vm =3D iotests.VM().add_drive(disk, opts=3D'node-name=3Dbase') +vm.launch() + +vm.qmp_log('block-dirty-bitmap-add', node=3D'drive0', name=3D'bitmap0') + +vm.hmp_qemu_io('drive0', 'write 0 512K') + +vm.qmp_log('transaction', indent=3D2, actions=3D[ + {'type': 'blockdev-snapshot-sync', + 'data': {'device': 'drive0', 'snapshot-file': top, + 'snapshot-node-name': 'snap'}}, + {'type': 'block-dirty-bitmap-add', + 'data': {'node': 'snap', 'name': 'bitmap0'}}, + {'type': 'block-dirty-bitmap-merge', + 'data': {'node': 'snap', 'target': 'bitmap0', + 'bitmaps': [{'node': 'base', 'name': 'bitmap0'}]}} +], filters=3D[iotests.filter_qmp_testfiles]) + +result =3D vm.qmp('query-block')['return'][0] +log("query-block: device =3D {}, node-name =3D {}, dirty-bitmaps:".format( + result['device'], result['inserted']['node-name'])) +log(result['dirty-bitmaps'], indent=3D2) + +vm.shutdown() diff --git a/tests/qemu-iotests/254.out b/tests/qemu-iotests/254.out new file mode 100644 index 0000000000..d7394cf002 --- /dev/null +++ b/tests/qemu-iotests/254.out @@ -0,0 +1,52 @@ +{"execute": "block-dirty-bitmap-add", "arguments": {"name": "bitmap0", "no= de": "drive0"}} +{"return": {}} +{ + "execute": "transaction", + "arguments": { + "actions": [ + { + "data": { + "device": "drive0", + "snapshot-file": "TEST_DIR/PID-top", + "snapshot-node-name": "snap" + }, + "type": "blockdev-snapshot-sync" + }, + { + "data": { + "name": "bitmap0", + "node": "snap" + }, + "type": "block-dirty-bitmap-add" + }, + { + "data": { + "bitmaps": [ + { + "name": "bitmap0", + "node": "base" + } + ], + "node": "snap", + "target": "bitmap0" + }, + "type": "block-dirty-bitmap-merge" + } + ] + } +} +{ + "return": {} +} +query-block: device =3D drive0, node-name =3D snap, dirty-bitmaps: +[ + { + "busy": false, + "count": 524288, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true, + "status": "active" + } +] diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 2c74deec00..859c4b5e9f 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -264,3 +264,4 @@ 249 rw auto quick 252 rw auto backing quick 253 rw auto quick +254 rw auto backing quick --=20 2.20.1