mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 07:42:56 +00:00
openvz: add quota argument when creating container
This commit is contained in:
parent
680ac813a5
commit
e63845469e
@ -189,6 +189,48 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
openvzSetDiskQuota(virDomainDefPtr vmdef,
|
||||||
|
virDomainFSDefPtr fss)
|
||||||
|
{
|
||||||
|
int ret = -1;
|
||||||
|
unsigned long long sl, hl;
|
||||||
|
virCommandPtr cmd = virCommandNewArgList(VZCTL,
|
||||||
|
"--quiet",
|
||||||
|
"set",
|
||||||
|
vmdef->name,
|
||||||
|
"--save",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (fss->type == VIR_DOMAIN_FS_TYPE_TEMPLATE) {
|
||||||
|
if (fss->space_hard_limit) {
|
||||||
|
hl = VIR_DIV_UP(fss->space_hard_limit, 1024);
|
||||||
|
virCommandAddArg(cmd, "--diskspace");
|
||||||
|
|
||||||
|
if (fss->space_soft_limit) {
|
||||||
|
sl = VIR_DIV_UP(fss->space_soft_limit, 1024);
|
||||||
|
virCommandAddArgFormat(cmd, "%lld:%lld", sl, hl);
|
||||||
|
} else {
|
||||||
|
virCommandAddArgFormat(cmd, "%lld", hl);
|
||||||
|
}
|
||||||
|
} else if (fss->space_soft_limit) {
|
||||||
|
openvzError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
|
_("Can't set soft limit without hard limit"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
virCommandFree(cmd);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virDomainPtr openvzDomainLookupByID(virConnectPtr conn,
|
static virDomainPtr openvzDomainLookupByID(virConnectPtr conn,
|
||||||
int id) {
|
int id) {
|
||||||
struct openvz_driver *driver = conn->privateData;
|
struct openvz_driver *driver = conn->privateData;
|
||||||
@ -895,7 +937,13 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: set quota */
|
if (vm->def->nfss == 1) {
|
||||||
|
if (openvzSetDiskQuota(vm->def, vm->def->fss[0]) < 0) {
|
||||||
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("Could not set disk quota"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (openvzSetDefinedUUID(strtoI(vm->def->name), vm->def->uuid) < 0) {
|
if (openvzSetDefinedUUID(strtoI(vm->def->name), vm->def->uuid) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
@ -977,6 +1025,14 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vm->def->nfss == 1) {
|
||||||
|
if (openvzSetDiskQuota(vm->def, vm->def->fss[0]) < 0) {
|
||||||
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("Could not set disk quota"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (openvzSetDefinedUUID(strtoI(vm->def->name), vm->def->uuid) < 0) {
|
if (openvzSetDefinedUUID(strtoI(vm->def->name), vm->def->uuid) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not set UUID"));
|
_("Could not set UUID"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user