From nobody Wed May 8 20:06: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 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 1580481242125996.2020918090299; Fri, 31 Jan 2020 06:34:02 -0800 (PST) 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-336-I4A0UNLfPfi1TyADfuVunQ-1; Fri, 31 Jan 2020 09:33:58 -0500 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 0EE5113F5; Fri, 31 Jan 2020 14:33:49 +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 DD7D95DDAA; Fri, 31 Jan 2020 14:33: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 9B7C185CD2; Fri, 31 Jan 2020 14:33:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVWAH019714 for ; Fri, 31 Jan 2020 09:31:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7C2BE89E85; Fri, 31 Jan 2020 14:31:32 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1D4B89E82; Fri, 31 Jan 2020 14:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481241; 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=wg/RkbVIRpAzAQE9jxVOeZEnfFHwrUoEQEGY2PNR9kE=; b=DCHQ15K1yQr6PWk+ihCRo3e8oaZlyU7i1cRyYCffbCSXn9RdGPPKLS0MYoq7XDVPZITUwD qZCLuuevnGg6P2cWT62Gsk4H/9dahqu7uj4CPEXVrRrBzL6eMLEteu69d/ln+SmotTj7mb A8uF3ZfZhGeephY0pOZTICCGlBuIymU= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/19] tests: qemublock: Add test for checkpoint deletion bitmap merge Date: Fri, 31 Jan 2020 15:31:05 +0100 Message-Id: <5e2faa8b5cc25674dcfb901c271b2e4dc25aaa14.1580480483.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: I4A0UNLfPfi1TyADfuVunQ-1 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" Add test infrastructure and a basic test for bitmap deletion. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 59 +++++++++++++++++++ .../checkpointdelete/basic-noparent-out.json | 9 +++ 2 files changed, 68 insertions(+) create mode 100644 tests/qemublocktestdata/checkpointdelete/basic-noparent= -out.json diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 3076dc9645..00056a2b90 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -27,6 +27,7 @@ #include "qemu/qemu_qapi.h" #include "qemu/qemu_monitor_json.h" #include "qemu/qemu_backup.h" +#include "qemu/qemu_checkpoint.h" #include "qemu/qemu_command.h" @@ -700,6 +701,50 @@ testQemuBackupIncrementalBitmapCalculate(const void *o= paque) } +static const char *checkpointDeletePrefix =3D "qemublocktestdata/checkpoin= tdelete/"; + +struct testQemuCheckpointDeleteMergeData { + const char *name; + virStorageSourcePtr chain; + const char *deletebitmap; + const char *parentbitmap; +}; + + +static int +testQemuCheckpointDeleteMerge(const void *opaque) +{ + const struct testQemuCheckpointDeleteMergeData *data =3D opaque; + g_autofree char *actual =3D NULL; + g_autofree char *expectpath =3D NULL; + g_autoptr(virJSONValue) actions =3D NULL; + bool currentcheckpoint; + + expectpath =3D g_strdup_printf("%s/%s%s-out.json", abs_srcdir, + checkpointDeletePrefix, data->name); + + if (!(actions =3D virJSONValueNewArray())) + return -1; + + /* hack to get the 'current' state until the function stops accepting = it */ + currentcheckpoint =3D STREQ("current", data->deletebitmap); + + if (qemuCheckpointDiscardDiskBitmaps(data->chain, + data->deletebitmap, + data->parentbitmap, + currentcheckpoint, + actions) < 0) { + VIR_TEST_VERBOSE("failed to generate checkpoint delete transaction= \n"); + return -1; + } + + if (!(actual =3D virJSONValueToString(actions, true))) + return -1; + + return virTestCompareToFile(actual, expectpath); +} + + static int mymain(void) { @@ -709,6 +754,7 @@ mymain(void) struct testQemuDiskXMLToJSONData diskxmljsondata; struct testQemuImageCreateData imagecreatedata; struct testQemuBackupIncrementalBitmapCalculateData backupbitmapcalcda= ta; + struct testQemuCheckpointDeleteMergeData checkpointdeletedata; char *capslatest_x86_64 =3D NULL; virQEMUCapsPtr caps_x86_64 =3D NULL; g_autoptr(virStorageSource) bitmapSourceChain =3D NULL; @@ -945,6 +991,19 @@ mymain(void) TEST_BACKUP_BITMAP_CALCULATE("snapshot-intermediate", bitmapSourceChai= n, "d", "snapshots"); TEST_BACKUP_BITMAP_CALCULATE("snapshot-deep", bitmapSourceChain, "a", = "snapshots"); +#define TEST_CHECKPOINT_DELETE_MERGE(testname, delbmp, parbmp) \ + do { \ + checkpointdeletedata.name =3D testname; \ + checkpointdeletedata.chain =3D bitmapSourceChain; \ + checkpointdeletedata.deletebitmap =3D delbmp; \ + checkpointdeletedata.parentbitmap =3D parbmp; \ + if (virTestRun("checkpoint delete " testname, \ + testQemuCheckpointDeleteMerge, &checkpointdeletedat= a) < 0) \ + ret =3D -1; \ + } while (0) + + TEST_CHECKPOINT_DELETE_MERGE("basic-noparent", "a", NULL); + cleanup: virHashFree(diskxmljsondata.schema); qemuTestDriverFree(&driver); diff --git a/tests/qemublocktestdata/checkpointdelete/basic-noparent-out.js= on b/tests/qemublocktestdata/checkpointdelete/basic-noparent-out.json new file mode 100644 index 0000000000..e87382fdb4 --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/basic-noparent-out.json @@ -0,0 +1,9 @@ +[ + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-1-format", + "name": "a" + } + } +] --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481229950379.79131518850716; Fri, 31 Jan 2020 06:33:49 -0800 (PST) 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-31-TmQJUqsGPg-tTcc-P3s4og-1; Fri, 31 Jan 2020 09:33:46 -0500 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 4FA568017CC; Fri, 31 Jan 2020 14:33:40 +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 15F0B19C4F; Fri, 31 Jan 2020 14:33:40 +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 AEA5581C84; Fri, 31 Jan 2020 14:33:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVXBF019719 for ; Fri, 31 Jan 2020 09:31:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id A168D89E82; Fri, 31 Jan 2020 14:31:33 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id C914F89E8E; Fri, 31 Jan 2020 14:31:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481228; 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=/foo0asXIVQwDuhJKq+72s+zHcpE0rsH6GHwE7X2mzo=; b=YPfQtSLSqSTafOVkHj3Mgfi95vswCmOuZ0r4bY3TWS3M0jXS4d1N+dYAKnhEbSvS94RwLP GSWkbIKJ8Cl5uv5YIKpeOe4SjByOUAKR+kmyRFnOmZHVlz48oqZfHwvaFC7Uz5Txu/5VXD 4IEx07BKCdjsGZfA9lJoCpOChSUcQpo= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/19] tests: qemublock: Add few more test cases for checkpoint deletion Date: Fri, 31 Jan 2020 15:31:06 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: TmQJUqsGPg-tTcc-P3s4og-1 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" Add all intermediate steps and deletion of the current checkpoint on a flat (single-image) disk image. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 4 +++ .../checkpointdelete/basic-current-out.json | 29 +++++++++++++++++++ .../basic-intermediate1-out.json | 22 ++++++++++++++ .../basic-intermediate2-out.json | 22 ++++++++++++++ .../basic-intermediate3-out.json | 22 ++++++++++++++ 5 files changed, 99 insertions(+) create mode 100644 tests/qemublocktestdata/checkpointdelete/basic-current-= out.json create mode 100644 tests/qemublocktestdata/checkpointdelete/basic-intermed= iate1-out.json create mode 100644 tests/qemublocktestdata/checkpointdelete/basic-intermed= iate2-out.json create mode 100644 tests/qemublocktestdata/checkpointdelete/basic-intermed= iate3-out.json diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 00056a2b90..e062f1a4cb 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -1003,6 +1003,10 @@ mymain(void) } while (0) TEST_CHECKPOINT_DELETE_MERGE("basic-noparent", "a", NULL); + TEST_CHECKPOINT_DELETE_MERGE("basic-intermediate1", "b", "a"); + TEST_CHECKPOINT_DELETE_MERGE("basic-intermediate2", "c", "b"); + TEST_CHECKPOINT_DELETE_MERGE("basic-intermediate3", "d", "c"); + TEST_CHECKPOINT_DELETE_MERGE("basic-current", "current", "d"); cleanup: virHashFree(diskxmljsondata.schema); diff --git a/tests/qemublocktestdata/checkpointdelete/basic-current-out.jso= n b/tests/qemublocktestdata/checkpointdelete/basic-current-out.json new file mode 100644 index 0000000000..1b607567e8 --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/basic-current-out.json @@ -0,0 +1,29 @@ +[ + { + "type": "block-dirty-bitmap-enable", + "data": { + "node": "libvirt-1-format", + "name": "d" + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-1-format", + "target": "d", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "current" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-1-format", + "name": "current" + } + } +] diff --git a/tests/qemublocktestdata/checkpointdelete/basic-intermediate1-o= ut.json b/tests/qemublocktestdata/checkpointdelete/basic-intermediate1-out.= json new file mode 100644 index 0000000000..eccb7ed15f --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/basic-intermediate1-out.json @@ -0,0 +1,22 @@ +[ + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-1-format", + "target": "a", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "b" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-1-format", + "name": "b" + } + } +] diff --git a/tests/qemublocktestdata/checkpointdelete/basic-intermediate2-o= ut.json b/tests/qemublocktestdata/checkpointdelete/basic-intermediate2-out.= json new file mode 100644 index 0000000000..de40e4b5b0 --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/basic-intermediate2-out.json @@ -0,0 +1,22 @@ +[ + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-1-format", + "target": "b", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "c" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-1-format", + "name": "c" + } + } +] diff --git a/tests/qemublocktestdata/checkpointdelete/basic-intermediate3-o= ut.json b/tests/qemublocktestdata/checkpointdelete/basic-intermediate3-out.= json new file mode 100644 index 0000000000..b5d85f43f0 --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/basic-intermediate3-out.json @@ -0,0 +1,22 @@ +[ + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-1-format", + "target": "c", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "d" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-1-format", + "name": "d" + } + } +] --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481244920511.1624113699212; Fri, 31 Jan 2020 06:34:04 -0800 (PST) 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-138-M3kzAGPHPhK1MGRczrpUZg-1; Fri, 31 Jan 2020 09:34:00 -0500 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 D1AB4140C; Fri, 31 Jan 2020 14:33:53 +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 AADDE89E85; Fri, 31 Jan 2020 14:33:53 +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 6D9AD85CE0; Fri, 31 Jan 2020 14:33:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVama019732 for ; Fri, 31 Jan 2020 09:31:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 259D489E82; Fri, 31 Jan 2020 14:31:36 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC62989E85; Fri, 31 Jan 2020 14:31:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481242; 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=anF2i8GXQMGNJq6nRGzqAuv1RThZ6LIxs9Apobm7lis=; b=D+OWVhduj8CR6TS06Gww6AIlvEmsNcMeGF30sRUqDpj+RLR0fzg0zP7APk+rfsdauLsU6N pxn9kcH+nA/fptpmiTlieeXUBYrRU98k6WQoSeYLQjOL0Mnt2+w9brCRvpF+yy4+f/t+9d mjbVSqvAIGCVutpbDvoyPG0G0mWOUpc= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/19] tests: qemublock: Add synthetic snapshot+checkpoint test data Date: Fri, 31 Jan 2020 15:31:07 +0100 Message-Id: <943dc140353334235aa3cd0899b18efed50af8a9.1580480483.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: M3kzAGPHPhK1MGRczrpUZg-1 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" Add a faked qemu output which would simulate scenario where libvirt would take a snapshot and checkpoint simultaneously. This is visible in libvirt-2-format node where bitmap 'c' appears, but bitmap 'b' which is active in the previous layer is not present. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 1 + .../snapshots-synthetic-checkpoint.json | 827 ++++++++++++++++++ .../bitmap/snapshots-synthetic-checkpoint.out | 13 + 3 files changed, 841 insertions(+) create mode 100644 tests/qemublocktestdata/bitmap/snapshots-synthetic-chec= kpoint.json create mode 100644 tests/qemublocktestdata/bitmap/snapshots-synthetic-chec= kpoint.out diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index e062f1a4cb..861b4e86ae 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -970,6 +970,7 @@ mymain(void) TEST_BITMAP_DETECT("basic"); TEST_BITMAP_DETECT("synthetic"); TEST_BITMAP_DETECT("snapshots"); + TEST_BITMAP_DETECT("snapshots-synthetic-checkpoint"); #define TEST_BACKUP_BITMAP_CALCULATE(testname, source, incrbackup, named) \ do { \ diff --git a/tests/qemublocktestdata/bitmap/snapshots-synthetic-checkpoint.= json b/tests/qemublocktestdata/bitmap/snapshots-synthetic-checkpoint.json new file mode 100644 index 0000000000..25cc150d67 --- /dev/null +++ b/tests/qemublocktestdata/bitmap/snapshots-synthetic-checkpoint.json @@ -0,0 +1,827 @@ +[ + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "backing-image": { + "backing-image": { + "backing-image": { + "virtual-size": 10485760, + "filename": "/tmp/pull4.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911522", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.qcow2", + "backing-filename": "/tmp/pull4.qcow2", + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911527", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 217088, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "c", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "b", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.1575911522", + "backing-filename": "/tmp/pull4.1575911522", + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911540", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 212992, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "d", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "c", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.1575911527", + "backing-filename": "/tmp/pull4.1575911527", + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911550", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 212992, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "in-use", + "auto" + ], + "name": "current", + "granularity": 65536 + }, + { + "flags": [ + "in-use" + ], + "name": "d", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.1575911540", + "backing-filename": "/tmp/pull4.1575911540", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-1-format", + "backing_file_depth": 4, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "/tmp/pull4.1575911540", + "dirty-bitmaps": [ + { + "name": "d", + "recording": false, + "persistent": true, + "busy": false, + "status": "disabled", + "granularity": 65536, + "count": 0 + }, + { + "name": "current", + "recording": true, + "persistent": true, + "busy": false, + "status": "active", + "granularity": 65536, + "count": 0 + } + ], + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911550", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 393728, + "filename": "/tmp/pull4.1575911550", + "format": "file", + "actual-size": 212992, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-1-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911550", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "backing-image": { + "backing-image": { + "virtual-size": 10485760, + "filename": "/tmp/pull4.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911522", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.qcow2", + "backing-filename": "/tmp/pull4.qcow2", + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911527", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 217088, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "c", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "b", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.1575911522", + "backing-filename": "/tmp/pull4.1575911522", + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911540", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 212992, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "d", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "c", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.1575911527", + "backing-filename": "/tmp/pull4.1575911527", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "libvirt-2-format", + "backing_file_depth": 3, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "/tmp/pull4.1575911527", + "dirty-bitmaps": [ + { + "name": "c", + "recording": false, + "persistent": true, + "busy": false, + "status": "disabled", + "granularity": 65536, + "count": 0 + }, + { + "name": "d", + "recording": true, + "persistent": true, + "busy": false, + "status": "active", + "granularity": 65536, + "count": 0 + } + ], + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911540", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 393728, + "filename": "/tmp/pull4.1575911540", + "format": "file", + "actual-size": 212992, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-2-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911540", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "backing-image": { + "virtual-size": 10485760, + "filename": "/tmp/pull4.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911522", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.qcow2", + "backing-filename": "/tmp/pull4.qcow2", + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911527", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 217088, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "c", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "b", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.1575911522", + "backing-filename": "/tmp/pull4.1575911522", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "libvirt-3-format", + "backing_file_depth": 2, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "/tmp/pull4.1575911522", + "dirty-bitmaps": [ + { + "name": "a", + "recording": false, + "persistent": true, + "busy": false, + "status": "disabled", + "granularity": 65536, + "count": 0 + }, + { + "name": "b", + "recording": true, + "persistent": true, + "busy": false, + "status": "disabled", + "granularity": 65536, + "count": 0 + } + ], + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911527", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 459264, + "filename": "/tmp/pull4.1575911527", + "format": "file", + "actual-size": 217088, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-3-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911527", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "virtual-size": 10485760, + "filename": "/tmp/pull4.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911522", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.qcow2", + "backing-filename": "/tmp/pull4.qcow2", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "libvirt-4-format", + "backing_file_depth": 1, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "/tmp/pull4.qcow2", + "dirty-bitmaps": [ + { + "name": "a", + "recording": true, + "persistent": true, + "busy": false, + "status": "active", + "granularity": 65536, + "count": 0 + } + ], + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911522", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 328192, + "filename": "/tmp/pull4.1575911522", + "format": "file", + "actual-size": 208896, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-4-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911522", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 10485760, + "filename": "/tmp/pull4.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "libvirt-5-format", + "backing_file_depth": 0, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "dirty-bitmaps": [ + { + "name": "a", + "recording": true, + "persistent": true, + "busy": false, + "status": "active", + "granularity": 65536, + "count": 0 + } + ], + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.qcow2", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 328192, + "filename": "/tmp/pull4.qcow2", + "format": "file", + "actual-size": 208896, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-5-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.qcow2", + "encryption_key_missing": false + } +] diff --git a/tests/qemublocktestdata/bitmap/snapshots-synthetic-checkpoint.= out b/tests/qemublocktestdata/bitmap/snapshots-synthetic-checkpoint.out new file mode 100644 index 0000000000..0270657001 --- /dev/null +++ b/tests/qemublocktestdata/bitmap/snapshots-synthetic-checkpoint.out @@ -0,0 +1,13 @@ +libvirt-1-format: + d: record:0 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 + current: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 +libvirt-2-format: + c: record:0 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 + d: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 +libvirt-3-format: + a: record:0 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 + b: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 +libvirt-4-format: + a: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 +libvirt-5-format: + a: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481264554979.2900275876184; Fri, 31 Jan 2020 06:34:24 -0800 (PST) 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-190-c-44eNx1OqW8tg9KwVi4EA-1; Fri, 31 Jan 2020 09:34:04 -0500 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 DD39C1407; Fri, 31 Jan 2020 14:33:58 +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 B307B19C4F; Fri, 31 Jan 2020 14:33: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 6E9ED1803C32; Fri, 31 Jan 2020 14:33:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVbwJ019739 for ; Fri, 31 Jan 2020 09:31:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4CD8489E82; Fri, 31 Jan 2020 14:31:37 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 734B389E7E; Fri, 31 Jan 2020 14:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481263; 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=z04nZ7zT83Y2MQ7pCqUXYMZSu4OaKt6NYk6mTm8/P1Q=; b=B1kNjPr+sU3rYodVuf7RDMZDyQemitrIsSxmZnHvBrrWl56scq01EG8T42dLZgUq7Y/jyT dltVekfL2Dvt+hJmHvY2Tnf2Kz2DNZL5F2n/DMhKwjLPermx0ZP6wjR3US3Dv8Z1Sa7dG5 yetgEQPXFbiiHRlqqImc7TLblIL9ou8= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/19] qemu: checkpoint: Introduce support for deleting checkpoints accross snapshots Date: Fri, 31 Jan 2020 15:31:08 +0100 Message-Id: <07e3c2f38e2b0143828609898fe91ef40c5b329f.1580480483.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: c-44eNx1OqW8tg9KwVi4EA-1 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" Allow deleting of checkpoints when snapshots were created along. The code tracks and modifies the checkpoint list so that backups can still be taken with such a backing chain. This unfortunately requires to rename few bitmaps (by copying and deleting them) in some cases. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_checkpoint.c | 112 ++++++++++++++++++++++++++++--------- src/qemu/qemu_checkpoint.h | 5 +- tests/qemublocktest.c | 34 +++++++---- 3 files changed, 111 insertions(+), 40 deletions(-) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index e75cdd0458..087a740cf8 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -24,6 +24,7 @@ #include "qemu_capabilities.h" #include "qemu_monitor.h" #include "qemu_domain.h" +#include "qemu_block.h" #include "virerror.h" #include "virlog.h" @@ -150,39 +151,92 @@ qemuCheckpointFindActiveDiskInParent(virDomainObjPtr = vm, int qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr src, + virHashTablePtr blockNamedNodeData, const char *delbitmap, const char *parentbitmap, - bool chkcurrent, - virJSONValuePtr actions) + virJSONValuePtr actions, + const char *diskdst) { - if (parentbitmap) { - g_autoptr(virJSONValue) arr =3D NULL; + virStorageSourcePtr n =3D src; - if (!(arr =3D virJSONValueNewArray())) - return -1; + /* find the backing chain entry with bitmap named '@bitmap' */ + while (n) { + qemuBlockNamedNodeDataBitmapPtr tmp; - if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr, - src->nodeform= at, - delbitmap) < = 0) - return -1; + if ((tmp =3D qemuBlockNamedNodeDataGetBitmapByName(blockNamedNodeD= ata, + n, delbitmap))) { + break; + } + + n =3D n->backingStore; + } + + if (!n) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("bitmap '%s' not found in backing chain of '%s'"), + delbitmap, diskdst); + return -1; + } - if (chkcurrent) { - if (qemuMonitorTransactionBitmapEnable(actions, - src->nodeformat, - parentbitmap) < 0) + while (n) { + qemuBlockNamedNodeDataBitmapPtr srcbitmap; + + if (!(srcbitmap =3D qemuBlockNamedNodeDataGetBitmapByName(blockNam= edNodeData, + n, delbitm= ap))) + break; + + /* For the actual checkpoint deletion we will merge any bitmap int= o the + * bitmap of the parent checkpoint (@mergebitmap) or for any image + * where the parent checkpoint bitmap is not present we must rename + * the bitmap of the deleted checkpoint into the bitmap of the par= ent + * checkpoint as qemu can't currently take the allocation map and = turn + * it into a bitmap and thus we wouldn't be able to do a backup. */ + if (parentbitmap) { + qemuBlockNamedNodeDataBitmapPtr dstbitmap; + g_autoptr(virJSONValue) arr =3D NULL; + + dstbitmap =3D qemuBlockNamedNodeDataGetBitmapByName(blockNamed= NodeData, + n, parentbit= map); + + if (dstbitmap) { + if (srcbitmap->recording && !dstbitmap->recording) { + if (qemuMonitorTransactionBitmapEnable(actions, + n->nodeformat, + dstbitmap->name= ) < 0) + return -1; + } + + } else { + if (qemuMonitorTransactionBitmapAdd(actions, + n->nodeformat, + parentbitmap, + true, + !srcbitmap->recording, + srcbitmap->granularity= ) < 0) + return -1; + } + + if (!(arr =3D virJSONValueNewArray())) + return -1; + + if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr, + n->nodefo= rmat, + srcbitmap= ->name) < 0) + return -1; + + if (qemuMonitorTransactionBitmapMerge(actions, + n->nodeformat, + parentbitmap, &arr) < 0) return -1; } - if (qemuMonitorTransactionBitmapMerge(actions, - src->nodeformat, - parentbitmap, &arr) < 0) + if (qemuMonitorTransactionBitmapRemove(actions, + n->nodeformat, + srcbitmap->name) < 0) return -1; - } - if (qemuMonitorTransactionBitmapRemove(actions, - src->nodeformat, - delbitmap) < 0) - return -1; + n =3D n->backingStore; + } return 0; } @@ -191,11 +245,11 @@ qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr = src, static int qemuCheckpointDiscardBitmaps(virDomainObjPtr vm, virDomainCheckpointDefPtr chkdef, - bool chkcurrent, virDomainMomentObjPtr parent) { qemuDomainObjPrivatePtr priv =3D vm->privateData; virQEMUDriverPtr driver =3D priv->driver; + g_autoptr(virHashTable) blockNamedNodeData =3D NULL; int rc; g_autoptr(virJSONValue) actions =3D NULL; size_t i; @@ -203,6 +257,11 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm, if (!(actions =3D virJSONValueNewArray())) return -1; + qemuDomainObjEnterMonitor(driver, vm); + blockNamedNodeData =3D qemuMonitorBlockGetNamedNodeData(priv->mon); + if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || !blockNamedNodeD= ata) + return -1; + for (i =3D 0; i < chkdef->ndisks; i++) { virDomainCheckpointDiskDef *chkdisk =3D &chkdef->disks[i]; virDomainDiskDefPtr domdisk =3D virDomainDiskByTarget(vm->def, chk= disk->name); @@ -223,8 +282,9 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm, chkdisk-= >name))) parentbitmap =3D parentchkdisk->name; - if (qemuCheckpointDiscardDiskBitmaps(domdisk->src, chkdisk->bitmap, - parentbitmap, chkcurrent, act= ions) < 0) + if (qemuCheckpointDiscardDiskBitmaps(domdisk->src, blockNamedNodeD= ata, + chkdisk->bitmap, parentbitmap, + actions, domdisk->dst) < 0) return -1; } @@ -262,7 +322,7 @@ qemuCheckpointDiscard(virQEMUDriverPtr driver, virDomainCheckpointDefPtr chkdef =3D virDomainCheckpointObjGetDef(= chk); parent =3D virDomainCheckpointFindByName(vm->checkpoints, chk->def->parent_name); - if (qemuCheckpointDiscardBitmaps(vm, chkdef, chkcurrent, parent) <= 0) + if (qemuCheckpointDiscardBitmaps(vm, chkdef, parent) < 0) return -1; } diff --git a/src/qemu/qemu_checkpoint.h b/src/qemu/qemu_checkpoint.h index 85fd453d50..976b1eed0f 100644 --- a/src/qemu/qemu_checkpoint.h +++ b/src/qemu/qemu_checkpoint.h @@ -74,7 +74,8 @@ qemuCheckpointRollbackMetadata(virDomainObjPtr vm, int qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr src, + virHashTablePtr blockNamedNodeData, const char *delbitmap, const char *parentbitmap, - bool chkcurrent, - virJSONValuePtr actions); + virJSONValuePtr actions, + const char *diskdst); diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 861b4e86ae..6194c45ec8 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -708,6 +708,7 @@ struct testQemuCheckpointDeleteMergeData { virStorageSourcePtr chain; const char *deletebitmap; const char *parentbitmap; + const char *nodedatafile; }; @@ -718,22 +719,30 @@ testQemuCheckpointDeleteMerge(const void *opaque) g_autofree char *actual =3D NULL; g_autofree char *expectpath =3D NULL; g_autoptr(virJSONValue) actions =3D NULL; - bool currentcheckpoint; + g_autoptr(virJSONValue) nodedatajson =3D NULL; + g_autoptr(virHashTable) nodedata =3D NULL; expectpath =3D g_strdup_printf("%s/%s%s-out.json", abs_srcdir, checkpointDeletePrefix, data->name); - if (!(actions =3D virJSONValueNewArray())) + if (!(nodedatajson =3D virTestLoadFileJSON(bitmapDetectPrefix, data->n= odedatafile, + ".json", NULL))) return -1; - /* hack to get the 'current' state until the function stops accepting = it */ - currentcheckpoint =3D STREQ("current", data->deletebitmap); + if (!(nodedata =3D qemuMonitorJSONBlockGetNamedNodeDataJSON(nodedatajs= on))) { + VIR_TEST_VERBOSE("failed to load nodedata JSON\n"); + return -1; + } + + if (!(actions =3D virJSONValueNewArray())) + return -1; if (qemuCheckpointDiscardDiskBitmaps(data->chain, + nodedata, data->deletebitmap, data->parentbitmap, - currentcheckpoint, - actions) < 0) { + actions, + "testdisk") < 0) { VIR_TEST_VERBOSE("failed to generate checkpoint delete transaction= \n"); return -1; } @@ -992,22 +1001,23 @@ mymain(void) TEST_BACKUP_BITMAP_CALCULATE("snapshot-intermediate", bitmapSourceChai= n, "d", "snapshots"); TEST_BACKUP_BITMAP_CALCULATE("snapshot-deep", bitmapSourceChain, "a", = "snapshots"); -#define TEST_CHECKPOINT_DELETE_MERGE(testname, delbmp, parbmp) \ +#define TEST_CHECKPOINT_DELETE_MERGE(testname, delbmp, parbmp, named) \ do { \ checkpointdeletedata.name =3D testname; \ checkpointdeletedata.chain =3D bitmapSourceChain; \ checkpointdeletedata.deletebitmap =3D delbmp; \ checkpointdeletedata.parentbitmap =3D parbmp; \ + checkpointdeletedata.nodedatafile =3D named; \ if (virTestRun("checkpoint delete " testname, \ testQemuCheckpointDeleteMerge, &checkpointdeletedat= a) < 0) \ ret =3D -1; \ } while (0) - TEST_CHECKPOINT_DELETE_MERGE("basic-noparent", "a", NULL); - TEST_CHECKPOINT_DELETE_MERGE("basic-intermediate1", "b", "a"); - TEST_CHECKPOINT_DELETE_MERGE("basic-intermediate2", "c", "b"); - TEST_CHECKPOINT_DELETE_MERGE("basic-intermediate3", "d", "c"); - TEST_CHECKPOINT_DELETE_MERGE("basic-current", "current", "d"); + TEST_CHECKPOINT_DELETE_MERGE("basic-noparent", "a", NULL, "basic"); + TEST_CHECKPOINT_DELETE_MERGE("basic-intermediate1", "b", "a", "basic"); + TEST_CHECKPOINT_DELETE_MERGE("basic-intermediate2", "c", "b", "basic"); + TEST_CHECKPOINT_DELETE_MERGE("basic-intermediate3", "d", "c", "basic"); + TEST_CHECKPOINT_DELETE_MERGE("basic-current", "current", "d", "basic"); cleanup: virHashFree(diskxmljsondata.schema); --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481307810298.69141376854543; Fri, 31 Jan 2020 06:35:07 -0800 (PST) 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-387-HLDk0TASNOego7ZRjlhYkQ-1; Fri, 31 Jan 2020 09:34:08 -0500 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 EFA2C85EE71; Fri, 31 Jan 2020 14:34:02 +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 C2A8C860F1; Fri, 31 Jan 2020 14:34:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5564085CE1; Fri, 31 Jan 2020 14:34:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVc2n019747 for ; Fri, 31 Jan 2020 09:31:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6EAD389E82; Fri, 31 Jan 2020 14:31:38 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A8DB89E7E; Fri, 31 Jan 2020 14:31:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481306; 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=TnwhZU0YBXmzT7Vpx63bw29RHJe+8RiBtwBdBcmwg3Q=; b=Tz5c2zqyzmZxApx4OPDf/JMCa0d8UZjhYWOEFzQB2SUD5WNAJlD883RvwhZFbhlttnNbwu Uue3Ocr82g2KuQjxtTQBiXMhLYC2NSB01cJ+IQpMien9pigBZtxVZXwPV6XvAGX/2PCrVg Ol3CRrZhCyadgOuskiwFXmI0Cc7TK1c= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/19] tests: qemublock: Add checkpoint deletion test for deep backing chain Date: Fri, 31 Jan 2020 15:31:09 +0100 Message-Id: <78a2d8b409b0f56870faa95b2234c3ebcf0ea5cb.1580480483.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: HLDk0TASNOego7ZRjlhYkQ-1 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" Add test cases for merging various pairs of bitmaps when snapshots were created together with checkpoints. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 6 ++ .../snapshots-current-out.json | 29 +++++++++ .../snapshots-intermediate1-out.json | 22 +++++++ .../snapshots-intermediate2-out.json | 59 +++++++++++++++++++ .../snapshots-intermediate3-out.json | 59 +++++++++++++++++++ .../snapshots-noparent-out.json | 23 ++++++++ 6 files changed, 198 insertions(+) create mode 100644 tests/qemublocktestdata/checkpointdelete/snapshots-curr= ent-out.json create mode 100644 tests/qemublocktestdata/checkpointdelete/snapshots-inte= rmediate1-out.json create mode 100644 tests/qemublocktestdata/checkpointdelete/snapshots-inte= rmediate2-out.json create mode 100644 tests/qemublocktestdata/checkpointdelete/snapshots-inte= rmediate3-out.json create mode 100644 tests/qemublocktestdata/checkpointdelete/snapshots-nopa= rent-out.json diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 6194c45ec8..1c04929e81 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -1019,6 +1019,12 @@ mymain(void) TEST_CHECKPOINT_DELETE_MERGE("basic-intermediate3", "d", "c", "basic"); TEST_CHECKPOINT_DELETE_MERGE("basic-current", "current", "d", "basic"); + TEST_CHECKPOINT_DELETE_MERGE("snapshots-noparent", "a", NULL, "snapsho= ts"); + TEST_CHECKPOINT_DELETE_MERGE("snapshots-intermediate1", "b", "a", "sna= pshots"); + TEST_CHECKPOINT_DELETE_MERGE("snapshots-intermediate2", "c", "b", "sna= pshots"); + TEST_CHECKPOINT_DELETE_MERGE("snapshots-intermediate3", "d", "c", "sna= pshots"); + TEST_CHECKPOINT_DELETE_MERGE("snapshots-current", "current", "d", "sna= pshots"); + cleanup: virHashFree(diskxmljsondata.schema); qemuTestDriverFree(&driver); diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-current-out= .json b/tests/qemublocktestdata/checkpointdelete/snapshots-current-out.json new file mode 100644 index 0000000000..1b607567e8 --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-current-out.json @@ -0,0 +1,29 @@ +[ + { + "type": "block-dirty-bitmap-enable", + "data": { + "node": "libvirt-1-format", + "name": "d" + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-1-format", + "target": "d", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "current" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-1-format", + "name": "current" + } + } +] diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediat= e1-out.json b/tests/qemublocktestdata/checkpointdelete/snapshots-intermedia= te1-out.json new file mode 100644 index 0000000000..29fefeea63 --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate1-out.= json @@ -0,0 +1,22 @@ +[ + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-3-format", + "target": "a", + "bitmaps": [ + { + "node": "libvirt-3-format", + "name": "b" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-3-format", + "name": "b" + } + } +] diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediat= e2-out.json b/tests/qemublocktestdata/checkpointdelete/snapshots-intermedia= te2-out.json new file mode 100644 index 0000000000..4da21a9df7 --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate2-out.= json @@ -0,0 +1,59 @@ +[ + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "libvirt-2-format", + "name": "b", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-2-format", + "target": "b", + "bitmaps": [ + { + "node": "libvirt-2-format", + "name": "c" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-2-format", + "name": "c" + } + }, + { + "type": "block-dirty-bitmap-enable", + "data": { + "node": "libvirt-3-format", + "name": "b" + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-3-format", + "target": "b", + "bitmaps": [ + { + "node": "libvirt-3-format", + "name": "c" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-3-format", + "name": "c" + } + } +] diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediat= e3-out.json b/tests/qemublocktestdata/checkpointdelete/snapshots-intermedia= te3-out.json new file mode 100644 index 0000000000..dc87dd60b8 --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate3-out.= json @@ -0,0 +1,59 @@ +[ + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "libvirt-1-format", + "name": "c", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-1-format", + "target": "c", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "d" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-1-format", + "name": "d" + } + }, + { + "type": "block-dirty-bitmap-enable", + "data": { + "node": "libvirt-2-format", + "name": "c" + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-2-format", + "target": "c", + "bitmaps": [ + { + "node": "libvirt-2-format", + "name": "d" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-2-format", + "name": "d" + } + } +] diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-noparent-ou= t.json b/tests/qemublocktestdata/checkpointdelete/snapshots-noparent-out.js= on new file mode 100644 index 0000000000..45a84b47c2 --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-noparent-out.json @@ -0,0 +1,23 @@ +[ + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-3-format", + "name": "a" + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-4-format", + "name": "a" + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-5-format", + "name": "a" + } + } +] --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481222042378.49978914360963; Fri, 31 Jan 2020 06:33:42 -0800 (PST) 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-24-bi7l3wM2Pparh1OfurVyVA-1; Fri, 31 Jan 2020 09:33:38 -0500 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 E8DAB13FD; Fri, 31 Jan 2020 14:33:32 +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 C2DB077951; Fri, 31 Jan 2020 14:33:32 +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 76E3018089CF; Fri, 31 Jan 2020 14:33:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVeQm019759 for ; Fri, 31 Jan 2020 09:31:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2BD3586C4B; Fri, 31 Jan 2020 14:31:40 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCB848EA1A; Fri, 31 Jan 2020 14:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481220; 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=oQDIbcRmTEFWG/a3kzWtO9P/KOedGWFMP3US0y6qFOQ=; b=Wq0C1q96oc1kCR9wwhMh+/m8eHHbg8UHUUJe5Ql7SCeFEQTPnylaqB8dbi9Mkzgw8P+42u liB1CRXO2tOAlY2EaAwIziWwHaFUejXkrwRXrCCRl3SJBoUe4ZLjSnMNbKGyM0eOaK656O PO1CE777+FdGqxNTsCZ39j/3Ni3e2Oc= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/19] tests: qemublock: Add checkpoint deletion tests for some special cases Date: Fri, 31 Jan 2020 15:31:10 +0100 Message-Id: <305c5c11d93deda734faaaedffed2ac7d89f371a.1580480483.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: bi7l3wM2Pparh1OfurVyVA-1 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" Use the synthetic test data to verify that the algorithm correctly picks bitmaps to merge when the bitmap is changed along with the image itself. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 7 +++ ...hots-synthetic-checkpoint-current-out.json | 29 +++++++++ ...ynthetic-checkpoint-intermediate1-out.json | 29 +++++++++ ...ynthetic-checkpoint-intermediate2-out.json | 32 ++++++++++ ...ynthetic-checkpoint-intermediate3-out.json | 59 +++++++++++++++++++ ...ots-synthetic-checkpoint-noparent-out.json | 23 ++++++++ 6 files changed, 179 insertions(+) create mode 100644 tests/qemublocktestdata/checkpointdelete/snapshots-synt= hetic-checkpoint-current-out.json create mode 100644 tests/qemublocktestdata/checkpointdelete/snapshots-synt= hetic-checkpoint-intermediate1-out.json create mode 100644 tests/qemublocktestdata/checkpointdelete/snapshots-synt= hetic-checkpoint-intermediate2-out.json create mode 100644 tests/qemublocktestdata/checkpointdelete/snapshots-synt= hetic-checkpoint-intermediate3-out.json create mode 100644 tests/qemublocktestdata/checkpointdelete/snapshots-synt= hetic-checkpoint-noparent-out.json diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 1c04929e81..306f6310ee 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -1025,6 +1025,13 @@ mymain(void) TEST_CHECKPOINT_DELETE_MERGE("snapshots-intermediate3", "d", "c", "sna= pshots"); TEST_CHECKPOINT_DELETE_MERGE("snapshots-current", "current", "d", "sna= pshots"); + TEST_CHECKPOINT_DELETE_MERGE("snapshots-synthetic-checkpoint-noparent"= , "a", NULL, "snapshots-synthetic-checkpoint"); + TEST_CHECKPOINT_DELETE_MERGE("snapshots-synthetic-checkpoint-intermedi= ate1", "b", "a", "snapshots-synthetic-checkpoint"); + TEST_CHECKPOINT_DELETE_MERGE("snapshots-synthetic-checkpoint-intermedi= ate2", "c", "b", "snapshots-synthetic-checkpoint"); + TEST_CHECKPOINT_DELETE_MERGE("snapshots-synthetic-checkpoint-intermedi= ate3", "d", "c", "snapshots-synthetic-checkpoint"); + TEST_CHECKPOINT_DELETE_MERGE("snapshots-synthetic-checkpoint-current",= "current", "d", "snapshots-synthetic-checkpoint"); + + cleanup: virHashFree(diskxmljsondata.schema); qemuTestDriverFree(&driver); diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-c= heckpoint-current-out.json b/tests/qemublocktestdata/checkpointdelete/snaps= hots-synthetic-checkpoint-current-out.json new file mode 100644 index 0000000000..1b607567e8 --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-current-out.json @@ -0,0 +1,29 @@ +[ + { + "type": "block-dirty-bitmap-enable", + "data": { + "node": "libvirt-1-format", + "name": "d" + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-1-format", + "target": "d", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "current" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-1-format", + "name": "current" + } + } +] diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-c= heckpoint-intermediate1-out.json b/tests/qemublocktestdata/checkpointdelete= /snapshots-synthetic-checkpoint-intermediate1-out.json new file mode 100644 index 0000000000..e979691e6f --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate1-out.json @@ -0,0 +1,29 @@ +[ + { + "type": "block-dirty-bitmap-enable", + "data": { + "node": "libvirt-3-format", + "name": "a" + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-3-format", + "target": "a", + "bitmaps": [ + { + "node": "libvirt-3-format", + "name": "b" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-3-format", + "name": "b" + } + } +] diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-c= heckpoint-intermediate2-out.json b/tests/qemublocktestdata/checkpointdelete= /snapshots-synthetic-checkpoint-intermediate2-out.json new file mode 100644 index 0000000000..e82098918a --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate2-out.json @@ -0,0 +1,32 @@ +[ + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "libvirt-2-format", + "name": "b", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-2-format", + "target": "b", + "bitmaps": [ + { + "node": "libvirt-2-format", + "name": "c" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-2-format", + "name": "c" + } + } +] diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-c= heckpoint-intermediate3-out.json b/tests/qemublocktestdata/checkpointdelete= /snapshots-synthetic-checkpoint-intermediate3-out.json new file mode 100644 index 0000000000..dc87dd60b8 --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate3-out.json @@ -0,0 +1,59 @@ +[ + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "libvirt-1-format", + "name": "c", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-1-format", + "target": "c", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "d" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-1-format", + "name": "d" + } + }, + { + "type": "block-dirty-bitmap-enable", + "data": { + "node": "libvirt-2-format", + "name": "c" + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "libvirt-2-format", + "target": "c", + "bitmaps": [ + { + "node": "libvirt-2-format", + "name": "d" + } + ] + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-2-format", + "name": "d" + } + } +] diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-c= heckpoint-noparent-out.json b/tests/qemublocktestdata/checkpointdelete/snap= shots-synthetic-checkpoint-noparent-out.json new file mode 100644 index 0000000000..45a84b47c2 --- /dev/null +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-noparent-out.json @@ -0,0 +1,23 @@ +[ + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-3-format", + "name": "a" + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-4-format", + "name": "a" + } + }, + { + "type": "block-dirty-bitmap-remove", + "data": { + "node": "libvirt-5-format", + "name": "a" + } + } +] --=20 2.24.1 From nobody Wed May 8 20:06: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 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 158048123392880.90767194942237; Fri, 31 Jan 2020 06:33:53 -0800 (PST) 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-134-ocmAQ8vsOU2xckLFRB7NnA-1; Fri, 31 Jan 2020 09:33:49 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 274181007276; Fri, 31 Jan 2020 14:33:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01FB17FB60; Fri, 31 Jan 2020 14:33:44 +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 B9B4318089CE; Fri, 31 Jan 2020 14:33:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVf0O019769 for ; Fri, 31 Jan 2020 09:31:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 59F7187B06; Fri, 31 Jan 2020 14:31:41 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B09E86C4B; Fri, 31 Jan 2020 14:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481232; 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=VAOM575zQrmZhezh4BEbgE64w0vdUv0PPtUf0fEntEs=; b=Mp3vPnDRdIVTl7KXfqgXs2zmzxwU/JbFfwtu0KmTD7Jd7Pm2UDy4m48ehlbbTvSKw+wn1y /4cbLMgSpnKZrFYygH5U0Wok8cuPhhteAr0byxKOGCJ7yhoo2cjDtyM6PDFx8tXkw8v3u7 8c0PwW4jaLB7qFmFbRahNg7UYUyS/cM= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/19] qemu: checkpoint: Track and relabel images for bitmap merging Date: Fri, 31 Jan 2020 15:31:11 +0100 Message-Id: <99d187aca3fc2726abcbb3ecf03070cb7e27be54.1580480483.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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.11 X-MC-Unique: ocmAQ8vsOU2xckLFRB7NnA-1 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" Allow qemu access to modify backing files in case when we want to delete a checkpoint. This patch adds tracking of which images need to be relabelled when calculating the transaction, the code to relabel them and rollback. To verify that stuff works we also output the list of images to relabel into the test case output files in qemublocktest. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_checkpoint.c | 35 ++++++++++++++++--- src/qemu/qemu_checkpoint.h | 3 +- tests/qemublocktest.c | 19 ++++++++-- .../snapshots-intermediate1-out.json | 2 ++ .../snapshots-intermediate2-out.json | 3 ++ .../snapshots-intermediate3-out.json | 2 ++ .../snapshots-noparent-out.json | 4 +++ ...ynthetic-checkpoint-intermediate1-out.json | 2 ++ ...ynthetic-checkpoint-intermediate2-out.json | 2 ++ ...ynthetic-checkpoint-intermediate3-out.json | 2 ++ ...ots-synthetic-checkpoint-noparent-out.json | 4 +++ 11 files changed, 70 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 087a740cf8..6ef35ea1a1 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -155,7 +155,8 @@ qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr sr= c, const char *delbitmap, const char *parentbitmap, virJSONValuePtr actions, - const char *diskdst) + const char *diskdst, + GSList **reopenimages) { virStorageSourcePtr n =3D src; @@ -235,6 +236,9 @@ qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr sr= c, srcbitmap->name) < 0) return -1; + if (n !=3D src) + *reopenimages =3D g_slist_prepend(*reopenimages, n); + n =3D n->backingStore; } @@ -250,9 +254,12 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm, qemuDomainObjPrivatePtr priv =3D vm->privateData; virQEMUDriverPtr driver =3D priv->driver; g_autoptr(virHashTable) blockNamedNodeData =3D NULL; - int rc; + int rc =3D -1; g_autoptr(virJSONValue) actions =3D NULL; size_t i; + g_autoptr(GSList) reopenimages =3D NULL; + g_autoptr(GSList) relabelimages =3D NULL; + GSList *next; if (!(actions =3D virJSONValueNewArray())) return -1; @@ -284,16 +291,34 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm, if (qemuCheckpointDiscardDiskBitmaps(domdisk->src, blockNamedNodeD= ata, chkdisk->bitmap, parentbitmap, - actions, domdisk->dst) < 0) + actions, domdisk->dst, + &reopenimages) < 0) return -1; } + /* label any non-top images for read-write access */ + for (next =3D reopenimages; next; next =3D next->next) { + virStorageSourcePtr src =3D next->data; + + if (qemuDomainStorageSourceAccessAllow(driver, vm, src, false, fal= se) < 0) + goto relabel; + + relabelimages =3D g_slist_prepend(relabelimages, src); + } + qemuDomainObjEnterMonitor(driver, vm); rc =3D qemuMonitorTransaction(priv->mon, &actions); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + if (qemuDomainObjExitMonitor(driver, vm) < 0) return -1; - return 0; + relabel: + for (next =3D relabelimages; next; next =3D next->next) { + virStorageSourcePtr src =3D next->data; + + ignore_value(qemuDomainStorageSourceAccessAllow(driver, vm, src, t= rue, false)); + } + + return rc; } diff --git a/src/qemu/qemu_checkpoint.h b/src/qemu/qemu_checkpoint.h index 976b1eed0f..cf1e9e46cb 100644 --- a/src/qemu/qemu_checkpoint.h +++ b/src/qemu/qemu_checkpoint.h @@ -78,4 +78,5 @@ qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr src, const char *delbitmap, const char *parentbitmap, virJSONValuePtr actions, - const char *diskdst); + const char *diskdst, + GSList **reopenimages); diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 306f6310ee..50dcb86810 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -721,6 +721,9 @@ testQemuCheckpointDeleteMerge(const void *opaque) g_autoptr(virJSONValue) actions =3D NULL; g_autoptr(virJSONValue) nodedatajson =3D NULL; g_autoptr(virHashTable) nodedata =3D NULL; + g_autoptr(GSList) reopenimages =3D NULL; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + GSList *tmp; expectpath =3D g_strdup_printf("%s/%s%s-out.json", abs_srcdir, checkpointDeletePrefix, data->name); @@ -742,14 +745,26 @@ testQemuCheckpointDeleteMerge(const void *opaque) data->deletebitmap, data->parentbitmap, actions, - "testdisk") < 0) { + "testdisk", + &reopenimages) < 0) { VIR_TEST_VERBOSE("failed to generate checkpoint delete transaction= \n"); return -1; } - if (!(actual =3D virJSONValueToString(actions, true))) + if (virJSONValueToBuffer(actions, &buf, true) < 0) return -1; + if (reopenimages) { + virBufferAddLit(&buf, "reopen nodes:\n"); + + for (tmp =3D reopenimages; tmp; tmp =3D tmp->next) { + virStorageSourcePtr src =3D tmp->data; + virBufferAsprintf(&buf, "%s\n", src->nodeformat); + } + } + + actual =3D virBufferContentAndReset(&buf); + return virTestCompareToFile(actual, expectpath); } diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediat= e1-out.json b/tests/qemublocktestdata/checkpointdelete/snapshots-intermedia= te1-out.json index 29fefeea63..c9bda3a17a 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate1-out.= json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate1-out.= json @@ -20,3 +20,5 @@ } } ] +reopen nodes: +libvirt-3-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediat= e2-out.json b/tests/qemublocktestdata/checkpointdelete/snapshots-intermedia= te2-out.json index 4da21a9df7..8a0e3f2cff 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate2-out.= json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate2-out.= json @@ -57,3 +57,6 @@ } } ] +reopen nodes: +libvirt-3-format +libvirt-2-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediat= e3-out.json b/tests/qemublocktestdata/checkpointdelete/snapshots-intermedia= te3-out.json index dc87dd60b8..211bc40baf 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate3-out.= json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate3-out.= json @@ -57,3 +57,5 @@ } } ] +reopen nodes: +libvirt-2-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-noparent-ou= t.json b/tests/qemublocktestdata/checkpointdelete/snapshots-noparent-out.js= on index 45a84b47c2..f750f44da2 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-noparent-out.json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-noparent-out.json @@ -21,3 +21,7 @@ } } ] +reopen nodes: +libvirt-5-format +libvirt-4-format +libvirt-3-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-c= heckpoint-intermediate1-out.json b/tests/qemublocktestdata/checkpointdelete= /snapshots-synthetic-checkpoint-intermediate1-out.json index e979691e6f..d7e6d18637 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate1-out.json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate1-out.json @@ -27,3 +27,5 @@ } } ] +reopen nodes: +libvirt-3-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-c= heckpoint-intermediate2-out.json b/tests/qemublocktestdata/checkpointdelete= /snapshots-synthetic-checkpoint-intermediate2-out.json index e82098918a..cfbff010c2 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate2-out.json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate2-out.json @@ -30,3 +30,5 @@ } } ] +reopen nodes: +libvirt-2-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-c= heckpoint-intermediate3-out.json b/tests/qemublocktestdata/checkpointdelete= /snapshots-synthetic-checkpoint-intermediate3-out.json index dc87dd60b8..211bc40baf 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate3-out.json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate3-out.json @@ -57,3 +57,5 @@ } } ] +reopen nodes: +libvirt-2-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-c= heckpoint-noparent-out.json b/tests/qemublocktestdata/checkpointdelete/snap= shots-synthetic-checkpoint-noparent-out.json index 45a84b47c2..f750f44da2 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-noparent-out.json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-noparent-out.json @@ -21,3 +21,7 @@ } } ] +reopen nodes: +libvirt-5-format +libvirt-4-format +libvirt-3-format --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481236808442.4734593409072; Fri, 31 Jan 2020 06:33:56 -0800 (PST) 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-382-cLhnvD1lM1eAVx1m7bzjjA-1; Fri, 31 Jan 2020 09:33:53 -0500 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 A21E6190B2A9; Fri, 31 Jan 2020 14:33:47 +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 7DB2289E99; Fri, 31 Jan 2020 14:33:47 +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 3AB76180880B; Fri, 31 Jan 2020 14:33:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVgC0019783 for ; Fri, 31 Jan 2020 09:31:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7AE2086C4B; Fri, 31 Jan 2020 14:31:42 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6BC189E7A; Fri, 31 Jan 2020 14:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481235; 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=3N4B3zUJ2bGQzFrkRVARzkkxtRLcRIyPBwzT/kNAzdA=; b=R8wB/QNSlAxl6plIg+RL+Z9Zns42cpBPek96NyyTvwFruO/qm3eh5PUZZswEvRJ6wo8bQa +PlLlTM8LY8RVpXXbgJW7XDyibXoduNX2j7ZUI+JLGqAbnlmAQhwpGb3gmUB4xB6Wq1pNI N7GTEcsAfLMutTA087UCfnGVRewPt20= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/19] qemu: block: Extract calls of qemuBlockGetNamedNodeData into a helper function Date: Fri, 31 Jan 2020 15:31:12 +0100 Message-Id: <21d34c01afb47136f083e8678fc845524272e1ac.1580480483.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: cLhnvD1lM1eAVx1m7bzjjA-1 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" Create a wrapper for qemuBlockGetNamedNodeData named qemuBlockGetNamedNodeData. The purpose of the wrapper is to integrate the monitor handling functionality and in the future possible qemuCaps-based flags. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_backup.c | 5 +---- src/qemu/qemu_block.c | 20 ++++++++++++++++++++ src/qemu/qemu_block.h | 4 ++++ src/qemu/qemu_driver.c | 16 ++++------------ 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 23518a5d40..8b1e9a7e19 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -830,10 +830,7 @@ qemuBackupBegin(virDomainObjPtr vm, goto endjob; } - if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, QEMU_ASYNC_JOB_BA= CKUP) < 0) - goto endjob; - blockNamedNodeData =3D qemuMonitorBlockGetNamedNodeData(priv->mon); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || !blockNamedNodeD= ata) + if (!(blockNamedNodeData =3D qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_= JOB_BACKUP))) goto endjob; if ((ndd =3D qemuBackupDiskPrepareData(vm, def, incremental, blockName= dNodeData, diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 22f03da485..13e240fdac 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2670,3 +2670,23 @@ qemuBlockNamedNodeDataGetBitmapByName(virHashTablePt= r blockNamedNodeData, return NULL; } + + +virHashTablePtr +qemuBlockGetNamedNodeData(virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virQEMUDriverPtr driver =3D priv->driver; + g_autoptr(virHashTable) blockNamedNodeData =3D NULL; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return NULL; + + blockNamedNodeData =3D qemuMonitorBlockGetNamedNodeData(priv->mon); + + if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockNamedNodeData) + return NULL; + + return g_steal_pointer(&blockNamedNodeData); +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 1a38e0eccf..68646cbf2e 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -208,3 +208,7 @@ qemuBlockNamedNodeDataBitmapPtr qemuBlockNamedNodeDataGetBitmapByName(virHashTablePtr blockNamedNodeData, virStorageSourcePtr src, const char *bitmap); + +virHashTablePtr +qemuBlockGetNamedNodeData(virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8bb845298b..47f0754a1a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15642,15 +15642,9 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPt= r driver, if (!(actions =3D virJSONValueNewArray())) return -1; - if (blockdev) { - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; - - blockNamedNodeData =3D qemuMonitorBlockGetNamedNodeData(priv->mon); - - if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockNamedNodeDat= a) - return -1; - } + if (blockdev && + !(blockNamedNodeData =3D qemuBlockGetNamedNodeData(vm, asyncJob))) + return -1; /* prepare a list of objects to use in the vm definition so that we do= n't * have to roll back later */ @@ -18354,9 +18348,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, = priv->qemuCaps))) goto endjob; } else { - qemuDomainObjEnterMonitor(driver, vm); - blockNamedNodeData =3D qemuMonitorBlockGetNamedNodeData(priv->= mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockNamedNod= eData) + if (!(blockNamedNodeData =3D qemuBlockGetNamedNodeData(vm, QEM= U_ASYNC_JOB_NONE))) goto endjob; if (qemuBlockStorageSourceCreateDetectSize(blockNamedNodeData, --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481257782569.5943078649136; Fri, 31 Jan 2020 06:34:17 -0800 (PST) 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-282-6RgmNGTnMWy3qafr8nO6qA-1; Fri, 31 Jan 2020 09:34:13 -0500 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 201D2DB22; Fri, 31 Jan 2020 14:34:07 +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 F334D5D9E5; Fri, 31 Jan 2020 14:34:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AFC271803C40; Fri, 31 Jan 2020 14:34:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVhkL019790 for ; Fri, 31 Jan 2020 09:31:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9B4FA89E7A; Fri, 31 Jan 2020 14:31:43 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id C889F86C4B; Fri, 31 Jan 2020 14:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481256; 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=Cn9tQm0/x3pAgzdr4bjWkqZaMGxrjIsrz+pVQVr455I=; b=Dk6/uWIfW2gAwmVCGrGlpEZZV8QDGD8Yjb3YOVF1HK7SgLKc4UETnnpPgJ1uvCo/k1mVjR bHxpKKM4JYocW/OZvH8wY9Hd0LLWZFYZJxnnyCUrcvzydQDMmFei86stm2Jmdj9XUzKevw KptiEeov9cvXius97XOAFzfr7iMgKL0= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/19] util: json: Introduce virJSONValueArrayConcat Date: Fri, 31 Jan 2020 15:31:13 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: 6RgmNGTnMWy3qafr8nO6qA-1 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" Add a helper that concatenates the second array into the first. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/util/virjson.c | 31 +++++++++++++++++++++++++++++++ src/util/virjson.h | 2 ++ 3 files changed, 34 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ebf830791e..b2d2420415 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2284,6 +2284,7 @@ virISCSIScanTargets; virJSONStringReformat; virJSONValueArrayAppend; virJSONValueArrayAppendString; +virJSONValueArrayConcat; virJSONValueArrayForeachSteal; virJSONValueArrayGet; virJSONValueArraySize; diff --git a/src/util/virjson.c b/src/util/virjson.c index 988a09e956..50993648eb 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -811,6 +811,37 @@ virJSONValueArrayAppendString(virJSONValuePtr object, } +/** + * virJSONValueArrayConcat: + * @a: JSON value array (destination) + * @c: JSON value array (source) + * + * Merges the members of @c array into @a. The values are stolen from @c. + */ +int +virJSONValueArrayConcat(virJSONValuePtr a, + virJSONValuePtr c) +{ + size_t i; + + if (a->type !=3D VIR_JSON_TYPE_ARRAY || + c->type !=3D VIR_JSON_TYPE_ARRAY) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("expecting JSON arr= ay")); + return -1; + } + + a->data.array.values =3D g_renew(virJSONValuePtr, a->data.array.values, + a->data.array.nvalues + c->data.array.n= values); + + for (i =3D 0; i < c->data.array.nvalues; i++) + a->data.array.values[a->data.array.nvalues++] =3D g_steal_pointer(= &c->data.array.values[i]); + + c->data.array.nvalues =3D 0; + + return 0; +} + + int virJSONValueObjectHasKey(virJSONValuePtr object, const char *key) diff --git a/src/util/virjson.h b/src/util/virjson.h index 7a6b063b17..0894e91b59 100644 --- a/src/util/virjson.h +++ b/src/util/virjson.h @@ -71,6 +71,8 @@ virJSONValuePtr virJSONValueNewArrayFromBitmap(virBitmapP= tr bitmap); int virJSONValueObjectAppend(virJSONValuePtr object, const char *key, virJ= SONValuePtr value); int virJSONValueArrayAppend(virJSONValuePtr object, virJSONValuePtr value); +int virJSONValueArrayConcat(virJSONValuePtr a, + virJSONValuePtr c); int virJSONValueObjectHasKey(virJSONValuePtr object, const char *key); virJSONValuePtr virJSONValueObjectGet(virJSONValuePtr object, const char *= key); --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481230509942.8177380451483; Fri, 31 Jan 2020 06:33:50 -0800 (PST) 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-374-3YClLDsXOdK52H8MKZXfUQ-1; Fri, 31 Jan 2020 09:33:45 -0500 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 4C4EA800D5E; Fri, 31 Jan 2020 14:33:40 +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 14D5560BE2; Fri, 31 Jan 2020 14:33:40 +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 AE47D18089D7; Fri, 31 Jan 2020 14:33:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEViVd019800 for ; Fri, 31 Jan 2020 09:31:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id C00C487B06; Fri, 31 Jan 2020 14:31:44 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id E97F086C4B; Fri, 31 Jan 2020 14:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481229; 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=WF04YtTojxa4Y73Xr3x/sX06l9HDj0+Fc3xwsSaRAe4=; b=aEC/lb6MIuS3qMdg7H13PQRjXnx9/ROJ+cEy93GU4rV9yEMzu15eEuOKo0xEDPQou/XXsF wFpHazLyHdWGdNLxm+mWO0bf4iBX5xC9g+o4a9qthyYrm4aRoy0SBrv/C0862SFEfwBi9D s93fCk8kTp+xG4n0SWOwA+NIKezyqDg= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/19] virJSONValueNewArray: Use g_new0 to allocate and remove NULL checks from callers Date: Fri, 31 Jan 2020 15:31:14 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: 3YClLDsXOdK52H8MKZXfUQ-1 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" Use the glib allocation function that never returns NULL and remove the now dead-code checks from all callers. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/locking/lock_daemon.c | 4 ++-- src/logging/log_handler.c | 3 +-- src/network/leaseshelper.c | 6 +----- src/qemu/qemu_agent.c | 6 +----- src/qemu/qemu_backup.c | 6 ++---- src/qemu/qemu_block.c | 9 +++------ src/qemu/qemu_blockjob.c | 3 +-- src/qemu/qemu_checkpoint.c | 9 +++------ src/qemu/qemu_driver.c | 3 +-- src/qemu/qemu_firmware.c | 12 ++++-------- src/qemu/qemu_migration_params.c | 3 +-- src/qemu/qemu_monitor_json.c | 3 +-- src/rpc/virnetserver.c | 6 ++---- src/rpc/virnetserverservice.c | 3 +-- src/util/virjson.c | 13 ++----------- src/util/virlockspace.c | 6 ++---- src/util/virmacmap.c | 8 ++++---- tests/qemublocktest.c | 3 +-- tests/qemumonitorjsontest.c | 5 ++--- 19 files changed, 35 insertions(+), 76 deletions(-) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 7ea228ce37..fd376fef2a 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -949,8 +949,8 @@ virLockDaemonPreExecRestart(const char *state_file, goto cleanup; } - if (!(lockspaces =3D virJSONValueNewArray())) - goto cleanup; + lockspaces =3D virJSONValueNewArray(); + if (virJSONValueObjectAppend(object, "lockspaces", lockspaces) < 0) { virJSONValueFree(lockspaces); goto cleanup; diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c index 030c9d66e3..973c52c7cd 100644 --- a/src/logging/log_handler.c +++ b/src/logging/log_handler.c @@ -619,8 +619,7 @@ virLogHandlerPreExecRestart(virLogHandlerPtr handler) if (!ret) return NULL; - if (!(files =3D virJSONValueNewArray())) - goto error; + files =3D virJSONValueNewArray(); if (virJSONValueObjectAppend(ret, "files", files) < 0) { virJSONValueFree(files); diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c index f1a061066e..dd1d5f70ee 100644 --- a/src/network/leaseshelper.c +++ b/src/network/leaseshelper.c @@ -200,11 +200,7 @@ main(int argc, char **argv) break; } - if (!(leases_array_new =3D virJSONValueNewArray())) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to create json")); - goto cleanup; - } + leases_array_new =3D virJSONValueNewArray(); if (virLeaseReadCustomLeaseFile(leases_array_new, custom_lease_file, delete ? ip : NULL, &server_duid) < 0) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 4374235d34..7d01d21a11 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1201,9 +1201,6 @@ qemuAgentMakeStringsArray(const char **strings, unsig= ned int len) size_t i; virJSONValuePtr ret =3D virJSONValueNewArray(), str; - if (!ret) - return NULL; - for (i =3D 0; i < len; i++) { str =3D virJSONValueNewString(strings[i]); if (!str) @@ -1534,8 +1531,7 @@ qemuAgentSetVCPUsCommand(qemuAgentPtr mon, *nmodified =3D 0; /* create the key data array */ - if (!(cpus =3D virJSONValueNewArray())) - goto cleanup; + cpus =3D virJSONValueNewArray(); for (i =3D 0; i < ninfo; i++) { qemuAgentCPUInfoPtr in =3D &info[i]; diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 8b1e9a7e19..2cc6ff7a42 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -180,8 +180,7 @@ qemuBackupDiskPrepareOneBitmapsChain(virDomainMomentDef= Ptr *incremental, g_autoptr(virJSONValue) ret =3D NULL; size_t incridx =3D 0; - if (!(ret =3D virJSONValueNewArray())) - return NULL; + ret =3D virJSONValueNewArray(); if (!(bitmap =3D qemuBlockNamedNodeDataGetBitmapByName(blockNamedNodeD= ata, backingChain, @@ -819,8 +818,7 @@ qemuBackupBegin(virDomainObjPtr vm, !(incremental =3D qemuBackupBeginCollectIncrementalCheckpoints(vm,= def->incremental))) goto endjob; - if (!(actions =3D virJSONValueNewArray())) - goto endjob; + actions =3D virJSONValueNewArray(); /* The 'chk' checkpoint must be rolled back if the transaction command * which creates it on disk is not executed or fails */ diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 13e240fdac..03f029368e 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -524,8 +524,7 @@ qemuBlockStorageSourceBuildHostsJSONSocketAddress(virSt= orageSourcePtr src, virStorageNetHostDefPtr host; size_t i; - if (!(servers =3D virJSONValueNewArray())) - return NULL; + servers =3D virJSONValueNewArray(); for (i =3D 0; i < src->nhosts; i++) { host =3D src->hosts + i; @@ -590,8 +589,7 @@ qemuBlockStorageSourceBuildHostsJSONInetSocketAddress(v= irStorageSourcePtr src) virStorageNetHostDefPtr host; size_t i; - if (!(servers =3D virJSONValueNewArray())) - return NULL; + servers =3D virJSONValueNewArray(); for (i =3D 0; i < src->nhosts; i++) { host =3D src->hosts + i; @@ -837,8 +835,7 @@ qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr s= rc, username =3D srcPriv->secinfo->s.aes.username; keysecret =3D srcPriv->secinfo->s.aes.alias; /* the auth modes are modelled after our old command line generato= r */ - if (!(authmodes =3D virJSONValueNewArray())) - return NULL; + authmodes =3D virJSONValueNewArray(); if (!(mode =3D virJSONValueNewString("cephx")) || virJSONValueArrayAppend(authmodes, mode) < 0) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index e04fcf69d1..3dc9222a6f 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1344,8 +1344,7 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDriver= Ptr driver, return; if (job->data.backup.bitmap) { - if (!(actions =3D virJSONValueNewArray())) - return; + actions =3D virJSONValueNewArray(); if (qemuMonitorTransactionBitmapRemove(actions, job->disk->src->nodeformat, diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 6ef35ea1a1..a60fbcdbac 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -217,8 +217,7 @@ qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr sr= c, return -1; } - if (!(arr =3D virJSONValueNewArray())) - return -1; + arr =3D virJSONValueNewArray(); if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr, n->nodefo= rmat, @@ -261,8 +260,7 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm, g_autoptr(GSList) relabelimages =3D NULL; GSList *next; - if (!(actions =3D virJSONValueNewArray())) - return -1; + actions =3D virJSONValueNewArray(); qemuDomainObjEnterMonitor(driver, vm); blockNamedNodeData =3D qemuMonitorBlockGetNamedNodeData(priv->mon); @@ -535,8 +533,7 @@ qemuCheckpointCreateCommon(virQEMUDriverPtr driver, if ((parent =3D virDomainCheckpointGetCurrent(vm->checkpoints))) (*def)->parent.parent_name =3D g_strdup(parent->def->name); - if (!(tmpactions =3D virJSONValueNewArray())) - return -1; + tmpactions =3D virJSONValueNewArray(); if (qemuCheckpointAddActions(vm, tmpactions, parent, *def) < 0) return -1; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 47f0754a1a..021e5a2732 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15639,8 +15639,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, if (virDomainObjCheckActive(vm) < 0) return -1; - if (!(actions =3D virJSONValueNewArray())) - return -1; + actions =3D virJSONValueNewArray(); if (blockdev && !(blockNamedNodeData =3D qemuBlockGetNamedNodeData(vm, asyncJob))) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 7fb57913e8..68e2c6b40f 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -651,8 +651,7 @@ qemuFirmwareInterfaceFormat(virJSONValuePtr doc, g_autoptr(virJSONValue) interfacesJSON =3D NULL; size_t i; - if (!(interfacesJSON =3D virJSONValueNewArray())) - return -1; + interfacesJSON =3D virJSONValueNewArray(); for (i =3D 0; i < fw->ninterfaces; i++) { if (virJSONValueArrayAppendString(interfacesJSON, @@ -799,8 +798,7 @@ qemuFirmwareTargetFormat(virJSONValuePtr doc, g_autoptr(virJSONValue) targetsJSON =3D NULL; size_t i; - if (!(targetsJSON =3D virJSONValueNewArray())) - return -1; + targetsJSON =3D virJSONValueNewArray(); for (i =3D 0; i < fw->ntargets; i++) { qemuFirmwareTargetPtr t =3D fw->targets[i]; @@ -816,8 +814,7 @@ qemuFirmwareTargetFormat(virJSONValuePtr doc, virQEMUCapsArchToString(t->arch= itecture)) < 0) return -1; - if (!(machines =3D virJSONValueNewArray())) - return -1; + machines =3D virJSONValueNewArray(); for (j =3D 0; j < t->nmachines; j++) { if (virJSONValueArrayAppendString(machines, @@ -851,8 +848,7 @@ qemuFirmwareFeatureFormat(virJSONValuePtr doc, g_autoptr(virJSONValue) featuresJSON =3D NULL; size_t i; - if (!(featuresJSON =3D virJSONValueNewArray())) - return -1; + featuresJSON =3D virJSONValueNewArray(); for (i =3D 0; i < fw->nfeatures; i++) { if (virJSONValueArrayAppendString(featuresJSON, diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 1b28e5e031..dd1ad9349b 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -785,8 +785,7 @@ qemuMigrationCapsToJSON(virBitmapPtr caps, qemuMigrationCapability bit; const char *name; - if (!(json =3D virJSONValueNewArray())) - return NULL; + json =3D virJSONValueNewArray(); for (bit =3D 0; bit < QEMU_MIGRATION_CAP_LAST; bit++) { bool supported =3D false; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 981d091ba0..dc1fc310ca 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4800,8 +4800,7 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon, size_t i; /* create the key data array */ - if (!(keys =3D virJSONValueNewArray())) - goto cleanup; + keys =3D virJSONValueNewArray(); for (i =3D 0; i < nkeycodes; i++) { if (keycodes[i] > 0xffff) { diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 4122636805..c87dade1a8 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -603,8 +603,7 @@ virJSONValuePtr virNetServerPreExecRestart(virNetServer= Ptr srv) goto error; } - if (!(services =3D virJSONValueNewArray())) - goto error; + services =3D virJSONValueNewArray(); if (virJSONValueObjectAppend(object, "services", services) < 0) { virJSONValueFree(services); @@ -622,8 +621,7 @@ virJSONValuePtr virNetServerPreExecRestart(virNetServer= Ptr srv) } } - if (!(clients =3D virJSONValueNewArray())) - goto error; + clients =3D virJSONValueNewArray(); if (virJSONValueObjectAppend(object, "clients", clients) < 0) { virJSONValueFree(clients); diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c index 5d1178f899..0a003e5814 100644 --- a/src/rpc/virnetserverservice.c +++ b/src/rpc/virnetserverservice.c @@ -353,8 +353,7 @@ virJSONValuePtr virNetServerServicePreExecRestart(virNe= tServerServicePtr svc) if (virJSONValueObjectAppendNumberUint(object, "nrequests_client_max",= svc->nrequests_client_max) < 0) goto error; - if (!(socks =3D virJSONValueNewArray())) - goto error; + socks =3D virJSONValueNewArray(); if (virJSONValueObjectAppend(object, "socks", socks) < 0) { virJSONValueFree(socks); diff --git a/src/util/virjson.c b/src/util/virjson.c index 50993648eb..ca57df816f 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -561,10 +561,7 @@ virJSONValueNewNull(void) virJSONValuePtr virJSONValueNewArray(void) { - virJSONValuePtr val; - - if (VIR_ALLOC(val) < 0) - return NULL; + virJSONValuePtr val =3D g_new0(virJSONValue, 1); val->type =3D VIR_JSON_TYPE_ARRAY; @@ -1265,8 +1262,7 @@ virJSONValueNewArrayFromBitmap(virBitmapPtr bitmap) virJSONValuePtr ret; ssize_t pos =3D -1; - if (!(ret =3D virJSONValueNewArray())) - return NULL; + ret =3D virJSONValueNewArray(); if (!bitmap) return ret; @@ -1522,8 +1518,6 @@ virJSONValueCopy(const virJSONValue *in) break; case VIR_JSON_TYPE_ARRAY: out =3D virJSONValueNewArray(); - if (!out) - return NULL; for (i =3D 0; i < in->data.array.nvalues; i++) { virJSONValuePtr val =3D NULL; if (!(val =3D virJSONValueCopy(in->data.array.values[i]))) @@ -1782,9 +1776,6 @@ virJSONParserHandleStartArray(void *ctx) VIR_DEBUG("parser=3D%p", parser); - if (!value) - return 0; - if (virJSONParserInsertValue(parser, value) < 0) { virJSONValueFree(value); return 0; diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index 59d47daae8..a44377f89e 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -443,8 +443,7 @@ virJSONValuePtr virLockSpacePreExecRestart(virLockSpace= Ptr lockspace) virJSONValueObjectAppendString(object, "directory", lockspace->dir= ) < 0) goto error; - if (!(resources =3D virJSONValueNewArray())) - goto error; + resources =3D virJSONValueNewArray(); if (virJSONValueObjectAppend(object, "resources", resources) < 0) { virJSONValueFree(resources); @@ -479,8 +478,7 @@ virJSONValuePtr virLockSpacePreExecRestart(virLockSpace= Ptr lockspace) goto error; } - if (!(owners =3D virJSONValueNewArray())) - goto error; + owners =3D virJSONValueNewArray(); if (virJSONValueObjectAppend(child, "owners", owners) < 0) { virJSONValueFree(owners); diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c index cd74f67678..ec589334ea 100644 --- a/src/util/virmacmap.c +++ b/src/util/virmacmap.c @@ -206,10 +206,11 @@ virMACMapHashDumper(void *payload, size_t i; int ret =3D -1; - if (!(obj =3D virJSONValueNewObject()) || - !(arr =3D virJSONValueNewArray())) + if (!(obj =3D virJSONValueNewObject())) goto cleanup; + arr =3D virJSONValueNewArray(); + for (i =3D 0; macs[i]; i++) { virJSONValuePtr m =3D virJSONValueNewString(macs[i]); @@ -244,8 +245,7 @@ virMacMapDumpStrLocked(virMacMapPtr mgr, virJSONValuePtr arr; int ret =3D -1; - if (!(arr =3D virJSONValueNewArray())) - goto cleanup; + arr =3D virJSONValueNewArray(); if (virHashForEach(mgr->macs, virMACMapHashDumper, arr) < 0) goto cleanup; diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 50dcb86810..cd61334b4a 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -737,8 +737,7 @@ testQemuCheckpointDeleteMerge(const void *opaque) return -1; } - if (!(actions =3D virJSONValueNewArray())) - return -1; + actions =3D virJSONValueNewArray(); if (qemuCheckpointDiscardDiskBitmaps(data->chain, nodedata, diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 0334f83628..2c696a2e8b 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2948,9 +2948,8 @@ testQemuMonitorJSONTransaction(const void *opaque) if (!(test =3D qemuMonitorTestNewSchema(data->xmlopt, data->schema))) return -1; - if (!(actions =3D virJSONValueNewArray()) || - !(mergebitmaps =3D virJSONValueNewArray())) - return -1; + actions =3D virJSONValueNewArray(); + mergebitmaps =3D virJSONValueNewArray(); if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(mergebitmaps, "no= de1", "bitmap1") < 0 || qemuMonitorTransactionBitmapMergeSourceAddBitmap(mergebitmaps, "no= de2", "bitmap2") < 0) --=20 2.24.1 From nobody Wed May 8 20:06: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 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580481305375133.59738730975278; Fri, 31 Jan 2020 06:35:05 -0800 (PST) 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-354-KDkw2OwNMDepo785-t8xtw-1; Fri, 31 Jan 2020 09:34:18 -0500 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 9C6BF800E21; Fri, 31 Jan 2020 14:34:12 +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 4C4E65C57E; Fri, 31 Jan 2020 14:34:12 +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 1A5AE85CE4; Fri, 31 Jan 2020 14:34:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVmP4019808 for ; Fri, 31 Jan 2020 09:31:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3A0AB89E7E; Fri, 31 Jan 2020 14:31:48 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63EB386C4B; Fri, 31 Jan 2020 14:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481304; 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=w6wNZk7E1kLV+NLi/2kCSidx1WfJ600a8vZ62+Qo5wk=; b=SXVRdXx5SXZszOAs8uFp2ZowKM/839j345LWweyGhhNhhlCNKyvVgSlXOTV8LFb4rifysq kzPKIl2kqzf2SNZ1OFmWUCTocWr/rVnJM/x3dnjqd9GTuPzKZMa8dGZtpps2z0F9+2/qKt ALD1B8t4g33Rc+EjAizIZZRDdgsbhfA= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/19] virhash: Make sure that hash key is always copied Date: Fri, 31 Jan 2020 15:31:15 +0100 Message-Id: <2a06a8a9441db5b0a72c9e6a055255329a49dea9.1580480483.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: KDkw2OwNMDepo785-t8xtw-1 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" Fix all implementations of virHashKeyCopy to always return a valid pointer. Tweak the return value expectation comment so that it doesn't necessarily require to allocate memory. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_addr.c | 5 +---- src/util/virhash.c | 4 +--- src/util/virhash.h | 3 ++- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index f07b3d9725..e0be655772 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -997,10 +997,7 @@ virZPCIAddrKeyEqual(const void *namea, static void * virZPCIAddrKeyCopy(const void *name) { - unsigned int *copy; - - if (VIR_ALLOC(copy) < 0) - return NULL; + unsigned int *copy =3D g_new0(unsigned int, 1); *copy =3D *((unsigned int *)name); return (void *)copy; diff --git a/src/util/virhash.c b/src/util/virhash.c index d5c5e017a1..c57d9f8292 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -94,9 +94,7 @@ static bool virHashStrEqual(const void *namea, const void= *nameb) static void *virHashStrCopy(const void *name) { - char *ret; - ret =3D g_strdup(name); - return ret; + return g_strdup(name); } diff --git a/src/util/virhash.h b/src/util/virhash.h index 08f99d8a3d..143ce52206 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -83,7 +83,8 @@ typedef bool (*virHashKeyEqual)(const void *namea, const = void *nameb); * Create a copy of the hash key, duplicating * memory allocation where applicable * - * Returns a newly allocated copy of @name + * Returns a copy of @name which will eventually be passed to the + * 'virHashKeyFree' callback at the end of it's lifetime. */ typedef void *(*virHashKeyCopy)(const void *name); /** --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481245545284.95043319160527; Fri, 31 Jan 2020 06:34:05 -0800 (PST) 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-401-nvigG4UhOM6BKN_Z0nGyMg-1; Fri, 31 Jan 2020 09:33:57 -0500 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 33F7D8010EA; Fri, 31 Jan 2020 14:33:51 +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 0D74289E85; Fri, 31 Jan 2020 14:33:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BD62E180612F; Fri, 31 Jan 2020 14:33:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVnWZ019815 for ; Fri, 31 Jan 2020 09:31:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5E82B87B12; Fri, 31 Jan 2020 14:31:49 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8788986C4B; Fri, 31 Jan 2020 14:31:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481244; 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=+j8z+r3ZK2n0PTWuPR+alyi8DL63qkjf9o/ihqOTMS8=; b=ai0VXwLmNWnCY8LkBMYxxUjDLYnIWRbW0ezyfromL16Nu1kATP8si/HnxCGo22v5fTbQGr 8+O1j30tEkOPFJJm0xqdjQe6cqM6A29rEE8qdNp3ZXzXyB+sT8/o9LDxoC72YNSg+3WcuZ WrXLDsHyteIHQ1ksbxpYQHl1+CgYJ6Y= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/19] virHashAddOrUpdateEntry: Simplify allocation of new entry Date: Fri, 31 Jan 2020 15:31:16 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: nvigG4UhOM6BKN_Z0nGyMg-1 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" Use g_new0 and skip checking of the return value of keyCopy callback as both are bound to return a valid pointer. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virhash.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/util/virhash.c b/src/util/virhash.c index c57d9f8292..36a2d312fc 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -344,7 +344,6 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const vo= id *name, size_t key, len =3D 0; virHashEntryPtr entry; virHashEntryPtr last =3D NULL; - void *new_name; if ((table =3D=3D NULL) || (name =3D=3D NULL)) return -1; @@ -374,12 +373,8 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const v= oid *name, len++; } - if (VIR_ALLOC(entry) < 0 || !(new_name =3D table->keyCopy(name))) { - VIR_FREE(entry); - return -1; - } - - entry->name =3D new_name; + entry =3D g_new0(virHashEntry, 1); + entry->name =3D table->keyCopy(name); entry->payload =3D userdata; if (last) --=20 2.24.1 From nobody Wed May 8 20:06: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 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580481243281163.92577453142917; Fri, 31 Jan 2020 06:34:03 -0800 (PST) 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-38-ov9tIHviOV2vbA0mogo-fg-1; Fri, 31 Jan 2020 09:33:59 -0500 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 A74C08010CB; Fri, 31 Jan 2020 14:33:54 +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 80EB05C3FA; Fri, 31 Jan 2020 14:33:54 +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 3D0A485CE2; Fri, 31 Jan 2020 14:33:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVoeY019823 for ; Fri, 31 Jan 2020 09:31:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7E32187B06; Fri, 31 Jan 2020 14:31:50 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC24C86C4B; Fri, 31 Jan 2020 14:31:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481241; 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=vyHNpqn+xNwo9+ZDL0A8nKUV/QQaxL6j4BXlPMhqy4k=; b=UCM+cP5pHEe+1BqlnVR+j05Qyo0HVJo5oFeEuKvGTGr0iDZmZ+K6AjLnTjEXtGKUFp0NmJ dTp/juyetnX7UqfBXQiP6cQePX+Mgcx2622G3MLrVJE09TBtjVXNUJCMKurvEYFWYT7y1C ohwcTrHM9GzUWd9jgQcZlxti3ZQWGTg= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/19] qemu: blockjob: Store 'jobflags' with block job data Date: Fri, 31 Jan 2020 15:31:17 +0100 Message-Id: <021352c4fce6512d3f5af8f04558a93e8ba63fa5.1580480483.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: ov9tIHviOV2vbA0mogo-fg-1 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" Add a variable which will store the contents of the 'flags' variable as passed in by the individual block jobs. Since the flags may influence behaviour of the jobs it's important to preserve it to the finalization steps. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.h | 3 +++ src/qemu/qemu_domain.c | 7 +++++++ tests/qemustatusxml2xmldata/backup-pull-in.xml | 2 +- tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml | 8 ++++---- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index 2f29e8209c..9e55382f15 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -129,6 +129,9 @@ struct _qemuBlockJobData { virStorageSourcePtr chain; /* Reference to the chain the job operates = on. */ virStorageSourcePtr mirrorChain; /* reference to 'mirror' part of the = job */ + unsigned int jobflags; /* per job flags */ + bool jobflagsmissing; /* job flags were not stored */ + union { qemuBlockJobPullData pull; qemuBlockJobCommitData commit; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 05a8d3de38..0c7a2641ea 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2582,6 +2582,8 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void *p= ayload, virBufferEscapeString(&attrBuf, " newstate=3D'%s'", newstate); if (job->brokentype !=3D QEMU_BLOCKJOB_TYPE_NONE) virBufferEscapeString(&attrBuf, " brokentype=3D'%s'", qemuBlockjob= TypeToString(job->brokentype)); + if (!job->jobflagsmissing) + virBufferAsprintf(&attrBuf, " jobflags=3D'0x%x'", job->jobflags); virBufferEscapeString(&childBuf, "%s", job->errmsg); if (job->disk) { @@ -3294,6 +3296,7 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObj= Ptr vm, int newstate =3D -1; bool invalidData =3D false; xmlNodePtr tmp; + unsigned long jobflags =3D 0; ctxt->node =3D node; @@ -3333,6 +3336,9 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObj= Ptr vm, STRNEQ(mirror, "yes")) invalidData =3D true; + if (virXPathULongHex("string(./@jobflags)", ctxt, &jobflags) !=3D 0) + job->jobflagsmissing =3D true; + if (!disk && !invalidData) { if ((tmp =3D virXPathNode("./chains/disk", ctxt)) && !(job->chain =3D qemuDomainObjPrivateXMLParseBlockjobChain(tmp= , ctxt, xmlopt))) @@ -3352,6 +3358,7 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObj= Ptr vm, job->state =3D state; job->newstate =3D newstate; + job->jobflags =3D jobflags; job->errmsg =3D virXPathString("string(./errmsg)", ctxt); job->invalidData =3D invalidData; job->disk =3D disk; diff --git a/tests/qemustatusxml2xmldata/backup-pull-in.xml b/tests/qemusta= tusxml2xmldata/backup-pull-in.xml index 3c69c41840..1db978a3ac 100644 --- a/tests/qemustatusxml2xmldata/backup-pull-in.xml +++ b/tests/qemustatusxml2xmldata/backup-pull-in.xml @@ -235,7 +235,7 @@ - + diff --git a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml b/tests/q= emustatusxml2xmldata/blockjob-blockdev-in.xml index b5d62fd4ab..ca6d110179 100644 --- a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml +++ b/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml @@ -261,19 +261,19 @@ - + - + - + - + --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481364228858.706025420716; Fri, 31 Jan 2020 06:36:04 -0800 (PST) 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-174-B16QXQmePzWED3sWAP0W7A-1; Fri, 31 Jan 2020 09:34:04 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D307190B2BA; Fri, 31 Jan 2020 14:33: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 18B9989A69; Fri, 31 Jan 2020 14:33: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 CB1D785CE6; Fri, 31 Jan 2020 14:33:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVp9B019834 for ; Fri, 31 Jan 2020 09:31:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9F63A87B06; Fri, 31 Jan 2020 14:31:51 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD46186C4B; Fri, 31 Jan 2020 14:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481363; 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=G4xDsAp/eJDts8rs9vWGlHNEIv2eNp38e5irH68JhJQ=; b=MA7l+D9U88FJW2rgtJ4bM8ZyE8n6NH9Ov6d1bTeQ4CLHmfEDESykwe8HU5E+fQWP9ZJgTr B4skNBTjbJa/6MzCSQI28vSlmEV3mN6OfTe8Yg+IFLKBfjXTCF3pttU+Nq5hev/LrfAPCc 2Gzu8eyxSYMedytKb2YN6bTwdNgUzVE= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/19] qemu: blockjob: Store 'flags' for all the block job types Date: Fri, 31 Jan 2020 15:31:18 +0100 Message-Id: <547fc9db59690252849caa3066f14e4b76f387ba.1580480483.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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.11 X-MC-Unique: B16QXQmePzWED3sWAP0W7A-1 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 flags may control important aspects of the block job which may influence also the termination of the job. Store the 'flags' for all the block job types. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 13 ++++++++++--- src/qemu/qemu_blockjob.h | 9 ++++++--- src/qemu/qemu_driver.c | 7 ++++--- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 3dc9222a6f..6b59bbeb2c 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -252,7 +252,8 @@ qemuBlockJobDiskNew(virDomainObjPtr vm, qemuBlockJobDataPtr qemuBlockJobDiskNewPull(virDomainObjPtr vm, virDomainDiskDefPtr disk, - virStorageSourcePtr base) + virStorageSourcePtr base, + unsigned int jobflags) { qemuDomainObjPrivatePtr priv =3D vm->privateData; g_autoptr(qemuBlockJobData) job =3D NULL; @@ -269,6 +270,7 @@ qemuBlockJobDiskNewPull(virDomainObjPtr vm, return NULL; job->data.pull.base =3D base; + job->jobflags =3D jobflags; if (qemuBlockJobRegister(job, vm, disk, true) < 0) return NULL; @@ -283,7 +285,8 @@ qemuBlockJobDiskNewCommit(virDomainObjPtr vm, virStorageSourcePtr topparent, virStorageSourcePtr top, virStorageSourcePtr base, - bool delete_imgs) + bool delete_imgs, + unsigned int jobflags) { qemuDomainObjPrivatePtr priv =3D vm->privateData; g_autoptr(qemuBlockJobData) job =3D NULL; @@ -307,6 +310,7 @@ qemuBlockJobDiskNewCommit(virDomainObjPtr vm, job->data.commit.top =3D top; job->data.commit.base =3D base; job->data.commit.deleteCommittedImages =3D delete_imgs; + job->jobflags =3D jobflags; if (qemuBlockJobRegister(job, vm, disk, true) < 0) return NULL; @@ -350,7 +354,8 @@ qemuBlockJobDiskNewCopy(virDomainObjPtr vm, virDomainDiskDefPtr disk, virStorageSourcePtr mirror, bool shallow, - bool reuse) + bool reuse, + unsigned int jobflags) { qemuDomainObjPrivatePtr priv =3D vm->privateData; g_autoptr(qemuBlockJobData) job =3D NULL; @@ -371,6 +376,8 @@ qemuBlockJobDiskNewCopy(virDomainObjPtr vm, if (shallow && !reuse) job->data.copy.shallownew =3D true; + job->jobflags =3D jobflags; + if (qemuBlockJobRegister(job, vm, disk, true) < 0) return NULL; diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index 9e55382f15..72c7fa053e 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -176,7 +176,8 @@ qemuBlockJobDiskNew(virDomainObjPtr vm, qemuBlockJobDataPtr qemuBlockJobDiskNewPull(virDomainObjPtr vm, virDomainDiskDefPtr disk, - virStorageSourcePtr base); + virStorageSourcePtr base, + unsigned int jobflags); qemuBlockJobDataPtr qemuBlockJobDiskNewCommit(virDomainObjPtr vm, @@ -184,7 +185,8 @@ qemuBlockJobDiskNewCommit(virDomainObjPtr vm, virStorageSourcePtr topparent, virStorageSourcePtr top, virStorageSourcePtr base, - bool delete_imgs); + bool delete_imgs, + unsigned int jobflags); qemuBlockJobDataPtr qemuBlockJobNewCreate(virDomainObjPtr vm, @@ -197,7 +199,8 @@ qemuBlockJobDiskNewCopy(virDomainObjPtr vm, virDomainDiskDefPtr disk, virStorageSourcePtr mirror, bool shallow, - bool reuse); + bool reuse, + unsigned int jobflags); qemuBlockJobDataPtr qemuBlockJobDiskNewBackup(virDomainObjPtr vm, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 021e5a2732..a2481232ad 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17706,7 +17706,7 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm, speed <<=3D 20; } - if (!(job =3D qemuBlockJobDiskNewPull(vm, disk, baseSource))) + if (!(job =3D qemuBlockJobDiskNewPull(vm, disk, baseSource, flags))) goto endjob; if (blockdev) { @@ -18393,7 +18393,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, goto endjob; } - if (!(job =3D qemuBlockJobDiskNewCopy(vm, disk, mirror, mirror_shallow= , mirror_reuse))) + if (!(job =3D qemuBlockJobDiskNewCopy(vm, disk, mirror, mirror_shallow= , mirror_reuse, flags))) goto endjob; disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_NONE; @@ -18814,7 +18814,8 @@ qemuDomainBlockCommit(virDomainPtr dom, if (!(job =3D qemuBlockJobDiskNewCommit(vm, disk, top_parent, topSourc= e, baseSource, - flags & VIR_DOMAIN_BLOCK_COMMIT_= DELETE))) + flags & VIR_DOMAIN_BLOCK_COMMIT_= DELETE, + flags))) goto endjob; disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_NONE; --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481274559495.125794824383; Fri, 31 Jan 2020 06:34:34 -0800 (PST) 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-107-IK6Ky2u2Ml2HRAb8R4NIuA-1; Fri, 31 Jan 2020 09:34:26 -0500 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 712A41005502; Fri, 31 Jan 2020 14:34:16 +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 498305C54A; Fri, 31 Jan 2020 14:34:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 011D985CEF; Fri, 31 Jan 2020 14:34:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVqHF019844 for ; Fri, 31 Jan 2020 09:31:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id C09A087B06; Fri, 31 Jan 2020 14:31:52 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED24786C4B; Fri, 31 Jan 2020 14:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481273; 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=s/dtFE9fUOnfiS9I686iJdeR/QMGQmputcduTtarx9I=; b=GkJhEGWtwCe1lFq9QfhBll5x7IAykOajmDEww+aLLRYWc/tnDVnVl4VkWsWTPm/2I1DnYh cviAqholmhrhMzN9JdRY591V6J1oIzgB9lsTTAWzcOReP567yEXNf/YzAlGearViPRjcbS Z/IGzFzmf/mKNFJPq97lpbAgD1FHVh8= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/19] qemu: block: Add validator for bitmap chains accross backing chains Date: Fri, 31 Jan 2020 15:31:19 +0100 Message-Id: <1d5ffbb3610ee8bfe001455fc5f444fcdd4a46e4.1580480483.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: IK6Ky2u2Ml2HRAb8R4NIuA-1 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" Add a validator which checks that a bitmap spanning multiple backing chain members doesn't look broken. The current rules are that no intermediate birmaps are missing (unfortunately it's hard to know whether the topmost or bottommost bitmap is missing) and none of the components is inconsistent. We can obviously improve it over time. The validator is also tested against the existing bitmap data we have for the backup merging test as well as some of the existing broken bitmap synthetic test cases. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 41 +++++++++++++++++++++++++ src/qemu/qemu_block.h | 5 ++++ tests/qemublocktest.c | 70 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 03f029368e..b19290e677 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2687,3 +2687,44 @@ qemuBlockGetNamedNodeData(virDomainObjPtr vm, return g_steal_pointer(&blockNamedNodeData); } + + +/** + * qemuBlockBitmapChainIsValid: + * + * Validates that the backing chain of @src contains proper consistent bit= map + * data for a chain of bitmaps named @bitmapname. + * + * A valid chain: + * 1) bitmaps of same name are in a consecutive subset of images without g= ap + * 2) don't have any inconsistent bitmaps + */ +bool +qemuBlockBitmapChainIsValid(virStorageSourcePtr src, + const char *bitmapname, + virHashTablePtr blockNamedNodeData) +{ + qemuBlockNamedNodeDataBitmapPtr bitmap; + virStorageSourcePtr n; + bool chain_started =3D false; + bool chain_ended =3D false; + + for (n =3D src; n; n =3D n->backingStore) { + if (!(bitmap =3D qemuBlockNamedNodeDataGetBitmapByName(blockNamedN= odeData, n, bitmapname))) { + if (chain_started) + chain_ended =3D true; + + continue; + } + + if (chain_ended) + return false; + + chain_started =3D true; + + if (bitmap->inconsistent) + return false; + } + + return chain_started; +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 68646cbf2e..cf51b9bf4e 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -212,3 +212,8 @@ qemuBlockNamedNodeDataGetBitmapByName(virHashTablePtr b= lockNamedNodeData, virHashTablePtr qemuBlockGetNamedNodeData(virDomainObjPtr vm, qemuDomainAsyncJob asyncJob); + +bool +qemuBlockBitmapChainIsValid(virStorageSourcePtr src, + const char *bitmapname, + virHashTablePtr blockNamedNodeData); diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index cd61334b4a..133372908a 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -768,6 +768,41 @@ testQemuCheckpointDeleteMerge(const void *opaque) } +struct testQemuBlockBitmapValidateData { + const char *name; + const char *bitmapname; + virStorageSourcePtr chain; + bool expect; +}; + +static int +testQemuBlockBitmapValidate(const void *opaque) +{ + const struct testQemuBlockBitmapValidateData *data =3D opaque; + g_autoptr(virJSONValue) nodedatajson =3D NULL; + g_autoptr(virHashTable) nodedata =3D NULL; + bool actual; + + if (!(nodedatajson =3D virTestLoadFileJSON(bitmapDetectPrefix, data->n= ame, + ".json", NULL))) + return -1; + + if (!(nodedata =3D qemuMonitorJSONBlockGetNamedNodeDataJSON(nodedatajs= on))) { + VIR_TEST_VERBOSE("failed to load nodedata JSON\n"); + return -1; + } + + actual =3D qemuBlockBitmapChainIsValid(data->chain, data->bitmapname, = nodedata); + + if (actual !=3D data->expect) { + VIR_TEST_VERBOSE("expected rv:'%d' actual rv:'%d'\n", data->expect= , actual); + return -1; + } + + return 0; +} + + static int mymain(void) { @@ -778,6 +813,7 @@ mymain(void) struct testQemuImageCreateData imagecreatedata; struct testQemuBackupIncrementalBitmapCalculateData backupbitmapcalcda= ta; struct testQemuCheckpointDeleteMergeData checkpointdeletedata; + struct testQemuBlockBitmapValidateData blockbitmapvalidatedata; char *capslatest_x86_64 =3D NULL; virQEMUCapsPtr caps_x86_64 =3D NULL; g_autoptr(virStorageSource) bitmapSourceChain =3D NULL; @@ -1045,7 +1081,41 @@ mymain(void) TEST_CHECKPOINT_DELETE_MERGE("snapshots-synthetic-checkpoint-intermedi= ate3", "d", "c", "snapshots-synthetic-checkpoint"); TEST_CHECKPOINT_DELETE_MERGE("snapshots-synthetic-checkpoint-current",= "current", "d", "snapshots-synthetic-checkpoint"); +#define TEST_BITMAP_VALIDATE(testname, bitmap, rc) \ + do { \ + blockbitmapvalidatedata.name =3D testname; \ + blockbitmapvalidatedata.chain =3D bitmapSourceChain; \ + blockbitmapvalidatedata.bitmapname =3D bitmap; \ + blockbitmapvalidatedata.expect =3D rc; \ + if (virTestRun("bitmap validate " testname " " bitmap, \ + testQemuBlockBitmapValidate, \ + &blockbitmapvalidatedata) < 0) \ + ret =3D -1; \ + } while (0) + TEST_BITMAP_VALIDATE("basic", "a", true); + TEST_BITMAP_VALIDATE("basic", "b", true); + TEST_BITMAP_VALIDATE("basic", "c", true); + TEST_BITMAP_VALIDATE("basic", "d", true); + TEST_BITMAP_VALIDATE("basic", "current", true); + + TEST_BITMAP_VALIDATE("snapshots", "a", true); + TEST_BITMAP_VALIDATE("snapshots", "b", true); + TEST_BITMAP_VALIDATE("snapshots", "c", true); + TEST_BITMAP_VALIDATE("snapshots", "d", true); + TEST_BITMAP_VALIDATE("snapshots", "current", true); + + TEST_BITMAP_VALIDATE("synthetic", "a", false); + TEST_BITMAP_VALIDATE("synthetic", "b", true); + TEST_BITMAP_VALIDATE("synthetic", "c", true); + TEST_BITMAP_VALIDATE("synthetic", "d", true); + TEST_BITMAP_VALIDATE("synthetic", "current", true); + + TEST_BITMAP_VALIDATE("snapshots-synthetic-checkpoint", "a", true); + TEST_BITMAP_VALIDATE("snapshots-synthetic-checkpoint", "b", true); + TEST_BITMAP_VALIDATE("snapshots-synthetic-checkpoint", "c", true); + TEST_BITMAP_VALIDATE("snapshots-synthetic-checkpoint", "d", true); + TEST_BITMAP_VALIDATE("snapshots-synthetic-checkpoint", "current", true= ); cleanup: virHashFree(diskxmljsondata.schema); qemuTestDriverFree(&driver); --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481233652445.2887267541273; Fri, 31 Jan 2020 06:33:53 -0800 (PST) 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-100-IBkVb039M9it0U6jKn7ghA-1; Fri, 31 Jan 2020 09:33:49 -0500 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 33C1D113784B; Fri, 31 Jan 2020 14:33:44 +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 08C808BE03; Fri, 31 Jan 2020 14:33:44 +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 BCA2085CD2; Fri, 31 Jan 2020 14:33:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVrpO019854 for ; Fri, 31 Jan 2020 09:31:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id E602A87B12; Fri, 31 Jan 2020 14:31:53 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BD1386C4B; Fri, 31 Jan 2020 14:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481232; 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=h5zesfWL2+GVg1kQXLD20G/xl6mmijVEDUte/c51oVo=; b=PCMtUh0hJN7yDa3HZSPv/qXF0hp9C3B0a+f8MRF01vD2iKofuK49IK1Xy3nAf0CaLeyaSC OdCG3S5i85PIVpzwJN4VKnvw7R8cj+1XzBsBM+tFxOBr+6AuVdTcsoITD2rNssAkp9vju/ d3lJa/esfdKpXJPJwuqsLbxhpm106WI= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/19] tests: qemublocktest: Add another synthetic test case for broken bitmaps Date: Fri, 31 Jan 2020 15:31:20 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: IBkVb039M9it0U6jKn7ghA-1 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" Add a case where a bitmap spanning multiple images is missing one of the intermediate components. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 8 + .../bitmap/snapshots-synthetic-broken.json | 819 ++++++++++++++++++ .../bitmap/snapshots-synthetic-broken.out | 12 + 3 files changed, 839 insertions(+) create mode 100644 tests/qemublocktestdata/bitmap/snapshots-synthetic-brok= en.json create mode 100644 tests/qemublocktestdata/bitmap/snapshots-synthetic-brok= en.out diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 133372908a..ada3608e53 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -1030,6 +1030,7 @@ mymain(void) TEST_BITMAP_DETECT("synthetic"); TEST_BITMAP_DETECT("snapshots"); TEST_BITMAP_DETECT("snapshots-synthetic-checkpoint"); + TEST_BITMAP_DETECT("snapshots-synthetic-broken"); #define TEST_BACKUP_BITMAP_CALCULATE(testname, source, incrbackup, named) \ do { \ @@ -1116,6 +1117,13 @@ mymain(void) TEST_BITMAP_VALIDATE("snapshots-synthetic-checkpoint", "c", true); TEST_BITMAP_VALIDATE("snapshots-synthetic-checkpoint", "d", true); TEST_BITMAP_VALIDATE("snapshots-synthetic-checkpoint", "current", true= ); + + TEST_BITMAP_VALIDATE("snapshots-synthetic-broken", "a", false); + TEST_BITMAP_VALIDATE("snapshots-synthetic-broken", "b", true); + TEST_BITMAP_VALIDATE("snapshots-synthetic-broken", "c", true); + TEST_BITMAP_VALIDATE("snapshots-synthetic-broken", "d", false); + TEST_BITMAP_VALIDATE("snapshots-synthetic-broken", "current", true); + cleanup: virHashFree(diskxmljsondata.schema); qemuTestDriverFree(&driver); diff --git a/tests/qemublocktestdata/bitmap/snapshots-synthetic-broken.json= b/tests/qemublocktestdata/bitmap/snapshots-synthetic-broken.json new file mode 100644 index 0000000000..bf4963494f --- /dev/null +++ b/tests/qemublocktestdata/bitmap/snapshots-synthetic-broken.json @@ -0,0 +1,819 @@ +[ + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "backing-image": { + "backing-image": { + "backing-image": { + "virtual-size": 10485760, + "filename": "/tmp/pull4.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911522", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.qcow2", + "backing-filename": "/tmp/pull4.qcow2", + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911527", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 217088, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "c", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "b", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.1575911522", + "backing-filename": "/tmp/pull4.1575911522", + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911540", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 212992, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "d", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "c", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.1575911527", + "backing-filename": "/tmp/pull4.1575911527", + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911550", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 212992, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "in-use", + "auto" + ], + "name": "current", + "granularity": 65536 + }, + { + "flags": [ + "in-use" + ], + "name": "d", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.1575911540", + "backing-filename": "/tmp/pull4.1575911540", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-1-format", + "backing_file_depth": 4, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "/tmp/pull4.1575911540", + "dirty-bitmaps": [ + { + "name": "d", + "recording": false, + "persistent": true, + "busy": false, + "status": "disabled", + "granularity": 65536, + "count": 0 + }, + { + "name": "current", + "recording": true, + "persistent": true, + "busy": false, + "status": "active", + "granularity": 65536, + "count": 0 + } + ], + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911550", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 393728, + "filename": "/tmp/pull4.1575911550", + "format": "file", + "actual-size": 212992, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-1-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911550", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "backing-image": { + "backing-image": { + "virtual-size": 10485760, + "filename": "/tmp/pull4.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911522", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.qcow2", + "backing-filename": "/tmp/pull4.qcow2", + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911527", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 217088, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "c", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "b", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.1575911522", + "backing-filename": "/tmp/pull4.1575911522", + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911540", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 212992, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "d", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "c", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.1575911527", + "backing-filename": "/tmp/pull4.1575911527", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "libvirt-2-format", + "backing_file_depth": 3, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "/tmp/pull4.1575911527", + "dirty-bitmaps": [ + { + "name": "c", + "recording": false, + "persistent": true, + "busy": false, + "status": "disabled", + "granularity": 65536, + "count": 0 + }, + { + "name": "d", + "recording": true, + "persistent": true, + "busy": false, + "status": "active", + "granularity": 65536, + "inconsistent": true, + "count": 0 + } + ], + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911540", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 393728, + "filename": "/tmp/pull4.1575911540", + "format": "file", + "actual-size": 212992, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-2-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911540", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "backing-image": { + "virtual-size": 10485760, + "filename": "/tmp/pull4.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911522", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.qcow2", + "backing-filename": "/tmp/pull4.qcow2", + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911527", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 217088, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "c", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "b", + "granularity": 65536 + }, + { + "flags": [ + + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.1575911522", + "backing-filename": "/tmp/pull4.1575911522", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "libvirt-3-format", + "backing_file_depth": 2, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "/tmp/pull4.1575911522", + "dirty-bitmaps": [ + { + "name": "a", + "recording": false, + "persistent": true, + "busy": false, + "status": "disabled", + "granularity": 65536, + "count": 0 + }, + { + "name": "b", + "recording": true, + "persistent": true, + "busy": false, + "status": "disabled", + "granularity": 65536, + "count": 0 + } + ], + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911527", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 459264, + "filename": "/tmp/pull4.1575911527", + "format": "file", + "actual-size": 217088, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-3-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911527", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "backing-image": { + "virtual-size": 10485760, + "filename": "/tmp/pull4.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "backing-filename-format": "qcow2", + "virtual-size": 10485760, + "filename": "/tmp/pull4.1575911522", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "full-backing-filename": "/tmp/pull4.qcow2", + "backing-filename": "/tmp/pull4.qcow2", + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "libvirt-4-format", + "backing_file_depth": 1, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "backing_file": "/tmp/pull4.qcow2", + "dirty-bitmaps": [ + ], + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911522", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 328192, + "filename": "/tmp/pull4.1575911522", + "format": "file", + "actual-size": 208896, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-4-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.1575911522", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 10485760, + "filename": "/tmp/pull4.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 208896, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "bitmaps": [ + { + "flags": [ + "auto" + ], + "name": "a", + "granularity": 65536 + } + ], + "refcount-bits": 16, + "corrupt": false + } + }, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "libvirt-5-format", + "backing_file_depth": 0, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "dirty-bitmaps": [ + { + "name": "a", + "recording": true, + "persistent": true, + "busy": false, + "status": "active", + "granularity": 65536, + "count": 0 + } + ], + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.qcow2", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 328192, + "filename": "/tmp/pull4.qcow2", + "format": "file", + "actual-size": 208896, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-5-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/pull4.qcow2", + "encryption_key_missing": false + } +] diff --git a/tests/qemublocktestdata/bitmap/snapshots-synthetic-broken.out = b/tests/qemublocktestdata/bitmap/snapshots-synthetic-broken.out new file mode 100644 index 0000000000..022630bd76 --- /dev/null +++ b/tests/qemublocktestdata/bitmap/snapshots-synthetic-broken.out @@ -0,0 +1,12 @@ +libvirt-1-format: + d: record:0 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 + current: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 +libvirt-2-format: + c: record:0 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 + d: record:1 busy:0 persist:1 inconsist:1 gran:65536 dirty:0 +libvirt-3-format: + a: record:0 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 + b: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 +libvirt-4-format: +libvirt-5-format: + a: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481360911610.8068187238466; Fri, 31 Jan 2020 06:36:00 -0800 (PST) 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-354-dCrKjRWROiuaPTVvPvNfLQ-1; Fri, 31 Jan 2020 09:34:07 -0500 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 40E52800D53; Fri, 31 Jan 2020 14:34:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E61E8BE09; Fri, 31 Jan 2020 14:34:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 91DED1803C41; Fri, 31 Jan 2020 14:34:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVtw2019864 for ; Fri, 31 Jan 2020 09:31:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1312289E7A; Fri, 31 Jan 2020 14:31:55 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F5D586C4B; Fri, 31 Jan 2020 14:31:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481359; 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=VeYJj5dnzy0w1X/YxuYqaFTaIB9AxwPtkqiZy7mXG/g=; b=BMszpP8/wTpHT0XpH5H4ftH//zftdRfGMah3FWs9faAnSFCl4+gdn+0Y2wGobWm85fQAjq hEN08M4mMZ7r/H7HHn1VIn1OpWeM1N9xPUINdzCPpK2WT+ySWkOYP/cVdtZHFQP2J4vI4v trZSHW9I+HqlT7GHVSbnox46zU3GVks= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/19] qemu: block: Introduce function to calculate bitmap handling for block-copy Date: Fri, 31 Jan 2020 15:31:21 +0100 Message-Id: <07d10cacfffe10f06c1d6a7ad45b386818847ebc.1580480483.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: dCrKjRWROiuaPTVvPvNfLQ-1 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" Add a function calculating which bitmaps to copy to the mirror during a block-copy operation. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 138 ++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_block.h | 7 +++ 2 files changed, 145 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index b19290e677..63116ef5f2 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2728,3 +2728,141 @@ qemuBlockBitmapChainIsValid(virStorageSourcePtr src, return chain_started; } + + +struct qemuBlockBitmapsHandleBlockcopyConcatData { + virHashTablePtr bitmaps_merge; + virJSONValuePtr actions; + const char *mirrornodeformat; + bool has_bitmaps; +}; + + +static int +qemuBlockBitmapsHandleBlockcopyConcatActions(void *payload, + const void *name, + void *opaque) +{ + struct qemuBlockBitmapsHandleBlockcopyConcatData *data =3D opaque; + virJSONValuePtr createactions =3D payload; + const char *bitmapname =3D name; + g_autoptr(virJSONValue) mergebitmaps =3D virHashSteal(data->bitmaps_me= rge, bitmapname); + + data->has_bitmaps =3D true; + + virJSONValueArrayConcat(data->actions, createactions); + + if (qemuMonitorTransactionBitmapMerge(data->actions, + data->mirrornodeformat, + bitmapname, + &mergebitmaps) < 0) + return -1; + + return 0; +} + + +/** + * qemuBlockBitmapsHandleBlockcopy: + * @src: disk source + * @mirror: mirror source + * @blockNamedNodeData: hash table containing data about bitmaps + * @shallow: whether shallow copy is requested + * @actions: filled with arguments for a 'transaction' command + * + * Calculates which bitmaps to copy and merge during a virDomainBlockCopy = job. + * This is designed to be called when the job is already synchronised as it + * may result in active bitmaps being created. + * + * Returns 0 on success and -1 on error. If @actions is NULL when 0 is ret= urned + * there are no actions to perform for the given job. + */ +int +qemuBlockBitmapsHandleBlockcopy(virStorageSourcePtr src, + virStorageSourcePtr mirror, + virHashTablePtr blockNamedNodeData, + bool shallow, + virJSONValuePtr *actions) +{ + g_autoptr(virHashTable) bitmaps =3D virHashNew(virJSONValueHashFree); + g_autoptr(virHashTable) bitmaps_merge =3D virHashNew(virJSONValueHashF= ree); + g_autoptr(virHashTable) bitmaps_skip =3D virHashNew(NULL); + g_autoptr(virJSONValue) tmpactions =3D virJSONValueNewArray(); + qemuBlockNamedNodeDataPtr entry; + virStorageSourcePtr n; + size_t i; + struct qemuBlockBitmapsHandleBlockcopyConcatData data =3D { .bitmaps_m= erge =3D bitmaps_merge, + .actions =3D= tmpactions, + .mirrornodef= ormat =3D mirror->nodeformat, + .has_bitmaps= =3D false, }; + + for (n =3D src; n; n =3D n->backingStore) { + if (!(entry =3D virHashLookup(blockNamedNodeData, n->nodeformat))) + continue; + + for (i =3D 0; i < entry->nbitmaps; i++) { + qemuBlockNamedNodeDataBitmapPtr bitmap =3D entry->bitmaps[i]; + virJSONValuePtr bitmap_merge; + + if (virHashHasEntry(bitmaps_skip, bitmap->name)) + continue; + + if (!(bitmap_merge =3D virHashLookup(bitmaps_merge, bitmap->na= me))) { + g_autoptr(virJSONValue) tmp =3D NULL; + bool disabled =3D !bitmap->recording; + + /* disable any non top-layer bitmaps */ + if (n !=3D src) + disabled =3D true; + + if (!bitmap->persistent || + !(qemuBlockBitmapChainIsValid(n, bitmap->name, + blockNamedNodeData))) { + ignore_value(virHashAddEntry(bitmaps_skip, bitmap->nam= e, NULL)); + continue; + } + + /* prepare the data for adding the bitmap to the mirror */ + tmp =3D virJSONValueNewArray(); + + if (qemuMonitorTransactionBitmapAdd(tmp, + mirror->nodeformat, + bitmap->name, + true, + disabled, + bitmap->granularity) <= 0) + return -1; + + if (virHashAddEntry(bitmaps, bitmap->name, tmp) < 0) + return -1; + + tmp =3D NULL; + + /* prepare array for merging all the bitmaps from the orig= inal chain */ + tmp =3D virJSONValueNewArray(); + + if (virHashAddEntry(bitmaps_merge, bitmap->name, tmp) < 0) + return -1; + + bitmap_merge =3D g_steal_pointer(&tmp); + } + + if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(bitmap_me= rge, + n->nodefo= rmat, + bitmap->n= ame) < 0) + return -1; + } + + if (shallow) + break; + } + + if (virHashForEach(bitmaps, qemuBlockBitmapsHandleBlockcopyConcatActio= ns, + &data) < 0) + return -1; + + if (data.has_bitmaps) + *actions =3D g_steal_pointer(&tmpactions); + + return 0; +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index cf51b9bf4e..a816190bb7 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -217,3 +217,10 @@ bool qemuBlockBitmapChainIsValid(virStorageSourcePtr src, const char *bitmapname, virHashTablePtr blockNamedNodeData); + +int +qemuBlockBitmapsHandleBlockcopy(virStorageSourcePtr src, + virStorageSourcePtr mirror, + virHashTablePtr blockNamedNodeData, + bool shallow, + virJSONValuePtr *actions); --=20 2.24.1 From nobody Wed May 8 20:06: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 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 1580481365264428.52227969906585; Fri, 31 Jan 2020 06:36:05 -0800 (PST) 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-144-i7KVyFjENp6MGnYT2izvGA-1; Fri, 31 Jan 2020 09:34:26 -0500 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 494B5DB68; Fri, 31 Jan 2020 14:34:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F18E10631CC; Fri, 31 Jan 2020 14:34:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B198D18034ED; Fri, 31 Jan 2020 14:34:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVumU019871 for ; Fri, 31 Jan 2020 09:31:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3444587B12; Fri, 31 Jan 2020 14:31:56 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60EC586C4B; Fri, 31 Jan 2020 14:31:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481362; 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=Sj1Dl4u5a+T/yqTgdT877r7RSx/iYds8NL9D0E7Fjd4=; b=H1z3wNC5B6wms0wM1myNU0u+07iN20GWZPgb3aGCLvYDsbc/UPzxNNZPOvceuXugUZdUGd SSFiXfak+ItyAWe43I2dbl3pudhgPK3Bq+zoCSScplFtiVXHtXUYtUzxwpGx8uIwDd6fAL THZ2L8Pir3bcpVDqsJ9bgWNRCIKGYy4= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/19] tests: qemublock: Add tests for qemuBlockBitmapsHandleBlockcopy Date: Fri, 31 Jan 2020 15:31:22 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: i7KVyFjENp6MGnYT2izvGA-1 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" Use some of the existing bitmap data to add tests for qemuBlockBitmapsHandleBlockcopy. As the output depends on the ordering in the hash table we must also install the "virdeterministichash" mock preload library. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 71 +++++++++- .../bitmapblockcopy/basic-deep-out.json | 117 +++++++++++++++ .../bitmapblockcopy/basic-shallow-out.json | 117 +++++++++++++++ .../bitmapblockcopy/snapshots-deep-out.json | 133 ++++++++++++++++++ .../snapshots-shallow-out.json | 48 +++++++ 5 files changed, 485 insertions(+), 1 deletion(-) create mode 100644 tests/qemublocktestdata/bitmapblockcopy/basic-deep-out.= json create mode 100644 tests/qemublocktestdata/bitmapblockcopy/basic-shallow-o= ut.json create mode 100644 tests/qemublocktestdata/bitmapblockcopy/snapshots-deep-= out.json create mode 100644 tests/qemublocktestdata/bitmapblockcopy/snapshots-shall= ow-out.json diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index ada3608e53..06d89b9230 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -803,6 +803,56 @@ testQemuBlockBitmapValidate(const void *opaque) } +static const char *blockcopyPrefix =3D "qemublocktestdata/bitmapblockcopy/= "; + +struct testQemuBlockBitmapBlockcopyData { + const char *name; + bool shallow; + virStorageSourcePtr chain; + const char *nodedatafile; +}; + + +static int +testQemuBlockBitmapBlockcopy(const void *opaque) +{ + const struct testQemuBlockBitmapBlockcopyData *data =3D opaque; + g_autofree char *actual =3D NULL; + g_autofree char *expectpath =3D NULL; + g_autoptr(virJSONValue) actions =3D NULL; + g_autoptr(virJSONValue) nodedatajson =3D NULL; + g_autoptr(virHashTable) nodedata =3D NULL; + g_autoptr(virStorageSource) fakemirror =3D virStorageSourceNew(); + + if (!fakemirror) + return -1; + + fakemirror->nodeformat =3D g_strdup("mirror-format-node"); + + expectpath =3D g_strdup_printf("%s/%s%s-out.json", abs_srcdir, + blockcopyPrefix, data->name); + + if (!(nodedatajson =3D virTestLoadFileJSON(bitmapDetectPrefix, data->n= odedatafile, + ".json", NULL))) + return -1; + + if (!(nodedata =3D qemuMonitorJSONBlockGetNamedNodeDataJSON(nodedatajs= on))) { + VIR_TEST_VERBOSE("failed to load nodedata JSON\n"); + return -1; + } + + if (qemuBlockBitmapsHandleBlockcopy(data->chain, fakemirror, nodedata, + data->shallow, &actions) < 0) + return -1; + + if (actions && + !(actual =3D virJSONValueToString(actions, true))) + return -1; + + return virTestCompareToFile(actual, expectpath); +} + + static int mymain(void) { @@ -814,6 +864,7 @@ mymain(void) struct testQemuBackupIncrementalBitmapCalculateData backupbitmapcalcda= ta; struct testQemuCheckpointDeleteMergeData checkpointdeletedata; struct testQemuBlockBitmapValidateData blockbitmapvalidatedata; + struct testQemuBlockBitmapBlockcopyData blockbitmapblockcopydata; char *capslatest_x86_64 =3D NULL; virQEMUCapsPtr caps_x86_64 =3D NULL; g_autoptr(virStorageSource) bitmapSourceChain =3D NULL; @@ -1124,6 +1175,24 @@ mymain(void) TEST_BITMAP_VALIDATE("snapshots-synthetic-broken", "d", false); TEST_BITMAP_VALIDATE("snapshots-synthetic-broken", "current", true); +#define TEST_BITMAP_BLOCKCOPY(testname, shllw, ndf) \ + do { \ + blockbitmapblockcopydata.name =3D testname; \ + blockbitmapblockcopydata.shallow =3D shllw; \ + blockbitmapblockcopydata.nodedatafile =3D ndf; \ + blockbitmapblockcopydata.chain =3D bitmapSourceChain;\ + if (virTestRun("bitmap block copy " testname, \ + testQemuBlockBitmapBlockcopy, \ + &blockbitmapblockcopydata) < 0) \ + ret =3D -1; \ + } while (0) + + TEST_BITMAP_BLOCKCOPY("basic-shallow", true, "basic"); + TEST_BITMAP_BLOCKCOPY("basic-deep", false, "basic"); + + TEST_BITMAP_BLOCKCOPY("snapshots-shallow", true, "snapshots"); + TEST_BITMAP_BLOCKCOPY("snapshots-deep", false, "snapshots"); + cleanup: virHashFree(diskxmljsondata.schema); qemuTestDriverFree(&driver); @@ -1133,4 +1202,4 @@ mymain(void) return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -VIR_TEST_MAIN(mymain) +VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virdeterministichash")) diff --git a/tests/qemublocktestdata/bitmapblockcopy/basic-deep-out.json b/= tests/qemublocktestdata/bitmapblockcopy/basic-deep-out.json new file mode 100644 index 0000000000..4ed2b97e95 --- /dev/null +++ b/tests/qemublocktestdata/bitmapblockcopy/basic-deep-out.json @@ -0,0 +1,117 @@ +[ + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "a", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "a", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "a" + } + ] + } + }, + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "b", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "b", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "b" + } + ] + } + }, + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "current", + "persistent": true, + "disabled": false, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "current", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "current" + } + ] + } + }, + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "c", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "c", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "c" + } + ] + } + }, + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "d", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "d", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "d" + } + ] + } + } +] diff --git a/tests/qemublocktestdata/bitmapblockcopy/basic-shallow-out.json= b/tests/qemublocktestdata/bitmapblockcopy/basic-shallow-out.json new file mode 100644 index 0000000000..4ed2b97e95 --- /dev/null +++ b/tests/qemublocktestdata/bitmapblockcopy/basic-shallow-out.json @@ -0,0 +1,117 @@ +[ + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "a", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "a", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "a" + } + ] + } + }, + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "b", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "b", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "b" + } + ] + } + }, + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "current", + "persistent": true, + "disabled": false, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "current", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "current" + } + ] + } + }, + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "c", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "c", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "c" + } + ] + } + }, + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "d", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "d", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "d" + } + ] + } + } +] diff --git a/tests/qemublocktestdata/bitmapblockcopy/snapshots-deep-out.jso= n b/tests/qemublocktestdata/bitmapblockcopy/snapshots-deep-out.json new file mode 100644 index 0000000000..5456553d78 --- /dev/null +++ b/tests/qemublocktestdata/bitmapblockcopy/snapshots-deep-out.json @@ -0,0 +1,133 @@ +[ + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "a", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "a", + "bitmaps": [ + { + "node": "libvirt-3-format", + "name": "a" + }, + { + "node": "libvirt-4-format", + "name": "a" + }, + { + "node": "libvirt-5-format", + "name": "a" + } + ] + } + }, + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "b", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "b", + "bitmaps": [ + { + "node": "libvirt-3-format", + "name": "b" + } + ] + } + }, + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "current", + "persistent": true, + "disabled": false, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "current", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "current" + } + ] + } + }, + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "c", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "c", + "bitmaps": [ + { + "node": "libvirt-2-format", + "name": "c" + }, + { + "node": "libvirt-3-format", + "name": "c" + } + ] + } + }, + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "d", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "d", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "d" + }, + { + "node": "libvirt-2-format", + "name": "d" + } + ] + } + } +] diff --git a/tests/qemublocktestdata/bitmapblockcopy/snapshots-shallow-out.= json b/tests/qemublocktestdata/bitmapblockcopy/snapshots-shallow-out.json new file mode 100644 index 0000000000..ddd47f7ee1 --- /dev/null +++ b/tests/qemublocktestdata/bitmapblockcopy/snapshots-shallow-out.json @@ -0,0 +1,48 @@ +[ + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "current", + "persistent": true, + "disabled": false, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "current", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "current" + } + ] + } + }, + { + "type": "block-dirty-bitmap-add", + "data": { + "node": "mirror-format-node", + "name": "d", + "persistent": true, + "disabled": true, + "granularity": 65536 + } + }, + { + "type": "block-dirty-bitmap-merge", + "data": { + "node": "mirror-format-node", + "target": "d", + "bitmaps": [ + { + "node": "libvirt-1-format", + "name": "d" + } + ] + } + } +] --=20 2.24.1 From nobody Wed May 8 20:06: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 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 158048130883114.197110469090603; Fri, 31 Jan 2020 06:35:08 -0800 (PST) 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-141-aeUsUrEKM3W5ip5E1Ar6xQ-1; Fri, 31 Jan 2020 09:34:14 -0500 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 933BE190B2A7; Fri, 31 Jan 2020 14:34:06 +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 6568A5DAA4; Fri, 31 Jan 2020 14:34:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E760585CE8; Fri, 31 Jan 2020 14:34:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEVvVW019876 for ; Fri, 31 Jan 2020 09:31:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 54BE389E85; Fri, 31 Jan 2020 14:31:57 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8178B89E7A; Fri, 31 Jan 2020 14:31:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481307; 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=lfAcYh+mp5XkAVo4IJHauJeV/06y8Wq06jMy9QtoxPc=; b=U6+MTki31Yf3nzWM6ztEAHqfd7QTFAayJ83P7cDGVqVkWuFfvydGsSBkRPEI4/XW9xNrXl Ebe/YL78O6WLo4gbYPnbp2SbDXUihnDukuWfyHW7+8jeuhqnRRTLFPDrLXwYZMgF7JSNPR lX/Z/uOmO7t9lCMBkDwOskvDzrYLXyI= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/19] qemuDomainBlockPivot: Copy bitmaps backing checkpoints for virDomainBlockCopy Date: Fri, 31 Jan 2020 15:31:23 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: aeUsUrEKM3W5ip5E1Ar6xQ-1 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" Use qemuBlockBitmapsHandleBlockcopy to calculate bitmaps to copy over for a block-copy job. We copy them when pivoting to the new image as at that point we are certain that we don't dirty any bitmap unnecessarily. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a2481232ad..7df3f53183 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17572,6 +17572,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, int ret =3D -1; qemuDomainObjPrivatePtr priv =3D vm->privateData; bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); + g_autoptr(virJSONValue) actions =3D NULL; switch ((qemuBlockJobType) job->type) { case QEMU_BLOCKJOB_TYPE_NONE: @@ -17592,6 +17593,20 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, return -1; case QEMU_BLOCKJOB_TYPE_COPY: + if (blockdev && !job->jobflagsmissing) { + g_autoptr(virHashTable) blockNamedNodeData =3D NULL; + bool shallow =3D job->jobflags & VIR_DOMAIN_BLOCK_COPY_SHALLOW; + + if (!(blockNamedNodeData =3D qemuBlockGetNamedNodeData(vm, QEM= U_ASYNC_JOB_NONE))) + return -1; + + if (qemuBlockBitmapsHandleBlockcopy(disk->src, disk->mirror, + blockNamedNodeData, + shallow, &actions) < 0) + return -1; + } + break; + case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT: break; } @@ -17604,10 +17619,17 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, } qemuDomainObjEnterMonitor(driver, vm); - if (blockdev) - ret =3D qemuMonitorJobComplete(priv->mon, job->name); - else + if (blockdev) { + int rc =3D 0; + + if (actions) + rc =3D qemuMonitorTransaction(priv->mon, &actions); + + if (rc =3D=3D 0) + ret =3D qemuMonitorJobComplete(priv->mon, job->name); + } else { ret =3D qemuMonitorDrivePivot(priv->mon, job->name); + } if (qemuDomainObjExitMonitor(driver, vm) < 0) return -1; --=20 2.24.1