how to get vm uptime through libvirt api

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


>
> On Tue, Jul 26, 2022 at 10:27:19AM +0200, Michal Prívozník wrote:
> > On 7/26/22 10:07, Jiatong Shen wrote:
> > > 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?
> >
> > Unfortunately, no. We specifically try to avoid telling users this
> > information so that they are not tempted to go behind libvirt's back and
> > interact with QEMU directly (which can lead to a split brain scenario -
> > libvirt thinks guest is in a certain state, but in fact it's in a
> > different state).
> >
> > But as I said, it should be fairly easy to extend stats to report when a
> > domain was started. If you don't feel comfortable providing a patch for
> > that I can try.
>
> Note, the time since a guest was started on the host is NOT the same as
> guest uptime. Guest uptime resets on every warm reboot the guest OS
> does, while QEMU stays running.
>

thank you very much for the reminder.

Best,
Norman

On Tue, Jul 26, 2022 at 4:31 PM Daniel P. Berrangé <berrange at redhat.com>
wrote:

> On Tue, Jul 26, 2022 at 10:27:19AM +0200, Michal Prívozník wrote:
> > On 7/26/22 10:07, Jiatong Shen wrote:
> > > 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?
> >
> > Unfortunately, no. We specifically try to avoid telling users this
> > information so that they are not tempted to go behind libvirt's back and
> > interact with QEMU directly (which can lead to a split brain scenario -
> > libvirt thinks guest is in a certain state, but in fact it's in a
> > different state).
> >
> > But as I said, it should be fairly easy to extend stats to report when a
> > domain was started. If you don't feel comfortable providing a patch for
> > that I can try.
>
> Note, the time since a guest was started on the host is NOT the same as
> guest uptime. Guest uptime resets on every warm reboot the guest OS
> does, while QEMU stays running.
>
> With regards,
> Daniel
> --
> |: https://berrange.com      -o-
> https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-
> https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-
> https://www.instagram.com/dberrange :|
>
>

-- 

Best Regards,

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


More information about the libvirt-users mailing list