Received: from eggs.gnu.org ([2001:4830:134:3::10]:51229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViNw8-0007B5-4o for qemu-devel@nongnu.org; Mon, 18 Nov 2013 07:28:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ViNvy-00071D-Ie for qemu-devel@nongnu.org; Mon, 18 Nov 2013 07:28:16 -0500 Received: from mail-wg0-x235.google.com ([2a00:1450:400c:c00::235]:43367) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViNvy-00070x-Bn for qemu-devel@nongnu.org; Mon, 18 Nov 2013 07:28:06 -0500 Received: by mail-wg0-f53.google.com with SMTP id b13so6142896wgh.20 for ; Mon, 18 Nov 2013 04:28:05 -0800 (PST) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 18 Nov 2013 13:25:27 +0100 Message-Id: <1384777531-14635-18-git-send-email-marcandre.lureau@gmail.com> In-Reply-To: <1384777531-14635-1-git-send-email-marcandre.lureau@gmail.com> References: <1384777531-14635-1-git-send-email-marcandre.lureau@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 17/21] block: allow to call bdrv_open() with an opaque List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , jcody@redhat.com, kraxel@redhat.com, spice-devel@freedesktop.org From: Marc-André Lureau If the block driver already has a bs->opaque when calling bdrv_open(), pass it down to the file driver. Signed-off-by: Marc-André Lureau Conflicts: block.c --- block.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index f154979..ce2427b 100644 --- a/block.c +++ b/block.c @@ -1131,6 +1131,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, QDict *file_options = NULL; const char *drvname; Error *local_err = NULL; + void *backing_opaque = NULL; /* NULL means an empty set of options */ if (options == NULL) { @@ -1154,6 +1155,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, goto fail; } + backing_opaque = bs->opaque; + bs->opaque = NULL; if (total_size == -1) { bs1 = bdrv_new_int("", NULL, NULL); ret = bdrv_open(bs1, filename, NULL, 0, drv, &local_err); @@ -1181,7 +1184,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, ret = bdrv_file_open_int(&file, filename, file_options, bdrv_open_flags(bs, flags | BDRV_O_UNMAP), - bs, NULL, &local_err); + bs, bs->opaque, &local_err); + bs->opaque = NULL; if (ret < 0) { goto fail; } @@ -1217,7 +1221,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, QDict *backing_options; qdict_extract_subqdict(options, &backing_options, "backing."); - ret = bdrv_open_backing_file_int(bs, backing_options, NULL, &local_err); + ret = bdrv_open_backing_file_int(bs, backing_options, + backing_opaque, &local_err); if (ret < 0) { goto close_and_fail; } -- 1.8.3.1