how to get vm uptime through libvirt api

Jiatong Shen yshxxsjt715 at gmail.com
Tue Jul 26 08:07:16 UTC 2022


thank you very much for reply. I have got another question which is off
topic.
Am I able to get vm's process id through libvirt api?

Thank you very much.

Best,
Norman

On Tue, Jul 26, 2022 at 4:04 PM Michal Prívozník <mprivozn at redhat.com>
wrote:

> On 7/26/22 09:48, Jiatong Shen wrote:
> > Thank you very much for reply. Initially my thought of uptime is equal
> > to executing to `uptime` inside a virtual machine.
> > as for the second case, where virtual machine is paused for a period,
> > does libvirt expose an api to get how long qemu process
> > has existed?
>
> No, it doesn't. But that should be pretty easy to implement into
> virDomainListGetStats()/virConnectGetAllDomainStats().
> Alternatively, libvirt emits an event when a domain is started, so you
> may use that to record the time when the domain was started.
>
> Michal
>
>

-- 

Best Regards,

Jiatong Shen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20220726/714afbe8/attachment-0001.htm>


More information about the libvirt-users mailing list