Code Monkey home page Code Monkey logo

run_qemu's Introduction

Requirements

  • mkosi
    • e.g. dnf install mkosi
  • qemu-system-x86_64
  • rsync
  • dracut
  • enabled virtualization (KVM)
  • nopasswd sudo preferred, or run as root, or enter passwords into the prompt several times
  • argbash to generate the argument parser lib (using parser_generator.m4)

Installation

  • symlink the run_qemu.sh script into somewhere in your PATH
    • e.g. ln -s ~/git/run_qemu/run_qemu.sh ~/bin/run_qemu.sh
  • Note: Supporting files in this repo are required to be in the same location as the script, after any symlink resolution. Copying just the script itself will not work.
  • Bash Completion
    • Copy or symlink the run_qemu file into the default bash completions dir
    • The completions directory can be found using: pkg-config --variable=completionsdir bash-completion

Usage Notes

  • Run this from the top level of a Linux kernel tree

    • e.g. run_qemu.sh --cxl --git-qemu
  • The script can/will:

    • Build the kernel with whatever .config is present (It is up to the user to manage the .config)
    • Create a rootfs image with the chosen distro using mkosi
    • Perform some basic setup on the rootfs, including installing the kernel, utilities (such as ndctl), and other convenience operations such as copying your ~/.ssh/id_rsa.pub for easy ssh access, and your ~/.bashrc etc.
    • Boot qemu with the newly compiled kernel provided on the qemu command line, and using the rootfs image above
    • Various options influence the qemu command line generated - there are options to select NUMA config, NVDIMMs, NVME devices, CXL devices etc.
  • More detailed CLI help is available with run_qemu.sh --help

  • Once qemu starts, in nographic mode, the Linux console 'takes over' the terminal. To interact with it, the following are useful:

    • Ctrl-a c : switch between the qemu monitor prompt (qemu) and console
    • Ctrl-a x : kill qemu and exit
  • mkosi creates a package cache in mkosi.cache/ If a cache is present, it will always use only that, and never go over the network even if newer packages are available. To force re-fetching everything, remove this directory, or --rebuild=wipe which removes the builddir entirely.

  • Which qemu to use can be overridden from the environment: qemu=/path/to/qemu/build/qemu-system-x86_64 ./run_qemu.sh [options]

  • List of variables that have overrides via env:

    • qemu
    • gdb
    • distro
    • rev
    • builddir
    • ndctl
  • To use the 'hostfwd' network, put this in your .ssh/config:

    Host rq
    Hostname localhost
    User root
    Port 10022
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
    

    And then ssh rq. You may need to open port 10022 on any local firewalls.

  • The root password for the guest VM is root. The serial console automatically logs in, and a password isn't required.

CXL Usage

The script enables generating a sane QEMU commandline for instantiating a basic CXL topology. Since QEMU support for CXL isn't yet upstream, --git-qemu is additionally required. The CXL related options are:

  • --cxl: Enables a simple CXL topology with:
    • single host bridge
      • 512M window size at 0x4c00000000
      • Bus #52
    • single root port
    • single Type 3 device
      • Persistent 256M
    • simple label storage area
  • --cxl-debug: Add any and all flags for extra debug (kernel and QEMU)
  • --cxl-hb: Turn q35 into a CXL capable Host bridge. Don't use this option unless you're working on support for this.
  • --cxl-test-run: Attempt to do a sanity test of the kernel and QEMU configuration.

DAX Usage

  • --dax-debug: Add any and all flags for extra debug of dax modules (kernel)

Kernel config

  • Make sure to Turn on CXL related options in the kernel's .config:
$ grep -i cxl .config
CONFIG_CXL_BUS=y
CONFIG_CXL_PCI=m
CONFIG_CXL_MEM_RAW_COMMANDS=y
CONFIG_CXL_ACPI=m
CONFIG_CXL_PMEM=m
CONFIG_CXL_MEM=m
CONFIG_CXL_PORT=y
CONFIG_CXL_SUSPEND=y

The following is a way to check basic sanity within the QEMU guest:

lspci  | grep '3[45]:00'
34:00.0 PCI bridge: Intel Corporation Device 7075
35:00.0 Memory controller [0502]: Intel Corporation Device 0d93 (rev 01)

readlink -f /sys/bus/cxl/devices/mem0
/sys/devices/pci0000:34/0000:34:00.0/0000:35:00.0/mem0

Fedora 39+ Notes

Fedora 39 updates mkosi to 15 (and later) which contains a lot of breaking changes, and indeed breaks various expectations with run_qemu's usage of it.

Fedora has packaged mkosi 14 separately and in parallel to the latest mkosi. Uninstall the default mkosi package, and install 'mkosi14' to continue using run_qemu on Fedora 39 and later.

# dnf remove mkosi
# dnf install mkosi14

run_qemu's People

Contributors

alisonschofield avatar bwidawsk avatar irides avatar jonzhang-fb avatar miguelinux avatar rchatre avatar sailer1205 avatar stellarhopper avatar sxd avatar weiny2 avatar zhijianli88 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

run_qemu's Issues

CXL devices does not seem to setup correctly

