[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/20] raw-win32: Use bdrv_open options instead of f
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 09/20] raw-win32: Use bdrv_open options instead of filename |
Date: |
Mon, 22 Apr 2013 13:31:23 +0200 |
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
block/raw-win32.c | 57 +++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 47 insertions(+), 10 deletions(-)
diff --git a/block/raw-win32.c b/block/raw-win32.c
index ece2f1a..be33cc1 100644
--- a/block/raw-win32.c
+++ b/block/raw-win32.c
@@ -221,21 +221,50 @@ static void raw_parse_flags(int flags, int *access_flags,
DWORD *overlapped)
}
}
-static int raw_open(BlockDriverState *bs, const char *filename,
+static QemuOptsList raw_runtime_opts = {
+ .name = "raw",
+ .head = QTAILQ_HEAD_INITIALIZER(raw_runtime_opts.head),
+ .desc = {
+ {
+ .name = "filename",
+ .type = QEMU_OPT_STRING,
+ .help = "File name of the image",
+ },
+ { /* end of list */ }
+ },
+};
+
+static int raw_open(BlockDriverState *bs, const char *unused,
QDict *options, int flags)
{
BDRVRawState *s = bs->opaque;
int access_flags;
DWORD overlapped;
+ QemuOpts *opts;
+ Error *local_err = NULL;
+ const char *filename;
+ int ret;
s->type = FTYPE_FILE;
+ opts = qemu_opts_create_nofail(&raw_runtime_opts);
+ qemu_opts_absorb_qdict(opts, options, &local_err);
+ if (error_is_set(&local_err)) {
+ qerror_report_err(local_err);
+ error_free(local_err);
+ ret = -EINVAL;
+ goto fail;
+ }
+
+ filename = qemu_opt_get(opts, "filename");
+
raw_parse_flags(flags, &access_flags, &overlapped);
-
+
if ((flags & BDRV_O_NATIVE_AIO) && aio == NULL) {
aio = win32_aio_init();
if (aio == NULL) {
- return -EINVAL;
+ ret = -EINVAL;
+ goto fail;
}
}
@@ -245,20 +274,27 @@ static int raw_open(BlockDriverState *bs, const char
*filename,
if (s->hfile == INVALID_HANDLE_VALUE) {
int err = GetLastError();
- if (err == ERROR_ACCESS_DENIED)
- return -EACCES;
- return -EINVAL;
+ if (err == ERROR_ACCESS_DENIED) {
+ ret = -EACCES;
+ } else {
+ ret = -EINVAL;
+ }
+ goto fail;
}
if (flags & BDRV_O_NATIVE_AIO) {
- int ret = win32_aio_attach(aio, s->hfile);
+ ret = win32_aio_attach(aio, s->hfile);
if (ret < 0) {
CloseHandle(s->hfile);
- return ret;
+ goto fail;
}
s->aio = aio;
}
- return 0;
+
+ ret = 0;
+fail:
+ qemu_opts_del(opts);
+ return ret;
}
static BlockDriverAIOCB *raw_aio_readv(BlockDriverState *bs,
@@ -495,13 +531,14 @@ static int hdev_probe_device(const char *filename)
return 0;
}
-static int hdev_open(BlockDriverState *bs, const char *filename,
+static int hdev_open(BlockDriverState *bs, const char *dummy,
QDict *options, int flags)
{
BDRVRawState *s = bs->opaque;
int access_flags, create_flags;
DWORD overlapped;
char device_name[64];
+ const char *filename = qdict_get_str(options, "filename");
if (strstart(filename, "/dev/cdrom", NULL)) {
if (find_cdrom(device_name, sizeof(device_name)) < 0)
--
1.8.1.4
- [Qemu-devel] [PULL 00/20] Block patches, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 03/20] qemu-img: do not zero-pad the compressed write buffer, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 01/20] qcow2: allow sub-cluster compressed write to last cluster, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 04/20] qemu-iotests: Fix _filter_qemu, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 02/20] qcow: allow sub-cluster compressed write to last cluster, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 06/20] block: Add driver-specific options for backing files, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 07/20] block: Enable filename option, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 05/20] block: Fail gracefully when using a format driver on protocol level, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 08/20] raw-posix: Use bdrv_open options instead of filename, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 10/20] blkdebug: Use bdrv_open options instead of filename, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 09/20] raw-win32: Use bdrv_open options instead of filename,
Kevin Wolf <=
- [Qemu-devel] [PATCH 11/20] blkverify: Use bdrv_open options instead of filename, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 13/20] gluster: Use bdrv_open options instead of filename, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 15/20] rbd: Use bdrv_open options instead of filename, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 12/20] curl: Use bdrv_open options instead of filename, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 14/20] iscsi: Use bdrv_open options instead of filename, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 17/20] vvfat: Use bdrv_open options instead of filename, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 16/20] sheepdog: Use bdrv_open options instead of filename, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 19/20] block: Allow overriding backing.file.filename, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 20/20] qemu-iotests: add 053 unaligned compressed image size test, Kevin Wolf, 2013/04/22
- [Qemu-devel] [PATCH 18/20] block: Remove filename parameter from .bdrv_file_open(), Kevin Wolf, 2013/04/22