qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-trivial] [PATCH v2 0/2] block/vhdx: Use IEC binary prefixes from "qemu/units.h"
@ 2019-03-27  9:56 Stefano Garzarella
  2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition Stefano Garzarella
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Stefano Garzarella @ 2019-03-27  9:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Max Reitz, John Snow, qemu-trivial, Jeff Cody, qemu-block,
	Philippe Mathieu-Daudé, Kevin Wolf

v2:
- Included units.h directly in the vhdx.h header file (John, Philippe)
- Added a comment next to DEFAULT_LOG_SIZE definition (Kevin)
- Added a second patch where I fixed some size constants using IEC
  binary prefixes.
  Note: checkpatch is not happy about a change in vhdx.h but all the comments
  in that file doesn't respect the new coding style so I left the comment as is

Stefano Garzarella (2):
  block/vhdx: Remove redundant IEC binary prefixes definition
  block/vhdx: Use IEC binary prefixes for size constants

 block/vhdx-log.c |  2 +-
 block/vhdx.c     |  7 ++++---
 block/vhdx.h     | 16 +++++++---------
 3 files changed, 12 insertions(+), 13 deletions(-)

-- 
2.20.1



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

* [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition
  2019-03-27  9:56 [Qemu-trivial] [PATCH v2 0/2] block/vhdx: Use IEC binary prefixes from "qemu/units.h" Stefano Garzarella
@ 2019-03-27  9:56 ` Stefano Garzarella
  2019-03-27 12:40   ` Philippe Mathieu-Daudé
                     ` (2 more replies)
  2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 2/2] block/vhdx: Use IEC binary prefixes for size constants Stefano Garzarella
  2019-03-28 12:29 ` [Qemu-trivial] [PATCH v2 0/2] block/vhdx: Use IEC binary prefixes from "qemu/units.h" Kevin Wolf
  2 siblings, 3 replies; 12+ messages in thread
From: Stefano Garzarella @ 2019-03-27  9:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Max Reitz, John Snow, qemu-trivial, Jeff Cody, qemu-block,
	Philippe Mathieu-Daudé, Kevin Wolf

IEC binary prefixes are already defined in "qemu/units.h",
so we can remove redundant definitions in "block/vhdx.h".

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
 block/vhdx.c | 3 ++-
 block/vhdx.h | 6 +-----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/block/vhdx.c b/block/vhdx.c
index b785aef4b7..7cd1fc3731 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -1889,7 +1889,8 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,
         return -EINVAL;
     }
     if (block_size > VHDX_BLOCK_SIZE_MAX) {
-        error_setg(errp, "Block size must not exceed %d", VHDX_BLOCK_SIZE_MAX);
+        error_setg(errp, "Block size must not exceed %" PRId64,
+                   VHDX_BLOCK_SIZE_MAX);
         return -EINVAL;
     }
 
diff --git a/block/vhdx.h b/block/vhdx.h
index 1bfb4e4f73..bf72090c8f 100644
--- a/block/vhdx.h
+++ b/block/vhdx.h
@@ -17,11 +17,7 @@
 
 #ifndef BLOCK_VHDX_H
 #define BLOCK_VHDX_H
-
-#define KiB              (1 * 1024)
-#define MiB            (KiB * 1024)
-#define GiB            (MiB * 1024)
-#define TiB ((uint64_t) GiB * 1024)
+#include "qemu/units.h"
 
 #define DEFAULT_LOG_SIZE 1048576 /* 1MiB */
 /* Structures and fields present in the VHDX file */
-- 
2.20.1



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

* [Qemu-trivial] [PATCH v2 2/2] block/vhdx: Use IEC binary prefixes for size constants
  2019-03-27  9:56 [Qemu-trivial] [PATCH v2 0/2] block/vhdx: Use IEC binary prefixes from "qemu/units.h" Stefano Garzarella
  2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition Stefano Garzarella
@ 2019-03-27  9:56 ` Stefano Garzarella
  2019-03-27 12:39   ` Philippe Mathieu-Daudé
  2019-03-27 17:17   ` [Qemu-trivial] [Qemu-devel] " John Snow
  2019-03-28 12:29 ` [Qemu-trivial] [PATCH v2 0/2] block/vhdx: Use IEC binary prefixes from "qemu/units.h" Kevin Wolf
  2 siblings, 2 replies; 12+ messages in thread
