diff options
Diffstat (limited to 'qemu-io-cmds.c')
-rw-r--r-- | qemu-io-cmds.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 952dc940f1..c288c2ab30 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -2405,6 +2405,34 @@ static const cmdinfo_t sleep_cmd = { .oneline = "waits for the given value in milliseconds", }; +#ifdef CONFIG_BDRV_CLUSTER_INFO +static int cluster_info_f(BlockBackend *blk, int argc, char **argv) +{ + BlockDriverState *bs = blk_bs(blk); + char *endptr; + long offset; + + offset = strtol(argv[1], &endptr, 0); + if (offset < 0 || *endptr != '\0' || + offset > (bs->total_sectors * BDRV_SECTOR_SIZE)) { + printf("%s is not a valid number\n", argv[1]); + return -EINVAL; + } + + return bdrv_get_cluster_info(bs, offset); +} + +static const cmdinfo_t cluster_info_cmd = { + .name = "cluster_info", + .argmin = 1, + .argmax = 1, + .cfunc = cluster_info_f, + .args = "offset", + .oneline = "returns information about the mapping between guest \ + and host cluster type for a specific guest address", +}; +#endif + static void help_oneline(const char *cmd, const cmdinfo_t *ct) { printf("%s ", cmd); @@ -2517,5 +2545,8 @@ static void __attribute((constructor)) init_qemuio_commands(void) qemuio_add_command(&wait_break_cmd); qemuio_add_command(&abort_cmd); qemuio_add_command(&sleep_cmd); +#ifdef CONFIG_BDRV_CLUSTER_INFO + qemuio_add_command(&cluster_info_cmd); +#endif qemuio_add_command(&sigraise_cmd); } |