New type of <devices> <filesystem type= 'volume'> is introduced.
This patch allows to use volumes for storing the filesystem, that is
accessed from the guest e.g. root directory for container.
To take advantage of volumes as a backend of filesystem volume
and pool names should be specified:
<filesystem type= 'volume'>
<source pool='pool name' volume='volume name'/>
Signed-off-by: Olga Krishtal <okrishtal(a)virtuozzo.com>
---
src/conf/domain_conf.c | 18 +++++++++++++++---
src/conf/domain_conf.h | 1 +
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0b33b3b..558a33e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -365,7 +365,8 @@ VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
"file",
"template",
"ram",
- "bind")
+ "bind",
+ "volume")
VIR_ENUM_IMPL(virDomainFSDriver, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
"default",
@@ -8600,6 +8601,10 @@ virDomainFSDefParseXML(xmlNodePtr node,
} else if (def->type == VIR_DOMAIN_FS_TYPE_RAM) {
usage = virXMLPropString(cur, "usage");
units = virXMLPropString(cur, "units");
+ } else if (def->type == VIR_DOMAIN_FS_TYPE_VOLUME) {
+ def->src->type = VIR_STORAGE_TYPE_VOLUME;
+ if (virDomainDiskSourcePoolDefParse(cur,
&def->src->srcpool) < 0)
+ goto error;
}
} else if (!target &&
xmlStrEqual(cur->name, BAD_CAST "target")) {
@@ -8644,8 +8649,8 @@ virDomainFSDefParseXML(xmlNodePtr node,
def->wrpolicy = VIR_DOMAIN_FS_WRPOLICY_DEFAULT;
}
- if (source == NULL &&
- def->type != VIR_DOMAIN_FS_TYPE_RAM) {
+ if (source == NULL && def->type != VIR_DOMAIN_FS_TYPE_RAM
+ && def->type != VIR_DOMAIN_FS_TYPE_VOLUME) {
virReportError(VIR_ERR_NO_SOURCE,
target ? "%s" : NULL, target);
goto error;
@@ -20222,6 +20227,13 @@ virDomainFSDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, "<source usage='%lld'
units='KiB'/>\n",
def->usage / 1024);
break;
+
+ case VIR_DOMAIN_FS_TYPE_VOLUME:
+ virBufferAddLit(buf, "<source");
+ virBufferEscapeString(buf, " pool='%s'",
def->src->srcpool->pool);
+ virBufferEscapeString(buf, " volume='%s'",
def->src->srcpool->volume);
+ virBufferAddLit(buf, "/>\n");
+ break;
}
virBufferEscapeString(buf, "<target dir='%s'/>\n",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 281abba..a129320 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -759,6 +759,7 @@ typedef enum {
VIR_DOMAIN_FS_TYPE_TEMPLATE, /* Expands a OS template to a guest dir */
VIR_DOMAIN_FS_TYPE_RAM, /* Mount a RAM filesystem on a guest dir */
VIR_DOMAIN_FS_TYPE_BIND, /* Binds a guest dir to another guest dir */
+ VIR_DOMAIN_FS_TYPE_VOLUME, /* Mounts storage pool volume to a guest */
VIR_DOMAIN_FS_TYPE_LAST
} virDomainFSType;
--
1.8.3.1