mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
Set default vCPUs to match pCPUs for OpenVZ containers (Evgeniy Sokolov )
This commit is contained in:
parent
c673689430
commit
1ad44362e3
@ -1,3 +1,9 @@
|
|||||||
|
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>
|
Mon Nov 24 19:27:40 GMT 2008 Dnaiel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
* examples/domain-events/events-python/event-test.py,
|
* examples/domain-events/events-python/event-test.py,
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include "buf.h"
|
#include "buf.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "nodeinfo.h"
|
||||||
|
|
||||||
static char *openvzLocateConfDir(void);
|
static char *openvzLocateConfDir(void);
|
||||||
static int openvzGetVPSUUID(int vpsid, char *uuidstr);
|
static int openvzGetVPSUUID(int vpsid, char *uuidstr);
|
||||||
@ -427,10 +428,11 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (ret > 0) {
|
} else if (ret > 0) {
|
||||||
dom->def->vcpus = strtoI(temp);
|
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 .... */
|
/* XXX load rest of VM config data .... */
|
||||||
|
|
||||||
openvzReadNetworkConf(NULL, dom->def, veid);
|
openvzReadNetworkConf(NULL, dom->def, veid);
|
||||||
@ -457,6 +459,19 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
return -1;
|
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
|
int
|
||||||
openvzWriteConfigParam(int vpsid, const char *param, const char *value)
|
openvzWriteConfigParam(int vpsid, const char *param, const char *value)
|
||||||
|
@ -68,5 +68,6 @@ int openvzLoadDomains(struct openvz_driver *driver);
|
|||||||
void openvzFreeDriver(struct openvz_driver *driver);
|
void openvzFreeDriver(struct openvz_driver *driver);
|
||||||
int strtoI(const char *str);
|
int strtoI(const char *str);
|
||||||
int openvzSetDefinedUUID(int vpsid, unsigned char *uuid);
|
int openvzSetDefinedUUID(int vpsid, unsigned char *uuid);
|
||||||
|
unsigned int openvzGetNodeCPUs(void);
|
||||||
|
|
||||||
#endif /* OPENVZ_CONF_H */
|
#endif /* OPENVZ_CONF_H */
|
||||||
|
@ -834,7 +834,7 @@ static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
|
|||||||
char str_vcpus[32];
|
char str_vcpus[32];
|
||||||
const char *prog[] = { VZCTL, "--quiet", "set", vm ? vm->def->name : NULL,
|
const char *prog[] = { VZCTL, "--quiet", "set", vm ? vm->def->name : NULL,
|
||||||
"--cpus", str_vcpus, "--save", NULL };
|
"--cpus", str_vcpus, "--save", NULL };
|
||||||
|
unsigned int pcpus;
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(conn, VIR_ERR_INVALID_DOMAIN,
|
openvzError(conn, VIR_ERR_INVALID_DOMAIN,
|
||||||
@ -848,6 +848,10 @@ static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pcpus = openvzGetNodeCPUs();
|
||||||
|
if (pcpus > 0 && pcpus < nvcpus)
|
||||||
|
nvcpus = pcpus;
|
||||||
|
|
||||||
snprintf(str_vcpus, 31, "%d", nvcpus);
|
snprintf(str_vcpus, 31, "%d", nvcpus);
|
||||||
str_vcpus[31] = '\0';
|
str_vcpus[31] = '\0';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user