Signed-off-by: Giuseppe Scrivano <gscrivan(a)redhat.com>
---
src/conf/domain_conf.c | 34 +++++++++++++++++++++++++---------
src/conf/domain_conf.h | 1 +
2 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c25c74b..3bdf46a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -342,7 +342,8 @@ VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
"file",
"template",
"ram",
- "bind")
+ "bind",
+ "mtp")
VIR_ENUM_IMPL(virDomainFSDriver, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
"default",
@@ -6404,7 +6405,8 @@ virDomainFSDefParseXML(xmlNodePtr node,
xmlStrEqual(cur->name, BAD_CAST "source")) {
if (def->type == VIR_DOMAIN_FS_TYPE_MOUNT ||
- def->type == VIR_DOMAIN_FS_TYPE_BIND)
+ def->type == VIR_DOMAIN_FS_TYPE_BIND ||
+ def->type == VIR_DOMAIN_FS_TYPE_MTP)
source = virXMLPropString(cur, "dir");
else if (def->type == VIR_DOMAIN_FS_TYPE_FILE)
source = virXMLPropString(cur, "file");
@@ -6418,7 +6420,10 @@ virDomainFSDefParseXML(xmlNodePtr node,
}
} else if (!target &&
xmlStrEqual(cur->name, BAD_CAST "target")) {
- target = virXMLPropString(cur, "dir");
+ if (def->type == VIR_DOMAIN_FS_TYPE_MTP)
+ target = virXMLPropString(cur, "name");
+ else
+ target = virXMLPropString(cur, "dir");
} else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
def->readonly = true;
} else if (xmlStrEqual(cur->name, BAD_CAST "driver")) {
@@ -15668,9 +15673,11 @@ virDomainFSDefFormat(virBufferPtr buf,
}
- virBufferAsprintf(buf,
- "<filesystem type='%s'
accessmode='%s'>\n",
- type, accessmode);
+ virBufferAsprintf(buf, "<filesystem type='%s'", type);
+ if (def->type != VIR_DOMAIN_FS_TYPE_MTP)
+ virBufferAsprintf(buf, " accessmode='%s'", accessmode);
+ virBufferAddLit(buf, ">\n");
+
virBufferAdjustIndent(buf, 2);
if (def->fsdriver) {
virBufferAsprintf(buf, "<driver type='%s'", fsdriver);
@@ -15712,15 +15719,24 @@ virDomainFSDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, "<source usage='%lld'
units='KiB'/>\n",
def->usage / 1024);
break;
+ case VIR_DOMAIN_FS_TYPE_MTP:
+ virBufferEscapeString(buf, "<source dir='%s'/>\n",
+ def->src);
+ break;
}
- virBufferEscapeString(buf, "<target dir='%s'/>\n",
- def->dst);
+ if (def->type == VIR_DOMAIN_FS_TYPE_MTP)
+ virBufferEscapeString(buf, "<target name='%s'/>\n",
+ def->dst);
+ else
+ virBufferEscapeString(buf, "<target dir='%s'/>\n",
+ def->dst);
if (def->readonly)
virBufferAddLit(buf, "<readonly/>\n");
- if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
+ if (def->type != VIR_DOMAIN_FS_TYPE_MTP &&
+ virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bffc0a5..a4d8a76 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -760,6 +760,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_MTP, /* Binds a host dir to a MTP guest device */
VIR_DOMAIN_FS_TYPE_LAST
} virDomainFSType;
--
1.9.3