Thibaut SAUTEREAU
2017-Mar-20 13:11 UTC
[libvirt-users] Get PID of a domain's QEMU instance from its domain ID
Hello, I cannot find a way to retrieve PIDs of QEMU instances from libvirt domains' IDs (I'm using libvirt C API). I recognize it sounds like a bad idea doing so (and I know PIDs are explicitly made not available, as I gathered from the source code and on your IRC channel) but I need that to use the perf_event_open syscall in order to gather statistics on my QEMU/KVM guests. I also know libvirt now supports some perf events but only a few and I need more. I could submit patches to add them and I will definitely consider that but in the meantime... What would be the best way to get those PIDs? I tried using the XML file but PID is hidden in there too. I took a look at QEMU Machine Protocol. Now I'm going to walk /proc and match on guests names but it is not that elegant. Any ideas? Thanks, Thibaut S.
Martin Kletzander
2017-Mar-21 11:06 UTC
Re: [libvirt-users] Get PID of a domain's QEMU instance from its domain ID
On Mon, Mar 20, 2017 at 02:11:21PM +0100, Thibaut SAUTEREAU wrote:>Hello, > >I cannot find a way to retrieve PIDs of QEMU instances from libvirt domains' >IDs (I'm using libvirt C API). I recognize it sounds like a bad idea doing so >(and I know PIDs are explicitly made not available, as I gathered from the >source code and on your IRC channel) but I need that to use the perf_event_open >syscall in order to gather statistics on my QEMU/KVM guests. I also know >libvirt now supports some perf events but only a few and I need more. I could >submit patches to add them and I will definitely consider that but in the >meantime... > >What would be the best way to get those PIDs? I tried using the XML file but >PID is hidden in there too. I took a look at QEMU Machine Protocol. Now I'm >going to walk /proc and match on guests names but it is not that elegant. >Any ideas? >`ps aux | grep $UUID | grep -v grep` ??>Thanks, > >Thibaut S. > >_______________________________________________ >libvirt-users mailing list >libvirt-users@redhat.com >https://www.redhat.com/mailman/listinfo/libvirt-users
Peter Krempa
2017-Mar-21 11:50 UTC
Re: [libvirt-users] Get PID of a domain's QEMU instance from its domain ID
On Tue, Mar 21, 2017 at 12:06:25 +0100, Martin Kletzander wrote:> On Mon, Mar 20, 2017 at 02:11:21PM +0100, Thibaut SAUTEREAU wrote: > > Hello, > > > > I cannot find a way to retrieve PIDs of QEMU instances from libvirt domains' > > IDs (I'm using libvirt C API). I recognize it sounds like a bad idea doing so > > (and I know PIDs are explicitly made not available, as I gathered from the > > source code and on your IRC channel) but I need that to use the perf_event_open > > syscall in order to gather statistics on my QEMU/KVM guests. I also know > > libvirt now supports some perf events but only a few and I need more. I could > > submit patches to add them and I will definitely consider that but in the > > meantime...Looks like you are looking for: http://libvirt.org/formatdomain.html#elementsPerf and http://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetPerfEvents> > > > What would be the best way to get those PIDs? I tried using the XML file but > > PID is hidden in there too. I took a look at QEMU Machine Protocol. Now I'm > > going to walk /proc and match on guests names but it is not that elegant. > > Any ideas?Just to re-iterate. We hide it because users should not fiddle with the VMs behind our backs.> > > > `ps aux | grep $UUID | grep -v grep` ??This will obviously work, but we won't give you an elegant way since we don't want you to know the pid.
Reasonably Related Threads
- Re: Get PID of a domain's QEMU instance from its domain ID
- Re: Get PID of a domain's QEMU instance from its domain ID
- Re: Obtaining the PID of a domain's QEMU process from C
- Re: Obtaining the PID of a domain's QEMU process from C
- Re: Obtaining the PID of a domain's QEMU process from C