\documentclass[xcolor={dvipsnames}]{beamer}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{xcolor,colortbl}
\usepackage{fancyvrb}
\usepackage{minted}

\usetheme{Boadilla}

\author{Andrew Cooper}
\title{Migration v2}
\institute{Citrix XenServer}
\date{$17^{th}$ August 2015}

\begin{document}

\frame{\titlepage}

\begin{frame}[fragile]{Why Migration v2}

  \begin{itemize}
    \item XenServer 6.2
      \begin{itemize}
        \item 64bit Xen, 32bit Dom0
        \item Inertia, More efficient to virtualise
      \end{itemize}
    \item<2-> XenServer 6.5
      \begin{itemize}
        \item 64bit Xen, 64bit Dom0
        \item High MMIO regions above $2^{44}$ bits
      \end{itemize}
    \item<3-> Rolling Pool Upgrade tests
      \begin{itemize}
        \item Migrate VM from XS6.2 to XS6.5
        \item Error on the receiving side:
      \end{itemize}
  \end{itemize}

  \medskip
  \begin{center}
    \onslide<4->
    \scriptsize
    \begin{BVerbatim}
xc: detail: xc_domain_restore: starting restore of new domid 1
xc: detail: xc_domain_restore: p2m_size = ffffffff00010000
xc: error: Couldn't allocate p2m_frame_list array: Internal error
    \end{BVerbatim}
  \end{center}
\end{frame}

\begin{frame}[fragile]{Legacy Migration}

