qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/7] block/null: Make more explicit the driver default size is 1G


From: Philippe Mathieu-Daudé
Subject: [PATCH 1/7] block/null: Make more explicit the driver default size is 1GiB
Date: Fri, 14 Aug 2020 10:28:35 +0200

As it is not obvious the default size for the null block driver
is 1 GiB, replace the obfuscated '1 << 30' magic value by a
definition using IEC binary prefixes.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 block/null.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/null.c b/block/null.c
index 15e1d56746..8354def367 100644
--- a/block/null.c
+++ b/block/null.c
@@ -11,6 +11,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qstring.h"
@@ -21,6 +22,7 @@
 
 #define NULL_OPT_LATENCY "latency-ns"
 #define NULL_OPT_ZEROES  "read-zeroes"
+#define NULL_OPT_SIZE    (1 * GiB)
 
 typedef struct {
     int64_t length;
@@ -86,7 +88,7 @@ static int null_file_open(BlockDriverState *bs, QDict 
*options, int flags,
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
     qemu_opts_absorb_qdict(opts, options, &error_abort);
     s->length =
-        qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 1 << 30);
+        qemu_opt_get_size(opts, BLOCK_OPT_SIZE, NULL_OPT_SIZE);
     s->latency_ns =
         qemu_opt_get_number(opts, NULL_OPT_LATENCY, 0);
     if (s->latency_ns < 0) {
-- 
2.21.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]