From 6f176b48f9f98820ed192a1355cc1c7c08ddf46b Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Tue, 3 Sep 2013 10:09:50 +0200 Subject: block: Image file option amendment This patch adds the "amend" option to qemu-img which allows changing image options on existing image files. It also adds the generic bdrv implementation which is basically just a wrapper for the image format specific function. Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- include/block/block_int.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/block/block_int.h') diff --git a/include/block/block_int.h b/include/block/block_int.h index 7c35198ad7..1541777d42 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -188,6 +188,9 @@ struct BlockDriver { int (*bdrv_check)(BlockDriverState* bs, BdrvCheckResult *result, BdrvCheckMode fix); + int (*bdrv_amend_options)(BlockDriverState *bs, + QEMUOptionParameter *options); + void (*bdrv_debug_event)(BlockDriverState *bs, BlkDebugEvent event); /* TODO Better pass a option string/QDict/QemuOpts to add any rule? */ -- cgit v1.2.3 From a89d89d3e65800fa4a8e00de7af0ea8272bef779 Mon Sep 17 00:00:00 2001 From: Wenchao Xia Date: Wed, 11 Sep 2013 14:04:33 +0800 Subject: snapshot: distinguish id and name in snapshot delete Snapshot creation actually already distinguish id and name since it take a structured parameter *sn, but delete can't. Later an accurate delete is needed in qmp_transaction abort and blockdev-snapshot-delete-sync, so change its prototype. Also *errp is added to tip error, but return value is kepted to let caller check what kind of error happens. Existing caller for it are savevm, delvm and qemu-img, they are not impacted by introducing a new function bdrv_snapshot_delete_by_id_or_name(), which check the return value and do the operation again. Before this patch: For qcow2, it search id first then name to find the one to delete. For rbd, it search name. For sheepdog, it does nothing. After this patch: For qcow2, logic is the same by call it twice in caller. For rbd, it always fails in delete with id, but still search for name in second try, no change to user. Some code for *errp is based on Pavel's patch. Signed-off-by: Wenchao Xia Signed-off-by: Pavel Hrdina Signed-off-by: Kevin Wolf --- include/block/block_int.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include/block/block_int.h') diff --git a/include/block/block_int.h b/include/block/block_int.h index 1541777d42..e7d1766ae0 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -150,7 +150,10 @@ struct BlockDriver { QEMUSnapshotInfo *sn_info); int (*bdrv_snapshot_goto)(BlockDriverState *bs, const char *snapshot_id); - int (*bdrv_snapshot_delete)(BlockDriverState *bs, const char *snapshot_id); + int (*bdrv_snapshot_delete)(BlockDriverState *bs, + const char *snapshot_id, + const char *name, + Error **errp); int (*bdrv_snapshot_list)(BlockDriverState *bs, QEMUSnapshotInfo **psn_info); int (*bdrv_snapshot_load_tmp)(BlockDriverState *bs, -- cgit v1.2.3 From 015a1036a74ad29bb6916754911ce25587ff4db3 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Thu, 5 Sep 2013 14:22:29 +0200 Subject: bdrv: Use "Error" for opening images Add an Error ** parameter to BlockDriver.bdrv_open and BlockDriver.bdrv_file_open to allow more specific error messages. Signed-off-by: Max Reitz --- include/block/block_int.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/block/block_int.h') diff --git a/include/block/block_int.h b/include/block/block_int.h index e7d1766ae0..076b40aa43 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -80,8 +80,10 @@ struct BlockDriver { void (*bdrv_reopen_commit)(BDRVReopenState *reopen_state); void (*bdrv_reopen_abort)(BDRVReopenState *reopen_state); - int (*bdrv_open)(BlockDriverState *bs, QDict *options, int flags); - int (*bdrv_file_open)(BlockDriverState *bs, QDict *options, int flags); + int (*bdrv_open)(BlockDriverState *bs, QDict *options, int flags, + Error **errp); + int (*bdrv_file_open)(BlockDriverState *bs, QDict *options, int flags, + Error **errp); int (*bdrv_read)(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors); int (*bdrv_write)(BlockDriverState *bs, int64_t sector_num, -- cgit v1.2.3 From d5124c00d80b4d948509f2c7f6b54228d9981f75 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Thu, 5 Sep 2013 14:26:05 +0200 Subject: bdrv: Use "Error" for creating images Add an Error ** parameter to BlockDriver.bdrv_create to allow more specific error messages. Signed-off-by: Max Reitz --- include/block/block_int.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/block/block_int.h') diff --git a/include/block/block_int.h b/include/block/block_int.h index 076b40aa43..3eeb6fe2a4 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -90,7 +90,8 @@ struct BlockDriver { const uint8_t *buf, int nb_sectors); void (*bdrv_close)(BlockDriverState *bs); void (*bdrv_rebind)(BlockDriverState *bs); - int (*bdrv_create)(const char *filename, QEMUOptionParameter *options); + int (*bdrv_create)(const char *filename, QEMUOptionParameter *options, + Error **errp); int (*bdrv_set_key)(BlockDriverState *bs, const char *key); int (*bdrv_make_empty)(BlockDriverState *bs); /* aio */ -- cgit v1.2.3