diff mbox

blockdev: fix drive-mirror 'granularity' error message

Message ID 1409146199-12855-1-git-send-email-stefanha@redhat.com
State New
Headers show

Commit Message

Stefan Hajnoczi Aug. 27, 2014, 1:29 p.m. UTC
Name the 'granularity' parameter and give its expected value range.
Previously the device name was mistakingly reported as the parameter
name.

Note that the error class is unchanged from ERROR_CLASS_GENERIC_ERROR.

Reported-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 blockdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Eric Blake Aug. 27, 2014, 1:33 p.m. UTC | #1
On 08/27/2014 07:29 AM, Stefan Hajnoczi wrote:
> Name the 'granularity' parameter and give its expected value range.
> Previously the device name was mistakingly reported as the parameter

s/mistakingly/mistakenly/

> name.
> 
> Note that the error class is unchanged from ERROR_CLASS_GENERIC_ERROR.
> 
> Reported-by: Eric Blake <eblake@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  blockdev.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

buf-size has the same bug a few lines later; might as well fix both at once.

But what you have is a strict improvement, so depending on whether you
do a v2 to fix buf-size, vs. do a followup patch, you could add:

Reviewed-by: Eric Blake <eblake@redhat.com>
Benoît Canet Aug. 27, 2014, 2:12 p.m. UTC | #2
The Wednesday 27 Aug 2014 à 14:29:59 (+0100), Stefan Hajnoczi wrote :
> Name the 'granularity' parameter and give its expected value range.
> Previously the device name was mistakingly reported as the parameter
> name.
> 
> Note that the error class is unchanged from ERROR_CLASS_GENERIC_ERROR.
> 
> Reported-by: Eric Blake <eblake@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  blockdev.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 6a204c6..eeb414e 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -2179,11 +2179,12 @@ void qmp_drive_mirror(const char *device, const char *target,
>      }
>  
>      if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {
> -        error_set(errp, QERR_INVALID_PARAMETER, device);
> +        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
> +                  "a value in range [512B, 64MB]");
>          return;
>      }
>      if (granularity & (granularity - 1)) {
> -        error_set(errp, QERR_INVALID_PARAMETER, device);
> +        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "power of 2");
>          return;
>      }
>  
> -- 
> 1.9.3
> 
> 
Reviewed-by: Benoît Canet <benoit.canet@nodalink.com>
Stefan Hajnoczi Aug. 28, 2014, 12:28 p.m. UTC | #3
On Wed, Aug 27, 2014 at 02:29:59PM +0100, Stefan Hajnoczi wrote:
> Name the 'granularity' parameter and give its expected value range.
> Previously the device name was mistakingly reported as the parameter
> name.
> 
> Note that the error class is unchanged from ERROR_CLASS_GENERIC_ERROR.
> 
> Reported-by: Eric Blake <eblake@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  blockdev.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Fixed "mistakingly" -> "mistakenly" spelling error while merging.

Applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan
Stefan Hajnoczi Aug. 28, 2014, 12:29 p.m. UTC | #4
On Wed, Aug 27, 2014 at 07:33:13AM -0600, Eric Blake wrote:
> But what you have is a strict improvement, so depending on whether you
> do a v2 to fix buf-size, vs. do a followup patch, you could add:

Thanks, I will send a follow-up.

Stefan
Stefan Hajnoczi Aug. 28, 2014, 12:31 p.m. UTC | #5
On Wed, Aug 27, 2014 at 07:33:13AM -0600, Eric Blake wrote:
> buf-size has the same bug a few lines later; might as well fix both at once.

Hmm...which git tree are you looking at?

I don't see any error paths for buf_size:
http://git.qemu-project.org/?p=qemu.git;a=blob;f=blockdev.c;h=6a204c662d4b648c78a379f5b8e8120254dde479;hb=HEAD#l2140

Stefan
Eric Blake Aug. 28, 2014, 12:39 p.m. UTC | #6
On 08/28/2014 06:31 AM, Stefan Hajnoczi wrote:
> On Wed, Aug 27, 2014 at 07:33:13AM -0600, Eric Blake wrote:
>> buf-size has the same bug a few lines later; might as well fix both at once.
> 
> Hmm...which git tree are you looking at?

Serves me right for going off of a 'git grep' rather than actually
looking at the source.

> 
> I don't see any error paths for buf_size:
> http://git.qemu-project.org/?p=qemu.git;a=blob;f=blockdev.c;h=6a204c662d4b648c78a379f5b8e8120254dde479;hb=HEAD#l2140

I _knew_ I had seen two violations:

blockdev.c:2175:        error_set(errp, QERR_INVALID_PARAMETER, device);
blockdev.c:2179:        error_set(errp, QERR_INVALID_PARAMETER, device);

but based on that grep, I then _assumed_ that it was for two variables
(hence my claim of granularity vs. buf_size).  But as your patch fixes
both violations, both related to "granularity", you are correct.  Sorry
for spreading confusion.
diff mbox

Patch

diff --git a/blockdev.c b/blockdev.c
index 6a204c6..eeb414e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2179,11 +2179,12 @@  void qmp_drive_mirror(const char *device, const char *target,
     }
 
     if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {
-        error_set(errp, QERR_INVALID_PARAMETER, device);
+        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
+                  "a value in range [512B, 64MB]");
         return;
     }
     if (granularity & (granularity - 1)) {
-        error_set(errp, QERR_INVALID_PARAMETER, device);
+        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "power of 2");
         return;
     }