I'm running run_qemu.sh --cxl on Ubuntu 22.10 with qemu 7.2.0 and kernel 6.2, lspci returns the following result:

...
35:00.0 PCI bridge: Intel Corporation Device 7075
35:01.0 PCI bridge: Intel Corporation Device 7075
36:00.0 CXL: Intel Corporation Device 0d93 (rev 01)
37:00.0 CXL: Intel Corporation Device 0d93 (rev 01)
bf:00.0 PCI bridge: Intel Corporation Device 7075
bf:01.0 PCI bridge: Intel Corporation Device 7075
c0:00.0 CXL: Intel Corporation Device 0d93 (rev 01)
c1:00.0 CXL: Intel Corporation Device 0d93 (rev 01)

and here is the content under /sys/bus/cxl/devices:

decoder0.0  decoder1.0  nvdimm-bridge0  port2
decoder0.1  decoder2.0  port1           root0

which does not match the content described in README. I'm not using --git-qemu since qemu 7.2.0 has already merged the CXL support, but maybe it's still needed? Could you please point out potential issues in my setup? Thanks!

BTW, I found the following log in dmesg:

[   14.127689] cxl_pci 0000:c0:00.0: Failed to get interrupt for event Info log
[   14.129074] cxl_pci 0000:c1:00.0: Failed to get interrupt for event Info log

Is this an expected behavior?

failed to find line: Mapped CXL Memory Device resource

Hi,

I have already built the kernel. And I try to test the system. But I got the following error:

starting qemu. console output is logged to /tmp/rq_0.log
guest will be terminated after 15 minute(s)
+--------------------+
|  CXL Tests - FAIL  |
+--------------------+
failed to find line: Mapped CXL Memory Device resource

I modified the script to output the QEMU command line a little bit:

/mydata/qemu/build/qemu-system-x86_64 -machine q35,accel=kvm,nvdimm=on,cxl=on -m 8192M,slots=4,maxmem=40964M -smp 8,sockets=2,cores=2,threads=2 -enable-kvm -display none -nographic -serial file:/tmp/rq_0.log -drive if=pflash,format=raw,unit=0,file=OVMF_CODE.fd,readonly=on -drive if=pflash,format=raw,unit=1,file=OVMF_VARS.fd -debugcon file:uefi_debug.log -global isa-debugcon.iobase=0x402 -drive file=root.img,format=raw,media=disk -kernel mkosi.extra/boot/vmlinuz-5.19.0 -initrd mkosi.extra/boot/initramfs-5.19.0.img -append selinux=0 audit=0 console=tty0 console=ttyS0 root=/dev/sda2 ignore_loglevel rw memory_hotplug.memmap_on_memory=force cxl_acpi.dyndbg=+fplm cxl_pci.dyndbg=+fplm cxl_core.dyndbg=+fplm cxl_mem.dyndbg=+fplm cxl_pmem.dyndbg=+fplm cxl_port.dyndbg=+fplm cxl_region.dyndbg=+fplm cxl_test.dyndbg=+fplm cxl_mock.dyndbg=+fplm cxl_mock_mem.dyndbg=+fplm memmap=2G!4G efi_fake_mem=2G@6G:0x40000 -device e1000,netdev=net0,mac=52:54:00:12:34:56 -netdev user,id=net0,hostfwd=tcp::10022-:22 -object memory-backend-file,id=cxl-mem0,share=on,mem-path=cxltest0.raw,size=256M -object memory-backend-file,id=cxl-mem1,share=on,mem-path=cxltest1.raw,size=256M -object memory-backend-file,id=cxl-mem2,share=on,mem-path=cxltest2.raw,size=256M -object memory-backend-file,id=cxl-mem3,share=on,mem-path=cxltest3.raw,size=256M -object memory-backend-file,id=cxl-lsa0,share=on,mem-path=lsa0.raw,size=1K -object memory-backend-file,id=cxl-lsa1,share=on,mem-path=lsa1.raw,size=1K -object memory-backend-file,id=cxl-lsa2,share=on,mem-path=lsa2.raw,size=1K -object memory-backend-file,id=cxl-lsa3,share=on,mem-path=lsa3.raw,size=1K -device pxb-cxl,id=cxl.0,bus=pcie.0,bus_nr=53 -device pxb-cxl,id=cxl.1,bus=pcie.0,bus_nr=191 -device cxl-rp,id=hb0rp0,bus=cxl.0,chassis=0,slot=0,port=0 -device cxl-rp,id=hb0rp1,bus=cxl.0,chassis=0,slot=1,port=1 -device cxl-rp,id=hb1rp0,bus=cxl.1,chassis=0,slot=2,port=0 -device cxl-rp,id=hb1rp1,bus=cxl.1,chassis=0,slot=3,port=1 -device cxl-type3,bus=hb0rp0,memdev=cxl-mem0,id=cxl-dev0,lsa=cxl-lsa0 -device cxl-type3,bus=hb0rp1,memdev=cxl-mem1,id=cxl-dev1,lsa=cxl-lsa1 -device cxl-type3,bus=hb1rp0,memdev=cxl-mem2,id=cxl-dev2,lsa=cxl-lsa2 -device cxl-type3,bus=hb1rp1,memdev=cxl-mem3,id=cxl-dev3,lsa=cxl-lsa3 -M cxl-fmw.0.targets.0=cxl.0,cxl-fmw.0.size=4G,cxl-fmw.0.interleave-granularity=8k,cxl-fmw.1.targets.0=cxl.0,cxl-fmw.1.targets.1=cxl.1,cxl-fmw.1.size=4G,cxl-fmw.1.interleave-granularity=8k -qmp unix:/tmp/run_qemu_qmp_0,server,nowait -snapshot -object memory-backend-ram,id=mem0,size=2048M -numa node,nodeid=0,memdev=mem0, -numa cpu,node-id=0,socket-id=0 -object memory-backend-ram,id=mem1,size=2048M -numa node,nodeid=1,memdev=mem1, -numa cpu,node-id=1,socket-id=1 -object memory-backend-ram,id=mem2,size=2048M -numa node,nodeid=2,memdev=mem2, -object memory-backend-ram,id=mem3,size=2048M -numa node,nodeid=3,memdev=mem3, -numa node,nodeid=4, -object memory-backend-file,id=nvmem0,share=on,mem-path=nvdimm-0,size=16384M,align=1G -device nvdimm,memdev=nvmem0,id=nv0,label-size=2M,node=4 -numa node,nodeid=5, -object memory-backend-file,id=nvmem1,share=on,mem-path=nvdimm-1,size=16384M,align=1G -device nvdimm,memdev=nvmem1,id=nv1,label-size=2M,node=5 -numa dist,src=0,dst=0,val=10 -numa dist,src=0,dst=1,val=21 -numa dist,src=0,dst=2,val=12 -numa dist,src=0,dst=3,val=21 -numa dist,src=0,dst=4,val=17 -numa dist,src=0,dst=5,val=28 -numa dist,src=1,dst=1,val=10 -numa dist,src=1,dst=2,val=21 -numa dist,src=1,dst=3,val=12 -numa dist,src=1,dst=4,val=28 -numa dist,src=1,dst=5,val=17 -numa dist,src=2,dst=2,val=10 -numa dist,src=2,dst=3,val=21 -numa dist,src=2,dst=4,val=28 -numa dist,src=2,dst=5,val=28 -numa dist,src=3,dst=3,val=10 -numa dist,src=3,dst=4,val=28 -numa dist,src=3,dst=5,val=28 -numa dist,src=4,dst=4,val=10 -numa dist,src=4,dst=5,val=28 -numa dist,src=5,dst=5,val=10

