]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: lvm: lvcreate fails with allocation=0, don't do that
authorCole Robinson <crobinso@redhat.com>
Wed, 17 Oct 2012 00:30:23 +0000 (20:30 -0400)
committerCole Robinson <crobinso@redhat.com>
Wed, 17 Oct 2012 01:16:44 +0000 (21:16 -0400)
On F17 at least, this command fails:

$ sudo /usr/sbin/lvcreate --name sparsetest -L 0K --virtualsize 16384K vgvirt
  Unable to create new logical volume with no extents

Which is unfortunate since allocation=0 is what virt-manager tries to use
by default.

Rather than telling the user 'don't do that', let's just give them the
smallest allocation possible if alloc=0 is requested.

https://bugzilla.redhat.com/show_bug.cgi?id=866481

src/storage/storage_backend_logical.c

index eebeec1ba80f3837ac99d28b270fee00e95c7356..de43c3a4290270d3a86bf84c2e2fac8bbd694f04 100644 (file)
@@ -725,7 +725,8 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
                                NULL);
     virCommandAddArg(cmd, "-L");
     if (vol->capacity != vol->allocation) {
-        virCommandAddArgFormat(cmd, "%lluK", VIR_DIV_UP(vol->allocation, 1024));
+        virCommandAddArgFormat(cmd, "%lluK",
+                VIR_DIV_UP(vol->allocation ? vol->allocation : 1, 1024));
         virCommandAddArg(cmd, "--virtualsize");
     }
     virCommandAddArgFormat(cmd, "%lluK", VIR_DIV_UP(vol->capacity, 1024));