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

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