标签: qemu

为了了解 QEMU 如何模拟支持的网络设备,我需要阅读/分析什么?

我想分析一下QEMU如何模拟支持的网络设备读取源代码。另外我想与我分享一下您对理解 QEMU 源代码需要什么背景的看法。请向我推荐一些围绕主题的好书或在线资源,为了实现这一目标,人们必须学习这些主题(我想需要设备驱动程序、处理器规范等?)。另外,如果你能告诉我用 C 语言应该达到的编程水平(因为源代码是用 C 语言编写的),那就太好了。

我已经浏览过 QEMU 的网站,其中提供的内容主要涉及如何使用 QEMU 和配置它。

qemu device processors device-emulation

1
推荐指数
1
解决办法
1638
查看次数

qemu-kvm 如何与 kvm 模块交互?

我正在尝试阅读 qemu-kvm 和 kvm 模块,但很难理解以下内容:

How does qemu-kvm interact with kvm kernel module?
Run Code Online (Sandbox Code Playgroud)

任何解释或指示将不胜感激。

kvm qemu

1
推荐指数
1
解决办法
646
查看次数

将 KVM XML 导入 Qemu

如果我qemu-system-x86_64 ~/Whonix-Gateway-11.0.0.3.0.qcow2 可以不联网启动机器,看到目录下有.xml文件

  <domain type='kvm'>
  <name>Debian</name>
  <description></description>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='static'>2</vcpu>
  ....
Run Code Online (Sandbox Code Playgroud)

我怎样才能导入它?

linux macos kvm qemu

1
推荐指数
1
解决办法
2万
查看次数

文本模式光标未出现在 qemu vga 模拟器中

我在文本模式下更新光标位置的函数有问题,函数定义和声明是

#include <sys/io.h>
signed int VGAx = 0,VGAy=0;
void setcursor()
{
        uint16_t position = VGAx+VGAy*COLS;
        outb(0x0f, 0x03d4);
        outb((position<<8)>>8,0x03d5);
        outb(0x0e,0x03d4);
        outb(position>>8,0x03d5);
}
Run Code Online (Sandbox Code Playgroud)

和文件 sys/io.h

static inline unsigned char inb (unsigned short int port)
{
        unsigned char value;
        asm ("inb %0, %%al":"=rm"(value):"a"(port));
        return value;
}
static inline void outb(unsigned char value, unsigned short int port)
{
        asm volatile ("outb %%al, $0"::"rm"(value), "a"(port));
}
Run Code Online (Sandbox Code Playgroud)

使用该功能前光标有时闪烁下划线有时不出现而使用该功能后没有光标出现

这是运行的主要功能

#include <vga/vga.h>
int kmain(){
        setcursor()
        setbgcolor(BLACK);
        clc();
        setforecolor(BLUE);
        terminal_write('h');
        setcursor();
        return 0;
}
Run Code Online (Sandbox Code Playgroud)

我尝试使用此功能

void enable_cursor() { …
Run Code Online (Sandbox Code Playgroud)

x86 gcc qemu inline-assembly osdev

1
推荐指数
1
解决办法
1220
查看次数

如何下载 Torvalds Linux Kernel master、(重新)编译它并使用 QEMU 启动它?

几天来,我正在研究一个小项目,以探索内核编程。然而,我在网上看了很多关于内核编译的问题,并在之前问过一个问题,但我在某些时候仍然感到迷茫。

如果我需要进行一些内核编程,我认为使用 Linus Torvalds 的 Linux 源代码将是最好的起点。所以我做了以下操作(来自 MacOS High Sierra)

  • 下载内核源代码:https://github.com/torvalds/linux
  • 解压它
  • 启动终端并运行:
    • vagrant init
    • vagrant up
    • vagrant ssh
  • 连接后,我输入:
    • cd /vagrant/linux 为了进入Linux源解压文件夹
    • make menuconfig 我只是按了确定/保存
    • sudo make -j 4 && sudo make modules_install -j 4 && sudo make install -j 4

现在,我遇到了一个小错误:

agrant @vagrant-ubuntu-trusty-64:/vagrant/Kernel-Programming/linx-kernel$ sudo make -j 4 && sudo make modules_install -j 4 && sudo make install -j 4
  CHK include/config/kernel.release
CHK     include/generated/uapi/linux/version.h
CHK     include/generated/utsrelease.h
CHK     scripts/mod/devicetable-offsets.h
CHK     include/generated/timeconst.h
CHK     include/generated/bounds.h
CHK     include/generated/asm-offsets.h
CALL    scripts/checksyscalls.sh …
Run Code Online (Sandbox Code Playgroud)

linux qemu linux-kernel macos-high-sierra

1
推荐指数
1
解决办法
5152
查看次数

如何修复“qemu:致命:尝试在 0x000a0000 处的 RAM 或 ROM 之外执行代码”

我正在开发自己的引导加载程序 + 内核。我创建了一个项目放在github上:https : //github.com/rprata/ubootlua(分支tmp-libc-implementation)

我尝试使用 QEMU 运行我的 boot.bin:

qemu-system-i386 -fda boot.bin -nographic -serial stdio -monitor none

但是会发生崩溃:

> qemu-system-i386 -fda ./deploy/boot.bin -nographic -serial stdio -monitor none
> WARNING: Image format was not specified for './deploy/boot.bin' and probing guessed raw.
>         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
>         Specify the 'raw' format explicitly to remove the restrictions.
> qemu: fatal: Trying to execute code outside RAM or …
Run Code Online (Sandbox Code Playgroud)

x86 assembly qemu osdev bootloader

1
推荐指数
1
解决办法
1737
查看次数

为 ARM 交叉编译的 Hello world 可在 x86_64 和 ARM 上运行

我正在准备演示 Qemu 的用户模式(qemu-user 包)qemu-arm。为此,我使用了一个简单的 hello world C 程序hello.c

#include <stdio.h>

int main()
{
        printf("Oi, Qemu!\nPrograma C aqui!\n");
}

Run Code Online (Sandbox Code Playgroud)

为了交叉编译它(静态链接),我使用了以下的交叉工具链gcc-arm-linux-gnueabihf

$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Ubuntu 9.3.0-10ubuntu1) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ arm-linux-gnueabihf-gcc hello.c -o hello_c_static -static
Run Code Online (Sandbox Code Playgroud)

