Assuming that any image on a block device is not properly zero-initialized is
actually wrong: Only raw images have this problem. Any other image format
shouldn't care about it, they initialize everything properly themselves.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
- if (bs->drv->no_zero_init) {
- return 0;
- } else if (bs->file) {
- return bdrv_has_zero_init(bs->file);
+ if (bs->drv->bdrv_has_zero_init) {
+ return bs->drv->bdrv_has_zero_init(bs);
+static int hdev_has_zero_init(BlockDriverState *bs)
+{
+ return 0;
+}
+
static BlockDriver bdrv_host_device = {
.format_name = "host_device",
.protocol_name = "host_device",
static BlockDriver bdrv_host_device = {
.format_name = "host_device",
.protocol_name = "host_device",
.bdrv_close = raw_close,
.bdrv_create = hdev_create,
.create_options = raw_create_options,
.bdrv_close = raw_close,
.bdrv_create = hdev_create,
.create_options = raw_create_options,
+ .bdrv_has_zero_init = hdev_has_zero_init,
.bdrv_flush = raw_flush,
.bdrv_aio_readv = raw_aio_readv,
.bdrv_flush = raw_flush,
.bdrv_aio_readv = raw_aio_readv,
.bdrv_close = raw_close,
.bdrv_create = hdev_create,
.create_options = raw_create_options,
.bdrv_close = raw_close,
.bdrv_create = hdev_create,
.create_options = raw_create_options,
+ .bdrv_has_zero_init = hdev_has_zero_init,
.bdrv_flush = raw_flush,
.bdrv_aio_readv = raw_aio_readv,
.bdrv_flush = raw_flush,
.bdrv_aio_readv = raw_aio_readv,
.bdrv_close = raw_close,
.bdrv_create = hdev_create,
.create_options = raw_create_options,
.bdrv_close = raw_close,
.bdrv_create = hdev_create,
.create_options = raw_create_options,
+ .bdrv_has_zero_init = hdev_has_zero_init,
.bdrv_flush = raw_flush,
.bdrv_aio_readv = raw_aio_readv,
.bdrv_flush = raw_flush,
.bdrv_aio_readv = raw_aio_readv,
.bdrv_close = raw_close,
.bdrv_create = hdev_create,
.create_options = raw_create_options,
.bdrv_close = raw_close,
.bdrv_create = hdev_create,
.create_options = raw_create_options,
+ .bdrv_has_zero_init = hdev_has_zero_init,
.bdrv_flush = raw_flush,
.bdrv_aio_readv = raw_aio_readv,
.bdrv_flush = raw_flush,
.bdrv_aio_readv = raw_aio_readv,
+static int hdev_has_zero_init(BlockDriverState *bs)
+{
+ return 0;
+}
+
static BlockDriver bdrv_host_device = {
.format_name = "host_device",
.protocol_name = "host_device",
static BlockDriver bdrv_host_device = {
.format_name = "host_device",
.protocol_name = "host_device",
.bdrv_file_open = hdev_open,
.bdrv_close = raw_close,
.bdrv_flush = raw_flush,
.bdrv_file_open = hdev_open,
.bdrv_close = raw_close,
.bdrv_flush = raw_flush,
+ .bdrv_has_zero_init = hdev_has_zero_init,
.bdrv_read = raw_read,
.bdrv_write = raw_write,
.bdrv_read = raw_read,
.bdrv_write = raw_write,
+static int raw_has_zero_init(BlockDriverState *bs)
+{
+ return bdrv_has_zero_init(bs->file);
+}
+
static BlockDriver bdrv_raw = {
.format_name = "raw",
static BlockDriver bdrv_raw = {
.format_name = "raw",
.bdrv_create = raw_create,
.create_options = raw_create_options,
.bdrv_create = raw_create,
.create_options = raw_create_options,
+ .bdrv_has_zero_init = raw_has_zero_init,
};
static void bdrv_raw_init(void)
};
static void bdrv_raw_init(void)
void (*bdrv_debug_event)(BlockDriverState *bs, BlkDebugEvent event);
void (*bdrv_debug_event)(BlockDriverState *bs, BlkDebugEvent event);
- /* Set if newly created images are not guaranteed to contain only zeros */
- int no_zero_init;
+ /*
+ * Returns 1 if newly created images are guaranteed to contain only
+ * zeros, 0 otherwise.
+ */
+ int (*bdrv_has_zero_init)(BlockDriverState *bs);
QLIST_ENTRY(BlockDriver) list;
};
QLIST_ENTRY(BlockDriver) list;
};