QEMU 网络和盖蒂问题



我正在尝试使用 qemu 为基于 ARM 的虚拟机创建一个极简主义设置。我正在按照以下指南执行此操作。

我正在使用以下命令运行 QEMU。

qemu-system-arm -M vexpress-a9 -dtb ./linux-4.20.8/arch/arm/boot/dts/vexpress-v2p-ca9.dtb -kernel ./linux-4.20.8/arch/arm/boot/zImage -initrd rootfs.img --append "console=ttyAMA0" --nographic

由于某种原因,我无法看到登录提示。这些是引导消息

pulseaudio: set_sink_input_volume() failed
pulseaudio: Reason: Invalid argument
pulseaudio: set_sink_input_mute() failed
pulseaudio: Reason: Invalid argument
Booting Linux on physical CPU 0x0
Linux version 4.20.8 (aijazbaig1@piper11) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29)) #2 SMP Sat Sep 7 17:17:31 +08 2019
CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
OF: fdt: Machine model: V2P-CA9
Memory policy: Data cache writeback
CPU: All CPU(s) started in SVC mode.
random: get_random_bytes called from start_kernel+0x88/0x458 with crng_init=0
percpu: Embedded 16 pages/cpu @(ptrval) s36800 r8192 d20544 u65536
Built 1 zonelists, mobility grouping on.  Total pages: 130048
Kernel command line: console=ttyAMA0 ip=dhcp
printk: log_buf_len individual max cpu contribution: 4096 bytes
printk: log_buf_len total cpu_extra contributions: 12288 bytes
printk: log_buf_len min size: 16384 bytes
printk: log_buf_len: 32768 bytes
printk: early log buf free: 14964(91%)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 498388K/524288K available (6144K kernel code, 400K rwdata, 1408K rodata, 1024K init, 157K bss, 25900K reserved, 0K cma-reserved)
Virtual kernel memory layout:
vector  : 0xffff0000 - 0xffff1000   (   4 kB)
fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
vmalloc : 0xa0800000 - 0xff800000   (1520 MB)
lowmem  : 0x80000000 - 0xa0000000   ( 512 MB)
modules : 0x7f000000 - 0x80000000   (  16 MB)
.text : 0x(ptrval) - 0x(ptrval)   (7136 kB)
.init : 0x(ptrval) - 0x(ptrval)   (1024 kB)
.data : 0x(ptrval) - 0x(ptrval)   ( 401 kB)
.bss : 0x(ptrval) - 0x(ptrval)   ( 158 kB)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
rcu: Hierarchical RCU implementation.
rcu:    RCU event tracing is enabled.
rcu:    RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
GIC CPU mask not found - kernel will fail to boot.
GIC CPU mask not found - kernel will fail to boot.
L2C: platform modifies aux control register: 0x02020000 -> 0x02420000
L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 dynamic clock gating disabled, standby mode disabled
L2C-310 cache controller enabled, 8 ways, 128 kB
L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x46420001
sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
Failed to initialize '/smb@4000000/motherboard/iofpga@7,00000000/timer@12000': -22
smp_twd: clock not found -2
Console: colour dummy device 80x30
Calibrating local timer... 97.42MHz.
Calibrating delay loop... 910.13 BogoMIPS (lpj=4550656)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
CPU0: Spectre v2: using BPIALL workaround
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x60100000 - 0x60100060
rcu: Hierarchical SRCU implementation.
smp: Bringing up secondary CPUs ...
smp: Brought up 1 node, 1 CPU
SMP: Total of 1 processors activated (910.13 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 0
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 1024 (order: 4, 65536 bytes)
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
hw-breakpoint: debug architecture 0x4 unsupported.
Serial: AMBA PL011 UART driver
10009000.uart: ttyAMA0 at MMIO 0x10009000 (irq = 29, base_baud = 0) is a PL011 rev1
printk: console [ttyAMA0] enabled
1000a000.uart: ttyAMA1 at MMIO 0x1000a000 (irq = 30, base_baud = 0) is a PL011 rev1
1000b000.uart: ttyAMA2 at MMIO 0x1000b000 (irq = 31, base_baud = 0) is a PL011 rev1
1000c000.uart: ttyAMA3 at MMIO 0x1000c000 (irq = 32, base_baud = 0) is a PL011 rev1
OF: amba_device_add() failed (-19) for /smb@4000000/motherboard/iofpga@7,00000000/wdt@f000
OF: amba_device_add() failed (-19) for /memory-controller@100e0000
OF: amba_device_add() failed (-19) for /memory-controller@100e1000
OF: amba_device_add() failed (-19) for /watchdog@100e5000
irq: type mismatch, failed to map hwirq-75 for interrupt-controller@1e001000!
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource arm,sp804
NET: Registered protocol family 2
tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes)
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Unpacking initramfs...
Freeing initrd memory: 11232K
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 1 counters available
workingset: timestamp_bits=30 max_order=17 bucket_order=0
squashfs: version 4.0 (2009/01/31) Phillip Lougher
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
9p: Installing v9fs 9p2000 file system support
io scheduler noop registered (default)
io scheduler mq-deadline registered
io scheduler kyber registered
clcd-pl11x 1001f000.clcd: PL111 designer 41 rev2 at 0x1001f000
clcd-pl11x 1001f000.clcd: clcd@1f000 hardware, 640x480@59 display
Console: switching to colour frame buffer device 80x30
clcd-pl11x 10020000.clcd: PL111 designer 41 rev2 at 0x10020000
clcd-pl11x 10020000.clcd: clcd@10020000 hardware, 1024x768@59 display
40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
Concatenating MTD devices:
(0): "40000000.flash"
(1): "40000000.flash"
into device "40000000.flash"
libphy: Fixed MDIO Bus: probed
smsc911x 4e000000.ethernet: Linked as a consumer to regulator.1
smsc911x 4e000000.ethernet (unnamed net_device) (uninitialized): Device not READY in 100ms aborting
isp1760 4f000000.usb: bus width: 32, oc: digital
isp1760 4f000000.usb: NXP ISP1760 USB Host Controller
isp1760 4f000000.usb: new USB bus registered, assigned bus number 1
isp1760 4f000000.usb: Scratch test failed.
isp1760 4f000000.usb: can't setup: -19
isp1760 4f000000.usb: USB bus 1 deregistered
usbcore: registered new interface driver usb-storage
rtc-pl031 10017000.rtc: registered as rtc0
mmci-pl18x 10005000.mmci: Got CD GPIO
mmci-pl18x 10005000.mmci: Got WP GPIO
mmci-pl18x 10005000.mmci: Linked as a consumer to regulator.1
mmci-pl18x 10005000.mmci: mmc0: PL181 manf 41 rev0 at 0x10005000 irq 25,26 (pio)
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
aaci-pl041 10004000.aaci: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 24
aaci-pl041 10004000.aaci: FIFO 512 entries
oprofile: using arm/armv7-ca9
NET: Registered protocol family 17
9pnet: Installing 9P2000 support
Registering SWP/SWPB emulation handler
input: AT Raw Set 2 keyboard as /devices/platform/smb@4000000/smb@4000000:motherboard/smb@4000000:motherboard:iofpga@7,00000000/10006000.kmi/serio0/input/input0
rtc-pl031 10017000.rtc: setting system clock to 2019-09-08 02:11:22 UTC (1567908682)
Sending DHCP requests ., OK
IP-Config: Got DHCP answer from 192.168.160.2, my address is 192.168.160.9
IP-Config: Complete:
device=eth0, hwaddr=52:54:00:12:34:56, ipaddr=192.168.160.9, mask=255.255.255.0, gw=192.168.160.2
host=192.168.160.9, domain=, nis-domain=(none)
bootserver=192.168.160.2, rootserver=192.168.160.2, rootpath=
nameserver0=192.168.160.3
ALSA device list:
#0: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 24
Freeing unused kernel memory: 1024K
Run /init as init process
input: ImExPS/2 Generic Explorer Mouse as /devices/platform/smb@4000000/smb@4000000:motherboard/smb@4000000:motherboard:iofpga@7,00000000/10007000.kmi/serio1/input/input2
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Initializing random number generator... random: dd: uninitialized urandom read (512 bytes read)
done.
Starting network: ip: RTNETLINK answers: File exists
FAIL

