diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-01-23 15:49:17 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-01-23 15:49:17 +0000 |
commit | 573817bc72b5f3273bcf2bca6e2d98e105c976b5 (patch) | |
tree | 4247f6a199896108f7ce7f8d1a1fb724c15d7ce4 | |
parent | 4afda13f9e30f96932b1d1ab28ef014a9ebaaa29 (diff) | |
download | lh-bootstrap-573817bc72b5f3273bcf2bca6e2d98e105c976b5.tar.xz |
Add run-qemu and disk image creation
Disk image creation depends on libguestfs, which is a huge
dependency, but people will only run it on dev machines already,
and it saves reinventing the wheel.
-rw-r--r-- | Makefile | 38 | ||||
-rw-r--r-- | README.md | 12 | ||||
-rwxr-xr-x | run-qemu | 15 | ||||
-rw-r--r-- | sub/kernel/qemu-system-aarch64-config | 111 |
4 files changed, 142 insertions, 34 deletions
@@ -7,31 +7,6 @@ # used by make to handle dependencies. Each of these files is # being touched at the end of each recipe to update its date, # since make relies on dates to handle updates of targets. -# -# * why these "exec" at the beginning at each line? -# => make spawns a shell for every line in every recipe. -# The "exec" keyword at the beginning of the recipe lines -# is just a small optimization: it ensures that the shell -# doesn't stay around while the recipe line is running, -# so it saves a little RAM and CPU. On most build machines, -# this should not be noticeable. -# -# * why these "setuidgid $(NORMALUSER)" ? -# => to drop privileges, from root to a normal user, for recipes -# that do not need root privileges. The user's name is defined in -# lh-config. -# -# * why do we need to be root? -# => Because some unavoidable operations in the build process need root privileges: -# + correctly handling several different uids for the target. -# + manipulating and deleting a loopback device, to create the disk images. -# -# * why is skarnet.org often an order-only prerequisite in the sub-Makefiles? -# => When it's the case, it means the build process, not the target, -# depends on a skarnet.org tool (for instance s6-touch) built for the -# BUILD machine. There's no need to rebuild everything if the tool -# changes, since the HOST image does not depend on its details; we -# just need to ensure that the tool is there. ifndef LH_MAKE_MARKER @@ -45,7 +20,7 @@ NORMALUSER_GID := $(shell id -g $(NORMALUSER)) it: all -.PHONY: it all rootfs kernel clean distclean +.PHONY: it all rootfs kernel qemu-boot clean distclean all: $(OUTPUT)/tmp/.lh_rootfs_installed $(OUTPUT)/build-host/kernel/.lh_installed @@ -83,6 +58,17 @@ $(OUTPUT)/tmp/.lh_rootfs_installed: $(OUTPUT)/tmp/.lh_layout_installed $(OUTPUT) exec setuidgid $(NORMALUSER) touch $@ +# The qemu disk image (requires qemu and libguestfs-tools) + +$(OUTPUT)/tmp/.lh_diskimage_done: $(OUTPUT)/tmp/.lh_rootfs_installed + exec setuidgid $(NORMALUSER) qemu-img create -f qcow2 $(OUTPUT)/disk-image.qcow2 1G + exec virt-make-fs --format=qcow2 --size=2G --type=ext4 $(OUTPUT)/rootfs $(OUTPUT)/disk-image.qcow2 + exec setuidgid $(NORMALUSER) touch $@ + +qemu-boot: $(OUTPUT)/build-host/kernel/.lh_installed $(OUTPUT)/tmp/.lh_diskimage_done run-qemu + exec ./run-qemu + + # Subsystems ## libc, toolchains, utilities, for the build itself, or for building the host @@ -232,12 +232,12 @@ been removed. ### Running on backends +To use qemu with lh-bootstrap, you need the qemu package installed +(obviously), and *also* the libguestfs package; some distributions +call it `libguestfs-tools`. (The lh-bootstrap uses the `virt-make-fs` +and `virt-copy-in` binaries.) + To launch qemu on an image you just created, run `./make qemu-boot`. This will start a qemu process running the image you just created. -You can look at the ./qemu-boot script to see exactly what it does. - -You can also "./make vmware-image" or "./make virtualbox-image" to create -a "disk-image.vmdk" file, which will be suitable as a main disk image -for VMWare or Virtualbox. Running those emulators, however, is out of -scope for this document. +You can look at the ./run-qemu script to see exactly what it does. diff --git a/run-qemu b/run-qemu new file mode 100755 index 0000000..5434678 --- /dev/null +++ b/run-qemu @@ -0,0 +1,15 @@ +#!/bin/sh -e + +case "$QEMU_ARCH" in + aarch64) + qemucpu=cortex-a57 + qemuconsole=ttyAMA0 ;; +esac + +exec qemu-system-${QEMU_ARCH} -nographic -M virt -cpu $qemucpu -smp 4 -m 2G \ + -kernel "$OUTPUT/kernel" \ + -append "root=/dev/vda1 console=$qemuconsole" \ + -drive if=none,file=$OUTPUT/disk-image.qcow2,format=qcow2,id=disk \ + -netdev user,id=network,hostfwd=tcp:127.0.0.1:2222-:22 \ + -device virtio-blk-pci,drive=disk \ + -device virtio-net-device,netdev=network diff --git a/sub/kernel/qemu-system-aarch64-config b/sub/kernel/qemu-system-aarch64-config index 6365efb..abf348a 100644 --- a/sub/kernel/qemu-system-aarch64-config +++ b/sub/kernel/qemu-system-aarch64-config @@ -234,7 +234,6 @@ CONFIG_ARCH_MMAP_RND_BITS_MIN=18 CONFIG_ARCH_MMAP_RND_BITS_MAX=24 CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=11 CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16 -CONFIG_NO_IOPORT_MAP=y CONFIG_STACKTRACE_SUPPORT=y CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000 CONFIG_LOCKDEP_SUPPORT=y @@ -477,6 +476,7 @@ CONFIG_ARM_CPUIDLE=y # # CONFIG_ARM_SDE_INTERFACE is not set # CONFIG_FIRMWARE_MEMMAP is not set +# CONFIG_FW_CFG_SYSFS is not set CONFIG_HAVE_ARM_SMCCC=y CONFIG_ARM_PSCI_FW=y # CONFIG_ARM_PSCI_CHECKER is not set @@ -666,6 +666,7 @@ CONFIG_CMDLINE_PARTITION=y # end of Partition Types CONFIG_BLOCK_COMPAT=y +CONFIG_BLK_MQ_PCI=y CONFIG_BLK_MQ_VIRTIO=y CONFIG_BLK_PM=y @@ -958,8 +959,64 @@ CONFIG_HAVE_EBPF_JIT=y # CONFIG_ARM_AMBA=y CONFIG_HAVE_PCI=y -# CONFIG_PCI is not set +CONFIG_PCI=y +CONFIG_PCI_DOMAINS=y +CONFIG_PCI_DOMAINS_GENERIC=y +CONFIG_PCI_SYSCALL=y +# CONFIG_PCIEPORTBUS is not set +CONFIG_PCI_MSI=y +CONFIG_PCI_MSI_IRQ_DOMAIN=y +# CONFIG_PCI_QUIRKS is not set +# CONFIG_PCI_DEBUG is not set +# CONFIG_PCI_STUB is not set +# CONFIG_PCI_IOV is not set +# CONFIG_PCI_PRI is not set +# CONFIG_PCI_PASID is not set +# CONFIG_HOTPLUG_PCI is not set + +# +# PCI controller drivers +# + +# +# Cadence PCIe controllers support +# +# CONFIG_PCIE_CADENCE_HOST is not set +# end of Cadence PCIe controllers support + +# CONFIG_PCI_FTPCI100 is not set +# CONFIG_PCI_HOST_GENERIC is not set +# CONFIG_PCIE_XILINX is not set +# CONFIG_PCI_XGENE is not set +# CONFIG_PCIE_ALTERA is not set +# CONFIG_PCI_HOST_THUNDER_PEM is not set +# CONFIG_PCI_HOST_THUNDER_ECAM is not set + +# +# DesignWare PCI Core Support +# +# CONFIG_PCIE_DW_PLAT_HOST is not set +# CONFIG_PCI_HISI is not set +# CONFIG_PCIE_KIRIN is not set +# CONFIG_PCI_MESON is not set +# CONFIG_PCIE_AL is not set +# end of DesignWare PCI Core Support +# end of PCI controller drivers + +# +# PCI Endpoint +# +# CONFIG_PCI_ENDPOINT is not set +# end of PCI Endpoint + +# +# PCI switch controller drivers +# +# CONFIG_PCI_SW_SWITCHTEC is not set +# end of PCI switch controller drivers + # CONFIG_PCCARD is not set +# CONFIG_RAPIDIO is not set # # Generic Driver Options @@ -1015,11 +1072,15 @@ CONFIG_OF_RESERVED_MEM=y # CONFIG_PARPORT is not set CONFIG_BLK_DEV=y # CONFIG_BLK_DEV_NULL_BLK is not set +# CONFIG_BLK_DEV_PCIESSD_MTIP32XX is not set +# CONFIG_BLK_DEV_UMEM is not set CONFIG_BLK_DEV_LOOP=m CONFIG_BLK_DEV_LOOP_MIN_COUNT=8 CONFIG_BLK_DEV_CRYPTOLOOP=m # CONFIG_BLK_DEV_DRBD is not set # CONFIG_BLK_DEV_NBD is not set +# CONFIG_BLK_DEV_SKD is not set +# CONFIG_BLK_DEV_SX8 is not set CONFIG_BLK_DEV_RAM=m CONFIG_BLK_DEV_RAM_COUNT=16 CONFIG_BLK_DEV_RAM_SIZE=4096 @@ -1028,10 +1089,12 @@ CONFIG_BLK_DEV_RAM_SIZE=4096 CONFIG_VIRTIO_BLK=y # CONFIG_VIRTIO_BLK_SCSI is not set # CONFIG_BLK_DEV_RBD is not set +# CONFIG_BLK_DEV_RSXX is not set # # NVME Support # +# CONFIG_BLK_DEV_NVME is not set # CONFIG_NVME_FC is not set # CONFIG_NVME_TARGET is not set # end of NVME Support @@ -1040,8 +1103,12 @@ CONFIG_VIRTIO_BLK=y # Misc devices # # CONFIG_DUMMY_IRQ is not set +# CONFIG_PHANTOM is not set +# CONFIG_TIFM_CORE is not set # CONFIG_ENCLOSURE_SERVICES is not set +# CONFIG_HP_ILO is not set # CONFIG_SRAM is not set +# CONFIG_PCI_ENDPOINT_TEST is not set # CONFIG_XILINX_SDFEC is not set # CONFIG_PVPANIC is not set # CONFIG_C2PORT is not set @@ -1052,6 +1119,8 @@ CONFIG_VIRTIO_BLK=y # CONFIG_EEPROM_93CX6 is not set # end of EEPROM support +# CONFIG_CB710_CORE is not set + # # Texas Instruments shared transport line discipline # @@ -1099,7 +1168,11 @@ CONFIG_VIRTIO_BLK=y # # end of Intel MIC & related support +# CONFIG_GENWQE is not set # CONFIG_ECHO is not set +# CONFIG_MISC_ALCOR_PCI is not set +# CONFIG_MISC_RTSX_PCI is not set +# CONFIG_HABANA_AI is not set # end of Misc devices # @@ -1114,6 +1187,15 @@ CONFIG_HAVE_PATA_PLATFORM=y # CONFIG_ATA is not set # CONFIG_MD is not set # CONFIG_TARGET_CORE is not set +# CONFIG_FUSION is not set + +# +# IEEE 1394 (FireWire) support +# +# CONFIG_FIREWIRE is not set +# CONFIG_FIREWIRE_NOSY is not set +# end of IEEE 1394 (FireWire) support + CONFIG_NETDEVICES=y CONFIG_NET_CORE=y # CONFIG_BONDING is not set @@ -1132,6 +1214,7 @@ CONFIG_TUN=m CONFIG_VETH=m CONFIG_VIRTIO_NET=m # CONFIG_NLMON is not set +# CONFIG_ARCNET is not set # # CAIF transport drivers @@ -1143,6 +1226,8 @@ CONFIG_VIRTIO_NET=m # end of Distributed Switch Architecture drivers # CONFIG_ETHERNET is not set +# CONFIG_FDDI is not set +# CONFIG_HIPPI is not set # CONFIG_MDIO_DEVICE is not set # CONFIG_PHYLIB is not set # CONFIG_PPP is not set @@ -1157,6 +1242,7 @@ CONFIG_VIRTIO_NET=m # Enable WiMAX (Networking options) to see the WiMAX drivers # # CONFIG_WAN is not set +# CONFIG_VMXNET3 is not set CONFIG_NET_FAILOVER=m # CONFIG_ISDN is not set # CONFIG_NVM is not set @@ -1210,6 +1296,7 @@ CONFIG_VT_HW_CONSOLE_BINDING=y CONFIG_UNIX98_PTYS=y # CONFIG_LEGACY_PTYS is not set # CONFIG_SERIAL_NONSTANDARD is not set +# CONFIG_NOZOMI is not set # CONFIG_N_GSM is not set # CONFIG_TRACE_SINK is not set # CONFIG_NULL_TTY is not set @@ -1224,6 +1311,8 @@ CONFIG_SERIAL_8250=y # CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set # CONFIG_SERIAL_8250_FINTEK is not set CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_PCI=y +CONFIG_SERIAL_8250_EXAR=y CONFIG_SERIAL_8250_NR_UARTS=4 CONFIG_SERIAL_8250_RUNTIME_UARTS=4 # CONFIG_SERIAL_8250_EXTENDED is not set @@ -1242,12 +1331,14 @@ CONFIG_SERIAL_8250_FSL=y # CONFIG_SERIAL_UARTLITE is not set CONFIG_SERIAL_CORE=y CONFIG_SERIAL_CORE_CONSOLE=y +# CONFIG_SERIAL_JSM is not set # CONFIG_SERIAL_SIFIVE is not set # CONFIG_SERIAL_SCCNXP is not set # CONFIG_SERIAL_ALTERA_JTAGUART is not set # CONFIG_SERIAL_ALTERA_UART is not set # CONFIG_SERIAL_XILINX_PS_UART is not set # CONFIG_SERIAL_ARC is not set +# CONFIG_SERIAL_RP2 is not set # CONFIG_SERIAL_FSL_LPUART is not set # CONFIG_SERIAL_FSL_LINFLEXUART is not set # CONFIG_SERIAL_CONEXANT_DIGICOLOR is not set @@ -1260,8 +1351,10 @@ CONFIG_HVC_DRIVER=y CONFIG_VIRTIO_CONSOLE=m # CONFIG_IPMI_HANDLER is not set # CONFIG_HW_RANDOM is not set +# CONFIG_APPLICOM is not set # CONFIG_RAW_DRIVER is not set # CONFIG_TCG_TPM is not set +CONFIG_DEVPORT=y # CONFIG_XILLYBUS is not set # end of Character devices @@ -1323,13 +1416,18 @@ CONFIG_BCMA_POSSIBLE=y # CONFIG_MFD_MADERA is not set # CONFIG_MFD_HI6421_PMIC is not set # CONFIG_HTC_PASIC3 is not set +# CONFIG_LPC_ICH is not set +# CONFIG_LPC_SCH is not set +# CONFIG_MFD_JANZ_CMODIO is not set # CONFIG_MFD_KEMPLD is not set # CONFIG_MFD_MT6397 is not set +# CONFIG_MFD_RDC321X is not set # CONFIG_MFD_SM501 is not set # CONFIG_ABX500_CORE is not set # CONFIG_MFD_SYSCON is not set # CONFIG_MFD_TI_AM335X_TSCADC is not set # CONFIG_MFD_TQMX86 is not set +# CONFIG_MFD_VX855 is not set # end of Multifunction device drivers # CONFIG_REGULATOR is not set @@ -1339,6 +1437,8 @@ CONFIG_BCMA_POSSIBLE=y # # Graphics support # +CONFIG_VGA_ARB=y +CONFIG_VGA_ARB_MAX_GPUS=16 # CONFIG_DRM is not set # CONFIG_DRM_DP_CEC is not set @@ -1469,6 +1569,8 @@ CONFIG_RTC_INTF_DEV=y CONFIG_VIRT_DRIVERS=y CONFIG_VIRTIO=y CONFIG_VIRTIO_MENU=y +CONFIG_VIRTIO_PCI=m +CONFIG_VIRTIO_PCI_LEGACY=y CONFIG_VIRTIO_BALLOON=m CONFIG_VIRTIO_INPUT=m CONFIG_VIRTIO_MMIO=y @@ -1580,6 +1682,8 @@ CONFIG_RPMSG_VIRTIO=m # CONFIG_EXTCON is not set # CONFIG_MEMORY is not set # CONFIG_IIO is not set +# CONFIG_NTB is not set +# CONFIG_VME_BUS is not set # CONFIG_PWM is not set # @@ -1588,8 +1692,10 @@ CONFIG_RPMSG_VIRTIO=m CONFIG_IRQCHIP=y CONFIG_ARM_GIC=y CONFIG_ARM_GIC_MAX_NR=1 +CONFIG_ARM_GIC_V2M=y CONFIG_ARM_GIC_V3=y CONFIG_ARM_GIC_V3_ITS=y +CONFIG_ARM_GIC_V3_ITS_PCI=y # CONFIG_AL_FIC is not set CONFIG_PARTITION_PERCPU=y # end of IRQ chip support @@ -2076,6 +2182,7 @@ CONFIG_DECOMPRESS_LZO=y CONFIG_DECOMPRESS_LZ4=y CONFIG_GENERIC_ALLOCATOR=y CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y CONFIG_HAS_DMA=y CONFIG_NEED_SG_DMA_LENGTH=y CONFIG_NEED_DMA_MAP_STATE=y |