diff mbox

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

Message ID 20180623172538.1590-1-yaoxu@didichuxing.com (mailing list archive)
State New, archived
Headers show

Commit Message

yaoxu@didichuxing.com June 23, 2018, 5:25 p.m. UTC
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.

Signed-off-by: yaoxu <yaoxu@didichuxing.com>
---

Comments

no-reply@patchew.org June 23, 2018, 10:39 p.m. UTC | #1
Hi,

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

Type: series
Message-id: 20180623172538.1590-1-yaoxu@didichuxing.com
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/1529764569-12848-1-git-send-email-linux@roeck-us.net -> patchew/1529764569-12848-1-git-send-email-linux@roeck-us.net
 t [tag update]            patchew/20180623085028.29553-1-mark.cave-ayland@ilande.co.uk -> patchew/20180623085028.29553-1-mark.cave-ayland@ilande.co.uk
 * [new tag]               patchew/20180623172538.1590-1-yaoxu@didichuxing.com -> patchew/20180623172538.1590-1-yaoxu@didichuxing.com
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 patchew-devel@redhat.com
diff mbox

Patch

diff --git a/blockdev.c b/blockdev.c
index 58d7570932..c85056a74b 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -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;
 }
 
 /**