Skip to content

Commit

Permalink
virt-test: Add sphinx documentation
Browse files Browse the repository at this point in the history
After some work with the virt-test wiki, it has been
converted to the sphinx format. Although many of the
rough edges and outdated docs were put into shape,
there's still a lot to be done. It's good to have
it out there and integrated early, where we can
work on it.

Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
  • Loading branch information
lmr committed Apr 15, 2014
1 parent 33568f7 commit 523b30f
Show file tree
Hide file tree
Showing 99 changed files with 8,930 additions and 0 deletions.
153 changes: 153 additions & 0 deletions documentation/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"

clean:
-rm -rf $(BUILDDIR)/*

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."

pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."

json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."

htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."

qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/VirtTest.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/VirtTest.qhc"

devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/VirtTest"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/VirtTest"
@echo "# devhelp"

epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."

latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."

latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."

man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."

texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."

info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."

gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."

changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."

linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."

doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
Empty file added documentation/build/.gitignore
Empty file.
Empty file.
Empty file.
165 changes: 165 additions & 0 deletions documentation/source/advanced/MultiHostMigration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
Writing your own QEMU multi host migration test
==============================================

Client part of Autotest works only on a single host, for this reason multi host
migration test needs to be started from the server part of Autotest. The server
module is responsible for preparing all hosts, then to start client part with
the appropriate parameters. To simplify writing a multi host migration, we
developed the MultihostMigration class. The class is a framework class that
allows to create, start and sync migration scenario over multiple host, taking
care of most of the heavy lifting for you.

Prepare env
-----------

For migration without disk migration is necessary have shared storage (NFS, ceph, etc.).
There have to be placed images of guests system in shared storage.
Nested virtualization config
:doc:`Use nested virt to develop multi host tests <../advanced/VirtualEnvMultihost>`

Prepare config files
--------------------

Multi host migration uses almost all the configuration files from standard virt
tests. The only difference the main configuration file, named
``multi-host-tests.cfg``. All multi host migration tests are defined in
``client/virt/qemu/tests/cfg/multi-host.cfg``.

Start multi host migration tests
--------------------------------

The server part of Autotest, just as the client part, uses a control file to
describe the operations to be executed on a test job. The multi host migration
control file can be found at ``client/virt/qemu/multi_host.srv``.

Starting autoserv:

Change your current working directory to the root of the autotest repo, say
``/home/myuser/Code/autotest``:

::

cd /home/myuser/Code/autotest
server/autoserv -m 192.168.100.220,192.168.100.240 client/tests/virt/qemu/multi_host.srv

the command starts autotest on machine 192.168.100.220 and 192.168.100.240 and
uses them for multi_host.srv control file. If four machines are defined it'll
create two pairs and with each pair the independent migration test is started.
Because of it there is added new arg "all" in multi_host.srv. It starts
one migration test with all machines.

::

server/autoserv -m 192.168.100.220,192.168.100.240,192.168.100.221 -a all client/virt/qemu/multi_host.srv


.. _multihost_migration:

Using of MultihostMigration class
---------------------------------

Scheme:
~~~~~~~

.. figure:: MultiHostMigration/multihost-migration.png

:download:`Source file for the diagram above (LibreOffice file) <MultiHostMigration/multihost-migration.odg>`


Example:
~~~~~~~~

::

class TestMultihostMigration(virt_utils.MultihostMigration):
def __init__(self, test, params, env):
super(testMultihostMigration, self).__init__(test, params, env)

def migration_scenario(self):
srchost = self.params.get("hosts")[0]
dsthost = self.params.get("hosts")[1]

def worker(mig_data):
vm = env.get_vm("vm1")
session = vm.wait_for_login(timeout=self.login_timeout)
session.sendline("nohup dd if=/dev/zero of=/dev/null &")
session.cmd("killall -0 dd")

def check_worker(mig_data):
vm = env.get_vm("vm1")
session = vm.wait_for_login(timeout=self.login_timeout)
session.cmd("killall -9 dd")

# Almost synchronized migration, waiting to end it.
# Work is started only on first VM.

self.migrate_wait(["vm1", "vm2"], srchost, dsthost,
worker, check_worker)

# Migration started in different threads.
# It allows to start multiple migrations simultaneously.

# Starts one migration without synchronization with work.
mig1 = self.migrate(["vm1"], srchost, dsthost,
worker, check_worker)

time.sleep(20)

# Starts another test simultaneously.
mig2 = self.migrate(["vm2"], srchost, dsthost)
# Wait for mig2 finish.
mig2.join()
mig1.join()

mig = TestMultihostMigration(test, params, env)
# Start test.
mig.run()

When you call:

::

mig = TestMultihostMigration(test, params, env):

What happens is

1. VM's disks will be prepared.
2. The synchronization server will be started.
3. All hosts will be synchronized after VM create disks.

When you call the method:

::

migrate():

What happens in a diagram is:

+------------------------------------------+-----------------------------------+
| source | destination |
+==========================================+===================================+
| It prepare VM if machine is not started. |
+------------------------------------------+-----------------------------------+
| Start work on VM. | |
+------------------------------------------+-----------------------------------+
| ``mig.migrate_vms_src()`` | ``mig.migrate_vms_dest()`` |
+------------------------------------------+-----------------------------------+
| | Check work on VM after migration. |
+------------------------------------------+-----------------------------------+
| Wait for finish migration on all hosts. |
+------------------------------------------+-----------------------------------+

It's important to note that the migrations are made using the ``tcp`` protocol,
since the others don't support multi host migration.

::

def migrate_vms_src(self, mig_data):
vm = mig_data.vms[0]
logging.info("Start migrating now...")
vm.migrate(mig_data.dst, mig_data.vm_ports)


This example migrates only the first machine defined in migration. Better example
is in ``virt_utils.MultihostMigration.migrate_vms_src``. This function migrates
all machines defined for migration.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 523b30f

Please sign in to comment.