Add temporary snapshot flag to DiskDescriptor.xml (1/10)

Add ability to read/write <Temporary> xml tag

Reference: PSBM-24755 "Temporary snapshots & their auto merge"
Reference:ploop@979393
Prepare ploop_create_snapshot to process temporary flag (2/10)

* make ploop_create_snapshot() as wrapper on  do_create_snapshot()
* move ploop_create_snapshot to lib/snapshot.c

Reference: ploop@979395
do_create_snapshot: minor cleanup enhancement

Handle DiskDescriptor.xml.tmp cleanup

Reference: ploop@979398
Create temporary snapshot (3/10)

Temporary  snapshot marked as <Temporary> in DiskDescriptor.xml
after snapshot have  created it mounted and snapshot device is opened
to lock snapshot from auto merge. The caller should close holder_fd
and merge snapshot.

* API
struct ploop_tsnapshot_param {
       char *guid;
       char *target;
       char device[64];
};
int ploop_create_temporary_snapshot(struct ploop_disk_images_data *di,
		struct ploop_tsnapshot_param *param, int *holder_fd);

Reference: PSBM-24755 "Temporary snapshots & their auto merge"
Reference: ploop@979401
ploop_find_dev, ploop_get_dev_by_delta: fix args

For some reason, the first two arguments of these two functions were
mixed up. It all worked though, because of double error effect.

This also presumably makes ploop_get_devs() working (currently there
are no users of this function).

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
ploop_get_dev_by_delta: search device by basedelta & topdelta pair (4/10)

Will be used to release mounted snapshot on snapshot merge action.

Reference: PSBM-24755 "Temporary snapshots & their auto merge"
Reference: ploop@979404
ploop_merge_snapshot_by_guid: umount snapshots on merge (5/10)

To not fail merging temporary snapshot, do umount all snapshots
that were mounted by guid.

Reference: PSBM-24755 "Temporary snapshots & their auto merge"
Reference: ploop@979410
merge temporary snapshot (6/10)

Added functionality to merge all not in use temporary snapshots

Reference: PSBM-24755 "Temporary snapshots & their auto merge"
Reference: ploop@979412
auto merge temporary snnapshot on mount & snapshot-create action (7/10)

Reference: PSBM-24755 "Temporary snapshots & their auto merge"
Reference: ploop@979413
ploop_switch_snapshot: deny to switch to temporary snapshot (8/10)

Reference: PSBM-24755 "Temporary snapshots & their auto merge"
Reference: ploop@979414
display snapshot type on create/delete

Reference: ploop@979415
validate_disk_descriptor: validate top delta (9/10)

Top delta can't be a temporary snapshot

Reference: PSBM-24755 "Temporary snapshots & their auto merge"
Reference: ploop@979416
tools/ploop: create temporary snapshot (10/10)

ploop tsnapshot -u <uuid> -c <component_name> [-m <MOUNT_POINT>] DiskDescriptor.xml

Reference: PSBM-24755 "Temporary snapshots & their auto merge"
Reference: ploop@979419
snapshot.c: move snapshot related code ploop.c -> snapshot.c

Reference: ploop@979426

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
is_snapshot_in_use: report snapshot is busy ploop_get_dev_by_delta() failure

Reference: ploop@980305

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
is_snapshot_in_use: use open_count to check locking state

The temporary snapshot do open /dev/ploopN to lock the snapshot.
This patch introduces logic to handle /sys/block/ploopN/pstate/open_count
reference counter on auto merge,

Snapshot is locked if:
  count >= 2
  count == 1 and not mounted

Reference: PSBM-24755 "Temporary snapshots & their auto merge"
Reference: ploop@981711

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
ploop tsnapshot: allow to specify mount point

 #ploop tsnapshot -u <uuid> -c <component_name> [-m MOUNT_POINT] DiskDescriptor.xml

Reference: PSBM-24755 "Temporary snapshots & their auto merge"
Reference: ploop@981721

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Introduce two locking schemas for temporary snapshots

Temporary snapshot locked in
ploop_create_temporary_snapshot(..., int *holder_fd)
the snapshot is locked until caller not closed holder_fd

It is hard to use that schema in bash script. This patch introduces
lock by ploop device, in case holder_fd is not passed the snapshot
is in locked state until device is mounted.

Reference: ploop@982200
is_snapshot_in_use: missed inuse assigment

Reference: ploop@982424
Use component name in find device logic only on mount/umount

All ploop action performed on main ploop device (without component_name).
The only mount/umount use component_name to mount/umount snapshots.

Reference: ploop@983108