Then I checked the log file, it seems no problem:

[  OK  ] Reached target Unmount All Filesystems.
[  OK  ] Closed Network Service Netlink Socket.
[  OK  ] Stopped Apply Kernel Variables.
[  OK  ] Stopped Load Kernel Modules.
[  OK  ] Stopped Create Static Device Nodes in /dev.
[  OK  ] Stopped Create System Users.
[  OK  ] Stopped Remount Root and Kernel File Systems.
[  OK  ] Reached target System Shutdown.
[  OK  ] Reached target Late Shutdown Services.
[  OK  ] Finished System Power Off.
[  OK  ] Reached target System Power Off.
[   10.650377] systemd-shutdown[1]: Syncing filesystems and block devices.
[   10.689438] systemd-shutdown[1]: Sending SIGTERM to remaining processes...
[   10.717339] systemd-journald[449]: Received SIGTERM from PID 1 (systemd-shutdow).
[   10.731498] systemd-shutdown[1]: Sending SIGKILL to remaining processes...
[   10.745673] systemd-shutdown[1]: Unmounting file systems.
[   10.749528] [647]: Remounting '/' read-only in with options '(null)'.
[   10.757674] EXT4-fs (sda2): re-mounted. Quota mode: none.
[   10.763603] systemd-shutdown[1]: All filesystems unmounted.
[   10.765736] systemd-shutdown[1]: Deactivating swaps.
[   10.767481] systemd-shutdown[1]: All swaps deactivated.
[   10.769480] systemd-shutdown[1]: Detaching loop devices.
[   10.774794] systemd-shutdown[1]: All loop devices detached.
[   10.777082] systemd-shutdown[1]: Stopping MD devices.
[   10.779097] systemd-shutdown[1]: All MD devices stopped.
[   10.780462] systemd-shutdown[1]: Detaching DM devices.
[   10.781864] systemd-shutdown[1]: All DM devices detached.
[   10.783232] systemd-shutdown[1]: All filesystems, swaps, loop devices, MD devices and DM devices detached.
[   10.790130] systemd-shutdown[1]: Syncing filesystems and block devices.
[   10.792615] systemd-shutdown[1]: Powering off.
[   10.795976] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[   10.798077] sd 0:0:0:0: [sda] Stopping disk
[   10.981353] ACPI: PM: Preparing to enter system sleep state S5
[   10.982950] reboot: Power down

The kernel I use is 5.19.
The part of the config looks like that:

$ grep -i cxl .config
CONFIG_CXL_BUS=m
CONFIG_CXL_PCI=m
CONFIG_CXL_MEM_RAW_COMMANDS=y
CONFIG_CXL_ACPI=m
CONFIG_CXL_PMEM=m
CONFIG_CXL_MEM=m
CONFIG_CXL_PORT=m
CONFIG_CXL_SUSPEND=y

