Blame SOURCES/kvm-tests-qemu-iotests-add-bitmap-resize-test-246.patch

7711c0
From 47d5d00fbef6568ecbf0cc6367c8629d75c275af Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Wed, 3 Apr 2019 22:42:52 +0200
7711c0
Subject: [PATCH 157/163] tests/qemu-iotests: add bitmap resize test 246
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190403224253.5251-5-jsnow@redhat.com>
7711c0
Patchwork-id: 85436
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 4/5] tests/qemu-iotests: add bitmap resize test 246
7711c0
Bugzilla: 1666884
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
7711c0
7711c0
Test that we can actually resize qcow2 images with persistent bitmaps
7711c0
correctly. Throw some other goofy stuff at the test while we're at it,
7711c0
like adding bitmaps of different granularities and at different times.
7711c0
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
Tested-by: Eric Blake <eblake@redhat.com>
7711c0
Message-id: 20190311185147.52309-5-vsementsov@virtuozzo.com
7711c0
   [vsmentsov: drop \n from the end of test output,
7711c0
      test output changed a bit: some bitmaps goes in other order
7711c0
      int the output]
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
(cherry picked from commit e2ec4119dc57e9d65e419b2e9071d35300aa1d92)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 tests/qemu-iotests/246     | 114 ++++++++++++++++++
7711c0
 tests/qemu-iotests/246.out | 295 +++++++++++++++++++++++++++++++++++++++++++++
7711c0
 tests/qemu-iotests/group   |   1 +
7711c0
 3 files changed, 410 insertions(+)
7711c0
 create mode 100755 tests/qemu-iotests/246
7711c0
 create mode 100644 tests/qemu-iotests/246.out
