1

I have Ubuntu 14.04.1 (ubuntu-14.04.1-server-amd64.iso) guest running in a KVM host. The host is running Ubuntu 16.04. I'm trying to find out how Ubuntu 14.04.1 differentiates between virsh shutdown and virsh reboot commands issued in the host. I see that in both cases the guest calls halt -d -f -i -p -h from /etc/rc0.d/S90halt. I don't see a change to runlevel 6 when virsh reboot is used (confirmed using echo to file in /etc/rc0.d/S90halt and /etc/rc6.d/S90reboot).

I also found that in Ubuntu 14.04.1 systemd-logind processes the acpi event and in turn does a dbus call to get systemd-shim running, which calls shutdown to get the runlevel changed to '0' through upstart. Any help in understanding this better it much appreciated.

Guest details:

srinij@ubuntu:/$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:        14.04
Codename:       trusty

Host details:

srinij@ubuntu-server-16x:~/Downloads$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04 LTS
Release:        16.04
Codename:       xenial
srinij@ubuntu-server-16x:~/Downloads$ virsh version
Compiled against library: libvirt 1.3.1
Using library: libvirt 1.3.1
Using API: QEMU 1.3.1
Running hypervisor: QEMU 2.5.0
1
  • libvirt first requests the guest to shutdown in both cases (Reboot/Shutdown) using ACPI power button event. Next in case of Reboot, libvirt itself restarts the VM. Thanks to Paolo Bonzini from qemu-devel for pointing this out
    – SriniJ
    Sep 27, 2016 at 1:40

2 Answers 2

0

I am not 100% sure, but the hypervisor can order the guest OS to shut down or reboot by emulating an ACPI hardware event, i.e. touching the power button.

There is no differentiated signal for shutdown or reboot as far as I know, just the normal power button.

That means virsh shutdown and virsh reboot should both emulate a power button tap which gets registered by the guest OS' ACPI daemon and results in a shutdown (on Ubuntu server by default) or an interactive prompt (on Ubuntu desktop by default) or however the guest OS is configured to handle this event.

The only difference, I think, is, that once the VM has shut down, if the command was virsh shutdown it stays off, but if it was virsh reboot it gets powered on again immediately. That would equal a cold boot though, not a warm reboot.

However, looking at the man virsh manual, it seems like there are more different options to send a reboot command other than just an ACPI event. However, I can't tell you anything about those, unfortunately.

   reboot domain [--mode MODE-LIST]
       Reboot a domain.  This acts just as if the domain had the reboot
       command run from the console.  The command returns as soon as it
       has executed the reboot action, which may be significantly before
       the domain actually reboots.

       The exact behavior of a domain when it reboots is set by the
       on_reboot parameter in the domain's XML definition.

       By default the hypervisor will try to pick a suitable shutdown
       method. To specify an alternative method, the --mode parameter can
       specify a comma separated list which includes "acpi", "agent",
       "initctl", "signal" and "paravirt". The order in which drivers will
       try each mode is undefined, and not related to the order specified
       to virsh.  For strict control over ordering, use a single mode at a
       time and repeat the command.
0

libvirt first requests the guest to shutdown in both cases (Reboot/Shutdown) using ACPI power button event. Next in case of Reboot, libvirt itself restarts the VM. Thanks to Paolo Bonzini from qemu-devel for pointing this out

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .