Re: Distinguishing between host and guest initiated VM shutdown

2020-08-27 Thread Milan Zamazal
Daniel P. Berrangé  writes:

> On Thu, Aug 27, 2020 at 10:06:25AM +0200, Milan Zamazal wrote:
>> "Daniel P. Berrange"  writes:
>> 
>
>> > On Wed, Aug 26, 2020 at 10:35:22PM +0200, Milan Zamazal wrote:
>> >> Hi,
>> >> 
>> >
>> >> we have a problem in oVirt that highly available VMs don't restart after
>> >> host poweroff because Vdsm identifies the case as a user initiated
>> >> shutdown (https://bugzilla.redhat.com/1800966).
>> >> 
>> >> When poweroff is run on the host, libvirt-guests service takes an
>> >> action.
>> >
>> > If oVirt is initiating a graceful host shutdown, 
>> 
>> I meant host shutdown not initiated by oVirt.
>
> Well oVirt still knows at any point in time what VMs are currently
> running on a host, so if it sees the host shutdown, it already
> knows that needs restarting.

libvirt-guests ensures graceful shutdown of the VMs (which is a good
thing) so at the moment when the host gets down, there are no VMs
running there.  We need that info at the moment when a VM is shut down
and I think we can get it by examining some systemd service (if ignoring
some not so important timing issues).

Regards,
Milan




Re: Distinguishing between host and guest initiated VM shutdown

2020-08-27 Thread Daniel P . Berrangé
On Thu, Aug 27, 2020 at 10:06:25AM +0200, Milan Zamazal wrote:
> "Daniel P. Berrange"  writes:
> 
> > On Wed, Aug 26, 2020 at 10:35:22PM +0200, Milan Zamazal wrote:
> >> Hi,
> >> 
> >
> >> we have a problem in oVirt that highly available VMs don't restart after
> >> host poweroff because Vdsm identifies the case as a user initiated
> >> shutdown (https://bugzilla.redhat.com/1800966).
> >> 
> >> When poweroff is run on the host, libvirt-guests service takes an
> >> action.
> >
> > If oVirt is initiating a graceful host shutdown, 
> 
> I meant host shutdown not initiated by oVirt.

Well oVirt still knows at any point in time what VMs are currently
running on a host, so if it sees the host shutdown, it already
knows that needs restarting.


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 :|



Re: Distinguishing between host and guest initiated VM shutdown

2020-08-27 Thread Milan Zamazal
"Daniel P. Berrange"  writes:

> On Wed, Aug 26, 2020 at 10:35:22PM +0200, Milan Zamazal wrote:
>> Hi,
>> 
>
>> we have a problem in oVirt that highly available VMs don't restart after
>> host poweroff because Vdsm identifies the case as a user initiated
>> shutdown (https://bugzilla.redhat.com/1800966).
>> 
>> When poweroff is run on the host, libvirt-guests service takes an
>> action.
>
> If oVirt is initiating a graceful host shutdown, 

I meant host shutdown not initiated by oVirt.

> then surely it already knows what VMs it has running on the host at
> that time, and so has enough info to restart them later.
>
>>`virsh shutdown' is run on the VM, the guest OS is shut down
>> cleanly and libvirt reports a shutdown event with
>> VIR_DOMAIN_EVENT_SHUTDOWN_GUEST detail.  Although it is a host initiated
>> shutdown actually.
>> 
>> Does libvirt provide any means to distinguish this case from a regular
>> user shutdown?
>
> A "virsh shutdown" merely triggers a request to the guest OS to start
> a guest initiated shutdown. As such it is indistinguishable from an
> administrator initiating the same thing inside the guest.

OK, so we will have to check on VM shutdown whether the host is in
shutdown or not ourselves.

Thank you for clarification,
Milan



Re: Distinguishing between host and guest initiated VM shutdown

2020-08-27 Thread Daniel P. Berrange
On Wed, Aug 26, 2020 at 10:35:22PM +0200, Milan Zamazal wrote:
> Hi,
> 
> we have a problem in oVirt that highly available VMs don't restart after
> host poweroff because Vdsm identifies the case as a user initiated
> shutdown (https://bugzilla.redhat.com/1800966).
> 
> When poweroff is run on the host, libvirt-guests service takes an
> action.

If oVirt is initiating a graceful host shutdown, then surely it already
knows what VMs it has running on the host at that time, and so has enough
info to restart them later.

>`virsh shutdown' is run on the VM, the guest OS is shut down
> cleanly and libvirt reports a shutdown event with
> VIR_DOMAIN_EVENT_SHUTDOWN_GUEST detail.  Although it is a host initiated
> shutdown actually.
> 
> Does libvirt provide any means to distinguish this case from a regular
> user shutdown?

A "virsh shutdown" merely triggers a request to the guest OS to start
a guest initiated shutdown. As such it is indistinguishable from an
administrator initiating the same thing inside the guest.

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 :|



Distinguishing between host and guest initiated VM shutdown

2020-08-26 Thread Milan Zamazal
Hi,

we have a problem in oVirt that highly available VMs don't restart after
host poweroff because Vdsm identifies the case as a user initiated
shutdown (https://bugzilla.redhat.com/1800966).

When poweroff is run on the host, libvirt-guests service takes an
action.  `virsh shutdown' is run on the VM, the guest OS is shut down
cleanly and libvirt reports a shutdown event with
VIR_DOMAIN_EVENT_SHUTDOWN_GUEST detail.  Although it is a host initiated
shutdown actually.

Does libvirt provide any means to distinguish this case from a regular
user shutdown?

Thanks,
Milan