7711c0
7711c0
diff --git a/tests/qemu-iotests/246 b/tests/qemu-iotests/246
7711c0
new file mode 100755
7711c0
index 0000000..b0997a3
7711c0
--- /dev/null
7711c0
+++ b/tests/qemu-iotests/246
7711c0
@@ -0,0 +1,114 @@
7711c0
+#!/usr/bin/env python
7711c0
+#
7711c0
+# Test persistent bitmap resizing.
7711c0
+#
7711c0
+# Copyright (c) 2019 John Snow for Red Hat, Inc.
7711c0
+#
7711c0
+# This program is free software; you can redistribute it and/or modify
7711c0
+# it under the terms of the GNU General Public License as published by
7711c0
+# the Free Software Foundation; either version 2 of the License, or
7711c0
+# (at your option) any later version.
7711c0
+#
7711c0
+# This program is distributed in the hope that it will be useful,
7711c0
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
7711c0
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7711c0
+# GNU General Public License for more details.
7711c0
+#
7711c0
+# You should have received a copy of the GNU General Public License
7711c0
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
7711c0
+#
7711c0
+# owner=jsnow@redhat.com
7711c0
+
7711c0
+import iotests
7711c0
+from iotests import log
7711c0
+
7711c0
+iotests.verify_image_format(supported_fmts=['qcow2'])
7711c0
+size = 64 * 1024 * 1024 * 1024
7711c0
+gran_small = 32 * 1024
7711c0
+gran_large = 128 * 1024
7711c0
+
7711c0
+def query_bitmaps(vm):
7711c0
+    res = vm.qmp("query-block")
7711c0
+    return { "bitmaps": { device['device']: device.get('dirty-bitmaps', []) for
7711c0
+                          device in res['return'] } }
7711c0
+
7711c0
+with iotests.FilePath('img') as img_path, \
7711c0
+     iotests.VM() as vm:
7711c0
+
7711c0
+    log('--- Preparing image & VM ---\n')
7711c0
+    iotests.qemu_img_create('-f', iotests.imgfmt, img_path, str(size))
7711c0
+    vm.add_drive(img_path)
7711c0
+
7711c0
+
7711c0
+    log('--- 1st Boot (Establish Baseline Image) ---\n')
7711c0
+    vm.launch()
7711c0
+
7711c0
+    log('\n--- Adding bitmaps Small, Medium, Large, and Transient ---\n')
7711c0
+    vm.qmp_log("block-dirty-bitmap-add", node="drive0",
7711c0
+               name="Small", granularity=gran_small, persistent=True)
7711c0
+    vm.qmp_log("block-dirty-bitmap-add", node="drive0",
7711c0
+               name="Medium", persistent=True)
7711c0
+    vm.qmp_log("block-dirty-bitmap-add", node="drive0",
7711c0
+               name="Large", granularity=gran_large, persistent=True)
7711c0
+    vm.qmp_log("block-dirty-bitmap-add", node="drive0",
7711c0
+               name="Transient", persistent=False)
7711c0
+
7711c0
+    log('--- Forcing flush of bitmaps to disk ---\n')
7711c0
+    log(query_bitmaps(vm), indent=2)
7711c0
+    vm.shutdown()
7711c0
+
7711c0
+
7711c0
+    log('--- 2nd Boot (Grow Image) ---\n')
7711c0
+    vm.launch()
7711c0
+    log(query_bitmaps(vm), indent=2)
7711c0
+
7711c0
+    log('--- Adding new bitmap, growing image, and adding 2nd new bitmap ---')
7711c0
+    vm.qmp_log("block-dirty-bitmap-add", node="drive0",
7711c0
+               name="New", persistent=True)
7711c0
+    vm.qmp_log("human-monitor-command",
7711c0
+               command_line="block_resize drive0 70G")
7711c0
+    vm.qmp_log("block-dirty-bitmap-add", node="drive0",
7711c0
+               name="Newtwo", persistent=True)
7711c0
+    log(query_bitmaps(vm), indent=2)
7711c0
+
7711c0
+    log('--- Forcing flush of bitmaps to disk ---\n')
7711c0
+    vm.shutdown()
7711c0
+
7711c0
+
7711c0
+    log('--- 3rd Boot (Shrink Image) ---\n')
7711c0
+    vm.launch()
7711c0
+    log(query_bitmaps(vm), indent=2)
7711c0
+
7711c0
+    log('--- Adding "NewB" bitmap, removing "New" bitmap ---')
7711c0
+    vm.qmp_log("block-dirty-bitmap-add", node="drive0",
7711c0
+               name="NewB", persistent=True)
7711c0
+    vm.qmp_log("block-dirty-bitmap-remove", node="drive0",
7711c0
+               name="New")
7711c0
+
7711c0
+    log('--- Truncating image ---\n')
7711c0
+    vm.qmp_log("human-monitor-command",
7711c0
+               command_line="block_resize drive0 50G")
7711c0
+
7711c0
+    log('--- Adding "NewC" bitmap, removing "NewTwo" bitmap ---')
7711c0
+    vm.qmp_log("block-dirty-bitmap-add", node="drive0",
7711c0
+               name="NewC", persistent=True)
7711c0
+    vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="Newtwo")
7711c0
+
7711c0
+    log('--- Forcing flush of bitmaps to disk ---\n')
7711c0
+    vm.shutdown()
7711c0
+
7711c0
+
7711c0
+    log('--- 4th Boot (Verification and Cleanup) ---\n')
7711c0
+    vm.launch()
7711c0
+    log(query_bitmaps(vm), indent=2)
7711c0
+
7711c0
+    log('--- Removing all Bitmaps ---\n')
7711c0
+    vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="Small")
7711c0
+    vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="Medium")
7711c0
+    vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="Large")
7711c0
+    vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="NewB")
7711c0
+    vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="NewC")
7711c0
+    log(query_bitmaps(vm), indent=2)
7711c0
+
7711c0
+    log('\n--- Done ---')
7711c0
+    vm.shutdown()
7711c0
diff --git a/tests/qemu-iotests/246.out b/tests/qemu-iotests/246.out
7711c0
new file mode 100644
7711c0
index 0000000..b991945
7711c0
--- /dev/null
7711c0
+++ b/tests/qemu-iotests/246.out
7711c0
@@ -0,0 +1,295 @@
7711c0
+--- Preparing image & VM ---
7711c0
+
7711c0
+--- 1st Boot (Establish Baseline Image) ---
7711c0
+
7711c0
+
7711c0
+--- Adding bitmaps Small, Medium, Large, and Transient ---
7711c0
+
7711c0
+{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 32768, "name": "Small", "node": "drive0", "persistent": true}}
7711c0
+{"return": {}}
7711c0
+{"execute": "block-dirty-bitmap-add", "arguments": {"name": "Medium", "node": "drive0", "persistent": true}}
7711c0
+{"return": {}}
7711c0
+{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 131072, "name": "Large", "node": "drive0", "persistent": true}}
7711c0
+{"return": {}}
7711c0
+{"execute": "block-dirty-bitmap-add", "arguments": {"name": "Transient", "node": "drive0", "persistent": false}}
7711c0
+{"return": {}}
7711c0
+--- Forcing flush of bitmaps to disk ---
7711c0
+
7711c0
+{
7711c0
+  "bitmaps": {
7711c0
+    "drive0": [
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 65536,
7711c0
+        "name": "Transient",
7711c0
+        "persistent": false,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 131072,
7711c0
+        "name": "Large",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 65536,
7711c0
+        "name": "Medium",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 32768,
7711c0
+        "name": "Small",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      }
7711c0
+    ]
7711c0
+  }
7711c0
+}
7711c0
+--- 2nd Boot (Grow Image) ---
7711c0
+
7711c0
+{
7711c0
+  "bitmaps": {
7711c0
+    "drive0": [
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 32768,
7711c0
+        "name": "Small",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 65536,
7711c0
+        "name": "Medium",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 131072,
7711c0
+        "name": "Large",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      }
7711c0
+    ]
7711c0
+  }
7711c0
+}
7711c0
+--- Adding new bitmap, growing image, and adding 2nd new bitmap ---
7711c0
+{"execute": "block-dirty-bitmap-add", "arguments": {"name": "New", "node": "drive0", "persistent": true}}
7711c0
+{"return": {}}
7711c0
+{"execute": "human-monitor-command", "arguments": {"command_line": "block_resize drive0 70G"}}
7711c0
+{"return": ""}
7711c0
+{"execute": "block-dirty-bitmap-add", "arguments": {"name": "Newtwo", "node": "drive0", "persistent": true}}
7711c0
+{"return": {}}
7711c0
+{
7711c0
+  "bitmaps": {
7711c0
+    "drive0": [
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 65536,
7711c0
+        "name": "Newtwo",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 65536,
7711c0
+        "name": "New",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 32768,
7711c0
+        "name": "Small",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 65536,
7711c0
+        "name": "Medium",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 131072,
7711c0
+        "name": "Large",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      }
7711c0
+    ]
7711c0
+  }
7711c0
+}
7711c0
+--- Forcing flush of bitmaps to disk ---
7711c0
+
7711c0
+--- 3rd Boot (Shrink Image) ---
7711c0
+
7711c0
+{
7711c0
+  "bitmaps": {
7711c0
+    "drive0": [
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 65536,
7711c0
+        "name": "New",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 65536,
7711c0
+        "name": "Newtwo",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 32768,
7711c0
+        "name": "Small",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 65536,
7711c0
+        "name": "Medium",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 131072,
7711c0
+        "name": "Large",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      }
7711c0
+    ]
7711c0
+  }
7711c0
+}
7711c0
+--- Adding "NewB" bitmap, removing "New" bitmap ---
7711c0
+{"execute": "block-dirty-bitmap-add", "arguments": {"name": "NewB", "node": "drive0", "persistent": true}}
7711c0
+{"return": {}}
7711c0
+{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "New", "node": "drive0"}}
7711c0
+{"return": {}}
7711c0
+--- Truncating image ---
7711c0
+
7711c0
+{"execute": "human-monitor-command", "arguments": {"command_line": "block_resize drive0 50G"}}
7711c0
+{"return": ""}
7711c0
+--- Adding "NewC" bitmap, removing "NewTwo" bitmap ---
7711c0
+{"execute": "block-dirty-bitmap-add", "arguments": {"name": "NewC", "node": "drive0", "persistent": true}}
7711c0
+{"return": {}}
7711c0
+{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "Newtwo", "node": "drive0"}}
7711c0
+{"return": {}}
7711c0
+--- Forcing flush of bitmaps to disk ---
7711c0
+
7711c0
+--- 4th Boot (Verification and Cleanup) ---
7711c0
+
7711c0
+{
7711c0
+  "bitmaps": {
7711c0
+    "drive0": [
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 65536,
7711c0
+        "name": "NewB",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 65536,
7711c0
+        "name": "NewC",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 32768,
7711c0
+        "name": "Small",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 65536,
7711c0
+        "name": "Medium",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      },
7711c0
+      {
7711c0
+        "busy": false,
7711c0
+        "count": 0,
7711c0
+        "granularity": 131072,
7711c0
+        "name": "Large",
7711c0
+        "persistent": true,
7711c0
+        "recording": true,
7711c0
+        "status": "active"
7711c0
+      }
7711c0
+    ]
7711c0
+  }
7711c0
+}
7711c0
+--- Removing all Bitmaps ---
7711c0
+
7711c0
+{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "Small", "node": "drive0"}}
7711c0
+{"return": {}}
7711c0
+{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "Medium", "node": "drive0"}}
7711c0
+{"return": {}}
7711c0
+{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "Large", "node": "drive0"}}
7711c0
+{"return": {}}
7711c0
+{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "NewB", "node": "drive0"}}
7711c0
+{"return": {}}
7711c0
+{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "NewC", "node": "drive0"}}
7711c0
+{"return": {}}
7711c0
+{
7711c0
+  "bitmaps": {
7711c0
+    "drive0": []
7711c0
+  }
7711c0
+}
7711c0
+
7711c0
+--- Done ---
7711c0
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
7711c0
index b3aeb6b..7da1334 100644
7711c0
--- a/tests/qemu-iotests/group
7711c0
+++ b/tests/qemu-iotests/group
7711c0
@@ -230,3 +230,4 @@
7711c0
 234 auto quick migration
7711c0
 236 auto quick
7711c0
 242 rw auto quick
7711c0
+246 rw auto quick
7711c0
-- 
7711c0
1.8.3.1
7711c0