From: Vratislav Podzimek vpodzime@redhat.com
Right now, we only support creation of non-linear LVs under some conditions that allow us avoid trying to do too crazy things. Let's make sure these conditions are met when a new LVMLogicalVolumeDevice object is being created. --- blivet/devices/lvm.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py index a836ed4..4cc39e2 100644 --- a/blivet/devices/lvm.py +++ b/blivet/devices/lvm.py @@ -595,6 +595,17 @@ def __init__(self, name, parents=None, size=None, uuid=None, seg_type=None,
"""
+ if not exists: + if seg_type and seg_type != "linear" and not pvs: + raise ValueError("List of PVs has to be given for every non-linear LV") + elif (not seg_type or seg_type == "linear") and pvs: + if not all(isinstance(pv, LVPVSpec) for pv in pvs): + raise ValueError("Invalid specification of PVs for a linear LV: either no or complete " + "specification (with all space split into PVs has to be given") + elif sum(spec.size for spec in pvs) != size: + raise ValueError("Invalid specification of PVs for a linear LV: the sum of space " + "assigned to PVs is not equal to the size of the LV") + # When this device's format is set in the superclass constructor it will # try to access self.snapshots. self.snapshots = [] @@ -1612,7 +1623,7 @@ def __init__(self, name, parents=None, size=None, uuid=None, :type sysfs_path: str :keyword uuid: the device UUID :type uuid: str - :keyword seg_type: segment type + :keyword seg_type: segment type (only "linear" supported for non-existing ThinPool LVs) :type seg_type: str
For non-existent pools only: @@ -1639,6 +1650,9 @@ def __init__(self, name, parents=None, size=None, uuid=None, not blockdev.lvm.is_valid_thpool_chunk_size(chunksize): raise ValueError("invalid chunksize value")
+ if not exists and seg_type and seg_type != "linear": + raise ValueError("creation of non-linear thin pool LVs is not supported (yet)") + super(LVMThinPoolDevice, self).__init__(name, parents=parents, size=size, uuid=uuid, fmt=fmt, exists=exists,
anaconda-patches@lists.fedorahosted.org