qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 08/21] block: Allow reference for bdrv_file_o


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH v3 08/21] block: Allow reference for bdrv_file_open()
Date: Fri, 13 Dec 2013 16:55:10 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1

On 12.12.2013 09:01, Fam Zheng wrote:
On 2013年12月12日 02:11, Max Reitz wrote:
Allow specifying a reference to an existing block device (by name) for
bdrv_file_open() instead of a filename and/or options.

Signed-off-by: Max Reitz <address@hidden>
---
block.c | 27 ++++++++++++++++++++++++---
block/blkdebug.c | 2 +-
block/blkverify.c | 2 +-
block/cow.c | 3 ++-
block/qcow.c | 3 ++-
block/qcow2.c | 2 +-
block/qed.c | 4 ++--
block/sheepdog.c | 4 ++--
block/vhdx.c | 2 +-
block/vmdk.c | 4 ++--
include/block/block.h | 3 ++-
qemu-io.c | 2 +-
12 files changed, 41 insertions(+), 17 deletions(-)

diff --git a/block.c b/block.c
index 13f001a..9e197b3 100644
--- a/block.c
+++ b/block.c
@@ -858,9 +858,10 @@ free_and_fail:
* dictionary, it needs to use QINCREF() before calling bdrv_file_open.
*/
int bdrv_file_open(BlockDriverState **pbs, const char *filename,
- QDict *options, int flags, Error **errp)
+ const char *reference, QDict *options, int flags,
+ Error **errp)
{
- BlockDriverState *bs;
+ BlockDriverState *bs = NULL;
BlockDriver *drv;
const char *drvname;
bool allow_protocol_prefix = false;
@@ -872,6 +873,26 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename,
options = qdict_new();
}

+ if (reference) {
+ if (filename || qdict_size(options)) {
+ error_setg(errp, "Cannot reference an existing block device with "
+ "additional options or a new filename");
+ ret = -EINVAL;
+ goto fail;
+ }
+ QDECREF(options);

QDECREF called...

+
+ bs = bdrv_find(reference);
+ if (!bs) {
+ error_setg(errp, "Cannot find block device '%s'", reference);
+ ret = -ENODEV;
+ goto fail;

Jump to fail for QDECREF again. Duplicated?

Oh, right, thanks.

Max



reply via email to

[Prev in Thread] Current Thread [Next in Thread]