9119d9
From 66cee818fd9a9651cbaf2421068e8dae2a5b92b2 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <66cee818fd9a9651cbaf2421068e8dae2a5b92b2@dist-git>
9119d9
From: John Ferlan <jferlan@redhat.com>
9119d9
Date: Wed, 17 Dec 2014 06:31:21 -0500
9119d9
Subject: [PATCH] logical: Add "--type snapshot" to lvcreate command
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1166592
9119d9
9119d9
A recent lvm change has resulted in a change for the "default" type of
9119d9
logical volume created when the "--virtualsize" or "--V" is supplied on
9119d9
the command line (e.g. when the allocation and capacity values of a to
9119d9
be created volume differ). It seems that at the very least the following
9119d9
change adjusts the default type:
9119d9
9119d9
https://git.fedorahosted.org/cgit/lvm2.git/commit/?id=e0164f21
9119d9
9119d9
and the following may also have some impact.
9119d9
9119d9
https://git.fedorahosted.org/cgit/lvm2.git/commit/?id=87fc3b71
9119d9
9119d9
When using the virsh vol-create-as or vol-create xmlfile commands, the
9119d9
result is that libvirt will now create a "thin logical volume" and a
9119d9
"thin logical volume pool" rather than just a "thin snapshot logical
9119d9
volume". For example the following sequence:
9119d9
9119d9
  # lvcreate --name test -L 2M -V 5M lvm_test
9119d9
    Rounding up size to full physical extent 4.00 MiB
9119d9
    Rounding up size to full physical extent 8.00 MiB
9119d9
    Logical volume "test" created.
9119d9
  # lvs lvm_test
9119d9
    LV    VG       Attr       LSize Pool  Origin Data%  Meta%  Move Log Cpy%Sync Convert
9119d9
    lvol1 lvm_test twi-a-tz-- 4.00m              0.00   0.98
9119d9
    test  lvm_test Vwi-a-tz-- 8.00m lvol1        0.00
9119d9
9119d9
compared to the former code which had the following:
9119d9
9119d9
    LV   VG       Attr       LSize  Pool Origin         Data%  Move Log Cpy%Sync Convert
9119d9
    test LVM_Test swi-a-s---  4.00m      [test_vorigin]   0.00
9119d9
9119d9
Since libvirt doesn't know how to parse the thin logical volume
9119d9
and pool, it will fail to find the newly created volume and pool
9119d9
even though it exists in the volume group.
9119d9
9119d9
It cannot find since the command used to find/parse returns a thin volume
9119d9
'test' with no associated device, for example the output is:
9119d9
9119d9
  lvol1##UgUwkp-fTFP-C0rc-ufue-xrYh-dkPr-FGPFPx#lvol1_tdata(0)#thin-pool#1#4194304#4194304#4194304#twi-a-tz--
9119d9
  test##NcaIoH-4YWJ-QKu3-sJc3-EOcS-goff-cThLIL##thin#0#8388608#4194304#8388608#Vwi-a-tz--
9119d9
9119d9
as compared to the former which had the following:
9119d9
9119d9
      test#[test_vorigin]#Dt5Of3-4WE6-buvw-CWJ4-XOiz-ywOU-YULYw6#/dev/sda3(1300)#linear#1#4194304#4194304#4194304#swi-a-s---
9119d9
9119d9
While it's possible to generate code to handle the new thin lv and pool, this
9119d9
patch will add a "--type snapshot" onto the lvcreate command libvirt uses
9119d9
in order to "for now" be able to continue to utilize the thin snapshots
9119d9
9119d9
(cherry picked from commit cafb934db850944e3b3cf4e3f6c4e28df4610b81)
9119d9
Signed-off-by: John Ferlan <jferlan@redhat.com>
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/storage/storage_backend_logical.c | 1 +
9119d9
 1 file changed, 1 insertion(+)
9119d9
9119d9
diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
9119d9
index 4959985..8aa68a6 100644
9119d9
--- a/src/storage/storage_backend_logical.c
9119d9
+++ b/src/storage/storage_backend_logical.c
9119d9
@@ -758,6 +758,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
9119d9
         virCommandAddArgFormat(cmd, "%lluK",
9119d9
                                VIR_DIV_UP(vol->target.allocation
9119d9
                                           ? vol->target.allocation : 1, 1024));
9119d9
+        virCommandAddArgList(cmd, "--type", "snapshot", NULL);
9119d9
         virCommandAddArg(cmd, "--virtualsize");
9119d9
         vol->target.sparse = true;
9119d9
     }
9119d9
-- 
9119d9
2.2.0
9119d9