How to run QEMU with Fedora + Custom kernel - linux-kernel

I am trying to run Fedora with QEMU, but with a custom kernel that i built by using the first steps from the readme.txt file from here. The kernel describes T-HEAD's C910 processor, and I want it in order to run benchmarks (Fedora was the first OS that I found that supports RISC-V).
Following the steps from Fedora's guide, QEMU finally successfully booted, but with the guide's suggested kernel. The command run is shown here.
qemu-system-riscv64 \
-bios none \
-nographic \
-machine virt \
-smp 8 \
-m 2G \
-kernel Fedora-Developer-Rawhide-*-fw_payload-uboot-qemu-virt-smode.elf \
-object rng-random,filename=/dev/urandom,id=rng0 \
-device virtio-rng-device,rng=rng0 \
-device virtio-blk-device,drive=hd0 \
-drive file=Fedora-Developer-Rawhide-*.raw,format=raw,id=hd0 \
-device virtio-net-device,netdev=usernet \
-netdev user,id=usernet,hostfwd=tcp::10000-:22
Also, the command from the readme.txt file from the first link works as well, but it just boots into the kernel alone, no OS (hence the need for the OS).
LD_LIBRARY_PATH=./host/lib ./host/csky-qemu/bin/qemu-system-riscv64 -M virt -kernel fw_jump.elf -device loader,file=Image,addr=0x80200000 -append "rootwait root=/dev/vda ro" -drive file=rootfs.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -nographic -smp 1
I tried modifing the -kernel argument from the command at Fedora's guide to the path to the custom kernel. By executing the command, it hangs at the start, as shown in the image below:
It's probably a matter of arguments that are supplied to QEMU since it's clear that the one from readme.txt and the one from Fedora's guide differ by a lot

Related

Invalid argument from bash script on MacOS command line

I'm trying to run the LiteCart bash installer script located here:
https://github.com/litecart/installer/tree/master/cli
Unfortunately, it's giving me a problem when I add preset arguments like this:
--document_root=/var/www/litecart/public_html \
--db_server=localhost \
--db_user=johndoe \
--db_password=mycatsname \
--db_database=mylitecartdb \
--db_prefix=lc_ \
--timezone=Europe/London \
--admin_folder=admin \
--admin_user=admin \
--admin_password=mydogsname \
--development_type=standard
I keep getting:
Error: Invalid argument (--document_root=/var/www/litecart/public_html)
My computer is running MacOS 10.15 and the server is running CentOS 7.9. The script runs fine without the arguments.
I can't find anything that even resembles this situation here. What's the proper way to run a script like this? Thanks.
Script contains no case for --document_root.
Try:
export document_root="/var/www/litecart/public_html"
./install.sh --db_server=localhost \
--db_user=johndoe \
--db_password=mycatsname \
--db_database=mylitecartdb \
--db_prefix=lc_
I assume that there are more problems in the script.

Can't get gdb to stop at breakpoint in Linux kernel running under Qemu

