qemu-block
[Top][All Lists]
Advanced

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

[Qemu-block] [RFC PATCH 52/56] block/nfs: Reject negative readahead-size


From: Markus Armbruster
Subject: [Qemu-block] [RFC PATCH 52/56] block/nfs: Reject negative readahead-size, page-cache-size
Date: Mon, 7 Aug 2017 16:45:56 +0200

The nfs block driver uses QEMU_OPT_NUMBER for these sizes.  All other
block drivers use QEMU_OPT_SIZE.  Both are uint64_t, but QEMU_OPT_SIZE
rejects negative numbers, while QEMU_OPT_NUMBER interprets them modulo
2^64.  Switch the nfs block driver to QEMU_OPT_SIZE.

Signed-off-by: Markus Armbruster <address@hidden>
---
 block/nfs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/nfs.c b/block/nfs.c
index 2776788..0ed3e7c 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -394,12 +394,12 @@ static QemuOptsList runtime_opts = {
         },
         {
             .name = "readahead-size",
-            .type = QEMU_OPT_NUMBER,
+            .type = QEMU_OPT_SIZE,
             .help = "Set the readahead size in bytes",
         },
         {
             .name = "page-cache-size",
-            .type = QEMU_OPT_NUMBER,
+            .type = QEMU_OPT_SIZE,
             .help = "Set the pagecache size in bytes",
         },
         {
@@ -557,7 +557,7 @@ static int64_t nfs_client_open(NFSClient *client, QDict 
*options,
                              "if cache.direct = on");
             goto fail;
         }
-        client->readahead = qemu_opt_get_number(opts, "readahead-size", 0);
+        client->readahead = qemu_opt_get_size(opts, "readahead-size", 0);
         if (client->readahead > QEMU_NFS_MAX_READAHEAD_SIZE) {
             warn_report("Truncating NFS readahead size to %d",
                         QEMU_NFS_MAX_READAHEAD_SIZE);
@@ -578,7 +578,7 @@ static int64_t nfs_client_open(NFSClient *client, QDict 
*options,
                              "if cache.direct = on");
             goto fail;
         }
-        client->pagecache = qemu_opt_get_number(opts, "page-cache-size", 0);
+        client->pagecache = qemu_opt_get_size(opts, "page-cache-size", 0);
         if (client->pagecache > QEMU_NFS_MAX_PAGECACHE_SIZE) {
             warn_report("Truncating NFS pagecache size to %d pages",
                         QEMU_NFS_MAX_PAGECACHE_SIZE);
-- 
2.7.5




reply via email to

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