\footnotesize
\begin{minted}{c}
int xc_domain_restore(xc_interface *xch,
...

if ( RDEXACT(io_fd, &dinfo->p2m_size, sizeof(unsigned long)) )
{
  PERROR("read: p2m_size");
  goto out;
}
DPRINTF("%s: p2m_size = %lx\n", __func__, dinfo->p2m_size);
\end{minted}

\end{frame}

\begin{frame}[fragile]{Legacy Migration}

  \begin{itemize}
  \item No format written down
    \begin{itemize}
    \item Subsequently reverse engineered from existing code
    \end{itemize}
  \item<2-> No header information at all
  \item<2-> Hard to extend
    \begin{itemize}
    \item Written mostly as two monolithic functions
    \item \verb!goto! tangle
    \item PV MSR support too complicated to implement
    \end{itemize}
  \item<3-> Asymmetry with Qemu handling
    \begin{itemize}
    \item Save side's caller puts Qemu blob into the stream
    \item Restore side pulls Qemu blob out and saves in magic path
    \end{itemize}
  \item<4-> Stream contents depends on compilation ABI
    \begin{itemize}
    \item \textbf{Different between 32bit and 64bit}
    \end{itemize}
  \end{itemize}

\end{frame}

\begin{frame}{VM Serialisation}

  \begin{itemize}
    \item Information (Currently x86 specific)
      \begin{description}
        \item[Common] Page Data, TSC
        \item[HVM] Params, Context (Xen serialised state)
        \item[PV] Width, Levels, P2M, VCPU State, Shared Info
      \end{description}
    \item<2-> Suspend
      \begin{itemize}
        \item Pause VM
        \item Copy all memory
      \end{itemize}
    \item<3-> Migrate
      \begin{itemize}
        \item Enable logdirty
        \item Copy all memory
        \item --- Query logdirty bitmap
        \item --- Copy dirty memory
        \item --- Loop
        \item Pause VM
        \item Copy remaining memory
      \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{Solution for XenServer}

  \begin{itemize}
    \item Redesigned completely from scratch
    \item<2-> Specification written down
      \begin{itemize}
      \item \verb!docs/specs/libxc-migration-stream.pandoc!
      \item Describes exact binary layout
      \item Extensible
      \end{itemize}
    \item<3-> Reimplemented completely from scratch
      \begin{itemize}
        \item Common save and restore algorithms
        \item Per-guest-type hooks to implement
      \end{itemize}
    \item<4-> Legacy conversion needed
      \begin{itemize}
        \item \verb!tools/python/scripts/convert-legacy-stream!
        \item Reads in legacy stream
        \item Writes out v2 stream
      \end{itemize}
  \end{itemize}

\end{frame}

\begin{frame}[fragile]{Stream format -- libxc}

  \begin{center}
    \scriptsize
    \begin{BVerbatim}
 0      1     2     3     4     5     6     7 octet
+-------------------------------------------------+   +
| marker (0xffffffffffffffff)                     |   |
+-----------------------+-------------------------+   | Image
| id ("XENF" in ASCII)  | version (2)             |   | Header
+-----------+-----------+-------------------------+   |
| options   | (reserved)                          |   |
+-----------+-------------------------------------+   +

+-----------------------+-----------+-------------+   +
| type (PV, HVM, etc)   | page_shift| (reserved)  |   | Domain
+-----------------------+-----------+-------------+   | Header
| xen_major (4)         | xen_minor (6)           |   |
+-----------------------+-------------------------+   +

+-----------------------+-------------------------+   +
| type                  | body_length             |   |
+-----------+-----------+-------------------------+   |
| body...                                         |   | Record
...                                                   |
|           | padding (0 to 7 octets)             |   |
+-----------+-------------------------------------+   +
    \end{BVerbatim}
  \end{center}
\end{frame}

\begin{frame}[fragile]{Upstreaming}

  \begin{itemize}
    \item Problems with libxl
      \begin{itemize}
        \item No participation in stream
        \item 'Toolstack Data' depends on compilation ABI
      \end{itemize}
    \item<2-> Design from scratch
    \item<3-> Specification written down
      \begin{itemize}
        \item \verb!docs/specs/libxl-migration-stream.pandoc!
        \item Describes exact binary layout
        \item Extensible
      \end{itemize}
    \item<4-> Write from scratch
    \item<5-> Compatibility script extended
      \begin{itemize}
        \item Able to write libxl migration v2 streams
        \item 'Qemu' and 'Toolstack data' layered appropriately
      \end{itemize}
  \end{itemize}

\end{frame}

\begin{frame}[fragile]{Framing}

  \begin{columns}[T]
    \column{0.33\textwidth}\onslide<1->\centering Legacy Migration
    \column{0.33\textwidth}\onslide<2->\centering Migration v2
    \column{0.33\textwidth}\onslide<3->\centering Remus Migration v2
  \end{columns}

  \medskip

  \scriptsize

  \begin{columns}[T]
    \column{0.33\textwidth}\centering
    \onslide<1->
    \begin{tabular}{ |l| }
      \hline
      \cellcolor{green}\verb!header!\\
      \cellcolor{green}\verb!optional data!\\
      \hline
      \cellcolor{yellow}\verb!...!\\
      \cellcolor{yellow}\verb!toolstack!\\
      \cellcolor{yellow}\verb!...!\\
      \cellcolor{yellow}\verb!qemu!\\
      \hline
    \end{tabular}

    \column{0.33\textwidth}\centering
    \onslide<2->
    \begin{tabular}{ |l| }
      \hline
      \cellcolor{green}\verb!header!\\
      \cellcolor{green}\verb!optional data!\\
      \hline
      \cellcolor{Salmon}\verb!header!\\
      \cellcolor{Salmon}\verb!libxc content!\\
      \hline
      \cellcolor{yellow}\verb!image header!\\
      \cellcolor{yellow}\verb!domain header!\\
      \cellcolor{yellow}\verb!...!\\
      \cellcolor{yellow}\verb!end!\\
      \hline
      \cellcolor{Salmon}\verb!emulator xenstore!\\
      \cellcolor{Salmon}\verb!emulator context!\\
      \cellcolor{Salmon}\verb!end!\\
      \hline
    \end{tabular}

    \column{0.33\textwidth}\centering
    \onslide<3->
    \begin{tabular}{ |l| }
      \hline
      \cellcolor{green}\verb!header!\\
      \cellcolor{green}\verb!optional data!\\
      \hline
      \cellcolor{Salmon}\verb!header!\\
      \cellcolor{Salmon}\verb!libxc content!\\
      \hline
      \cellcolor{yellow}\verb!image header!\\
      \cellcolor{yellow}\verb!domain header!\\
      \cellcolor{yellow}\verb!...!\\
      \cellcolor{yellow}\verb!checkpoint!\\
      \hline
      \cellcolor{Salmon}\verb!...!\\
      \cellcolor{Salmon}\verb!checkpoint end!\\
      \hline
      \cellcolor{yellow}\verb!...!\\
      \cellcolor{yellow}\verb!checkpoint!\\
      \hline
      \cellcolor{Salmon}\verb!...!\\
      \cellcolor{Salmon}\verb!checkpoint end!\\
      \hline
      \cellcolor{yellow}\verb!...!\\
      \hline
    \end{tabular}

  \end{columns}

{\onslide<1->
\semiverbatim
Key: \colorbox{green}{xl} \colorbox{Salmon}{libxl} \colorbox{yellow}{libxc}
}

\end{frame}

\begin{frame}{General Notes}

  \begin{itemize}
    \item Issues fixed
      \begin{itemize}
        \item PV VCPU state corruption when racing with vcpu actions
        \item PV guests with superpages abort on save, rather than failing to
          reconstruct pagetables on restore
        \item More efficient handling of page data
      \end{itemize}
    \item<2-> Issues still present
      \begin{itemize}
        \item Guests which balloon
        \item PV P2M structure changes
        \item HVM guests with PoD pages
      \end{itemize}
    \item<3-> Areas for further work
      \begin{itemize}
        \item Live migrate looping parameters
        \item Linear P2M support
      \end{itemize}
  \end{itemize}

\end{frame}

\begin{frame}[fragile]{Status -- Xen 4.6}

  \begin{itemize}
    \item All committed
    \item Fully enabled (and tested)
    \item \verb!xl save/restore/migrate/remus! function as before
    \item Legacy migration removed
    \item No noticeable difference to users
  \end{itemize}
\end{frame}

\begin{frame}{Migration v2}

\begin{center}
Any Questions?
\end{center}

\end{frame}

\end{document}

\iffalse

\begin{frame}
  \frametitle{...}
\end{frame}

  \begin{itemize}
    \item
  \end{itemize}

\fi
