The number one use case for live migration today is for evacuation: when a Solaris Zones host needs some maintenance operation that involves a reboot, then the zones are live migrated to some other willing host. This avoids scheduling simultaneous maintenance windows for all the services provided by those zones.

Implementing this today on Solaris 11.3 involves manually migrating zones with individual zoneadm migrate commands, and especially, determining suitable destinations for each of the zones. To make this common scenario simpler and less error prone, Solaris 11.4 Beta comes with a new command sysadm(8) for system maintenance that also allows for zone evacuation.

The basic idea of how it is supposed to be used is like this:

# pkg update
...
# sysadm maintain -s -m "updating to new build"
# sysadm evacuate -v
Evacuating 3 zones...
Migrating myzone1 to rads://destination1/ ...
Migrating myzone3 to rads://destination1/ ...
Migrating myzone4 to rads://destination2/ ...
Done in 3m30s.
# reboot
...
# sysadm maintain -e
# sysadm evacuate -r
...

When in maintenance mode, an attempt to attach or boot any zone is refused: if the admin is trying to move zones off the host, it’s not helpful to allow incoming zones. Note that this maintenance mode is recorded system-wide, not just in the zones framework; even though the only current impact is on zones, it seems likely other sub-systems may find it useful in the future.

To set up an evacuation target for a zone, an SMF property evacuation/target for a given zone service instance system/zones/zone:<zone-name> must be set to the target host. You can either use rads:// or ssh:// location identifier, e.g.: ssh://janp@mymachine.mydomain.com. Do not forget to refresh the service instance for your change to take effect.

You can evacuate running Kernel Zones and both installed native and Kernel Zones. The evacuation always means evacuating running zones, and with the option -a, installed zones are included as well. Only those zones with the set evacuation/target property in their service instance are scheduled for evacuation. However, if any of the running zone (and also installed if the evacuate -a is used) is not set with the property, the overall result of the evacuation will be reported as failed by sysadm which is logical as an evacuation by its definition means to evacuate everything.

As live zone migration does not support native zones, those can be only evacuated in the installed state. Also note that you can only evacuate zones installed on shared storage. For example, on iSCSI volumes. See the storage URI manual page, suri(7), for information on what other shared storage is supported. Note that you can install Kernel Zones to NFS files as well.

To setup live Kernel Zone migration, please check out Migrating an Oracle Solaris Kernel Zone section of the 11.4 online documentation.

Now, let’s see a real example. We have a few zones on host nacaozumbi. All running and installed zones are on shared storage, including the native zone tzone1 and Kernel Zone evac1:

root:nacaozumbi:~# zonecfg -z tzone1 info rootzpool
rootzpool:
	storage: iscsi://saison/luname.naa.600144f0dbf8af1900005582f1c90007

root:nacaozumbi::~$ zonecfg -z evac1 info device
device:
        storage: iscsi://saison/luname.naa.600144f0dbf8af19000058ff48060017
        id: 1
        bootpri: 0

root:nacaozumbi:~# zoneadm list -cv
  ID NAME      STATUS      PATH                  BRAND      IP
   0 global    running     /                     solaris    shared
  82 evac3     running     -                     solaris-kz excl
  83 evac1     running     -                     solaris-kz excl
  84 evac2     running     -                     solaris-kz excl
   - tzone1    installed   /system/zones/tzone1  solaris    excl
   - on-fixes  configured  -                     solaris-kz excl
   - evac4     installed   -                     solaris-kz excl
   - zts       configured  -                     solaris-kz excl

Zones not set for evacution were detached – ie. on-fixes and zts. All running and installed zones are set to be evacuated to bjork, for example:

root:nacaozumbi:~# svccfg -s system/zones/zone:evac1 listprop evacuation/target
evacuation/target astring     ssh://root@bjork

Now, let’s start the maintenance window:

root:nacaozumbi:~# sysadm maintain -s -m "updating to new build"
root:nacaozumbi:~# sysadm maintain -l
TYPE  USER       DATE             MESSAGE
admin root       2018-02-02 01:10 updating to new build

At this point we can no longer boot or attach zones on nacaozumbi:

root:nacaozumbi:~# zoneadm -z on-fixes attach
zoneadm: zone 'on-fixes': attach prevented due to system maintenance: see sysadm(8)

And that also includes migrating zones to nacaozumbi:

