Pasquale Dir
2014-Mar-29 12:21 UTC
[libvirt-users] Programmatically force shutdown a guest: possible?
I am looking at the shutdown method, but if the guest system is a desktop system, like for example ubuntu, it just has the effect to show a box prompting the user for a shutdown/reboot/ and such. I could enter the guest and change this default behaviour and it actually works..but I'd like for a way to send a shutdown command without doing so. Is it possible?
Eric Blake
2014-Mar-29 14:12 UTC
Re: [libvirt-users] Programmatically force shutdown a guest: possible?
On 03/29/2014 06:21 AM, Pasquale Dir wrote:> I am looking at the shutdown method, but if the guest system is a desktop > system, like for example ubuntu, it just has the effect to show a box > prompting the user for a shutdown/reboot/ and such. > > I could enter the guest and change this default behaviour and it actually > works..but I'd like for a way to send a shutdown command without doing so. > > Is it possible?Guest shutdown is ALWAYS a cooperative action. It sounds like your guest defaults to an interactive shutdown when an ACPI shutdown request is received. You can install qemu-guest-agent in your guest and send shutdown via the agent instead of via ACPI - that may be a bit more responsive at doing an immediate shutdown. But beyond that, no, there is no way to guarantee a graceful guest shutdown without guest cooperation. If you must stop a guest, and shutdown is taking too long because the guest is not cooperating, then use the 'virsh destroy' command. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Pasquale Dir
2014-Mar-30 08:47 UTC
Re: [libvirt-users] Programmatically force shutdown a guest: possible?
Yes, you are right. Listen, as the documentation is not very exaustive, can you explain briefly to me how a guest agent works? After installing it via the apt-get on the hypervisor (I am using ubuntu as host system) how can I create a script which would do this? That is waiting for an acpi signal and actually shut down the guest. And what other operation can you actually do with a guest agent? I would be interested in getting the current amount of memory the guest is using too...as libvirt apis just tell me the max memory allocated. 2014-03-29 15:12 GMT+01:00 Eric Blake <eblake@redhat.com>:> On 03/29/2014 06:21 AM, Pasquale Dir wrote: > > I am looking at the shutdown method, but if the guest system is a desktop > > system, like for example ubuntu, it just has the effect to show a box > > prompting the user for a shutdown/reboot/ and such. > > > > I could enter the guest and change this default behaviour and it actually > > works..but I'd like for a way to send a shutdown command without doing > so. > > > > Is it possible? > > Guest shutdown is ALWAYS a cooperative action. It sounds like your > guest defaults to an interactive shutdown when an ACPI shutdown request > is received. You can install qemu-guest-agent in your guest and send > shutdown via the agent instead of via ACPI - that may be a bit more > responsive at doing an immediate shutdown. But beyond that, no, there > is no way to guarantee a graceful guest shutdown without guest > cooperation. If you must stop a guest, and shutdown is taking too long > because the guest is not cooperating, then use the 'virsh destroy' command. > > -- > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org > >