Skip to contentSkip to conversation

package/test-vm: a virtual machine image to test libvirt

PATCH New unixmania at gmail.com 2 participants 2 messages Oct 25, 2019 – Oct 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/test-vm: a virtual machine image to test libvirt

From: Carlos Santos <[email protected]>

Builds and installs a virtual machine disk image to test libvirt. Only x86_64 is supported at the moment. Refer to package/test-vm/readme.txt for instructions.

---
CC: Matthew Weber <[email protected]>
---

---
 package/Config.in                 |  1 +
 package/test-vm/Config.in         |  4 ++
 package/test-vm/grub-bios.cfg     | 10 +++++
 package/test-vm/post-build.sh     | 11 ++++++
 package/test-vm/readme.txt        | 63 +++++++++++++++++++++++++++++++
 package/test-vm/test-vm.mk        | 25 ++++++++++++
 package/test-vm/test-vm.xml       | 59 +++++++++++++++++++++++++++++
 package/test-vm/test_vm_defconfig | 28 ++++++++++++++
 8 files changed, 201 insertions(+)
 create mode 100644 package/test-vm/Config.in
 create mode 100644 package/test-vm/grub-bios.cfg
 create mode 100755 package/test-vm/post-build.sh
 create mode 100644 package/test-vm/readme.txt
 create mode 100644 package/test-vm/test-vm.mk
 create mode 100644 package/test-vm/test-vm.xml
 create mode 100644 package/test-vm/test_vm_defconfig
package/Config.in +1 -0
index a3fb5af04b..d71582dafd 100644
@@ -2290,6 +2290,7 @@ menu "System tools"
 	source "package/systemd-bootchart/Config.in"
 	source "package/sysvinit/Config.in"
 	source "package/tar/Config.in"
+	source "package/test-vm/Config.in"
 	source "package/tpm-tools/Config.in"
 	source "package/tpm2-abrmd/Config.in"
 	source "package/tpm2-tools/Config.in"
package/test-vm/Config.in new file +4 -0
new file mode 100644
index 0000000000..efaa475e22
@@ -0,0 +1,4 @@
+config BR2_PACKAGE_TEST_VM
+	bool "test-vm"
+	help
+	  A test VM for Libvirt.
package/test-vm/grub-bios.cfg new file +10 -0
new file mode 100644
index 0000000000..e3cc13a269
@@ -0,0 +1,10 @@
+serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
+terminal_input serial
+terminal_output serial
+
+set default="0"
+set timeout="5"
+
+menuentry "Buildroot" {
+	linux /boot/bzImage root=/dev/vda1 rootwait console=ttyS0,115200n8 locale.LANG=C net.ifnames=0
+}
package/test-vm/post-build.sh new file +11 -0
new file mode 100755
index 0000000000..5e4dc88a3d
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# exit on any failure
+set -e
+
+MY_DIR=$(dirname "$0")
+
+cp -f "$MY_DIR/grub-bios.cfg" "$TARGET_DIR/boot/grub/grub.cfg"
+
+# Copy grub 1st stage to binaries, required for genimage
+cp -f "$HOST_DIR/lib/grub/i386-pc/boot.img" "$BINARIES_DIR"
package/test-vm/readme.txt new file +63 -0

63 lines not on this page · raw message

package/test-vm/test-vm.mk new file +25 -0
new file mode 100644
index 0000000000..cc7f5b9240
@@ -0,0 +1,25 @@
+################################################################################
+#
+# test-vm
+#
+################################################################################
+
+define TEST_VM_CONFIGURE_CMDS
+	$(MAKE) O=$(@D) \
+		BR2_DEFCONFIG=$(TEST_VM_PKGDIR)/test_vm_defconfig \
+		BR2_DL_DIR=$(BR2_DL_DIR) \
+		defconfig
+endef
+
+define TEST_VM_BUILD_CMDS
+	$(MAKE) -C $(@D)
+endef
+
+define TEST_VM_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 644 $(@D)/images/disk.img \
+		$(TARGET_DIR)/var/lib/libvirt/images/test-vm.img
+	$(INSTALL) -D -m 644 $(TEST_VM_PKGDIR)/test-vm.xml \
+		$(TARGET_DIR)/etc/vm-templates/test-xm.xml
+endef
+
+$(eval $(generic-package))
package/test-vm/test-vm.xml new file +59 -0

59 lines not on this page · raw message

package/test-vm/test_vm_defconfig new file +28 -0
new file mode 100644
index 0000000000..1c548eafd7
@@ -0,0 +1,28 @@
+BR2_x86_64=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
+BR2_TOOLCHAIN_EXTERNAL_URL="https://toolchains.bootlin.com/downloads/releases/toolchains/x86-64-core-i7/tarballs/x86-64-core-i7--glibc--bleeding-edge-2018.11-1.tar.bz2"
+BR2_TOOLCHAIN_EXTERNAL_GCC_8=y
+BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_14=y
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
+BR2_TOOLCHAIN_EXTERNAL_CXX=y
+BR2_TARGET_GENERIC_HOSTNAME="test-vm"
+BR2_TARGET_GENERIC_ISSUE="Welcome to test-vm"
+BR2_SYSTEM_DHCP="eth0"
+BR2_ROOTFS_POST_BUILD_SCRIPT="package/test-vm/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/pc/genimage-bios.cfg"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.16"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux.config"
+BR2_LINUX_KERNEL_INSTALL_TARGET=y
+BR2_PACKAGE_ACPID=y
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+BR2_TARGET_ROOTFS_EXT2_SIZE="120M"
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_TARGET_GRUB2=y
+BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat squash4 part_msdos part_gpt normal biosdisk serial"
+BR2_PACKAGE_HOST_GENIMAGE=y
Signature · 1 line
2.18.1
#1 lore raw

PATCH 1/1 package/test-vm: a virtual machine image to test libvirt

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"unixmania" == unixmania <[email protected]> writes:

From: Carlos Santos <[email protected]>
Builds and installs a virtual machine disk image to test libvirt. Only x86_64 is supported at the moment. Refer to package/test-vm/readme.txt for instructions.

Cute! I'm not too happy about making a visible package for this though, right next to tar. How about adding it to a br2-external under support/testing/conf and use it in a runtime test?

Signature · 1 line
Bye, Peter Korsgaard