[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 05/13] block: Check create_opts before image crea
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v2 05/13] block: Check create_opts before image creation |
Date: |
Thu, 27 Nov 2014 15:48:32 +0100 |
If a driver supports image creation, it needs to set the .create_opts
field. We can use that to make sure .create_opts for both drivers
involved is not NULL in bdrv_img_create(), which is important so that
the create_opts pointer in that function is not NULL after the
qemu_opts_append() calls and when going into qemu_opts_create().
Cc: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
block.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/block.c b/block.c
index fbd7cb2..29cf4bb 100644
--- a/block.c
+++ b/block.c
@@ -5546,6 +5546,18 @@ void bdrv_img_create(const char *filename, const char
*fmt,
return;
}
+ if (!drv->create_opts) {
+ error_setg(errp, "Format driver '%s' does not support image creation",
+ drv->format_name);
+ return;
+ }
+
+ if (!proto_drv->create_opts) {
+ error_setg(errp, "Protocol driver '%s' does not support image
creation",
+ proto_drv->format_name);
+ return;
+ }
+
create_opts = qemu_opts_append(create_opts, drv->create_opts);
create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
--
1.9.3
- [Qemu-devel] [PATCH v2 00/13] block: Various Coverity-spotted fixes, Max Reitz, 2014/11/27
- [Qemu-devel] [PATCH v2 01/13] block: Make essential BlockDriver objects public, Max Reitz, 2014/11/27
- [Qemu-devel] [PATCH v2 02/13] block: Omit bdrv_find_format for essential drivers, Max Reitz, 2014/11/27
- [Qemu-devel] [PATCH v2 03/13] block/vvfat: qcow driver may not be found, Max Reitz, 2014/11/27
- [Qemu-devel] [PATCH v2 04/13] block/nfs: Add create_opts, Max Reitz, 2014/11/27
- [Qemu-devel] [PATCH v2 05/13] block: Check create_opts before image creation,
Max Reitz <=
- [Qemu-devel] [PATCH v2 06/13] qemu-img: Check create_opts before image creation, Max Reitz, 2014/11/27
- [Qemu-devel] [PATCH v2 07/13] qemu-img: Check create_opts before image amendment, Max Reitz, 2014/11/27
- [Qemu-devel] [PATCH v2 08/13] iotests: Only kill NBD server if it runs, Max Reitz, 2014/11/27
- [Qemu-devel] [PATCH v2 09/13] iotests: Add test for unsupported image creation, Max Reitz, 2014/11/27
- [Qemu-devel] [PATCH v2 10/13] qcow2: Prevent numerical overflow, Max Reitz, 2014/11/27
- [Qemu-devel] [PATCH v2 12/13] qcow2: Respect bdrv_truncate() error, Max Reitz, 2014/11/27
- [Qemu-devel] [PATCH v2 11/13] qcow2: Flushing the caches in qcow2_close may fail, Max Reitz, 2014/11/27
- [Qemu-devel] [PATCH v2 13/13] block/raw-posix: Fix ret in raw_open_common(), Max Reitz, 2014/11/27