\section{QEMU}

\begin{frame}
   {What is QEMU?}

   \begin{itemize}
      \item
      \textbf{Q}uick \textbf{EMU}lator
      \item
      Three levels:
      \begin{enumerate}
         \item \textbf{libvirt}: Common Library and API
         \item \textbf{QEMU}: Emulator
         \item \textbf{KVM}: Accelerator
      \end{enumerate}
      \item
      Hypervisor doing hardware emulation
      \item
      Host and guest can be different architectures (CPUs)
      \item
      Combine with accelerator (e.g., \textbf{KVM}) to speed up to
      native speeds
      \item
      Useful for development for new processing chips
   \end{itemize}

\end{frame}

\cprotect\note{

\textbf{QEMU} stands for \textbf{Q}uick \textbf{EMU}lator.
It was originally written by Fabrice Bellard in 2002.
(Bellard is also known for feats such as holding, at one
point, the world record for calculating $\pi$, reaching
2.7 trillion digits.)

\textbf{QEMU} is a \textbf{hypervisor} that performs
hardware \textbf{emulation}, or \textbf{virtualization}.
It emulates CPUs by dynamically translating binary
instructions between the host architecture and the
emulated one.

The host and emulated architectures may be different or
the same.  There are numerous choices for both host and
guest operating systems.

\textbf{QEMU} can also be used to emulate just particular
applications, not entire operating systems.

By itself, \textbf{QEMU} is much slower than the host
machine.  But it can be used to together with \textbf{KVM}
(\textbf{K}ernel \textbf{V}irtual \textbf{M}achine) to
reach speeds close to those of the native host.

Guest operating systems do not require rewriting to run under
\textbf{QEMU}.

\textbf{QEMU} can save, pause, and restore a virtual
machine at any time.

\textbf{QEMU} is free software licensed under the
\textbf{GPL}.

\textbf{QEMU} has the capability of supporting many
architectures including:
{\quotation{
   \textbf{IA-32} (i386),
   \textbf{x86-64},
   \textbf{MIPS},
   \textbf{SPARC},
   \textbf{ARM},
   \textbf{SH4},
   \textbf{PowerPC},
   \textbf{CRIS},
   \textbf{MicroBlaze},
   \textbf{etc.}
}}

The cross-compilation abilities of \textbf{QEMU} make it
extremely useful when doing development for embedded
processors.

In fact, \textbf{QEMU} has often been used to develop for
processors which have either not yet been physically
produced, or released to market.

}

\begin{frame}
   {Third Party Hypervisor Integration}

   \begin{itemize}
      \item
      \textbf{QEMU} is slow but can reach almost native speed
      with an \textbf{accelerator} such as:
      \begin{itemize}
         \item
         \textbf{KVM}
         \item
         \textbf{Xen}
         \item
         \textbf{Oracle Virtual Box}
      \end{itemize}
      \item
      \textbf{KVM} is very tightly integrated with
      \textbf{QEMU} and arose from the same projects.
   \end{itemize}
\end{frame}

\cprotect\note{

   Used by itself, \textbf{QEMU} is relatively slow.
   However, it can be integrated with third party
   hypervisors, and then reach near native speeds.  Note
   some of these systems are very close cousins of
   \textbf{QEMU}; others are more remote.  To mention a few
   main ones:

   \begin{itemize}
      \item
      \textbf{KVM} offers particularly tight integration
      with \textbf{QEMU}.  When host and target are the same
      architecture, full acceleration and high speed are
      delivered.  \textbf{KVM} is native to \textbf{Linux}.
      We will discuss this in detail.
      \item
      \textbf{Xen}, also native to \textbf{Linux}, can run
      in hardware virtualization mode if the architecture
      offers it, as does \textbf{x86} and some \textbf{ARM}
      variants.
      \item
      \textbf{Oracle Virtual Box} can use \textbf{qcow2}
      formatted images, and has a very close relationship
      with \textbf{qemu}.

   \end{itemize}

   In this course we recommend using (and will use in labs)
   \textbf{virt-manager} to configure and run virtual
   machines.  We will also give instructions for how to run
   them using \textbf{qemu} command line utilities.

}

\begin{frame}
   {Image Formats}

   \begin{itemize}
      \item
      Two main Formats:

      \begin{enumerate}
         \item
         \textbf{cmd}: Simplest
         \item
         \textbf{qcow2}: \textbf{C}opy \textbf{O}n
         \textbf{W}rite 2
      \end{enumerate}
      \item
      Can support many other formats
      \item
      Can convert between formats:
      \begin{cmd}
$ qemu-img convert -O vmdk myvm.qcow2 myvm.vmdk
      \end{cmd}
   \end{itemize}
\end{frame}

\cprotect\note{
   \small{

      \textbf{QEMU} supports many formats for disk image files.  However,
      only two are used primarily, with the rest being available for
      historical reasons and for conversion utilities.  These
      two main formats are:

      \begin{itemize}
         \item
         \textbf{cmd} (default)

         This is the simplest and easiest to export to other non-\textbf{QEMU}
         emulators.  Empty sectors do not take up space.

         \item
         \textbf{qcow2}

         \textbf{COW} stands for \textbf{C}opy \textbf{O}n \textbf{W}rite.
         There are many options.  See \textbf{man qemu-img}.
      \end{itemize}

      To get a list of supported formats:
      \begin{cmd}
$ qemu-img --help | grep formats:
   \end{cmd}
      \vspace{-12pt}
      \begin{klst}[]
Supported formats: blkdebug blklogwrites blkreplay blkverify copy-on-read file ftp ftps gluster host_cdrom host_device http https iscsi iser luks nbd null-aio null-co nvme qcow2 quorum raw rbd ssh throttle vhdx vmdk vpc
   \end{klst}

      Note in particular:
      \begin{itemize}
         \item
         \textbf{vdi}: Used by \textbf{Oracle Virtual Box}
         \item
         \textbf{vmdk}: Used by \textbf{VMware}
      \end{itemize}


      Note that \textbf{qemu-img} can be used to translate
      between formats, .e.g.:
      \begin{cmd}
$ qemu-img convert -O vmdk myvm.qcow2 myvm.vmdk
   \end{cmd}
      using default options.  See the \textbf{man} page for full
      possibilities.
   }

}

