This patch adds support for generating vmx files with
shared folders enabled.
Update test suite accordingly.
---
src/vmx/vmx.c | 59 +++++++++++++++++++++++++++-
src/vmx/vmx.h | 3 ++
tests/xml2vmxdata/xml2vmx-sharedfolder.vmx | 18 +++++++++
tests/xml2vmxdata/xml2vmx-sharedfolder.xml | 14 +++++++
tests/xml2vmxtest.c | 2 +
5 files changed, 95 insertions(+), 1 deletion(-)
create mode 100644 tests/xml2vmxdata/xml2vmx-sharedfolder.vmx
create mode 100644 tests/xml2vmxdata/xml2vmx-sharedfolder.xml
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 3de7062..8a26f8c 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -262,6 +262,29 @@ def->disks[0]...
################################################################################
+## filesystems #################################################################
+
+ isolation.tools.hgfs.disable = "false"
# defaults to "true"
+
+def->nfss = 1 <=> sharedFolder.maxNum = "1"
# must match the number of shared folders
+
+ sharedFolder[0..n] -> <filesystem>
+
+def->fss[0]... <=> sharedFolder0.present = "true"
# defaults to "false"
+ sharedFolder0.enabled = "true"
# defaults to "false"
+ sharedFolder0.expiration = "never"
# defaults to "never"
+ sharedFolder0.readAccess = "true"
# defaults to "false"
+->type = _FS_TYPE_MOUNT
+->fsdriver
+->accessmode
+->wrpolicy
+->src = <value> <=> sharedFolder0.hostPath =
"<value>" # defaults to ?
+->dst = <value> <=> sharedFolder0.guestName =
"<value>"
+->readonly = <readonly> <=> sharedFolder0.writeAccess =
"<value>" # "true" -> <readonly> = 0,
"false" -> <readonly> = 1
+
+
+
+################################################################################
## nets ########################################################################
ethernet[0..3] -> <controller>
@@ -3142,7 +3165,16 @@ virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps,
virDomainDefPtr def,
}
/* def:fss */
- /* FIXME */
+ if (def->nfss > 0) {
+ virBufferAddLit(&buffer, "isolation.tools.hgfs.disable =
\"false\"\n");
+ virBufferAsprintf(&buffer, "sharedFolder.maxNum =
\"%d\"\n", def->nfss);
+ }
+
+ for (i = 0; i < def->nfss; ++i) {
+ if (virVMXFormatFileSystem(def->fss[i], i, &buffer) < 0) {
+ goto cleanup;
+ }
+ }
/* def:nets */
for (i = 0; i < def->nnets; ++i) {
@@ -3496,6 +3528,31 @@ virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def,
int
+virVMXFormatFileSystem(virDomainFSDefPtr def, int index, virBufferPtr buffer)
+{
+ if (def->type != VIR_DOMAIN_FS_TYPE_MOUNT) {
+ VMX_ERROR(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Only '%s' filesystem type is supported"),
+ virDomainFSTypeToString(VIR_DOMAIN_FS_TYPE_MOUNT));
+ return -1;
+ }
+
+ virBufferAsprintf(buffer, "sharedFolder%d.present = \"true\"\n",
index);
+ virBufferAsprintf(buffer, "sharedFolder%d.enabled = \"true\"\n",
index);
+ virBufferAsprintf(buffer, "sharedFolder%d.readAccess =
\"true\"\n", index);
+ virBufferAsprintf(buffer, "sharedFolder%d.writeAccess =
\"%s\"\n", index,
+ def->readonly ? "false" : "true");
+ virBufferAsprintf(buffer, "sharedFolder%d.hostPath = \"%s\"\n",
index,
+ def->src);
+ virBufferAsprintf(buffer, "sharedFolder%d.guestName = \"%s\"\n",
index,
+ def->dst);
+
+ return 0;
+}
+
+
+
+int
virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
virBufferPtr buffer)
{
diff --git a/src/vmx/vmx.h b/src/vmx/vmx.h
index 4d54660..656aafa 100644
--- a/src/vmx/vmx.h
+++ b/src/vmx/vmx.h
@@ -120,6 +120,9 @@ int virVMXFormatCDROM(virVMXContext *ctx, virDomainDiskDefPtr def,
int virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def,
virBufferPtr buffer, bool floppy_present[2]);
+int virVMXFormatFileSystem(virDomainFSDefPtr def, int index,
+ virBufferPtr buffer);
+
int virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
virBufferPtr buffer);
diff --git a/tests/xml2vmxdata/xml2vmx-sharedfolder.vmx
b/tests/xml2vmxdata/xml2vmx-sharedfolder.vmx
new file mode 100644
index 0000000..15a322a
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-sharedfolder.vmx
@@ -0,0 +1,18 @@
+.encoding = "UTF-8"
+config.version = "8"
+virtualHW.version = "4"
+guestOS = "other"
+uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
+displayName = "sharedFolder"
+memsize = "4"
+numvcpus = "1"
+floppy0.present = "false"
+floppy1.present = "false"
+isolation.tools.hgfs.disable = "false"
+sharedFolder.maxNum = "1"
+sharedFolder0.present = "true"
+sharedFolder0.enabled = "true"
+sharedFolder0.readAccess = "true"
+sharedFolder0.writeAccess = "true"
+sharedFolder0.hostPath = "/path/to/shared"
+sharedFolder0.guestName = "shared"
diff --git a/tests/xml2vmxdata/xml2vmx-sharedfolder.xml
b/tests/xml2vmxdata/xml2vmx-sharedfolder.xml
new file mode 100644
index 0000000..2cc87d5
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-sharedfolder.xml
@@ -0,0 +1,14 @@
+<domain type='vmware'>
+ <name>sharedFolder</name>
+ <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
+ <memory unit='KiB'>4096</memory>
+ <os>
+ <type>hvm</type>
+ </os>
+ <devices>
+ <filesystem type='mount'>
+ <source dir='/path/to/shared'/>
+ <target dir='shared'/>
+ </filesystem>
+ </devices>
+</domain>
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index 60a24b2..451b1e4 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -255,6 +255,8 @@ mymain(void)
DO_TEST("floppy-file", "floppy-file", 4);
DO_TEST("floppy-device", "floppy-device", 4);
+ DO_TEST("sharedfolder", "sharedfolder", 4);
+
DO_TEST("ethernet-e1000", "ethernet-e1000", 4);
DO_TEST("ethernet-vmxnet2", "ethernet-vmxnet2", 4);
--
1.7.10.4