mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-21 21:51:57 +02:00
vm_image_util: add qemu_xen image type for testing
To aid testing things under Xen it helps to have a machine locally that actually runs Xen! This isn't a particularly great setup but it works well enough to simplify my own testing. Must be used with a developer image and packages built with `USE=vm-testing` set to include the Xen userspace tools.
This commit is contained in:
parent
d443daa168
commit
fe9db4157b
51
build_library/qemu_xen.sh
Executable file
51
build_library/qemu_xen.sh
Executable file
@ -0,0 +1,51 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT_DIR="`dirname "$0"`"
|
||||
VM_NAME=
|
||||
VM_IMAGE=
|
||||
VM_MEMORY=
|
||||
VM_NCPUS="`grep -c ^processor /proc/cpuinfo`"
|
||||
SSH_PORT=2222
|
||||
USAGE="Usage: $0 [-p PORT] [--] [qemu options...]
|
||||
Options:
|
||||
-p PORT The port on localhost to map to the VM's sshd. [2222]
|
||||
-h this ;-)
|
||||
|
||||
QEMU wrapper script for a VM that is compatible with Xen:
|
||||
- No x2apic, everything APIC related breaks when it is on.
|
||||
- No virtio, simply does not work whatsoever under Xen.
|
||||
|
||||
Any arguments after -p will be passed through to qemu, -- may be
|
||||
used as an explicit separator. See the qemu(1) man page for more details.
|
||||
"
|
||||
|
||||
while [ $# -ge 1 ]; do
|
||||
case "$1" in
|
||||
-p|-ssh-port)
|
||||
SSH_PORT="$2"
|
||||
shift 2 ;;
|
||||
-v|-verbose)
|
||||
set -x
|
||||
shift ;;
|
||||
-h|-help|--help)
|
||||
echo "$USAGE"
|
||||
exit ;;
|
||||
--)
|
||||
shift
|
||||
break ;;
|
||||
*)
|
||||
break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
qemu-system-x86_64 \
|
||||
-machine accel=kvm \
|
||||
-cpu host,-x2apic \
|
||||
-smp "${VM_NCPUS}" \
|
||||
-name "$VM_NAME" \
|
||||
-m ${VM_MEMORY} \
|
||||
-net nic,vlan=0,model=e1000 \
|
||||
-net user,vlan=0,hostfwd=tcp::"${SSH_PORT}"-:22,hostname="${VM_NAME}" \
|
||||
-drive if=scsi,file="${SCRIPT_DIR}/${VM_IMAGE}" \
|
||||
"$@"
|
||||
exit $?
|
@ -13,6 +13,7 @@ VALID_IMG_TYPES=(
|
||||
qemu
|
||||
qemu_no_kexec
|
||||
qemu_uefi
|
||||
qemu_xen
|
||||
rackspace
|
||||
rackspace_onmetal
|
||||
rackspace_vhd
|
||||
@ -44,6 +45,7 @@ VALID_OEM_PACKAGES=(
|
||||
hyperv
|
||||
rackspace
|
||||
rackspace-onmetal
|
||||
xendom0
|
||||
vagrant
|
||||
vagrant-key
|
||||
vmware
|
||||
@ -118,6 +120,12 @@ IMG_qemu_uefi_DISK_FORMAT=qcow2
|
||||
IMG_qemu_uefi_DISK_LAYOUT=vm
|
||||
IMG_qemu_uefi_CONF_FORMAT=qemu_uefi
|
||||
|
||||
IMG_qemu_xen_DISK_FORMAT=qcow2
|
||||
IMG_qemu_xen_DISK_LAYOUT=vm
|
||||
IMG_qemu_xen_CONF_FORMAT=qemu_xen
|
||||
IMG_qemu_xen_OEM_PACKAGE=oem-xendom0
|
||||
IMG_qemu_xen_MEM=2048
|
||||
|
||||
## xen
|
||||
IMG_xen_BOOT_KERNEL=0
|
||||
IMG_xen_CONF_FORMAT=xl
|
||||
@ -606,6 +614,21 @@ _write_qemu_uefi_conf() {
|
||||
VM_GENERATED_FILES+=( "$(_dst_dir)/${ovmf_ro}" "$(_dst_dir)/${ovmf_rw}" )
|
||||
}
|
||||
|
||||
_write_qemu_xen_conf() {
|
||||
local script="$(_dst_dir)/$(_dst_name ".sh")"
|
||||
local dst_name=$(basename "$VM_DST_IMG")
|
||||
local vm_mem="$(_get_vm_opt MEM)"
|
||||
|
||||
sed -e "s%^VM_NAME=.*%VM_NAME='${VM_NAME}'%" \
|
||||
-e "s%^VM_IMAGE=.*%VM_IMAGE='${dst_name}'%" \
|
||||
-e "s%^VM_MEMORY=.*%VM_MEMORY='${vm_mem}'%" \
|
||||
"${BUILD_LIBRARY_DIR}/qemu_xen.sh" > "${script}"
|
||||
checkbashisms --posix "${script}" || die
|
||||
chmod +x "${script}"
|
||||
|
||||
VM_GENERATED_FILES+=( "${script}" )
|
||||
}
|
||||
|
||||
_write_pxe_conf() {
|
||||
local script="$(_dst_dir)/$(_dst_name ".sh")"
|
||||
local vmlinuz_name="$(_dst_name ".vmlinuz")"
|
||||
|
Loading…
x
Reference in New Issue
Block a user