]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libxl: Move detection of autoballoon to libxl_conf
authorJim Fehlig <jfehlig@suse.com>
Fri, 30 Aug 2013 17:11:08 +0000 (11:11 -0600)
committerJim Fehlig <jfehlig@suse.com>
Tue, 3 Sep 2013 22:43:20 +0000 (16:43 -0600)
Detecting whether or not to autoballoon is configuration related,
so move the code to libxl_conf.

src/libxl/libxl_conf.c
src/libxl/libxl_conf.h
src/libxl/libxl_driver.c

index 8129c7fe1f2d6a03021f7dd4476c5cb76c1c36d2..f8937a4aa3d6bc313f766a8e08ae9571386e0f29 100644 (file)
@@ -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)
 {
index 9d72b722422b1d44004aafde339d97579d543c81..0498012f1c4ebc908c2b2bf56add3776db1fe2a2 100644 (file)
@@ -120,6 +120,9 @@ struct _libxlSavefileHeader {
     uint32_t unused[10];
 };
 
+bool
+libxlGetAutoballoonConf(libxlDriverPrivatePtr driver);
+
 virCapsPtr
 libxlMakeCapabilities(libxl_ctx *ctx);
 
index 9fb4fa513e5969470a9b63d666d79b7bdcac5e08..91beb306df29ea6d72fc52d16194172b06d74959 100644 (file)
@@ -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,