return -1;
}
-static bool
-libxlGetAutoballoonConf(libxlDriverConfigPtr cfg)
+static int
+libxlGetAutoballoonConf(libxlDriverConfigPtr cfg, bool *autoballoon)
{
regex_t regex;
- int ret;
+ int res;
+
+ if ((res = regcomp(®ex,
+ "(^| )dom0_mem=((|min:|max:)[0-9]+[bBkKmMgG]?,?)+($| )",
+ REG_NOSUB | REG_EXTENDED)) != 0) {
+ char error[100];
+ regerror(res, ®ex, error, sizeof(error));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to compile regex %s"),
+ error);
- ret = regcomp(®ex,
- "(^| )dom0_mem=((|min:|max:)[0-9]+[bBkKmMgG]?,?)+($| )",
- REG_NOSUB | REG_EXTENDED);
- if (ret)
- return true;
+ return -1;
+ }
- ret = regexec(®ex, cfg->verInfo->commandline, 0, NULL, 0);
+ res = regexec(®ex, cfg->verInfo->commandline, 0, NULL, 0);
regfree(®ex);
- return ret == REG_NOMATCH;
+ *autoballoon = res == REG_NOMATCH;
+ return 0;
}
libxlDriverConfigPtr
}
/* setup autoballoon */
- cfg->autoballoon = libxlGetAutoballoonConf(cfg);
+ if (libxlGetAutoballoonConf(cfg, &cfg->autoballoon) < 0)
+ goto error;
return cfg;