mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Add systemvmtemplate arm64 build support (#9437)
* Move and copy files to new filenames * Adjust bash scripts to support arm64 * change preseed for arm64 to create EFI partition * change packer template files to support arm64 * Correct preseed file name in x86_64 packer template * fixes Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> * try different machine cpu Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> * don't accelerate KVM for different arch (arm64 vm on amd64 host) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> * fix building arm64 on x86 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> * Update README.md --------- Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> Co-authored-by: StepBee <stephan@bienek.org>
This commit is contained in:
		
							parent
							
								
									49cd5ba64a
								
							
						
					
					
						commit
						f8385a48da
					
				| @ -25,7 +25,8 @@ CentOS based built-in user VM template. | ||||
| 
 | ||||
| # Setting up Tools and Environment | ||||
| 
 | ||||
| - Install packer and latest KVM, qemu on a Linux machine | ||||
| - Install packer (v1.8.x, v1.9.x tested) and latest KVM, qemu on a Linux x86 | ||||
|   machine (Ubuntu 20.04 tested) | ||||
| - Install tools for exporting appliances: qemu-img, ovftool, faketime, sharutils | ||||
| - Build and install `vhd-util` as described in build.sh or use pre-built | ||||
|   binaries at: | ||||
| @ -33,10 +34,18 @@ CentOS based built-in user VM template. | ||||
|       http://packages.shapeblue.com/systemvmtemplate/vhd-util | ||||
|       http://packages.shapeblue.com/systemvmtemplate/libvhd.so.1.0 | ||||
| 
 | ||||
| - For building ARM64 systemvm template on amd64 systems, please also install: | ||||
|   qemu-utils qemu-system-arm qemu-efi-aarch64 | ||||
| 
 | ||||
| # How to build appliances | ||||
| 
 | ||||
| Just run build.sh, it will export archived appliances for KVM, XenServer, | ||||
| VMWare and HyperV in `dist` directory: | ||||
| 
 | ||||
|     bash build.sh systemvmtemplate | ||||
|     bash build.sh <name> <version> <arch> | ||||
|     bash build.sh systemvmtemplate 4.19.1.0 x86_64 | ||||
|     bash build.sh systemvmtemplate 4.19.1.0 aarch64 | ||||
| 
 | ||||
| For building builtin x86_64 template run: | ||||
| 
 | ||||
|     bash build.sh builtin | ||||
|  | ||||
| @ -27,6 +27,8 @@ Usage: | ||||
|      (or use command line arg, default systemvmtemplate) | ||||
|    * Set \$version to provide version to apply to built appliance | ||||
|      (or use command line arg, default empty) | ||||
|    * Set \$target_arch to provide target architecture | ||||
|      (or use command line arg, default to current architecture. Currently x86_64 and aarch64 are implemented) | ||||
|    * Set \$BUILD_NUMBER to provide build number to apply to built appliance | ||||
|      (or use command line arg, default empty) | ||||
|    * Set \$DEBUG=1 to enable debug logging | ||||
| @ -85,12 +87,18 @@ if [[ ! -z "${JENKINS_HOME}" ]]; then | ||||
|   DEBUG=1 | ||||
| fi | ||||
| 
 | ||||
| # get current system architecture | ||||
| base_arch=`arch` | ||||
| 
 | ||||
| # which packer definition to use | ||||
| appliance="${1:-${appliance:-systemvmtemplate}}" | ||||
| 
 | ||||
| # optional version tag to put into the image filename | ||||
| version="${2:-${version:-}}" | ||||
| 
 | ||||
| # which architecture to build the template for | ||||
| target_arch="${3:-${target_arch:-${base_arch}}}" | ||||
| 
 | ||||
| # optional (jenkins) build number tag to put into the image filename | ||||
| BUILD_NUMBER="${4:-${BUILD_NUMBER:-}}" | ||||
| 
 | ||||
| @ -105,7 +113,7 @@ elif [ ! -z "${BUILD_NUMBER}" ]; then | ||||
|   version_tag="-${BUILD_NUMBER}" | ||||
| fi | ||||
| 
 | ||||
| appliance_build_name=${appliance}${version_tag} | ||||
| appliance_build_name="${appliance}${version_tag}-${target_arch}" | ||||
| 
 | ||||
| ### | ||||
| ### Generic helper functions | ||||
| @ -218,7 +226,7 @@ function prepare() { | ||||
| 
 | ||||
| function packer_build() { | ||||
|   log INFO "building new image with packer" | ||||
|   cd ${appliance_build_name} && packer build template.json && cd .. | ||||
|   cd ${appliance_build_name} && packer build template-base_${base_arch}-target_${target_arch}.json && cd .. | ||||
| } | ||||
| 
 | ||||
| function stage_vmx() { | ||||
| @ -349,10 +357,12 @@ function main() { | ||||
| 
 | ||||
|   # process the disk at dist | ||||
|   kvm_export | ||||
|   ovm_export | ||||
|   xen_server_export | ||||
|   vmware_export | ||||
|   hyperv_export | ||||
|   if [ "${target_arch}" == "x86_64" ]; then | ||||
|     ovm_export | ||||
|     xen_server_export | ||||
|     vmware_export | ||||
|     hyperv_export | ||||
|   fi | ||||
|   rm -f "dist/${appliance}" | ||||
|   cd dist && chmod +r * && cd .. | ||||
|   cd dist && md5sum * > md5sum.txt && cd .. | ||||
|  | ||||
							
								
								
									
										122
									
								
								tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										122
									
								
								tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,122 @@ | ||||
| # Licensed to the Apache Software Foundation (ASF) under one | ||||
| # or more contributor license agreements.  See the NOTICE file | ||||
| # distributed with this work for additional information | ||||
| # regarding copyright ownership.  The ASF licenses this file | ||||
| # to you under the Apache License, Version 2.0 (the | ||||
| # "License"); you may not use this file except in compliance | ||||
| # with the License.  You may obtain a copy of the License at | ||||
| # | ||||
| #   http://www.apache.org/licenses/LICENSE-2.0 | ||||
| # | ||||
| # Unless required by applicable law or agreed to in writing, | ||||
| # software distributed under the License is distributed on an | ||||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||
| # KIND, either express or implied.  See the License for the | ||||
| # specific language governing permissions and limitations | ||||
| # under the License. | ||||
| 
 | ||||
| ### Localization | ||||
| # Locale sets language and country. | ||||
| d-i debian-installer/locale string en_US.UTF-8 | ||||
| d-i debian-installer/country string IN | ||||
| 
 | ||||
| # Keyboard selection. | ||||
| d-i keymap select us | ||||
| d-i keyboard-configuration/xkb-keymap select us | ||||
| 
 | ||||
| ### Network configuration | ||||
| d-i netcfg/choose_interface select auto | ||||
| d-i netcfg/get_hostname string systemvm | ||||
| d-i netcfg/get_domain string apache.org | ||||
| d-i netcfg/wireless_wep string | ||||
| 
 | ||||
| d-i hw-detect/load_firmware boolean true | ||||
| 
 | ||||
| ### Mirror settings | ||||
| d-i mirror/country string manual | ||||
| d-i mirror/http/hostname string deb.debian.org | ||||
| d-i mirror/http/directory string /debian | ||||
| d-i mirror/http/proxy string | ||||
| 
 | ||||
| ### Apt setup | ||||
| d-i apt-setup/cdrom/set-first false | ||||
| d-i apt-setup/security-updates boolean true | ||||
| d-i apt-setup/services-select multiselect security, updates | ||||
| d-i apt-setup/security_host string security.debian.org | ||||
| d-i apt-setup/local0/source boolean false | ||||
| d-i apt-setup/multiarch string i386 | ||||
| d-i apt-setup/backports  boolean true | ||||
| d-i apt-setup/contrib    boolean true | ||||
| d-i apt-setup/multiverse boolean true | ||||
| d-i apt-setup/universe   boolean true | ||||
| 
 | ||||
| ### Clock and time zone setup | ||||
| d-i clock-setup/utc boolean true | ||||
| d-i time/zone string UTC | ||||
| d-i clock-setup/ntp boolean true | ||||
| 
 | ||||
| ### Partitioning | ||||
| d-i partman-auto/disk string /dev/vda | ||||
| d-i partman-auto/method string regular | ||||
| d-i partman-auto/expert_recipe string                         \ | ||||
|       boot-root ::                                            \ | ||||
|               538 538 1075 free                               \ | ||||
|                       $iflabel{ gpt }                         \ | ||||
|                       $reusemethod{ }                         \ | ||||
|                       method{ efi }                           \ | ||||
|                       format{ }                               \ | ||||
|               .                                               \ | ||||
|               400 60 400 ext2                                 \ | ||||
|                       $primary{ } $bootable{ }                \ | ||||
|                       method{ format } format{ }              \ | ||||
|                       use_filesystem{ } filesystem{ ext2 }    \ | ||||
|                       mountpoint{ /boot }                     \ | ||||
|               .                                               \ | ||||
|               256 1000 256 linux-swap                         \ | ||||
|                       method{ swap } format{ }                \ | ||||
|               .                                               \ | ||||
|               2240 40 4000 ext4                               \ | ||||
|                       method{ format } format{ }              \ | ||||
|                       use_filesystem{ } filesystem{ ext4 }    \ | ||||
|                       mountpoint{ / }                         \ | ||||
|               . | ||||
| 
 | ||||
| d-i partman-md/confirm boolean true | ||||
| d-i partman-partitioning/confirm_write_new_label boolean true | ||||
| d-i partman/choose_partition select finish | ||||
| d-i partman/confirm boolean true | ||||
| d-i partman/confirm_nooverwrite boolean true | ||||
| grub-efi-arm64  grub2/force_efi_extra_removable boolean true | ||||
| d-i partman-partitioning/choose_label select gpt | ||||
| d-i partman-partitioning/default_label string gpt | ||||
| 
 | ||||
| ### Base system installation | ||||
| # ... | ||||
| 
 | ||||
| ### Account setup | ||||
| d-i passwd/root-login boolean false | ||||
| d-i passwd/root-password password password | ||||
| d-i passwd/root-password-again password password | ||||
| d-i passwd/user-fullname string Cloud User | ||||
| d-i passwd/username string cloud | ||||
| d-i passwd/user-password password cloud | ||||
| d-i passwd/user-password-again password cloud | ||||
| d-i user-setup/encrypt-home boolean false | ||||
| d-i user-setup/allow-password-weak boolean true | ||||
| d-i passwd/user-default-groups string audio cdrom video admin | ||||
| 
 | ||||
| ### Package selection | ||||
| tasksel tasksel/first multiselect ssh-server | ||||
| d-i pkgsel/include string openssh-server ntp acpid sudo bzip2 openssl | ||||
| # Allowed values: none, safe-upgrade, full-upgrade | ||||
| d-i pkgsel/upgrade select full-upgrade | ||||
| d-i pkgsel/update-policy select none | ||||
| 
 | ||||
| popularity-contest popularity-contest/participate boolean false | ||||
| 
 | ||||
| ### Boot loader installation | ||||
| d-i grub-installer/only_debian boolean true | ||||
| d-i grub-installer/bootdev  string default | ||||
| d-i finish-install/reboot_in_progress note | ||||
| 
 | ||||
| #### Advanced options | ||||
| @ -87,7 +87,7 @@ function install_packages() { | ||||
|   apt_clean | ||||
| 
 | ||||
|   # 32 bit architecture support for vhd-util | ||||
|   if [ "${arch}" != "i386" ]; then | ||||
|   if [[ "${arch}" != "i386" && "${arch}" != "arm64" ]]; then | ||||
|     dpkg --add-architecture i386 | ||||
|     apt-get update | ||||
|     ${apt_get} install libuuid1:i386 libc6:i386 | ||||
| @ -96,17 +96,25 @@ function install_packages() { | ||||
|   # Install docker and containerd for CKS | ||||
|   curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - | ||||
|   apt-key fingerprint 0EBFCD88 | ||||
|   add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | ||||
|   if [ "${arch}" == "arm64" ]; then | ||||
|     add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | ||||
|   elif [ "${arch}" == "amd64" ]; then | ||||
|     add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | ||||
|   else | ||||
|     add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | ||||
|   fi | ||||
|   apt-get update | ||||
|   ${apt_get} install containerd.io | ||||
| 
 | ||||
|   apt_clean | ||||
| 
 | ||||
|   install_vhd_util | ||||
|   # Install xenserver guest utilities as debian repos don't have it | ||||
|   wget https://mirrors.kernel.org/ubuntu/pool/main/x/xe-guest-utilities/xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb | ||||
|   dpkg -i xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb | ||||
|   rm -f xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb | ||||
|   if [ "${arch}" != "arm64" ]; then | ||||
|     install_vhd_util | ||||
|     # Install xenserver guest utilities as debian repos don't have it | ||||
|     wget https://mirrors.kernel.org/ubuntu/pool/main/x/xe-guest-utilities/xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb | ||||
|     dpkg -i xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb | ||||
|     rm -f xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb | ||||
|   fi | ||||
| } | ||||
| 
 | ||||
| return 2>/dev/null || install_packages | ||||
|  | ||||
| @ -0,0 +1,93 @@ | ||||
| { | ||||
|   "_license": "Apache License 2.0", | ||||
|   "builders": [ | ||||
|     { | ||||
|       "accelerator": "kvm", | ||||
|       "boot_command": [ | ||||
|         "c<wait>", | ||||
|         "linux /install.a64/vmlinuz <wait>", | ||||
|         "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed_aarch64.cfg <wait>", | ||||
|         "debian-installer=en_US.UTF-8 <wait>", | ||||
|         "auto <wait>", | ||||
|         "language=en locale=en_US.UTF-8 <wait>", | ||||
|         "kbd-chooser/method=us <wait>", | ||||
|         "keyboard-configuration/xkb-keymap=us <wait>", | ||||
|         "netcfg/get_hostname=systemvm <wait>", | ||||
|         "netcfg/get_domain=apache.org <wait>", | ||||
|         "country=IN keymap=us <wait>", | ||||
|         "fb=false <wait>", | ||||
|         "debconf/frontend=noninteractive <wait>", | ||||
|         "console-setup/ask_detect=false <wait>", | ||||
|         "console-keymaps-at/keymap=us <wait>", | ||||
| 	"---", | ||||
|         "<enter><wait>", | ||||
| 	"initrd /install.a64/initrd.gz", | ||||
| 	"<enter><wait>", | ||||
| 	"boot<enter><wait>" | ||||
|       ], | ||||
|       "boot_wait": "180s", | ||||
|       "disk_interface": "virtio", | ||||
|       "cdrom_interface": "virtio-scsi", | ||||
|       "disk_size": "5000M", | ||||
|       "format": "qcow2", | ||||
|       "headless": true, | ||||
|       "http_directory": "http", | ||||
|       "iso_checksum": "sha512:4980197fa30646a43df2672d98500a182d6636422e39e809d986551356f4d24b1ffab6d745331369b27f2e9a5326f020ba141df5772ac2c6328c08cce73de7e8", | ||||
|       "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/11.10.0/arm64/iso-cd/debian-11.10.0-arm64-netinst.iso", | ||||
|       "net_device": "virtio-net", | ||||
|       "output_directory": "../dist", | ||||
|       "qemu_binary": "qemu-system-aarch64", | ||||
|       "qemuargs": [ | ||||
|         [ | ||||
|           "-m", | ||||
|           "500M" | ||||
|         ], | ||||
| 	[ | ||||
|           "-machine", | ||||
|           "virt" | ||||
|         ], | ||||
| 	[ | ||||
|           "-cpu", | ||||
|           "host" | ||||
|         ], | ||||
|         [ | ||||
|           "-smp", | ||||
|           "1" | ||||
|         ], | ||||
| 	[ "-pflash", "/usr/share/AAVMF/AAVMF_CODE.fd" ], | ||||
| 	[ "-monitor", "none" ], | ||||
| 	[ "-enable-kvm" ], | ||||
| 	[ "-boot", "strict=off" ] | ||||
|       ], | ||||
|       "shutdown_command": "sudo halt -p", | ||||
|       "ssh_password": "cloud", | ||||
|       "ssh_timeout": "120m", | ||||
|       "ssh_username": "cloud", | ||||
|       "type": "qemu", | ||||
|       "vm_name": "systemvmtemplate" | ||||
|     } | ||||
|   ], | ||||
|   "description": "CloudStack SystemVM template", | ||||
|   "provisioners": [ | ||||
|     { | ||||
|       "execute_command": "echo 'cloud' | sudo -u root -S bash {{.Path}}", | ||||
|       "scripts": [ | ||||
|         "scripts/apt_upgrade.sh", | ||||
|         "scripts/configure_grub.sh", | ||||
|         "scripts/configure_locale.sh", | ||||
|         "scripts/configure_networking.sh", | ||||
|         "scripts/configure_acpid.sh", | ||||
|         "scripts/install_systemvm_packages.sh", | ||||
|         "scripts/configure_conntrack.sh", | ||||
|         "scripts/authorized_keys.sh", | ||||
|         "scripts/configure_persistent_config.sh", | ||||
|         "scripts/configure_login.sh", | ||||
|         "../cloud_scripts_shar_archive.sh", | ||||
|         "scripts/configure_systemvm_services.sh", | ||||
|         "scripts/cleanup.sh", | ||||
|         "scripts/finalize.sh" | ||||
|       ], | ||||
|       "type": "shell" | ||||
|     } | ||||
|   ] | ||||
| } | ||||
| @ -0,0 +1,91 @@ | ||||
| { | ||||
|   "_license": "Apache License 2.0", | ||||
|   "builders": [ | ||||
|     { | ||||
|       "boot_command": [ | ||||
|         "c<wait>", | ||||
|         "linux /install.a64/vmlinuz <wait>", | ||||
|         "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed_aarch64.cfg <wait>", | ||||
|         "debian-installer=en_US.UTF-8 <wait>", | ||||
|         "auto <wait>", | ||||
|         "language=en locale=en_US.UTF-8 <wait>", | ||||
|         "kbd-chooser/method=us <wait>", | ||||
|         "keyboard-configuration/xkb-keymap=us <wait>", | ||||
|         "netcfg/get_hostname=systemvm <wait>", | ||||
|         "netcfg/get_domain=apache.org <wait>", | ||||
|         "country=IN keymap=us <wait>", | ||||
|         "fb=false <wait>", | ||||
|         "debconf/frontend=noninteractive <wait>", | ||||
|         "console-setup/ask_detect=false <wait>", | ||||
|         "console-keymaps-at/keymap=us <wait>", | ||||
|         "---", | ||||
|         "<enter><wait>", | ||||
|         "initrd /install.a64/initrd.gz", | ||||
|         "<enter><wait>", | ||||
|         "boot<enter><wait>" | ||||
|       ], | ||||
|       "boot_wait": "60s", | ||||
|       "disk_interface": "virtio", | ||||
|       "cdrom_interface": "virtio-scsi", | ||||
|       "disk_size": "5000M", | ||||
|       "format": "qcow2", | ||||
|       "headless": true, | ||||
|       "http_directory": "http", | ||||
|       "iso_checksum": "sha512:4980197fa30646a43df2672d98500a182d6636422e39e809d986551356f4d24b1ffab6d745331369b27f2e9a5326f020ba141df5772ac2c6328c08cce73de7e8", | ||||
|       "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/11.10.0/arm64/iso-cd/debian-11.10.0-arm64-netinst.iso", | ||||
|       "net_device": "virtio-net", | ||||
|       "output_directory": "../dist", | ||||
|       "qemu_binary": "qemu-system-aarch64", | ||||
|       "qemuargs": [ | ||||
|         [ | ||||
|           "-m", | ||||
|           "500M" | ||||
|         ], | ||||
|         [ | ||||
|           "-machine", | ||||
|           "virt" | ||||
|         ], | ||||
|         [ | ||||
|           "-cpu", | ||||
|           "cortex-a72" | ||||
|         ], | ||||
|         [ | ||||
|           "-smp", | ||||
|           "1" | ||||
|         ], | ||||
|         [ "-bios", "/usr/share/qemu-efi-aarch64/QEMU_EFI.fd" ], | ||||
|         [ "-monitor", "none" ], | ||||
|         [ "-boot", "strict=off" ] | ||||
|       ], | ||||
|       "shutdown_command": "sudo halt -p", | ||||
|       "ssh_password": "cloud", | ||||
|       "ssh_timeout": "120m", | ||||
|       "ssh_username": "cloud", | ||||
|       "type": "qemu", | ||||
|       "vm_name": "systemvmtemplate" | ||||
|     } | ||||
|   ], | ||||
|   "description": "CloudStack SystemVM template", | ||||
|   "provisioners": [ | ||||
|     { | ||||
|       "execute_command": "echo 'cloud' | sudo -u root -S bash {{.Path}}", | ||||
|       "scripts": [ | ||||
|         "scripts/apt_upgrade.sh", | ||||
|         "scripts/configure_grub.sh", | ||||
|         "scripts/configure_locale.sh", | ||||
|         "scripts/configure_networking.sh", | ||||
|         "scripts/configure_acpid.sh", | ||||
|         "scripts/install_systemvm_packages.sh", | ||||
|         "scripts/configure_conntrack.sh", | ||||
|         "scripts/authorized_keys.sh", | ||||
|         "scripts/configure_persistent_config.sh", | ||||
|         "scripts/configure_login.sh", | ||||
|         "../cloud_scripts_shar_archive.sh", | ||||
|         "scripts/configure_systemvm_services.sh", | ||||
|         "scripts/cleanup.sh", | ||||
|         "scripts/finalize.sh" | ||||
|       ], | ||||
|       "type": "shell" | ||||
|     } | ||||
|   ] | ||||
| } | ||||
| @ -6,7 +6,7 @@ | ||||
|       "boot_command": [ | ||||
|         "<esc><wait>", | ||||
|         "install <wait>", | ||||
|         "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg <wait>", | ||||
|         "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed_x86_64.cfg <wait>", | ||||
|         "debian-installer=en_US.UTF-8 <wait>", | ||||
|         "auto <wait>", | ||||
|         "language=en locale=en_US.UTF-8 <wait>", | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user