Is the version of the Linux kernel a problem? The image I tried to build is ubuntu22.04.
Besides, I log into the image without test. The mode used by Pmem is:

root@localhost:~# ndctl list
[
  {
    "dev":"namespace0.0",
    "mode":"raw",
    "size":2147483648,
    "sector_size":512,
    "blockdev":"pmem0"
  }
]

The mode is raw.. I am not sure which part is wrong.
By the way, I made little modification here. I changed the : "${distro:=ubuntu}"
: "${rev:=jammy}"

#!/bin/bash -Ee
# SPDX-License-Identifier: CC0-1.0
# Copyright (C) 2021 Intel Corporation. All rights reserved.

# default config
: "${builddir:=./qbuild}"
rootpw="root"
rootfssize="10G"
nvme_size="1G"
efi_mem_size="2"   #in GiB
legacy_pmem_size="2"   #in GiB
pmem_size="16384"  #in MiB
pmem_label_size=2  #in MiB
pmem_final_size="$((pmem_size + pmem_label_size))"
: "${qemu:=qemu-system-x86_64}"
: "${gdb:=gdb}"
: "${distro:=ubuntu}"
: "${rev:=jammy}"
: "${ndctl:=$(readlink -f ~/git/ndctl)}"
selftests_home=root/built-selftests
mkosi_bin="mkosi"
mkosi_opts=("-i" "-f")

# some canned hmat defaults - make configurable as/when needed
# terminology:
# local = attached directly to the socket in question
# far = memory controller is on 'this' socket, but distinct numa node/pxm domain
# cross = memory controller across sockets
# mem = memory node and pmem = NVDIMM node, as before
# Units: lat(ency) - nanoseconds, bw - MB/s
local_mem_lat=5
local_mem_bw=2000
far_mem_lat=10
far_mem_bw=1500
cross_mem_lat=20
cross_mem_bw=1000
# local_pmem is not a thing. In these configs we always give pmems their own node
far_pmem_lat=30
far_pmem_bw=1000
cross_pmem_lat=40
cross_pmem_bw=500

# similarly, some canned SLIT defaults
local_mem_dist=10
far_mem_dist=12
cross_mem_dist=21
far_pmem_dist=17
cross_pmem_dist=28

# CXL device params
cxl_addr="0x4c00000000"
cxl_backend_size="512M"
cxl_t3_size="256M"
cxl_label_size="1K"

Looking forward to your reply.

Thank you very much

run_qemu failed during "Copying in extra file trees…"

Hello,

I am currently trying to apply this script with the following materials, and it always failed during Create a snapshot of '/root/git/linux/qbuild/mkosi.cache/fedora~40/image.cache' in '/root/git/linux/qbuild/.mkosi-tmpsv2arv0d/root'

DISTRO: Fedora release 40 (Rawhide) with 6.5.0-0.rc6.20230818git0e8860d2125f.47.fc40.x86_64
Linux: latest linux tree: https://github.com/torvalds/linux.git
mkosi: mkosi 15.1

# run_qemu.sh --cxl  -r wipe
--snip--
‣   Installing cache copies
‣   Copying cached trees
Create a snapshot of '/root/git/linux/qbuild/mkosi.cache/fedora~40/image.cache' in '/root/git/linux/qbuild/.mkosi-tmpsv2arv0d/root'
‣   Copying in extra file trees…
cp: cannot overwrite non-directory '/root/git/linux/qbuild/.mkosi-tmpsv2arv0d/root/lib' with directory '/root/git/linux/qbuild/mkosi.extra/lib'
‣ "cp --recursive --preserve=mode,timestamps,links,xattr --reflink=auto /root/git/linux/qbuild/mkosi.extra /root/git/linux/qbuild/.mkosi-tmpsv2arv0d/root --no-target-directory" returned non-zero exit code 1.

Could you help check it?

Building for CXL doesn't respect users qemu environment variable

sudo qemu=/path-to/qemu/build/qemu-system-x86_64 run_qemu.sh --git-qemu --cxl-debug

if [[ $_arg_cxl_legacy == "on" ]] || [[ $_arg_cxl == "on" ]]; then
		_arg_git_qemu="on"
	fi
	if [[ $_arg_git_qemu == "on" ]]; then
		qemu=~/git/qemu/x86_64-softmmu/qemu-system-x86_64
		qemu_img=~/git/qemu/qemu-img
		qmp=~/git/qemu/scripts/qmp/qmp-shell
		# upstream changed where binaries go recently
		if [ ! -f "$qemu_img" ]; then
			qemu=~/git/qemu/build/qemu-system-x86_64
			qemu_img=~/git/qemu/build/qemu-img
		fi

‣ Error: Sorry, --without-unified-kernel-images is not supported in UEFI mode on this distro.

I tried to run it with the run_qemu.sh to build the ubuntu image. So I modified the following inside the run_qemu.sh.

: "${distro:=ubuntu}"
: "${rev:=focal}"

Then I try the following command in my linux kernel folder:

sudo run_qemu.sh --cxl

Then I got the following result:

