[PATCH 9/9] conf: Move definition of virDomainParseMemory

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

 



Shove it to the top of the file so that it can be reused earlier.
---
 src/conf/domain_conf.c | 60 +++++++++++++++++++++++++-------------------------
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0634116..42c0223 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6372,6 +6372,36 @@ virDomainParseScaledValue(const char *xpath,
 }


+/* Parse a memory element located at XPATH within CTXT, and store the
+ * result into MEM.  If REQUIRED, then the value must exist;
+ * otherwise, the value is optional.  The value is in blocks of 1024.
+ * Return 0 on success, -1 on failure after issuing error.  */
+static int
+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;
+
+    ret = virDomainParseScaledValue(xpath, ctxt, &bytes, 1024, max, required);
+    if (ret < 0)
+        goto cleanup;
+
+    /* Yes, we really do use kibibytes for our internal sizing.  */
+    *mem = VIR_DIV_UP(bytes, 1024);
+    ret = 0;
+ cleanup:
+    return ret;
+}
+
+
 static int
 virDomainControllerModelTypeFromString(const virDomainControllerDef *def,
                                        const char *model)
@@ -11917,36 +11947,6 @@ virDomainDefMaybeAddInput(virDomainDefPtr def,
 }


-/* Parse a memory element located at XPATH within CTXT, and store the
- * result into MEM.  If REQUIRED, then the value must exist;
- * otherwise, the value is optional.  The value is in blocks of 1024.
- * Return 0 on success, -1 on failure after issuing error.  */
-static int
-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;
-
-    ret = virDomainParseScaledValue(xpath, ctxt, &bytes, 1024, max, required);
-    if (ret < 0)
-        goto cleanup;
-
-    /* Yes, we really do use kibibytes for our internal sizing.  */
-    *mem = VIR_DIV_UP(bytes, 1024);
-    ret = 0;
- cleanup:
-    return ret;
-}
-
-
 static int
 virDomainHugepagesParseXML(xmlNodePtr node,
                            xmlXPathContextPtr ctxt,
-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]