qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

tests/qemu-iotests: add bitmap resize test 246

Test that we can actually resize qcow2 images with persistent bitmaps
correctly. Throw some other goofy stuff at the test while we're at it,
like adding bitmaps of different granularities and at different times.

Signed-off-by: John Snow <jsnow@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Tested-by: Eric Blake <eblake@redhat.com>
Message-id: 20190311185147.52309-5-vsementsov@virtuozzo.com
[vsmentsov: drop \n from the end of test output,
test output changed a bit: some bitmaps goes in other order
int the output]
Signed-off-by: John Snow <jsnow@redhat.com>

+410
+114
tests/qemu-iotests/246
··· 1 + #!/usr/bin/env python 2 + # 3 + # Test persistent bitmap resizing. 4 + # 5 + # Copyright (c) 2019 John Snow for Red Hat, Inc. 6 + # 7 + # This program is free software; you can redistribute it and/or modify 8 + # it under the terms of the GNU General Public License as published by 9 + # the Free Software Foundation; either version 2 of the License, or 10 + # (at your option) any later version. 11 + # 12 + # This program is distributed in the hope that it will be useful, 13 + # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + # GNU General Public License for more details. 16 + # 17 + # You should have received a copy of the GNU General Public License 18 + # along with this program. If not, see <http://www.gnu.org/licenses/>. 19 + # 20 + # owner=jsnow@redhat.com 21 + 22 + import iotests 23 + from iotests import log 24 + 25 + iotests.verify_image_format(supported_fmts=['qcow2']) 26 + size = 64 * 1024 * 1024 * 1024 27 + gran_small = 32 * 1024 28 + gran_large = 128 * 1024 29 + 30 + def query_bitmaps(vm): 31 + res = vm.qmp("query-block") 32 + return { "bitmaps": { device['device']: device.get('dirty-bitmaps', []) for 33 + device in res['return'] } } 34 + 35 + with iotests.FilePath('img') as img_path, \ 36 + iotests.VM() as vm: 37 + 38 + log('--- Preparing image & VM ---\n') 39 + iotests.qemu_img_create('-f', iotests.imgfmt, img_path, str(size)) 40 + vm.add_drive(img_path) 41 + 42 + 43 + log('--- 1st Boot (Establish Baseline Image) ---\n') 44 + vm.launch() 45 + 46 + log('\n--- Adding bitmaps Small, Medium, Large, and Transient ---\n') 47 + vm.qmp_log("block-dirty-bitmap-add", node="drive0", 48 + name="Small", granularity=gran_small, persistent=True) 49 + vm.qmp_log("block-dirty-bitmap-add", node="drive0", 50 + name="Medium", persistent=True) 51 + vm.qmp_log("block-dirty-bitmap-add", node="drive0", 52 + name="Large", granularity=gran_large, persistent=True) 53 + vm.qmp_log("block-dirty-bitmap-add", node="drive0", 54 + name="Transient", persistent=False) 55 + 56 + log('--- Forcing flush of bitmaps to disk ---\n') 57 + log(query_bitmaps(vm), indent=2) 58 + vm.shutdown() 59 + 60 + 61 + log('--- 2nd Boot (Grow Image) ---\n') 62 + vm.launch() 63 + log(query_bitmaps(vm), indent=2) 64 + 65 + log('--- Adding new bitmap, growing image, and adding 2nd new bitmap ---') 66 + vm.qmp_log("block-dirty-bitmap-add", node="drive0", 67 + name="New", persistent=True) 68 + vm.qmp_log("human-monitor-command", 69 + command_line="block_resize drive0 70G") 70 + vm.qmp_log("block-dirty-bitmap-add", node="drive0", 71 + name="Newtwo", persistent=True) 72 + log(query_bitmaps(vm), indent=2) 73 + 74 + log('--- Forcing flush of bitmaps to disk ---\n') 75 + vm.shutdown() 76 + 77 + 78 + log('--- 3rd Boot (Shrink Image) ---\n') 79 + vm.launch() 80 + log(query_bitmaps(vm), indent=2) 81 + 82 + log('--- Adding "NewB" bitmap, removing "New" bitmap ---') 83 + vm.qmp_log("block-dirty-bitmap-add", node="drive0", 84 + name="NewB", persistent=True) 85 + vm.qmp_log("block-dirty-bitmap-remove", node="drive0", 86 + name="New") 87 + 88 + log('--- Truncating image ---\n') 89 + vm.qmp_log("human-monitor-command", 90 + command_line="block_resize drive0 50G") 91 + 92 + log('--- Adding "NewC" bitmap, removing "NewTwo" bitmap ---') 93 + vm.qmp_log("block-dirty-bitmap-add", node="drive0", 94 + name="NewC", persistent=True) 95 + vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="Newtwo") 96 + 97 + log('--- Forcing flush of bitmaps to disk ---\n') 98 + vm.shutdown() 99 + 100 + 101 + log('--- 4th Boot (Verification and Cleanup) ---\n') 102 + vm.launch() 103 + log(query_bitmaps(vm), indent=2) 104 + 105 + log('--- Removing all Bitmaps ---\n') 106 + vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="Small") 107 + vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="Medium") 108 + vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="Large") 109 + vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="NewB") 110 + vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="NewC") 111 + log(query_bitmaps(vm), indent=2) 112 + 113 + log('\n--- Done ---') 114 + vm.shutdown()
+295
tests/qemu-iotests/246.out
··· 1 + --- Preparing image & VM --- 2 + 3 + --- 1st Boot (Establish Baseline Image) --- 4 + 5 + 6 + --- Adding bitmaps Small, Medium, Large, and Transient --- 7 + 8 + {"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 32768, "name": "Small", "node": "drive0", "persistent": true}} 9 + {"return": {}} 10 + {"execute": "block-dirty-bitmap-add", "arguments": {"name": "Medium", "node": "drive0", "persistent": true}} 11 + {"return": {}} 12 + {"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 131072, "name": "Large", "node": "drive0", "persistent": true}} 13 + {"return": {}} 14 + {"execute": "block-dirty-bitmap-add", "arguments": {"name": "Transient", "node": "drive0", "persistent": false}} 15 + {"return": {}} 16 + --- Forcing flush of bitmaps to disk --- 17 + 18 + { 19 + "bitmaps": { 20 + "drive0": [ 21 + { 22 + "busy": false, 23 + "count": 0, 24 + "granularity": 65536, 25 + "name": "Transient", 26 + "persistent": false, 27 + "recording": true, 28 + "status": "active" 29 + }, 30 + { 31 + "busy": false, 32 + "count": 0, 33 + "granularity": 131072, 34 + "name": "Large", 35 + "persistent": true, 36 + "recording": true, 37 + "status": "active" 38 + }, 39 + { 40 + "busy": false, 41 + "count": 0, 42 + "granularity": 65536, 43 + "name": "Medium", 44 + "persistent": true, 45 + "recording": true, 46 + "status": "active" 47 + }, 48 + { 49 + "busy": false, 50 + "count": 0, 51 + "granularity": 32768, 52 + "name": "Small", 53 + "persistent": true, 54 + "recording": true, 55 + "status": "active" 56 + } 57 + ] 58 + } 59 + } 60 + --- 2nd Boot (Grow Image) --- 61 + 62 + { 63 + "bitmaps": { 64 + "drive0": [ 65 + { 66 + "busy": false, 67 + "count": 0, 68 + "granularity": 32768, 69 + "name": "Small", 70 + "persistent": true, 71 + "recording": true, 72 + "status": "active" 73 + }, 74 + { 75 + "busy": false, 76 + "count": 0, 77 + "granularity": 65536, 78 + "name": "Medium", 79 + "persistent": true, 80 + "recording": true, 81 + "status": "active" 82 + }, 83 + { 84 + "busy": false, 85 + "count": 0, 86 + "granularity": 131072, 87 + "name": "Large", 88 + "persistent": true, 89 + "recording": true, 90 + "status": "active" 91 + } 92 + ] 93 + } 94 + } 95 + --- Adding new bitmap, growing image, and adding 2nd new bitmap --- 96 + {"execute": "block-dirty-bitmap-add", "arguments": {"name": "New", "node": "drive0", "persistent": true}} 97 + {"return": {}} 98 + {"execute": "human-monitor-command", "arguments": {"command-line": "block_resize drive0 70G"}} 99 + {"return": ""} 100 + {"execute": "block-dirty-bitmap-add", "arguments": {"name": "Newtwo", "node": "drive0", "persistent": true}} 101 + {"return": {}} 102 + { 103 + "bitmaps": { 104 + "drive0": [ 105 + { 106 + "busy": false, 107 + "count": 0, 108 + "granularity": 65536, 109 + "name": "Newtwo", 110 + "persistent": true, 111 + "recording": true, 112 + "status": "active" 113 + }, 114 + { 115 + "busy": false, 116 + "count": 0, 117 + "granularity": 65536, 118 + "name": "New", 119 + "persistent": true, 120 + "recording": true, 121 + "status": "active" 122 + }, 123 + { 124 + "busy": false, 125 + "count": 0, 126 + "granularity": 32768, 127 + "name": "Small", 128 + "persistent": true, 129 + "recording": true, 130 + "status": "active" 131 + }, 132 + { 133 + "busy": false, 134 + "count": 0, 135 + "granularity": 65536, 136 + "name": "Medium", 137 + "persistent": true, 138 + "recording": true, 139 + "status": "active" 140 + }, 141 + { 142 + "busy": false, 143 + "count": 0, 144 + "granularity": 131072, 145 + "name": "Large", 146 + "persistent": true, 147 + "recording": true, 148 + "status": "active" 149 + } 150 + ] 151 + } 152 + } 153 + --- Forcing flush of bitmaps to disk --- 154 + 155 + --- 3rd Boot (Shrink Image) --- 156 + 157 + { 158 + "bitmaps": { 159 + "drive0": [ 160 + { 161 + "busy": false, 162 + "count": 0, 163 + "granularity": 65536, 164 + "name": "New", 165 + "persistent": true, 166 + "recording": true, 167 + "status": "active" 168 + }, 169 + { 170 + "busy": false, 171 + "count": 0, 172 + "granularity": 65536, 173 + "name": "Newtwo", 174 + "persistent": true, 175 + "recording": true, 176 + "status": "active" 177 + }, 178 + { 179 + "busy": false, 180 + "count": 0, 181 + "granularity": 32768, 182 + "name": "Small", 183 + "persistent": true, 184 + "recording": true, 185 + "status": "active" 186 + }, 187 + { 188 + "busy": false, 189 + "count": 0, 190 + "granularity": 65536, 191 + "name": "Medium", 192 + "persistent": true, 193 + "recording": true, 194 + "status": "active" 195 + }, 196 + { 197 + "busy": false, 198 + "count": 0, 199 + "granularity": 131072, 200 + "name": "Large", 201 + "persistent": true, 202 + "recording": true, 203 + "status": "active" 204 + } 205 + ] 206 + } 207 + } 208 + --- Adding "NewB" bitmap, removing "New" bitmap --- 209 + {"execute": "block-dirty-bitmap-add", "arguments": {"name": "NewB", "node": "drive0", "persistent": true}} 210 + {"return": {}} 211 + {"execute": "block-dirty-bitmap-remove", "arguments": {"name": "New", "node": "drive0"}} 212 + {"return": {}} 213 + --- Truncating image --- 214 + 215 + {"execute": "human-monitor-command", "arguments": {"command-line": "block_resize drive0 50G"}} 216 + {"return": ""} 217 + --- Adding "NewC" bitmap, removing "NewTwo" bitmap --- 218 + {"execute": "block-dirty-bitmap-add", "arguments": {"name": "NewC", "node": "drive0", "persistent": true}} 219 + {"return": {}} 220 + {"execute": "block-dirty-bitmap-remove", "arguments": {"name": "Newtwo", "node": "drive0"}} 221 + {"return": {}} 222 + --- Forcing flush of bitmaps to disk --- 223 + 224 + --- 4th Boot (Verification and Cleanup) --- 225 + 226 + { 227 + "bitmaps": { 228 + "drive0": [ 229 + { 230 + "busy": false, 231 + "count": 0, 232 + "granularity": 65536, 233 + "name": "NewB", 234 + "persistent": true, 235 + "recording": true, 236 + "status": "active" 237 + }, 238 + { 239 + "busy": false, 240 + "count": 0, 241 + "granularity": 65536, 242 + "name": "NewC", 243 + "persistent": true, 244 + "recording": true, 245 + "status": "active" 246 + }, 247 + { 248 + "busy": false, 249 + "count": 0, 250 + "granularity": 32768, 251 + "name": "Small", 252 + "persistent": true, 253 + "recording": true, 254 + "status": "active" 255 + }, 256 + { 257 + "busy": false, 258 + "count": 0, 259 + "granularity": 65536, 260 + "name": "Medium", 261 + "persistent": true, 262 + "recording": true, 263 + "status": "active" 264 + }, 265 + { 266 + "busy": false, 267 + "count": 0, 268 + "granularity": 131072, 269 + "name": "Large", 270 + "persistent": true, 271 + "recording": true, 272 + "status": "active" 273 + } 274 + ] 275 + } 276 + } 277 + --- Removing all Bitmaps --- 278 + 279 + {"execute": "block-dirty-bitmap-remove", "arguments": {"name": "Small", "node": "drive0"}} 280 + {"return": {}} 281 + {"execute": "block-dirty-bitmap-remove", "arguments": {"name": "Medium", "node": "drive0"}} 282 + {"return": {}} 283 + {"execute": "block-dirty-bitmap-remove", "arguments": {"name": "Large", "node": "drive0"}} 284 + {"return": {}} 285 + {"execute": "block-dirty-bitmap-remove", "arguments": {"name": "NewB", "node": "drive0"}} 286 + {"return": {}} 287 + {"execute": "block-dirty-bitmap-remove", "arguments": {"name": "NewC", "node": "drive0"}} 288 + {"return": {}} 289 + { 290 + "bitmaps": { 291 + "drive0": [] 292 + } 293 + } 294 + 295 + --- Done ---
+1
tests/qemu-iotests/group
··· 243 243 242 rw auto quick 244 244 243 rw auto quick 245 245 244 rw auto quick 246 + 246 rw auto quick