From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqoFT-0001Sj-W7 for qemu-devel@nongnu.org; Wed, 11 Dec 2013 13:11:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VqoFN-0002HY-Va for qemu-devel@nongnu.org; Wed, 11 Dec 2013 13:11:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5386) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqoFN-0002HL-Mh for qemu-devel@nongnu.org; Wed, 11 Dec 2013 13:10:57 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBBIAtgL011651 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 11 Dec 2013 13:10:55 -0500 From: Max Reitz Date: Wed, 11 Dec 2013 19:11:03 +0100 Message-Id: <1386785473-26157-12-git-send-email-mreitz@redhat.com> In-Reply-To: <1386785473-26157-1-git-send-email-mreitz@redhat.com> References: <1386785473-26157-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH v3 11/21] block: Allow recursive "file"s List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , Stefan Hajnoczi , Max Reitz It should be possible to use a format as a driver for a file which in turn requires another file, i.e., nesting file formats. Signed-off-by: Max Reitz --- block.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 33ef995..bebf080 100644 --- a/block.c +++ b/block.c @@ -950,14 +950,19 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename, goto fail; } - ret = bdrv_open_common(bs, NULL, options, flags, drv, &local_err); + if (!drv->bdrv_file_open) { + ret = bdrv_open(bs, filename, options, flags, drv, &local_err); + options = NULL; + } else { + ret = bdrv_open_common(bs, NULL, options, flags, drv, &local_err); + } if (ret < 0) { error_propagate(errp, local_err); goto fail; } /* Check if any unknown options were used */ - if (qdict_size(options) != 0) { + if (options && (qdict_size(options) != 0)) { const QDictEntry *entry = qdict_first(options); error_setg(errp, "Block protocol '%s' doesn't support the option '%s'", drv->format_name, entry->key); @@ -972,10 +977,12 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename, fail: QDECREF(options); - if (!bs->drv) { - QDECREF(bs->options); + if (bs) { + if (!bs->drv) { + QDECREF(bs->options); + } + bdrv_unref(bs); } - bdrv_unref(bs); return ret; } -- 1.8.5.1