Skip to contentSkip to conversation

blockdev: fix drive-mirror 'granularity' error message

PATCH Applied Stefan Hajnoczi 4 participants 7 messages Aug 27, 2014 – Aug 28, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blockdev: fix drive-mirror 'granularity' error message

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.

---
 blockdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
blockdev.c +3 -2
index 6a204c6..eeb414e 100644
@@ -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;
     }
 
Signature · 1 line
1.9.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Stefan Hajnoczi

Name the 'granularity' parameter and give its expected value range. Previously the device name was mistakingly reported as the parameter

s/mistakingly/mistakenly/

Quoted 9 lines

name.

Note that the error class is unchanged from ERROR_CLASS_GENERIC_ERROR.

---
 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:

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Reviewed-by on v1 1/1
#5 lore raw
In reply to Stefan Hajnoczi
Quoted 35 lines · Stefan Hajnoczi

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.

---
 blockdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
blockdev.c +3 -2
index 6a204c6..eeb414e 100644
@@ -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;
     }
 
Signature · 1 line
1.9.3
#6 lore raw
In reply to Stefan Hajnoczi
Quoted 11 lines · Stefan Hajnoczi

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.

---
 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

#2 lore raw
In reply to Eric Blake
Quoted 2 lines · Eric Blake

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

#4 lore raw
Quoted 4 lines · Stefan Hajnoczi
Quoted 1 line · Eric Blake

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.

Quoted 3 lines

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.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org