mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-14 23:24:23 +03:00
libxl: convert to typesafe virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
51eeb756d2
commit
571bced207
@ -1271,22 +1271,11 @@ static int
|
|||||||
libxlGetAutoballoonConf(libxlDriverConfigPtr cfg,
|
libxlGetAutoballoonConf(libxlDriverConfigPtr cfg,
|
||||||
virConfPtr conf)
|
virConfPtr conf)
|
||||||
{
|
{
|
||||||
virConfValuePtr p;
|
|
||||||
regex_t regex;
|
regex_t regex;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
p = virConfGetValue(conf, "autoballoon");
|
if (virConfGetValueBool(conf, "autoballoon", &cfg->autoballoon) < 0)
|
||||||
if (p) {
|
|
||||||
if (p->type != VIR_CONF_ULONG) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
"%s",
|
|
||||||
_("Unexpected type for 'autoballoon' setting"));
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
cfg->autoballoon = p->l != 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((res = regcomp(®ex,
|
if ((res = regcomp(®ex,
|
||||||
"(^| )dom0_mem=((|min:|max:)[0-9]+[bBkKmMgG]?,?)+($| )",
|
"(^| )dom0_mem=((|min:|max:)[0-9]+[bBkKmMgG]?,?)+($| )",
|
||||||
@ -1450,7 +1439,6 @@ int libxlDriverConfigLoadFile(libxlDriverConfigPtr cfg,
|
|||||||
const char *filename)
|
const char *filename)
|
||||||
{
|
{
|
||||||
virConfPtr conf = NULL;
|
virConfPtr conf = NULL;
|
||||||
virConfValuePtr p;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
/* defaults for keepalive messages */
|
/* defaults for keepalive messages */
|
||||||
@ -1472,39 +1460,14 @@ int libxlDriverConfigLoadFile(libxlDriverConfigPtr cfg,
|
|||||||
if (libxlGetAutoballoonConf(cfg, conf) < 0)
|
if (libxlGetAutoballoonConf(cfg, conf) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((p = virConfGetValue(conf, "lock_manager"))) {
|
if (virConfGetValueString(conf, "lock_manager", &cfg->lockManagerName) < 0)
|
||||||
if (p->type != VIR_CONF_STRING) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
"%s",
|
|
||||||
_("Unexpected type for 'lock_manager' setting"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (VIR_STRDUP(cfg->lockManagerName, p->str) < 0)
|
if (virConfGetValueInt(conf, "keepalive_interval", &cfg->keepAliveInterval) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if ((p = virConfGetValue(conf, "keepalive_interval"))) {
|
if (virConfGetValueUInt(conf, "keepalive_count", &cfg->keepAliveCount) < 0)
|
||||||
if (p->type != VIR_CONF_LONG && p->type != VIR_CONF_ULONG) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
"%s",
|
|
||||||
_("Unexpected type for 'keepalive_interval' setting"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
cfg->keepAliveInterval = p->l;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((p = virConfGetValue(conf, "keepalive_count"))) {
|
|
||||||
if (p->type != VIR_CONF_ULONG) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
"%s",
|
|
||||||
_("Unexpected type for 'keepalive_count' setting"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg->keepAliveCount = p->l;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user