root:bjork:~# zoneadm -z on-fixes migrate ssh://root@nacaozumbi
zoneadm: zone 'on-fixes': Using existing zone configuration on destination.
zoneadm: zone 'on-fixes': Attaching zone.
zoneadm: zone 'on-fixes': attach failed:
zoneadm: zone 'on-fixes': attach prevented due to system maintenance: see sysadm(8)

Now we start evacuating all the zones. In this example, all running and installed zones have their service instance property evacuation/target set. The option -a means all the zones, that is including those installed. The -v option provides verbose output.

root:nacaozumbi:~# sysadm evacuate -va
sysadm: preparing 5 zone(s) for evacuation ...
sysadm: initializing migration of evac1 to bjork ...
sysadm: initializing migration of evac3 to bjork ...
sysadm: initializing migration of evac4 to bjork ...
sysadm: initializing migration of tzone1 to bjork ...
sysadm: initializing migration of evac2 to bjork ...
sysadm: evacuating 5 zone(s) ...
sysadm: migrating tzone1 to bjork ...
sysadm: migrating evac2 to bjork ...
sysadm: migrating evac4 to bjork ...
sysadm: migrating evac1 to bjork ...
sysadm: migrating evac3 to bjork ...
sysadm: evacuation completed successfully.
sysadm: evac1: evacuated to ssh://root@bjork
sysadm: evac2: evacuated to ssh://root@bjork
sysadm: evac3: evacuated to ssh://root@bjork
sysadm: evac4: evacuated to ssh://root@bjork
sysadm: tzone1: evacuated to ssh://root@bjork

While being evacuated, you can check the state of evacuation like this:

root:nacaozumbi:~# sysadm evacuate -l
sysadm: evacuation in progress

After the evacuation is done, you can also see the details like this (for example, in case you did not run it in verbose mode):

root:nacaozumbi:~# sysadm evacuate -l -o ZONENAME,STATE,DEST
ZONENAME         STATE     DEST
evac1            EVACUATED ssh://root@bjork
evac2            EVACUATED ssh://root@bjork
evac3            EVACUATED ssh://root@bjork
evac4            EVACUATED ssh://root@bjork
tzone1           EVACUATED ssh://root@bjork

And you can see all the evacuated zones are now in the configured state on the source host:

root:nacaozumbi:~# zoneadm list -cv
  ID NAME      STATUS      PATH                  BRAND      IP
   0 global    running     /                     solaris    shared
   - tzone1    configured  /system/zones/tzone1  solaris    excl
   - evac1     configured  -                     solaris-kz excl
   - on-fixes  configured  -                     solaris-kz excl
   - evac4     configured  -                     solaris-kz excl
   - zts       configured  -                     solaris-kz excl
   - evac3     configured  -                     solaris-kz excl
   - evac2     configured  -                     solaris-kz excl

And the migrated zones are happily running or in the installed state on host bjork:

jpechane:bjork::~$ zoneadm list -cv
  ID NAME      STATUS      PATH                  BRAND      IP
   0 global    running     /                     solaris    shared
  57 evac3     running     -                     solaris-kz excl
  58 evac1     running     -                     solaris-kz excl
  59 evac2     running     -                     solaris-kz excl
   - on-fixes  installed   -                     solaris-kz excl
   - tzone1    installed   /system/zones/tzone1  solaris    excl
   - zts       installed   -                     solaris-kz excl
   - evac4     installed   -                     solaris-kz excl

The maintenance state is still held at this point:

root:nacaozumbi:~# sysadm maintain -l
TYPE  USER   DATE             MESSAGE
admin root   2018-02-02 01:10 updating to new build

Upgrade the system with a new boot environment unless you did that before (which you should have to keep the time your zones are running on the other host to minimum):

root:nacaozumbi:~# pkg update --be-name=.... -C0 entire@...
root:nacaozumbi:~# reboot

Now, finish the maintenance mode.

root:nacaozumbi:~# sysadm maintain -e

And as the final step, return all the evacuated zones now. As explained before, you would not be able to do it if still in the maintenace mode.

root:nacaozumbi:~# sysadm evacuate -ra
sysadm: preparing zones for return ... 5/5
sysadm: returning zones ... 5/5
sysadm: return completed successfully.

Possible enhancements for the future we are considering include specifying multiple targets and a spread policy, with a resource utilisation comparison algorithm that would consider CPU arch, RAM and CPU resources.