From 5d7e4f0cf335235c09e4c2d797fe1cf870f5cba9 Mon Sep 17 00:00:00 2001 From: Wout Mertens Date: Tue, 17 Dec 2013 18:04:35 +0100 Subject: [PATCH] Support transient attribute on vmware disks vmx/vmx.c ignores the transient attribute on the disk xml format. This patch adds a 1-1 relationship between it and [disk].mode = "independent-nonpersistent". The other modes are ignored as before. It works in my testing. https://bugzilla.redhat.com/show_bug.cgi?id=1044023 Signed-off-by: Eric Blake --- src/vmx/vmx.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 48487f832f..8fb2a9308e 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1980,6 +1980,9 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con char writeThrough_name[32] = ""; bool writeThrough = false; + char mode_name[32] = ""; + char *mode = NULL; + if (def == NULL || *def != NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); return -1; @@ -2093,6 +2096,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con VMX_BUILD_NAME(fileType); VMX_BUILD_NAME(fileName); VMX_BUILD_NAME(writeThrough); + VMX_BUILD_NAME(mode); /* vmx:present */ if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) { @@ -2121,6 +2125,11 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con goto cleanup; } + /* vmx:mode -> def:transient */ + if (virVMXGetConfigString(conf, mode_name, &mode, true) < 0) { + goto cleanup; + } + if (clientDevice) { /* * Just ignore devices in client mode, because I have no clue how to @@ -2172,6 +2181,9 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con (*def)->src = ctx->parseFileName(fileName, ctx->opaque); (*def)->cachemode = writeThrough ? VIR_DOMAIN_DISK_CACHE_WRITETHRU : VIR_DOMAIN_DISK_CACHE_DEFAULT; + if (mode) + (*def)->transient = STRCASEEQ(mode, + "independent-nonpersistent"); if ((*def)->src == NULL) { goto cleanup; @@ -2290,6 +2302,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con VIR_FREE(deviceType); VIR_FREE(fileType); VIR_FREE(fileName); + VIR_FREE(mode); return result; @@ -3498,6 +3511,10 @@ virVMXFormatDisk(virVMXContext *ctx, virDomainDiskDefPtr def, } } + if (def->transient) + virBufferAsprintf(buffer, + "%s%d:%d.mode = \"independent-nonpersistent\"\n", + busType, controllerOrBus, unit); return 0; } -- GitLab