
在 2012年4月11日 下午7:22,Richard W.M. Jones <rjones@redhat.com> 写道:
On Wed, Apr 11, 2012 at 12:01:55PM +0100, Daniel P. Berrange wrote:
On Wed, Apr 11, 2012 at 06:41:34PM +0800, Zhihua Che wrote:
BTW, Does libvirt supply any function which can return the process identifier of the domain?
No, we don't consider the PID of the QEMU process to be part of the public API, since that is a hypervisor specific implementation detail. Why do you want to know that ? Maybe there is some API you can use to get do the same thing
I agree with Dan that you're probably doing it for the wrong reasons and shouldn't need to know the PID.
Nevertheless, it's pretty simple to map a running domain name to a qemu PID, by parsing the '-name' parameter from the process list. eg the following works for simple names (no spaces, metachars etc):
$ sudo virsh list --all Id Name State ---------------------------------- 2 builder-rhel6 running
$ ps ax | grep '[-]name builder-rhel6' | awk '{print $1}' 2311
Rich.
Hi, I guess I miss another thing. I thought the domain xml config file was stored in etc/libvirt/qemu/ directory. But I did a interesting experiment. I edited a xml config file ubuntu-1.xml in the above directory. After defining the domain, I removed the domain's xml config file and found that it could still be started by 'start ubuntu-1'. I guess the action 'define' would parse the original config file and store it in another 'safe' place. What's this place? I wish I could handle some emergence in case if I knew this place.