diff options
author | Matthias Bolte <matthias.bolte@googlemail.com> | 2010-08-05 17:43:19 +0200 |
---|---|---|
committer | Matthias Bolte <matthias.bolte@googlemail.com> | 2010-08-11 16:17:50 +0200 |
commit | 3de8245560267f6a06afe34a70117211b7b7e68f (patch) | |
tree | 610799e8b8e8667e5005fc117ec11366fa2b9612 /tests/xml2vmxtest.c | |
parent | allow memballoon type of none to desactivate it (diff) | |
download | libvirt-3de8245560267f6a06afe34a70117211b7b7e68f.tar.gz libvirt-3de8245560267f6a06afe34a70117211b7b7e68f.tar.bz2 libvirt-3de8245560267f6a06afe34a70117211b7b7e68f.zip |
esx: Split VMX code into a general and an ESX specific part
Introduce esxVMX_Context containing functions pointers to
glue both parts together in a generic way.
Move the ESX specific part to esx_driver.c.
This is a step towards making the VMX code reusable in a
potential VMware Workstation and VMware Player driver.
Diffstat (limited to 'tests/xml2vmxtest.c')
-rw-r--r-- | tests/xml2vmxtest.c | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 0a9bc5389..eed3ac074 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -14,6 +14,7 @@ static char *progname = NULL; static char *abs_srcdir = NULL; static virCapsPtr caps = NULL; +static esxVMX_Context ctx; # define MAX_FILE 4096 @@ -92,7 +93,7 @@ testCompareFiles(const char *xml, const char *vmx, goto failure; } - formatted = esxVMX_FormatConfig(NULL, caps, def, productVersion); + formatted = esxVMX_FormatConfig(&ctx, caps, def, productVersion); if (formatted == NULL) { goto failure; @@ -134,6 +135,60 @@ testCompareHelper(const void *data) } static int +testAutodetectSCSIControllerModel(virDomainDiskDefPtr def ATTRIBUTE_UNUSED, + int *model, void *opaque ATTRIBUTE_UNUSED) +{ + *model = VIR_DOMAIN_CONTROLLER_MODEL_LSILOGIC; + + return 0; +} + +static char * +testFormatVMXFileName(const char *src, void *opaque ATTRIBUTE_UNUSED) +{ + bool success = false; + char *datastoreName = NULL; + char *directoryName = NULL; + char *fileName = NULL; + char *absolutePath = NULL; + + if (STRPREFIX(src, "[")) { + /* Found potential datastore path */ + if (esxUtil_ParseDatastorePath(src, &datastoreName, &directoryName, + &fileName) < 0) { + goto cleanup; + } + + if (directoryName == NULL) { + virAsprintf(&absolutePath, "/vmfs/volumes/%s/%s", datastoreName, + fileName); + } else { + virAsprintf(&absolutePath, "/vmfs/volumes/%s/%s/%s", datastoreName, + directoryName, fileName); + } + } else if (STRPREFIX(src, "/")) { + /* Found absolute path */ + absolutePath = strdup(src); + } else { + /* Found relative path, this is not supported */ + goto cleanup; + } + + success = true; + + cleanup: + if (! success) { + VIR_FREE(absolutePath); + } + + VIR_FREE(datastoreName); + VIR_FREE(directoryName); + VIR_FREE(fileName); + + return absolutePath; +} + +static int mymain(int argc, char **argv) { int result = 0; @@ -157,7 +212,7 @@ mymain(int argc, char **argv) return EXIT_FAILURE; } -# define DO_TEST(_in, _out, _version) \ +# define DO_TEST(_in, _out, _version) \ do { \ struct testInfo info = { _in, _out, _version }; \ virResetLastError(); \ @@ -173,6 +228,11 @@ mymain(int argc, char **argv) return EXIT_FAILURE; } + ctx.opaque = NULL; + ctx.parseFileName = NULL; + ctx.formatFileName = testFormatVMXFileName; + ctx.autodetectSCSIControllerModel = testAutodetectSCSIControllerModel; + DO_TEST("minimal", "minimal", esxVI_ProductVersion_ESX35); DO_TEST("minimal-64bit", "minimal-64bit", esxVI_ProductVersion_ESX35); |