+Mon Nov 24 19:32:40 GMT 2008 Dnaiel P. Berrange <berrange@redhat.com>
+
+ * src/openvz_conf.c, src/openvz_conf.h, src/openvz_driver.c:
+ Default vCPUs to equal host pCPU count if not set in config
+ (patch from Evgeniy Sokolov)
+
Mon Nov 24 19:27:40 GMT 2008 Dnaiel P. Berrange <berrange@redhat.com>
* examples/domain-events/events-python/event-test.py,
#include "buf.h"
#include "memory.h"
#include "util.h"
+#include "nodeinfo.h"
static char *openvzLocateConfDir(void);
static int openvzGetVPSUUID(int vpsid, char *uuidstr);
goto cleanup;
} else if (ret > 0) {
dom->def->vcpus = strtoI(temp);
- } else {
- dom->def->vcpus = 1;
}
+ if (ret == 0 || dom->def->vcpus == 0)
+ dom->def->vcpus = openvzGetNodeCPUs();
+
/* XXX load rest of VM config data .... */
openvzReadNetworkConf(NULL, dom->def, veid);
return -1;
}
+unsigned int
+openvzGetNodeCPUs(void)
+{
+ virNodeInfo nodeinfo;
+
+ if (virNodeInfoPopulate(NULL, &nodeinfo) < 0) {
+ openvzError(NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Cound not read nodeinfo"));
+ return 0;
+ }
+
+ return nodeinfo.cpus;
+}
int
openvzWriteConfigParam(int vpsid, const char *param, const char *value)
void openvzFreeDriver(struct openvz_driver *driver);
int strtoI(const char *str);
int openvzSetDefinedUUID(int vpsid, unsigned char *uuid);
+unsigned int openvzGetNodeCPUs(void);
#endif /* OPENVZ_CONF_H */
char str_vcpus[32];
const char *prog[] = { VZCTL, "--quiet", "set", vm ? vm->def->name : NULL,
"--cpus", str_vcpus, "--save", NULL };
-
+ unsigned int pcpus;
if (!vm) {
openvzError(conn, VIR_ERR_INVALID_DOMAIN,
return -1;
}
+ pcpus = openvzGetNodeCPUs();
+ if (pcpus > 0 && pcpus < nvcpus)
+ nvcpus = pcpus;
+
snprintf(str_vcpus, 31, "%d", nvcpus);
str_vcpus[31] = '\0';