Revision 7d81bb8b lib/backend.py
b/lib/backend.py | ||
---|---|---|
3044 | 3044 |
_Fail("Failed to grow block device: %s", err, exc=True) |
3045 | 3045 |
|
3046 | 3046 |
|
3047 |
def BlockdevSnapshot(disk): |
|
3047 |
def BlockdevSnapshot(disk, snapshot_name=None):
|
|
3048 | 3048 |
"""Create a snapshot copy of a block device. |
3049 | 3049 |
|
3050 | 3050 |
This function is called recursively, and the snapshot is actually created |
... | ... | |
3061 | 3061 |
_Fail("DRBD device '%s' without backing storage cannot be snapshotted", |
3062 | 3062 |
disk.unique_id) |
3063 | 3063 |
return BlockdevSnapshot(disk.children[0]) |
3064 |
elif disk.dev_type == constants.DT_PLAIN: |
|
3064 |
elif disk.dev_type == constants.DT_PLAIN and not snapshot_name:
|
|
3065 | 3065 |
r_dev = _RecursiveFindBD(disk) |
3066 | 3066 |
if r_dev is not None: |
3067 | 3067 |
# FIXME: choose a saner value for the snapshot size |
... | ... | |
3069 | 3069 |
return r_dev.Snapshot(disk.size) |
3070 | 3070 |
else: |
3071 | 3071 |
_Fail("Cannot find block device %s", disk) |
3072 |
elif disk.dev_type == constants.DT_EXT: |
|
3073 |
r_dev = _RecursiveFindBD(disk) |
|
3074 |
if r_dev is not None: |
|
3075 |
r_dev.Snapshot(snapshot_name) |
|
3076 |
else: |
|
3077 |
_Fail("Cannot find block device %s", disk) |
|
3072 | 3078 |
else: |
3073 | 3079 |
_Fail("Cannot snapshot non-lvm block device '%s' of type '%s'", |
3074 | 3080 |
disk.unique_id, disk.dev_type) |
Also available in: Unified diff