Skip to contentSkip to conversation

block/dirty-bitmap: Useless bitmap in image should be removed

Qemu-devel [email protected] 2 participants 2 messages Jun 23, 2018 – Jun 25, 2018

lore
Share & tools
lore
#0 lore raw

If qemu-kvm quit without saving bitmaps in image(coredump or panic on host), bitmaps in image can not be used safely anymore, and can not be removed also. Useless bitmaps should be removed.

---

blockdev.c +21 -17
index 58d7570932..c85056a74b 100644
@@ -2837,31 +2837,35 @@ void qmp_block_dirty_bitmap_remove(const char *node, const char *name,
     Error *local_err = NULL;
 
     bitmap = block_dirty_bitmap_lookup(node, name, &bs, errp);
-    if (!bitmap || !bs) {
+    if (!bs) {
         return;
     }
 
-    if (bdrv_dirty_bitmap_frozen(bitmap)) {
-        error_setg(errp,
-                   "Bitmap '%s' is currently frozen and cannot be removed",
-                   name);
-        return;
-    } else if (bdrv_dirty_bitmap_qmp_locked(bitmap)) {
-        error_setg(errp,
-                   "Bitmap '%s' is currently locked and cannot be removed",
-                   name);
+    if (bitmap){
+        if (bdrv_dirty_bitmap_frozen(bitmap)) {
+            error_setg(errp,
+                       "Bitmap '%s' is currently frozen and cannot be removed",
+                       name);
+            return;
+        } else if (bdrv_dirty_bitmap_qmp_locked(bitmap)) {
+            error_setg(errp,
+                       "Bitmap '%s' is currently locked and cannot be removed",
+                       name);
+            return;
+        }
+    }
+
+    bdrv_remove_persistent_dirty_bitmap(bs, name, &local_err);
+    if (local_err != NULL) {
+        error_propagate(errp, local_err);
         return;
     }
 
-    if (bdrv_dirty_bitmap_get_persistance(bitmap)) {
-        bdrv_remove_persistent_dirty_bitmap(bs, name, &local_err);
-        if (local_err != NULL) {
-            error_propagate(errp, local_err);
-            return;
-        }
+    if (bitmap){
+        bdrv_release_dirty_bitmap(bs, bitmap);
     }
 
-    bdrv_release_dirty_bitmap(bs, bitmap);
+    *errp = NULL;
 }
 
 /**
#1 lore raw
This series seems to have some coding style problems. See output below for more information:

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [Qemu-devel] block/dirty-bitmap: Useless bitmap in image should be removed

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu

   7ed14cbf3c..f28d0dfdce  master     -> master
 t [tag update]            patchew/[email protected] -> patchew/[email protected]
 t [tag update]            patchew/[email protected] -> patchew/[email protected]
 * [new tag]               patchew/[email protected] -> patchew/[email protected]

Switched to a new branch 'test'
a4a2587f86 block/dirty-bitmap: Useless bitmap in image should be removed

=== OUTPUT BEGIN ===
Checking PATCH 1/1: block/dirty-bitmap: Useless bitmap in image should be removed...
ERROR: space required before the open brace '{'
#42: FILE: blockdev.c:2844:
+ if (bitmap){

ERROR: space required before the open brace '{'
#63: FILE: blockdev.c:2864:
+ if (bitmap){

total: 2 errors, 0 warnings, 53 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]