[libvirt-users] Obtaining the PID of a domain's QEMU process from C

Shawn Anastasio shawn at anastas.io
Fri Mar 1 01:31:22 UTC 2019


Hello all,

I'm currently writing a C program that uses the libvirt API and I need a 
way to obtain the pid of a given domain's QEMU process.

Specifically, I'm writing an ivshmem server that uses SO_PEERCRED to get 
the pid of clients that connect to it, and I would like to use that pid 
to look up the domain in libvirt to determine the proper domain ID to 
return to the client.

As far as I can tell, libvirt doesn't expose this information in an easy 
to access manner. Of course it is possible to call `ps` and grep for the 
information I'm looking for, but I was hoping for a cleaner solution.

If anybody knows how to do this, advice would be greatly appreciated.

Thanks in advance,
Shawn




More information about the libvirt-users mailing list