在buildroot中,我已经为getty baudrate尝试了各种配置,但无济于事。到底出了什么问题?目前我已经尝试使用 vt100、内核选择波特率以及 vt100、115200,但它都失败了。

更新

到目前为止,我已经能够在对命令行参数稍作修改后看到登录提示,如下所示:

qemu-system-arm -M vexpress-a9 -m 512M 
-kernel linux-4.20.8/arch/arm/boot/zImage 
-dtb linux-4.20.8/arch/arm/boot/dts/vexpress-v2p-ca9.dtb
-append "console=ttyAMA0,115200 ip=dhcp" 
-initrd buildroot/output/images/rootfs.cpio 
-serial stdio <s>-nographic</s>
-netdev user,id=mynet0,net=192.168.160.0/24,hostfwd=tcp::2222-:22
-device virtio-net-device,netdev=mynet0

如您所见,我已将-nographic替换为-serial stdio,因此我现在单独看到 QEMU GUI 窗口(顺便说一下,它是空白的),并且我看到登录提示。W帽子在这里发生?

此外,我无法使用 ssh 从我的 Debian 主机登录虚拟机(ssh 已在构建根中选中,您可以从以下日志消息中看到(这些消息出现在我的最新修改后)

random: ssh-keygen: uninitialized urandom read (32 bytes read)
ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519
Starting sshd: random: sshd: uninitialized urandom read (32 bytes read)
OK
Welcome to Buildroot
buildroot login: root
Password:

我已通过修改 VM 上的sshd_config文件启用了根登录。我已经尝试了ssh root@localhost:2222ssh root@192.168.160.9但它只是消失了(没有说连接是否被拒绝或其他任何东西)。我在这里有点迷茫。

根据您在内核命令行 (rdinit) 上的说明,Linux 内核在引导后作为第一个用户进程运行/sbin/init。

通常配置了 Busybox(有几个选项)的那个将读取一个名为/etc/inittab 的配置文件,并根据那里编写的内容进行操作。

/etc/init.d/rcS 的执行(如果有的话)是从这个文件执行的。

很难确切地确定发生了什么,但在第一步中,看看/etc/inittab。它可能已经在挂载/proc。

至少我猜测有关/dev/ttyy 的错误源于此文件中的指令,可以通过编辑它来静音。

最新更新