KVM 中的虚拟 CPU
virtual CPU in KVM
有人知道 vcpu 线程 ID 存储在 linux 中的什么地方吗?事实上,根据我的研究,当我们在 KVM 中创建一个 VM 时,一些线程会形成 vcpus;我需要他们的 ID 和位置。
我看了一下这个位置:
/proc/qemu-kvm process ID
/tasks/*/
qemu-kvm process ID
字段来自此位置:
/var/run/libvirt/qemu/VM_NAME.xml
因为我认为也许可以在那里找到 vcpu 的 ID,但不幸的是它们不是 vcpu 的 ID,它们只是一些子进程。
如有任何帮助,我们将不胜感激。
非常感谢。
我认为 vcpu 线程 ID 是 Qemu 内部的,它作为普通线程暴露给 linux
struct CPUState {
...
struct QemuThread *thread;
...
int thread_id;
...
bool thread_kicked;
...
bool throttle_thread_scheduled;
...
};
您可以使用 Qemu 命令 info cpus
来显示有关 cpus 的信息。它给了我这个:
(qemu) info cpus
* CPU #0: pc=0x00000000b483c8c4 thread_id=6660
如果你用参数 -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
有人知道 vcpu 线程 ID 存储在 linux 中的什么地方吗?事实上,根据我的研究,当我们在 KVM 中创建一个 VM 时,一些线程会形成 vcpus;我需要他们的 ID 和位置。 我看了一下这个位置:
/proc/qemu-kvm process ID
/tasks/*/
qemu-kvm process ID
字段来自此位置:
/var/run/libvirt/qemu/VM_NAME.xml
因为我认为也许可以在那里找到 vcpu 的 ID,但不幸的是它们不是 vcpu 的 ID,它们只是一些子进程。
如有任何帮助,我们将不胜感激。 非常感谢。
我认为 vcpu 线程 ID 是 Qemu 内部的,它作为普通线程暴露给 linux
struct CPUState {
...
struct QemuThread *thread;
...
int thread_id;
...
bool thread_kicked;
...
bool throttle_thread_scheduled;
...
};
您可以使用 Qemu 命令 info cpus
来显示有关 cpus 的信息。它给了我这个:
(qemu) info cpus
* CPU #0: pc=0x00000000b483c8c4 thread_id=6660
如果你用参数 -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