devices: filesystems: added volume type

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@virtuozzo.com>
This commit is contained in:
Olga Krishtal 2016-07-14 16:52:39 +03:00 committed by Maxim Nestratov
parent da665fbd48
commit e05274a2a4
2 changed files with 16 additions and 3 deletions

View File

@ -367,7 +367,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",
@ -8612,6 +8613,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")) {
@ -8656,8 +8661,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;
@ -20305,6 +20310,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",

View File

@ -764,6 +764,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;