initial specific VM formats support

Raw disk images are convenient and universal
but there are custom formats like Qemu's qcow2
providing additional features, e.g. copy-on-write
or space savings.  All of this ultimately belongs
to mkimage but in the mean time has been implemented
here as well.
This commit is contained in:
Michael Shigorin 2012-06-19 16:51:56 +03:00
parent 90be07fbf8
commit 8a04d9b656
4 changed files with 26 additions and 5 deletions

View File

@ -26,7 +26,7 @@ endif
# recursive make considered useful for m-p
MAKE += -r --no-print-directory
DIRECT_TARGETS := clean distclean check help help/distro help/ve
DIRECT_TARGETS := clean distclean check help help/distro help/ve help/vm
.PHONY: $(DIRECT_TARGETS)
$(DIRECT_TARGETS):
@$(MAKE) -f main.mk $@

View File

@ -13,6 +13,10 @@ mike ALL=NOPASSWD: /usr/share/mkimage-profiles/bin/tar2vm
пользователю право выполнять с повышенными привилегиями доступный ему
по записи скрипт равнозначно предоставлению полных привилегий root.
Для работы с более специфичными форматами, чем raw ("буквальный"
образ диска), потребуется утилита qemu-img из одноименного пакета;
см. тж. вывод команды make help/vm
Также потребуется пакет multipath-tools (/sbin/kpartx).
Пример сборки и запуска VM:

View File

@ -9,6 +9,7 @@ IMAGE_PACKAGES = $(SYSTEM_PACKAGES) \
# intermediate chroot archive
VM_TARBALL := $(IMAGE_OUTDIR)/$(IMAGE_NAME).tar
VM_RAWDISK := $(IMAGE_OUTDIR)/$(IMAGE_NAME).raw
check-sudo:
@if ! type -t sudo >&/dev/null; then \
@ -16,15 +17,29 @@ check-sudo:
exit 1; \
fi
convert-image: check-sudo
prepare-image: check-sudo
@if ! sudo $(TOPDIR)/bin/tar2vm \
"$(VM_TARBALL)" "$(IMAGE_OUTPATH)" $$VM_SIZE; then \
"$(VM_TARBALL)" "$(VM_RAWDISK)" $$VM_SIZE; then \
echo "** error: sudo tar2vm failed, see also doc/vm.txt" >&2; \
exit 1; \
fi
convert-image: prepare-image
@case "$(IMAGE_TYPE)" in \
"img") VM_FORMAT="raw";; \
"vhd") VM_FORMAT="vpc";; \
*) VM_FORMAT="$(IMAGE_TYPE)"; \
esac; \
if ! type -t qemu-img >&/dev/null; then \
echo "** warning: qemu-img not available" >&2; \
else \
qemu-img convert -O "$$VM_FORMAT" \
"$(VM_RAWDISK)" "$(IMAGE_OUTPATH)"; \
fi
run-image-scripts: GLOBAL_ROOTPW := $(ROOTPW)
# override
pack-image: MKI_PACK_RESULTS := tar:$(VM_TARBALL)
all: $(GLOBAL_DEBUG) build-image copy-tree run-image-scripts pack-image \

View File

@ -1,3 +1,5 @@
### this might really belong to build-*...
# distributions
DISTRO_EXTS := .iso
@ -38,6 +40,6 @@ $(foreach c,$(VE_ARCHIVES), \
$(eval $(call PACK_compressors,$(c),$(z)))))
# virtual machines
VM_EXTS := .img
VM_EXTS := .img .qcow2 .vdi .vmdk .vhd
use/pack/img: use/pack; @:
$(VM_EXTS:.%=use/pack/%): use/pack; @: