Lines Matching +full:cmd +full:- +full:cnt +full:- +full:name

4  * Copyright (C) 2009-2016 Red Hat, Inc.
5 * Copyright (c) 2003-2005 Silicon Graphics, Inc.
8 * See the COPYING file in the top-level directory.
14 #include "qemu-io.h"
15 #include "system/block-backend.h"
19 #include "qemu/error-report.h"
20 #include "qemu/main-loop.h"
35 return strcmp(((const cmdinfo_t *)a)->name, in compare_cmdname()
36 ((const cmdinfo_t *)b)->name); in compare_cmdname()
41 /* ci->perm assumes a file is open, but the GLOBAL and NOFILE_OK in qemuio_add_command()
46 assert(ci->perm == 0 || in qemuio_add_command()
47 (ci->flags & (CMD_FLAG_GLOBAL | CMD_NOFILE_OK)) == 0); in qemuio_add_command()
49 cmdtab[ncmds - 1] = *ci; in qemuio_add_command()
55 printf("%s %s -- %s\n", ci->name, ci->args, ci->oneline); in qemuio_command_usage()
60 if (ct->flags & CMD_FLAG_GLOBAL) { in init_check_command()
63 if (!(ct->flags & CMD_NOFILE_OK) && !blk) { in init_check_command()
73 char *cmd = argv[0]; in command() local
76 return -EINVAL; in command()
79 if (argc - 1 < ct->argmin || (ct->argmax != -1 && argc - 1 > ct->argmax)) { in command()
80 if (ct->argmax == -1) { in command()
83 argc-1, cmd, ct->argmin); in command()
84 } else if (ct->argmin == ct->argmax) { in command()
87 argc-1, cmd, ct->argmin); in command()
91 argc-1, cmd, ct->argmin, ct->argmax); in command()
93 return -EINVAL; in command()
104 * qemuio_add_command() we assert that command with non-zero .perm field in command()
108 assert(blk || !ct->perm); in command()
109 if (ct->perm && blk_is_available(blk)) { in command()
113 if (ct->perm & ~orig_perm) { in command()
118 new_perm = orig_perm | ct->perm; in command()
129 return ct->cfunc(blk, argc, argv); in command()
132 static const cmdinfo_t *find_command(const char *cmd) in find_command() argument
137 if (strcmp(ct->name, cmd) == 0 || in find_command()
138 (ct->altname && strcmp(ct->altname, cmd) == 0)) in find_command()
148 void (*fn)(const char *cmd, void *opaque), in qemuio_complete_command() argument
155 if (strncmp(input, ct->name, input_len) == 0) { in qemuio_complete_command()
156 fn(ct->name, opaque); in qemuio_complete_command()
173 rval[c - 1] = p; in breakline()
190 return -ERANGE; in cvtnum()
198 case -EINVAL: in print_cvtnum_err()
199 printf("Parsing error: non-numeric argument," in print_cvtnum_err()
200 " or extraneous/unrecognized suffix -- %s\n", arg); in print_cvtnum_err()
202 case -ERANGE: in print_cvtnum_err()
203 printf("Parsing error: argument too large -- %s\n", arg); in print_cvtnum_err()
231 snprintf(str, size - 4, "%.3f", TO_EXABYTES(value)); in cvtstr()
234 snprintf(str, size - 4, "%.3f", TO_PETABYTES(value)); in cvtstr()
237 snprintf(str, size - 4, "%.3f", TO_TERABYTES(value)); in cvtstr()
240 snprintf(str, size - 4, "%.3f", TO_GIGABYTES(value)); in cvtstr()
243 snprintf(str, size - 4, "%.3f", TO_MEGABYTES(value)); in cvtstr()
246 snprintf(str, size - 4, "%.3f", TO_KILOBYTES(value)); in cvtstr()
249 snprintf(str, size - 6, "%f", value); in cvtstr()
264 t1.tv_nsec -= t2.tv_nsec; in tsub()
267 t1.tv_sec--; in tsub()
269 t1.tv_sec -= t2.tv_sec; in tsub()
291 double frac_sec = tv->tv_nsec / 1e9; in timestr()
294 if (!HOURS(tv->tv_sec)) { in timestr()
296 (unsigned int) MINUTES(tv->tv_sec), in timestr()
297 SECONDS(tv->tv_sec) + frac_sec); in timestr()
303 if ((format & VERBOSE_FIXED_TIME) || tv->tv_sec) { in timestr()
305 (unsigned int) HOURS(tv->tv_sec), in timestr()
306 (unsigned int) MINUTES(tv->tv_sec), in timestr()
307 SECONDS(tv->tv_sec) + frac_sec); in timestr()
314 * Parse the pattern argument to various sub-commands.
327 return -1; in parse_pattern()
364 p -= MISALIGN_OFFSET; in qemu_io_free()
380 * @blk - the block backend where the buffer content is going to be written to
381 * @len - the buffer length
382 * @file_name - the file to read the content from
383 * @register_buf - call blk_register_buf()
428 memcpy(p, buf, MIN(pattern_len, end - p)); in qemu_io_alloc_from_file()
471 int64_t count, int64_t total, int cnt, bool Cflag) in print_report() argument
482 s1, cnt, ts, s2, tdiv((double)cnt, *t)); in print_report()
485 total, cnt, ts, in print_report()
487 tdiv((double)cnt, *t)); in print_report()
521 if (count > BDRV_REQUEST_MAX_BYTES - len) { in create_iovec()
551 return -ERANGE; in do_pread()
568 return -ERANGE; in do_pwrite()
599 return -ERANGE; in do_write_compressed()
614 return -ERANGE; in do_load_vmstate()
628 return -ERANGE; in do_save_vmstate()
654 *total = qiov->size; in do_aio_readv()
668 *total = qiov->size; in do_aio_writev()
679 " 'read -v 512 1k' - dumps 1 kilobyte read from 512 bytes into the file\n" in read_help()
682 " standard output stream (with -v option) for subsequent inspection.\n" in read_help()
683 " -b, -- read from the VM state rather than the virtual disk\n" in read_help()
684 " -C, -- report statistics in a machine parsable format\n" in read_help()
685 " -l, -- length for pattern verification (only with -P)\n" in read_help()
686 " -p, -- ignored for backwards compatibility\n" in read_help()
687 " -P, -- use a pattern to verify read data\n" in read_help()
688 " -q, -- quiet mode, do not show I/O statistics\n" in read_help()
689 " -r, -- register I/O buffer\n" in read_help()
690 " -s, -- start offset for pattern verification (only with -P)\n" in read_help()
691 " -v, -- dump buffer to standard output\n" in read_help()
698 .name = "read",
702 .argmax = -1,
703 .args = "[-abCqrv] [-P pattern [-s off] [-l len]] off len",
713 int c, cnt, ret; in read_f() local
723 while ((c = getopt(argc, argv, "bCl:pP:qrs:v")) != -1) { in read_f()
746 return -EINVAL; in read_f()
768 return -EINVAL; in read_f()
772 if (optind != argc - 2) { in read_f()
774 return -EINVAL; in read_f()
791 return -EINVAL; in read_f()
796 return -EINVAL; in read_f()
800 pattern_count = count - pattern_offset; in read_f()
805 return -EINVAL; in read_f()
810 printf("%" PRId64 " is not a sector-aligned value for 'offset'\n", in read_f()
812 return -EINVAL; in read_f()
815 printf("%"PRId64" is not a sector-aligned value for 'count'\n", in read_f()
817 return -EINVAL; in read_f()
822 return -EINVAL; in read_f()
837 printf("read failed: %s\n", strerror(-ret)); in read_f()
840 cnt = ret; in read_f()
851 ret = -EINVAL; in read_f()
864 /* Finally, report back -- -C gives a parsable format */ in read_f()
866 print_report("read", &t2, offset, count, total, cnt, Cflag); in read_f()
880 " 'readv -v 512 1k 1k ' - dumps 2 kilobytes read from 512 bytes into the file\n" in readv_help()
883 " standard output stream (with -v option) for subsequent inspection.\n" in readv_help()
885 " -C, -- report statistics in a machine parsable format\n" in readv_help()
886 " -P, -- use a pattern to verify read data\n" in readv_help()
887 " -q, -- quiet mode, do not show I/O statistics\n" in readv_help()
888 " -r, -- register I/O buffer\n" in readv_help()
889 " -v, -- dump buffer to standard output\n" in readv_help()
896 .name = "readv",
899 .argmax = -1,
900 .args = "[-Cqrv] [-P pattern] off len [len..]",
909 int c, cnt, ret; in readv_f() local
920 while ((c = getopt(argc, argv, "CP:qrv")) != -1) { in readv_f()
929 return -EINVAL; in readv_f()
943 return -EINVAL; in readv_f()
947 if (optind > argc - 2) { in readv_f()
949 return -EINVAL; in readv_f()
960 nr_iov = argc - optind; in readv_f()
964 return -EINVAL; in readv_f()
972 printf("readv failed: %s\n", strerror(-ret)); in readv_f()
975 cnt = ret; in readv_f()
985 ret = -EINVAL; in readv_f()
998 /* Finally, report back -- -C gives a parsable format */ in readv_f()
1000 print_report("read", &t2, offset, qiov.size, total, cnt, Cflag); in readv_f()
1015 " 'write 512 1k' - writes 1 kilobyte at 512 bytes into the open file\n" in write_help()
1019 " -b, -- write to the VM state rather than the virtual disk\n" in write_help()
1020 " -c, -- write compressed data with blk_write_compressed\n" in write_help()
1021 " -C, -- report statistics in a machine parsable format\n" in write_help()
1022 " -f, -- use Force Unit Access semantics\n" in write_help()
1023 " -n, -- with -z, don't allow slow fallback\n" in write_help()
1024 " -p, -- ignored for backwards compatibility\n" in write_help()
1025 " -P, -- use different pattern to fill file\n" in write_help()
1026 " -q, -- quiet mode, do not show I/O statistics\n" in write_help()
1027 " -r, -- register I/O buffer\n" in write_help()
1028 " -s, -- use a pattern file to fill the write buffer\n" in write_help()
1029 " -u, -- with -z, allow unmapping\n" in write_help()
1030 " -z, -- write zeroes using blk_pwrite_zeroes\n" in write_help()
1037 .name = "write",
1042 .argmax = -1,
1043 .args = "[-bcCfnqruz] [-P pattern | -s source_file] off len",
1054 int c, cnt, ret; in write_f() local
1063 while ((c = getopt(argc, argv, "bcCfnpP:qrs:uz")) != -1) { in write_f()
1087 return -EINVAL; in write_f()
1108 return -EINVAL; in write_f()
1112 if (optind != argc - 2) { in write_f()
1114 return -EINVAL; in write_f()
1118 printf("-b and -z cannot be specified at the same time\n"); in write_f()
1119 return -EINVAL; in write_f()
1123 printf("-f and -b or -c cannot be specified at the same time\n"); in write_f()
1124 return -EINVAL; in write_f()
1128 printf("-n requires -z to be specified\n"); in write_f()
1129 return -EINVAL; in write_f()
1133 printf("-u requires -z to be specified\n"); in write_f()
1134 return -EINVAL; in write_f()
1138 printf("Only one of -z, -P, and -s " in write_f()
1140 return -EINVAL; in write_f()
1156 printf("length cannot exceed %" PRIu64 " without -n, given %s\n", in write_f()
1158 return -EINVAL; in write_f()
1163 printf("%" PRId64 " is not a sector-aligned value for 'offset'\n", in write_f()
1165 return -EINVAL; in write_f()
1169 printf("%"PRId64" is not a sector-aligned value for 'count'\n", in write_f()
1171 return -EINVAL; in write_f()
1178 return -EINVAL; in write_f()
1185 return -EINVAL; in write_f()
1206 printf("write failed: %s\n", strerror(-ret)); in write_f()
1209 cnt = ret; in write_f()
1217 /* Finally, report back -- -C gives a parsable format */ in write_f()
1219 print_report("wrote", &t2, offset, count, total, cnt, Cflag); in write_f()
1236 " 'writev 512 1k 1k' - writes 2 kilobytes at 512 bytes into the open file\n" in writev_help()
1240 " -C, -- report statistics in a machine parsable format\n" in writev_help()
1241 " -f, -- use Force Unit Access semantics\n" in writev_help()
1242 " -P, -- use different pattern to fill file\n" in writev_help()
1243 " -q, -- quiet mode, do not show I/O statistics\n" in writev_help()
1244 " -r, -- register I/O buffer\n" in writev_help()
1251 .name = "writev",
1255 .argmax = -1,
1256 .args = "[-Cfqr] [-P pattern] off len [len..]",
1266 int c, cnt, ret; in writev_f() local
1275 while ((c = getopt(argc, argv, "CfP:qr")) != -1) { in writev_f()
1292 return -EINVAL; in writev_f()
1297 return -EINVAL; in writev_f()
1301 if (optind > argc - 2) { in writev_f()
1303 return -EINVAL; in writev_f()
1313 nr_iov = argc - optind; in writev_f()
1317 return -EINVAL; in writev_f()
1325 printf("writev failed: %s\n", strerror(-ret)); in writev_f()
1328 cnt = ret; in writev_f()
1336 /* Finally, report back -- -C gives a parsable format */ in writev_f()
1338 print_report("wrote", &t2, offset, qiov.size, total, cnt, Cflag); in writev_f()
1370 printf("aio_write failed: %s\n", strerror(-ret)); in aio_write_done()
1371 block_acct_failed(blk_get_stats(ctx->blk), &ctx->acct); in aio_write_done()
1375 block_acct_done(blk_get_stats(ctx->blk), &ctx->acct); in aio_write_done()
1377 if (ctx->qflag) { in aio_write_done()
1381 /* Finally, report back -- -C gives a parsable format */ in aio_write_done()
1382 t2 = tsub(t2, ctx->t1); in aio_write_done()
1383 print_report("wrote", &t2, ctx->offset, ctx->qiov.size, in aio_write_done()
1384 ctx->qiov.size, 1, ctx->Cflag); in aio_write_done()
1386 if (!ctx->zflag) { in aio_write_done()
1387 qemu_io_free(ctx->blk, ctx->buf, ctx->qiov.size, in aio_write_done()
1388 ctx->flags & BDRV_REQ_REGISTERED_BUF); in aio_write_done()
1389 qemu_iovec_destroy(&ctx->qiov); in aio_write_done()
1402 printf("readv failed: %s\n", strerror(-ret)); in aio_read_done()
1403 block_acct_failed(blk_get_stats(ctx->blk), &ctx->acct); in aio_read_done()
1407 if (ctx->Pflag) { in aio_read_done()
1408 void *cmp_buf = g_malloc(ctx->qiov.size); in aio_read_done()
1410 memset(cmp_buf, ctx->pattern, ctx->qiov.size); in aio_read_done()
1411 if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) { in aio_read_done()
1413 PRId64 ", %zu bytes\n", ctx->offset, ctx->qiov.size); in aio_read_done()
1418 block_acct_done(blk_get_stats(ctx->blk), &ctx->acct); in aio_read_done()
1420 if (ctx->qflag) { in aio_read_done()
1424 if (ctx->vflag) { in aio_read_done()
1425 dump_buffer(ctx->buf, ctx->offset, ctx->qiov.size); in aio_read_done()
1428 /* Finally, report back -- -C gives a parsable format */ in aio_read_done()
1429 t2 = tsub(t2, ctx->t1); in aio_read_done()
1430 print_report("read", &t2, ctx->offset, ctx->qiov.size, in aio_read_done()
1431 ctx->qiov.size, 1, ctx->Cflag); in aio_read_done()
1433 qemu_io_free(ctx->blk, ctx->buf, ctx->qiov.size, in aio_read_done()
1434 ctx->flags & BDRV_REQ_REGISTERED_BUF); in aio_read_done()
1435 qemu_iovec_destroy(&ctx->qiov); in aio_read_done()
1446 " 'aio_read -v 512 1k 1k ' - dumps 2 kilobytes read from 512 bytes into the file\n" in aio_read_help()
1449 " standard output stream (with -v option) for subsequent inspection.\n" in aio_read_help()
1455 " -C, -- report statistics in a machine parsable format\n" in aio_read_help()
1456 " -i, -- treat request as invalid, for exercising stats\n" in aio_read_help()
1457 " -P, -- use a pattern to verify read data\n" in aio_read_help()
1458 " -q, -- quiet mode, do not show I/O statistics\n" in aio_read_help()
1459 " -r, -- register I/O buffer\n" in aio_read_help()
1460 " -v, -- dump buffer to standard output\n" in aio_read_help()
1467 .name = "aio_read",
1470 .argmax = -1,
1471 .args = "[-Ciqrv] [-P pattern] off len [len..]",
1481 ctx->blk = blk; in aio_read_f()
1482 while ((c = getopt(argc, argv, "CiP:qrv")) != -1) { in aio_read_f()
1485 ctx->Cflag = true; in aio_read_f()
1488 ctx->Pflag = true; in aio_read_f()
1489 ctx->pattern = parse_pattern(optarg); in aio_read_f()
1490 if (ctx->pattern < 0) { in aio_read_f()
1492 return -EINVAL; in aio_read_f()
1501 ctx->qflag = true; in aio_read_f()
1504 ctx->flags |= BDRV_REQ_REGISTERED_BUF; in aio_read_f()
1507 ctx->vflag = true; in aio_read_f()
1512 return -EINVAL; in aio_read_f()
1516 if (optind > argc - 2) { in aio_read_f()
1519 return -EINVAL; in aio_read_f()
1522 ctx->offset = cvtnum(argv[optind]); in aio_read_f()
1523 if (ctx->offset < 0) { in aio_read_f()
1524 int ret = ctx->offset; in aio_read_f()
1531 nr_iov = argc - optind; in aio_read_f()
1532 ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov, 0xab, in aio_read_f()
1533 ctx->flags & BDRV_REQ_REGISTERED_BUF); in aio_read_f()
1534 if (ctx->buf == NULL) { in aio_read_f()
1537 return -EINVAL; in aio_read_f()
1540 clock_gettime(CLOCK_MONOTONIC, &ctx->t1); in aio_read_f()
1541 block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size, in aio_read_f()
1543 blk_aio_preadv(blk, ctx->offset, &ctx->qiov, ctx->flags, aio_read_done, in aio_read_f()
1556 " 'aio_write 512 1k 1k' - writes 2 kilobytes at 512 bytes into the open file\n" in aio_write_help()
1565 " -C, -- report statistics in a machine parsable format\n" in aio_write_help()
1566 " -f, -- use Force Unit Access semantics\n" in aio_write_help()
1567 " -i, -- treat request as invalid, for exercising stats\n" in aio_write_help()
1568 " -P, -- use different pattern to fill file\n" in aio_write_help()
1569 " -q, -- quiet mode, do not show I/O statistics\n" in aio_write_help()
1570 " -r, -- register I/O buffer\n" in aio_write_help()
1571 " -u, -- with -z, allow unmapping\n" in aio_write_help()
1572 " -z, -- write zeroes using blk_aio_pwrite_zeroes\n" in aio_write_help()
1579 .name = "aio_write",
1583 .argmax = -1,
1584 .args = "[-Cfiqruz] [-P pattern] off len [len..]",
1595 ctx->blk = blk; in aio_write_f()
1596 while ((c = getopt(argc, argv, "CfiP:qruz")) != -1) { in aio_write_f()
1599 ctx->Cflag = true; in aio_write_f()
1602 ctx->flags |= BDRV_REQ_FUA; in aio_write_f()
1605 ctx->qflag = true; in aio_write_f()
1608 ctx->flags |= BDRV_REQ_REGISTERED_BUF; in aio_write_f()
1611 ctx->flags |= BDRV_REQ_MAY_UNMAP; in aio_write_f()
1617 return -EINVAL; in aio_write_f()
1626 ctx->zflag = true; in aio_write_f()
1631 return -EINVAL; in aio_write_f()
1635 if (optind > argc - 2) { in aio_write_f()
1638 return -EINVAL; in aio_write_f()
1641 if (ctx->zflag && optind != argc - 2) { in aio_write_f()
1642 printf("-z supports only a single length parameter\n"); in aio_write_f()
1644 return -EINVAL; in aio_write_f()
1647 if ((ctx->flags & BDRV_REQ_MAY_UNMAP) && !ctx->zflag) { in aio_write_f()
1648 printf("-u requires -z to be specified\n"); in aio_write_f()
1650 return -EINVAL; in aio_write_f()
1653 if (ctx->zflag && ctx->Pflag) { in aio_write_f()
1654 printf("-z and -P cannot be specified at the same time\n"); in aio_write_f()
1656 return -EINVAL; in aio_write_f()
1659 if (ctx->zflag && (ctx->flags & BDRV_REQ_REGISTERED_BUF)) { in aio_write_f()
1662 return -EINVAL; in aio_write_f()
1665 ctx->offset = cvtnum(argv[optind]); in aio_write_f()
1666 if (ctx->offset < 0) { in aio_write_f()
1667 int ret = ctx->offset; in aio_write_f()
1674 if (ctx->zflag) { in aio_write_f()
1682 ctx->qiov.size = count; in aio_write_f()
1683 blk_aio_pwrite_zeroes(blk, ctx->offset, count, ctx->flags, in aio_write_f()
1686 nr_iov = argc - optind; in aio_write_f()
1687 ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov, in aio_write_f()
1688 pattern, ctx->flags & BDRV_REQ_REGISTERED_BUF); in aio_write_f()
1689 if (ctx->buf == NULL) { in aio_write_f()
1692 return -EINVAL; in aio_write_f()
1695 clock_gettime(CLOCK_MONOTONIC, &ctx->t1); in aio_write_f()
1696 block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size, in aio_write_f()
1699 blk_aio_pwritev(blk, ctx->offset, &ctx->qiov, ctx->flags, in aio_write_f()
1716 .name = "aio_flush",
1727 .name = "flush",
1730 .oneline = "flush all in-core file state to disk",
1759 return -ERANGE; in zone_report_f()
1767 printf("zone report failed: %s\n", strerror(-ret)); in zone_report_f()
1782 .name = "zone_report",
1809 printf("zone open failed: %s\n", strerror(-ret)); in zone_open_f()
1815 .name = "zone_open",
1842 printf("zone close failed: %s\n", strerror(-ret)); in zone_close_f()
1848 .name = "zone_close",
1875 printf("zone finish failed: %s\n", strerror(-ret)); in zone_finish_f()
1881 .name = "zone_finish",
1908 printf("zone reset failed: %s\n", strerror(-ret)); in zone_reset_f()
1914 .name = "zone_reset",
1933 *total = qiov->size; in do_aio_zone_append()
1949 if (optind > argc - 3) { in zone_append_f()
1950 return -EINVAL; in zone_append_f()
1953 if ((c = getopt(argc, argv, "p")) != -1) { in zone_append_f()
1963 nr_iov = argc - optind; in zone_append_f()
1967 return -EINVAL; in zone_append_f()
1971 printf("zone append failed: %s\n", strerror(-ret)); in zone_append_f()
1988 .name = "zone_append",
1999 .name = "truncate",
2005 .args = "[-m prealloc_mode] off",
2016 while ((c = getopt(argc, argv, "m:")) != -1) { in truncate_f()
2023 return -EINVAL; in truncate_f()
2028 return -EINVAL; in truncate_f()
2039 * qemu-io is a debugging tool, so let us be strict here and pass in truncate_f()
2059 printf("getlength: %s\n", strerror(-size)); in length_f()
2070 .name = "length",
2089 if (bs->drv && bs->drv->format_name) { in info_f()
2090 printf("format name: %s\n", bs->drv->format_name); in info_f()
2092 if (bs->drv && bs->drv->protocol_name) { in info_f()
2093 printf("format name: %s\n", bs->drv->protocol_name); in info_f()
2110 return -EIO; in info_f()
2125 .name = "info",
2138 " 'discard 512 1k' - discards 1 kilobyte from 512 bytes into the file\n" in discard_help()
2141 " -C, -- report statistics in a machine parsable format\n" in discard_help()
2142 " -q, -- quiet mode, do not show I/O statistics\n" in discard_help()
2149 .name = "discard",
2154 .argmax = -1,
2155 .args = "[-Cq] off len",
2167 while ((c = getopt(argc, argv, "Cq")) != -1) { in discard_f()
2177 return -EINVAL; in discard_f()
2181 if (optind != argc - 2) { in discard_f()
2183 return -EINVAL; in discard_f()
2200 return -EINVAL; in discard_f()
2208 printf("discard failed: %s\n", strerror(-ret)); in discard_f()
2212 /* Finally, report back -- -C gives a parsable format */ in discard_f()
2250 printf("is_allocated failed: %s\n", strerror(-ret)); in alloc_f()
2254 remaining -= num; in alloc_f()
2259 count -= remaining; in alloc_f()
2272 .name = "alloc",
2298 bytes -= num; in map_is_allocated()
2322 error_report("Failed to query image length: %s", strerror(-bytes)); in map_f()
2329 error_report("Failed to get allocation status: %s", strerror(-ret)); in map_f()
2333 return -EIO; in map_f()
2343 bytes -= num; in map_f()
2350 .name = "map",
2365 " 'reopen -o lazy-refcounts=on' - activates lazy refcount writeback on a qcow2 image\n" in reopen_help()
2367 " -r, -- Reopen the image read-only\n" in reopen_help()
2368 " -w, -- Reopen the image read-write\n" in reopen_help()
2369 " -c, -- Change the cache mode to the given value\n" in reopen_help()
2370 " -o, -- Changes block driver options (cf. 'open' command)\n" in reopen_help()
2377 .name = "reopen",
2387 .name = "reopen",
2389 .argmax = -1,
2391 .args = "[(-r|-w)] [-c cache] [-o options]",
2402 int flags = bs->open_flags; in reopen_f()
2408 while ((c = getopt(argc, argv, "c:o:rw")) != -1) { in reopen_f()
2413 return -EINVAL; in reopen_f()
2420 return -EINVAL; in reopen_f()
2425 error_report("Only one -r/-w option may be given"); in reopen_f()
2426 return -EINVAL; in reopen_f()
2433 error_report("Only one -r/-w option may be given"); in reopen_f()
2434 return -EINVAL; in reopen_f()
2442 return -EINVAL; in reopen_f()
2449 return -EINVAL; in reopen_f()
2457 return -EBUSY; in reopen_f()
2478 error_report("Cannot set both -r/-w and '" BDRV_OPT_READ_ONLY "'"); in reopen_f()
2480 return -EINVAL; in reopen_f()
2489 error_report("Cannot set both -c and the cache options"); in reopen_f()
2491 return -EINVAL; in reopen_f()
2502 return -EINVAL; in reopen_f()
2515 printf("Could not set breakpoint: %s\n", strerror(-ret)); in break_f()
2528 printf("Could not remove breakpoint %s: %s\n", argv[1], strerror(-ret)); in remove_break_f()
2536 .name = "break",
2546 .name = "remove_break",
2560 printf("Could not resume request: %s\n", strerror(-ret)); in resume_f()
2568 .name = "resume",
2585 .name = "wait_break",
2599 .name = "abort",
2612 " 'sigraise %i' - raises SIGTERM\n" in sigraise_help()
2622 .name = "sigraise",
2641 return -EINVAL; in sigraise_f()
2646 * non-buffered anyway) should be flushed, though. */ in sigraise_f()
2671 return -EINVAL; in sleep_f()
2686 .name = "sleep",
2694 static void help_oneline(const char *cmd, const cmdinfo_t *ct) in help_oneline() argument
2696 printf("%s ", cmd); in help_oneline()
2698 if (ct->args) { in help_oneline()
2699 printf("%s ", ct->args); in help_oneline()
2701 printf("-- %s\n", ct->oneline); in help_oneline()
2704 static void help_onecmd(const char *cmd, const cmdinfo_t *ct) in help_onecmd() argument
2706 help_oneline(cmd, ct); in help_onecmd()
2707 if (ct->help) { in help_onecmd()
2708 ct->help(); in help_onecmd()
2717 help_oneline(ct->name, ct); in help_all()
2734 return -EINVAL; in help_f()
2742 .name = "help",
2756 int qemuio_command(BlockBackend *blk, const char *cmd) in qemuio_command() argument
2764 input = g_strdup(cmd); in qemuio_command()
2772 ret = -EINVAL; in qemuio_command()