From d1402b502691142b9cebadd5cb993dc8858e9071 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Wed, 9 May 2018 23:00:18 +0200 Subject: block: Add Error parameter to bdrv_amend_options Looking at the qcow2 code that is riddled with error_report() calls, this is really how it should have been from the start. Along the way, turn the target_version/current_version comparisons at the beginning of qcow2_downgrade() into assertions (the caller has to make sure these conditions are met), and rephrase the error message on using compat=1.1 to get refcount widths other than 16 bits. Signed-off-by: Max Reitz Message-id: 20180509210023.20283-3-mreitz@redhat.com Reviewed-by: Eric Blake Reviewed-by: John Snow Signed-off-by: Max Reitz --- include/block/block.h | 3 ++- include/block/block_int.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/block/block.h b/include/block/block.h index 6cc6c7e..4dd4f1e 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -343,7 +343,8 @@ int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix); typedef void BlockDriverAmendStatusCB(BlockDriverState *bs, int64_t offset, int64_t total_work_size, void *opaque); int bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts, - BlockDriverAmendStatusCB *status_cb, void *cb_opaque); + BlockDriverAmendStatusCB *status_cb, void *cb_opaque, + Error **errp); /* external snapshots */ bool bdrv_recurse_is_first_non_filter(BlockDriverState *bs, diff --git a/include/block/block_int.h b/include/block/block_int.h index 888b7f7..327e478 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -353,7 +353,8 @@ struct BlockDriver { int (*bdrv_amend_options)(BlockDriverState *bs, QemuOpts *opts, BlockDriverAmendStatusCB *status_cb, - void *cb_opaque); + void *cb_opaque, + Error **errp); void (*bdrv_debug_event)(BlockDriverState *bs, BlkdebugEvent event); -- cgit v1.1 From b444d0e9d1ae323fed1ef7c35a359ce064f36b32 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Wed, 9 May 2018 21:42:58 +0200 Subject: qemu-io: Drop command functions' return values For qemu-io, a function returns an integer with two possible values: 0 for "qemu-io may continue execution", or 1 for "qemu-io should exit". However, there is only a single command that returns 1, and that is "quit". So let's turn this case into a global variable instead so we can make better use of the return value in a later patch. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-id: 20180509194302.21585-2-mreitz@redhat.com Signed-off-by: Max Reitz --- include/qemu-io.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/qemu-io.h b/include/qemu-io.h index 196fde0..06cdfbf 100644 --- a/include/qemu-io.h +++ b/include/qemu-io.h @@ -22,7 +22,7 @@ #define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */ -typedef int (*cfunc_t)(BlockBackend *blk, int argc, char **argv); +typedef void (*cfunc_t)(BlockBackend *blk, int argc, char **argv); typedef void (*helpfunc_t)(void); typedef struct cmdinfo { @@ -41,10 +41,10 @@ typedef struct cmdinfo { extern bool qemuio_misalign; -bool qemuio_command(BlockBackend *blk, const char *cmd); +void qemuio_command(BlockBackend *blk, const char *cmd); void qemuio_add_command(const cmdinfo_t *ci); -int qemuio_command_usage(const cmdinfo_t *ci); +void qemuio_command_usage(const cmdinfo_t *ci); void qemuio_complete_command(const char *input, void (*fn)(const char *cmd, void *opaque), void *opaque); -- cgit v1.1 From b32d7a39af488d280ce5f02a2ed94871d696f87a Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Wed, 9 May 2018 21:42:59 +0200 Subject: qemu-io: Let command functions return error code This is basically what everything else in the qemu code base does, so we can do it here, too. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-id: 20180509194302.21585-3-mreitz@redhat.com Signed-off-by: Max Reitz --- include/qemu-io.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/qemu-io.h b/include/qemu-io.h index 06cdfbf..7433239 100644 --- a/include/qemu-io.h +++ b/include/qemu-io.h @@ -22,7 +22,12 @@ #define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */ -typedef void (*cfunc_t)(BlockBackend *blk, int argc, char **argv); +/* Implement a qemu-io command. + * Operate on @blk using @argc/@argv as the command's arguments, and + * return 0 on success or negative errno on failure. + */ +typedef int (*cfunc_t)(BlockBackend *blk, int argc, char **argv); + typedef void (*helpfunc_t)(void); typedef struct cmdinfo { @@ -41,7 +46,7 @@ typedef struct cmdinfo { extern bool qemuio_misalign; -void qemuio_command(BlockBackend *blk, const char *cmd); +int qemuio_command(BlockBackend *blk, const char *cmd); void qemuio_add_command(const cmdinfo_t *ci); void qemuio_command_usage(const cmdinfo_t *ci); -- cgit v1.1 From cc022140972f8b6ac3973c12ccf9dd6b1d2fd200 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Wed, 6 Jun 2018 21:37:00 +0200 Subject: block: Make bdrv_is_writable() public This is a useful function for the whole block layer, so make it public. At the same time, users outside of block.c probably do not need to make use of the reopen functionality, so rename the current function to bdrv_is_writable_after_reopen() create a new bdrv_is_writable() function that just passes NULL to it for the reopen queue. Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Message-id: 20180606193702.7113-2-mreitz@redhat.com Reviewed-by: John Snow Reviewed-by: Jeff Cody Signed-off-by: Max Reitz --- include/block/block.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/block/block.h b/include/block/block.h index 4dd4f1e..e677080 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -408,6 +408,7 @@ bool bdrv_is_read_only(BlockDriverState *bs); int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, bool ignore_allow_rdw, Error **errp); int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); +bool bdrv_is_writable(BlockDriverState *bs); bool bdrv_is_sg(BlockDriverState *bs); bool bdrv_is_inserted(BlockDriverState *bs); void bdrv_lock_medium(BlockDriverState *bs, bool locked); -- cgit v1.1