From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLuu7-0003dY-8K for qemu-devel@nongnu.org; Fri, 07 Mar 2014 08:33:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLuu2-0001lN-7G for qemu-devel@nongnu.org; Fri, 07 Mar 2014 08:33:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58801) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLuu2-0001lB-0k for qemu-devel@nongnu.org; Fri, 07 Mar 2014 08:33:30 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s27DXTY4019303 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 7 Mar 2014 08:33:29 -0500 From: Kevin Wolf Date: Fri, 7 Mar 2014 14:32:58 +0100 Message-Id: <1394199187-9576-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1394199187-9576-1-git-send-email-kwolf@redhat.com> References: <1394199187-9576-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 10/19] block/raw-posix: Implement bdrv_parse_filename() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com From: Max Reitz The "file" protocol driver should strip the "file:" prefix from filenames if present. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Benoit Canet Signed-off-by: Kevin Wolf --- block/raw-posix.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/block/raw-posix.c b/block/raw-posix.c index 161ea14..892145c 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -336,6 +336,17 @@ error: } #endif +static void raw_parse_filename(const char *filename, QDict *options, + Error **errp) +{ + /* The filename does not have to be prefixed by the protocol name, since + * "file" is the default protocol; therefore, the return value of this + * function call can be ignored. */ + strstart(filename, "file:", &filename); + + qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename))); +} + static QemuOptsList raw_runtime_opts = { .name = "raw", .head = QTAILQ_HEAD_INITIALIZER(raw_runtime_opts.head), @@ -1412,6 +1423,7 @@ static BlockDriver bdrv_file = { .instance_size = sizeof(BDRVRawState), .bdrv_needs_filename = true, .bdrv_probe = NULL, /* no probe for protocols */ + .bdrv_parse_filename = raw_parse_filename, .bdrv_file_open = raw_open, .bdrv_reopen_prepare = raw_reopen_prepare, .bdrv_reopen_commit = raw_reopen_commit, -- 1.8.1.4