|
|
9ae3a8 |
From 8adbd2914ccd44e0b1766690b514bda213b88740 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 23 Nov 2015 17:38:39 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 20/27] qemu-io: Correct error messages
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1448300320-7772-21-git-send-email-jsnow@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 68446
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.3 qemu-kvm PATCH v2 20/21] qemu-io: Correct error messages
|
|
|
9ae3a8 |
Bugzilla: 1272523
|
|
|
9ae3a8 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reported-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit a9ecfa004f2dd83df612daac4a87dfc3a0feba28)
|
|
|
9ae3a8 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
qemu-io-cmds.c:
|
|
|
9ae3a8 |
- Fixes to sigraise are not backported.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qemu-io-cmds.c | 51 +++++++++++++++++++++++++++++++++------------------
|
|
|
9ae3a8 |
1 file changed, 33 insertions(+), 18 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
|
|
|
9ae3a8 |
index 6ea027d..b41d6ee 100644
|
|
|
9ae3a8 |
--- a/qemu-io-cmds.c
|
|
|
9ae3a8 |
+++ b/qemu-io-cmds.c
|
|
|
9ae3a8 |
@@ -134,6 +134,21 @@ static int64_t cvtnum(const char *s)
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static void print_cvtnum_err(int64_t rc, const char *arg)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ switch (rc) {
|
|
|
9ae3a8 |
+ case -EINVAL:
|
|
|
9ae3a8 |
+ printf("Parsing error: non-numeric argument,"
|
|
|
9ae3a8 |
+ " or extraneous/unrecognized suffix -- %s\n", arg);
|
|
|
9ae3a8 |
+ break;
|
|
|
9ae3a8 |
+ case -ERANGE:
|
|
|
9ae3a8 |
+ printf("Parsing error: argument too large -- %s\n", arg);
|
|
|
9ae3a8 |
+ break;
|
|
|
9ae3a8 |
+ default:
|
|
|
9ae3a8 |
+ printf("Parsing error: %s\n", arg);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
#define EXABYTES(x) ((long long)(x) << 60)
|
|
|
9ae3a8 |
#define PETABYTES(x) ((long long)(x) << 50)
|
|
|
9ae3a8 |
#define TERABYTES(x) ((long long)(x) << 40)
|
|
|
9ae3a8 |
@@ -355,13 +370,13 @@ create_iovec(BlockDriverState *bs, QEMUIOVector *qiov, char **argv, int nr_iov,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
len = cvtnum(arg);
|
|
|
9ae3a8 |
if (len < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", arg);
|
|
|
9ae3a8 |
+ print_cvtnum_err(len, arg);
|
|
|
9ae3a8 |
goto fail;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* should be SIZE_T_MAX, but that doesn't exist */
|
|
|
9ae3a8 |
if (len > INT_MAX) {
|
|
|
9ae3a8 |
- printf("too large length argument -- %s\n", arg);
|
|
|
9ae3a8 |
+ printf("Argument '%s' exceeds maximum size %d\n", arg, INT_MAX);
|
|
|
9ae3a8 |
goto fail;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -688,7 +703,7 @@ static int read_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
lflag = 1;
|
|
|
9ae3a8 |
pattern_count = cvtnum(optarg);
|
|
|
9ae3a8 |
if (pattern_count < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", optarg);
|
|
|
9ae3a8 |
+ print_cvtnum_err(pattern_count, optarg);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
break;
|
|
|
9ae3a8 |
@@ -709,7 +724,7 @@ static int read_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
sflag = 1;
|
|
|
9ae3a8 |
pattern_offset = cvtnum(optarg);
|
|
|
9ae3a8 |
if (pattern_offset < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", optarg);
|
|
|
9ae3a8 |
+ print_cvtnum_err(pattern_offset, optarg);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
break;
|
|
|
9ae3a8 |
@@ -732,14 +747,14 @@ static int read_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
offset = cvtnum(argv[optind]);
|
|
|
9ae3a8 |
if (offset < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(offset, argv[optind]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
optind++;
|
|
|
9ae3a8 |
count = cvtnum(argv[optind]);
|
|
|
9ae3a8 |
if (count < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(count, argv[optind]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
} else if (count > SIZE_MAX) {
|
|
|
9ae3a8 |
printf("length cannot exceed %" PRIu64 ", given %s\n",
|
|
|
9ae3a8 |
@@ -894,7 +909,7 @@ static int readv_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
offset = cvtnum(argv[optind]);
|
|
|
9ae3a8 |
if (offset < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(offset, argv[optind]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
optind++;
|
|
|
9ae3a8 |
@@ -1043,14 +1058,14 @@ static int write_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
offset = cvtnum(argv[optind]);
|
|
|
9ae3a8 |
if (offset < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(offset, argv[optind]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
optind++;
|
|
|
9ae3a8 |
count = cvtnum(argv[optind]);
|
|
|
9ae3a8 |
if (count < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(count, argv[optind]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
} else if (count > SIZE_MAX) {
|
|
|
9ae3a8 |
printf("length cannot exceed %" PRIu64 ", given %s\n",
|
|
|
9ae3a8 |
@@ -1179,7 +1194,7 @@ static int writev_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
offset = cvtnum(argv[optind]);
|
|
|
9ae3a8 |
if (offset < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(offset, argv[optind]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
optind++;
|
|
|
9ae3a8 |
@@ -1306,7 +1321,7 @@ static int multiwrite_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
/* Read the offset of the request */
|
|
|
9ae3a8 |
offset = cvtnum(argv[optind]);
|
|
|
9ae3a8 |
if (offset < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric offset argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(offset, argv[optind]);
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
optind++;
|
|
|
9ae3a8 |
@@ -1526,7 +1541,7 @@ static int aio_read_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
ctx->offset = cvtnum(argv[optind]);
|
|
|
9ae3a8 |
if (ctx->offset < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(ctx->offset, argv[optind]);
|
|
|
9ae3a8 |
g_free(ctx);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -1618,7 +1633,7 @@ static int aio_write_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
ctx->offset = cvtnum(argv[optind]);
|
|
|
9ae3a8 |
if (ctx->offset < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(ctx->offset, argv[optind]);
|
|
|
9ae3a8 |
g_free(ctx);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -1676,7 +1691,7 @@ static int truncate_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
offset = cvtnum(argv[1]);
|
|
|
9ae3a8 |
if (offset < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric truncate argument -- %s\n", argv[1]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(offset, argv[1]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1822,14 +1837,14 @@ static int discard_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
offset = cvtnum(argv[optind]);
|
|
|
9ae3a8 |
if (offset < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(offset, argv[optind]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
optind++;
|
|
|
9ae3a8 |
count = cvtnum(argv[optind]);
|
|
|
9ae3a8 |
if (count < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(count, argv[optind]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
} else if (count >> BDRV_SECTOR_BITS > INT_MAX) {
|
|
|
9ae3a8 |
printf("length cannot exceed %"PRIu64", given %s\n",
|
|
|
9ae3a8 |
@@ -1867,7 +1882,7 @@ static int alloc_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
offset = cvtnum(argv[1]);
|
|
|
9ae3a8 |
if (offset < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric offset argument -- %s\n", argv[1]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(offset, argv[1]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
} else if (offset & 0x1ff) {
|
|
|
9ae3a8 |
printf("offset %" PRId64 " is not sector aligned\n",
|
|
|
9ae3a8 |
@@ -1878,7 +1893,7 @@ static int alloc_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
if (argc == 3) {
|
|
|
9ae3a8 |
nb_sectors = cvtnum(argv[2]);
|
|
|
9ae3a8 |
if (nb_sectors < 0) {
|
|
|
9ae3a8 |
- printf("non-numeric length argument -- %s\n", argv[2]);
|
|
|
9ae3a8 |
+ print_cvtnum_err(nb_sectors, argv[2]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
} else if (nb_sectors > INT_MAX) {
|
|
|
9ae3a8 |
printf("length argument cannot exceed %d, given %s\n",
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|