Skip to contentSkip to conversation

Fix: remove bogus QDECREF()

PATCH New Benoît Canet 3 participants 4 messages Feb 13, 2014 – Feb 14, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix: remove bogus QDECREF()

This extra QDECREF() was causing quorum_close() to crash while doing bdrv_unref().

As the optional options qdict should belong to the block layer so do not use QDECREF() on it.

I tested the following inti and qemu exit sequences.

tested regular snapshots on device=virtio0 ok tested command line quorum ok
tested command line quorum + snapshot transaction ok tested quorum open by reference ok
tested quorum open by reference + snapshot transaction ok tested quorum open at once ok
tested quorum open at once + snapshot transaction ok

Benoît Canet (1):
blockdev: Fix wrong usage of QDECREF causing snapshoted quorum to
crash on close.

 blockdev.c | 2 --
 1 file changed, 2 deletions(-)
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 1/1 blockdev: Fix wrong usage of QDECREF causing snapshoted quorum to crash on close.

As bdrv_open() documentation states:
"The reference to the QDict belongs to the block layer
* after the call (even on failure), so if the caller intends to reuse the
* dictionary, it needs to use QINCREF() before calling bdrv_open."

the optional options dict will not be reused after bdrv_open() and should belong to the block layer so remove the extra QDECREF(options).

---
 blockdev.c | 2 --
 1 file changed, 2 deletions(-)
blockdev.c +0 -2
index 5cd50f3..7fbce6c 100644
@@ -1316,8 +1316,6 @@ static void external_snapshot_prepare(BlkTransactionState *common,
     if (ret != 0) {
         error_propagate(errp, local_err);
     }
-
-    QDECREF(options);
 }
 
 static void external_snapshot_commit(BlkTransactionState *common)
Signature · 1 line
1.8.3.2
Reviewed-by on v1 1/1
#2 lore raw

Re: [Qemu-devel] [PATCH] blockdev: Fix wrong usage of QDECREF causing snapshoted quorum to crash on close.

Am 13.02.2014 um 17:22 hat Benoît Canet geschrieben:

Quoted 9 lines

As bdrv_open() documentation states:
"The reference to the QDict belongs to the block layer
* after the call (even on failure), so if the caller intends to reuse the
* dictionary, it needs to use QINCREF() before calling bdrv_open."

the optional options dict will not be reused after bdrv_open() and should belong to the block layer so remove the extra QDECREF(options).

Ouch, yes. Sorry for not catching this in the review.

#3 lore raw

Re: [Qemu-devel] [PATCH] blockdev: Fix wrong usage of QDECREF causing snapshoted quorum to crash on close.

In reply to Benoît Canet
Quoted 5 lines · Benoît Canet

As bdrv_open() documentation states:
"The reference to the QDict belongs to the block layer
* after the call (even on failure), so if the caller intends to reuse the
* dictionary, it needs to use QINCREF() before calling bdrv_open."

Quoted 7 lines

the optional options dict will not be reused after bdrv_open() and should belong to the block layer so remove the extra QDECREF(options).

---
 blockdev.c | 2 --
 1 file changed, 2 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan