- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在写一个关于 qemu 内部的开源文档,所以如果你帮助我,你就是在帮助 Qemu 项目的发展
我找到的最接近的答案是:In which conditions the ioctl KVM_RUN returns?
这是在 KVM 上运行的单个 CPU 的线程循环:
static void *qemu_kvm_cpu_thread_fn(void *arg)
{
CPUState *cpu = arg;
int r;
rcu_register_thread();
qemu_mutex_lock_iothread();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
cpu->can_do_io = 1;
current_cpu = cpu;
r = kvm_init_vcpu(cpu);
if (r < 0) {
error_report("kvm_init_vcpu failed: %s", strerror(-r));
exit(1);
}
kvm_init_cpu_signals(cpu);
/* signal CPU creation */
cpu->created = true;
qemu_cond_signal(&qemu_cpu_cond);
qemu_guest_random_seed_thread_part2(cpu->random_seed);
do {
if (cpu_can_run(cpu)) {
r = kvm_cpu_exec(cpu);
if (r == EXCP_DEBUG) {
cpu_handle_guest_debug(cpu);
}
}
qemu_wait_io_event(cpu);
} while (!cpu->unplug || cpu_can_run(cpu));
qemu_kvm_destroy_vcpu(cpu);
cpu->created = false;
qemu_cond_signal(&qemu_cpu_cond);
qemu_mutex_unlock_iothread();
rcu_unregister_thread();
return NULL;
}
你可以在这里看到:
do {
if (cpu_can_run(cpu)) {
r = kvm_cpu_exec(cpu);
if (r == EXCP_DEBUG) {
cpu_handle_guest_debug(cpu);
}
}
qemu_wait_io_event(cpu);
} while (!cpu->unplug || cpu_can_run(cpu));
每次 KVM 返回时,它都为 Qemu 提供了模拟事物的机会。我想当 guest 上的内核尝试访问 PCIe 设备时,主机上的 KVM 会返回。不知道KVM怎么知道怎么返回。也许 KVM 维护了 PCIe 设备的地址,并告诉 Intel 的 VT-D 或 AMD 的 IOV 哪些地址应该产生异常。有人可以澄清这一点吗?
qemu_kvm_cpu_thread_fn
的外观来看,唯一可以模拟 PCIe 访问的地方是
qemu_wait_io_event(cpu)
,这里定义:
https://github.com/qemu/qemu/blob/stable-4.2/cpus.c#L1266并调用
qemu_wait_io_event_common
此处定义:
https://github.com/qemu/qemu/blob/stable-4.2/cpus.c#L1241其中调用
process_queued_cpu_work
此处定义:
https://github.com/qemu/qemu/blob/stable-4.2/cpus-common.c#L309
while (cpu->queued_work_first != NULL) {
wi = cpu->queued_work_first;
cpu->queued_work_first = wi->next;
if (!cpu->queued_work_first) {
cpu->queued_work_last = NULL;
}
qemu_mutex_unlock(&cpu->work_mutex);
if (wi->exclusive) {
/* Running work items outside the BQL avoids the following deadlock:
* 1) start_exclusive() is called with the BQL taken while another
* CPU is running; 2) cpu_exec in the other CPU tries to takes the
* BQL, so it goes to sleep; start_exclusive() is sleeping too, so
* neither CPU can proceed.
*/
qemu_mutex_unlock_iothread();
start_exclusive();
wi->func(cpu, wi->data);
看起来VCPU线程唯一的动力
qemu_kvm_cpu_thread_fn
has 当 KVM 返回时,就是执行排队的函数:
wi->func(cpu, wi->data);
这意味着 PCIe 设备必须不断地将自身排队作为 qemu 执行的功能。我不明白它会如何运作。
run_on_cpu
在它的名字上。通过在 VSCode 上搜索,我发现了一些排队工作但与 PCIe 甚至仿真无关的函数。我发现最好的功能是这个显然修补指令的功能:
https://github.com/qemu/qemu/blob/stable-4.2/hw/i386/kvmvapic.c#L446 .不错,我也想知道。
最佳答案
KVM 下的设备仿真(所有设备,不仅仅是 PCI)由“case KVM_EXIT_IO”(对于 x86 风格的 IO 端口)和“case KVM_EXIT_MMIO”(对于包括 PCI 的内存映射 IO)在“开关(运行-> exit_reason)”在 kvm_cpu_exec() 中。 qemu_wait_io_event() 无关。
想知道执行如何“模拟在 PCI 设备上读取的寄存器”?在 gdb 下运行 QEMU,在您使用的以太网 PCI 卡的寄存器读/写功能上设置断点,然后当您进入调试器时查看堆栈回溯。 (编译 QEMU --enable-debug 以获得更好的调试信息。)
PS:如果您出于教育目的检查 QEMU 内部结构,最好使用当前代码,而不是它的一年前版本。
关于c - Qemu 如何模拟 PCIe 设备?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65246928/
我正在为 aarch64 使用 qemu 模拟器,并且想要创建一个外部检查点(或快速转发)以保存我需要从创建检查点时重新启动系统的所有内容。 (其实我是想跳过开机这一步)我只在qemu VM快照和快进
我想了解这两个包之间的关系,因为更改“qemu”的源 uri 似乎会导致 qemu-native 的构建损坏。 我不是 Yocot/Bitbake 专家,所以稍微澄清一下会大有帮助。 谢谢。 最佳答案
如何写入在 QEMU 中运行的虚拟系统的处理器寄存器和特定内存地址? 我的愿望是通过在 QEMU 之外运行的用户空间程序来完成此操作。这将引起中断并精细地控制处理器和虚拟硬件的执行。 QEMU Mon
我有一个表单,用户可以在其中上传图像(不同操作系统的图像)。 如何检测图像是否为“qcow2”类型的 QEMU 图像? 最佳答案 您可以使用 qemu-img info检查图像格式。 qemu-img
我想知道是否可以编写 qemu 脚本,以便您可以启动它并自动让它在 guest 操作系统中运行程序?就我而言,那就是 Linux。基本上,我想避免与客人互动,以便我可以用秃鹰或类似的东西进行一批实验。
我想到了两种可能的机制: IPC 类似于现有的 QMP 和 QAPI QEMU 加载一个包含模型 的共享库插件 所需的能力(当然所有可能通过 C API,但不一定是 IPC API): 注入(inje
是否有选项? qemu-nbd 命令获得下一个空闲,即未使用的 NBD,如 lossup -f 做? 0.0.1 的联机帮助页(这是 qemu 当前稳定版 1.7.0 的版本)没有提及任何内容。 最佳
qemu-system-armw.exe 和 qemu-system-arm.exe 有什么区别?我在任何地方都找不到它。 最佳答案 带有 w 的可执行文件不会打开控制台窗口,而没有 w 的可执行文件
我正在尝试了解 QEMU 的区 block 链。我对每个执行的 TB 的分支方向有疑问。假设 TB#1 现在已经执行,并找到 next_tb (TB#2)。然后我们知道方向是 TB#1--->TB#2
我有一个使用 KVM 的 Windows 10 专业版虚拟机。它是通过 virt-manager 使用最新版本的 libvirt 和 QEMU 设置的。所有这些都在 Manjaro Linux 20
我开始学习 riscv。我得到了 qemu-riscv、riscv-gcc 并编译了下一个 hello world asm 程序: .section .text .globl _start _star
我有一个运行 kvm/qemu 的 Windows VM,它正在经历时间漂移。Windows 客户机的最佳 libvirt 设置是什么? 目前我正在使用这个,但它没有帮助:
我有一个运行 kvm/qemu 的 Windows VM,它正在经历时间漂移。Windows 客户机的最佳 libvirt 设置是什么? 目前我正在使用这个,但它没有帮助:
我是 qemu 开发新手。我正在尝试修改 qemu 以使用 QEMU 模拟器在 x86 机器上模拟 SGX 处理器的某些功能。这是我想要做的。 我想将以下内容添加到 qemu。我想用一个新参数 EEC
我目前正在尝试构建一个配置来测试 Big-Endian 系统上的一些代码。 通过聊天和研究,我确信这些测试的一个很好的目标是 PowerPC 架构。由于我没有一个,并且不希望在短期内直接访问一个,我正
我正在制作一个操作系统,我正在使用 Qemu 调试它。我想要一种方法来在一些指令的末尾读取一些大块的 ram。怎么做?可以对 Qemu 说将 ram 复制到文件中吗?如果不是我能做什么? 最佳答案 q
qemu/kvm 支持 ovf 吗?它能够启动现有的 ovf 软件包吗?我在 ovf 标准和 qemu/kvm 网站上找不到任何相关信息。对此有任何有用的链接吗?谢谢。 最佳答案 您正在寻找virt-
我想知道如何从 ubuntu 中的源代码构建 grub 2 引导加载程序并使用 qemu 模拟器对其进行测试。 我还想在新版本中更改 grub2 引导加载程序的默认背景图像吗? 这可能吗?如果是,怎么
我的环境是Ubuntu15.10。我写了下面的源代码。 #include "efi.h" #include "efilib.h" EFI_STATUS EFIAPI efi_main(EFI_HAND
我正在尝试使用 qemu 调试 linux 内核的启动顺序,我正在运行的命令是: qemu -serial stdio -kernel -hda -append "root=/dev/sda
我是一名优秀的程序员,十分优秀!