mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
libxl: Move detection of autoballoon to libxl_conf
Detecting whether or not to autoballoon is configuration related, so move the code to libxl_conf.
This commit is contained in:
parent
11e80ddfe4
commit
c9d5432d85
@ -978,6 +978,28 @@ error:
|
|||||||
return -1;
|
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(®ex,
|
||||||
|
"(^| )dom0_mem=((|min:|max:)[0-9]+[bBkKmMgG]?,?)+($| )",
|
||||||
|
REG_NOSUB | REG_EXTENDED);
|
||||||
|
if (ret)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
ret = regexec(®ex, info->commandline, 0, NULL, 0);
|
||||||
|
regfree(®ex);
|
||||||
|
return ret == REG_NOMATCH;
|
||||||
|
}
|
||||||
|
|
||||||
virCapsPtr
|
virCapsPtr
|
||||||
libxlMakeCapabilities(libxl_ctx *ctx)
|
libxlMakeCapabilities(libxl_ctx *ctx)
|
||||||
{
|
{
|
||||||
|
@ -120,6 +120,9 @@ struct _libxlSavefileHeader {
|
|||||||
uint32_t unused[10];
|
uint32_t unused[10];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool
|
||||||
|
libxlGetAutoballoonConf(libxlDriverPrivatePtr driver);
|
||||||
|
|
||||||
virCapsPtr
|
virCapsPtr
|
||||||
libxlMakeCapabilities(libxl_ctx *ctx);
|
libxlMakeCapabilities(libxl_ctx *ctx);
|
||||||
|
|
||||||
|
@ -1207,29 +1207,6 @@ libxlStateCleanup(void)
|
|||||||
return 0;
|
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(®ex,
|
|
||||||
"(^| )dom0_mem=((|min:|max:)[0-9]+[bBkKmMgG]?,?)+($| )",
|
|
||||||
REG_NOSUB | REG_EXTENDED);
|
|
||||||
if (ret)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
ret = regexec(®ex, info->commandline, 0, NULL, 0);
|
|
||||||
regfree(®ex);
|
|
||||||
return ret == REG_NOMATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
libxlStateInitialize(bool privileged,
|
libxlStateInitialize(bool privileged,
|
||||||
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
|
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
|
||||||
@ -1376,7 +1353,7 @@ libxlStateInitialize(bool privileged,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* setup autoballoon */
|
/* setup autoballoon */
|
||||||
libxl_driver->autoballoon = libxlGetAutoballoon(libxl_driver);
|
libxl_driver->autoballoon = libxlGetAutoballoonConf(libxl_driver);
|
||||||
|
|
||||||
/* Load running domains first. */
|
/* Load running domains first. */
|
||||||
if (virDomainObjListLoadAllConfigs(libxl_driver->domains,
|
if (virDomainObjListLoadAllConfigs(libxl_driver->domains,
|
||||||
|
Loading…
Reference in New Issue
Block a user