The path of a mount point does not need to start with a slash, for
example a mount point configured with
mp0: tank:subvol-999-disk-0,mp=data,size=1G,backup=1
gets mounted at /data in the container when it starts. The backup code
however builds its paths by appending the path of the mount point to
the root directory, which only works with a leading slash. So such a
mount point broke all three backup modes, as it ended up as
'/mnt/vzsnap0/.data' instead of '/mnt/vzsnap0/./data' in snapshot and
stop mode, and as '/proc/<PID>/root//.data' in suspend mode.
Add the missing leading slash when collecting the mount points for the
backup, so that all paths built from it are correct. This also anchors
the exclude pattern of such a mount point if it is excluded from the
backup, which otherwise matched every file or directory with the same
name in suspend mode.
Signed-off-by: Michal Fox <me@dualfroz.com>
When the last tag of a container gets removed, for example in the web
UI, the API gets an empty 'tags' value, which then ends up as an empty
'tags:' line in the config and in the output of 'pct config'. As the
config parser reads that line back as a single space, it also gets
written out again on every following config change.
Skip a tag list without any tag when writing the config, which also
cleans up existing configs with such a line on their next change. Keep
it in the pending section, where it is still needed for removing all
tags with a pending change.
Add a basic test for parsing and writing container configs, similar to
the one in qemu-server, to cover this.
Signed-off-by: Michal Fox <me@dualfroz.com>