All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] nbd/client: Fix error messages during NBD_INFO_BLOCK_SIZE
@ 2018-05-01 15:46 Eric Blake
  2018-05-01 15:55 ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Blake @ 2018-05-01 15:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: vsementsov, qemu-stable, Paolo Bonzini, open list:Network Block Dev...

A missing space makes for poor error messages.  Also, we missed
diagnosing a server that sends a maximum block size less than
the minimum.

Fixes: 081dd1fe
CC: qemu-stable@nongnu.org
Signed-off-by: Eric Blake <eblake@redhat.com>
---
 nbd/client.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/nbd/client.c b/nbd/client.c
index 7f35b5c3232..7b3caa90ec2 100644
--- a/nbd/client.c
+++ b/nbd/client.c
@@ -436,7 +436,7 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname,
             be32_to_cpus(&info->min_block);
             if (!is_power_of_2(info->min_block)) {
                 error_setg(errp, "server minimum block size %" PRId32
-                           "is not a power of two", info->min_block);
+                           " is not a power of two", info->min_block);
                 nbd_send_opt_abort(ioc);
                 return -1;
             }
@@ -451,7 +451,7 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname,
             if (!is_power_of_2(info->opt_block) ||
                 info->opt_block < info->min_block) {
                 error_setg(errp, "server preferred block size %" PRId32
-                           "is not valid", info->opt_block);
+                           " is not valid", info->opt_block);
                 nbd_send_opt_abort(ioc);
                 return -1;
             }
@@ -462,6 +462,12 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname,
                 return -1;
             }
             be32_to_cpus(&info->max_block);
+            if (info->max_block < info->min_block) {
+                error_setg(errp, "server maximum block size %" PRId32
+                           " is not valid", info->max_block);
+                nbd_send_opt_abort(ioc);
+                return -1;
+            }
             trace_nbd_opt_go_info_block_size(info->min_block, info->opt_block,
                                              info->max_block);
             break;
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] nbd/client: Fix error messages during NBD_INFO_BLOCK_SIZE
  2018-05-01 15:46 [Qemu-devel] [PATCH] nbd/client: Fix error messages during NBD_INFO_BLOCK_SIZE Eric Blake
@ 2018-05-01 15:55 ` Vladimir Sementsov-Ogievskiy
  2018-05-01 20:15   ` Eric Blake
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2018-05-01 15:55 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: qemu-stable, Paolo Bonzini, open list:Network Block Dev...

01.05.2018 18:46, Eric Blake wrote:
> A missing space makes for poor error messages.  Also, we missed
> diagnosing a server that sends a maximum block size less than
> the minimum.
>
> Fixes: 081dd1fe
> CC: qemu-stable@nongnu.org
> Signed-off-by: Eric Blake <eblake@redhat.com>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

> ---
>   nbd/client.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/nbd/client.c b/nbd/client.c
> index 7f35b5c3232..7b3caa90ec2 100644
> --- a/nbd/client.c
> +++ b/nbd/client.c
> @@ -436,7 +436,7 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname,
>               be32_to_cpus(&info->min_block);
>               if (!is_power_of_2(info->min_block)) {
>                   error_setg(errp, "server minimum block size %" PRId32
> -                           "is not a power of two", info->min_block);
> +                           " is not a power of two", info->min_block);
>                   nbd_send_opt_abort(ioc);
>                   return -1;
>               }
> @@ -451,7 +451,7 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname,
>               if (!is_power_of_2(info->opt_block) ||
>                   info->opt_block < info->min_block) {
>                   error_setg(errp, "server preferred block size %" PRId32
> -                           "is not valid", info->opt_block);
> +                           " is not valid", info->opt_block);
>                   nbd_send_opt_abort(ioc);
>                   return -1;
>               }
> @@ -462,6 +462,12 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname,
>                   return -1;
>               }
>               be32_to_cpus(&info->max_block);
> +            if (info->max_block < info->min_block) {
> +                error_setg(errp, "server maximum block size %" PRId32
> +                           " is not valid", info->max_block);
> +                nbd_send_opt_abort(ioc);
> +                return -1;
> +            }
>               trace_nbd_opt_go_info_block_size(info->min_block, info->opt_block,
>                                                info->max_block);
>               break;


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] nbd/client: Fix error messages during NBD_INFO_BLOCK_SIZE
  2018-05-01 15:55 ` Vladimir Sementsov-Ogievskiy
@ 2018-05-01 20:15   ` Eric Blake
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Blake @ 2018-05-01 20:15 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: qemu-stable, Paolo Bonzini, open list:Network Block Dev...

On 05/01/2018 10:55 AM, Vladimir Sementsov-Ogievskiy wrote:
> 01.05.2018 18:46, Eric Blake wrote:
>> A missing space makes for poor error messages.  Also, we missed
>> diagnosing a server that sends a maximum block size less than
>> the minimum.
>>
>> Fixes: 081dd1fe
>> CC: qemu-stable@nongnu.org
>> Signed-off-by: Eric Blake <eblake@redhat.com>
> 
> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> 
>> ---
>>   nbd/client.c | 10 ++++++++--
>>   1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/nbd/client.c b/nbd/client.c
>> index 7f35b5c3232..7b3caa90ec2 100644
>> --- a/nbd/client.c
>> +++ b/nbd/client.c
>> @@ -436,7 +436,7 @@ static int nbd_opt_go(QIOChannel *ioc, const char 
>> *wantname,
>>               be32_to_cpus(&info->min_block);
>>               if (!is_power_of_2(info->min_block)) {
>>                   error_setg(errp, "server minimum block size %" PRId32
>> -                           "is not a power of two", info->min_block);
>> +                           " is not a power of two", info->min_block);

One more tweak: PRIu32 is better than PRId32, as block sizes cannot go 
negative.  I'm squashing that in, then staging this on my NBD queue.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-01 20:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-01 15:46 [Qemu-devel] [PATCH] nbd/client: Fix error messages during NBD_INFO_BLOCK_SIZE Eric Blake
2018-05-01 15:55 ` Vladimir Sementsov-Ogievskiy
2018-05-01 20:15   ` Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.