From 2952f0e90728c15707b03f9769ac5e0b8790d76e Mon Sep 17 00:00:00 2001
From: Jarrod Johnson <jbjohnso@us.ibm.com>
Date: Fri, 9 Aug 2013 10:30:58 -0400
Subject: [PATCH] Do sparse allocation for non-lvm raw format images

---
 xCAT-server/lib/xcat/plugins/kvm.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm
index 2c52ffb1e..53d7568ef 100644
--- a/xCAT-server/lib/xcat/plugins/kvm.pm
+++ b/xCAT-server/lib/xcat/plugins/kvm.pm
@@ -278,7 +278,9 @@ sub get_filepath_by_url { #at the end of the day, the libvirt storage api gives
     my $create = $args{create};
     my $force = $args{force};
     my $format = $args{format};
+    my $sparse = 1;
     if ($url =~ /^lvm:/) {
+    $sparse = 0;
 	$format = 'raw';
     }
     unless ($format) {
@@ -327,7 +329,7 @@ sub get_filepath_by_url { #at the end of the day, the libvirt storage api gives
             #  additionally, when mastering a powered down node, we should rebase the node to be a cow clone of the master it just spawned
         } else {
 	    my $vol;
-	    if ($format eq 'raw') { #skip allocation specification for now
+	    unless  ($sparse) { #skip allocation specification for now
 	       #currently, LV can have reduced allocation, but *cannot* grow.....
                $vol = $poolobj->create_volume("<volume><name>".$desiredname."</name><target><format type='$format'/></target><capacity>".getUnits($create,"G",1)."</capacity></volume>");
 	    } else {