|
|
383d26 |
From 1180606c147edadc4a7979baae377fb983dc5fd2 Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Date: Fri, 22 Mar 2019 03:22:15 +0100
|
|
|
383d26 |
Subject: [PATCH 048/163] nbd/client: Fix error messages during
|
|
|
383d26 |
NBD_INFO_BLOCK_SIZE
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Message-id: <20190322032241.8111-3-jsnow@redhat.com>
|
|
|
383d26 |
Patchwork-id: 85091
|
|
|
383d26 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 02/28] nbd/client: Fix error messages during NBD_INFO_BLOCK_SIZE
|
|
|
383d26 |
Bugzilla: 1691563
|
|
|
383d26 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
From: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
A missing space makes for poor error messages, and sizes can't
|
|
|
383d26 |
go negative. Also, we missed diagnosing a server that sends
|
|
|
383d26 |
a maximum block size less than the minimum.
|
|
|
383d26 |
|
|
|
383d26 |
Fixes: 081dd1fe
|
|
|
383d26 |
CC: qemu-stable@nongnu.org
|
|
|
383d26 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
Message-Id: <20180501154654.943782-1-eblake@redhat.com>
|
|
|
383d26 |
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
383d26 |
(cherry picked from commit e475d108f1b3d3163f0affea67cdedbe5fc9752b)
|
|
|
383d26 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
nbd/client.c | 14 ++++++++++----
|
|
|
383d26 |
1 file changed, 10 insertions(+), 4 deletions(-)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/nbd/client.c b/nbd/client.c
|
|
|
383d26 |
index a151fa5..40b74d9 100644
|
|
|
383d26 |
--- a/nbd/client.c
|
|
|
383d26 |
+++ b/nbd/client.c
|
|
|
383d26 |
@@ -435,8 +435,8 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname,
|
|
|
383d26 |
}
|
|
|
383d26 |
be32_to_cpus(&info->min_block);
|
|
|
383d26 |
if (!is_power_of_2(info->min_block)) {
|
|
|
383d26 |
- error_setg(errp, "server minimum block size %" PRId32
|
|
|
383d26 |
- "is not a power of two", info->min_block);
|
|
|
383d26 |
+ error_setg(errp, "server minimum block size %" PRIu32
|
|
|
383d26 |
+ " is not a power of two", info->min_block);
|
|
|
383d26 |
nbd_send_opt_abort(ioc);
|
|
|
383d26 |
return -1;
|
|
|
383d26 |
}
|
|
|
383d26 |
@@ -450,8 +450,8 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname,
|
|
|
383d26 |
be32_to_cpus(&info->opt_block);
|
|
|
383d26 |
if (!is_power_of_2(info->opt_block) ||
|
|
|
383d26 |
info->opt_block < info->min_block) {
|
|
|
383d26 |
- error_setg(errp, "server preferred block size %" PRId32
|
|
|
383d26 |
- "is not valid", info->opt_block);
|
|
|
383d26 |
+ error_setg(errp, "server preferred block size %" PRIu32
|
|
|
383d26 |
+ " is not valid", info->opt_block);
|
|
|
383d26 |
nbd_send_opt_abort(ioc);
|
|
|
383d26 |
return -1;
|
|
|
383d26 |
}
|
|
|
383d26 |
@@ -462,6 +462,12 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname,
|
|
|
383d26 |
return -1;
|
|
|
383d26 |
}
|
|
|
383d26 |
be32_to_cpus(&info->max_block);
|
|
|
383d26 |
+ if (info->max_block < info->min_block) {
|
|
|
383d26 |
+ error_setg(errp, "server maximum block size %" PRIu32
|
|
|
383d26 |
+ " is not valid", info->max_block);
|
|
|
383d26 |
+ nbd_send_opt_abort(ioc);
|
|
|
383d26 |
+ return -1;
|
|
|
383d26 |
+ }
|
|
|
383d26 |
trace_nbd_opt_go_info_block_size(info->min_block, info->opt_block,
|
|
|
383d26 |
info->max_block);
|
|
|
383d26 |
break;
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|