输出在 qemu-arm、Beaglebone Black和 PC 上运行。

这怎么可能?!

编辑

关于编译后的可执行文件:

file hello_c_static 
hello_c_static: …
Run Code Online (Sandbox Code Playgroud)

linux x86 arm qemu cross-compiling

1
推荐指数
1
解决办法
847
查看次数

带有网络和 virtio 支持的用于 raspberry pi 3 的 QEMU 内核

我使用 QEMU(qemu-system-aarch64 -M raspi3) 从工作映像中模拟带有内核的 Raspberry pi3。一切正常,但没有网络。

qemu-system-aarch64 \
   -kernel ./bootpart/kernel8.img \
   -initrd ./bootpart/initrd.img-4.14.0-3-arm64 \
   -dtb ./debian_bootpart/bcm2837-rpi-3-b.dtb \
   -M raspi3 -m 1024 \
   -nographic \
   -serial mon:stdio \
   -append "rw earlycon=pl011,0x3f201000 console=ttyAMA0 loglevel=8 root=/dev/mmcblk0p3 fsck.repair=yes net.ifnames=0 rootwait memtest=1" \
   -drive file=./genpi64lite.img,format=raw,if=sd,id=hd-root \
   -no-reboot
Run Code Online (Sandbox Code Playgroud)

我试图添加这个选项

-device virtio-blk-device,drive=hd-root \
-netdev user,id=net0,hostfwd=tcp::5555-:22 \
-device virtio-net-device,netdev=net0 \
Run Code Online (Sandbox Code Playgroud)

但是会有错误

qemu-system-aarch64: -device virtio-blk-device,drive=hd-root: 没有找到设备“virtio-blk-device”的“virtio-bus”总线 我参考了一些论坛,并使用了“virt”机器代替 raspi3 以模拟 virtio-network

qemu-system-aarch64 \
  -kernel ./bootpart/kernel8.img \
  -initrd ./bootpart/initrd.img-4.14.0-3-arm64 \
  -m 2048 \
  -M virt \
  -cpu cortex-a53 \
  -smp …
Run Code Online (Sandbox Code Playgroud)

virtualization kernel qemu linux-kernel raspberry-pi3

1
推荐指数
3
解决办法
4006
查看次数

如何使用 qemu 对算法进行分析

我现在有一个程序在 Ubuntu 上运行良好。该程序纯用C语言编写,最终将在嵌入式处理器上运行。我希望知道它在不同目标上的执行速度,例如Cortex M3、M4或A系列。由于double类型的算术非常多,所以区别应该很明显。目前,我的想法是使用 qemu 来统计对某些数据集执行的指令。由于该程序仅涉及数据处理,因此唯一需要的资源应该是 RAM。

我不需要非常准确的结果,因为它只能作为选择CPU的指导。有一些简单的任务指南吗?我对 qemu 的经验很少。我看到有两种调用 qemu 的方法:qemu-system-arm 和 qemu-user。我想最准确的模拟结果应该是qemu-system-arm。更何况Cortex M系列应该因为缺少MMU而不支持Linux吧?

c qemu

1
推荐指数
1
解决办法
1247
查看次数

在"Raspberry Pi"的QEMU仿真上设置Jenkins CI服务器(Windows)

  1. 如何使用QEMU设置Raspberry'VM'
  2. 设置Jenkins以使用新的Oracle Java 7运行

java qemu raspberry-pi raspbian

0
推荐指数
1
解决办法
1574
查看次数