[PATCH 01/12] libxl: Move detection of autoballoon to libxl_conf

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

 



Detecting whether or not to autoballoon is configuration related,
so move the code to libxl_conf.

Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
---
 src/libxl/libxl_conf.c   | 22 ++++++++++++++++++++++
 src/libxl/libxl_conf.h   |  3 +++
 src/libxl/libxl_driver.c | 25 +------------------------
 3 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 8129c7f..f8937a4 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -978,6 +978,28 @@ error:
     return -1;
 }
 
+bool
+libxlGetAutoballoonConf(libxlDriverPrivatePtr driver)
+{
+    const libxl_version_info *info;
+    regex_t regex;
+    int ret;
+
+    info = libxl_get_version_info(driver->ctx);
+    if (!info)
+        return true; /* default to on */
+
+    ret = regcomp(&regex,
+            "(^| )dom0_mem=((|min:|max:)[0-9]+[bBkKmMgG]?,?)+($| )",
+            REG_NOSUB | REG_EXTENDED);
+    if (ret)
+        return true;
+
+    ret = regexec(&regex, info->commandline, 0, NULL, 0);
+    regfree(&regex);
+    return ret == REG_NOMATCH;
+}
+
 virCapsPtr
 libxlMakeCapabilities(libxl_ctx *ctx)
 {
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 9d72b72..0498012 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -120,6 +120,9 @@ struct _libxlSavefileHeader {
     uint32_t unused[10];
 };
 
+bool
+libxlGetAutoballoonConf(libxlDriverPrivatePtr driver);
+
 virCapsPtr
 libxlMakeCapabilities(libxl_ctx *ctx);
 
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 9fb4fa5..91beb30 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1207,29 +1207,6 @@ libxlStateCleanup(void)
     return 0;
 }
 
-static bool
-libxlGetAutoballoon(libxlDriverPrivatePtr driver)
-{
-    const libxl_version_info *info;
-    regex_t regex;
-    int ret;
-
-    info = libxl_get_version_info(driver->ctx);
-    if (!info)
-        return true; /* default to on */
-
-    ret = regcomp(&regex,
-            "(^| )dom0_mem=((|min:|max:)[0-9]+[bBkKmMgG]?,?)+($| )",
-            REG_NOSUB | REG_EXTENDED);
-    if (ret)
-        return true;
-
-    ret = regexec(&regex, info->commandline, 0, NULL, 0);
-    regfree(&regex);
-    return ret == REG_NOMATCH;
-}
-
-
 static int
 libxlStateInitialize(bool privileged,
                      virStateInhibitCallback callback ATTRIBUTE_UNUSED,
@@ -1376,7 +1353,7 @@ libxlStateInitialize(bool privileged,
     }
 
     /* setup autoballoon */
-    libxl_driver->autoballoon = libxlGetAutoballoon(libxl_driver);
+    libxl_driver->autoballoon = libxlGetAutoballoonConf(libxl_driver);
 
     /* Load running domains first. */
     if (virDomainObjListLoadAllConfigs(libxl_driver->domains,
-- 
1.8.1.4

--
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]