[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 31/56] file-win32: Support .bdrv_co_create
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 31/56] file-win32: Support .bdrv_co_create |
Date: |
Fri, 9 Mar 2018 17:19:08 +0100 |
This adds the .bdrv_co_create driver callback to file-win32, which
enables image creation over QMP.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
block/file-win32.c | 47 ++++++++++++++++++++++++++++++++++++++---------
1 file changed, 38 insertions(+), 9 deletions(-)
diff --git a/block/file-win32.c b/block/file-win32.c
index 4a430d45f1..2e2f746bb1 100644
--- a/block/file-win32.c
+++ b/block/file-win32.c
@@ -553,30 +553,59 @@ static int64_t
raw_get_allocated_file_size(BlockDriverState *bs)
return st.st_size;
}
-static int coroutine_fn raw_co_create_opts(const char *filename, QemuOpts
*opts,
- Error **errp)
+static int raw_co_create(BlockdevCreateOptions *options, Error **errp)
{
+ BlockdevCreateOptionsFile *file_opts;
int fd;
- int64_t total_size = 0;
- strstart(filename, "file:", &filename);
+ assert(options->driver == BLOCKDEV_DRIVER_FILE);
+ file_opts = &options->u.file;
- /* Read out options */
- total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
- BDRV_SECTOR_SIZE);
+ if (file_opts->has_preallocation) {
+ error_setg(errp, "Preallocation is not supported on Windows");
+ return -EINVAL;
+ }
+ if (file_opts->has_nocow) {
+ error_setg(errp, "nocow is not supported on Windows");
+ return -EINVAL;
+ }
- fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
+ fd = qemu_open(file_opts->filename, O_WRONLY | O_CREAT | O_TRUNC |
O_BINARY,
0644);
if (fd < 0) {
error_setg_errno(errp, errno, "Could not create file");
return -EIO;
}
set_sparse(fd);
- ftruncate(fd, total_size);
+ ftruncate(fd, file_opts->size);
qemu_close(fd);
+
return 0;
}
+static int coroutine_fn raw_co_create_opts(const char *filename, QemuOpts
*opts,
+ Error **errp)
+{
+ BlockdevCreateOptions options;
+ int64_t total_size = 0;
+
+ strstart(filename, "file:", &filename);
+
+ /* Read out options */
+ total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
+ BDRV_SECTOR_SIZE);
+
+ options = (BlockdevCreateOptions) {
+ .driver = BLOCKDEV_DRIVER_FILE,
+ .u.file = {
+ .filename = (char *) filename,
+ .size = total_size,
+ .has_preallocation = false,
+ .has_nocow = false,
+ },
+ };
+ return raw_co_create(&options, errp);
+}
static QemuOptsList raw_create_opts = {
.name = "raw-create-opts",
--
2.13.6
- [Qemu-devel] [PULL 20/56] qcow2: Use BlockdevRef in qcow2_co_create(), (continued)
- [Qemu-devel] [PULL 20/56] qcow2: Use BlockdevRef in qcow2_co_create(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 32/56] gluster: Support .bdrv_co_create, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 27/56] qcow2: Use visitor for options in qcow2_create(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 18/56] qcow2: Let qcow2_create() handle protocol layer, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 21/56] qcow2: Use QCryptoBlockCreateOptions in qcow2_co_create(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 19/56] qcow2: Pass BlockdevCreateOptions to qcow2_co_create(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 26/56] qdict: Introduce qdict_rename_keys(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 34/56] rbd: Factor out qemu_rbd_connect(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 36/56] rbd: Pass BlockdevOptionsRbd to qemu_rbd_connect(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 23/56] util: Add qemu_opts_to_qdict_filtered(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 31/56] file-win32: Support .bdrv_co_create,
Kevin Wolf <=
- [Qemu-devel] [PULL 33/56] rbd: Fix use after free in qemu_rbd_set_keypairs() error path, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 37/56] rbd: Support .bdrv_co_create, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 40/56] nfs: Use QAPI options in nfs_client_open(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 48/56] file-posix: Fix no-op bdrv_truncate() with falloc preallocation, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 41/56] nfs: Support .bdrv_co_create, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 46/56] ssh: Pass BlockdevOptionsSsh to connect_to_ssh(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 49/56] block: Fail bdrv_truncate() with negative size, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 44/56] ssh: Use QAPI BlockdevOptionsSsh object, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 39/56] rbd: Use qemu_rbd_connect() in qemu_rbd_do_create(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 35/56] rbd: Remove non-schema options from runtime_opts, Kevin Wolf, 2018/03/09