[PATCH] Support transient attribute on vmware disks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Wout Mertens <Wout.Mertens@xxxxxxxxx>

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

---
 src/vmx/vmx.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 48487f8..4282390 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -1954,6 +1954,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
      *         busType = VIR_DOMAIN_DISK_BUS_FDC
      * controllerOrBus = [0]
      *            unit = [0..1]
+     *
      */
 
     int result = -1;
@@ -1980,6 +1981,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 +2097,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 +2126,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 +2182,7 @@ 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;
+            (*def)->transient = STRCASEEQ(mode, "independent-nonpersistent") ? true: false;
 
             if ((*def)->src == NULL) {
                 goto cleanup;
@@ -3497,7 +3508,11 @@ virVMXFormatDisk(virVMXContext *ctx, virDomainDiskDefPtr def,
             return -1;
         }
     }
-
+	
+	if (def->transient) {
+		virBufferAsprintf(buffer, "%s%d:%d.mode = \"independent-nonpersistent\"\n",
+						  busType, controllerOrBus, unit);
+	}
     return 0;
 }
 
-- 
1.8.2.3


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]