diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2016-03-30 00:23:09 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-03-31 23:01:37 +0100 |
commit | 723fa563a09daaf7d1b7e9c1bb079139b3e84677 (patch) | |
tree | 6ae64a1e5f556fc51dafb00dbdcebba3a3aa8053 | |
parent | 9e588481f866acb7ba09fb8a21fe32df42633af2 (diff) | |
download | poky-723fa563a09daaf7d1b7e9c1bb079139b3e84677.tar.gz |
boot-directdisk.bbclass: merge it into image-vm.bbclass
They are doing the same things: create virtual machine images, merge
them into one bbclass makes it easy to understand.
(From OE-Core rev: c314fda9d739560b6a08e627e7aabf105d97c8c4)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/boot-directdisk.bbclass | 190 | ||||
-rw-r--r-- | meta/classes/image-vm.bbclass | 216 |
2 files changed, 198 insertions, 208 deletions
diff --git a/meta/classes/boot-directdisk.bbclass b/meta/classes/boot-directdisk.bbclass deleted file mode 100644 index 46f88ac9bf..0000000000 --- a/meta/classes/boot-directdisk.bbclass +++ /dev/null | |||
@@ -1,190 +0,0 @@ | |||
1 | # boot-directdisk.bbclass | ||
2 | # (loosly based off bootimg.bbclass Copyright (C) 2004, Advanced Micro Devices, Inc.) | ||
3 | # | ||
4 | # Create an image which can be placed directly onto a harddisk using dd and then | ||
5 | # booted. | ||
6 | # | ||
7 | # This uses syslinux. extlinux would have been nice but required the ext2/3 | ||
8 | # partition to be mounted. grub requires to run itself as part of the install | ||
9 | # process. | ||
10 | # | ||
11 | # The end result is a 512 boot sector populated with an MBR and partition table | ||
12 | # followed by an msdos fat16 partition containing syslinux and a linux kernel | ||
13 | # completed by the ext2/3 rootfs. | ||
14 | # | ||
15 | # We have to push the msdos parition table size > 16MB so fat 16 is used as parted | ||
16 | # won't touch fat12 partitions. | ||
17 | |||
18 | # External variables needed | ||
19 | |||
20 | # ${ROOTFS} - the rootfs image to incorporate | ||
21 | |||
22 | do_bootdirectdisk[depends] += "dosfstools-native:do_populate_sysroot \ | ||
23 | virtual/kernel:do_deploy \ | ||
24 | syslinux:do_populate_sysroot \ | ||
25 | syslinux-native:do_populate_sysroot \ | ||
26 | parted-native:do_populate_sysroot \ | ||
27 | mtools-native:do_populate_sysroot " | ||
28 | |||
29 | PACKAGES = " " | ||
30 | EXCLUDE_FROM_WORLD = "1" | ||
31 | |||
32 | BOOTDD_VOLUME_ID ?= "boot" | ||
33 | BOOTDD_EXTRA_SPACE ?= "16384" | ||
34 | |||
35 | EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}" | ||
36 | EFI_PROVIDER ?= "grub-efi" | ||
37 | EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}" | ||
38 | |||
39 | # Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not | ||
40 | # contain "efi". This way legacy is supported by default if neither is | ||
41 | # specified, maintaining the original behavior. | ||
42 | def pcbios(d): | ||
43 | pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d) | ||
44 | if pcbios == "0": | ||
45 | pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d) | ||
46 | return pcbios | ||
47 | |||
48 | def pcbios_class(d): | ||
49 | if d.getVar("PCBIOS", True) == "1": | ||
50 | return "syslinux" | ||
51 | return "" | ||
52 | |||
53 | PCBIOS = "${@pcbios(d)}" | ||
54 | PCBIOS_CLASS = "${@pcbios_class(d)}" | ||
55 | |||
56 | # Get the build_syslinux_cfg() function from the syslinux class | ||
57 | inherit ${PCBIOS_CLASS} | ||
58 | inherit ${EFI_CLASS} | ||
59 | |||
60 | DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}" | ||
61 | ROOT_VM ?= "root=/dev/sda2" | ||
62 | |||
63 | boot_direct_populate() { | ||
64 | dest=$1 | ||
65 | install -d $dest | ||
66 | |||
67 | # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use. | ||
68 | if [ -e ${DEPLOY_DIR_IMAGE}/bzImage ]; then | ||
69 | install -m 0644 ${DEPLOY_DIR_IMAGE}/bzImage $dest/vmlinuz | ||
70 | fi | ||
71 | |||
72 | # initrd is made of concatenation of multiple filesystem images | ||
73 | if [ -n "${INITRD}" ]; then | ||
74 | rm -f $dest/initrd | ||
75 | for fs in ${INITRD} | ||
76 | do | ||
77 | if [ -s "${fs}" ]; then | ||
78 | cat ${fs} >> $dest/initrd | ||
79 | else | ||
80 | bbfatal "${fs} is invalid. initrd image creation failed." | ||
81 | fi | ||
82 | done | ||
83 | chmod 0644 $dest/initrd | ||
84 | fi | ||
85 | } | ||
86 | |||
87 | build_boot_dd() { | ||
88 | HDDDIR="${S}/hdd/boot" | ||
89 | HDDIMG="${S}/hdd.image" | ||
90 | IMAGE=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect | ||
91 | |||
92 | boot_direct_populate $HDDDIR | ||
93 | |||
94 | if [ "${PCBIOS}" = "1" ]; then | ||
95 | syslinux_hddimg_populate $HDDDIR | ||
96 | fi | ||
97 | if [ "${EFI}" = "1" ]; then | ||
98 | efi_hddimg_populate $HDDDIR | ||
99 | fi | ||
100 | |||
101 | if [ "x${AUTO_SYSLINUXMENU}" = "x1" ] ; then | ||
102 | install -m 0644 ${STAGING_DIR}/${MACHINE}/usr/share/syslinux/vesamenu.c32 $HDDDIR/${SYSLINUXDIR}/ | ||
103 | if [ "x${SYSLINUX_SPLASH}" != "x" ] ; then | ||
104 | install -m 0644 ${SYSLINUX_SPLASH} $HDDDIR/${SYSLINUXDIR}/splash.lss | ||
105 | fi | ||
106 | fi | ||
107 | |||
108 | BLOCKS=`du -bks $HDDDIR | cut -f 1` | ||
109 | BLOCKS=`expr $BLOCKS + ${BOOTDD_EXTRA_SPACE}` | ||
110 | |||
111 | # Ensure total sectors is an integral number of sectors per | ||
112 | # track or mcopy will complain. Sectors are 512 bytes, and we | ||
113 | # generate images with 32 sectors per track. This calculation is | ||
114 | # done in blocks, thus the mod by 16 instead of 32. | ||
115 | BLOCKS=$(expr $BLOCKS + $(expr 16 - $(expr $BLOCKS % 16))) | ||
116 | |||
117 | # Remove it since mkdosfs would fail when it exists | ||
118 | rm -f $HDDIMG | ||
119 | mkdosfs -n ${BOOTDD_VOLUME_ID} -S 512 -C $HDDIMG $BLOCKS | ||
120 | mcopy -i $HDDIMG -s $HDDDIR/* ::/ | ||
121 | |||
122 | if [ "${PCBIOS}" = "1" ]; then | ||
123 | syslinux_hdddirect_install $HDDIMG | ||
124 | fi | ||
125 | chmod 644 $HDDIMG | ||
126 | |||
127 | ROOTFSBLOCKS=`du -Lbks ${ROOTFS} | cut -f 1` | ||
128 | TOTALSIZE=`expr $BLOCKS + $ROOTFSBLOCKS` | ||
129 | END1=`expr $BLOCKS \* 1024` | ||
130 | END2=`expr $END1 + 512` | ||
131 | END3=`expr \( $ROOTFSBLOCKS \* 1024 \) + $END1` | ||
132 | |||
133 | echo $ROOTFSBLOCKS $TOTALSIZE $END1 $END2 $END3 | ||
134 | rm -rf $IMAGE | ||
135 | dd if=/dev/zero of=$IMAGE bs=1024 seek=$TOTALSIZE count=1 | ||
136 | |||
137 | parted $IMAGE mklabel msdos | ||
138 | parted $IMAGE mkpart primary fat16 0 ${END1}B | ||
139 | parted $IMAGE unit B mkpart primary ext2 ${END2}B ${END3}B | ||
140 | parted $IMAGE set 1 boot on | ||
141 | |||
142 | parted $IMAGE print | ||
143 | |||
144 | awk "BEGIN { printf \"$(echo ${DISK_SIGNATURE} | fold -w 2 | tac | paste -sd '' | sed 's/\(..\)/\\x&/g')\" }" | \ | ||
145 | dd of=$IMAGE bs=1 seek=440 conv=notrunc | ||
146 | |||
147 | OFFSET=`expr $END2 / 512` | ||
148 | if [ "${PCBIOS}" = "1" ]; then | ||
149 | dd if=${STAGING_DATADIR}/syslinux/mbr.bin of=$IMAGE conv=notrunc | ||
150 | fi | ||
151 | |||
152 | dd if=$HDDIMG of=$IMAGE conv=notrunc seek=1 bs=512 | ||
153 | dd if=${ROOTFS} of=$IMAGE conv=notrunc seek=$OFFSET bs=512 | ||
154 | |||
155 | cd ${DEPLOY_DIR_IMAGE} | ||
156 | rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hdddirect | ||
157 | ln -s ${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hdddirect | ||
158 | } | ||
159 | |||
160 | python do_bootdirectdisk() { | ||
161 | validate_disk_signature(d) | ||
162 | set_live_vm_vars(d, 'VM') | ||
163 | if d.getVar("PCBIOS", True) == "1": | ||
164 | bb.build.exec_func('build_syslinux_cfg', d) | ||
165 | if d.getVar("EFI", True) == "1": | ||
166 | bb.build.exec_func('build_efi_cfg', d) | ||
167 | bb.build.exec_func('build_boot_dd', d) | ||
168 | } | ||
169 | |||
170 | def generate_disk_signature(): | ||
171 | import uuid | ||
172 | |||
173 | signature = str(uuid.uuid4())[:8] | ||
174 | |||
175 | if signature != '00000000': | ||
176 | return signature | ||
177 | else: | ||
178 | return 'ffffffff' | ||
179 | |||
180 | def validate_disk_signature(d): | ||
181 | import re | ||
182 | |||
183 | disk_signature = d.getVar("DISK_SIGNATURE", True) | ||
184 | |||
185 | if not re.match(r'^[0-9a-fA-F]{8}$', disk_signature): | ||
186 | bb.fatal("DISK_SIGNATURE '%s' must be an 8 digit hex string" % disk_signature) | ||
187 | |||
188 | DISK_SIGNATURE_GENERATED := "${@generate_disk_signature()}" | ||
189 | |||
190 | addtask bootdirectdisk before do_image_complete | ||
diff --git a/meta/classes/image-vm.bbclass b/meta/classes/image-vm.bbclass index 8608ec0c11..68cf89b68d 100644 --- a/meta/classes/image-vm.bbclass +++ b/meta/classes/image-vm.bbclass | |||
@@ -1,37 +1,217 @@ | |||
1 | # image-vm.bbclass | ||
2 | # (loosly based off bootimg.bbclass Copyright (C) 2004, Advanced Micro Devices, Inc.) | ||
3 | # | ||
4 | # Create an image which can be placed directly onto a harddisk using dd and then | ||
5 | # booted. | ||
6 | # | ||
7 | # This uses syslinux. extlinux would have been nice but required the ext2/3 | ||
8 | # partition to be mounted. grub requires to run itself as part of the install | ||
9 | # process. | ||
10 | # | ||
11 | # The end result is a 512 boot sector populated with an MBR and partition table | ||
12 | # followed by an msdos fat16 partition containing syslinux and a linux kernel | ||
13 | # completed by the ext2/3 rootfs. | ||
14 | # | ||
15 | # We have to push the msdos parition table size > 16MB so fat 16 is used as parted | ||
16 | # won't touch fat12 partitions. | ||
1 | 17 | ||
2 | LABELS_VM ?= "boot" | 18 | do_bootdirectdisk[depends] += "dosfstools-native:do_populate_sysroot \ |
19 | virtual/kernel:do_deploy \ | ||
20 | syslinux:do_populate_sysroot \ | ||
21 | syslinux-native:do_populate_sysroot \ | ||
22 | parted-native:do_populate_sysroot \ | ||
23 | mtools-native:do_populate_sysroot \ | ||
24 | ${PN}:do_image_ext4 \ | ||
25 | " | ||
26 | |||
27 | IMAGE_TYPEDEP_vmdk = "ext4" | ||
28 | IMAGE_TYPEDEP_vdi = "ext4" | ||
29 | IMAGE_TYPEDEP_qcow2 = "ext4" | ||
30 | IMAGE_TYPEDEP_hdddirect = "ext4" | ||
31 | IMAGE_TYPES_MASKED += "vmdk vdi qcow2 hdddirect" | ||
3 | 32 | ||
33 | ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.ext4" | ||
34 | |||
35 | # Used by bootloader | ||
36 | LABELS_VM ?= "boot" | ||
37 | ROOT_VM ?= "root=/dev/sda2" | ||
4 | # Using an initramfs is optional. Enable it by setting INITRD_IMAGE_VM. | 38 | # Using an initramfs is optional. Enable it by setting INITRD_IMAGE_VM. |
5 | INITRD_IMAGE_VM ?= "" | 39 | INITRD_IMAGE_VM ?= "" |
6 | INITRD_VM ?= "${@'${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE_VM}-${MACHINE}.cpio.gz' if '${INITRD_IMAGE_VM}' else ''}" | 40 | INITRD_VM ?= "${@'${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE_VM}-${MACHINE}.cpio.gz' if '${INITRD_IMAGE_VM}' else ''}" |
7 | do_bootdirectdisk[depends] += "${@'${INITRD_IMAGE_VM}:do_image_complete' if '${INITRD_IMAGE_VM}' else ''}" | 41 | do_bootdirectdisk[depends] += "${@'${INITRD_IMAGE_VM}:do_image_complete' if '${INITRD_IMAGE_VM}' else ''}" |
8 | 42 | ||
9 | # need to define the dependency and the ROOTFS for directdisk | 43 | BOOTDD_VOLUME_ID ?= "boot" |
10 | do_bootdirectdisk[depends] += "${PN}:do_image_ext4" | 44 | BOOTDD_EXTRA_SPACE ?= "16384" |
11 | ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.ext4" | ||
12 | 45 | ||
13 | # creating VM images relies on having a hdddirect so ensure we inherit it here. | 46 | EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}" |
14 | inherit boot-directdisk | 47 | EFI_PROVIDER ?= "grub-efi" |
48 | EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}" | ||
15 | 49 | ||
16 | IMAGE_TYPEDEP_vmdk = "ext4" | 50 | # Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not |
17 | IMAGE_TYPEDEP_vdi = "ext4" | 51 | # contain "efi". This way legacy is supported by default if neither is |
18 | IMAGE_TYPEDEP_qcow2 = "ext4" | 52 | # specified, maintaining the original behavior. |
19 | IMAGE_TYPEDEP_hdddirect = "ext4" | 53 | def pcbios(d): |
20 | IMAGE_TYPES_MASKED += "vmdk vdi qcow2 hdddirect" | 54 | pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d) |
55 | if pcbios == "0": | ||
56 | pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d) | ||
57 | return pcbios | ||
58 | |||
59 | def pcbios_class(d): | ||
60 | if d.getVar("PCBIOS", True) == "1": | ||
61 | return "syslinux" | ||
62 | return "" | ||
63 | |||
64 | PCBIOS = "${@pcbios(d)}" | ||
65 | PCBIOS_CLASS = "${@pcbios_class(d)}" | ||
66 | |||
67 | # Get the build_syslinux_cfg() function from the syslinux class | ||
68 | inherit ${PCBIOS_CLASS} | ||
69 | inherit ${EFI_CLASS} | ||
70 | |||
71 | DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}" | ||
72 | |||
73 | boot_direct_populate() { | ||
74 | dest=$1 | ||
75 | install -d $dest | ||
76 | |||
77 | # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use. | ||
78 | if [ -e ${DEPLOY_DIR_IMAGE}/bzImage ]; then | ||
79 | install -m 0644 ${DEPLOY_DIR_IMAGE}/bzImage $dest/vmlinuz | ||
80 | fi | ||
81 | |||
82 | # initrd is made of concatenation of multiple filesystem images | ||
83 | if [ -n "${INITRD}" ]; then | ||
84 | rm -f $dest/initrd | ||
85 | for fs in ${INITRD} | ||
86 | do | ||
87 | if [ -s "${fs}" ]; then | ||
88 | cat ${fs} >> $dest/initrd | ||
89 | else | ||
90 | bbfatal "${fs} is invalid. initrd image creation failed." | ||
91 | fi | ||
92 | done | ||
93 | chmod 0644 $dest/initrd | ||
94 | fi | ||
95 | } | ||
96 | |||
97 | build_boot_dd() { | ||
98 | HDDDIR="${S}/hdd/boot" | ||
99 | HDDIMG="${S}/hdd.image" | ||
100 | IMAGE=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect | ||
101 | |||
102 | boot_direct_populate $HDDDIR | ||
21 | 103 | ||
104 | if [ "${PCBIOS}" = "1" ]; then | ||
105 | syslinux_hddimg_populate $HDDDIR | ||
106 | fi | ||
107 | if [ "${EFI}" = "1" ]; then | ||
108 | efi_hddimg_populate $HDDDIR | ||
109 | fi | ||
110 | |||
111 | if [ "x${AUTO_SYSLINUXMENU}" = "x1" ] ; then | ||
112 | install -m 0644 ${STAGING_DIR}/${MACHINE}/usr/share/syslinux/vesamenu.c32 $HDDDIR/${SYSLINUXDIR}/ | ||
113 | if [ "x${SYSLINUX_SPLASH}" != "x" ] ; then | ||
114 | install -m 0644 ${SYSLINUX_SPLASH} $HDDDIR/${SYSLINUXDIR}/splash.lss | ||
115 | fi | ||
116 | fi | ||
117 | |||
118 | BLOCKS=`du -bks $HDDDIR | cut -f 1` | ||
119 | BLOCKS=`expr $BLOCKS + ${BOOTDD_EXTRA_SPACE}` | ||
120 | |||
121 | # Ensure total sectors is an integral number of sectors per | ||
122 | # track or mcopy will complain. Sectors are 512 bytes, and we | ||
123 | # generate images with 32 sectors per track. This calculation is | ||
124 | # done in blocks, thus the mod by 16 instead of 32. | ||
125 | BLOCKS=$(expr $BLOCKS + $(expr 16 - $(expr $BLOCKS % 16))) | ||
126 | |||
127 | # Remove it since mkdosfs would fail when it exists | ||
128 | rm -f $HDDIMG | ||
129 | mkdosfs -n ${BOOTDD_VOLUME_ID} -S 512 -C $HDDIMG $BLOCKS | ||
130 | mcopy -i $HDDIMG -s $HDDDIR/* ::/ | ||
131 | |||
132 | if [ "${PCBIOS}" = "1" ]; then | ||
133 | syslinux_hdddirect_install $HDDIMG | ||
134 | fi | ||
135 | chmod 644 $HDDIMG | ||
136 | |||
137 | ROOTFSBLOCKS=`du -Lbks ${ROOTFS} | cut -f 1` | ||
138 | TOTALSIZE=`expr $BLOCKS + $ROOTFSBLOCKS` | ||
139 | END1=`expr $BLOCKS \* 1024` | ||
140 | END2=`expr $END1 + 512` | ||
141 | END3=`expr \( $ROOTFSBLOCKS \* 1024 \) + $END1` | ||
142 | |||
143 | echo $ROOTFSBLOCKS $TOTALSIZE $END1 $END2 $END3 | ||
144 | rm -rf $IMAGE | ||
145 | dd if=/dev/zero of=$IMAGE bs=1024 seek=$TOTALSIZE count=1 | ||
146 | |||
147 | parted $IMAGE mklabel msdos | ||
148 | parted $IMAGE mkpart primary fat16 0 ${END1}B | ||
149 | parted $IMAGE unit B mkpart primary ext2 ${END2}B ${END3}B | ||
150 | parted $IMAGE set 1 boot on | ||
151 | |||
152 | parted $IMAGE print | ||
153 | |||
154 | awk "BEGIN { printf \"$(echo ${DISK_SIGNATURE} | fold -w 2 | tac | paste -sd '' | sed 's/\(..\)/\\x&/g')\" }" | \ | ||
155 | dd of=$IMAGE bs=1 seek=440 conv=notrunc | ||
156 | |||
157 | OFFSET=`expr $END2 / 512` | ||
158 | if [ "${PCBIOS}" = "1" ]; then | ||
159 | dd if=${STAGING_DATADIR}/syslinux/mbr.bin of=$IMAGE conv=notrunc | ||
160 | fi | ||
161 | |||
162 | dd if=$HDDIMG of=$IMAGE conv=notrunc seek=1 bs=512 | ||
163 | dd if=${ROOTFS} of=$IMAGE conv=notrunc seek=$OFFSET bs=512 | ||
164 | |||
165 | cd ${DEPLOY_DIR_IMAGE} | ||
166 | rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hdddirect | ||
167 | ln -s ${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hdddirect | ||
168 | } | ||
169 | |||
170 | python do_bootdirectdisk() { | ||
171 | validate_disk_signature(d) | ||
172 | set_live_vm_vars(d, 'VM') | ||
173 | if d.getVar("PCBIOS", True) == "1": | ||
174 | bb.build.exec_func('build_syslinux_cfg', d) | ||
175 | if d.getVar("EFI", True) == "1": | ||
176 | bb.build.exec_func('build_efi_cfg', d) | ||
177 | bb.build.exec_func('build_boot_dd', d) | ||
178 | } | ||
179 | |||
180 | def generate_disk_signature(): | ||
181 | import uuid | ||
182 | |||
183 | signature = str(uuid.uuid4())[:8] | ||
184 | |||
185 | if signature != '00000000': | ||
186 | return signature | ||
187 | else: | ||
188 | return 'ffffffff' | ||
189 | |||
190 | def validate_disk_signature(d): | ||
191 | import re | ||
192 | |||
193 | disk_signature = d.getVar("DISK_SIGNATURE", True) | ||
194 | |||
195 | if not re.match(r'^[0-9a-fA-F]{8}$', disk_signature): | ||
196 | bb.fatal("DISK_SIGNATURE '%s' must be an 8 digit hex string" % disk_signature) | ||
197 | |||
198 | DISK_SIGNATURE_GENERATED := "${@generate_disk_signature()}" | ||
199 | |||
200 | run_qemu_img (){ | ||
201 | type="$1" | ||
202 | qemu-img convert -O $type ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.$type | ||
203 | ln -sf ${IMAGE_NAME}.$type ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.$type | ||
204 | } | ||
22 | create_vmdk_image () { | 205 | create_vmdk_image () { |
23 | qemu-img convert -O vmdk ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.vmdk | 206 | run_qemu_img vmdk |
24 | ln -sf ${IMAGE_NAME}.vmdk ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.vmdk | ||
25 | } | 207 | } |
26 | 208 | ||
27 | create_vdi_image () { | 209 | create_vdi_image () { |
28 | qemu-img convert -O vdi ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.vdi | 210 | run_qemu_img vdi |
29 | ln -sf ${IMAGE_NAME}.vdi ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.vdi | ||
30 | } | 211 | } |
31 | 212 | ||
32 | create_qcow2_image () { | 213 | create_qcow2_image () { |
33 | qemu-img convert -O qcow2 ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.qcow2 | 214 | run_qemu_img qcow2 |
34 | ln -sf ${IMAGE_NAME}.qcow2 ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.qcow2 | ||
35 | } | 215 | } |
36 | 216 | ||
37 | python do_vmimg() { | 217 | python do_vmimg() { |
@@ -43,6 +223,6 @@ python do_vmimg() { | |||
43 | bb.build.exec_func('create_qcow2_image', d) | 223 | bb.build.exec_func('create_qcow2_image', d) |
44 | } | 224 | } |
45 | 225 | ||
226 | addtask bootdirectdisk before do_vmimg | ||
46 | addtask vmimg after do_bootdirectdisk before do_image_complete | 227 | addtask vmimg after do_bootdirectdisk before do_image_complete |
47 | do_vmimg[depends] += "qemu-native:do_populate_sysroot" | 228 | do_vmimg[depends] += "qemu-native:do_populate_sysroot" |
48 | |||