[libvirt] [PATCH] Support transient attribute on vmware disks

Eric Blake eblake at redhat.com
Tue Dec 17 20:42:33 UTC 2013


On 12/17/2013 10:04 AM, Wout Mertens wrote:
> From: Wout Mertens <Wout.Mertens at gmail.com>
> 
> 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(-)

Congrats on your first libvirt patch.  It failed 'make syntax-check':

TAB_in_indentation
src/vmx/vmx.c:3511:	
src/vmx/vmx.c:3512:	if (def->transient) {
src/vmx/vmx.c:3513:		virBufferAsprintf(buffer, "%s%d:%d.mode =
\"independent-nonpersistent\"\n",
src/vmx/vmx.c:3514:						  busType, controllerOrBus, unit);
src/vmx/vmx.c:3515:	}
maint.mk: indent with space, not TAB, in C, sh, html, py, syms and RNG
schemas
src/vmx/vmx.c:3511:	
maint.mk: found trailing blank(s)
make: *** [sc_trailing_blank] Error 1

But I don't mind fixing those on a first-time submission.

> +++ 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;

This hunk looks spurious.

> @@ -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;

'bool_expr ? true : false' is a waste of typing.  It's just as easy to
write 'bool_expr'.

Pushed with the following squashed in:

diff --git i/src/vmx/vmx.c w/src/vmx/vmx.c
index 4282390..c04e397 100644
--- i/src/vmx/vmx.c
+++ w/src/vmx/vmx.c
@@ -1954,7 +1954,6 @@ virVMXParseDisk(virVMXContext *ctx,
virDomainXMLOptionPtr xmlopt, virConfPtr con
      *         busType = VIR_DOMAIN_DISK_BUS_FDC
      * controllerOrBus = [0]
      *            unit = [0..1]
-     *
      */

     int result = -1;
@@ -2182,7 +2181,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;
+            (*def)->transient = STRCASEEQ(mode,
"independent-nonpersistent");

             if ((*def)->src == NULL) {
                 goto cleanup;
@@ -3508,11 +3507,11 @@ virVMXFormatDisk(virVMXContext *ctx,
virDomainDiskDefPtr def,
             return -1;
         }
     }
-	
-	if (def->transient) {
-		virBufferAsprintf(buffer, "%s%d:%d.mode =
\"independent-nonpersistent\"\n",
-						  busType, controllerOrBus, unit);
-	}
+
+    if (def->transient)
+        virBufferAsprintf(buffer,
+                          "%s%d:%d.mode = \"independent-nonpersistent\"\n",
+                          busType, controllerOrBus, unit);
     return 0;
 }



-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131217/2093d268/attachment-0001.sig>


More information about the libvir-list mailing list