mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
Fix openvz crash when setting vcpus & initialize mutex (Anton Protopopov)
This commit is contained in:
parent
34cd4f9076
commit
6add3883a6
18
ChangeLog
18
ChangeLog
@ -1,18 +1,26 @@
|
|||||||
|
Wed Dec 17 21:10:39 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
|
Mutex / crash fixes to openvz driver (Anton Protopopov)
|
||||||
|
* src/openvz_driver.c: Fix crash with setting CPU value
|
||||||
|
during define
|
||||||
|
* src/openvz_conf.c: Initialize the domain mutex when
|
||||||
|
loading config files
|
||||||
|
|
||||||
Wed Dec 17 20:53:39 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
|
Wed Dec 17 20:53:39 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
* domain_conf.c, node_device_conf.c, node_device_conf.h,
|
* src/domain_conf.c, src/node_device_conf.c, src/node_device_conf.h,
|
||||||
storage_conf.c, storage_conf.h: Remove trailing semi-colon
|
src/storage_conf.c, src/storage_conf.h: Remove trailing semi-colon
|
||||||
causing empty statement compile warnings on solaris (John
|
causing empty statement compile warnings on solaris (John
|
||||||
Levon).
|
Levon).
|
||||||
|
|
||||||
Wed Dec 17 18:10:39 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
|
Wed Dec 17 18:10:39 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
Anonymous union fixes for non-GCC compilers (John Levon)
|
Anonymous union fixes for non-GCC compilers (John Levon)
|
||||||
* domain_conf.c, qemu_conf.c, qemu_driver.c: Remove use
|
* src/domain_conf.c, src/qemu_conf.c, src/qemu_driver.c: Remove use
|
||||||
of anonymous union
|
of anonymous union
|
||||||
* domain_conf.h: Give a name to the anonymous union for
|
* src/domain_conf.h: Give a name to the anonymous union for
|
||||||
host devices. Add 'dummy' field to avoid empty struct
|
host devices. Add 'dummy' field to avoid empty struct
|
||||||
* remote_internal.c: Remove gcc-ism in empty "x ? : y"
|
* src/remote_internal.c: Remove gcc-ism in empty "x ? : y"
|
||||||
|
|
||||||
Wed Dec 17 19:06:53 +0100 2008 Jim Meyering <meyering@redhat.com>
|
Wed Dec 17 19:06:53 +0100 2008 Jim Meyering <meyering@redhat.com>
|
||||||
|
|
||||||
|
@ -393,6 +393,8 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
VIR_ALLOC(dom->def) < 0)
|
VIR_ALLOC(dom->def) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
|
pthread_mutex_init(&dom->lock, NULL);
|
||||||
|
|
||||||
if (STREQ(status, "stopped"))
|
if (STREQ(status, "stopped"))
|
||||||
dom->state = VIR_DOMAIN_SHUTOFF;
|
dom->state = VIR_DOMAIN_SHUTOFF;
|
||||||
else
|
else
|
||||||
|
@ -66,6 +66,7 @@ static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid);
|
|||||||
static int openvzGetMaxVCPUs(virConnectPtr conn, const char *type);
|
static int openvzGetMaxVCPUs(virConnectPtr conn, const char *type);
|
||||||
static int openvzDomainGetMaxVcpus(virDomainPtr dom);
|
static int openvzDomainGetMaxVcpus(virDomainPtr dom);
|
||||||
static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus);
|
static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus);
|
||||||
|
static int openvzDomainSetVcpusInternal(virConnectPtr conn, virDomainObjPtr vm, unsigned int nvcpus);
|
||||||
|
|
||||||
static void openvzDriverLock(struct openvz_driver *driver)
|
static void openvzDriverLock(struct openvz_driver *driver)
|
||||||
{
|
{
|
||||||
@ -695,7 +696,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (vm->def->vcpus > 0) {
|
if (vm->def->vcpus > 0) {
|
||||||
if (openvzDomainSetVcpus(dom, vm->def->vcpus) < 0) {
|
if (openvzDomainSetVcpusInternal(conn, vm, vm->def->vcpus) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Could not set number of virtual cpu"));
|
"%s", _("Could not set number of virtual cpu"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -780,9 +781,9 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
vm->state = VIR_DOMAIN_RUNNING;
|
vm->state = VIR_DOMAIN_RUNNING;
|
||||||
|
|
||||||
if (vm->def->vcpus > 0) {
|
if (vm->def->vcpus > 0) {
|
||||||
if (openvzDomainSetVcpus(dom, vm->def->vcpus) < 0) {
|
if (openvzDomainSetVcpusInternal(conn, vm, vm->def->vcpus) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Could not set number of virtual cpu"));
|
"%s", _("Could not set number of virtual cpu"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -961,14 +962,36 @@ static int openvzDomainGetMaxVcpus(virDomainPtr dom) {
|
|||||||
return openvzGetMaxVCPUs(dom->conn, "openvz");
|
return openvzGetMaxVCPUs(dom->conn, "openvz");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
|
static int openvzDomainSetVcpusInternal(virConnectPtr conn, virDomainObjPtr vm,
|
||||||
struct openvz_driver *driver = dom->conn->privateData;
|
unsigned int nvcpus)
|
||||||
virDomainObjPtr vm;
|
{
|
||||||
char str_vcpus[32];
|
char str_vcpus[32];
|
||||||
const char *prog[] = { VZCTL, "--quiet", "set", PROGRAM_SENTINAL,
|
const char *prog[] = { VZCTL, "--quiet", "set", PROGRAM_SENTINAL,
|
||||||
"--cpus", str_vcpus, "--save", NULL };
|
"--cpus", str_vcpus, "--save", NULL };
|
||||||
unsigned int pcpus;
|
unsigned int pcpus;
|
||||||
int ret = -1;
|
pcpus = openvzGetNodeCPUs();
|
||||||
|
if (pcpus > 0 && pcpus < nvcpus)
|
||||||
|
nvcpus = pcpus;
|
||||||
|
|
||||||
|
snprintf(str_vcpus, 31, "%d", nvcpus);
|
||||||
|
str_vcpus[31] = '\0';
|
||||||
|
|
||||||
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
|
if (virRun(conn, prog, NULL) < 0) {
|
||||||
|
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Could not exec %s"), VZCTL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
vm->def->vcpus = nvcpus;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
|
||||||
|
{
|
||||||
|
virDomainObjPtr vm;
|
||||||
|
struct openvz_driver *driver = dom->conn->privateData;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
openvzDriverLock(driver);
|
openvzDriverLock(driver);
|
||||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
@ -986,21 +1009,7 @@ static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
pcpus = openvzGetNodeCPUs();
|
openvzDomainSetVcpusInternal(dom->conn, vm, nvcpus);
|
||||||
if (pcpus > 0 && pcpus < nvcpus)
|
|
||||||
nvcpus = pcpus;
|
|
||||||
|
|
||||||
snprintf(str_vcpus, 31, "%d", nvcpus);
|
|
||||||
str_vcpus[31] = '\0';
|
|
||||||
|
|
||||||
openvzSetProgramSentinal(prog, vm->def->name);
|
|
||||||
if (virRun(dom->conn, prog, NULL) < 0) {
|
|
||||||
openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Could not exec %s"), VZCTL);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
vm->def->vcpus = nvcpus;
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
Reference in New Issue
Block a user