Skip to content

Commit

Permalink
Merge pull request #1425 from mikalstill/support-qcow2
Browse files Browse the repository at this point in the history
Add support for qcow2 as an image format.
  • Loading branch information
bcressey authored Apr 1, 2021
2 parents 05357a0 + 652228e commit fc84271
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions tools/buildsys/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl VariantBuilder {
"IMAGE_FORMAT",
match image_format {
Some(ImageFormat::Raw) | None => "raw",
Some(ImageFormat::Qcow2) => "qcow2",
Some(ImageFormat::Vmdk) => "vmdk",
},
);
Expand Down
1 change: 1 addition & 0 deletions tools/buildsys/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ pub(crate) struct BuildVariant {
#[derive(Deserialize, Debug)]
#[serde(rename_all = "lowercase")]
pub(crate) enum ImageFormat {
Qcow2,
Raw,
Vmdk,
}
Expand Down
14 changes: 6 additions & 8 deletions tools/rpm2img
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ for opt in "$@"; do
done

case "${OUTPUT_FMT}" in
raw|vmdk) ;;
raw|qcow2|vmdk) ;;
*)
echo "unexpected image output format '${OUTPUT_FMT}'" >&2
exit 1
Expand Down Expand Up @@ -222,22 +222,20 @@ sgdisk -v "${DATA_IMAGE}"
if [[ ${OUTPUT_FMT} == "raw" ]]; then
lz4 -vc "${DISK_IMAGE}" >"${OUTPUT_DIR}/${DISK_IMAGE_BASENAME}.img.lz4"
lz4 -vc "${DATA_IMAGE}" >"${OUTPUT_DIR}/${DATA_IMAGE_BASENAME}.img.lz4"
chown 1000:1000 "${OUTPUT_DIR}/${DISK_IMAGE_BASENAME}.img.lz4" \
"${OUTPUT_DIR}/${DATA_IMAGE_BASENAME}.img.lz4"
elif [[ ${OUTPUT_FMT} == "qcow2" ]]; then
qemu-img convert -f raw -O qcow2 "${DISK_IMAGE}" "${OUTPUT_DIR}/${DISK_IMAGE_BASENAME}.qcow2"
qemu-img convert -f raw -O qcow2 "${DATA_IMAGE}" "${OUTPUT_DIR}/${DATA_IMAGE_BASENAME}.qcow2"
elif [[ ${OUTPUT_FMT} == "vmdk" ]]; then
# Stream optimization is required for creating an Open Virtual Appliance (OVA)
qemu-img convert -f raw -O vmdk -o subformat=streamOptimized "${DISK_IMAGE}" "${OUTPUT_DIR}/${DISK_IMAGE_BASENAME}.vmdk"
qemu-img convert -f raw -O vmdk -o subformat=streamOptimized "${DATA_IMAGE}" "${OUTPUT_DIR}/${DATA_IMAGE_BASENAME}.vmdk"
chown 1000:1000 "${OUTPUT_DIR}/${DISK_IMAGE_BASENAME}.vmdk" \
"${OUTPUT_DIR}/${DATA_IMAGE_BASENAME}.vmdk"
fi

lz4 -9vc "${BOOT_IMAGE}" >"${OUTPUT_DIR}/${BOOT_IMAGE_NAME}"
lz4 -9vc "${VERITY_IMAGE}" >"${OUTPUT_DIR}/${VERITY_IMAGE_NAME}"
lz4 -9vc "${ROOT_IMAGE}" >"${OUTPUT_DIR}/${ROOT_IMAGE_NAME}"
chown 1000:1000 "${OUTPUT_DIR}/${BOOT_IMAGE_NAME}" \
"${OUTPUT_DIR}/${VERITY_IMAGE_NAME}" \
"${OUTPUT_DIR}/${ROOT_IMAGE_NAME}"

find "${OUTPUT_DIR}" -type f -print -exec chown 1000:1000 {} \;

# Clean up temporary files to reduce size of layer.
rm -f "${PACKAGE_DIR}"/*.rpm
Expand Down

0 comments on commit fc84271

Please sign in to comment.