linux - KVM 中的虚拟 CPU

标签 linux kvm

有人知道,vcpu 线程 id 在 linux 中存储在哪里吗?事实上,根据我的研究,当我们在 KVM 中创建一个 VM 时,一些线程会形成 vcpus;我需要他们的 ID 和位置。 我看了一下这个位置:

/proc/qemu-kvm进程ID/tasks/*/

qemu-kvm 进程 ID 字段来自此位置: /var/run/libvirt/qemu/VM_NAME.xml

因为我认为也许可以在那里找到 vcpu 的 ID,但不幸的是它们不是 vcpu 的 ID,它们只是一些子进程。

如有任何帮助,我们将不胜感激。 非常感谢。

最佳答案

如果您使用参数 -qmp unix:./qmp-sock,server,nowait 执行 qemu,例如:

# /opt/qemu/bin/qemu-system-x86_64 \
    -smp cpus=2 \
    -drive file=/opt/test.qcow2,format=qcow2 \
    -cdrom CentOS-7-x86_64-DVD-1511.iso \
    -qmp unix:./qmp-sock,server,nowait 

您可以执行 qmp-shell 来获取 cpu 信息:

# /opt/git/qemu/scripts/qmp/qmp-shell /opt/qmp-sock   
Welcome to the QMP low-level shell!
Connected to QEMU 2.5.50

(QEMU) query-cpus
{"return": [{"halted": false, "pc": -2124176787, "current": true, "qom_path": "/machine/unattached/device[0]", "thread_id": 2344, "arch": "x86", "CPU": 0}, {"halted": true, "pc": -2130342250, "current": false, "qom_path": "/machine/unattached/device[3]", "thread_id": 2341, "arch": "x86", "CPU": 1}]}

此处的线程 ID:2344 和 2341

# ps -eLf|grep qemu-system
root      2341  2252  2341  9    4 08:52 pts/0    00:00:48 /opt/qemu/bin/qemu-system-x86_64 -smp cpus=2 -drive file=/opt/test.qcow2,format=qcow2 -cdrom CentOS-7-x86_64-DVD-1511.iso -qmp unix:./qmp-sock,server,nowait
root      2341  2252  2342  0    4 08:52 pts/0    00:00:00 /opt/qemu/bin/qemu-system-x86_64 -smp cpus=2 -drive file=/opt/test.qcow2,format=qcow2 -cdrom CentOS-7-x86_64-DVD-1511.iso -qmp unix:./qmp-sock,server,nowait
root      2341  2252  2344 85    4 08:52 pts/0    00:07:04 /opt/qemu/bin/qemu-system-x86_64 -smp cpus=2 -drive file=/opt/test.qcow2,format=qcow2 -cdrom CentOS-7-x86_64-DVD-1511.iso -qmp unix:./qmp-sock,server,nowait
root      2341  2252  2345  0    4 08:52 pts/0    00:00:00 /opt/qemu/bin/qemu-system-x86_64 -smp cpus=2 -drive file=/opt/test.qcow2,format=qcow2 -cdrom CentOS-7-x86_64-DVD-1511.iso -qmp unix:./qmp-sock,server,nowait
root      2378  2304  2378  0    1 09:01 pts/2    00:00:00 grep --color=auto qemu-system

有关详细信息,请参阅 http://wiki.qemu.org/QMP

关于linux - KVM 中的虚拟 CPU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34351555/

相关文章:

qemu+pulseaudio 音质很差

virtualization - kvm的hypercall怎么用?

c - kvm:模块验证失败:缺少签名和/或所需的 key - 污染内核

ubuntu - 性能 kvm 报告未知

openstack - openstack实例运行时间长了会不会变慢

json - 使用具有不同键的 jq 将 json 转换为 csv

Python LDAP - 将用户移动到不同的 OU

linux - 将缓冲区或 C 字符串复制到 std::string 的最快方法

C++在linux平台运行时加载共享库和提取类实现

c++ - 是否可以为同时使用 Windows 和 Linux 的客户端使用相同的 DLL