* See the COPYING file in the top-level directory.
*/
-#include "qemu-common.h"
+#include "qemu-io.h"
#include "block/block_int.h"
-#include "cmd.h"
+#include "block/qapi.h"
+#include "qemu/main-loop.h"
#define CMD_NOFILE_OK 0x01
return 1;
}
-static int command(const cmdinfo_t *ct, int argc, char **argv)
+static int command(BlockDriverState *bs, const cmdinfo_t *ct, int argc,
+ char **argv)
{
char *cmd = argv[0];
- if (!init_check_command(qemuio_bs, ct)) {
+ if (!init_check_command(bs, ct)) {
return 0;
}
return 0;
}
optind = 0;
- return ct->cfunc(qemuio_bs, argc, argv);
+ return ct->cfunc(bs, argc, argv);
}
static const cmdinfo_t *find_command(const char *cmd)
static int info_f(BlockDriverState *bs, int argc, char **argv)
{
BlockDriverInfo bdi;
+ ImageInfoSpecific *spec_info;
char s1[64], s2[64];
int ret;
printf("cluster size: %s\n", s1);
printf("vm state offset: %s\n", s2);
+ spec_info = bdrv_get_specific_info(bs);
+ if (spec_info) {
+ printf("Format specific information:\n");
+ bdrv_image_info_specific_dump(fprintf, stdout, spec_info);
+ qapi_free_ImageInfoSpecific(spec_info);
+ }
+
return 0;
}
sector_num = offset >> 9;
while (remaining) {
ret = bdrv_is_allocated(bs, sector_num, remaining, &num);
+ if (ret < 0) {
+ printf("is_allocated failed: %s\n", strerror(-ret));
+ return 0;
+ }
sector_num += num;
remaining -= num;
if (ret) {
.oneline = "help for one or all commands",
};
-bool qemuio_command(const char *cmd)
+bool qemuio_command(BlockDriverState *bs, const char *cmd)
{
char *input;
const cmdinfo_t *ct;
if (c) {
ct = find_command(v[0]);
if (ct) {
- done = command(ct, c, v);
+ done = command(bs, ct, c, v);
} else {
fprintf(stderr, "command \"%s\" not found\n", v[0]);
}