2015-12-18 65 views
0

有誰知道,在哪裏vcpu線程ID存儲在linux中?實際上,根據我在KVM中創建虛擬機的研究,一些線程將形成vcpus;我需要他們的ID和位置。 我看了看這個位置:虛擬CPU在KVM中

的/ proc/qemu-kvm process ID /任務/ */

qemu-kvm process ID場來源於此位置: /var/run/libvirt/qemu/VM_NAME.xml

因爲我認爲可能在那裏找到vcpu的ID,但不幸的是,它們不是vcpu的ID,它們只是一些子進程。

任何幫助,將不勝感激。 非常感謝。

回答

0

如果EXEC QEMU與參數-qmp UNIX:./ QMP-襪子,服務器,NOWAIT,例如:

# /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 

你可以Exec的QMP殼獲得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

0

我認爲虛擬CPU線程ID是內部的Qemu,並暴露在Linux作爲一個正常的線程

struct CPUState { 
... 
struct QemuThread *thread; 
... 
int thread_id; 
... 
bool thread_kicked; 
... 
bool throttle_thread_scheduled; 
... 
}; 

可以使用的Qemu命令info cpus顯示有關CPU的信息。它給了我這樣的:

(qemu) info cpus 
* CPU #0: pc=0x00000000b483c8c4 thread_id=6660 
+0

謝謝Yachine,我有一個Q,其中這些代碼行來自您的上述答案?進一步'(qemu)info cpus'在我的系統中不起作用。你知道什麼可能出錯嗎? – sami