From: Stefano Garzarella @ 2019-03-27  9:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Max Reitz, John Snow, qemu-trivial, Jeff Cody, qemu-block,
	Philippe Mathieu-Daudé, Kevin Wolf

Using IEC binary prefixes in order to make the code more readable,
with the exception of DEFAULT_LOG_SIZE because it's passed to
stringify().

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
 block/vhdx-log.c |  2 +-
 block/vhdx.c     |  4 ++--
 block/vhdx.h     | 10 ++++++----
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index 3149ff08d8..5e946846f1 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -551,7 +551,7 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVHDXState *s,
         }
         if (file_length < desc_entries->hdr.last_file_offset) {
             new_file_size = desc_entries->hdr.last_file_offset;
-            if (new_file_size % (1024*1024)) {
+            if (new_file_size % (1 * MiB)) {
                 /* round up to nearest 1MB boundary */
                 new_file_size = QEMU_ALIGN_UP(new_file_size, MiB);
                 if (new_file_size > INT64_MAX) {
diff --git a/block/vhdx.c b/block/vhdx.c
index 7cd1fc3731..a143a57657 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -1175,7 +1175,7 @@ static int vhdx_allocate_block(BlockDriverState *bs, BDRVVHDXState *s,
     *new_offset = current_len;
 
     /* per the spec, the address for a block is in units of 1MB */
-    *new_offset = ROUND_UP(*new_offset, 1024 * 1024);
+    *new_offset = ROUND_UP(*new_offset, 1 * MiB);
     if (*new_offset > INT64_MAX) {
         return -EINVAL;
     }
@@ -1338,7 +1338,7 @@ static coroutine_fn int vhdx_co_writev(BlockDriverState *bs, int64_t sector_num,
             case PAYLOAD_BLOCK_FULLY_PRESENT:
                 /* if the file offset address is in the header zone,
                  * there is a problem */
-                if (sinfo.file_offset < (1024 * 1024)) {
+                if (sinfo.file_offset < (1 * MiB)) {
                     ret = -EFAULT;
                     goto error_bat_restore;
                 }
diff --git a/block/vhdx.h b/block/vhdx.h
index bf72090c8f..0b74924cee 100644
--- a/block/vhdx.h
+++ b/block/vhdx.h
@@ -20,6 +20,8 @@
 #include "qemu/units.h"
 
 #define DEFAULT_LOG_SIZE 1048576 /* 1MiB */
+/* Note: can't use 1 * MiB, because it's passed to stringify() */
+
 /* Structures and fields present in the VHDX file */
 
 /* The header section has the following blocks,
@@ -32,7 +34,7 @@
  * 0.........64KB...........128KB........192KB..........256KB................1MB
  */
 
-#define VHDX_HEADER_BLOCK_SIZE      (64 * 1024)
+#define VHDX_HEADER_BLOCK_SIZE      (64 * KiB)
 
 #define VHDX_FILE_ID_OFFSET         0
 #define VHDX_HEADER1_OFFSET         (VHDX_HEADER_BLOCK_SIZE * 1)
@@ -81,7 +83,7 @@ typedef struct QEMU_PACKED MSGUID {
 #define guid_eq(a, b) \
     (memcmp(&(a), &(b), sizeof(MSGUID)) == 0)
 
-#define VHDX_HEADER_SIZE (4 * 1024)   /* although the vhdx_header struct in disk
+#define VHDX_HEADER_SIZE (4 * KiB)    /* although the vhdx_header struct in disk
                                          is only 582 bytes, for purposes of crc
                                          the header is the first 4KB of the 64KB
                                          block */
@@ -157,8 +159,8 @@ typedef struct QEMU_PACKED VHDXRegionTableEntry {
 
 
 /* ---- LOG ENTRY STRUCTURES ---- */
-#define VHDX_LOG_MIN_SIZE (1024 * 1024)
-#define VHDX_LOG_SECTOR_SIZE 4096
+#define VHDX_LOG_MIN_SIZE (1 * MiB)
+#define VHDX_LOG_SECTOR_SIZE (4 * KiB)
 #define VHDX_LOG_HDR_SIZE 64
 #define VHDX_LOG_SIGNATURE 0x65676f6c
 typedef struct QEMU_PACKED VHDXLogEntryHeader {
-- 
2.20.1



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

* Re: [Qemu-trivial] [PATCH v2 2/2] block/vhdx: Use IEC binary prefixes for size constants
  2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 2/2] block/vhdx: Use IEC binary prefixes for size constants Stefano Garzarella
@ 2019-03-27 12:39   ` Philippe Mathieu-Daudé
  2019-03-27 17:17   ` [Qemu-trivial] [Qemu-devel] " John Snow
  1 sibling, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-03-27 12:39 UTC (permalink / raw)
  To: Stefano Garzarella
  Cc: qemu-devel@nongnu.org Developers, Max Reitz, John Snow,
	qemu-trivial, Jeff Cody, qemu-block, Kevin Wolf

[-- Attachment #1: Type: text/plain, Size: 3938 bytes --]

Le mer. 27 mars 2019 10:56, Stefano Garzarella <sgarzare@redhat.com> a
écrit :

> Using IEC binary prefixes in order to make the code more readable,
> with the exception of DEFAULT_LOG_SIZE because it's passed to
> stringify().
>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
>  block/vhdx-log.c |  2 +-
>  block/vhdx.c     |  4 ++--
>  block/vhdx.h     | 10 ++++++----
>  3 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/block/vhdx-log.c b/block/vhdx-log.c
> index 3149ff08d8..5e946846f1 100644
> --- a/block/vhdx-log.c
> +++ b/block/vhdx-log.c
> @@ -551,7 +551,7 @@ static int vhdx_log_flush(BlockDriverState *bs,
> BDRVVHDXState *s,
>          }
>          if (file_length < desc_entries->hdr.last_file_offset) {
>              new_file_size = desc_entries->hdr.last_file_offset;
> -            if (new_file_size % (1024*1024)) {
> +            if (new_file_size % (1 * MiB)) {
>                  /* round up to nearest 1MB boundary */
>                  new_file_size = QEMU_ALIGN_UP(new_file_size, MiB);
>                  if (new_file_size > INT64_MAX) {
> diff --git a/block/vhdx.c b/block/vhdx.c
> index 7cd1fc3731..a143a57657 100644
> --- a/block/vhdx.c
> +++ b/block/vhdx.c
> @@ -1175,7 +1175,7 @@ static int vhdx_allocate_block(BlockDriverState *bs,
> BDRVVHDXState *s,
>      *new_offset = current_len;
>
>      /* per the spec, the address for a block is in units of 1MB */
> -    *new_offset = ROUND_UP(*new_offset, 1024 * 1024);
> +    *new_offset = ROUND_UP(*new_offset, 1 * MiB);
>      if (*new_offset > INT64_MAX) {
>          return -EINVAL;
>      }
> @@ -1338,7 +1338,7 @@ static coroutine_fn int
> vhdx_co_writev(BlockDriverState *bs, int64_t sector_num,
>              case PAYLOAD_BLOCK_FULLY_PRESENT:
>                  /* if the file offset address is in the header zone,
>                   * there is a problem */
> -                if (sinfo.file_offset < (1024 * 1024)) {
> +                if (sinfo.file_offset < (1 * MiB)) {
>                      ret = -EFAULT;
>                      goto error_bat_restore;
>                  }
> diff --git a/block/vhdx.h b/block/vhdx.h
> index bf72090c8f..0b74924cee 100644
> --- a/block/vhdx.h
> +++ b/block/vhdx.h
> @@ -20,6 +20,8 @@
>  #include "qemu/units.h"
>
>  #define DEFAULT_LOG_SIZE 1048576 /* 1MiB */
> +/* Note: can't use 1 * MiB, because it's passed to stringify() */
> +
>  /* Structures and fields present in the VHDX file */
>
>  /* The header section has the following blocks,
> @@ -32,7 +34,7 @@
>   *
> 0.........64KB...........128KB........192KB..........256KB................1MB
>   */
>
> -#define VHDX_HEADER_BLOCK_SIZE      (64 * 1024)
> +#define VHDX_HEADER_BLOCK_SIZE      (64 * KiB)
>
>  #define VHDX_FILE_ID_OFFSET         0
>  #define VHDX_HEADER1_OFFSET         (VHDX_HEADER_BLOCK_SIZE * 1)
> @@ -81,7 +83,7 @@ typedef struct QEMU_PACKED MSGUID {
>  #define guid_eq(a, b) \
>      (memcmp(&(a), &(b), sizeof(MSGUID)) == 0)
>
> -#define VHDX_HEADER_SIZE (4 * 1024)   /* although the vhdx_header struct
> in disk
> +#define VHDX_HEADER_SIZE (4 * KiB)    /* although the vhdx_header struct
> in disk
>                                           is only 582 bytes, for purposes
> of crc
>                                           the header is the first 4KB of
> the 64KB
>                                           block */
> @@ -157,8 +159,8 @@ typedef struct QEMU_PACKED VHDXRegionTableEntry {
>
>
>  /* ---- LOG ENTRY STRUCTURES ---- */
> -#define VHDX_LOG_MIN_SIZE (1024 * 1024)
> -#define VHDX_LOG_SECTOR_SIZE 4096
> +#define VHDX_LOG_MIN_SIZE (1 * MiB)
> +#define VHDX_LOG_SECTOR_SIZE (4 * KiB)
>  #define VHDX_LOG_HDR_SIZE 64
>  #define VHDX_LOG_SIGNATURE 0x65676f6c
>  typedef struct QEMU_PACKED VHDXLogEntryHeader {
> -- 2.20.1
>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

>

[-- Attachment #2: Type: text/html, Size: 4999 bytes --]

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

* Re: [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition
  2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition Stefano Garzarella
@ 2019-03-27 12:40   ` Philippe Mathieu-Daudé
  2019-03-27 17:16   ` John Snow
  2019-04-11 19:54   ` [Qemu-trivial] " Laurent Vivier
  2 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-03-27 12:40 UTC (permalink / raw)
  To: Stefano Garzarella
  Cc: qemu-devel@nongnu.org Developers, Max Reitz, John Snow,
	qemu-trivial, Jeff Cody, qemu-block, Kevin Wolf

[-- Attachment #1: Type: text/plain, Size: 1520 bytes --]

Le mer. 27 mars 2019 10:56, Stefano Garzarella <sgarzare@redhat.com> a
écrit :

> IEC binary prefixes are already defined in "qemu/units.h",
> so we can remove redundant definitions in "block/vhdx.h".
>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
>  block/vhdx.c | 3 ++-
>  block/vhdx.h | 6 +-----
>  2 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/block/vhdx.c b/block/vhdx.c
> index b785aef4b7..7cd1fc3731 100644
> --- a/block/vhdx.c
> +++ b/block/vhdx.c
> @@ -1889,7 +1889,8 @@ static int coroutine_fn
> vhdx_co_create(BlockdevCreateOptions *opts,
>          return -EINVAL;
>      }
>      if (block_size > VHDX_BLOCK_SIZE_MAX) {
> -        error_setg(errp, "Block size must not exceed %d",
> VHDX_BLOCK_SIZE_MAX);
> +        error_setg(errp, "Block size must not exceed %" PRId64,
> +                   VHDX_BLOCK_SIZE_MAX);
>          return -EINVAL;
>      }
>
> diff --git a/block/vhdx.h b/block/vhdx.h
> index 1bfb4e4f73..bf72090c8f 100644
> --- a/block/vhdx.h
> +++ b/block/vhdx.h
> @@ -17,11 +17,7 @@
>
>  #ifndef BLOCK_VHDX_H
>  #define BLOCK_VHDX_H
> -
> -#define KiB              (1 * 1024)
> -#define MiB            (KiB * 1024)
> -#define GiB            (MiB * 1024)
> -#define TiB ((uint64_t) GiB * 1024)
> +#include "qemu/units.h"
>
>  #define DEFAULT_LOG_SIZE 1048576 /* 1MiB */
>  /* Structures and fields present in the VHDX file */
> --
> 2.20.1
>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

>

[-- Attachment #2: Type: text/html, Size: 2308 bytes --]

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

* Re: [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition
  2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition Stefano Garzarella
  2019-03-27 12:40   ` Philippe Mathieu-Daudé
@ 2019-03-27 17:16   ` John Snow
  2019-03-27 17:23     ` Stefano Garzarella
  2019-03-27 20:16     ` [Qemu-trivial] [Qemu-devel] " Philippe Mathieu-Daudé
  2019-04-11 19:54   ` [Qemu-trivial] " Laurent Vivier
  2 siblings, 2 replies; 12+ messages in thread
From: John Snow @ 2019-03-27 17:16 UTC (permalink / raw)
  To: Stefano Garzarella, qemu-devel
  Cc: Max Reitz, qemu-trivial, Jeff Cody, qemu-block,
	Philippe Mathieu-Daudé, Kevin Wolf



On 3/27/19 5:56 AM, Stefano Garzarella wrote:
> IEC binary prefixes are already defined in "qemu/units.h",
> so we can remove redundant definitions in "block/vhdx.h".
> 
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
>  block/vhdx.c | 3 ++-
>  block/vhdx.h | 6 +-----
>  2 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/block/vhdx.c b/block/vhdx.c
> index b785aef4b7..7cd1fc3731 100644
> --- a/block/vhdx.c
> +++ b/block/vhdx.c
> @@ -1889,7 +1889,8 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,
>          return -EINVAL;
>      }
>      if (block_size > VHDX_BLOCK_SIZE_MAX) {
> -        error_setg(errp, "Block size must not exceed %d", VHDX_BLOCK_SIZE_MAX);
> +        error_setg(errp, "Block size must not exceed %" PRId64,
> +                   VHDX_BLOCK_SIZE_MAX);
>          return -EINVAL;
>      }
>  
> diff --git a/block/vhdx.h b/block/vhdx.h
> index 1bfb4e4f73..bf72090c8f 100644
> --- a/block/vhdx.h
> +++ b/block/vhdx.h
> @@ -17,11 +17,7 @@
>  
>  #ifndef BLOCK_VHDX_H
>  #define BLOCK_VHDX_H
> -
> -#define KiB              (1 * 1024)
> -#define MiB            (KiB * 1024)
> -#define GiB            (MiB * 1024)
> -#define TiB ((uint64_t) GiB * 1024)
> +#include "qemu/units.h"
>  
>  #define DEFAULT_LOG_SIZE 1048576 /* 1MiB */
>  /* Structures and fields present in the VHDX file */
> 

Looks good. By the way, you may want to consider adding to your git
config rules that put the .h file diff changes above the .c file.

Look at qemu/scripts/git.orderfile

(I know I'm one to talk, I still haven't set mine up...)

Reviewed-by: John Snow <jsnow@redhat.com>


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

* Re: [Qemu-trivial] [Qemu-devel] [PATCH v2 2/2] block/vhdx: Use IEC binary prefixes for size constants
  2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 2/2] block/vhdx: Use IEC binary prefixes for size constants Stefano Garzarella
  2019-03-27 12:39   ` Philippe Mathieu-Daudé
@ 2019-03-27 17:17   ` John Snow
  1 sibling, 0 replies; 12+ messages in thread
From: John Snow @ 2019-03-27 17:17 UTC (permalink / raw)
  To: Stefano Garzarella, qemu-devel
  Cc: Kevin Wolf, qemu-block, qemu-trivial, Philippe Mathieu-Daudé,
	Max Reitz, Jeff Cody



On 3/27/19 5:56 AM, Stefano Garzarella wrote:
> Using IEC binary prefixes in order to make the code more readable,
> with the exception of DEFAULT_LOG_SIZE because it's passed to
> stringify().
> 
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>

Looks good to me;

Reviewed-by: John Snow <jsnow@redhat.com>


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

* Re: [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition
  2019-03-27 17:16   ` John Snow
@ 2019-03-27 17:23     ` Stefano Garzarella
  2019-03-27 20:16     ` [Qemu-trivial] [Qemu-devel] " Philippe Mathieu-Daudé
  1 sibling, 0 replies; 12+ messages in thread
From: Stefano Garzarella @ 2019-03-27 17:23 UTC (permalink / raw)
  To: John Snow
  Cc: qemu-devel, Max Reitz, qemu-trivial, Jeff Cody, qemu-block,
	Philippe Mathieu-Daudé, Kevin Wolf

On Wed, Mar 27, 2019 at 01:16:49PM -0400, John Snow wrote:
> 
> 
> On 3/27/19 5:56 AM, Stefano Garzarella wrote:
> > IEC binary prefixes are already defined in "qemu/units.h",
> > so we can remove redundant definitions in "block/vhdx.h".
> > 
> > Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> > ---
> >  block/vhdx.c | 3 ++-
> >  block/vhdx.h | 6 +-----
> >  2 files changed, 3 insertions(+), 6 deletions(-)
> > 
> > diff --git a/block/vhdx.c b/block/vhdx.c
> > index b785aef4b7..7cd1fc3731 100644
> > --- a/block/vhdx.c
> > +++ b/block/vhdx.c
> > @@ -1889,7 +1889,8 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,
> >          return -EINVAL;
> >      }
> >      if (block_size > VHDX_BLOCK_SIZE_MAX) {
> > -        error_setg(errp, "Block size must not exceed %d", VHDX_BLOCK_SIZE_MAX);
> > +        error_setg(errp, "Block size must not exceed %" PRId64,
> > +                   VHDX_BLOCK_SIZE_MAX);
> >          return -EINVAL;
> >      }
> >  
> > diff --git a/block/vhdx.h b/block/vhdx.h
> > index 1bfb4e4f73..bf72090c8f 100644
> > --- a/block/vhdx.h
> > +++ b/block/vhdx.h
> > @@ -17,11 +17,7 @@
> >  
> >  #ifndef BLOCK_VHDX_H
> >  #define BLOCK_VHDX_H
> > -
> > -#define KiB              (1 * 1024)
> > -#define MiB            (KiB * 1024)
> > -#define GiB            (MiB * 1024)
> > -#define TiB ((uint64_t) GiB * 1024)
> > +#include "qemu/units.h"
> >  
> >  #define DEFAULT_LOG_SIZE 1048576 /* 1MiB */
> >  /* Structures and fields present in the VHDX file */
> > 
> 
> Looks good. By the way, you may want to consider adding to your git
> config rules that put the .h file diff changes above the .c file.
> 
> Look at qemu/scripts/git.orderfile

Thank you very much! It is very useful!

> 
> (I know I'm one to talk, I still haven't set mine up...)

:)

> 
> Reviewed-by: John Snow <jsnow@redhat.com>

Thanks,
Stefano


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

* Re: [Qemu-trivial] [Qemu-devel] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition
  2019-03-27 17:16   ` John Snow
  2019-03-27 17:23     ` Stefano Garzarella
@ 2019-03-27 20:16     ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-03-27 20:16 UTC (permalink / raw)
  To: John Snow
  Cc: Stefano Garzarella, qemu-devel@nongnu.org Developers, Kevin Wolf,
	qemu-block, qemu-trivial, Max Reitz, Jeff Cody

[-- Attachment #1: Type: text/plain, Size: 1876 bytes --]

Le mer. 27 mars 2019 18:18, John Snow <jsnow@redhat.com> a écrit :

>
>
> On 3/27/19 5:56 AM, Stefano Garzarella wrote:
> > IEC binary prefixes are already defined in "qemu/units.h",
> > so we can remove redundant definitions in "block/vhdx.h".
> >
> > Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> > ---
> >  block/vhdx.c | 3 ++-
> >  block/vhdx.h | 6 +-----
> >  2 files changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/block/vhdx.c b/block/vhdx.c
> > index b785aef4b7..7cd1fc3731 100644
> > --- a/block/vhdx.c
> > +++ b/block/vhdx.c
> > @@ -1889,7 +1889,8 @@ static int coroutine_fn
> vhdx_co_create(BlockdevCreateOptions *opts,
> >          return -EINVAL;
> >      }
> >      if (block_size > VHDX_BLOCK_SIZE_MAX) {
> > -        error_setg(errp, "Block size must not exceed %d",
> VHDX_BLOCK_SIZE_MAX);
> > +        error_setg(errp, "Block size must not exceed %" PRId64,
> > +                   VHDX_BLOCK_SIZE_MAX);
> >          return -EINVAL;
> >      }
> >
> > diff --git a/block/vhdx.h b/block/vhdx.h
> > index 1bfb4e4f73..bf72090c8f 100644
> > --- a/block/vhdx.h
> > +++ b/block/vhdx.h
> > @@ -17,11 +17,7 @@
> >
> >  #ifndef BLOCK_VHDX_H
> >  #define BLOCK_VHDX_H
> > -
> > -#define KiB              (1 * 1024)
> > -#define MiB            (KiB * 1024)
> > -#define GiB            (MiB * 1024)
> > -#define TiB ((uint64_t) GiB * 1024)
> > +#include "qemu/units.h"
> >
> >  #define DEFAULT_LOG_SIZE 1048576 /* 1MiB */
> >  /* Structures and fields present in the VHDX file */
> >
>
> Looks good. By the way, you may want to consider adding to your git
> config rules that put the .h file diff changes above the .c file.
>
> Look at qemu/scripts/git.orderfile
>
> (I know I'm one to talk, I still haven't set mine up...)
>

=)


> Reviewed-by: John Snow <jsnow@redhat.com>
>
>

[-- Attachment #2: Type: text/html, Size: 2887 bytes --]

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

* Re: [Qemu-trivial] [PATCH v2 0/2] block/vhdx: Use IEC binary prefixes from "qemu/units.h"
  2019-03-27  9:56 [Qemu-trivial] [PATCH v2 0/2] block/vhdx: Use IEC binary prefixes from "qemu/units.h" Stefano Garzarella
  2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition Stefano Garzarella
  2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 2/2] block/vhdx: Use IEC binary prefixes for size constants Stefano Garzarella
@ 2019-03-28 12:29 ` Kevin Wolf
  2 siblings, 0 replies; 12+ messages in thread
From: Kevin Wolf @ 2019-03-28 12:29 UTC (permalink / raw)
  To: Stefano Garzarella
  Cc: qemu-devel, Max Reitz, John Snow, qemu-trivial, Jeff Cody,
	qemu-block, Philippe Mathieu-Daudé

Am 27.03.2019 um 10:56 hat Stefano Garzarella geschrieben:
> v2:
> - Included units.h directly in the vhdx.h header file (John, Philippe)
> - Added a comment next to DEFAULT_LOG_SIZE definition (Kevin)
> - Added a second patch where I fixed some size constants using IEC
>   binary prefixes.
>   Note: checkpatch is not happy about a change in vhdx.h but all the comments
>   in that file doesn't respect the new coding style so I left the comment as is

Thanks, applied to the block-next branch for 4.1.

Kevin


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

* Re: [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition
  2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition Stefano Garzarella
  2019-03-27 12:40   ` Philippe Mathieu-Daudé
  2019-03-27 17:16   ` John Snow
@ 2019-04-11 19:54   ` Laurent Vivier
  2019-04-11 19:55     ` Laurent Vivier
  2 siblings, 1 reply; 12+ messages in thread
From: Laurent Vivier @ 2019-04-11 19:54 UTC (permalink / raw)
  To: Stefano Garzarella, qemu-devel
  Cc: Kevin Wolf, qemu-block, qemu-trivial, Philippe Mathieu-Daudé,
	Max Reitz, Jeff Cody, John Snow

On 27/03/2019 10:56, Stefano Garzarella wrote:
> IEC binary prefixes are already defined in "qemu/units.h",
> so we can remove redundant definitions in "block/vhdx.h".
> 
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
>  block/vhdx.c | 3 ++-
>  block/vhdx.h | 6 +-----
>  2 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/block/vhdx.c b/block/vhdx.c
> index b785aef4b7..7cd1fc3731 100644
> --- a/block/vhdx.c
> +++ b/block/vhdx.c
> @@ -1889,7 +1889,8 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,
>          return -EINVAL;
>      }
>      if (block_size > VHDX_BLOCK_SIZE_MAX) {
> -        error_setg(errp, "Block size must not exceed %d", VHDX_BLOCK_SIZE_MAX);
> +        error_setg(errp, "Block size must not exceed %" PRId64,
> +                   VHDX_BLOCK_SIZE_MAX);
>          return -EINVAL;
>      }
>  
> diff --git a/block/vhdx.h b/block/vhdx.h
> index 1bfb4e4f73..bf72090c8f 100644
> --- a/block/vhdx.h
> +++ b/block/vhdx.h
> @@ -17,11 +17,7 @@
>  
>  #ifndef BLOCK_VHDX_H
>  #define BLOCK_VHDX_H
> -
> -#define KiB              (1 * 1024)
> -#define MiB            (KiB * 1024)
> -#define GiB            (MiB * 1024)
> -#define TiB ((uint64_t) GiB * 1024)
> +#include "qemu/units.h"
>  
>  #define DEFAULT_LOG_SIZE 1048576 /* 1MiB */
>  /* Structures and fields present in the VHDX file */
> 

Applied to my trivial-patches branch.

Thanks,
Laurent


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

* Re: [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition
  2019-04-11 19:54   ` [Qemu-trivial] " Laurent Vivier
@ 2019-04-11 19:55     ` Laurent Vivier
  0 siblings, 0 replies; 12+ messages in thread
From: Laurent Vivier @ 2019-04-11 19:55 UTC (permalink / raw)
  To: Stefano Garzarella, qemu-devel
  Cc: Kevin Wolf, qemu-block, qemu-trivial, Philippe Mathieu-Daudé,
	Max Reitz, Jeff Cody, John Snow

On 11/04/2019 21:54, Laurent Vivier wrote:
> On 27/03/2019 10:56, Stefano Garzarella wrote:
>> IEC binary prefixes are already defined in "qemu/units.h",
>> so we can remove redundant definitions in "block/vhdx.h".
>>
>> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
>> ---
>>  block/vhdx.c | 3 ++-
>>  block/vhdx.h | 6 +-----
>>  2 files changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/block/vhdx.c b/block/vhdx.c
>> index b785aef4b7..7cd1fc3731 100644
>> --- a/block/vhdx.c
>> +++ b/block/vhdx.c
>> @@ -1889,7 +1889,8 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,
>>          return -EINVAL;
>>      }
>>      if (block_size > VHDX_BLOCK_SIZE_MAX) {
>> -        error_setg(errp, "Block size must not exceed %d", VHDX_BLOCK_SIZE_MAX);
>> +        error_setg(errp, "Block size must not exceed %" PRId64,
>> +                   VHDX_BLOCK_SIZE_MAX);
>>          return -EINVAL;
>>      }
>>  
>> diff --git a/block/vhdx.h b/block/vhdx.h
>> index 1bfb4e4f73..bf72090c8f 100644
>> --- a/block/vhdx.h
>> +++ b/block/vhdx.h
>> @@ -17,11 +17,7 @@
>>  
>>  #ifndef BLOCK_VHDX_H
>>  #define BLOCK_VHDX_H
>> -
>> -#define KiB              (1 * 1024)
>> -#define MiB            (KiB * 1024)
>> -#define GiB            (MiB * 1024)
>> -#define TiB ((uint64_t) GiB * 1024)
>> +#include "qemu/units.h"
>>  
>>  #define DEFAULT_LOG_SIZE 1048576 /* 1MiB */
>>  /* Structures and fields present in the VHDX file */
>>
> 
> Applied to my trivial-patches branch.

Removed as Kevin already applied it to block-next.

Thanks,
Laurent



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

end of thread, other threads:[~2019-04-11 19:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-27  9:56 [Qemu-trivial] [PATCH v2 0/2] block/vhdx: Use IEC binary prefixes from "qemu/units.h" Stefano Garzarella
2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition Stefano Garzarella
2019-03-27 12:40   ` Philippe Mathieu-Daudé
2019-03-27 17:16   ` John Snow
2019-03-27 17:23     ` Stefano Garzarella
2019-03-27 20:16     ` [Qemu-trivial] [Qemu-devel] " Philippe Mathieu-Daudé
2019-04-11 19:54   ` [Qemu-trivial] " Laurent Vivier
2019-04-11 19:55     ` Laurent Vivier
2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 2/2] block/vhdx: Use IEC binary prefixes for size constants Stefano Garzarella
2019-03-27 12:39   ` Philippe Mathieu-Daudé
2019-03-27 17:17   ` [Qemu-trivial] [Qemu-devel] " John Snow
2019-03-28 12:29 ` [Qemu-trivial] [PATCH v2 0/2] block/vhdx: Use IEC binary prefixes from "qemu/units.h" Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).