From: Gylstorff Quirin <quirin.gylstorff@siemens.com>
To: Henning Schild <henning.schild@siemens.com>
Cc: isar-users@googlegroups.com
Subject: Re: [PATCH 2/3] meta/classes: Generate ova image for vmware or virtualbox
Date: Mon, 30 Mar 2020 09:27:36 +0200 [thread overview]
Message-ID: <352dc12d-79dc-4317-c77d-727cb6fdc6cc@siemens.com> (raw)
In-Reply-To: <20200327195008.7e72c2b1@md1za8fc.ad001.siemens.net>
On 3/27/20 7:50 PM, Henning Schild wrote:
> Hi Quirin,
>
> i recently used that in a layer. In fact it does two things that maybe
> deserve two classes ... or the name of the class should change.
>
> 1. it converts a raw image into another format ... something that could
> even eventually support qcow2, vdi ...
ACK
>
> 2. it creates an ova as a follow-up step of a vmdk conversion
>
> That said, i think it can stay in one class. But the name of that class
> should change.
> "virtual-machine-image.bbclass" ?
ACK
>
> And the ova step should be done only if
> VIRTUAL_MACHINE_IMAGE_TYPE="vmdk".
>
> I think going with vmdk-only in a first round is good, but its
> important to hopefully find an interface that we do not need to change
> with the next sub-feature.
>
I will incorporate your comments in a v2.
Quirin
> On Fri, 27 Mar 2020 14:28:00 +0100
> "[ext] Q. Gylstorff" <Quirin.Gylstorff@siemens.com> wrote:
>
>> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>>
>> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>> ---
>> meta/classes/ova-wic-img.bbclass | 236
>> +++++++++++++++++++++++++++++++ 1 file changed, 236 insertions(+)
>> create mode 100644 meta/classes/ova-wic-img.bbclass
>>
>> diff --git a/meta/classes/ova-wic-img.bbclass
>> b/meta/classes/ova-wic-img.bbclass new file mode 100644
>> index 0000000..a03ec1b
>> --- /dev/null
>> +++ b/meta/classes/ova-wic-img.bbclass
>> @@ -0,0 +1,236 @@
>> +# This software is a part of ISAR.
>> +# Copyright (C) 2019-2020 Siemens AG
>> +#
>> +# This class allows to generate images for vmware and virtualbox
>> +#
>> +
>> +inherit buildchroot
>> +inherit wic-img
>> +IMAGER_INSTALL += "qemu-utils gawk uuid-runtime"
>> +OVA_NAME ?= "${IMAGE_FULLNAME}"
>> +OVA_MEMORY ?= "8192"
>> +OVA_NUMBER_OF_CPU ?= "4"
>> +OVA_VRAM ?= "64"
>> +OVA_FIRMWARE ?= "efi"
>> +OVA_ACPI ?= "true"
>> +OVA_3D_ACCEL ?= "true"
>> +OVA_CLIPBOARD ?= "bidirectional"
>> +VMDK_DISK ?= "${PP_DEPLOY}/${VMDK_IMAGE_FILE}"
>> +RAW_INPUT_IMAGE_FILE ?= "${IMAGE_FULLNAME}.wic.img"
>> +VMDK_IMAGE_FILE = "${IMAGE_FULLNAME}.vmdk"
>> +VMDK_SUBFORMAT ?= "monolithicSparse"
>> +do_convert_wic_to_vmdk() {
ok>> + rm -f '${DEPLOY_DIR_IMAGE}/${VMDK_IMAGE_FILE}'
>
> indent is off
>
>> + image_do_mounts
>> + bbnote "Creating ${VMDK_IMAGE_FILE} from ${RAW_INPUT_IMAGE_FILE}"
>> + sudo -E chroot --userspec=$( id -u ):$( id -g )
>> ${BUILDCHROOT_DIR} \
>> + /usr/bin/qemu-img convert -f raw -O vmdk -o
>> subformat=${VMDK_SUBFORMAT} \
>> + '${PP_DEPLOY}/${RAW_INPUT_IMAGE_FILE}'
>> '${PP_DEPLOY}/${VMDK_IMAGE_FILE}' +}
>
> the command under sudo should be indented deeper
>
>> +addtask convert_wic_to_vmdk before do_build after do_wic_image
>> do_copy_boot_files do_install_imager_deps do_transform_template +
>> +# Generate random MAC addresses just as VirtualBox does, the format
>> is +# their assigned prefix for the first 3 bytes followed by 3
>> random bytes. +VBOX_MAC_PREFIX = "080027"
>> +macgen() {
>> + hexdump -n3 -e "\"${VBOX_MAC_PREFIX}%06X\n\"" /dev/urandom
>> +}
>> +get_disksize() {
>> + image_do_mounts
>> + sudo -E chroot --userspec=$( id -u ):$( id -g ) ${BUILDCHROOT_DIR}
>> \
>> + qemu-img info -f vmdk "${VMDK_DISK}" | gawk 'match($0, /^virtual
>> size:.*\(([0-9]+) bytes\)/, a) {print a[1]}' +}
>> +do_create_ova() {
>> + rm -f '${DEPLOY_DIR_IMAGE}/${OVA_NAME}.ova'
>> + rm -f '${DEPLOY_DIR_IMAGE}/${OVA_NAME}.ovf'
>> + export PRIMARY_MAC=$(macgen)
>> + export SECONDARY_MAC=$(macgen)
>
> I am not sure, but maybe people would want to control that. But i guess
> default random is a good starting point.
>
>> + export DISK_NAME=$(basename -s .vmdk ${VMDK_DISK})
>> + export DISK_SIZE_BYTES=$(get_disksize)
>> + export LAST_CHANGE=$(date -u "+%Y-%m-%dT%H:%M:%SZ")
>> + export OVA_FIRMWARE_VIRTUALBOX=$(echo ${OVA_FIRMWARE} | tr '[a-z]'
>> '[A-Z]')
>> + image_do_mounts
>> + sudo -Es chroot --userspec=$( id -u ):$( id -g )
>> ${BUILDCHROOT_DIR} <<'EOSUDO'
>
> indentation again
>
>> + export DISK_UUID=$(uuidgen)
>> + export VM_UUID=$(uuidgen)
>> + # create ovf
>> + cat > "${PP_DEPLOY}/${DISK_NAME}.ovf" << EOF
>> +<?xml version="1.0" encoding="UTF-8"?>
>> +<Envelope ovf:version="1.0" xml:lang="en-US"
>
> The xml is pretty long-ish and makes reading the code hard. How about
> that gets fetch with file:/// and patched with the templating code we
> have.
> That would also allow customizations by replacing the file:/// in a
> layer.
>
>> xmlns="http://schemas.dmtf.org/ovf/envelope/1"
>> xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
>> xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
>> xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:vbox="http://www.virtualbox.org/ovf/machine">
>> + <References>
>> + <File ovf:href="${VMDK_IMAGE_FILE}" ovf:id="file1"/>
>> + </References>
>> + <DiskSection>
>> + <Info>List of the virtual disks used in the package</Info>
>> + <Disk ovf:capacity="${DISK_SIZE_BYTES}"
>> ovf:capacityAllocationUnits="byte" ovf:diskId="vmdisk1"
>> ovf:fileRef="file1"
>> ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized"
>> vbox:uuid="${DISK_UUID}"/>
>> + </DiskSection>
>> + <NetworkSection>
>> + <Info>Logical networks used in the package</Info>
>> + <Network ovf:name="NAT">
>> + <Description>Logical network used by this
>> appliance.</Description>
>> + </Network>
>> + </NetworkSection>
>> + <VirtualSystem ovf:id="${OVA_NAME}">
>> + <Info>A virtual machine</Info>
>> + <OperatingSystemSection ovf:id="100">
>> + <Info>The kind of installed guest operating system</Info>
>> + <Description>Debian_64</Description>
>> + <vbox:OSType ovf:required="false">Debian_64</vbox:OSType>
>> + </OperatingSystemSection>
>> + <VirtualHardwareSection>
>> + <Info>Virtual hardware requirements for a virtual
>> machine</Info>
>> + <System>
>> + <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
>> + <vssd:InstanceID>0</vssd:InstanceID>
>> +
>> <vssd:VirtualSystemIdentifier>${OVA_NAME}</vssd:VirtualSystemIdentifier>
>> +
>> <vssd:VirtualSystemType>virtualbox-2.2</vssd:VirtualSystemType>
>> + </System>
>> + <Item>
>> + <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
>> + <rasd:Caption>${OVA_NUMBER_OF_CPU} virtual CPU</rasd:Caption>
>> + <rasd:Description>Number of virtual CPUs</rasd:Description>
>> + <rasd:ElementName>${OVA_NUMBER_OF_CPU} virtual
>> CPU</rasd:ElementName>
>> + <rasd:InstanceID>1</rasd:InstanceID>
>> + <rasd:ResourceType>3</rasd:ResourceType>
>> +
>> <rasd:VirtualQuantity>${OVA_NUMBER_OF_CPU}</rasd:VirtualQuantity>
>> + </Item>
>> + <Item>
>> + <rasd:AllocationUnits>MegaBytes</rasd:AllocationUnits>
>> + <rasd:Caption>${OVA_MEMORY} MB of memory</rasd:Caption>
>> + <rasd:Description>Memory Size</rasd:Description>
>> + <rasd:ElementName>${OVA_MEMORY} MB of
>> memory</rasd:ElementName>
>> + <rasd:InstanceID>2</rasd:InstanceID>
>> + <rasd:ResourceType>4</rasd:ResourceType>
>> + <rasd:VirtualQuantity>${OVA_MEMORY}</rasd:VirtualQuantity>
>> + </Item>
>> + <Item>
>> + <rasd:Address>0</rasd:Address>
>> + <rasd:Caption>ideController0</rasd:Caption>
>> + <rasd:Description>IDE Controller</rasd:Description>
>> + <rasd:ElementName>ideController0</rasd:ElementName>
>> + <rasd:InstanceID>3</rasd:InstanceID>
>> + <rasd:ResourceSubType>PIIX4</rasd:ResourceSubType>
>> + <rasd:ResourceType>5</rasd:ResourceType>
>> + </Item>
>> + <Item>
>> + <rasd:Address>1</rasd:Address>
>> + <rasd:Caption>ideController1</rasd:Caption>
>> + <rasd:Description>IDE Controller</rasd:Description>
>> + <rasd:ElementName>ideController1</rasd:ElementName>
>> + <rasd:InstanceID>4</rasd:InstanceID>
>> + <rasd:ResourceSubType>PIIX4</rasd:ResourceSubType>
>> + <rasd:ResourceType>5</rasd:ResourceType>
>> + </Item>
>> + <Item>
>> + <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
>> + <rasd:Caption>Ethernet adapter on 'NAT'</rasd:Caption>
>> + <rasd:Connection>NAT</rasd:Connection>
>> + <rasd:ElementName>Ethernet adapter on
>> 'NAT'</rasd:ElementName>
>> + <rasd:InstanceID>5</rasd:InstanceID>
>> + <rasd:ResourceSubType>E1000</rasd:ResourceSubType>
>> + <rasd:ResourceType>10</rasd:ResourceType>
>> + </Item>
>> + <Item>
>> + <rasd:AddressOnParent>0</rasd:AddressOnParent>
>> + <rasd:Caption>disk1</rasd:Caption>
>> + <rasd:Description>Disk Image</rasd:Description>
>> + <rasd:ElementName>disk1</rasd:ElementName>
>> + <rasd:HostResource>/disk/vmdisk1</rasd:HostResource>
>> + <rasd:InstanceID>6</rasd:InstanceID>
>> + <rasd:Parent>3</rasd:Parent>
>> + <rasd:ResourceType>17</rasd:ResourceType>
>> + </Item>
>> + <vmw:Config ovf:required="false" vmw:key="firmware"
>> vmw:value="${OVA_FIRMWARE}"/>
>> + <vmw:Config ovf:required="false"
>> vmw:key="tools.syncTimeWithHost" vmw:value="false"/>
>> + <vmw:Config ovf:required="false" vmw:key="tools.afterPowerOn"
>> vmw:value="true"/>
>> + <vmw:Config ovf:required="false" vmw:key="tools.afterResume"
>> vmw:value="true"/>
>> + <vmw:Config ovf:required="false"
>> vmw:key="tools.beforeGuestShutdown" vmw:value="true"/>
>> + <vmw:Config ovf:required="false"
>> vmw:key="tools.beforeGuestStandby" vmw:value="true"/>
>> + <vmw:ExtraConfig ovf:required="false"
>> vmw:key="virtualHW.productCompatibility" vmw:value="hosted"/>
>> + </VirtualHardwareSection>
>> + <vbox:Machine ovf:required="false" version="1.12-linux"
>> uuid="${VM_UUID}" name="${OVA_NAME}" OSType="Debian_64"
>> snapshotFolder="Snapshots" lastStateChange="${LAST_CHANGE}">
>> + <ovf:Info>Complete VirtualBox machine configuration in
>> VirtualBox format</ovf:Info>
>> + <Hardware version="2">
>> + <CPU count="${OVA_NUMBER_OF_CPU}" hotplug="false">
>> + <HardwareVirtEx enabled="true" exclusive="true"/>
>> + <HardwareVirtExNestedPaging enabled="true"/>
>> + <HardwareVirtExVPID enabled="true"/>
>> + <PAE enabled="true"/>
>> + <HardwareVirtExLargePages enabled="false"/>
>> + <HardwareVirtForce enabled="false"/>
>> + </CPU>
>> + <Memory RAMSize="${OVA_MEMORY}" PageFusion="false"/>
>> + <Firmware type="${OVA_FIRMWARE_VIRTUALBOX}"/>
>> + <HID Pointing="PS2Mouse" Keyboard="PS2Keyboard"/>
>> + <HPET enabled="false"/>
>> + <Chipset type="PIIX3"/>
>> + <Boot>
>> + <Order position="1" device="HardDisk"/>
>> + <Order position="2" device="None"/>
>> + <Order position="3" device="None"/>
>> + <Order position="4" device="None"/>
>> + </Boot>
>> + <Display VRAMSize="${OVA_VRAM}" monitorCount="1"
>> accelerate3D="${OVA_3D_ACCEL}" accelerate2DVideo="false"/>
>> + <VideoRecording enabled="false" file="Test.webm"
>> horzRes="640" vertRes="480"/>
>> + <RemoteDisplay enabled="false" authType="Null"/>
>> + <BIOS>
>> + <ACPI enabled="${OVA_ACPI}"/>
>> + <IOAPIC enabled="${OVA_ACPI}"/>
>> + <Logo fadeIn="true" fadeOut="true" displayTime="0"/>
>> + <BootMenu mode="MessageAndMenu"/>
>> + <TimeOffset value="0"/>
>> + <PXEDebug enabled="false"/>
>> + </BIOS>
>> + <USBController enabled="false" enabledEhci="false"/>
>> + <Network>
>> + <Adapter slot="0" enabled="true"
>> MACAddress="${PRIMARY_MAC}" cable="true" speed="0" type="virtio">
>> + <DisabledModes/>
>> + <NAT>
>> + <DNS pass-domain="true" use-proxy="false"
>> use-host-resolver="false"/>
>> + <Alias logging="false" proxy-only="false"
>> use-same-ports="false"/>
>> + </NAT>
>> + </Adapter>
>> + </Network>
>> + <UART>
>> + <Port slot="0" enabled="false" IOBase="0x3f8" IRQ="4"
>> hostMode="Disconnected"/>
>> + <Port slot="1" enabled="false" IOBase="0x2f8" IRQ="3"
>> hostMode="Disconnected"/>
>> + </UART>
>> + <LPT>
>> + <Port slot="0" enabled="false" IOBase="0x378" IRQ="7"/>
>> + <Port slot="1" enabled="false" IOBase="0x378" IRQ="7"/>
>> + </LPT>
>> + <AudioAdapter controller="AC97" driver="Pulse"
>> enabled="false"/>
>> + <RTC localOrUTC="local"/>
>> + <SharedFolders/>
>> + <Clipboard mode="Disabled"/>
>> + <DragAndDrop mode="Disabled"/>
>> + <IO>
>> + <IoCache enabled="true" size="5"/>
>> + <BandwidthGroups/>
>> + </IO>
>> + <HostPci>
>> + <Devices/>
>> + </HostPci>
>> + <EmulatedUSB>
>> + <CardReader enabled="false"/>
>> + </EmulatedUSB>
>> + <Guest memoryBalloonSize="0"/>
>> + <GuestProperties/>
>> + </Hardware>
>> + <StorageControllers>
>> + <StorageController name="IDE Controller" type="PIIX4"
>> PortCount="2" useHostIOCache="true" Bootable="true">
>> + <AttachedDevice type="HardDisk" port="0" device="0">
>> + <Image uuid="{${DISK_UUID}}"/>
>> + </AttachedDevice>
>> + </StorageController>
>> + </StorageControllers>
>> + </vbox:Machine>
>> + </VirtualSystem>
>> +</Envelope>
>> +EOF
>> +tar -c -f ${PP_DEPLOY}/${OVA_NAME}.ova -C ${PP_DEPLOY}
>> ${OVA_NAME}.ovf ${VMDK_IMAGE_FILE} +EOSUDO
>> +}
>> +
>> +addtask do_create_ova after do_convert_wic_to_vmdk before do_deploy
>> \ No newline at end of file
>
--
Quirin
next prev parent reply other threads:[~2020-03-30 7:27 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-27 13:27 [PATCH 0/3] some image classes Q. Gylstorff
2020-03-27 13:27 ` [PATCH 1/3] meta/classes: Generate a custom initramfs Q. Gylstorff
2020-03-30 7:25 ` Gylstorff Quirin
2020-03-30 8:08 ` Henning Schild
2020-03-27 13:28 ` [PATCH 2/3] meta/classes: Generate ova image for vmware or virtualbox Q. Gylstorff
2020-03-27 18:50 ` Henning Schild
2020-03-30 7:27 ` Gylstorff Quirin [this message]
2020-03-27 13:28 ` [PATCH 3/3] meta/classes: add cpiogz-img Q. Gylstorff
2020-03-27 19:01 ` Henning Schild
2020-03-30 7:29 ` Gylstorff Quirin
2020-03-27 14:51 ` [PATCH] Add ova configuration for testing Q. Gylstorff
2020-03-27 18:46 ` Henning Schild
2020-03-27 14:52 ` [PATCH] conf: Add multiconfig for cpiogz Q. Gylstorff
2020-04-03 14:55 ` [PATCH v2 0/3] some images classes Q. Gylstorff
2020-04-03 14:55 ` [PATCH v2 1/3] meta/support: Generate a custom initramfs Q. Gylstorff
2020-04-09 6:39 ` Henning Schild
2020-04-09 13:59 ` Gylstorff Quirin
2020-04-09 17:18 ` Henning Schild
2020-04-03 14:55 ` [PATCH v2 2/3] meta/classes: Generate ova image for vmware or virtualbox Q. Gylstorff
2020-04-09 6:48 ` Henning Schild
2020-04-09 14:28 ` Gylstorff Quirin
2020-04-03 14:55 ` [PATCH v2 3/3] meta/classes: add cpiogz-img Q. Gylstorff
2020-04-09 6:54 ` [PATCH v2 0/3] some images classes Henning Schild
2020-04-14 12:24 ` [PATCH v3 " Q. Gylstorff
2020-04-14 12:24 ` [PATCH v3 1/3] meta/support: Generate a custom initramfs Q. Gylstorff
2020-04-20 20:14 ` Henning Schild
2020-04-21 14:30 ` Gylstorff Quirin
2020-04-14 12:24 ` [PATCH v3 2/3] meta/classes: Generate ova image for vmware or virtualbox Q. Gylstorff
2020-04-14 12:24 ` [PATCH v3 3/3] meta/classes: add cpiogz-img Q. Gylstorff
2020-04-20 20:14 ` [PATCH v3 0/3] some images classes Henning Schild
2020-04-21 14:57 ` [PATCH v4 0/3] some images Q. Gylstorff
2020-04-21 14:57 ` [PATCH v4 1/3] meta/support: Generate a custom initramfs Q. Gylstorff
2020-04-21 14:57 ` [PATCH v4 2/3] meta/classes: Generate ova image for vmware or virtualbox Q. Gylstorff
2020-04-21 15:17 ` Jan Kiszka
2020-04-23 9:46 ` [PATCH v5 0/3] some images Q. Gylstorff
2020-04-23 9:46 ` [PATCH v5 1/3] meta/support: Generate a custom initramfs Q. Gylstorff
2020-06-18 15:54 ` Harald Seiler
2020-06-22 13:44 ` Gylstorff Quirin
2020-06-25 12:56 ` [PATCH v6 0/3] some images Q. Gylstorff
2020-06-25 12:56 ` [PATCH v6 1/3] meta/support: Generate a custom initramfs Q. Gylstorff
2020-09-16 12:24 ` Harald Seiler
2020-06-25 12:56 ` [PATCH v6 2/3] meta/classes: Generate ova image for vmware or virtualbox Q. Gylstorff
2020-06-25 12:56 ` [PATCH v6 3/3] meta/classes: add cpiogz-img Q. Gylstorff
2020-10-13 10:22 ` [PATCH v6 0/3] some images Jan Kiszka
2021-02-05 10:07 ` Gylstorff Quirin
2021-02-05 10:52 ` [PATCH v7 0/2] CPIO & OVA Images Q. Gylstorff
2021-02-05 10:52 ` [PATCH v7 1/2] meta/classes: Generate ova image for vmware or virtualbox Q. Gylstorff
2021-02-05 11:16 ` Jan Kiszka
2021-02-05 10:52 ` [PATCH v7 2/2] meta/classes: add cpiogz-img Q. Gylstorff
2021-02-05 11:09 ` Jan Kiszka
2021-02-05 15:57 ` [PATCH v8 0/2] CPIO & OVA Images Q. Gylstorff
2021-02-05 15:57 ` [PATCH v8 1/2] meta/classes: Generate ova image for VMWare or Virtualbox Q. Gylstorff
2021-03-26 11:47 ` Anton Mikanovich
2021-02-05 15:57 ` [PATCH v8 2/2] meta/classes: add cpiogz-img Q. Gylstorff
2021-03-26 11:51 ` Anton Mikanovich
2020-04-23 9:46 ` [PATCH v5 2/3] meta/classes: Generate ova image for vmware or virtualbox Q. Gylstorff
2020-04-23 9:46 ` [PATCH v5 3/3] meta/classes: add cpiogz-img Q. Gylstorff
2020-04-21 14:57 ` [PATCH v4 " Q. Gylstorff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=352dc12d-79dc-4317-c77d-727cb6fdc6cc@siemens.com \
--to=quirin.gylstorff@siemens.com \
--cc=henning.schild@siemens.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox