Différences
Ci-dessous, les différences entre deux révisions de la page.
— |
tuto:virtualisation:libvirt_migration_snapshots [21/11/2014 12:07] (Version actuelle) dani créée |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== Migration des machines virtuelles avec snapshots ====== | ||
+ | Libvirt ne supporte malheureusement pas //Out of the box// la migration des machines virtuelles avec des snapshots, mais fournit tous les outils pour le faire (il faut voir libvirt comme un outil de bas niveau qui fournit uniquement les API nécessaires, | ||
+ | |||
+ | <file perl migrate_all.pl> | ||
+ | # | ||
+ | |||
+ | use strict; | ||
+ | use Sys::Virt; | ||
+ | |||
+ | my ($local, | ||
+ | |||
+ | eval { $local = Sys:: | ||
+ | if ($@){ | ||
+ | # No connection to the local libvirt | ||
+ | # We can't do anything | ||
+ | die 'Error connecting to libvirt on URI: qemu:/// | ||
+ | } | ||
+ | |||
+ | eval { $remote = Sys:: | ||
+ | if ($@){ | ||
+ | # No connection to the remote server | ||
+ | # Let's try to managed save all running domain | ||
+ | # foreach my $dom ($local-> | ||
+ | # next unless $dom-> | ||
+ | # $dom-> | ||
+ | # } | ||
+ | die " | ||
+ | } | ||
+ | else{ | ||
+ | # We have a connection to both the local and | ||
+ | # the remote libvirt. Lets try to migrate | ||
+ | # all our running domain to our friend | ||
+ | foreach my $locdom ($local-> | ||
+ | # Is the remote domain already defined ? | ||
+ | my $remdom = eval { $remote-> | ||
+ | if ($@){ | ||
+ | # Remote domain not defined yet | ||
+ | $remdom = $remote-> | ||
+ | } | ||
+ | # Now lets migrate all the snapshots | ||
+ | foreach my $snap ($locdom-> | ||
+ | # Handle the active snapshot | ||
+ | if ($snap-> | ||
+ | $remdom-> | ||
+ | } | ||
+ | else{ | ||
+ | $remdom-> | ||
+ | } | ||
+ | # Once snapshot has been moved, lets remove it's metadata handling on the local hypervisor | ||
+ | $snap-> | ||
+ | } | ||
+ | # Now migrate the domain itself. We can either do a live migration if the domain is active | ||
+ | if ($locdom-> | ||
+ | $locdom-> | ||
+ | } | ||
+ | # Or an offline migration | ||
+ | else{ | ||
+ | $locdom-> | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ |