有人知道,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/