[libvirt-users] [API reference] Are there XML-handling API to retrieve info directly from xml configure file

Richard W.M. Jones rjones at redhat.com
Wed Apr 11 11:22:22 UTC 2012


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.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw




More information about the libvirt-users mailing list