]> git.proxmox.com Git - proxmox-backup.git/commit - proxmox-backup-client/src/main.rs
client: implement map/unmap commands for .img backups
authorStefan Reiter <s.reiter@proxmox.com>
Mon, 5 Oct 2020 08:57:58 +0000 (10:57 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 6 Oct 2020 07:08:14 +0000 (09:08 +0200)
commit45f9b32e0f030dff9c28cfeb0b218444cf5dfa69
treeaf184a1b16248d8b3a1f7d8dc0d4ce1fbf92b0c4
parent1d0b662b42c36786fbd016e9bd31737c59335648
client: implement map/unmap commands for .img backups

Allows mapping fixed-index .img files (usually from VM backups) to be
mapped to a local loopback device.

The architecture uses a FUSE-backed temp file mapped to a loopdev:

  /dev/loopX -> FUSE /run/pbs-loopdev/xxx -> backup client -> PBS

Since unmapping requires some cleanup (unmap the loopdev, stop FUSE,
remove the temp files) a special 'unmap' command is added, which uses a
PID file to send SIGINT to the backup-client instance started with
'map', which will handle the cleanup itself.

The polling with select! in mount.rs needs to be split in two, since we
have a chicken and egg problem between running FUSE and setting up the
loop device - so we need to do them concurrently, until the loopdev is
assigned, at which point we can report success and daemonize, and then
continue polling the FUSE loop future.

A loopdev module is added to tools containing all required functions for
mapping a loop device to the FUSE file, with the ioctls moved into an
inline module to avoid exposing them directly.

The client code is placed in the 'mount' module, which, while
admittedly a loose fit, allows reuse of the daemonizing code.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
src/bin/proxmox-backup-client.rs
src/bin/proxmox_backup_client/mount.rs
src/tools.rs
src/tools/fuse_loop.rs [new file with mode: 0644]
src/tools/loopdev.rs [new file with mode: 0644]