]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Support transient attribute on vmware disks
authorWout Mertens <Wout.Mertens@gmail.com>
Tue, 17 Dec 2013 17:04:35 +0000 (18:04 +0100)
committerEric Blake <eblake@redhat.com>
Tue, 17 Dec 2013 21:24:49 +0000 (14:24 -0700)
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 <eblake@redhat.com>
src/vmx/vmx.c

index 48487f832fcb4836d38fc2e155c5c2405dca7c61..8fb2a9308ee0d91504f73d23d3b1ed6f99845807 100644 (file)
@@ -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;
 }