‣ Error: Sorry, --without-unified-kernel-images is not supported in UEFI mode on this distro.

Could you give me some hints on which part is wrong? Thank you very much

cannot boot a guest

I've recently been getting the following splat and cannot work around it so far (this is on latest and older branches of qemu). This occurs with the most basic invocations of run_qemu.sh.

EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
!!!! X64 Exception Type - 0D(#GP - General Protection) CPU Apic ID - 00000000 !!!!
ExceptionData - 0000000000000000
RIP - 000000004FE7CD45, CS - 0000000000000038, RFLAGS - 0000000000010206
RAX - 00790072006F0074, RCX - 000000007F258A80, RDX - 000000007E43EAC0
RBX - 000000007E39A000, RSP - 000000007FE9B760, RBP - 0000000000000000
RSI - 000000007FEB31A0, RDI - 00000000AFAFAFAF
R8 - 000000007E399B98, R9 - 000000007FE9B800, R10 - 00000000AFAFAFAF
R11 - 00000000AFAFAFAF, R12 - 00790072006F0074, R13 - 000000007FE9B800
R14 - 000000004F4B5000, R15 - 0000000000000001
DS - 0000000000000030, ES - 0000000000000030, FS - 0000000000000030
GS - 0000000000000030, SS - 0000000000000030
CR0 - 0000000080010033, CR2 - 0000000000000000, CR3 - 000000007FC01000
CR4 - 0000000000000668, CR8 - 0000000000000000
DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
GDTR - 000000007F9DE000 0000000000000047, LDTR - 0000000000000000
IDTR - 000000007F25E018 0000000000000FFF, TR - 0000000000000000
FXSAVE_STATE - 000000007FE9B3C0

mkosi 13 breaks run_qemu's fresh image build

Adding this issue here to keep track of it and narrow it down further.

An update to mkosi 13 seems to have broken run_qemu. For a fresh build (-r wipe), mkosi fails with:

dracut: dracut module 'nvmf' depends on 'network', which can't be installed
Kernel image argument /lib/modules/5.18.0-rc2/vmlinuz not a file
Error: Workspace command kernel-install add 5.18.0-rc2 /lib/modules/5.18.0-rc2/vmlinuz returned non-zero exit code 1.

Downgrading to mkosi 12 fixes this for now.

Have git-qemu take a command line argument

git-qemu is currently a boolean, if set, qemu is expected to be at ~/git/qemu. Does it make sense for this argument to take a path to a qemu tree? If so, I can send a PR.

Format/mount CXL devices

Hi,

I have managed to run QEMU using this script in combination with:

QEMU runs fine, I can see the cxl devices in /dev/cxl/.

ndctl reports the below

[root@localhost ndctl]# ndctl list -BDiu -b CXL
{
  "provider":"CXL",
  "dev":"ndbus0",
  "dimms":[
    {
      "dev":"nmem1"
    },
    {
      "dev":"nmem0"
    }
  ]
}

After that I have not been able to format (e.g., with xfs) and mount/use the devices. Any suggestions on how to make actual use of those devices?

Thanks

Error: Workspace command kernel-install add 6.5.0 /lib/modules/6.5.0/vmlinuz returned non-zero exit code 1.

Hello

Running run_qemu with [1] failed at [2], could anyone help check it?
And could you help provide the workable environment, so I can try with them.

[1]

DISTRO: Fedora release 39 (Thirty Nine) with 6.5.0-0.rc7.20230821gitf7757129e3de.50.fc39.x86_64
Linux: latest linux tree: https://github.com/torvalds/linux.git
mkosi: mkosi-14-5.fc39.noarch

[2]

#run_qemu.sh --cxl
--snip--
‣      Unmounting API VFS…
‣    Unmounting Package Cache
‣    Setting root password
‣    Setting up autologin…
‣    Removing random seed
‣   Unmounting image…
‣  Detaching /dev/loop0
‣  Installing cache copy…
‣  Installed cache copy root.img.cache-pre-inst
‣  Changing ownership of output file /root/git/linux/qbuild/root.img.cache-pre-inst to user root…
‣  Changed ownership of /root/git/linux/qbuild/root.img.cache-pre-inst
‣ Running second (final) stage…
‣  Basing off cached image /root/git/linux/qbuild/root.img.cache-pre-inst
‣  Copied cached image as /root/git/linux/qbuild/.mkosi-i88mczn7
‣  Refreshing partition table…
Partition #1 contains a vfat signature.
Partition #2 contains a ext4 signature.
‣  Refreshed partition table.
‣  Attaching /root/git/linux/qbuild/.mkosi-i88mczn7 as loopback…
‣   Refreshing file system /dev/loop0p2…
tune2fs 1.47.0 (5-Feb-2023)
‣   Mounting image…
‣    Copying in extra file trees…
‣    Generating initramfs images…
/usr/bin/dracut: line 1056: /sys/module/firmware_class/parameters/path: No such file or directory
dracut: No '/dev/log' or 'logger' included for syslog logging
/usr/bin/dracut: line 1056: /sys/module/firmware_class/parameters/path: No such file or directory
dracut: No '/dev/log' or 'logger' included for syslog logging
cp: error writing '/efi/99d5c5d911e74e8192390fba2a07d2a2/6.5.0/initrd': No space left on device
dracut: Creation of /efi/99d5c5d911e74e8192390fba2a07d2a2/6.5.0/initrd failed
‣ Error: Workspace command kernel-install add 6.5.0 /lib/modules/6.5.0/vmlinuz returned non-zero exit code 1.

sed: can't read ./qbuild/mnt/loader/loader.conf: No such file or directory

Hello,

I am currently trying to apply this script with the following materials.

Since my host OS is Ubuntu(20.04), I am trying out the recently merged "Add Ubuntu Support" to install ubuntu-bionic(18.04). But I am facing the following error.

After successfully going through "build_kernel" and "make_rootfs" (I have used the command 'sudo run_qemu.sh --cxl --git-qemu') an error occurs during 'update_rootfs_boot_kernel'.

sed: can't read ./qbuild/mnt/loader/loader.conf: No such file or directory

In line 491 of 'run_qemu.sh', there is a reference to '$builddir/mnt/loader/loader.conf'. So to check this out, I have manually mounted the EFI system partition (using losetup, mount) and checked the /mnt/loader directory. It only contained a directory named 'entries'.

I tried to solve this myself, and looked through all the scripts, but I couldn't find any other part where it mounted the EFI system partition rather than 'update_rootfs_boot_kernel'. Could it be because of some sort of mkosi error?

Thank you for your time.

ubuntu gdb Segmentation fault

run_qemu.sh --git-qemu --rebuild=none --cxl --cxl-test --cxl-debug --gdb

/usr/local/bin/run_qemu.sh: line 1319: 288649 Segmentation fault (core dumped) "${qcmd[@]}"

Broken with mkosi version < 9

mkosi now requires a verb as part of the command invocation. From the docs, it looks like build is the correct verb to make everything behave as it did before.

ovmf install location

I'm trying to use this script to build the VM and get an error message: OVMF binaries not found, please install 'edk2-ovmf' or similar
The distro I'm using is ubuntu 22.04 and install the OVMF package. I have the following:

ls /usr/share/ovmf/
OVMF.fd  PkKek-1-snakeoil.key  PkKek-1-snakeoil.pem

run_qemu/run_qemu.sh

Lines 986 to 991 in 31cb2d0

if [ ! -f /usr/share/edk2/ovmf/OVMF_CODE.fd ]; then
echo "OVMF binaries not found, please install 'edk2-ovmf' or similar"
exit 1
fi
cp /usr/share/edk2/ovmf/OVMF_CODE.fd .
cp /usr/share/edk2/ovmf/OVMF_VARS.fd .

I'm not sure whether what I have are equivalent to the files listed here. I only have one fd file not CODES.fd and VARS.fd.

run_qemu.sh on top of linux kernel fails

Hello,
I'm trying to get used to run_qemu script in order to later manage multiple vm.
Following instructions from the readme, run_qemu.sh fails at some points:

debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
update-initramfs: deferring update (trigger activated)
Processing triggers for dracut (059-4) ...
dracut: Generating /boot/initrd.img-6.1.0-22-amd64
/usr/bin/dracut: line 1056: /sys/module/firmware_class/parameters/path: No such file or directory
dracut: Generating /boot/initrd.img-6.9.9
/usr/bin/dracut: line 1056: /sys/module/firmware_class/parameters/path: No such file or directory
Failed to create '/var/tmp/mkosi-e6ogcm3s/root/run/host/unix-export': File exists
‣ Error: Workspace command kernel-install add 6.9.9 /boot/vmlinuz-6.9.9 returned non-zero exit code 1.

I've compiled a 6.9.9 linux kernel, with by default option, (make menuconfig && make)
The only lines I've modified are distro=debian and rev=bookworm at the beginning of the script.
run_qemu.sh is not run as root

Versions:
I was using mkosi 14, and switch to latest stable release: 23
dracut :102-3
qemu : 9.0.1
I'm under Debian 12

dracut-install crashing

While this is not a bug in this project, 'run_qemu.sh' has a way of always triggering dracut-install(1) segfaults during the install_build_initrd phase. I can reproduce this on every run in Fedora 36 and Tumbleweed, it can happen multiple times as well during the same phase.

/usr/lib/dracut/dracut-init.sh: line 1015: 1240336 Segmentation fault      (core dumped) "$DRACUT_INSTALL" ${initdir:+-D "$initdir"} ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${srcmods:+--kerneldir "$srcmods"} ${_optional:+-o} ${_silent:+--silent} -m "$@"
dracut: FAILED:  /usr/lib/dracut/dracut-install -D /var/tmp/dracut.EboI1Q/initramfs -N nfit|libnvdimm|nd_pmem --kerneldir ./qbuild/mkosi.extra/lib/modules/5.18.0/ -o -m fuse msr ipmi-devintf fuse ip_tables ip6_tables

gdb can not put breakpoint on kernel function

Hello,

I am currently trying to apply this script with the following materials.

My host OS is Fedora 35, and this is my execution command
run_qemu.sh --cxl --cxl-legacy --debug --git-qemu --cxl-debug --gdb

Then it starts QEMU.

/home/hanjin/git/qemu/build/qemu-system-x86_64 -machine q35,accel=kvm,nvdimm=on,cxl=on -m 8192M,slots=4,maxmem=40964M -smp 8,sockets=2,cores=2,threads=2 -display none -nographic -drive if=pflash,format=raw,unit=0,file=OVMF_CODE.fd,readonly=on -drive if=pflash,format=raw,unit=1,file=OVMF_VARS.fd -debugcon file:uefi_debug.log -global isa-debugcon.iobase=0x402 -drive file=root.img,format=raw,media=disk -kernel ./mkosi.extra/boot/vmlinuz-5.17.1 -initrd mkosi.extra/boot/initramfs-5.17.1.img -append 'selinux=0 audit=0 console=tty0 console=ttyS0 root=/dev/sda2 ignore_loglevel rw cxl_acpi.dyndbg=+fplm cxl_pci.dyndbg=+fplm cxl_core.dyndbg=+fplm cxl_mem.dyndbg=+fplm cxl_port.dyndbg=+fplm cxl_region.dyndbg=+fplm cxl_test.dyndbg=+fplm cxl_mock.dyndbg=+fplm' -device e1000,netdev=net0,mac=52:54:00:12:34:56 -netdev user,id=net0,hostfwd=tcp::10022-:22 -object memory-backend-file,id=cxl-mem1,share=on,mem-path=cxl-window1,size=512M -object memory-backend-file,id=cxl-label1,share=on,mem-path=cxl-label1,size=1K -object memory-backend-file,id=cxl-label2,share=on,mem-path=cxl-label2,size=1K -device 'pxb-cxl,id=cxl.0,bus=pcie.0,bus_nr=52,uid=0,len-window-base=1,window-base[0]=0x4c00000000,memdev[0]=cxl-mem1' -device cxl-rp,id=rp0,bus=cxl.0,addr=0.0,chassis=0,slot=0,port=0 -device cxl-rp,id=rp1,bus=cxl.0,addr=1.0,chassis=0,slot=1,port=1 -device cxl-type3,bus=rp0,memdev=cxl-mem1,id=cxl-pmem0,size=256M,lsa=cxl-label1 -device cxl-type3,bus=rp1,memdev=cxl-mem1,id=cxl-pmem1,size=256M,lsa=cxl-label2 -snapshot -gdb tcp::10000 -S -object memory-backend-ram,id=mem0,size=2048M -numa node,nodeid=0,memdev=mem0, -numa cpu,node-id=0,socket-id=0 -object memory-backend-ram,id=mem1,size=2048M -numa node,nodeid=1,memdev=mem1, -numa cpu,node-id=1,socket-id=1 -object memory-backend-ram,id=mem2,size=2048M -numa node,nodeid=2,memdev=mem2, -object memory-backend-ram,id=mem3,size=2048M -numa node,nodeid=3,memdev=mem3, -numa node,nodeid=4, -object memory-backend-file,id=nvmem0,share=on,mem-path=nvdimm-0,size=16384M,align=1G -device nvdimm,memdev=nvmem0,id=nv0,label-size=2M,node=4 -numa node,nodeid=5, -object memory-backend-file,id=nvmem1,share=on,mem-path=nvdimm-1,size=16384M,align=1G -device nvdimm,memdev=nvmem1,id=nv1,label-size=2M,node=5 -numa dist,src=0,dst=0,val=10 -numa dist,src=0,dst=1,val=21 -numa dist,src=0,dst=2,val=12 -numa dist,src=0,dst=3,val=21 -numa dist,src=0,dst=4,val=17 -numa dist,src=0,dst=5,val=28 -numa dist,src=1,dst=1,val=10 -numa dist,src=1,dst=2,val=21 -numa dist,src=1,dst=3,val=12 -numa dist,src=1,dst=4,val=28 -numa dist,src=1,dst=5,val=17 -numa dist,src=2,dst=2,val=10 -numa dist,src=2,dst=3,val=21 -numa dist,src=2,dst=4,val=28 -numa dist,src=2,dst=5,val=28 -numa dist,src=3,dst=3,val=10 -numa dist,src=3,dst=4,val=28 -numa dist,src=3,dst=5,val=28 -numa dist,src=4,dst=4,val=10 -numa dist,src=4,dst=5,val=28 -numa dist,src=5,dst=5,val=10

And then when I start gdb and set break point an error occurs.

$ gdb vmlinux
(gdb) target remote :10000
(gdb) b start_kernel
Breakpoint 1 at 0xffffffff830cae77: file init/main.c, line 928.
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff830cae77

Command aborted.

If I turn off the KVM option of QEMU, then gdb can set breakpoint. However QEMU does not work with this warning.

qemu-system-x86_64: warning: This family of AMD CPU doesn't support hyperthreading(2)
Please configure -smp options properly or try enabling topoext feature.

How can I solve this problem?

Thank you for your time.

chmod: cannot access 'root.img': No such file or directory

Hello

Pls help check this error, during build process, thanks

DISTRO: Fedora release 40 (Rawhide) with 6.5.0-0.rc6.20230818git0e8860d2125f.47.fc40.x86_64
Linux: latest linux tree: https://github.com/torvalds/linux.git
mkosi: mkosi 15.1
running: mkosi -i -f build
‣ Removing output files…
‣ Building default image
Create subvolume '/root/git/linux/qbuild/.mkosi-tmp7dgrxv9y/root'
‣  Mounting image…
‣   Copying cached trees
Create a snapshot of '/root/git/linux/qbuild/mkosi.cache/fedora~40/image.cache' in '/root/git/linux/qbuild/.mkosi-tmp7dgrxv9y/root'
‣   Copying in extra file trees…
‣   Running postinstall script…
+ [[ ! -d /root/ndctl ]]
+ exit 0
‣   Generating system users
‣   Applying presets…
‣   Generating hardware database
No hwdb files found, skipping.
‣   Recording packages in manifest…
‣  Unmounting image…
‣  Generating disk image
No machine ID set, using randomized partition UUIDs.
Pre-populating btrfs filesystem of partition 10-root.conf twice to calculate minimal partition size
Populating btrfs filesystem.
Successfully populated btrfs filesystem.
btrfs-progs v6.3.2
See https://btrfs.readthedocs.io for more information.

NOTE: several default settings have changed in version 5.15, please make sure
      this does not affect your deployments:
      - DUP for metadata (-m dup)
      - enabled no-holes (-O no-holes)
      - enabled free-space-tree (-R free-space-tree)

Rootdir from:       /var/tmp/.#repart8f24a5ac7fa55719
  Shrink:           no
Label:              root-x86-64
UUID:               bcebc2c4-d003-4c52-bbd6-d5644151fd81
Node size:          16384
Sector size:        4096
Filesystem size:    1.00TiB
Block group profiles:
  Data:             single            8.02GiB
  Metadata:         DUP               1.00GiB
  System:           DUP               8.00MiB
SSD detected:       no
Zoned device:       no
Incompat features:  extref, skinny-metadata, no-holes, free-space-tree
Runtime features:   free-space-tree
Checksum:           crc32c
Number of devices:  1
Devices:
   ID        SIZE  PATH
    1     1.00TiB  /var/tmp/.#repartd9afafd37efe36ac

/var/tmp/.#repartd9afafd37efe36ac successfully formatted as btrfs (label "root-x86-64", uuid bcebc2c4-d003-4c52-bbd6-d5644151fd81)
Minimal partition size of btrfs filesystem of partition 10-root.conf is 8.4G
btrfs-progs v6.3.2
See https://btrfs.readthedocs.io for more information.

NOTE: several default settings have changed in version 5.15, please make sure
      this does not affect your deployments:
      - DUP for metadata (-m dup)
      - enabled no-holes (-O no-holes)
      - enabled free-space-tree (-R free-space-tree)

Rootdir from:       /var/tmp/.#repart8f24a5ac7fa55719
  Shrink:           no
Label:              root-x86-64
UUID:               4f743d66-1aee-492a-ad0c-73d7587d7fa7
Node size:          16384
Sector size:        4096
Filesystem size:    8.48GiB
Block group profiles:
  Data:             single            7.95GiB
  Metadata:         DUP             256.00MiB
  System:           DUP               8.00MiB
SSD detected:       no
Zoned device:       no
Incompat features:  extref, skinny-metadata, no-holes, free-space-tree
Runtime features:   free-space-tree
Checksum:           crc32c
Number of devices:  1
Devices:
   ID        SIZE  PATH
    1     8.48GiB  /var/tmp/.#repartd9afafd37efe36ac

/var/tmp/.#repartd9afafd37efe36ac successfully formatted as btrfs (label "root-x86-64", uuid 4f743d66-1aee-492a-ad0c-73d7587d7fa7)
Automatically determined minimal disk image size as 8.4G.
Sized '/root/git/linux/qbuild/.mkosi-tmp7dgrxv9y/staging/image.raw' to 8.4G.
Applying changes.
Wiped block device.
Discarded entire block device.
Successfully wiped file system signatures from future partition 0.
Copying in '/var/tmp/.#repartd9afafd37efe36ac' (8.4G) on block level into future partition 0.
Copying in of '/var/tmp/.#repartd9afafd37efe36ac' on block level completed.
Adding new partition 0 to partition table.
Writing new partition table.
All done.
‣  Generating disk image
No machine ID set, using randomized partition UUIDs.
Automatically determined minimal disk image size as 8.4G, current image size is 8.4G.
File '/root/git/linux/qbuild/.mkosi-tmp7dgrxv9y/staging/image.raw' already is of requested size or larger, not growing. (8.4G >= 8.4G)
No changes.
‣  Saving manifest image.manifest
‣  /root/git/linux/qbuild/image size is 8.5G, consumes 5.7G.
chmod: cannot access 'root.img': No such file or directory

Poorly named memory backend file

The file being created here is actually a "window" for possibly more than single type3 device. It can be confusing when seen in the file system, in particular if/when interleave is supported.
Something like:

- qcmd+=("-object" "memory-backend-file,id=cxl-mem1,share=on,mem-path=cxl-type3,size=$cxl_backend_size")
+ qcmd+=("-object" "memory-backend-file,id=cxl-mem1,share=on,mem-path=cxl-window1,size=$cxl_backend_size")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.