[libvirt] [PATCH] conf: use proper maximum for parsing memory values

Martin Kletzander mkletzan at redhat.com
Thu Oct 30 15:49:09 UTC 2014


The value is stored in unsigned long long, so ULLONG_MAX is the proper
upper limit to use.

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
Even though this is a build-breaker (for 32bit systems
memtune-unlimited fails to parse), I'm not pushing it as one because
it feels odd that such change wouldn't break anything else.

 src/conf/domain_conf.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a351382..beb3d26 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6388,16 +6388,10 @@ virDomainParseMemory(const char *xpath, xmlXPathContextPtr ctxt,
                      unsigned long long *mem, bool required)
 {
     int ret = -1;
-    unsigned long long bytes, max;
-
-    /* On 32-bit machines, our bound is 0xffffffff * KiB. On 64-bit
-     * machines, our bound is off_t (2^63).  */
-    if (sizeof(unsigned long) < sizeof(long long))
-        max = 1024ull * ULONG_MAX;
-    else
-        max = LLONG_MAX;
+    unsigned long long bytes;

-    ret = virDomainParseScaledValue(xpath, ctxt, &bytes, 1024, max, required);
+    ret = virDomainParseScaledValue(xpath, ctxt, &bytes, 1024,
+                                    ULLONG_MAX, required);
     if (ret < 0)
         goto cleanup;

--
2.1.2




More information about the libvir-list mailing list