vzctl create --ostemplate: add support for .bz2 and .xz
Support for compressors other than gzip was not added mostly
because there was no way to find out the uncompressed file
size.
Now good news: recent versions of xz (as in Fedora 14) implement
-l --robot flags which can be used to get the uncompressed size.
For bzip2 and older xz we can estimate uncompressed file sizes by
multiplying compressed size to some factor. I did a quick test
(see bug report below) and ended up with 3 and 4.7 multipliers
for bzip2 -9 and xz -9, respectively.
Because of the above, using bzip2 for templates IS NOT RECOMMENDED.
Error message ("file not found") has changed appropriately
since we are now looking for a few files. If --verbose is specified,
we also print full names of all the files we try:
# vzctl --verbose create 1234567 --ostemplate aka
Creating container private area (aka)
Looking for /vz/template/cache/aka.tar
Looking for /vz/template/cache/aka.tar.gz
Looking for /vz/template/cache/aka.tar.bz2
Looking for /vz/template/cache/aka.tar.xz
Cached OS template /vz/template/cache/aka.tar[.gz|.bz2|.xz] not found
Creation of container private area failed
# echo $?
91
Loosely based on patch from Víctor Román Archidona.
http://bugzilla.openvz.org/1670
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
2 files changed