1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

vmx: handle shared folders formatting

This patch adds support for generating vmx files with
shared folders enabled.

Update test suite accordingly.
This commit is contained in:
Jean-Baptiste Rouault 2012-07-11 12:16:34 +02:00 committed by Matthias Bolte
parent df80282dab
commit 1f2bd1072a
5 changed files with 95 additions and 1 deletions

View File

@ -261,6 +261,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 ########################################################################
@ -3138,7 +3161,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) {
@ -3491,6 +3523,31 @@ virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def,
int
virVMXFormatFileSystem(virDomainFSDefPtr def, int number, virBufferPtr buffer)
{
if (def->type != VIR_DOMAIN_FS_TYPE_MOUNT) {
virReportError(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", number);
virBufferAsprintf(buffer, "sharedFolder%d.enabled = \"true\"\n", number);
virBufferAsprintf(buffer, "sharedFolder%d.readAccess = \"true\"\n", number);
virBufferAsprintf(buffer, "sharedFolder%d.writeAccess = \"%s\"\n", number,
def->readonly ? "false" : "true");
virBufferAsprintf(buffer, "sharedFolder%d.hostPath = \"%s\"\n", number,
def->src);
virBufferAsprintf(buffer, "sharedFolder%d.guestName = \"%s\"\n", number,
def->dst);
return 0;
}
int
virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
virBufferPtr buffer)

View File

@ -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 number,
virBufferPtr buffer);
int virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
virBufferPtr buffer);

View File

@ -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"

View File

@ -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>

View File

@ -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);