On Tue, 21 Sep 2010 18:21:39 +0100, "Daniel P. Berrange" <berra...@redhat.com> wrote: > On Mon, Sep 20, 2010 at 02:16:51PM +0530, Nikunj A. Dadhania wrote: > > Driver interface for setting memory hard_limit, soft_limit and swap > > hard_limit. This patch also NULLs the other HV driver interface structure. > > > > Signed-off-by: Nikunj A. Dadhania <nik...@linux.vnet.ibm.com> > > --- > > src/esx/esx_driver.c | 1 > > src/lxc/lxc_driver.c | 1 > > src/openvz/openvz_driver.c | 1 > > src/phyp/phyp_driver.c | 1 > > src/qemu/qemu_driver.c | 93 > > ++++++++++++++++++++++++++++++++++++++++++++ > > src/remote/remote_driver.c | 1 > > src/test/test_driver.c | 1 > > src/uml/uml_driver.c | 1 > > src/xen/xen_driver.c | 1 > > 9 files changed, 101 insertions(+), 0 deletions(-) > > > > diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c > > index e382950..be55796 100644 > > --- a/src/esx/esx_driver.c > > +++ b/src/esx/esx_driver.c > > @@ -4217,6 +4217,7 @@ static virDriver esxDriver = { > > esxDomainRevertToSnapshot, /* domainRevertToSnapshot */ > > esxDomainSnapshotDelete, /* domainSnapshotDelete */ > > NULL, /* qemuDomainMonitorCommand */ > > + NULL, /* domainSetMemoryParameters */ > > }; > > All these bits should be in the patch which changes 'driver.h', so that > the code compiles there. > > This patch needs just replace the 'NULL' with the real function for > QEMU. > Sure, will do that. > > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > > index c4aacc9..06666e9 100644 > > --- a/src/qemu/qemu_driver.c > > +++ b/src/qemu/qemu_driver.c > > @@ -9365,6 +9365,98 @@ cleanup: > > return ret; > > } > > > > + > > +static int qemuDomainSetMemoryParameters(virDomainPtr dom, > > + virMemoryParameterPtr params, > > + int nparams) > > +{ > > + struct qemud_driver *driver = dom->conn->privateData; > > + int i; > > + virCgroupPtr group = NULL; > > + virDomainObjPtr vm = NULL; > > + int ret = -1; > > + > > + qemuDriverLock(driver); > > + if (!qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_MEMORY)) > > { > > + qemuReportError(VIR_ERR_NO_SUPPORT, > > + __FUNCTION__); > > + goto cleanup; > > + } > > + > > + vm = virDomainFindByUUID(&driver->domains, dom->uuid); > > + > > + if (vm == NULL) { > > + qemuReportError(VIR_ERR_INTERNAL_ERROR, > > + _("No such domain %s"), dom->uuid); > > + goto cleanup; > > + } > > + > > + if (virCgroupForDomain(driver->cgroup, vm->def->name, &group, 0) != 0) > > { > > + qemuReportError(VIR_ERR_INTERNAL_ERROR, > > + _("cannot find cgroup for domain %s"), > > vm->def->name); > > + goto cleanup; > > + } > > + > > + for (i = 0; i < nparams; i++) { > > + virMemoryParameterPtr param = ¶ms[i]; > > + > > + if (STREQ(param->field, "hard_limit")) { > > + int rc; > > + if (param->type != VIR_DOMAIN_MEMORY_FIELD_ULLONG) { > > + qemuReportError(VIR_ERR_INVALID_ARG, "%s", > > + _("invalid type for memory hard_limit > > tunable, expected a 'ullong'")); > > + continue; > > + } > > + > > + rc = virCgroupSetMemoryHardLimit(group, params[i].value.ul); > > + if (rc != 0) { > > + virReportSystemError(-rc, "%s", > > + _("unable to set memory hard_limit > > tunable")); > > + } > > + } else if (STREQ(param->field, "soft_limit")) { > > + int rc; > > + if (param->type != VIR_DOMAIN_MEMORY_FIELD_ULLONG) { > > + qemuReportError(VIR_ERR_INVALID_ARG, "%s", > > + _("invalid type for memory soft_limit > > tunable, expected a 'ullong'")); > > + continue; > > + } > > + > > + rc = virCgroupSetMemorySoftLimit(group, params[i].value.ul); > > + if (rc != 0) { > > + virReportSystemError(-rc, "%s", > > + _("unable to set memory soft_limit > > tunable")); > > + } > > + } else if (STREQ(param->field, "swap_hard_limit")) { > > + int rc; > > + if (param->type != VIR_DOMAIN_MEMORY_FIELD_ULLONG) { > > + qemuReportError(VIR_ERR_INVALID_ARG, "%s", > > + _("invalid type for swap_hard_limit > > tunable, expected a 'ullong'")); > > + continue; > > + } > > + > > + rc = virCgroupSetSwapHardLimit(group, params[i].value.ul); > > + if (rc != 0) { > > + virReportSystemError(-rc, "%s", > > + _("unable to set swap_hard_limit > > tunable")); > > + } > > + } else if (STREQ(param->field, "min_gaurantee")) { > > Same typo here s/gaur/guar/ Will correct it.
> > + qemuReportError(VIR_ERR_INVALID_ARG, > > + _("Memory tunable `%s' not implemented"), > > param->field); > > + } else { > > + qemuReportError(VIR_ERR_INVALID_ARG, > > + _("Parameter `%s' not supported"), > > param->field); > > + } > > + } > > + ret = 0; > > + > > +cleanup: > > + virCgroupFree(&group); > > + if (vm) > > + virDomainObjUnlock(vm); > > + qemuDriverUnlock(driver); > > + return ret; > > +} > > This looks pretty sane. Just need to swap patches 6 & 7 in order, because > this patch requires the cgroups functions before it will compile Ok Nikunj -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list