[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V2 1/4] block: Add option to do external snapshot im
From: |
Benoît Canet |
Subject: |
[Qemu-devel] [PATCH V2 1/4] block: Add option to do external snapshot image creation in the block drivers. |
Date: |
Mon, 28 Jan 2013 18:04:37 +0100 |
This patch will allow protocols to implements snapshots as the image creation
can now delegated to the block driver.
Signed-off-by: Benoit Canet <address@hidden>
---
block.c | 26 ++++++++++++++++++++++++++
blockdev.c | 8 ++++----
include/block/block.h | 6 ++++++
include/block/block_int.h | 8 ++++++++
4 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/block.c b/block.c
index 6fa7c90..41a9ac0 100644
--- a/block.c
+++ b/block.c
@@ -4626,3 +4626,29 @@ out:
bdrv_delete(bs);
}
}
+
+void bdrv_ext_snapshot_img_create(BlockDriverState *old_bs,
+ const char *filename, const char *fmt,
+ const char *base_filename,
+ const char *base_fmt,
+ char *options, uint64_t img_size,
+ int flags, Error **errp)
+{
+ if (!old_bs || !old_bs->file || !old_bs->file->drv) {
+ error_setg(errp, "Block driver not reachable.");
+ return;
+ }
+
+ if (!old_bs->file->drv->bdrv_ext_snapshot_img_create) {
+ bdrv_img_create(filename, fmt, base_filename, base_fmt, options,
+ img_size, flags, errp);
+ return;
+ }
+
+ old_bs->file->drv->bdrv_ext_snapshot_img_create(old_bs,
+ filename, fmt,
+ base_filename,
+ base_fmt,
+ options, img_size,
+ flags, errp);
+}
diff --git a/blockdev.c b/blockdev.c
index 9126587..0ce45c5 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -787,10 +787,10 @@ void qmp_transaction(BlockdevActionList *dev_list, Error
**errp)
/* create new image w/backing file */
if (mode != NEW_IMAGE_MODE_EXISTING) {
- bdrv_img_create(new_image_file, format,
- states->old_bs->filename,
- states->old_bs->drv->format_name,
- NULL, -1, flags, &local_err);
+ bdrv_ext_snapshot_img_create(states->old_bs, new_image_file,
format,
+ states->old_bs->filename,
+ states->old_bs->drv->format_name,
+ NULL, -1, flags, &local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
goto delete_and_fail;
diff --git a/include/block/block.h b/include/block/block.h
index ffd1936..12470fc 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -346,6 +346,12 @@ int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf,
void bdrv_img_create(const char *filename, const char *fmt,
const char *base_filename, const char *base_fmt,
char *options, uint64_t img_size, int flags, Error
**errp);
+void bdrv_ext_snapshot_img_create(BlockDriverState *old_bs,
+ const char *filename, const char *fmt,
+ const char *base_filename,
+ const char *base_fmt,
+ char *options, uint64_t img_size,
+ int flags, Error **errp);
void bdrv_set_buffer_alignment(BlockDriverState *bs, int align);
void *qemu_blockalign(BlockDriverState *bs, size_t size);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index f83ffb8..5bab830 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -202,6 +202,14 @@ struct BlockDriver {
*/
int (*bdrv_has_zero_init)(BlockDriverState *bs);
+ /* optional field */
+ void (*bdrv_ext_snapshot_img_create)(BlockDriverState *bs,
+ const char *filename, const char *fmt,
+ const char *base_filename,
+ const char *base_fmt,
+ char *options, uint64_t img_size,
+ int flags, Error **errp);
+
QLIST_ENTRY(BlockDriver) list;
};
--
1.7.10.4
- [Qemu-devel] [PATCH V2 0/4] Pave the way for protocol snapshot creation, Benoît Canet, 2013/01/28
- [Qemu-devel] [PATCH V2 2/4] block: make path_hash_protocol public., Benoît Canet, 2013/01/28
- [Qemu-devel] [PATCH V2 1/4] block: Add option to do external snapshot image creation in the block drivers.,
Benoît Canet <=
- [Qemu-devel] [PATCH V2 3/4] blockdev: Allow snapshoting of protocols., Benoît Canet, 2013/01/28
- Re: [Qemu-devel] [PATCH V2 3/4] blockdev: Allow snapshoting of protocols., Kevin Wolf, 2013/01/29
- Re: [Qemu-devel] [PATCH V2 3/4] blockdev: Allow snapshoting of protocols., Benoît Canet, 2013/01/29
- Re: [Qemu-devel] [PATCH V2 3/4] blockdev: Allow snapshoting of protocols., Kevin Wolf, 2013/01/29
- Re: [Qemu-devel] [PATCH V2 3/4] blockdev: Allow snapshoting of protocols., Benoît Canet, 2013/01/29
- Re: [Qemu-devel] [PATCH V2 3/4] blockdev: Allow snapshoting of protocols., Kevin Wolf, 2013/01/29
- Re: [Qemu-devel] [PATCH V2 3/4] blockdev: Allow snapshoting of protocols., Benoît Canet, 2013/01/29
- Re: [Qemu-devel] [PATCH V2 3/4] blockdev: Allow snapshoting of protocols., Eric Blake, 2013/01/29
- Re: [Qemu-devel] [PATCH V2 3/4] blockdev: Allow snapshoting of protocols., Benoît Canet, 2013/01/29
- Re: [Qemu-devel] [PATCH V2 3/4] blockdev: Allow snapshoting of protocols., Kevin Wolf, 2013/01/29