mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
* src/qemu_conf.c src/qemu_conf.h src/qemu_driver.c: applied patch
from Cole Robinson implementing memory operations for qemu driver Daniel
This commit is contained in:
parent
2fe1c38796
commit
623ec4d2f2
@ -1,3 +1,8 @@
|
||||
Wed Mar 19 15:31:34 CET 2008 Daniel Veillard <veillard@redhat.com>
|
||||
|
||||
* src/qemu_conf.c src/qemu_conf.h src/qemu_driver.c: applied patch
|
||||
from Cole Robinson implementing memory operations for qemu driver
|
||||
|
||||
Tue Mar 18 23:31:26 CET 2008 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
Avoid "make syntax-check" failure.
|
||||
|
@ -1650,7 +1650,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
||||
(vm->def->graphicsType == QEMUD_GRAPHICS_SDL ? 0 : 1)) + /* graphics */
|
||||
(vm->migrateFrom[0] ? 3 : 0); /* migrateFrom */
|
||||
|
||||
snprintf(memory, sizeof(memory), "%d", vm->def->memory/1024);
|
||||
snprintf(memory, sizeof(memory), "%lu", vm->def->memory/1024);
|
||||
snprintf(vcpus, sizeof(vcpus), "%d", vm->def->vcpus);
|
||||
|
||||
if (!(*argv = malloc(sizeof(**argv) * (len+1))))
|
||||
@ -2820,9 +2820,9 @@ char *qemudGenerateXML(virConnectPtr conn,
|
||||
virUUIDFormat(uuid, uuidstr);
|
||||
if (virBufferVSprintf(buf, " <uuid>%s</uuid>\n", uuidstr) < 0)
|
||||
goto no_memory;
|
||||
if (virBufferVSprintf(buf, " <memory>%d</memory>\n", def->maxmem) < 0)
|
||||
if (virBufferVSprintf(buf, " <memory>%lu</memory>\n", def->maxmem) < 0)
|
||||
goto no_memory;
|
||||
if (virBufferVSprintf(buf, " <currentMemory>%d</currentMemory>\n", def->memory) < 0)
|
||||
if (virBufferVSprintf(buf, " <currentMemory>%lu</currentMemory>\n", def->memory) < 0)
|
||||
goto no_memory;
|
||||
if (virBufferVSprintf(buf, " <vcpu>%d</vcpu>\n", def->vcpus) < 0)
|
||||
goto no_memory;
|
||||
|
@ -193,8 +193,8 @@ struct qemud_vm_def {
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
char name[QEMUD_MAX_NAME_LEN];
|
||||
|
||||
int memory;
|
||||
int maxmem;
|
||||
unsigned long memory;
|
||||
unsigned long maxmem;
|
||||
int vcpus;
|
||||
|
||||
int noReboot;
|
||||
|
@ -1765,6 +1765,66 @@ static char *qemudDomainGetOSType(virDomainPtr dom) {
|
||||
return type;
|
||||
}
|
||||
|
||||
/* Returns max memory in kb, 0 if error */
|
||||
static unsigned long qemudDomainGetMaxMemory(virDomainPtr dom) {
|
||||
struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
|
||||
struct qemud_vm *vm = qemudFindVMByUUID(driver, dom->uuid);
|
||||
|
||||
if (!vm) {
|
||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_DOMAIN,
|
||||
_("no domain with matching uuid '%s'"), dom->uuid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return vm->def->maxmem;
|
||||
}
|
||||
|
||||
static int qemudDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) {
|
||||
struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
|
||||
struct qemud_vm *vm = qemudFindVMByUUID(driver, dom->uuid);
|
||||
|
||||
if (!vm) {
|
||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_DOMAIN,
|
||||
_("no domain with matching uuid '%s'"), dom->uuid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (newmax < vm->def->memory) {
|
||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_ARG,
|
||||
_("cannot set max memory lower than current memory"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
vm->def->maxmem = newmax;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
|
||||
struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
|
||||
struct qemud_vm *vm = qemudFindVMByUUID(driver, dom->uuid);
|
||||
|
||||
if (!vm) {
|
||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_DOMAIN,
|
||||
_("no domain with matching uuid '%s'"), dom->uuid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qemudIsActiveVM(vm)) {
|
||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot set memory of an active domain"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (newmem > vm->def->maxmem) {
|
||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_ARG,
|
||||
_("cannot set memory higher than max memory"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
vm->def->memory = newmem;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int qemudDomainGetInfo(virDomainPtr dom,
|
||||
virDomainInfoPtr info) {
|
||||
struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
|
||||
@ -2886,9 +2946,9 @@ static virDriver qemuDriver = {
|
||||
NULL, /* domainReboot */
|
||||
qemudDomainDestroy, /* domainDestroy */
|
||||
qemudDomainGetOSType, /* domainGetOSType */
|
||||
NULL, /* domainGetMaxMemory */
|
||||
NULL, /* domainSetMaxMemory */
|
||||
NULL, /* domainSetMemory */
|
||||
qemudDomainGetMaxMemory, /* domainGetMaxMemory */
|
||||
qemudDomainSetMaxMemory, /* domainSetMaxMemory */
|
||||
qemudDomainSetMemory, /* domainSetMemory */
|
||||
qemudDomainGetInfo, /* domainGetInfo */
|
||||
qemudDomainSave, /* domainSave */
|
||||
qemudDomainRestore, /* domainRestore */
|
||||
|
Loading…
Reference in New Issue
Block a user