|
|
46c39e |
From f2b896fa48272c26445e17b59a365fcaea808e0e Mon Sep 17 00:00:00 2001
|
|
|
46c39e |
From: Max Reitz <mreitz@redhat.com>
|
|
|
46c39e |
Date: Fri, 29 Nov 2013 21:41:29 +0100
|
|
|
46c39e |
Subject: [PATCH] block: Close backing file early in bdrv_img_create
|
|
|
46c39e |
|
|
|
46c39e |
Leaving the backing file open although it is not needed anymore can
|
|
|
46c39e |
cause problems if it is opened through a block driver which allows
|
|
|
46c39e |
exclusive access only and if the create function of the block driver
|
|
|
46c39e |
used for the top image (the one being created) tries to close and reopen
|
|
|
46c39e |
the image file (which will include opening the backing file a second
|
|
|
46c39e |
time).
|
|
|
46c39e |
|
|
|
46c39e |
In particular, this will happen with a backing file opened through
|
|
|
46c39e |
qemu-nbd and using qcow2 as the top image file format (which reopens the
|
|
|
46c39e |
image to flush it to disk).
|
|
|
46c39e |
|
|
|
46c39e |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
46c39e |
---
|
|
|
46c39e |
block.c | 3 +++
|
|
|
46c39e |
1 file changed, 3 insertions(+)
|
|
|
46c39e |
|
|
|
46c39e |
diff --git a/block.c b/block.c
|
|
|
46c39e |
index 382ea71..6d571ad 100644
|
|
|
46c39e |
--- a/block.c
|
|
|
46c39e |
+++ b/block.c
|
|
|
46c39e |
@@ -4608,6 +4608,9 @@ void bdrv_img_create(const char *filename, const char *fmt,
|
|
|
46c39e |
|
|
|
46c39e |
snprintf(buf, sizeof(buf), "%" PRId64, size);
|
|
|
46c39e |
set_option_parameter(param, BLOCK_OPT_SIZE, buf);
|
|
|
46c39e |
+
|
|
|
46c39e |
+ bdrv_unref(bs);
|
|
|
46c39e |
+ bs = NULL;
|
|
|
46c39e |
} else {
|
|
|
46c39e |
error_setg(errp, "Image creation needs a size parameter");
|
|
|
46c39e |
goto out;
|