From 680ac813a504441ff8bf592bc7df73a2c54f6793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 24 Apr 2012 08:39:01 +0200 Subject: [PATCH] openvz: support file system quota reporting --- src/openvz/openvz_conf.c | 24 +++++++++++++++++++ .../domainschemadata/domain-openvz-simple.xml | 2 ++ 2 files changed, 26 insertions(+) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 5f107edce0..72cd1e64cf 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -407,6 +407,8 @@ openvzReadFSConf(virDomainDefPtr def, virDomainFSDefPtr fs = NULL; char *veid_str = NULL; char *temp = NULL; + const char *param; + unsigned long long barrier, limit; ret = openvzReadVPSConfigParam(veid, "OSTEMPLATE", &temp); if (ret < 0) { @@ -444,6 +446,28 @@ openvzReadFSConf(virDomainDefPtr def, fs->dst = strdup("/"); + param = "DISKSPACE"; + ret = openvzReadVPSConfigParam(veid, param, &temp); + if (ret > 0) { + if (openvzParseBarrierLimit(temp, &barrier, &limit)) { + openvzError(VIR_ERR_INTERNAL_ERROR, + _("Could not read '%s' from config for container %d"), + param, veid); + goto error; + } else { + /* Ensure that we can multiply by 1024 without overflowing. */ + if (barrier > ULONG_LONG_MAX / 1024 || + limit > ULONG_LONG_MAX / 1024 ) { + virReportSystemError(VIR_ERR_OVERFLOW, + _("%s"), + "Unable to parse quota"); + goto error; + } + fs->space_soft_limit = barrier * 1024; /* unit is bytes */ + fs->space_hard_limit = limit * 1024; /* unit is bytes */ + } + } + if (fs->src == NULL || fs->dst == NULL) goto no_memory; diff --git a/tests/domainschemadata/domain-openvz-simple.xml b/tests/domainschemadata/domain-openvz-simple.xml index a121d39dd9..949e96dbed 100644 --- a/tests/domainschemadata/domain-openvz-simple.xml +++ b/tests/domainschemadata/domain-openvz-simple.xml @@ -21,6 +21,8 @@ + 1153024 + 1048576