ctx.parseFileName = esxParseVMXFileName;
ctx.formatFileName = NULL;
ctx.autodetectSCSIControllerModel = NULL;
+ ctx.datacenterPath = priv->primary->datacenterPath;
def = virVMXParseConfig(&ctx, priv->xmlopt, vmx);
ctx.parseFileName = esxParseVMXFileName;
ctx.formatFileName = NULL;
ctx.autodetectSCSIControllerModel = NULL;
+ ctx.datacenterPath = NULL;
def = virVMXParseConfig(&ctx, priv->xmlopt, nativeConfig);
ctx.parseFileName = NULL;
ctx.formatFileName = esxFormatVMXFileName;
ctx.autodetectSCSIControllerModel = esxAutodetectSCSIControllerModel;
+ ctx.datacenterPath = NULL;
vmx = virVMXFormatConfig(&ctx, priv->xmlopt, def, virtualHW_version);
ctx.parseFileName = NULL;
ctx.formatFileName = esxFormatVMXFileName;
ctx.autodetectSCSIControllerModel = esxAutodetectSCSIControllerModel;
+ ctx.datacenterPath = NULL;
vmx = virVMXFormatConfig(&ctx, priv->xmlopt, def, virtualHW_version);
virCommandPtr cmd;
ctx.parseFileName = vmwareCopyVMXFileName;
+ ctx.formatFileName = NULL;
+ ctx.autodetectSCSIControllerModel = NULL;
+ ctx.datacenterPath = NULL;
cmd = virCommandNewArgList(driver->vmrun, "-T",
vmwareDriverTypeToString(driver->type),
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
+ ctx.parseFileName = NULL;
ctx.formatFileName = vmwareCopyVMXFileName;
+ ctx.autodetectSCSIControllerModel = NULL;
+ ctx.datacenterPath = NULL;
vmwareDriverLock(driver);
if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
if (flags & VIR_DOMAIN_START_VALIDATE)
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
+ ctx.parseFileName = NULL;
ctx.formatFileName = vmwareCopyVMXFileName;
+ ctx.autodetectSCSIControllerModel = NULL;
+ ctx.datacenterPath = NULL;
vmwareDriverLock(driver);
}
ctx.parseFileName = vmwareCopyVMXFileName;
+ ctx.formatFileName = NULL;
+ ctx.autodetectSCSIControllerModel = NULL;
+ ctx.datacenterPath = NULL;
def = virVMXParseConfig(&ctx, driver->xmlopt, nativeConfig);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Helpers
*/
+
static int
-vmxDomainDefPostParse(virDomainDefPtr def,
- virCapsPtr caps ATTRIBUTE_UNUSED,
- void *opaque ATTRIBUTE_UNUSED)
+virVMXDomainDefPostParse(virDomainDefPtr def,
+ virCapsPtr caps ATTRIBUTE_UNUSED,
+ void *opaque ATTRIBUTE_UNUSED)
{
/* memory hotplug tunables are not supported by this driver */
if (virDomainDefCheckUnsupportedMemoryHotplug(def) < 0)
}
static int
-vmxDomainDeviceDefPostParse(virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
- const virDomainDef *def ATTRIBUTE_UNUSED,
- virCapsPtr caps ATTRIBUTE_UNUSED,
- void *opaque ATTRIBUTE_UNUSED)
+virVMXDomainDevicesDefPostParse(virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
+ const virDomainDef *def ATTRIBUTE_UNUSED,
+ virCapsPtr caps ATTRIBUTE_UNUSED,
+ void *opaque ATTRIBUTE_UNUSED)
{
return 0;
}
-virDomainDefParserConfig virVMXDomainDefParserConfig = {
+static virDomainDefParserConfig virVMXDomainDefParserConfig = {
.hasWideSCSIBus = true,
.macPrefix = {0x00, 0x0c, 0x29},
- .devicesPostParseCallback = vmxDomainDeviceDefPostParse,
- .domainPostParseCallback = vmxDomainDefPostParse,
+ .devicesPostParseCallback = virVMXDomainDevicesDefPostParse,
+ .domainPostParseCallback = virVMXDomainDefPostParse,
};
+static void
+virVMXDomainDefNamespaceFree(void *nsdata)
+{
+ VIR_FREE(nsdata);
+}
+
+static int
+virVMXDomainDefNamespaceFormatXML(virBufferPtr buf, void *nsdata)
+{
+ const char *datacenterPath = nsdata;
+
+ if (!datacenterPath)
+ return 0;
+
+ virBufferAddLit(buf, "<vmware:datacenterpath>");
+ virBufferEscapeString(buf, "%s", datacenterPath);
+ virBufferAddLit(buf, "</vmware:datacenterpath>\n");
+
+ return 0;
+}
+
+static const char *
+virVMXDomainDefNamespaceHref(void)
+{
+ return "xmlns:vmware='http://libvirt.org/schemas/domain/vmware/1.0'";
+}
+
+static virDomainXMLNamespace virVMXDomainXMLNamespace = {
+ .parse = NULL,
+ .free = virVMXDomainDefNamespaceFree,
+ .format = virVMXDomainDefNamespaceFormatXML,
+ .href = virVMXDomainDefNamespaceHref,
+};
virDomainXMLOptionPtr
virVMXDomainXMLConfInit(void)
{
- return virDomainXMLOptionNew(&virVMXDomainDefParserConfig,
- NULL, NULL);
+ return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, NULL,
+ &virVMXDomainXMLNamespace);
}
char *
bool hgfs_disabled = true;
long long sharedFolder_maxNum = 0;
int cpumasklen;
+ char *namespaceData;
if (ctx->parseFileName == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
++def->nparallels;
}
+ /* ctx:datacenterPath -> def:namespaceData */
+ if (ctx->datacenterPath) {
+ if (VIR_STRDUP(namespaceData, ctx->datacenterPath) < 0)
+ goto cleanup;
+
+ def->ns = *virDomainXMLOptionGetNamespace(xmlopt);
+ def->namespaceData = namespaceData;
+ }
+
success = true;
cleanup:
/*
* vmx.h: VMware VMX parsing/formatting functions
*
- * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte@googlemail.com>
+ * Copyright (C) 2009-2011, 2015 Matthias Bolte <matthias.bolte@googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
int *model, void *opaque);
/*
- * virVMXParseFileName is only used by virVMXParseConfig.
- * virVMXFormatFileName is only used by virVMXFormatConfig.
- * virVMXAutodetectSCSIControllerModel is optionally used by virVMXFormatConfig.
+ * parseFileName is only used by virVMXParseConfig.
+ * formatFileName is only used by virVMXFormatConfig.
+ * autodetectSCSIControllerModel is optionally used by virVMXFormatConfig.
+ * datacenterPath is only used by virVMXFormatConfig.
*/
struct _virVMXContext {
void *opaque;
virVMXParseFileName parseFileName;
virVMXFormatFileName formatFileName;
virVMXAutodetectSCSIControllerModel autodetectSCSIControllerModel;
+ const char *datacenterPath; /* including folders */
};
--- /dev/null
+config.version = "8"
+virtualHW.version = "4"
--- /dev/null
+<domain type='vmware' xmlns:vmware='http://libvirt.org/schemas/domain/vmware/1.0'>
+ <uuid>00000000-0000-0000-0000-000000000000</uuid>
+ <memory unit='KiB'>32768</memory>
+ <currentMemory unit='KiB'>32768</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <video>
+ <model type='vmvga' vram='4096'/>
+ </video>
+ </devices>
+ <vmware:datacenterpath>folder1/folder2/datacenter1</vmware:datacenterpath>
+</domain>
ctx.parseFileName = testParseVMXFileName;
ctx.formatFileName = NULL;
ctx.autodetectSCSIControllerModel = NULL;
+ ctx.datacenterPath = NULL;
DO_TEST("case-insensitive-1", "case-insensitive-1");
DO_TEST("case-insensitive-2", "case-insensitive-2");
DO_TEST("svga", "svga");
+ ctx.datacenterPath = "folder1/folder2/datacenter1";
+
+ DO_TEST("datacenterpath", "datacenterpath");
+
virObjectUnref(caps);
virObjectUnref(xmlopt);
--- /dev/null
+.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 = "datacenterpath"
+memsize = "4"
+numvcpus = "1"
+floppy0.present = "false"
+floppy1.present = "false"
--- /dev/null
+<domain type='vmware' xmlns:vmware='http://libvirt.org/schemas/domain/vmware/1.0'>
+ <name>datacenterpath</name>
+ <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
+ <memory unit='KiB'>4096</memory>
+ <os>
+ <type>hvm</type>
+ </os>
+ <vmware:datacenterpath>folder1/folder2/datacenter1</vmware:datacenterpath>
+</domain>
ctx.parseFileName = NULL;
ctx.formatFileName = testFormatVMXFileName;
ctx.autodetectSCSIControllerModel = testAutodetectSCSIControllerModel;
+ ctx.datacenterPath = NULL;
DO_TEST("minimal", "minimal", 4);
DO_TEST("minimal-64bit", "minimal-64bit", 4);
DO_TEST("svga", "svga", 4);
+ DO_TEST("datacenterpath", "datacenterpath", 4);
+
virObjectUnref(caps);
virObjectUnref(xmlopt);