Have compiled linux 5.5.5 kernel, with make menuconfig added option CONFIG_GDB_SCRIPTS and turned off option CONFIG_DEBUG_INFO_REDUCED .
Runned qemu
qemu-system-x86_64 \
-kernel arch/x86/boot/bzImage \
-append "root=/dev/sda1" \
-device virtio-scsi-pci,id=scsi0 \
-drive file=../../zso2020_cow.qcow2,if=none,id=drive0 \
-device scsi-hd,bus=scsi0.0,drive=drive0 \
-enable-kvm \
-smp 1 \
-net nic,model=virtio -net user \
-net user,hostfwd=tcp::2222-:22 \
-m 1G -balloon virtio \
-fsdev local,id=hshare,path=$(pwd),security_model=none -device virtio-9p-pci,fsdev=hshare,mount_tag=hshare \
-chardev stdio,id=cons,signal=off -device virtio-serial-pci -device virtconsole,chardev=cons \
-soundhw hda \
-usb -device usb-mouse \
-gdb tcp::23308 \
-display none \
-S
Qemu runs with compiled kernel, what I have checked using kprint in source code.
Then I have runned
gdb \
-ex "add-auto-load-safe-path $(pwd)" \
-ex "file vmlinux" \
-ex 'target remote localhost:23308' \
-ex 'break start_kernel' \
-ex 'continue'
(both scripts were runned from directory with compiled kernel)
Qemu goes to user login, and gdb outputs (waits for breakpoint)
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Reading symbols from vmlinux...done.
Remote debugging using localhost:23308
0x000000000000fff0 in exception_stacks ()
Breakpoint 1 at 0xffffffff8271db30: file init/main.c, line 577.
Continuing.
I tried also
hbr insted of br
first target remote :23308 i and set breakpoint, then file vmlinux
go to compiled kernel directory and install kernel from qemu level
in every case gdb does not stops at breakpoint.
How to properly connect to kernel with gdb, where to look for mistake?
The solution to the problem was to add nokaslr option and use hbreak. That means replace
-append "root=/dev/sda1"
with
`-append "root=/dev/sda1 nokaslr"
and
break start_kernel
with
hbreak start_kernel
then gdb properly catches kernel breakpoints.

What does that script mean? What do i have to do to run it?

So, i have to update a firmware of a sonoff switch with a script i found on GitHub, i don't know how and where to run it, what programmes do i need. (I'm on windows)
I installed bash and tried to run it but it says "No such file or directory" and none of the tutorials on the internet works.
it says "line 8: esptool.py command not found"
esptool.py \
-p $SONOFF_PORT \
--baud 115200 \
write_flash \
-fs 8m \
-fm dout \
-ff 40m \
0x0 ./firmware/rboot.bin \
0x1000 ./firmware/blank_config.bin \
0x2000 ./firmware/Sonoff_$POWERON_STATE.bin
it should work and start the script but i keep getting error messages.
To install esptool using pip pip install esptool.
To check if you have python or pip installed:
python -V
pip -V
According to the filename (esptool.py) this should be a python script. So you need to have the correct python version (python2 or python3) installed and then run it via the respective python interpreter.
python esptool.py ...
Just executing it via bash tries to interpret as a bash script and that explains the error you are getting.

QEMU on Linux works, but on Windows (probably 7/8) fails when -redir parameter is used

I'm shipping my project via qemu static build and a Linux VM. My project uses port 4848 for server configuration and port 8080 for HTTP (tools) and ephermal ports (49152+) for spawned sub-projects that use p2p websockets.
Note that the qemu binary is the qemu-system-... binary from Linux and the qemu.exe on windows, all statically compiled.
On Linux, I'm starting everything with this command. It works like a charm as expected:
./qemu -curses \
-kernel ../vmlinuz \
-initrd ../root.gz \
-L ./ \
-redir tcp:4848::4848 \
-redir tcp:8080::8080 \
-redir tcp:49152::49152 \
-redir tcp:49153::49153 \
-redir tcp:49154::49154 \
-redir tcp:49155::49155 \
-redir tcp:49156::49156 \
-redir tcp:49157::49157 \
-redir tcp:49158::49158 \
-redir tcp:49159::49159 \
-redir tcp:49160::49160 \
-redir tcp:49161::49161 \
-redir tcp:49162::49162 \
-append "quiet autologin loglevel=3"
On my Windows XP VM (in VirtualBox), this command here works fine without issues once you have approved the Firewall popup, but it seems to not work on Windows 8:
start qemu.exe -kernel ..\vmlinuz -initrd ..\root.gz -L ./ -redir tcp:4848::4848 -redir tcp:8080::8080 -redir tcp:49152::49152 -redir tcp:49153::49153 -redir tcp:49154::49154 -redir tcp:49155::49155 -redir tcp:49156::49156 -redir tcp:49157::49157 -redir tcp:49158::49158 -redir tcp:49159::49159 -redir tcp:49160::49160 -redir tcp:49161::49161 -redir tcp:49162::49162 -append "quiet autologin loglevel=3"
I found out that there might be an issue with the NE2000 network card driver on Windows, which I read here: http://www.h7.dion.ne.jp/~qemu-win/HowToNetwork-en.html
When trying to bootup qemu.exe directly without the -redir stuff and the flags "-net nic,model=rtl8139 -net user", it boots up properly.
But when I start to add the -redir flags on Windows8, it crashes and not even shows a single message in the cmd / Terminal.
Question
How to properly redir ports of a VM guest to a Windows 8 host with qemu.exe in CMD?

How to get better performance with Qt4.5 on arm platform

I just finished porting the QT4.5.3 GUI lib with touchscreen lib tslib1.4.1 to arm9 based S3C2440;but I find programs are running slow.How to make Qt4.5.3 run more smoothly?
I have already read the references on http://doc.trolltech.com/4.7-snapshot/fine-tuning-features.html and http://doc.trolltech.com/4.7-snapshot/qt-performance.html Any other suggestion according to your experience?Thanks!
I use the S3C24xx too. I use Qt 4.6.2. Here is my compile configuration
#host:/qt-everywhere-opensource-src-4.6.2#./configure \
-opensource \
-confirm-license \
-release -shared \
-embedded arm \
-xplatform qws/linux-arm-g++ \
-depths 16,18,24 \
-fast \
-optimized-qmake \
-pch \
-qt-sql-sqlite \
-qt-libjpeg \
-qt-zlib \
-qt-libpng \
-qt-freetype \
-little-endian -host-little-endian \
-no-qt3support \
-no-libtiff -no-libmng \
-no-opengl \
-no-mmx -no-sse -no-sse2 \
-no-3dnow \
-no-openssl \
-no-webkit \
-no-qvfb \
-no-phonon \
-no-nis \
-no-opengl \
-no-cups \
-no-glib \
-no-xcursor -no-xfixes -no-xrandr -no-xrender \
-no-separate-debug-info \
-nomake examples -nomake tools -nomake docs \
-qt-mouse-tslib -I/usr/local/tslib/include -L/usr/local/tslib/lib
#host:/qt-everywhere-opensource-src-4.6.2# make
#host:/qt-everywhere-opensource-src-4.6.2# make install
Also notice that, if you change optimization level of compiler in file qt-everywhere-opensource-src-4.6.2/mkspecs/common/g++.conf from -O2 to -O0 may cause the Qt library run very slow.
Hope it is useful for you.
I suggest running a profiling tool to see what your program is actually doing. It might be that another part of your program is hogging the CPU. Performance problems are often first noticed through the GUI since it is something that the user sees and interacts with. Oprofile is a good tool to try out.

Resources