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