Libvirt test v2
cover Libvirt test v2
Hi guys, this is an updated version of the Libvirt test. Cleber has made some great work and fixed a bunch of problems involving using libvirt Xen backend, and now it is possible to run most of the autotest tests using libvirt on both KVM and Xen backends.
This patchset was also sent as a pull request on github, so you can comment in there, if you wish so.
https://github.com/autotest/autotest/pull/31
Cleber Rosa (3):
Virt: builtin HTTP server for unattended installs
Virt: support XEN via libvirt and auto url installer
Virt: add support for XEN via libvirt installs and auto url
Lucas Meneghel Rodrigues (8):
virt: Move data dirs from KVM test to client.virt
virt: Introducing virt_test.virt_test class
Moving unattended_install test from kvm test to common virt location Moving get_started code to client.virt.virt_utils
virt: Introducing libvirt VM class
virt: Introducing libvirt monitor
virt.virt_env_process: Add libvirt vm handling client.tests: Introducing libvirt test
client/tests/kvm/autoit/notepad1.au3 | 44 - client/tests/kvm/autotest_control/bonnie.control | 21 - .../tests/kvm/autotest_control/cpu_hotplug.control | 10 - client/tests/kvm/autotest_control/ctcs.control | 19 - client/tests/kvm/autotest_control/dbench.control | 20 - client/tests/kvm/autotest_control/disktest.control | 15 - client/tests/kvm/autotest_control/ebizzy.control | 11 - client/tests/kvm/autotest_control/flail.control | 17 - .../tests/kvm/autotest_control/hackbench.control | 13 - client/tests/kvm/autotest_control/hwclock.control | 12 - client/tests/kvm/autotest_control/iozone.control | 18 - .../tests/kvm/autotest_control/kernbench.control | 12 - .../kvm/autotest_control/monotonic_time.control | 37 - client/tests/kvm/autotest_control/npb.control | 28 - client/tests/kvm/autotest_control/rtc.control | 15 - client/tests/kvm/autotest_control/scrashme.control | 14 - .../tests/kvm/autotest_control/sleeptest.control | 15 - client/tests/kvm/autotest_control/stress.control | 14 - .../tests/kvm/autotest_control/systemtap.control | 14 - client/tests/kvm/autotest_control/tsc.control | 13 - client/tests/kvm/deps/Makefile | 8 - client/tests/kvm/deps/finish.cpp | 144 - client/tests/kvm/deps/finish.exe | Bin 31007 -> 0 bytes client/tests/kvm/deps/heartbeat_slu.py | 205 -- client/tests/kvm/deps/rss.cpp | 1011 ------- client/tests/kvm/deps/rss.exe | Bin 94518 -> 0 bytes client/tests/kvm/deps/rss.reg | 15 - client/tests/kvm/deps/setuprss.bat | 21 - client/tests/kvm/deps/test_clock_getres/Makefile | 11 - .../kvm/deps/test_clock_getres/test_clock_getres.c | 58 - client/tests/kvm/deps/whql_delete_machine_15.cs | 82 - client/tests/kvm/deps/whql_delete_machine_15.exe | Bin 5632 -> 0 bytes client/tests/kvm/deps/whql_submission_15.cs | 373 --- client/tests/kvm/deps/whql_submission_15.exe | Bin 12288 -> 0 bytes client/tests/kvm/get_started.py | 162 +- client/tests/kvm/kvm.py | 123 +- client/tests/kvm/scripts/ksm_overcommit_guest.py | 237 -- client/tests/kvm/scripts/multicast_guest.py | 37 - client/tests/kvm/scripts/virtio_console_guest.py | 929 ------- client/tests/kvm/steps/Belenix-0.7.1.steps | 198 -- client/tests/kvm/steps/CentOS5-64.steps | 316 --- client/tests/kvm/steps/DSL-4.2.5.steps | 482 ---- client/tests/kvm/steps/Fedora-11-64.steps | 300 -- client/tests/kvm/steps/Fedora-8-64.steps | 281 -- client/tests/kvm/steps/Fedora-8-i386.steps | 317 --- client/tests/kvm/steps/Fedora-9-64.steps | 274 -- client/tests/kvm/steps/Fedora-9-i386.steps | 268 -- client/tests/kvm/steps/FreeSBIE-2.0.1.steps | 198 -- client/tests/kvm/steps/Mandriva-One-2007-32.steps | 480 ---- client/tests/kvm/steps/NetBSD-1.6.2.steps | 241 -- client/tests/kvm/steps/OpenBSD-4.1-32.steps | 348 --- client/tests/kvm/steps/RHEL-3.9-i386.steps | 316 --- client/tests/kvm/steps/RHEL-3.9-x86_64.steps | 311 --- client/tests/kvm/steps/RHEL-4.7-i386.steps | 297 -- client/tests/kvm/steps/RHEL-4.7-x86_64.steps | 323 --- client/tests/kvm/steps/RHEL-5.3-i386.steps | 306 -- client/tests/kvm/steps/RHEL-5.3-x86_64.steps | 298 -- client/tests/kvm/steps/Slax-6.0.7.steps | 311 --- client/tests/kvm/steps/Ubuntu-6.10-32.steps | 127 - .../tests/kvm/steps/Ubuntu-8.04-32-setupssh.steps | 184 -- client/tests/kvm/steps/Ubuntu-8.04-32.steps | 246 -- client/tests/kvm/steps/Ubuntu-8.04-server-32.steps | 210 -- client/tests/kvm/steps/Ubuntu-8.10-64.steps | 165 -- .../kvm/steps/Ubuntu-8.10-server-32-gcc.steps | 148 - client/tests/kvm/steps/Ubuntu-8.10-server-32.steps | 258 -- client/tests/kvm/steps/Win-Vista-32.steps | 152 - client/tests/kvm/steps/Win-Vista-64.steps | 153 - client/tests/kvm/steps/Win2000-32-rss.steps | 52 - client/tests/kvm/steps/Win2000-32-setupssh.steps | 106 - client/tests/kvm/steps/Win2000-32.steps | 119 - client/tests/kvm/steps/Win2003-32-rss.steps | 49 - client/tests/kvm/steps/Win2003-32-setupssh.steps | 109 - client/tests/kvm/steps/Win2003-32.steps | 231 -- client/tests/kvm/steps/Win2003-64-rss.steps | 47 - client/tests/kvm/steps/Win2003-64.steps | 154 - client/tests/kvm/steps/Win2008-32-rss.steps | 49 - client/tests/kvm/steps/Win2008-32-setupssh.steps | 83 - .../tests/kvm/steps/Win2008-32-setuptelnet.steps | 86 - client/tests/kvm/steps/Win2008-32.steps | 139 - client/tests/kvm/steps/Win2008-64-rss.steps | 52 - client/tests/kvm/steps/Win2008-64.steps | 105 - client/tests/kvm/steps/Win7-64-rss.steps | 121 - client/tests/kvm/steps/Win7-64.steps | 187 -- client/tests/kvm/steps/WinVista-32-rss.steps | 53 - client/tests/kvm/steps/WinVista-64-rss.steps | 53 - client/tests/kvm/steps/WinXP-32-rss.steps | 31 - client/tests/kvm/steps/WinXP-32-setupssh.steps | 98 - client/tests/kvm/steps/WinXP-32.steps | 175 -- client/tests/kvm/steps/WinXP-64-rss.steps | 34 - client/tests/kvm/steps/WinXP-64.steps | 111 - client/tests/kvm/steps/memtest86+.steps | 9 - client/tests/kvm/steps/openSUSE-11.0-32.steps | 203 -- .../tests/kvm/steps/openSUSE-11.1-32-and-64.steps | 321 --- client/tests/kvm/tests/cpu_hotplug.py | 2 +- client/tests/kvm/tests/stepmaker.py | 2 +- client/tests/kvm/tests/steps.py | 2 +- client/tests/kvm/tests/unattended_install.py | 632 ----- client/tests/kvm/unattended/Fedora-10.ks | 39 - client/tests/kvm/unattended/Fedora-11.ks | 39 - client/tests/kvm/unattended/Fedora-12.ks | 39 - client/tests/kvm/unattended/Fedora-13.ks | 39 - client/tests/kvm/unattended/Fedora-14.ks | 40 - client/tests/kvm/unattended/Fedora-15.ks | 40 - client/tests/kvm/unattended/Fedora-8.ks | 37 - client/tests/kvm/unattended/Fedora-9.ks | 38 - client/tests/kvm/unattended/OpenSUSE-11.xml | 243 -- client/tests/kvm/unattended/RHEL-3-series.ks | 36 - client/tests/kvm/unattended/RHEL-4-series.ks | 37 - client/tests/kvm/unattended/RHEL-5-series.ks | 39 - client/tests/kvm/unattended/RHEL-6-series.ks | 42 - client/tests/kvm/unattended/SLES-11.xml | 891 ------ client/tests/kvm/unattended/win2000-32.sif | 76 - client/tests/kvm/unattended/win2003-32.sif | 66 - client/tests/kvm/unattended/win2003-64.sif | 66 - .../kvm/unattended/win2008-32-autounattend.xml | 194 -- .../kvm/unattended/win2008-64-autounattend.xml | 200 -- .../kvm/unattended/win2008-r2-autounattend.xml | 200 -- .../tests/kvm/unattended/win7-32-autounattend.xml | 179 -- .../tests/kvm/unattended/win7-64-autounattend.xml | 179 -- client/tests/kvm/unattended/winnt.bat | 12 - .../kvm/unattended/winvista-32-autounattend.xml | 175 -- .../kvm/unattended/winvista-64-autounattend.xml | 188 -- client/tests/kvm/unattended/winxp32.sif | 76 - client/tests/kvm/unattended/winxp64.sif | 76 - client/tests/libvirt/README | 11 + client/tests/libvirt/cdkeys.cfg.sample | 18 + client/tests/libvirt/common.py | 8 + client/tests/libvirt/control | 64 + client/tests/libvirt/get_started.py | 22 + client/tests/libvirt/libvirt.py | 9 + client/tests/libvirt/tests.cfg.sample | 88 + client/tests/libvirt/tests_base.cfg.sample | 2925 ++++++++++++++++++++ client/tests/libvirt/virtio-win.cfg.sample | 235 ++ client/virt/autoit/notepad1.au3 | 44 + client/virt/autotest_control/bonnie.control | 21 + client/virt/autotest_control/cpu_hotplug.control | 10 + client/virt/autotest_control/ctcs.control | 19 + client/virt/autotest_control/dbench.control | 20 + client/virt/autotest_control/disktest.control | 15 + client/virt/autotest_control/ebizzy.control | 11 + client/virt/autotest_control/flail.control | 17 + client/virt/autotest_control/hackbench.control | 13 + client/virt/autotest_control/hwclock.control | 12 + client/virt/autotest_control/iozone.control | 18 + client/virt/autotest_control/kernbench.control | 12 + .../virt/autotest_control/monotonic_time.control | 37 + client/virt/autotest_control/npb.control | 28 + client/virt/autotest_control/rtc.control | 15 + client/virt/autotest_control/scrashme.control | 14 + client/virt/autotest_control/sleeptest.control | 15 + client/virt/autotest_control/stress.control | 14 + client/virt/autotest_control/systemtap.control | 14 + client/virt/autotest_control/tsc.control | 13 + client/virt/deps/Makefile | 8 + client/virt/deps/finish.cpp | 144 + client/virt/deps/finish.exe | Bin 0 -> 31007 bytes client/virt/deps/heartbeat_slu.py | 205 ++ client/virt/deps/rss.cpp | 1011 +++++++ client/virt/deps/rss.exe | Bin 0 -> 94518 bytes client/virt/deps/rss.reg | 15 + client/virt/deps/setuprss.bat | 21 + client/virt/deps/test_clock_getres/Makefile | 11 + .../deps/test_clock_getres/test_clock_getres.c | 58 + client/virt/deps/whql_delete_machine_15.cs | 82 + client/virt/deps/whql_delete_machine_15.exe | Bin 0 -> 5632 bytes client/virt/deps/whql_submission_15.cs | 373 +++ client/virt/deps/whql_submission_15.exe | Bin 0 -> 12288 bytes client/virt/libvirt_monitor.py | 322 +++ client/virt/libvirt_vm.py | 1246 +++++++++ client/virt/scripts/ksm_overcommit_guest.py | 237 ++ client/virt/scripts/multicast_guest.py | 37 + client/virt/scripts/virtio_console_guest.py | 929 +++++++ client/virt/steps/Belenix-0.7.1.steps | 198 ++ client/virt/steps/CentOS5-64.steps | 316 +++ client/virt/steps/DSL-4.2.5.steps | 482 ++++ client/virt/steps/Fedora-11-64.steps | 300 ++ client/virt/steps/Fedora-8-64.steps | 281 ++ client/virt/steps/Fedora-8-i386.steps | 317 +++ client/virt/steps/Fedora-9-64.steps | 274 ++ client/virt/steps/Fedora-9-i386.steps | 268 ++ client/virt/steps/FreeSBIE-2.0.1.steps | 198 ++ client/virt/steps/Mandriva-One-2007-32.steps | 480 ++++ client/virt/steps/NetBSD-1.6.2.steps | 241 ++ client/virt/steps/OpenBSD-4.1-32.steps | 348 +++ client/virt/steps/RHEL-3.9-i386.steps | 316 +++ client/virt/steps/RHEL-3.9-x86_64.steps | 311 +++ client/virt/steps/RHEL-4.7-i386.steps | 297 ++ client/virt/steps/RHEL-4.7-x86_64.steps | 323 +++ client/virt/steps/RHEL-5.3-i386.steps | 306 ++ client/virt/steps/RHEL-5.3-x86_64.steps | 298 ++ client/virt/steps/Slax-6.0.7.steps | 311 +++ client/virt/steps/Ubuntu-6.10-32.steps | 127 + client/virt/steps/Ubuntu-8.04-32-setupssh.steps | 184 ++ client/virt/steps/Ubuntu-8.04-32.steps | 246 ++ client/virt/steps/Ubuntu-8.04-server-32.steps | 210 ++ client/virt/steps/Ubuntu-8.10-64.steps | 165 ++ client/virt/steps/Ubuntu-8.10-server-32-gcc.steps | 148 + client/virt/steps/Ubuntu-8.10-server-32.steps | 258 ++ client/virt/steps/Win-Vista-32.steps | 152 + client/virt/steps/Win-Vista-64.steps | 153 + client/virt/steps/Win2000-32-rss.steps | 52 + client/virt/steps/Win2000-32-setupssh.steps | 106 + client/virt/steps/Win2000-32.steps | 119 + client/virt/steps/Win2003-32-rss.steps | 49 + client/virt/steps/Win2003-32-setupssh.steps | 109 + client/virt/steps/Win2003-32.steps | 231 ++ client/virt/steps/Win2003-64-rss.steps | 47 + client/virt/steps/Win2003-64.steps | 154 + client/virt/steps/Win2008-32-rss.steps | 49 + client/virt/steps/Win2008-32-setupssh.steps | 83 + client/virt/steps/Win2008-32-setuptelnet.steps | 86 + client/virt/steps/Win2008-32.steps | 139 + client/virt/steps/Win2008-64-rss.steps | 52 + client/virt/steps/Win2008-64.steps | 105 + client/virt/steps/Win7-64-rss.steps | 121 + client/virt/steps/Win7-64.steps | 187 ++ client/virt/steps/WinVista-32-rss.steps | 53 + client/virt/steps/WinVista-64-rss.steps | 53 + client/virt/steps/WinXP-32-rss.steps | 31 + client/virt/steps/WinXP-32-setupssh.steps | 98 + client/virt/steps/WinXP-32.steps | 175 ++ client/virt/steps/WinXP-64-rss.steps | 34 + client/virt/steps/WinXP-64.steps | 111 + client/virt/steps/memtest86+.steps | 9 + client/virt/steps/openSUSE-11.0-32.steps | 203 ++ client/virt/steps/openSUSE-11.1-32-and-64.steps | 321 +++ client/virt/tests/autotest.py | 2 +- client/virt/tests/clock_getres.py | 2 +- client/virt/tests/guest_test.py | 2 +- client/virt/tests/unattended_install.py | 797 ++++++ client/virt/tests/whql_submission.py | 4 +- client/virt/unattended/Fedora-10.ks | 39 + client/virt/unattended/Fedora-11.ks | 39 + client/virt/unattended/Fedora-12.ks | 39 + client/virt/unattended/Fedora-13.ks | 39 + client/virt/unattended/Fedora-14.ks | 40 + client/virt/unattended/Fedora-15.ks | 40 + client/virt/unattended/Fedora-8.ks | 37 + client/virt/unattended/Fedora-9.ks | 38 + client/virt/unattended/OpenSUSE-11.xml | 243 ++ client/virt/unattended/RHEL-3-series.ks | 36 + client/virt/unattended/RHEL-4-series.ks | 37 + client/virt/unattended/RHEL-5-series.ks | 39 + client/virt/unattended/RHEL-6-series.ks | 42 + client/virt/unattended/SLES-11.xml | 891 ++++++ client/virt/unattended/win2000-32.sif | 76 + client/virt/unattended/win2003-32.sif | 66 + client/virt/unattended/win2003-64.sif | 66 + client/virt/unattended/win2008-32-autounattend.xml | 194 ++ client/virt/unattended/win2008-64-autounattend.xml | 200 ++ client/virt/unattended/win2008-r2-autounattend.xml | 200 ++ client/virt/unattended/win7-32-autounattend.xml | 179 ++ client/virt/unattended/win7-64-autounattend.xml | 179 ++ client/virt/unattended/winnt.bat | 12 + .../virt/unattended/winvista-32-autounattend.xml | 175 ++ .../virt/unattended/winvista-64-autounattend.xml | 188 ++ client/virt/unattended/winxp32.sif | 76 + client/virt/unattended/winxp64.sif | 76 + client/virt/virt_env_process.py | 51 +- client/virt/virt_http_server.py | 124 + client/virt/virt_test.py | 131 + client/virt/virt_utils.py | 171 ++- 262 files changed, 23295 insertions(+), 17988 deletions(-) delete mode 100644 client/tests/kvm/autoit/notepad1.au3 delete mode 100644 client/tests/kvm/autotest_control/bonnie.control delete mode 100644 client/tests/kvm/autotest_control/cpu_hotplug.control delete mode 100644 client/tests/kvm/autotest_control/ctcs.control delete mode 100644 client/tests/kvm/autotest_control/dbench.control delete mode 100644 client/tests/kvm/autotest_control/disktest.control delete mode 100644 client/tests/kvm/autotest_control/ebizzy.control delete mode 100644 client/tests/kvm/autotest_control/flail.control delete mode 100644 client/tests/kvm/autotest_control/hackbench.control delete mode 100644 client/tests/kvm/autotest_control/hwclock.control delete mode 100644 client/tests/kvm/autotest_control/iozone.control delete mode 100644 client/tests/kvm/autotest_control/kernbench.control delete mode 100644 client/tests/kvm/autotest_control/monotonic_time.control delete mode 100644 client/tests/kvm/autotest_control/npb.control delete mode 100644 client/tests/kvm/autotest_control/rtc.control delete mode 100644 client/tests/kvm/autotest_control/scrashme.control delete mode 100644 client/tests/kvm/autotest_control/sleeptest.control delete mode 100644 client/tests/kvm/autotest_control/stress.control delete mode 100644 client/tests/kvm/autotest_control/systemtap.control delete mode 100644 client/tests/kvm/autotest_control/tsc.control delete mode 100644 client/tests/kvm/deps/Makefile delete mode 100644 client/tests/kvm/deps/finish.cpp delete mode 100644 client/tests/kvm/deps/finish.exe delete mode 100755 client/tests/kvm/deps/heartbeat_slu.py delete mode 100644 client/tests/kvm/deps/rss.cpp delete mode 100644 client/tests/kvm/deps/rss.exe delete mode 100644 client/tests/kvm/deps/rss.reg delete mode 100644 client/tests/kvm/deps/setuprss.bat delete mode 100644 client/tests/kvm/deps/test_clock_getres/Makefile delete mode 100644 client/tests/kvm/deps/test_clock_getres/test_clock_getres.c delete mode 100644 client/tests/kvm/deps/whql_delete_machine_15.cs delete mode 100644 client/tests/kvm/deps/whql_delete_machine_15.exe delete mode 100644 client/tests/kvm/deps/whql_submission_15.cs delete mode 100644 client/tests/kvm/deps/whql_submission_15.exe delete mode 100755 client/tests/kvm/scripts/ksm_overcommit_guest.py delete mode 100755 client/tests/kvm/scripts/multicast_guest.py delete mode 100755 client/tests/kvm/scripts/virtio_console_guest.py delete mode 100644 client/tests/kvm/steps/Belenix-0.7.1.steps delete mode 100644 client/tests/kvm/steps/CentOS5-64.steps delete mode 100644 client/tests/kvm/steps/DSL-4.2.5.steps delete mode 100644 client/tests/kvm/steps/Fedora-11-64.steps delete mode 100644 client/tests/kvm/steps/Fedora-8-64.steps delete mode 100644 client/tests/kvm/steps/Fedora-8-i386.steps delete mode 100644 client/tests/kvm/steps/Fedora-9-64.steps delete mode 100644 client/tests/kvm/steps/Fedora-9-i386.steps delete mode 100644 client/tests/kvm/steps/FreeSBIE-2.0.1.steps delete mode 100644 client/tests/kvm/steps/Mandriva-One-2007-32.steps delete mode 100644 client/tests/kvm/steps/NetBSD-1.6.2.steps delete mode 100644 client/tests/kvm/steps/OpenBSD-4.1-32.steps delete mode 100644 client/tests/kvm/steps/RHEL-3.9-i386.steps delete mode 100644 client/tests/kvm/steps/RHEL-3.9-x86_64.steps delete mode 100644 client/tests/kvm/steps/RHEL-4.7-i386.steps delete mode 100644 client/tests/kvm/steps/RHEL-4.7-x86_64.steps delete mode 100644 client/tests/kvm/steps/RHEL-5.3-i386.steps delete mode 100644 client/tests/kvm/steps/RHEL-5.3-x86_64.steps delete mode 100644 client/tests/kvm/steps/Slax-6.0.7.steps delete mode 100644 client/tests/kvm/steps/Ubuntu-6.10-32.steps delete mode 100644 client/tests/kvm/steps/Ubuntu-8.04-32-setupssh.steps delete mode 100644 client/tests/kvm/steps/Ubuntu-8.04-32.steps delete mode 100644 client/tests/kvm/steps/Ubuntu-8.04-server-32.steps delete mode 100644 client/tests/kvm/steps/Ubuntu-8.10-64.steps delete mode 100644 client/tests/kvm/steps/Ubuntu-8.10-server-32-gcc.steps delete mode 100644 client/tests/kvm/steps/Ubuntu-8.10-server-32.steps delete mode 100644 client/tests/kvm/steps/Win-Vista-32.steps delete mode 100644 client/tests/kvm/steps/Win-Vista-64.steps delete mode 100644 client/tests/kvm/steps/Win2000-32-rss.steps delete mode 100644 client/tests/kvm/steps/Win2000-32-setupssh.steps delete mode 100644 client/tests/kvm/steps/Win2000-32.steps delete mode 100644 client/tests/kvm/steps/Win2003-32-rss.steps delete mode 100644 client/tests/kvm/steps/Win2003-32-setupssh.steps delete mode 100644 client/tests/kvm/steps/Win2003-32.steps delete mode 100644 client/tests/kvm/steps/Win2003-64-rss.steps delete mode 100644 client/tests/kvm/steps/Win2003-64.steps delete mode 100644 client/tests/kvm/steps/Win2008-32-rss.steps delete mode 100644 client/tests/kvm/steps/Win2008-32-setupssh.steps delete mode 100644 client/tests/kvm/steps/Win2008-32-setuptelnet.steps delete mode 100644 client/tests/kvm/steps/Win2008-32.steps delete mode 100644 client/tests/kvm/steps/Win2008-64-rss.steps delete mode 100644 client/tests/kvm/steps/Win2008-64.steps delete mode 100644 client/tests/kvm/steps/Win7-64-rss.steps delete mode 100644 client/tests/kvm/steps/Win7-64.steps delete mode 100644 client/tests/kvm/steps/WinVista-32-rss.steps delete mode 100644 client/tests/kvm/steps/WinVista-64-rss.steps delete mode 100644 client/tests/kvm/steps/WinXP-32-rss.steps delete mode 100644 client/tests/kvm/steps/WinXP-32-setupssh.steps delete mode 100644 client/tests/kvm/steps/WinXP-32.steps delete mode 100644 client/tests/kvm/steps/WinXP-64-rss.steps delete mode 100644 client/tests/kvm/steps/WinXP-64.steps delete mode 100644 client/tests/kvm/steps/memtest86+.steps delete mode 100644 client/tests/kvm/steps/openSUSE-11.0-32.steps delete mode 100644 client/tests/kvm/steps/openSUSE-11.1-32-and-64.steps delete mode 100644 client/tests/kvm/tests/unattended_install.py delete mode 100644 client/tests/kvm/unattended/Fedora-10.ks delete mode 100644 client/tests/kvm/unattended/Fedora-11.ks delete mode 100644 client/tests/kvm/unattended/Fedora-12.ks delete mode 100644 client/tests/kvm/unattended/Fedora-13.ks delete mode 100644 client/tests/kvm/unattended/Fedora-14.ks delete mode 100644 client/tests/kvm/unattended/Fedora-15.ks delete mode 100644 client/tests/kvm/unattended/Fedora-8.ks delete mode 100644 client/tests/kvm/unattended/Fedora-9.ks delete mode 100644 client/tests/kvm/unattended/OpenSUSE-11.xml delete mode 100644 client/tests/kvm/unattended/RHEL-3-series.ks delete mode 100644 client/tests/kvm/unattended/RHEL-4-series.ks delete mode 100644 client/tests/kvm/unattended/RHEL-5-series.ks delete mode 100644 client/tests/kvm/unattended/RHEL-6-series.ks delete mode 100644 client/tests/kvm/unattended/SLES-11.xml delete mode 100644 client/tests/kvm/unattended/win2000-32.sif delete mode 100644 client/tests/kvm/unattended/win2003-32.sif delete mode 100644 client/tests/kvm/unattended/win2003-64.sif delete mode 100644 client/tests/kvm/unattended/win2008-32-autounattend.xml delete mode 100644 client/tests/kvm/unattended/win2008-64-autounattend.xml delete mode 100644 client/tests/kvm/unattended/win2008-r2-autounattend.xml delete mode 100644 client/tests/kvm/unattended/win7-32-autounattend.xml delete mode 100644 client/tests/kvm/unattended/win7-64-autounattend.xml delete mode 100644 client/tests/kvm/unattended/winnt.bat delete mode 100644 client/tests/kvm/unattended/winvista-32-autounattend.xml delete mode 100644 client/tests/kvm/unattended/winvista-64-autounattend.xml delete mode 100644 client/tests/kvm/unattended/winxp32.sif delete mode 100644 client/tests/kvm/unattended/winxp64.sif create mode 100644 client/tests/libvirt/README create mode 100644 client/tests/libvirt/cdkeys.cfg.sample create mode 100644 client/tests/libvirt/common.py create mode 100644 client/tests/libvirt/control create mode 100755 client/tests/libvirt/get_started.py create mode 100644 client/tests/libvirt/libvirt.py create mode 100644 client/tests/libvirt/tests.cfg.sample create mode 100644 client/tests/libvirt/tests_base.cfg.sample create mode 100644 client/tests/libvirt/virtio-win.cfg.sample create mode 100644 client/virt/autoit/notepad1.au3 create mode 100644 client/virt/autotest_control/bonnie.control create mode 100644 client/virt/autotest_control/cpu_hotplug.control create mode 100644 client/virt/autotest_control/ctcs.control create mode 100644 client/virt/autotest_control/dbench.control create mode 100644 client/virt/autotest_control/disktest.control create mode 100644 client/virt/autotest_control/ebizzy.control create mode 100644 client/virt/autotest_control/flail.control create mode 100644 client/virt/autotest_control/hackbench.control create mode 100644 client/virt/autotest_control/hwclock.control create mode 100644 client/virt/autotest_control/iozone.control create mode 100644 client/virt/autotest_control/kernbench.control create mode 100644 client/virt/autotest_control/monotonic_time.control create mode 100644 client/virt/autotest_control/npb.control create mode 100644 client/virt/autotest_control/rtc.control create mode 100644 client/virt/autotest_control/scrashme.control create mode 100644 client/virt/autotest_control/sleeptest.control create mode 100644 client/virt/autotest_control/stress.control create mode 100644 client/virt/autotest_control/systemtap.control create mode 100644 client/virt/autotest_control/tsc.control create mode 100644 client/virt/deps/Makefile create mode 100644 client/virt/deps/finish.cpp create mode 100644 client/virt/deps/finish.exe create mode 100755 client/virt/deps/heartbeat_slu.py create mode 100644 client/virt/deps/rss.cpp create mode 100644 client/virt/deps/rss.exe create mode 100644 client/virt/deps/rss.reg create mode 100644 client/virt/deps/setuprss.bat create mode 100644 client/virt/deps/test_clock_getres/Makefile create mode 100644 client/virt/deps/test_clock_getres/test_clock_getres.c create mode 100644 client/virt/deps/whql_delete_machine_15.cs create mode 100644 client/virt/deps/whql_delete_machine_15.exe create mode 100644 client/virt/deps/whql_submission_15.cs create mode 100644 client/virt/deps/whql_submission_15.exe create mode 100644 client/virt/libvirt_monitor.py create mode 100644 client/virt/libvirt_vm.py create mode 100755 client/virt/scripts/ksm_overcommit_guest.py create mode 100755 client/virt/scripts/multicast_guest.py create mode 100755 client/virt/scripts/virtio_console_guest.py create mode 100644 client/virt/steps/Belenix-0.7.1.steps create mode 100644 client/virt/steps/CentOS5-64.steps create mode 100644 client/virt/steps/DSL-4.2.5.steps create mode 100644 client/virt/steps/Fedora-11-64.steps create mode 100644 client/virt/steps/Fedora-8-64.steps create mode 100644 client/virt/steps/Fedora-8-i386.steps create mode 100644 client/virt/steps/Fedora-9-64.steps create mode 100644 client/virt/steps/Fedora-9-i386.steps create mode 100644 client/virt/steps/FreeSBIE-2.0.1.steps create mode 100644 client/virt/steps/Mandriva-One-2007-32.steps create mode 100644 client/virt/steps/NetBSD-1.6.2.steps create mode 100644 client/virt/steps/OpenBSD-4.1-32.steps create mode 100644 client/virt/steps/RHEL-3.9-i386.steps create mode 100644 client/virt/steps/RHEL-3.9-x86_64.steps create mode 100644 client/virt/steps/RHEL-4.7-i386.steps create mode 100644 client/virt/steps/RHEL-4.7-x86_64.steps create mode 100644 client/virt/steps/RHEL-5.3-i386.steps create mode 100644 client/virt/steps/RHEL-5.3-x86_64.steps create mode 100644 client/virt/steps/Slax-6.0.7.steps create mode 100644 client/virt/steps/Ubuntu-6.10-32.steps create mode 100644 client/virt/steps/Ubuntu-8.04-32-setupssh.steps create mode 100644 client/virt/steps/Ubuntu-8.04-32.steps create mode 100644 client/virt/steps/Ubuntu-8.04-server-32.steps create mode 100644 client/virt/steps/Ubuntu-8.10-64.steps create mode 100644 client/virt/steps/Ubuntu-8.10-server-32-gcc.steps create mode 100644 client/virt/steps/Ubuntu-8.10-server-32.steps create mode 100644 client/virt/steps/Win-Vista-32.steps create mode 100644 client/virt/steps/Win-Vista-64.steps create mode 100644 client/virt/steps/Win2000-32-rss.steps create mode 100644 client/virt/steps/Win2000-32-setupssh.steps create mode 100644 client/virt/steps/Win2000-32.steps create mode 100644 client/virt/steps/Win2003-32-rss.steps create mode 100644 client/virt/steps/Win2003-32-setupssh.steps create mode 100644 client/virt/steps/Win2003-32.steps create mode 100644 client/virt/steps/Win2003-64-rss.steps create mode 100644 client/virt/steps/Win2003-64.steps create mode 100644 client/virt/steps/Win2008-32-rss.steps create mode 100644 client/virt/steps/Win2008-32-setupssh.steps create mode 100644 client/virt/steps/Win2008-32-setuptelnet.steps create mode 100644 client/virt/steps/Win2008-32.steps create mode 100644 client/virt/steps/Win2008-64-rss.steps create mode 100644 client/virt/steps/Win2008-64.steps create mode 100644 client/virt/steps/Win7-64-rss.steps create mode 100644 client/virt/steps/Win7-64.steps create mode 100644 client/virt/steps/WinVista-32-rss.steps create mode 100644 client/virt/steps/WinVista-64-rss.steps create mode 100644 client/virt/steps/WinXP-32-rss.steps create mode 100644 client/virt/steps/WinXP-32-setupssh.steps create mode 100644 client/virt/steps/WinXP-32.steps create mode 100644 client/virt/steps/WinXP-64-rss.steps create mode 100644 client/virt/steps/WinXP-64.steps create mode 100644 client/virt/steps/memtest86+.steps create mode 100644 client/virt/steps/openSUSE-11.0-32.steps create mode 100644 client/virt/steps/openSUSE-11.1-32-and-64.steps create mode 100644 client/virt/tests/unattended_install.py create mode 100644 client/virt/unattended/Fedora-10.ks create mode 100644 client/virt/unattended/Fedora-11.ks create mode 100644 client/virt/unattended/Fedora-12.ks create mode 100644 client/virt/unattended/Fedora-13.ks create mode 100644 client/virt/unattended/Fedora-14.ks create mode 100644 client/virt/unattended/Fedora-15.ks create mode 100644 client/virt/unattended/Fedora-8.ks create mode 100644 client/virt/unattended/Fedora-9.ks create mode 100644 client/virt/unattended/OpenSUSE-11.xml create mode 100644 client/virt/unattended/RHEL-3-series.ks create mode 100644 client/virt/unattended/RHEL-4-series.ks create mode 100644 client/virt/unattended/RHEL-5-series.ks create mode 100644 client/virt/unattended/RHEL-6-series.ks create mode 100644 client/virt/unattended/SLES-11.xml create mode 100644 client/virt/unattended/win2000-32.sif create mode 100644 client/virt/unattended/win2003-32.sif create mode 100644 client/virt/unattended/win2003-64.sif create mode 100644 client/virt/unattended/win2008-32-autounattend.xml create mode 100644 client/virt/unattended/win2008-64-autounattend.xml create mode 100644 client/virt/unattended/win2008-r2-autounattend.xml create mode 100644 client/virt/unattended/win7-32-autounattend.xml create mode 100644 client/virt/unattended/win7-64-autounattend.xml create mode 100644 client/virt/unattended/winnt.bat create mode 100644 client/virt/unattended/winvista-32-autounattend.xml create mode 100644 client/virt/unattended/winvista-64-autounattend.xml create mode 100644 client/virt/unattended/winxp32.sif create mode 100644 client/virt/unattended/winxp64.sif create mode 100644 client/virt/virt_http_server.py create mode 100644 client/virt/virt_test.py
Signature · 1 line
1.7.6.4
PATCH 2/11 virt: Introducing virt_test.virt_test class
During the process of implementing the libvirt test, we've noticed that the whole mechanism implemented by the KVM test (subtest loader, use of env file, params) could be turned into common infrastructure. So move all implementation to a class called virt_test.
We believe most virt test classes don't even need to be implemented with this common infrastructure in place.
--- client/tests/kvm/kvm.py | 126 +------------------------------------------- client/virt/virt_test.py | 131 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+), 123 deletions(-) create mode 100644 client/virt/virt_test.py
client/tests/kvm/kvm.py +3 -123
@@ -1,10 +1,7 @@ -import os, logging, imp, sys -from autotest_lib.client.bin import test -from autotest_lib.client.common_lib import error -from autotest_lib.client.virt import virt_utils, virt_env_process +from autotest_lib.client.virt import virt_test -class kvm(test.test): +class kvm(virt_test.virt_test): """ Suite of KVM virtualization functional tests. Contains tests for testing both KVM kernel code and userspace code.
@@ -20,121 +17,4 @@ class kvm(test.test): @see: http://www.linux-kvm.org/page/KVM-Autotest/Client_Install (Online doc - Getting started with KVM testing) """ - version = 1 - env_version = 1 - - - def initialize(self, params): - # Change the value of the preserve_srcdir attribute according to - # the value present on the configuration file (defaults to yes) - if params.get("preserve_srcdir", "yes") == "yes": - self.preserve_srcdir = True - dirname = os.path.dirname(sys.modules[__name__].__file__) - clientdir = os.path.abspath(os.path.join(dirname, "..", "..")) - self.virtdir = os.path.join(clientdir, "virt") - - - def run_once(self, params): - # Convert params to a Params object - params = virt_utils.Params(params) - - # If a dependency test prior to this test has failed, let's fail - # it right away as TestNA. - if params.get("dependency_failed") == 'yes': - raise error.TestNAError("Test dependency failed") - - # Report the parameters we've received and write them as keyvals - logging.debug("Test parameters:") - keys = params.keys() - keys.sort() - for key in keys: - logging.debug(" %s = %s", key, params[key]) - self.write_test_keyval({key: params[key]}) - - # Set the log file dir for the logging mechanism used by kvm_subprocess - # (this must be done before unpickling env) - virt_utils.set_log_file_dir(self.debugdir) - - # Open the environment file - env_filename = os.path.join(self.bindir, params.get("env", "env")) - env = virt_utils.Env(env_filename, self.env_version) - - test_passed = False - - try: - try: - try: - # Get the test routine corresponding to the specified - # test type - t_type = params.get("type") - # Verify if we have the correspondent source file for it - virt_dir = os.path.dirname(virt_utils.__file__) - subtest_dir_virt = os.path.join(virt_dir, "tests") - subtest_dir_kvm = os.path.join(self.bindir, "tests") - subtest_dir = None - for d in [subtest_dir_kvm, subtest_dir_virt]: - module_path = os.path.join(d, "%s.py" % t_type) - if os.path.isfile(module_path): - subtest_dir = d - break - if subtest_dir is None: - raise error.TestError("Could not find test file %s.py " - "on either %s or %s directory" % - (t_type, subtest_dir_kvm, - subtest_dir_virt)) - # Load the test module - f, p, d = imp.find_module(t_type, [subtest_dir]) - test_module = imp.load_module(t_type, f, p, d) - f.close() - - # Preprocess - try: - virt_env_process.preprocess(self, params, env) - finally: - env.save() - # Run the test function - run_func = getattr(test_module, "run_%s" % t_type) - try: - run_func(self, params, env) - finally: - env.save() - test_passed = True - - except Exception, e: - logging.error("Test failed: %s: %s", - e.__class__.__name__, e) - try: - virt_env_process.postprocess_on_error( - self, params, env) - finally: - env.save() - raise - - finally: - # Postprocess - try: - try: - virt_env_process.postprocess(self, params, env) - except Exception, e: - if test_passed: - raise - logging.error("Exception raised during " - "postprocessing: %s", e) - finally: - env.save() - - except Exception, e: - if params.get("abort_on_error") != "yes": - raise - # Abort on error - logging.info("Aborting job (%s)", e) - for vm in env.get_all_vms(): - if vm.is_dead(): - continue - logging.info("VM '%s' is alive.", vm.name) - for m in vm.monitors: - logging.info("'%s' has a %s monitor unix socket at: %s", - vm.name, m.protocol, m.filename) - logging.info("The command line used to start '%s' was:\n%s", - vm.name, vm.make_qemu_command()) - raise error.JobError("Abort requested (%s)" % e) + pass
client/virt/virt_test.py new file +131 -0
131 lines not on this page · raw message
Signature · 1 line
1.7.6.4
PATCH 3/11 Moving unattended_install test from kvm test to common virt location
In reply to Lucas Meneghel Rodrigues--- client/tests/kvm/tests/unattended_install.py | 632 -------------------------- client/virt/tests/unattended_install.py | 632 ++++++++++++++++++++++++++ 2 files changed, 632 insertions(+), 632 deletions(-) delete mode 100644 client/tests/kvm/tests/unattended_install.py create mode 100644 client/virt/tests/unattended_install.py
client/tests/kvm/tests/unattended_install.py deleted +0 -632
@@ -1,632 +0,0 @@ -import logging, time, socket, re, os, shutil, tempfile, glob, ConfigParser -import xml.dom.minidom -from autotest_lib.client.common_lib import error -from autotest_lib.client.bin import utils -from autotest_lib.client.virt import virt_vm, virt_utils - - [email protected]_aware -def cleanup(dir): - """ - If dir is a mountpoint, do what is possible to unmount it. Afterwards, - try to remove it. - - @param dir: Directory to be cleaned up. - """ - error.context("cleaning up unattended install directory %s" % dir) - if os.path.ismount(dir): - utils.run('fuser -k %s' % dir, ignore_status=True) - utils.run('umount %s' % dir) - if os.path.isdir(dir): - shutil.rmtree(dir) - - [email protected]_aware -def clean_old_image(image): - """ - Clean a leftover image file from previous processes. If it contains a - mounted file system, do the proper cleanup procedures. - - @param image: Path to image to be cleaned up. - """ - error.context("cleaning up old leftover image %s" % image) - if os.path.exists(image): - mtab = open('/etc/mtab', 'r') - mtab_contents = mtab.read() - mtab.close() - if image in mtab_contents: - utils.run('fuser -k %s' % image, ignore_status=True) - utils.run('umount %s' % image) - os.remove(image) - - -class Disk(object): - """ - Abstract class for Disk objects, with the common methods implemented. - """ - def __init__(self): - self.path = None - - - def get_answer_file_path(self, filename): - return os.path.join(self.mount, filename) - - - def copy_to(self, src): - logging.debug("Copying %s to disk image mount", src) - dst = os.path.join(self.mount, os.path.basename(src)) - if os.path.isdir(src): - shutil.copytree(src, dst) - elif os.path.isfile(src): - shutil.copyfile(src, dst) - - - def close(self): - os.chmod(self.path, 0755) - cleanup(self.mount) - logging.debug("Disk %s successfuly set", self.path) - - -class FloppyDisk(Disk): - """ - Represents a 1.44 MB floppy disk. We can copy files to it, and setup it in - convenient ways. - """ - @error.context_aware - def __init__(self, path, qemu_img_binary, tmpdir): - error.context("Creating unattended install floppy image %s" % path) - self.tmpdir = tmpdir - self.mount = tempfile.mkdtemp(prefix='floppy_', dir=self.tmpdir) - self.virtio_mount = None - self.path = path - clean_old_image(path) - if not os.path.isdir(os.path.dirname(path)): - os.makedirs(os.path.dirname(path)) - - try: - c_cmd = '%s create -f raw %s 1440k' % (qemu_img_binary, path) - utils.run(c_cmd) - f_cmd = 'mkfs.msdos -s 1 %s' % path - utils.run(f_cmd) - m_cmd = 'mount -o loop,rw %s %s' % (path, self.mount) - utils.run(m_cmd) - except error.CmdError, e: - logging.error("Error during floppy initialization: %s" % e) - cleanup(self.mount) - raise - - - def _copy_virtio_drivers(self, virtio_floppy): - """ - Copy the virtio drivers on the virtio floppy to the install floppy. - - 1) Mount the floppy containing the viostor drivers - 2) Copy its contents to the root of the install floppy - """ - virtio_mount = tempfile.mkdtemp(prefix='virtio_floppy_', - dir=self.tmpdir) - - pwd = os.getcwd() - try: - m_cmd = 'mount -o loop,ro %s %s' % (virtio_floppy, virtio_mount) - utils.run(m_cmd) - os.chdir(virtio_mount) - path_list = glob.glob('*') - for path in path_list: - self.copy_to(path) - finally: - os.chdir(pwd) - cleanup(virtio_mount) - - - def setup_virtio_win2003(self, virtio_floppy, virtio_oemsetup_id): - """ - Setup the install floppy with the virtio storage drivers, win2003 style. - - Win2003 and WinXP depend on the file txtsetup.oem file to install - the virtio drivers from the floppy, which is a .ini file. - Process: - - 1) Copy the virtio drivers on the virtio floppy to the install floppy - 2) Parse the ini file with config parser - 3) Modify the identifier of the default session that is going to be - executed on the config parser object - 4) Re-write the config file to the disk - """ - self._copy_virtio_drivers(virtio_floppy) - txtsetup_oem = os.path.join(self.mount, 'txtsetup.oem') - if not os.path.isfile(txtsetup_oem): - raise IOError('File txtsetup.oem not found on the install ' - 'floppy. Please verify if your floppy virtio ' - 'driver image has this file') - parser = ConfigParser.ConfigParser() - parser.read(txtsetup_oem) - if not parser.has_section('Defaults'): - raise ValueError('File txtsetup.oem does not have the session ' - '"Defaults". Please check txtsetup.oem') - default_driver = parser.get('Defaults', 'SCSI') - if default_driver != virtio_oemsetup_id: - parser.set('Defaults', 'SCSI', virtio_oemsetup_id) - fp = open(txtsetup_oem, 'w') - parser.write(fp) - fp.close() - - - def setup_virtio_win2008(self, virtio_floppy): - """ - Setup the install floppy with the virtio storage drivers, win2008 style. - - Win2008, Vista and 7 require people to point out the path to the drivers - on the unattended file, so we just need to copy the drivers to the - driver floppy disk. Important to note that it's possible to specify - drivers from a CDROM, so the floppy driver copy is optional. - Process: - - 1) Copy the virtio drivers on the virtio floppy to the install floppy, - if there is one available - """ - if os.path.isfile(virtio_floppy): - self._copy_virtio_drivers(virtio_floppy) - else: - logging.debug("No virtio floppy present, not needed for this OS anyway") - - -class CdromDisk(Disk): - """ - Represents a CDROM disk that we can master according to our needs. - """ - def __init__(self, path, tmpdir): - self.mount = tempfile.mkdtemp(prefix='cdrom_unattended_', dir=tmpdir) - self.path = path - clean_old_image(path) - if not os.path.isdir(os.path.dirname(path)): - os.makedirs(os.path.dirname(path)) - - - @error.context_aware - def close(self): - error.context("Creating unattended install CD image %s" % self.path) - g_cmd = ('mkisofs -o %s -max-iso9660-filenames ' - '-relaxed-filenames -D --input-charset iso8859-1 ' - '%s' % (self.path, self.mount)) - utils.run(g_cmd) - - os.chmod(self.path, 0755) - cleanup(self.mount) - logging.debug("unattended install CD image %s successfuly created", - self.path) - - -class UnattendedInstallConfig(object): - """ - Creates a floppy disk image that will contain a config file for unattended - OS install. The parameters to the script are retrieved from environment - variables. - """ - def __init__(self, test, params): - """ - Sets class atributes from test parameters. - - @param test: KVM test object. - @param params: Dictionary with test parameters. - """ - root_dir = test.bindir - self.deps_dir = os.path.join(test.virtdir, 'deps') - self.unattended_dir = os.path.join(test.virtdir, 'unattended') - - attributes = ['kernel_args', 'finish_program', 'cdrom_cd1', - 'unattended_file', 'medium', 'url', 'kernel', 'initrd', - 'nfs_server', 'nfs_dir', 'install_virtio', 'floppy', - 'cdrom_unattended', 'boot_path', 'extra_params', - 'qemu_img_binary', 'cdkey', 'finish_program'] - - for a in attributes: - setattr(self, a, params.get(a, '')) - - if self.install_virtio == 'yes': - v_attributes = ['virtio_floppy', 'virtio_storage_path', - 'virtio_network_path', 'virtio_oemsetup_id', - 'virtio_network_installer'] - for va in v_attributes: - setattr(self, va, params.get(va, '')) - - self.tmpdir = test.tmpdir - - if getattr(self, 'unattended_file'): - self.unattended_file = os.path.join(test.virtdir, self.unattended_file) - - if getattr(self, 'finish_program'): - self.finish_program = os.path.join(test.virtdir, self.finish_program) - - if getattr(self, 'qemu_img_binary'): - if not os.path.isfile(getattr(self, 'qemu_img_binary')): - self.qemu_img_binary = os.path.join(root_dir, - self.qemu_img_binary) - - if getattr(self, 'cdrom_cd1'): - self.cdrom_cd1 = os.path.join(root_dir, self.cdrom_cd1) - self.cdrom_cd1_mount = tempfile.mkdtemp(prefix='cdrom_cd1_', - dir=self.tmpdir) - if self.medium == 'nfs': - self.nfs_mount = tempfile.mkdtemp(prefix='nfs_', - dir=self.tmpdir) - - if getattr(self, 'floppy'): - self.floppy = os.path.join(root_dir, self.floppy) - if not os.path.isdir(os.path.dirname(self.floppy)): - os.makedirs(os.path.dirname(self.floppy)) - - self.image_path = os.path.dirname(self.kernel) - - - def answer_kickstart(self, answer_path): - """ - Replace KVM_TEST_CDKEY (in the unattended file) with the cdkey - provided for this test and replace the KVM_TEST_MEDIUM with - the tree url or nfs address provided for this test. - - @return: Answer file contents - """ - contents = open(self.unattended_file).read() - - dummy_cdkey_re = r'\bKVM_TEST_CDKEY\b' - if re.search(dummy_cdkey_re, contents): - if self.cdkey: - contents = re.sub(dummy_cdkey_re, self.cdkey, contents) - - dummy_medium_re = r'\bKVM_TEST_MEDIUM\b' - if self.medium == "cdrom": - content = "cdrom" - elif self.medium == "url": - content = "url --url %s" % self.url - elif self.medium == "nfs": - content = "nfs --server=%s --dir=%s" % (self.nfs_server, - self.nfs_dir) - else: - raise ValueError("Unexpected installation medium %s" % self.url) - - contents = re.sub(dummy_medium_re, content, contents) - - logging.debug("Unattended install contents:") - for line in contents.splitlines(): - logging.debug(line) - - utils.open_write_close(answer_path, contents) - - - def answer_windows_ini(self, answer_path): - parser = ConfigParser.ConfigParser() - parser.read(self.unattended_file) - # First, replacing the CDKEY - if self.cdkey: - parser.set('UserData', 'ProductKey', self.cdkey) - else: - logging.error("Param 'cdkey' required but not specified for " - "this unattended installation") - - # Now, replacing the virtio network driver path, under double quotes - if self.install_virtio == 'yes': - parser.set('Unattended', 'OemPnPDriversPath', - '"%s"' % self.virtio_nework_path) - else: - parser.remove_option('Unattended', 'OemPnPDriversPath') - - # Last, replace the virtio installer command - if self.install_virtio == 'yes': - driver = self.virtio_network_installer_path - else: - driver = 'dir' - - dummy_re = 'KVM_TEST_VIRTIO_NETWORK_INSTALLER' - installer = parser.get('GuiRunOnce', 'Command0') - if dummy_re in installer: - installer = re.sub(dummy_re, driver, installer) - parser.set('GuiRunOnce', 'Command0', installer) - - # Now, writing the in memory config state to the unattended file - fp = open(answer_path, 'w') - parser.write(fp) - - # Let's read it so we can debug print the contents - fp = open(answer_path, 'r') - contents = fp.read() - logging.debug("Unattended install contents:") - for line in contents.splitlines(): - logging.debug(line) - fp.close() - - - def answer_windows_xml(self, answer_path): - doc = xml.dom.minidom.parse(self.unattended_file) - - if self.cdkey: - # First, replacing the CDKEY - product_key = doc.getElementsByTagName('ProductKey')[0] - key = product_key.getElementsByTagName('Key')[0] - key_text = key.childNodes[0] - assert key_text.nodeType == doc.TEXT_NODE - key_text.data = self.cdkey - else: - logging.error("Param 'cdkey' required but not specified for " - "this unattended installation") - - # Now, replacing the virtio driver paths or removing the entire - # component PnpCustomizationsWinPE Element Node - if self.install_virtio == 'yes': - paths = doc.getElementsByTagName("Path") - values = [self.virtio_storage_path, self.virtio_network_path] - for path, value in zip(paths, values): - path_text = path.childNodes[0] - assert key_text.nodeType == doc.TEXT_NODE - path_text.data = value - else: - settings = doc.getElementsByTagName("settings") - for s in settings: - for c in s.getElementsByTagName("component"): - if (c.getAttribute('name') == - "Microsoft-Windows-PnpCustomizationsWinPE"): - s.removeChild(c) - - # Last but not least important, replacing the virtio installer command - command_lines = doc.getElementsByTagName("CommandLine") - for command_line in command_lines: - command_line_text = command_line.childNodes[0] - assert command_line_text.nodeType == doc.TEXT_NODE - dummy_re = 'KVM_TEST_VIRTIO_NETWORK_INSTALLER' - if (self.install_virtio == 'yes' and - hasattr(self, 'virtio_network_installer_path')): - driver = self.virtio_network_installer_path - else: - driver = 'dir' - if driver.endswith("msi"): - driver = 'msiexec /passive /package ' + driver - if dummy_re in command_line_text.data: - t = command_line_text.data - t = re.sub(dummy_re, driver, t) - command_line_text.data = t - - contents = doc.toxml() - logging.debug("Unattended install contents:") - for line in contents.splitlines(): - logging.debug(line) - - fp = open(answer_path, 'w') - doc.writexml(fp) - - - def answer_suse_xml(self, answer_path): - # There's nothing to replace on SUSE files to date. Yay! - doc = xml.dom.minidom.parse(self.unattended_file) - - contents = doc.toxml() - logging.debug("Unattended install contents:") - for line in contents.splitlines(): - logging.debug(line) - - fp = open(answer_path, 'w') - doc.writexml(fp) - - - def setup_boot_disk(self): - if self.unattended_file.endswith('.sif'): - dest_fname = 'winnt.sif' - setup_file = 'winnt.bat' - boot_disk = FloppyDisk(self.floppy, self.qemu_img_binary, - self.tmpdir) - answer_path = boot_disk.get_answer_file_path(dest_fname) - self.answer_windows_ini(answer_path) - setup_file_path = os.path.join(self.unattended_dir, setup_file) - boot_disk.copy_to(setup_file_path) - if self.install_virtio == "yes": - boot_disk.setup_virtio_win2003(self.virtio_floppy, - self.virtio_oemsetup_id) - boot_disk.copy_to(self.finish_program) - - elif self.unattended_file.endswith('.ks'): - # Red Hat kickstart install - dest_fname = 'ks.cfg' - if self.cdrom_unattended: - boot_disk = CdromDisk(self.cdrom_unattended, self.tmpdir) - elif self.floppy: - boot_disk = FloppyDisk(self.floppy, self.qemu_img_binary, - self.tmpdir) - else: - raise ValueError("Neither cdrom_unattended nor floppy set " - "on the config file, please verify") - answer_path = boot_disk.get_answer_file_path(dest_fname) - self.answer_kickstart(answer_path) - - elif self.unattended_file.endswith('.xml'): - if "autoyast" in self.extra_params: - # SUSE autoyast install - dest_fname = "autoinst.xml" - if self.cdrom_unattended: - boot_disk = CdromDisk(self.cdrom_unattended, self.tmpdir) - elif self.floppy: - boot_disk = FloppyDisk(self.floppy, self.qemu_img_binary, - self.tmpdir) - else: - raise ValueError("Neither cdrom_unattended nor floppy set " - "on the config file, please verify") - answer_path = boot_disk.get_answer_file_path(dest_fname) - self.answer_suse_xml(answer_path) - - else: - # Windows unattended install - dest_fname = "autounattend.xml" - boot_disk = FloppyDisk(self.floppy, self.qemu_img_binary, - self.tmpdir) - answer_path = boot_disk.get_answer_file_path(dest_fname) - self.answer_windows_xml(answer_path) - - if self.install_virtio == "yes": - boot_disk.setup_virtio_win2008(self.virtio_floppy) - boot_disk.copy_to(self.finish_program) - - else: - raise ValueError('Unknown answer file type: %s' % - self.unattended_file) - - boot_disk.close() - - - @error.context_aware - def setup_cdrom(self): - """ - Mount cdrom and copy vmlinuz and initrd.img. - """ - error.context("Copying vmlinuz and initrd.img from install cdrom %s" % - self.cdrom_cd1) - m_cmd = ('mount -t iso9660 -v -o loop,ro %s %s' % - (self.cdrom_cd1, self.cdrom_cd1_mount)) - utils.run(m_cmd) - - try: - if not os.path.isdir(self.image_path): - os.makedirs(self.image_path) - kernel_fetch_cmd = ("cp %s/%s/%s %s" % - (self.cdrom_cd1_mount, self.boot_path, - os.path.basename(self.kernel), self.kernel)) - utils.run(kernel_fetch_cmd) - initrd_fetch_cmd = ("cp %s/%s/%s %s" % - (self.cdrom_cd1_mount, self.boot_path, - os.path.basename(self.initrd), self.initrd)) - utils.run(initrd_fetch_cmd) - finally: - cleanup(self.cdrom_cd1_mount) - - - @error.context_aware - def setup_url(self): - """ - Download the vmlinuz and initrd.img from URL. - """ - error.context("downloading vmlinuz and initrd.img from %s" % self.url) - os.chdir(self.image_path) - kernel_fetch_cmd = "wget -q %s/%s/%s" % (self.url, self.boot_path, - os.path.basename(self.kernel)) - initrd_fetch_cmd = "wget -q %s/%s/%s" % (self.url, self.boot_path, - os.path.basename(self.initrd)) - - if os.path.exists(self.kernel): - os.remove(self.kernel) - if os.path.exists(self.initrd): - os.remove(self.initrd) - - utils.run(kernel_fetch_cmd) - utils.run(initrd_fetch_cmd) - - - def setup_nfs(self): - """ - Copy the vmlinuz and initrd.img from nfs. - """ - error.context("copying the vmlinuz and initrd.img from NFS share") - - m_cmd = ("mount %s:%s %s -o ro" % - (self.nfs_server, self.nfs_dir, self.nfs_mount)) - utils.run(m_cmd) - - try: - kernel_fetch_cmd = ("cp %s/%s/%s %s" % - (self.nfs_mount, self.boot_path, - os.path.basename(self.kernel), self.image_path)) - utils.run(kernel_fetch_cmd) - initrd_fetch_cmd = ("cp %s/%s/%s %s" % - (self.nfs_mount, self.boot_path, - os.path.basename(self.initrd), self.image_path)) - utils.run(initrd_fetch_cmd) - finally: - cleanup(self.nfs_mount) - - - def setup(self): - """ - Configure the environment for unattended install. - - Uses an appropriate strategy according to each install model. - """ - logging.info("Starting unattended install setup") - virt_utils.display_attributes(self) - - if self.unattended_file and (self.floppy or self.cdrom_unattended): - self.setup_boot_disk() - if self.medium == "cdrom": - if self.kernel and self.initrd: - self.setup_cdrom() - elif self.medium == "url": - self.setup_url() - elif self.medium == "nfs": - self.setup_nfs() - else: - raise ValueError("Unexpected installation method %s" % - self.medium) - - [email protected]_aware -def run_unattended_install(test, params, env): - """ - Unattended install test: - 1) Starts a VM with an appropriated setup to start an unattended OS install. - 2) Wait until the install reports to the install watcher its end. - - @param test: KVM test object. - @param params: Dictionary with the test parameters. - @param env: Dictionary with test environment. - """ - unattended_install_config = UnattendedInstallConfig(test, params) - unattended_install_config.setup() - vm = env.get_vm(params["main_vm"]) - vm.create() - - install_timeout = int(params.get("timeout", 3000)) - port = vm.get_port(int(params.get("guest_port_unattended_install"))) - - migrate_background = params.get("migrate_background") == "yes" - if migrate_background: - mig_timeout = float(params.get("mig_timeout", "3600")) - mig_protocol = params.get("migration_protocol", "tcp") - - logging.info("Waiting for installation to finish. Timeout set to %d s " - "(%d min)", install_timeout, install_timeout/60) - error.context("waiting for installation to finish") - - start_time = time.time() - while (time.time() - start_time) < install_timeout: - try: - vm.verify_alive() - except virt_vm.VMDeadError, e: - if params.get("wait_no_ack", "no") == "yes": - break - else: - raise e - vm.verify_kernel_crash() - if params.get("wait_no_ack", "no") == "no": - client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - try: - client.connect((vm.get_address(), port)) - if client.recv(1024) == "done": - break - except (socket.error, virt_vm.VMAddressError): - pass - - if migrate_background: - vm.migrate(timeout=mig_timeout, protocol=mig_protocol) - else: - time.sleep(1) - if params.get("wait_no_ack", "no") == "no": - client.close() - else: - raise error.TestFail("Timeout elapsed while waiting for install to " - "finish") - - time_elapsed = time.time() - start_time - logging.info("Guest reported successful installation after %d s (%d min)", - time_elapsed, time_elapsed/60) - - if params.get("shutdown_cleanly", "yes") == "yes": - shutdown_cleanly_timeout = int(params.get("shutdown_cleanly_timeout", - 120)) - logging.info("Wait for guest to shutdown cleanly") - if virt_utils.wait_for(vm.is_dead, shutdown_cleanly_timeout, 1, 1): - logging.info("Guest managed to shutdown cleanly")
client/virt/tests/unattended_install.py new file +632 -0
632 lines not on this page · raw message
Signature · 1 line
1.7.6.4
PATCH 4/11 Moving get_started code to client.virt.virt_utils
In reply to Lucas Meneghel RodriguesAs most of the get_started.py code could be very well shared among virt tests, moved the bulk of the code to virt_utils.py. Now we have the function virt_test_assistant(), that is generic enough so other tests can implement their variation of the assistant script.
--- client/tests/kvm/get_started.py | 162 +++---------------------------------- client/virt/virt_utils.py | 171 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 181 insertions(+), 152 deletions(-)
client/tests/kvm/get_started.py +11 -151
@@ -4,159 +4,19 @@ Program to help setup kvm test environment @copyright: Red Hat 2010 """ - -import os, sys, logging, shutil, glob +import os, sys import common -from autotest_lib.client.common_lib import logging_manager -from autotest_lib.client.bin import utils from autotest_lib.client.virt import virt_utils - -def check_iso(url, destination, hash): - """ - Verifies if ISO that can be find on url is on destination with right hash. - - This function will verify the SHA1 hash of the ISO image. If the file - turns out to be missing or corrupted, let the user know we can download it. - - @param url: URL where the ISO file can be found. - @param destination: Directory in local disk where we'd like the iso to be. - @param hash: SHA1 hash for the ISO image. - """ - file_ok = False - if not destination: - os.makedirs(destination) - iso_path = os.path.join(destination, os.path.basename(url)) - if not os.path.isfile(iso_path): - logging.warning("File %s not found", iso_path) - logging.warning("Expected SHA1 sum: %s", hash) - answer = utils.ask("Would you like to download it from %s?" % url) - if answer == 'y': - try: - utils.unmap_url_cache(destination, url, hash, method="sha1") - file_ok = True - except EnvironmentError, e: - logging.error(e) - else: - logging.warning("Missing file %s", iso_path) - logging.warning("Please download it or put an exsiting copy on the " - "appropriate location") - return - else: - logging.info("Found %s", iso_path) - logging.info("Expected SHA1 sum: %s", hash) - answer = utils.ask("Would you like to check %s? It might take a while" % - iso_path) - if answer == 'y': - try: - utils.unmap_url_cache(destination, url, hash, method="sha1") - file_ok = True - except EnvironmentError, e: - logging.error(e) - else: - logging.info("File %s present, but chose to not verify it", - iso_path) - return - - if file_ok: - logging.info("%s present, with proper checksum", iso_path) - +test_name = "kvm" +test_dir = os.path.dirname(sys.modules[__name__].__file__) +test_dir = os.path.abspath(test_dir) +base_dir = "/tmp/kvm_autotest_root" +default_userspace_paths = ["/usr/bin/qemu-kvm", "/usr/bin/qemu-img"] +check_modules = ["kvm", "kvm-%s" % virt_utils.get_cpu_vendor(verbose=False)] +online_docs_url = "https://github.com/autotest/autotest/wiki/KVMAutotest-GetStartedClient" if __name__ == "__main__": - logging_manager.configure_logging(virt_utils.VirtLoggingConfig(), - verbose=True) - logging.info("KVM test config helper") - - logging.info("") - logging.info("1 - Verifying directories (check if the directory structure " - "expected by the default test config is there)") - base_dir = "/tmp/kvm_autotest_root" - sub_dir_list = ["images", "isos", "steps_data"] - for sub_dir in sub_dir_list: - sub_dir_path = os.path.join(base_dir, sub_dir) - if not os.path.isdir(sub_dir_path): - logging.debug("Creating %s", sub_dir_path) - os.makedirs(sub_dir_path) - else: - logging.debug("Dir %s exists, not creating" % - sub_dir_path) - logging.info("") - logging.info("2 - Creating config files from samples (copy the default " - "config samples to actual config files)") - kvm_test_dir = os.path.dirname(sys.modules[__name__].__file__) - kvm_test_dir = os.path.abspath(kvm_test_dir) - config_file_list = glob.glob(os.path.join(kvm_test_dir, "*.cfg.sample")) - for config_file in config_file_list: - src_file = config_file - dst_file = config_file.rstrip(".sample") - if not os.path.isfile(dst_file): - logging.debug("Creating config file %s from sample", dst_file) - shutil.copyfile(src_file, dst_file) - else: - logging.debug("Config file %s exists, not touching" % dst_file) - - logging.info("") - logging.info("3 - Verifying iso (make sure we have the OS ISO needed for " - "the default test set)") - - iso_name = "Fedora-15-x86_64-DVD.iso" - fedora_dir = "pub/fedora/linux/releases/15/Fedora/x86_64/iso" - url = os.path.join("http://download.fedoraproject.org/", fedora_dir, - iso_name) - hash = "61b3407f62bac22d3a3b2e919c7fc960116012d7" - destination = os.path.join(base_dir, 'isos', 'linux') - path = os.path.join(destination, iso_name) - check_iso(url, destination, hash) - - logging.info("") - logging.info("4 - Verifying winutils.iso (make sure we have the utility " - "ISO needed for Windows testing)") - - logging.info("In order to run the KVM autotests in Windows guests, we " - "provide you an ISO that this script can download") - - url = "http://people.redhat.com/mrodrigu/kvm/winutils.iso" - hash = "02930224756510e383c44c49bffb760e35d6f892" - destination = os.path.join(base_dir, 'isos', 'windows') - path = os.path.join(destination, iso_name) - check_iso(url, destination, hash) - - logging.info("") - logging.info("5 - Checking if qemu is installed (certify qemu and qemu-kvm " - "are in the place the default config expects)") - qemu_default_paths = ['/usr/bin/qemu-kvm', '/usr/bin/qemu-img'] - for qemu_path in qemu_default_paths: - if not os.path.isfile(qemu_path): - logging.warning("No %s found. You might need to install qemu-kvm.", - qemu_path) - else: - logging.debug("%s present", qemu_path) - logging.info("If you wish to change qemu-kvm to qemu or other binary path, " - "you will have to modify tests.cfg") - - logging.info("") - logging.info("6 - Checking for the KVM module (make sure kvm is loaded " - "to accelerate qemu-kvm)") - if not utils.module_is_loaded("kvm"): - logging.warning("KVM module is not loaded. You might want to load it") - else: - logging.debug("KVM module loaded") - - logging.info("") - logging.info("7 - Verify needed packages to get started") - logging.info("Please take a look at the online documentation " - "http://www.linux-kvm.org/page/KVM-Autotest/Client_Install " - "(session 'Install Prerequisite packages')") - - client_dir = os.path.abspath(os.path.join(kvm_test_dir, "..", "..")) - autotest_bin = os.path.join(client_dir, 'bin', 'autotest') - control_file = os.path.join(kvm_test_dir, 'control') - - logging.info("") - logging.info("When you are done fixing eventual warnings found, " - "you can run the kvm test using the command line AS ROOT:") - logging.info("%s %s", autotest_bin, control_file) - logging.info("Autotest prints the results dir, so you can look at DEBUG " - "logs if something went wrong") - logging.info("You can also edit the test config files (see output of " - "step 2 for a list)") + virt_utils.virt_test_assistant(test_name, test_dir, base_dir, + default_userspace_paths, check_modules, + online_docs_url)
client/virt/virt_utils.py +170 -1
182 lines not on this page · raw message
Signature · 1 line
1.7.6.4
PATCH 5/11 virt: Introducing libvirt VM class
In reply to Lucas Meneghel RodriguesThis is a first attempt at providing a libvirt VM class, in order to implement the needed methods for virt testing. With this class, we will be able to implement a libvirt test, that behaves similarly to the KVM test.
As of implementation details, libvirt_vm uses virsh (a userspace program written on top of libvirt) to do domain start, stop, verification of status and other common operations. The reason why virsh was used is to get more coverage of the userspace stack that libvirt offers, and also to catch issues that virsh users would catch.
--- client/virt/libvirt_vm.py | 1232 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 1232 insertions(+), 0 deletions(-) create mode 100644 client/virt/libvirt_vm.py
client/virt/libvirt_vm.py new file +1232 -0
@@ -0,0 +1,1232 @@ +""" +Utility classes and functions to handle Virtual Machine creation using qemu. + +@copyright: 2008-2009 Red Hat Inc. +""" + +import time, os, logging, fcntl, re, commands +from autotest_lib.client.common_lib import error +from autotest_lib.client.bin import utils, os_dep +from xml.dom import minidom +import virt_utils, virt_vm, aexpect + +DEBUG = False +try: + VIRSH_EXEC = os_dep.command("virsh") +except ValueError: + VIRSH_EXEC = None + + +def libvirtd_restart(): + """ + Restart libvirt daemon. + """ + try: + utils.run("service libvirtd restart") + logging.debug("Restarted libvirtd successfuly") + return True + except error.CmdError, detail: + logging.error("Failed to restart libvirtd: %s" % detail) + return False + + +def virsh_cmd(cmd): + if VIRSH_EXEC is None: + raise ValueError('Missing command: virsh') + cmd_result = utils.run("%s %s" % (VIRSH_EXEC, cmd), ignore_status=True, + verbose=DEBUG) + if DEBUG: + if cmd_result.stdout.strip(): + logging.debug("stdout: %s", cmd_result.stdout.strip()) + if cmd_result.stderr.strip(): + logging.debug("stderr: %s", cmd_result.stderr.strip()) + return cmd_result.stdout.strip() + + +def virsh_uri(): + """ + Return the hypervisor canonical URI. + """ + return virsh_cmd("uri") + + +def virsh_hostname(): + """ + Return the hypervisor hostname. + """ + return virsh_cmd("hostname") + + +def virsh_domstate(name): + """ + Return the state about a running domain. + + @param name: VM name + """ + return virsh_cmd("domstate %s" % name) + + +def virsh_uuid(name): + """ + Return the Converted domain name or id to the domain UUID. + + @param name: VM name + """ + return virsh_cmd("domuuid %s" % name) + + +def virsh_screenshot(name, filename): + virsh_cmd("screenshot %s %s" % (name, filename)) + return filename + + +def virsh_dumpxml(name): + """ + Return the domain information as an XML dump. + + @param name: VM name + """ + return virsh_cmd("dumpxml %s" % name) + + +def virsh_is_alive(name): + """ + Return True if the domain is started/alive. + + @param name: VM name + """ + return not virsh_is_dead(name) + + +def virsh_is_dead(name): + """ + Return True if the domain is not started/dead. + + @param name: VM name + """ + if (virsh_domstate(name) == 'running' or + virsh_domstate(name) == 'idle'): + return False + else: + return True + + +def virsh_suspend(name): + """ + Return True on successful domain suspention of VM. + + Suspend a domain. It is kept in memory but will not be scheduled. + + @param name: VM name + """ + try: + utils.run("virsh suspend %s" % (name)) + if virsh_domstate(name) == 'paused': + logging.debug("Suspended VM %s", name) + return True + else: + return False + except error.CmdError: + logging.error("Suspending VM %s failed", name) + return False + + +def virsh_resume(name): + """ + Return True on successful domain resumption of VM. + + Move a domain out of the suspended state. + + @param name: VM name + """ + try: + utils.run("virsh resume %s" % (name)) + if virsh_is_alive(name): + logging.debug("Resumed VM %s", name) + return True + else: + return False + except error.CmdError: + logging.error("Resume VM %s failed", name) + return False + + +def virsh_start(name, vm): + """ + Return True on successful domain start. + + Start a (previously defined) inactive domain. + + @param name: VM name + """ + if virsh_is_alive(name): + return + try: + utils.run("virsh start %s" % (name)) + return True + except error.CmdError: + logging.error("Start VM %s failed", name) + return False + + +def virsh_shutdown(name): + """ + Return True on successful domain shutdown. + + Gracefully shuts down a domain. + + @param name: VM name + """ + if virsh_domstate(name) == 'shut off': + return True + try: + utils.run("virsh shutdown %s" % (name)) + return True + except error.CmdError: + logging.error("Shutdown VM %s failed", name) + return False + + +def virsh_destroy(name): + """ + Return True on successful domain destroy. + + Immediately terminate the domain domain-id. The equivalent of ripping + the power cord out on a physical machine. + + @param name: VM name + """ + if virsh_domstate(name) == 'shut off': + return True + try: + utils.run("virsh destroy %s" % (name)) + return True + except error.CmdError: + logging.error("Destroy VM %s failed", name) + return False + + +def virsh_undefine(name): + """ + Return True on successful domain undefine. + + Undefine the configuration for an inactive domain. The domain should + be shutdown or destroyed before calling this method. + + @param name: VM name + """ + try: + utils.run("virsh undefine %s" % (name)) + logging.debug("undefined VM %s", name) + return True + except error.CmdError: + logging.error("undefine VM %s failed", name) + return False + + +def virsh_remove_domain(name): + """ + Return True after forcefully removing a domain if it exists. + + @param name: VM name + """ + if virsh_domain_exists(name): + if virsh_is_alive(name): + virsh_destroy(name) + virsh_undefine(name) + return True + + +def virsh_domain_exists(name): + """ + Return True if a domain exits. + + @param name: VM name + """ + try: + utils.run("virsh domstate %s" % name) + return True + except error.CmdError: + logging.warning("VM %s does not exist", name) + return False + + +class VM(virt_vm.BaseVM): + """ + This class handles all basic VM operations for libvirt. + """ + def __init__(self, name, params, root_dir, address_cache, state=None): + """ + Initialize the object and set a few attributes. + + @param name: The name of the object + @param params: A dict containing VM params + (see method make_qemu_command for a full description) + @param root_dir: Base directory for relative filenames + @param address_cache: A dict that maps MAC addresses to IP addresses + @param state: If provided, use this as self.__dict__ + """ + virt_vm.BaseVM.__init__(self, name, params) + + if state: + self.__dict__ = state + else: + self.process = None + self.serial_console = None + self.redirs = {} + self.vnc_port = 5900 + self.pci_assignable = None + self.netdev_id = [] + self.device_id = [] + self.pci_devices = [] + self.uuid = None + + self.spice_port = 8000 + self.name = name + self.params = params + self.root_dir = root_dir + self.address_cache = address_cache + # For now, libvirt does not have a monitor property. + self.monitor = None + + + def verify_alive(self): + """ + Make sure the VM is alive. + + @raise VMDeadError: If the VM is dead + """ + if not self.is_alive(): + raise virt_vm.VMDeadError("Domain %s is inactive" % self.name, + virsh_domstate(self.name)) + + + def is_alive(self): + """ + Return True if VM is alive. + """ + return virsh_is_alive(self.name) + + + def is_dead(self): + """ + Return True if VM is dead. + """ + return virsh_is_dead(self.name) + + + def clone(self, name=None, params=None, root_dir=None, address_cache=None, + copy_state=False): + """ + Return a clone of the VM object with optionally modified parameters. + The clone is initially not alive and needs to be started using create(). + Any parameters not passed to this function are copied from the source + VM. + + @param name: Optional new VM name + @param params: Optional new VM creation parameters + @param root_dir: Optional new base directory for relative filenames + @param address_cache: A dict that maps MAC addresses to IP addresses + @param copy_state: If True, copy the original VM's state to the clone. + Mainly useful for make_qemu_command(). + """ + if name is None: + name = self.name + if params is None: + params = self.params.copy() + if root_dir is None: + root_dir = self.root_dir + if address_cache is None: + address_cache = self.address_cache + if copy_state: + state = self.__dict__.copy() + else: + state = None + return VM(name, params, root_dir, address_cache, state) + + + def __make_libvirt_command(self, name=None, params=None, root_dir=None): + """ + Generate a libvirt command line. All parameters are optional. If a + parameter is not supplied, the corresponding value stored in the + class attributes is used. + + @param name: The name of the object + @param params: A dict containing VM params + @param root_dir: Base directory for relative filenames + + @note: The params dict should contain: + mem -- memory size in MBs + cdrom -- ISO filename to use with the qemu -cdrom parameter + extra_params -- a string to append to the qemu command + shell_port -- port of the remote shell daemon on the guest + (SSH, Telnet or the home-made Remote Shell Server) + shell_client -- client program to use for connecting to the + remote shell daemon on the guest (ssh, telnet or nc) + x11_display -- if specified, the DISPLAY environment variable + will be be set to this value for the qemu process (useful for + SDL rendering) + images -- a list of image object names, separated by spaces + nics -- a list of NIC object names, separated by spaces + + For each image in images: + drive_format -- string to pass as 'if' parameter for this + image (e.g. ide, scsi) + image_snapshot -- if yes, pass 'snapshot=on' to qemu for + this image + image_boot -- if yes, pass 'boot=on' to qemu for this image + In addition, all parameters required by get_image_filename. + + For each NIC in nics: + nic_model -- string to pass as 'model' parameter for this + NIC (e.g. e1000) + """ + # helper function for command line option wrappers + def has_option(help, option): + return bool(re.search(r"--%s" % option, help, re.MULTILINE)) + + # Wrappers for all supported libvirt command line parameters. + # This is meant to allow support for multiple libvirt versions. + # Each of these functions receives the output of 'libvirt --help' as a + # parameter, and should add the requested command line option + # accordingly. + + def add_name(help, name): + return " --name '%s'" % name + + def add_hvm_or_pv(help, hvm_or_pv): + return " --%s" % hvm_or_pv + + def add_mem(help, mem): + return " --ram=%s" % mem + + def add_check_cpu(help): + if has_option(help, "check-cpu"): + return " --check-cpu" + else: + return "" + + def add_smp(help, smp): + return " --vcpu=%s" % smp + + def add_location(help, location): + #return " --location %s" % location + if has_option(help, "location"): + return " --location %s" % location + else: + return "" + + def add_cdrom(help, filename, index=None): + if has_option(help, "cdrom"): + return " --cdrom %s" % filename + else: + return "" + + def add_pxe(help): + if has_option(help, "pxe"): + return " --pxe" + else: + return "" + + def add_drive(help, filename, pool=None, vol=None, device=None, + bus=None, perms=None, size=None, sparse=False, + cache=None, format=None): + cmd = " --disk" + if filename: + cmd += " path=%s" % filename + elif pool: + if vol: + cmd += " vol=%s/%s" % (pool, vol) + else: + cmd += " pool=%s" % pool + if device: + cmd += ",device=%s" % device + if bus: + cmd += ",bus=%s" % bus + if perms: + cmd += ",%s" % perms + if size: + cmd += ",size=%s" % size.rstrip("Gg") + if sparse: + cmd += ",sparse=false" + if format: + cmd += ",format=%s" % format + return cmd + + def add_floppy(help, filename): + return " --disk path=%s,device=floppy,ro" % filename + + def add_vnc(help, vnc_port): + return " --vnc --vncport=%d" % (vnc_port) + + def add_sdl(help): + if has_option(help, "sdl"): + return " --sdl" + else: + return "" + + def add_nographic(help): + return " --nographics" + + def add_video(help, video_device): + if has_option(help, "video"): + return " --video=%s" % (video_device) + else: + return "" + + def add_uuid(help, uuid): + if has_option(help, "uuid"): + return " --uuid %s" % uuid + else: + return "" + + def add_os_type(help, os_type): + if has_option(help, "os-type"): + return " --os-type %s" % os_type + else: + return "" + + def add_os_variant(help, os_variant): + if has_option(help, "os-variant"): + return " --os-variant %s" % os_variant + else: + return "" + + def add_pcidevice(help, pci_device): + if has_option(help, "host-device"): + return " --host-device %s" % pci_device + else: + return "" + + def add_soundhw(help, sound_device): + if has_option(help, "soundhw"): + return " --soundhw %s" % sound_device + else: + return "" + + def add_serial(help, filename): + if has_option(help, "serial"): + return " --serial file,path=%s --serial pty" % filename + else: + return "" + + def add_kernel_cmdline(help, cmdline): + return " -append %s" % cmdline + + # End of command line option wrappers + + if name is None: + name = self.name + if params is None: + params = self.params + if root_dir is None: + root_dir = self.root_dir + + # Clone this VM using the new params + vm = self.clone(name, params, root_dir, copy_state=True) + + virt_install_binary = virt_utils.get_path(root_dir, + params.get("virt_install_binary", + "virt-install")) + + help = utils.system_output("%s --help" % virt_install_binary) + + # Start constructing the qemu command + virt_install_cmd = "" + # Set the X11 display parameter if requested + if params.get("x11_display"): + virt_install_cmd += "DISPLAY=%s " % params.get("x11_display") + # Add the qemu binary + virt_install_cmd += virt_install_binary + + # hvm or pv specificed by libvirt switch (pv used by Xen only) + hvm_or_pv = params.get("hvm_or_pv") + if hvm_or_pv: + virt_install_cmd += add_hvm_or_pv(help, hvm_or_pv) + + # Add the VM's name + virt_install_cmd += add_name(help, name) + + mem = params.get("mem") + if mem: + virt_install_cmd += add_mem(help, mem) + + # TODO: should we do the check before we call ? negative case ? + check_cpu = params.get("use_check_cpu") + if check_cpu: + virt_install_cmd += add_check_cpu(help) + + smp = params.get("smp") + if smp: + virt_install_cmd += add_smp(help, smp) + + # TODO: directory location for vmlinuz/kernel for cdrom install ? + location = None + if params.get("medium") == 'url': + location = params.get("url") + elif params.get("medium") == 'kernel_initrd': + # directory location of kernel/initrd pair (directory layout must + # be in format libvirt will recognize) + location = params.get("image_dir") + elif params.get("medium") == 'nfs': + location = "nfs:%s:%s" % (params.get("nfs_server"), + params.get("nfs_dir")) + elif params.get("medium") == 'cdrom': + if params.get("use_libvirt_cdrom_switch") == 'yes': + virt_install_cmd += add_cdrom(help, params.get("cdrom_cd1")) + else: + location = params.get("image_dir") + + if location: + virt_install_cmd += add_location(help, location) + + if params.get("display") == "vnc": + if params.get("vnc_port"): + vm.vnc_port = int(params.get("vnc_port")) + virt_install_cmd += add_vnc(help, vm.vnc_port) + elif params.get("display") == "sdl": + virt_install_cmd += add_sdl(help) + elif params.get("display") == "nographic": + virt_install_cmd += add_nographic(help) + + video_device = params.get("video_device") + if video_device: + virt_install_cmd += add_video(help, video_device) + + sound_device = params.get("sound_device") + if sound_device: + virt_install_cmd += add_soundhw(help, sound_device) + + # if none is given a random UUID will be generated by libvirt + if params.get("uuid"): + virt_install_cmd += add_uuid(help, params.get("uuid")) + + # selectable OS type + if params.get("use_os_type") == "yes": + virt_install_cmd += add_os_type(help, params.get("os_type")) + + # selectable OS variant + if params.get("use_os_variant") == "yes": + virt_install_cmd += add_os_variant(help, params.get("os_variant")) + + # If the PCI assignment step went OK, add each one of the PCI assigned + # devices to the command line. + if self.pci_devices: + for pci_id in self.pci_devices: + virt_install_cmd += add_pcidevice(help, pci_id) + + for image_name in params.objects("images"): + image_params = params.object_params(image_name) + filename = virt_vm.get_image_filename(image_params, root_dir) + if image_params.get("use_storage_pool") == "yes": + filename = None + if image_params.get("boot_drive") == "no": + continue + virt_install_cmd += add_drive(help, + filename, + image_params.get("image_pool"), + image_params.get("image_vol"), + image_params.get("image_device"), + image_params.get("image_bus"), + image_params.get("image_perms"), + image_params.get("image_size"), + image_params.get("drive_sparse"), + image_params.get("drive_cache"), + image_params.get("image_format")) + + for cdrom in params.objects("cdroms"): + cdrom_params = params.object_params(cdrom) + iso = cdrom_params.get("cdrom") + if params.get("use_libvirt_cdrom_switch") == 'yes': + # we don't want to skip the winutils iso + if not cdrom == 'winutils': + logging.debug("Using --cdrom instead of --disk for install") + logging.debug("Skipping CDROM:%s:%s", cdrom, iso) + continue + if params.get("medium") == 'cdrom_no_kernel_initrd': + if iso == params.get("cdrom_cd1"): + logging.debug("Using cdrom or url for install") + logging.debug("Skipping CDROM: %s", iso) + continue + + if iso: + virt_install_cmd += add_drive(help, + virt_utils.get_path(root_dir, iso), + image_params.get("iso_image_pool"), + image_params.get("iso_image_vol"), + 'cdrom', + None, + None, + None, + None, + None, + None) + + # We may want to add {floppy_otps} parameter for -fda + # {fat:floppy:}/path/. However vvfat is not usually recommended. + floppy = params.get("floppy") + if floppy: + floppy = virt_utils.get_path(root_dir, floppy) + virt_install_cmd += add_drive(help, floppy, + None, + None, + 'floppy', + None, + None, + None, + None, + None, + None) + + # FIXME: for now in the pilot always add mac address to virt-install + vlan = 0 + mac = vm.get_mac_address(vlan) + if mac: + virt_install_cmd += " --mac %s" % mac + self.nic_mac = mac + + virt_install_cmd += (" --network %s,model=%s" % + (params.get("virsh_network"), + params.get("nic_model"))) + + if params.get("use_no_reboot") == "yes": + virt_install_cmd += " --noreboot" + + if params.get("use_autostart") == "yes": + virt_install_cmd += " --autostart" + + if params.get("virt_install_debug") == "yes": + virt_install_cmd += " --debug" + + # bz still open, not fully functional yet + if params.get("use_virt_install_wait") == "yes": + virt_install_cmd += (" --wait %s" % + params.get("virt_install_wait_time")) + + extra_params = params.get("extra_params") + if extra_params: + virt_install_cmd += " --extra-args '%s'" % extra_params + + virt_install_cmd += " --noautoconsole" + + return virt_install_cmd + + + @error.context_aware + def create(self, name=None, params=None, root_dir=None, timeout=5.0, + migration_mode=None, mac_source=None): + """ + Start the VM by running a qemu command. + All parameters are optional. If name, params or root_dir are not + supplied, the respective values stored as class attributes are used. + + @param name: The name of the object + @param params: A dict containing VM params + @param root_dir: Base directory for relative filenames + @param migration_mode: If supplied, start VM for incoming migration + using this protocol (either 'tcp', 'unix' or 'exec') + @param migration_exec_cmd: Command to embed in '-incoming "exec: ..."' + (e.g. 'gzip -c -d filename') if migration_mode is 'exec' + @param mac_source: A VM object from which to copy MAC addresses. If not + specified, new addresses will be generated. + + @raise VMCreateError: If qemu terminates unexpectedly + @raise VMKVMInitError: If KVM initialization fails + @raise VMHugePageError: If hugepage initialization fails + @raise VMImageMissingError: If a CD image is missing + @raise VMHashMismatchError: If a CD image hash has doesn't match the + expected hash + @raise VMBadPATypeError: If an unsupported PCI assignment type is + requested + @raise VMPAError: If no PCI assignable devices could be assigned + """ + error.context("creating '%s'" % self.name) + self.destroy(free_mac_addresses=False) + + if name is not None: + self.name = name + if params is not None: + self.params = params + if root_dir is not None: + self.root_dir = root_dir + name = self.name + params = self.params + root_dir = self.root_dir + + # Verify the md5sum of the ISO images + for cdrom in params.objects("cdroms"): + cdrom_params = params.object_params(cdrom) + iso = cdrom_params.get("cdrom") + if iso: + iso = virt_utils.get_path(root_dir, iso) + if not os.path.exists(iso): + raise virt_vm.VMImageMissingError(iso) + compare = False + if cdrom_params.get("md5sum_1m"): + logging.debug("Comparing expected MD5 sum with MD5 sum of " + "first MB of ISO file...") + actual_hash = utils.hash_file(iso, 1048576, method="md5") + expected_hash = cdrom_params.get("md5sum_1m") + compare = True + elif cdrom_params.get("md5sum"): + logging.debug("Comparing expected MD5 sum with MD5 sum of " + "ISO file...") + actual_hash = utils.hash_file(iso, method="md5") + expected_hash = cdrom_params.get("md5sum") + compare = True + elif cdrom_params.get("sha1sum"): + logging.debug("Comparing expected SHA1 sum with SHA1 sum " + "of ISO file...") + actual_hash = utils.hash_file(iso, method="sha1") + expected_hash = cdrom_params.get("sha1sum") + compare = True + if compare: + if actual_hash == expected_hash: + logging.debug("Hashes match") + else: + raise virt_vm.VMHashMismatchError(actual_hash, + expected_hash) + + # Make sure the following code is not executed by more than one thread + # at the same time + lockfile = open("/tmp/libvirt-autotest-vm-create.lock", "w+") + fcntl.lockf(lockfile, fcntl.LOCK_EX) + + try: + # Handle port redirections + redir_names = params.objects("redirs") + host_ports = virt_utils.find_free_ports(5000, 6000, len(redir_names)) + self.redirs = {} + for i in range(len(redir_names)): + redir_params = params.object_params(redir_names[i]) + guest_port = int(redir_params.get("guest_port")) + self.redirs[guest_port] = host_ports[i] + + # Generate netdev/device IDs for all NICs + self.netdev_id = [] + self.device_id = [] + for nic in params.objects("nics"): + self.netdev_id.append(virt_utils.generate_random_id()) + self.device_id.append(virt_utils.generate_random_id()) + + # Find available PCI devices + self.pci_devices = [] + for device in params.objects("pci_devices"): + self.pci_devices.append(device) + + # Find available VNC port, if needed + if params.get("display") == "vnc": + self.vnc_port = virt_utils.find_free_port(5900, 6100) + + # Find available spice port, if needed + if params.get("spice"): + self.spice_port = virt_utils.find_free_port(8000, 8100) + + # Find random UUID if specified 'uuid = random' in config file + if params.get("uuid") == "random": + f = open("/proc/sys/kernel/random/uuid") + self.uuid = f.read().strip() + f.close() + + # Generate or copy MAC addresses for all NICs + num_nics = len(params.objects("nics")) + for vlan in range(num_nics): + nic_name = params.objects("nics")[vlan] + nic_params = params.object_params(nic_name) + mac = (nic_params.get("nic_mac") or + mac_source and mac_source.get_mac_address(vlan)) + if mac: + virt_utils.set_mac_address(self.instance, vlan, mac) + else: + virt_utils.generate_mac_address(self.instance, vlan) + + # Make qemu command + install_command = self.__make_libvirt_command() + + logging.info("Running libvirt command:\n%s", install_command) + utils.run(install_command, verbose=False) + # Wait for the domain to be created + virt_utils.wait_for(func=self.is_alive, timeout=60, + text=("waiting for domain %s to start" % + self.name)) + + # Establish a session with the serial console -- requires a version + # of netcat that supports -U + self.serial_console = aexpect.ShellSession( + "nc -U %s" % self.get_serial_console_filename(), + auto_close=False, + output_func=virt_utils.log_line, + output_params=("serial-%s.log" % name,)) + + finally: + fcntl.lockf(lockfile, fcntl.LOCK_UN) + lockfile.close() + + + def destroy(self, gracefully=True, free_mac_addresses=True): + """ + Destroy the VM. + + If gracefully is True, first attempt to shutdown the VM with a shell + command. If that fails, send SIGKILL to the qemu process. + + @param gracefully: If True, an attempt will be made to end the VM + using a shell command before trying to end the qemu process + with a 'quit' or a kill signal. + @param free_mac_addresses: If True, the MAC addresses used by the VM + will be freed. + """ + try: + # Is it already dead? + if self.is_dead(): + return + + logging.debug("Destroying VM") + if gracefully and self.params.get("shutdown_command"): + # Try to destroy with shell command + logging.debug("Trying to shutdown VM with shell command") + try: + session = self.login() + except (virt_utils.LoginError, virt_vm.VMError), e: + logging.debug(e) + else: + try: + # Send the shutdown command + session.sendline(self.params.get("shutdown_command")) + logging.debug("Shutdown command sent; waiting for VM " + "to go down...") + if virt_utils.wait_for(self.is_dead, 60, 1, 1): + logging.debug("VM is down") + return + finally: + session.close() + + virsh_destroy(self.name) + + finally: + if self.serial_console: + self.serial_console.close() + for f in ([self.get_testlog_filename(), + self.get_serial_console_filename()]): + try: + os.unlink(f) + except OSError: + pass + if hasattr(self, "migration_file"): + try: + os.unlink(self.migration_file) + except OSError: + pass + if free_mac_addresses: + num_nics = len(self.params.objects("nics")) + for vlan in range(num_nics): + self.free_mac_address(vlan) + + + def get_address(self, index=0): + """ + Return the address of a NIC of the guest, in host space. + + If port redirection is used, return 'localhost' (the NIC has no IP + address of its own). Otherwise return the NIC's IP address. + + @param index: Index of the NIC whose address is requested. + @raise VMMACAddressMissingError: If no MAC address is defined for the + requested NIC + @raise VMIPAddressMissingError: If no IP address is found for the the + NIC's MAC address + @raise VMAddressVerificationError: If the MAC-IP address mapping cannot + be verified (using arping) + """ + nics = self.params.objects("nics") + nic_name = nics[index] + nic_params = self.params.object_params(nic_name) + if nic_params.get("nic_mode") == "tap": + mac = self.get_mac_address(index).lower() + # Get the IP address from the cache + ip = self.address_cache.get(mac) + if not ip: + raise virt_vm.VMIPAddressMissingError(mac) + # Make sure the IP address is assigned to this guest + macs = [self.get_mac_address(i) for i in range(len(nics))] + if not virt_utils.verify_ip_address_ownership(ip, macs): + raise virt_vm.VMAddressVerificationError(mac, ip) + return ip + else: + return "localhost" + + + def get_port(self, port, nic_index=0): + """ + Return the port in host space corresponding to port in guest space. + + @param port: Port number in host space. + @param nic_index: Index of the NIC. + @return: If port redirection is used, return the host port redirected + to guest port port. Otherwise return port. + @raise VMPortNotRedirectedError: If an unredirected port is requested + in user mode + """ + nic_name = self.params.objects("nics")[nic_index] + nic_params = self.params.object_params(nic_name) + if nic_params.get("nic_mode") == "tap": + return port + else: + try: + return self.redirs[port] + except KeyError: + raise virt_vm.VMPortNotRedirectedError(port) + + + def get_ifname(self, nic_index=0): + """ + Return the ifname of a tap device associated with a NIC. + + @param nic_index: Index of the NIC + """ + nics = self.params.objects("nics") + nic_name = nics[nic_index] + nic_params = self.params.object_params(nic_name) + if nic_params.get("nic_ifname"): + return nic_params.get("nic_ifname") + else: + return "t%d-%s" % (nic_index, self.instance[-11:]) + + + def get_virsh_mac_address(self, nic_index): + thexml = virsh_dumpxml(self.name) + dom = minidom.parseString(thexml) + count = 0 + for node in dom.getElementsByTagName('interface'): + source = node.childNodes[1] + x = source.attributes["address"] + if nic_index == count: + return x.value + count += 1 + + + def get_mac_address(self, nic_index=0): + """ + Return the MAC address of a NIC. + + @param nic_index: Index of the NIC + @raise VMMACAddressMissingError: If no MAC address is defined for the + requested NIC + """ + nic_name = self.params.objects("nics")[nic_index] + nic_params = self.params.object_params(nic_name) + if nic_params.get("vm_type") == 'libvirt': + if self.params.objects("type")[0] == 'unattended_install': + mac = virt_utils.get_mac_address(self.instance, nic_index) + else: + mac = self.get_virsh_mac_address(nic_index) + else: + mac = (nic_params.get("nic_mac") or + virt_utils.get_mac_address(self.instance, nic_index)) + if not mac: + raise virt_vm.VMMACAddressMissingError(nic_index) + return mac + + + def free_mac_address(self, nic_index=0): + """ + Free a NIC's MAC address. + + @param nic_index: Index of the NIC + """ + virt_utils.free_mac_address(self.instance, nic_index) + + + def get_pid(self): + """ + Return the VM's PID. If the VM is dead return None. + + @note: This works under the assumption that self.process.get_pid() + returns the PID of the parent shell process. + """ + try: + filename = "/var/run/libvirt/qemu/%s.pid" % self.name + if not self.params.get("type") == "unattended_install": + if os.path.exists(filename): + self.process = int(open(filename).read()) + children = commands.getoutput("ps --ppid=%d -o pid=" % + self.process.get_pid()).split() + return int(children[0]) + except (TypeError, IndexError, ValueError): + return None + + + def get_shell_pid(self): + """ + Return the PID of the parent shell process. + + @note: This works under the assumption that self.process.get_pid() + returns the PID of the parent shell process. + """ + return self.process.get_pid() + + + def get_shared_meminfo(self): + """ + Returns the VM's shared memory information. + + @return: Shared memory used by VM (MB) + """ + if self.is_dead(): + logging.error("Could not get shared memory info from dead VM.") + return None + + filename = "/proc/%d/statm" % self.get_pid() + shm = int(open(filename).read().split()[2]) + # statm stores informations in pages, translate it to MB + return shm * 4.0 / 1024 + + + @error.context_aware + def reboot(self, session=None, method="shell", nic_index=0, timeout=240): + """ + Reboot the VM and wait for it to come back up by trying to log in until + timeout expires. + + @param session: A shell session object or None. + @param method: Reboot method. Can be "shell" (send a shell reboot + command). + @param nic_index: Index of NIC to access in the VM, when logging in + after rebooting. + @param timeout: Time to wait for login to succeed (after rebooting). + @return: A new shell session object. + """ + error.base_context("rebooting '%s'" % self.name, logging.info) + error.context("before reboot") + session = session or self.login() + error.context() + + if method == "shell": + session.sendline(self.params.get("reboot_command")) + else: + raise virt_vm.VMRebootError("Unknown reboot method: %s" % method) + + error.context("waiting for guest to go down", logging.info) + if not virt_utils.wait_for(lambda: + not session.is_responsive(timeout=30), + 120, 0, 1): + raise virt_vm.VMRebootError("Guest refuses to go down") + session.close() + + error.context("logging in after reboot", logging.info) + return self.wait_for_login(nic_index, timeout=timeout) + + + def needs_restart(self, name, params, basedir): + """ + Verifies whether the current qemu commandline matches the requested + one, based on the test parameters. + """ + return (self.__make_libvirt_command() != + self.__make_libvirt_command(name, params, basedir)) + + + def screendump(self, filename, debug=False): + if debug: + logging.debug("Requesting screenshot %s" % filename) + return virsh_screenshot(self.name, filename) + + + def wait_for_start(self, count=60): + """ + Return True on successful domain start. + + Wait for a domain to start, libvirt does not block on domain + start so we need to watch for successful completion. + + @param name: VM name + @param name: Optional timeout value + """ + timeout = count + while count > 0: + # check every 5 seconds + if count % 5 == 0: + if virsh_is_alive(self.name): + session = self.wait_for_login(timeout=60) + session.close() + logging.debug("Start took %d seconds", timeout - count) + return True + count -= 1 + time.sleep(1) + logging.debug("Waiting for guest to start %d", count) + return False + + + def start(self): + """ + Starts this VM. + """ + if virsh_start(self.name): + if self.wait_for_start(): + logging.debug("Started VM %s", self.name) + return True + else: + logging.error("VM %s failed to start", self.name) + return False + else: + logging.error("VM %s failed to start", self.name) + return False + + + def wait_for_shutdown(self, count=60): + """ + Return True on successful domain shutdown. + + Wait for a domain to shutdown, libvirt does not block on domain + shutdown so we need to watch for successful completion. + + @param name: VM name + @param name: Optional timeout value + """ + timeout = count + while count > 0: + # check every 5 seconds + if count % 5 == 0: + if virsh_is_dead(self.name): + logging.debug("Shutdown took %d seconds", timeout - count) + return True + count -= 1 + time.sleep(1) + logging.debug("Waiting for guest to shutdown %d", count) + return False + + + def shutdown(self): + """ + Shuts down this VM. + """ + if virsh_shutdown(self.name): + if self.wait_for_shutdown(): + logging.debug("VM %s shut down", self.name) + return True + else: + logging.error("VM %s failed to shut down", self.name) + return False + else: + logging.error("VM %s failed to shut down", self.name) + return False + + + def send_key(self): + pass + + + def migrate(self): + pass + + + def pause(self): + pass + + + def resume(self): + pass + + + def save_to_file(self): + pass
Signature · 1 line
1.7.6.4
Re: [Autotest] [PATCH 05/11] virt: Introducing libvirt VM class
Quoted 169 lines · Lucas Meneghel Rodrigues
This is a first attempt at providing a libvirt VM class, in order to implement the needed methods for virt testing. With this class, we will be able to implement a libvirt test, that behaves similarly to the KVM test.
As of implementation details,
libvirt_vmuses virsh (a userspace program written on top of libvirt) to do domain start, stop, verification of status and other common operations. The reason why virsh was used is to get more coverage of the userspace stack that libvirt offers, and also to catch issues that virsh users would catch.Signed-off-by Lucas Meneghel Rodrigues<[email protected]>--- client/virt/libvirt_vm.py | 1232 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 1232 insertions(+), 0 deletions(-)create mode 100644
client/virt/libvirt_vm.pyclient/virt/libvirt_vm.py new file +144
-0@@ -0,0 +1,1232 @@ +""" +Utility classes and functions to handle Virtual Machine creation using qemu. + +@copyright: 2008-2009 Red Hat Inc. +""" + +import time, os, logging, fcntl, re, commands +from autotest_lib.client.common_lib import error +from autotest_lib.client.bin import utils, os_dep +from xml.dom import minidom +import virt_utils, virt_vm, aexpect + +DEBUG = False +try: + VIRSH_EXEC = os_dep.command("virsh") +except ValueError: + VIRSH_EXEC = None + + +def libvirtd_restart(): + """ + Restart libvirt daemon. + """ + try: + utils.run("service libvirtd restart") + logging.debug("Restarted libvirtd successfuly") + return True + except error.CmdError, detail: + logging.error("Failed to restart libvirtd: %s" % detail) + return False + + +def virsh_cmd(cmd): + if VIRSH_EXEC is None: + raise ValueError('Missing command: virsh') + cmd_result = utils.run("%s %s" % (VIRSH_EXEC, cmd), ignore_status=True, + verbose=DEBUG) + if DEBUG: + if cmd_result.stdout.strip(): + logging.debug("stdout: %s", cmd_result.stdout.strip()) + if cmd_result.stderr.strip(): + logging.debug("stderr: %s", cmd_result.stderr.strip()) + return cmd_result.stdout.strip() + + +def virsh_uri(): + """ + Return the hypervisor canonical URI. + """ + return virsh_cmd("uri") + + +def virsh_hostname(): + """ + Return the hypervisor hostname. + """ + return virsh_cmd("hostname") + + +def virsh_domstate(name): + """ + Return the state about a running domain. + + @param name: VM name + """ + return virsh_cmd("domstate %s" % name) + + +def virsh_uuid(name): + """ + Return the Converted domain name or id to the domain UUID. + + @param name: VM name + """ + return virsh_cmd("domuuid %s" % name) + + +def virsh_screenshot(name, filename): + virsh_cmd("screenshot %s %s" % (name, filename)) + return filename + + +def virsh_dumpxml(name): + """ + Return the domain information as an XML dump. + + @param name: VM name + """ + return virsh_cmd("dumpxml %s" % name) + + +def virsh_is_alive(name): + """ + Return True if the domain is started/alive. + + @param name: VM name + """ + return not virsh_is_dead(name) + + +def virsh_is_dead(name): + """ + Return True if the domain is not started/dead. + + @param name: VM name + """ + if (virsh_domstate(name) == 'running' or + virsh_domstate(name) == 'idle'): + return False + else: + return True + + +def virsh_suspend(name): + """ + Return True on successful domain suspention of VM. + + Suspend a domain. It is kept in memory but will not be scheduled. + + @param name: VM name + """ + try: + utils.run("virsh suspend %s" % (name)) + if virsh_domstate(name) == 'paused': + logging.debug("Suspended VM %s", name) + return True + else: + return False + except error.CmdError: + logging.error("Suspending VM %s failed", name) + return False + + +def virsh_resume(name): + """ + Return True on successful domain resumption of VM. + + Move a domain out of the suspended state. + + @param name: VM name + """ + try: + utils.run("virsh resume %s" % (name)) + if virsh_is_alive(name):
client/virt/libvirt_vm.py line 154
Quoted 10 lines
client/virt/libvirt_vm.py new file +10
-0+ logging.debug("Resumed VM %s", name) + return True + else: + return False + except error.CmdError: + logging.error("Resume VM %s failed", name) + return False + + +def virsh_start(name, vm):
def virsh_start(name):
one or two augments here? this function is called with one augment in VM.start()
Quoted 4 lines
client/virt/libvirt_vm.py new file +4
-0+ """ + Return True on successful domain start. + + Start a (previously defined) inactive domain.
client/virt/libvirt_vm.py line 168
Quoted 10 lines
client/virt/libvirt_vm.py new file +10
-0+ + @param name: VM name + """ + if virsh_is_alive(name): + return + try: + utils.run("virsh start %s" % (name)) + return True + except error.CmdError: + logging.error("Start VM %s failed", name)
If the virsh cmd fails, we would got two error message.
They are repeated, how about remove this one? or add a prefix(we would know it's an error of virsh cmd)
logging.error("Start VM %s failed", name)logging.error("VM %s failed to start", self.name)
Quoted 3 lines
client/virt/libvirt_vm.py new file +3
-0+ return False + +
....
Quoted 12 lines
client/virt/libvirt_vm.py new file +12
-0+ +class VM(virt_vm.BaseVM): + """ + This class handles all basic VM operations for libvirt. + """ + def __init__(self, name, params, root_dir, address_cache, state=None): + """ + Initialize the object and set a few attributes. + + @param name: The name of the object + @param params: A dict containing VM params + (see method make_qemu_command for a full description)
....
client/virt/libvirt_vm.py line 1164
Quoted 6 lines
client/virt/libvirt_vm.py new file +6
-0+ + def start(self): + """ + Starts this VM. + """ + if virsh_start(self.name):
^^^^^^^^
client/virt/libvirt_vm.py line 1172
Quoted 8 lines
client/virt/libvirt_vm.py new file +8
-0+ if self.wait_for_start(): + logging.debug("Started VM %s", self.name) + return True + else: + logging.error("VM %s failed to start", self.name) + return False + else: + logging.error("VM %s failed to start", self.name)
^^^^^^^^
Quoted 25 lines
client/virt/libvirt_vm.py new file +25
-0+ return False + + + def wait_for_shutdown(self, count=60): + """ + Return True on successful domain shutdown. + + Wait for a domain to shutdown, libvirt does not block on domain + shutdown so we need to watch for successful completion. + + @param name: VM name + @param name: Optional timeout value + """ + timeout = count + while count> 0: + # check every 5 seconds + if count % 5 == 0: + if virsh_is_dead(self.name): + logging.debug("Shutdown took %d seconds", timeout - count) + return True + count -= 1 + time.sleep(1) + logging.debug("Waiting for guest to shutdown %d", count) + return False +
Re: [PATCH 05/11] virt: Introducing libvirt VM class
In reply to Lucas Meneghel RodriguesQuoted 5 lines · Lucas Meneghel Rodrigues
This is a first attempt at providing a libvirt VM class, in order to implement the needed methods for virt testing. With this class, we will be able to implement a libvirt test, that behaves similarly to the KVM test.
Quoted 7 lines
As of implementation details,
libvirt_vmuses virsh (a userspace program written on top of libvirt) to do domain start, stop, verification of status and other common operations. The reason why virsh was used is to get more coverage of the userspace stack that libvirt offers, and also to catch issues that virsh users would catch.
Personally I would have recommended that you use the libvirt Python API. virsh is a very thin layer over the libvirt API, which mostly avoidse adding any logic of its own, so once it has been tested once, there's not much value in doing more. By using the Python API directly, you will be able todo more intelligent handling of errors, since you'll get the full libvirt python exception object instead of a blob of stuff on stderr. Not to mention that it is so much more efficient, and robust against any future changes in virsh.
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Re: [PATCH 05/11] virt: Introducing libvirt VM class
Quoted 14 lines · Daniel P. Berrange
Quoted 5 lines · Lucas Meneghel Rodrigues
This is a first attempt at providing a libvirt VM class, in order to implement the needed methods for virt testing. With this class, we will be able to implement a libvirt test, that behaves similarly to the KVM test.
Quoted 7 lines
As of implementation details,
libvirt_vmuses virsh (a userspace program written on top of libvirt) to do domain start, stop, verification of status and other common operations. The reason why virsh was used is to get more coverage of the userspace stack that libvirt offers, and also to catch issues that virsh users would catch.
Quoted 8 lines
Personally I would have recommended that you use the libvirt Python API. virsh is a very thin layer over the libvirt API, which mostly avoidse adding any logic of its own, so once it has been tested once, there's not much value in doing more. By using the Python API directly, you will be able todo more intelligent handling of errors, since you'll get the full libvirt python exception object instead of a blob of stuff on stderr. Not to mention that it is so much more efficient, and robust against any future changes in virsh.
Thanks Daniel. We've discussed about that quite a few times during the development of the code. The plan is to just add methods that will do the same as the API counterpart moving forward, so we can test both the think layer that is virsh and the py API. We just wanted to focusing in one implementation to get something functional first.
We'll keep you guys posted about progress on py bindings.
Cheers,
Lucas
PATCH 6/11 virt: Introducing libvirt monitor
In reply to Lucas Meneghel RodriguesThis is an initial implementation for a libvirt monitor. With it, we plan on making the libvirt test use all the monitor features, making most of the tests available for kvm available for libvirt.
As of implementation details, it uses aexpect to get a virsh shell, and then the monitor methods are implemented by executing commands on that virsh shell.
As of now, the libvirt vm class is still not using the monitor code, but we plan on making the move soon enough.
--- client/virt/libvirt_monitor.py | 322 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 322 insertions(+), 0 deletions(-) create mode 100644 client/virt/libvirt_monitor.py
client/virt/libvirt_monitor.py new file +322 -0
@@ -0,0 +1,322 @@ +import re, tempfile, xml.dom.minidom, logging +import virt_utils, aexpect +from autotest_lib.client.bin import utils + + +class VirshMonitor: + """ + Wraps "Virsh monitor" commands. + """ + + def __init__(self, virsh_exec='virsh', name, vmname, password=None, + prompt=None, hostname='localhost', driver=None, username=None, + linesep="\\n"): + """ + Connect to the hypervisor and get virsh prompt. + + @param virsh_exec: Virsh executable + @param name: Monitor identifier (a string) + @param vmname: VM name + @param password: Hypervisor user password + @param prompt: Virsh prompt + @param hostname: Hypervisor IP + @param driver: Hypervisor driver type + @param username: Hypervisor username + @param linesep: The line separator to use when sending lines + (e.g. '\\n' or '\\r\\n') + """ + self.virsh_exec = virsh_exec + self.name = name + self.vmname = vmname + self.password = password + self.prompt = prompt + self.hostname = hostname + self.driver = driver + self.username = username + self.session = self.login() + self.virsh_cmd = {"help":"help", "quit":"destroy " + self.vmname, + "stop":"suspend", "cont":"resume"} + self.drive_map = {} + self.network_info = [] + self.disk_info = [] + self._parse_domxml() + + + def __del__(self): + self.session.sendline("quit") + + + def __getstate__(self): + pass + + + def __setstate__(self, state): + pass + + + def __getinitargs__(self): + # Save some information when pickling -- will be passed to the + # constructor upon unpickling + return (self.name, self.vmname, self.password, self.prompt, + self.hostname, self.driver, self.username) + + + def login(self, timeout=10): + """ + Log into the hypervisor using required URIs . + + @timeout: Time in seconds that we will wait before giving up on logging + into the host. + @return: A ShellSession object. + """ + if self.driver is None: + uri = utils.system_output('%s uri' % self.virsh_exec) + else: + uri = "%s+ssh://%s@%s/system" % (self.driver, self.username, + self.host) + + command = "%s --connect %s" % (self.virsh_exec, uri) + + session = aexpect.ShellSession(command, linesep=self.linesep, + prompt=self.prompt) + + if self.username is not None: + try: + virt_utils._remote_login(session, self.username, self.password, + self.prompt, self.timeout) + except aexpect.ShellError: + session.close() + session = None + + return session + + + def _parse_domxml(self): + self.session.cmd_output("\n") + domxml = self.session.cmd_output("dumpxml %s \n" % self.vmname) + self._parse_dev(domxml) + + + def _parse_dev(self, domxml): + dom = xml.dom.minidom.parseString(domxml) + self.network_info = [] + for elems in dom.getElementsByTagName('interface'): + self.network_info.append(elems.toxml()) + + self.disk_info = [] + for elems in dom.getElementsByTagName('disk'): + self.disk_info.append(elems.toxml()) + + + def verify_responsive(self): + """ + Make sure the monitor is responsive by sending a command. + """ + self.cmd("help") + + + def cmd(self, command): + """ + Send command to the monitor. + + @param command: Command to send to the monitor + @return: Output received from the monitor + """ + def dev_add(command): + """ + Create the xml file for the device to be attached + """ + parm_dic = dict(re.findall("(id|driver|mac|drive)=([^,\s]+)", + command)) + self.session.cmd_output("\n") + if parm_dic.has_key("drive"): + self.drive_map[parm_dic["drive"]]["driver"] = parm_dic\ + ["driver"] + self.drive_map[parm_dic["drive"]]["device_id"] = parm_dic["id"] + self.drive_map[parm_dic["drive"]]["dev"] = "vd" + str(len( + self.drive_map)) + doc = xml.dom.minidom.Document() + topelem = doc.createElement("disk") + topelem.setAttribute('device', 'disk') + topelem.setAttribute('type', 'file') + doc.appendChild(topelem) + chld_elem = doc.createElement("driver") + chld_elem.setAttribute('name', "qemu") + topelem.appendChild(chld_elem) + chld_elem = doc.createElement("source") + chld_elem.setAttribute('file', self.drive_map[parm_dic["drive"] + ]["file"]) + topelem.appendChild(chld_elem) + chld_elem = doc.createElement("target") + if "virtio-blk-pci" in command: + self.drive_map[parm_dic["drive"]]["driver"] = "virtio" + chld_elem.setAttribute('bus', self.drive_map[parm_dic["drive"] + ]["driver"]) + chld_elem.setAttribute('dev', self.drive_map[parm_dic["drive"] + ]["dev"]) + topelem.appendChild(chld_elem) + else: + netpool_lst = self.session.cmd_output("net-list" + ).split('\n') + netpool = [] + for r in range(2, len(netpool_lst) - 2): + netpool.append(netpool_lst[r].split()[0]) + + doc = xml.dom.minidom.Document() + topelem = doc.createElement("interface") + doc.appendChild(topelem) + + chld_elem = doc.createElement("source") + chld_elem.setAttribute('network', netpool[-1]) + topelem.appendChild(chld_elem) + if parm_dic.has_key("mac"): + mac = parm_dic.get("mac") + chld_elem = doc.createElement("mac") + chld_elem.setAttribute('address', mac) + topelem.appendChild(chld_elem) + if not parm_dic.has_key("driver"): + model = re.findall("device_add ([^,\s]+)", command)[0] + else: + model = parm_dic.get("driver") + if model == "virtio-net-pci": + model = "virtio" + chld_elem = doc.createElement("model") + chld_elem.setAttribute('type', model) + topelem.appendChild(chld_elem) + if parm_dic.has_key("id"): + id = parm_dic.get("id") + chld_elem = doc.createElement("target") + chld_elem.setAttribute('dev', id) + topelem.appendChild(chld_elem) + + tmp_xml = doc.toxml() + devfl = tempfile.mktemp(prefix='dev') + devfd = open(devfl, 'w') + devfd.write(tmp_xml) + devfd.close() + return devfl + + def net_del(command): + """ + Create the xml file for the device to be detached + """ + xml_str = "" + id = re.findall("device_del ([^,\s]+)", command)[0] + for i in range(len(self.network_info)): + if id in str(self.network_info[i]): + xml_str = str(self.network_info[i]) + for i in self.drive_map: + if id in str(self.drive_map[i]): + map_key = self.drive_map[i]["dev"] + for i in range(len(self.disk_info)): + if map_key in str(self.disk_info[i]): + xml_str = str(self.disk_info[i]) + devfl = tempfile.mktemp(prefix='dev') + devfd = open(devfl, 'w') + devfd.write(xml_str) + devfd.close() + return devfl + + if "device_add ?" in command: + return "virtio-net-pci virtio-blk-pci e1000 rtl8139" + + if "?" in command: + output = "\nhelp|? [cmd]\ndevice_add\ndevice_del\ndrive_add"\ + "\n__com.redhat_drive_add" + return output + + if "redhat_drive" in command: + drive_dic = dict(re.findall("(file|id)=([^,\s]+)", command)) + self.drive_map[drive_dic["id"]] = drive_dic + return + + if "netdev_add" in command: + id = re.findall("id=(.*?),", command)[0] + net_str = " peer=%s" % id + self.network_info[id] = net_str + return + + if "device_add" in command: + devfile = dev_add(command) + xml_handle = open(devfile) + xml_pars = xml.dom.minidom.parse(xml_handle) + self.session.cmd_output("attach-device %s %s" % + (self.vmname, devfile)) + domxml = self.session.cmd_output("dumpxml %s \n" % self.vmname) + self._parse_dev(domxml) + return + + if "device_del" in command: + devfile = net_del(command) + xml_handle = open(devfile) + xml_pars = xml.dom.minidom.parse(xml_handle) + self.session.cmd_output("detach-device %s %s" % + (self.vmname, devfile)) + domxml = self.session.cmd_output("dumpxml %s \n" % self.vmname) + self._parse_dev(domxml) + return + + if "balloon" in command: + new_mem = re.findall("balloon\s+(\d+)", command)[0] + new_mem = str(int(new_mem) * 1024) + output = self.session.cmd_output("setmem %s %s" % + (self.vmname, new_mem)) + return + + if "system_reset" in command: + self.session.cmd_output("destroy %s" % self.vmname) + self.session.cmd_output("start %s" % self.vmname) + return + + data = self.session.cmd_output(" %s \n" % self.virsh_cmd.get( + command, command)) + return data + + + def is_responsive(self): + """ + Return True if the monitor is responsive. + """ + return True + + + def quit(self): + """ + Send "quit" without waiting for output. + """ + self.cmd("quit") + + + def screendump(self, filename, debug=True): + """ + Request a screendump. + + @param filename: Location for the screendump + @return: The command's output + """ + if debug: + logging.debug("Requesting screendump %s" % filename) + self.cmd("screenshot %s" % filename) + + + def info(self, what): + """ + Request info about something and return the output. + """ + if "network" in what: + return self.network_info + + if "pci" in what: + domxml = self.session.cmd_output("dumpxml %s \n" % + self.vmname) + self._parse_dev(domxml) + return str(self.network_info) + str(self.drive_map) + + if "balloon" in what: + self.session.cmd_output("\n") + netpool_lst = self.session.cmd_output("dominfo %s" % + self.vmname) + return str(int(re.findall("Used memory:\s+(\d+)", netpool_lst) + [0]) / 1024) + + return self.cmd("info %s" % what)
Signature · 1 line
1.7.6.4
Re: [Autotest] [PATCH 06/11] virt: Introducing libvirt monitor
Quoted 71 lines · Lucas Meneghel Rodrigues
This is an initial implementation for a libvirt monitor. With it, we plan on making the libvirt test use all the monitor features, making most of the tests available for kvm available for libvirt.
As of implementation details, it uses aexpect to get a virsh shell, and then the monitor methods are implemented by executing commands on that virsh shell.
As of now, the libvirt vm class is still not using the monitor code, but we plan on making the move soon enough.
Signed-off-by Lucas Meneghel Rodrigues<[email protected]>--- client/virt/libvirt_monitor.py | 322 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 322 insertions(+), 0 deletions(-)create mode 100644
client/virt/libvirt_monitor.pyclient/virt/libvirt_monitor.py new file +47
-0@@ -0,0 +1,322 @@ +import re, tempfile, xml.dom.minidom, logging +import virt_utils, aexpect +from autotest_lib.client.bin import utils + + +class VirshMonitor: + """ + Wraps "Virsh monitor" commands. + """ + + def __init__(self, virsh_exec='virsh', name, vmname, password=None, + prompt=None, hostname='localhost', driver=None, username=None, + linesep="\\n"): + """ + Connect to the hypervisor and get virsh prompt. + + @param virsh_exec: Virsh executable + @param name: Monitor identifier (a string) + @param vmname: VM name + @param password: Hypervisor user password + @param prompt: Virsh prompt + @param hostname: Hypervisor IP + @param driver: Hypervisor driver type + @param username: Hypervisor username + @param linesep: The line separator to use when sending lines + (e.g. '\\n' or '\\r\\n') + """ + self.virsh_exec = virsh_exec + self.name = name + self.vmname = vmname + self.password = password + self.prompt = prompt + self.hostname = hostname + self.driver = driver + self.username = username + self.session = self.login() + self.virsh_cmd = {"help":"help", "quit":"destroy " + self.vmname, + "stop":"suspend", "cont":"resume"} + self.drive_map = {} + self.network_info = [] + self.disk_info = [] + self._parse_domxml() + + + def __del__(self): + self.session.sendline("quit") +
....
client/virt/libvirt_monitor.py line 269
Quoted 11 lines
client/virt/libvirt_monitor.py new file +11
-0+ if "balloon" in command: + new_mem = re.findall("balloon\s+(\d+)", command)[0] + new_mem = str(int(new_mem) * 1024) + output = self.session.cmd_output("setmem %s %s" % + (self.vmname, new_mem)) + return + + if "system_reset" in command: + self.session.cmd_output("destroy %s" % self.vmname) + self.session.cmd_output("start %s" % self.vmname) + return
This would make qemu process exit, this is not same as qemu monitor cmd(system_reset). We may migrate guest which is repeatedly rebooting, then migration will be failed.
# grep system_reset virt/tests/* virt/tests/boot.py: 2) Send a reboot command or a system_reset monitor command (optional) virt/tests/boot.py: if params["reboot_method"] == "system_reset": Binary file virt/tests/boot.pyc matches virt/tests/iofuzz.py: session = vm.reboot(method="system_reset")
'system_reset' of qemu monitor is only called for fakereboot in Libvirt. but Libvirt developer told me they may add new API for it.
Quoted 15 lines
client/virt/libvirt_monitor.py new file +15
-0+ data = self.session.cmd_output(" %s \n" % self.virsh_cmd.get( + command, command)) + return data + + + def is_responsive(self): + """ + Return True if the monitor is responsive. + """ + return True + + + def quit(self): + """ + Send "quit" without waiting for output.
client/virt/libvirt_monitor.py line 295
Quoted 10 lines
client/virt/libvirt_monitor.py new file +10
-0+ """ + self.cmd("quit") + + + def screendump(self, filename, debug=True): + """ + Request a screendump. + + @param filename: Location for the screendump + @return: The command's output
^^^^^^^^^^^^
client/virt/libvirt_monitor.py line 299
Quoted 4 lines
client/virt/libvirt_monitor.py new file +4
-0+ """ + if debug: + logging.debug("Requesting screendump %s" % filename) + self.cmd("screenshot %s" % filename)
cmd output is not returned.
Quoted 21 lines
client/virt/libvirt_monitor.py new file +21
-0+ def info(self, what): + """ + Request info about something and return the output. + """ + if "network" in what: + return self.network_info + + if "pci" in what: + domxml = self.session.cmd_output("dumpxml %s \n" % + self.vmname) + self._parse_dev(domxml) + return str(self.network_info) + str(self.drive_map) + + if "balloon" in what: + self.session.cmd_output("\n") + netpool_lst = self.session.cmd_output("dominfo %s" % + self.vmname) + return str(int(re.findall("Used memory:\s+(\d+)", netpool_lst) + [0]) / 1024) + + return self.cmd("info %s" % what)
Re: [Autotest] [PATCH 06/11] virt: Introducing libvirt monitor
Quoted 86 lines · Amos Kong
Quoted 71 lines · Lucas Meneghel Rodrigues
This is an initial implementation for a libvirt monitor. With it, we plan on making the libvirt test use all the monitor features, making most of the tests available for kvm available for libvirt.
As of implementation details, it uses aexpect to get a virsh shell, and then the monitor methods are implemented by executing commands on that virsh shell.
As of now, the libvirt vm class is still not using the monitor code, but we plan on making the move soon enough.
Signed-off-by Lucas Meneghel Rodrigues<[email protected]>---
client/virt/libvirt_monitor.py| 322 ++++++++++++++++++++++++++++++++++++++++1 files changed, 322 insertions(+), 0 deletions(-)create mode 100644
client/virt/libvirt_monitor.pyclient/virt/libvirt_monitor.py new file +47
-0@@ -0,0 +1,322 @@ +import re, tempfile, xml.dom.minidom, logging +import virt_utils, aexpect +from autotest_lib.client.bin import utils + + +class VirshMonitor: + """ + Wraps "Virsh monitor" commands. + """ + + def __init__(self, virsh_exec='virsh', name, vmname, password=None, + prompt=None, hostname='localhost', driver=None, username=None, + linesep="\\n"): + """ + Connect to the hypervisor and get virsh prompt. + + @param virsh_exec: Virsh executable + @param name: Monitor identifier (a string) + @param vmname: VM name + @param password: Hypervisor user password + @param prompt: Virsh prompt + @param hostname: Hypervisor IP + @param driver: Hypervisor driver type + @param username: Hypervisor username + @param linesep: The line separator to use when sending lines + (e.g. '\\n' or '\\r\\n') + """ + self.virsh_exec = virsh_exec + self.name = name + self.vmname = vmname + self.password = password + self.prompt = prompt + self.hostname = hostname + self.driver = driver + self.username = username + self.session = self.login() + self.virsh_cmd = {"help":"help", "quit":"destroy " + self.vmname, + "stop":"suspend", "cont":"resume"} + self.drive_map = {} + self.network_info = [] + self.disk_info = [] + self._parse_domxml() + + + def __del__(self): + self.session.sendline("quit") +....
Quoted 11 lines
+ if "balloon" in command:
+ new_mem =re.findall("balloon\s+(\d+)", command)[0]
+ new_mem =str(int(new_mem) * 1024)
+ output = self.session.cmd_output("setmem %s %s" %
+ (self.vmname,new_mem))
+ return
+
+ if "system_reset" in command:
+ self.session.cmd_output("destroy %s" % self.vmname)
+ self.session.cmd_output("start %s" % self.vmname)
+ return
Quoted 3 lines
This would make qemu process exit, this is not same as qemu monitor
cmd(system_reset). We may migrate guest which is repeatedly rebooting, then migration will be failed.
Ok, noted, but since there's no such an API written for it yet, and since we are still not supporting migration tests, I believe it's OK to leave it like that for now.
Quoted 40 lines
# grep system_reset virt/tests/* virt/tests/boot.py: 2) Send a reboot command or a system_reset monitor command (optional) virt/tests/boot.py: if params["reboot_method"] == "system_reset": Binary file virt/tests/boot.pyc matches virt/tests/iofuzz.py: session = vm.reboot(method="system_reset")'
system_reset' of qemu monitor is only called for fakereboot in Libvirt. but Libvirt developer told me they may add new API for it.Quoted 15 lines
+ data = self.session.cmd_output(" %s \n" % self.virsh_cmd.get(
+ command, command))
+ return dataclient/virt/libvirt_monitor.py new file +12
-0+ + + def is_responsive(self): + """ + Return True if the monitor is responsive. + """ + return True + + + def quit(self): + """ + Send "quit" without waiting for output.client/virt/libvirt_monitor.py line 295
Quoted 10 lines
client/virt/libvirt_monitor.py new file +10
-0+ """ + self.cmd("quit") + + + def screendump(self, filename, debug=True): + """ + Request a screendump. + + @param filename: Location for the screendump + @return: The command's output^^^^^^^^^^^^
Quoted 6 lines
Quoted 4 lines
+ """
+ if debug:
+ logging.debug("Requesting screendump %s" % filename)
+ self.cmd("screenshot %s" % filename)cmd output is not returned.
Ok, that was easy enough to fix, thanks! I've updated my branch with all the fixes pointed out so far.
Quoted 28 lines
Quoted 12 lines
+ def
info(self, what):
+ """
+ Request info about something and return the output.
+ """
+ if "network" in what:
+ return self.network_infoclient/virt/libvirt_monitor.py new file +5
-0+ + if "pci" in what: + domxml = self.session.cmd_output("dumpxml %s \n" % + self.vmname) + self._parse_dev(domxml)client/virt/libvirt_monitor.py line 322
Quoted 10 lines
client/virt/libvirt_monitor.py new file +10
-0+ return str(self.network_info) + str(self.drive_map) + + if "balloon" in what: + self.session.cmd_output("\n") + netpool_lst = self.session.cmd_output("dominfo %s" % + self.vmname) + return str(int(re.findall("Used memory:\s+(\d+)", netpool_lst) + [0]) / 1024) + + return self.cmd("info %s" % what)_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
Signature · 1 line
Lucas
PATCH 7/11 virt.virt_env_process: Add libvirt vm handling
In reply to Lucas Meneghel RodriguesWith this patch, we make libvirt vm handling integrating to pre/postprocessing code, making it possible the execution of a libvirt test. The idea was to try to abstract some concepts and intrude the least possible in the pre/postprocessing code.
--- client/virt/virt_env_process.py | 51 +++++++++++++++++++++++++++++--------- 1 files changed, 39 insertions(+), 12 deletions(-)
client/virt/virt_env_process.py +39 -12
@@ -2,7 +2,7 @@ import os, time, commands, re, logging, glob, threading, shutil from autotest_lib.client.bin import utils from autotest_lib.client.common_lib import error import aexpect, virt_utils, kvm_monitor, ppm_utils, virt_test_setup -import virt_vm, kvm_vm +import virt_vm, kvm_vm, libvirt_vm try: import PIL.Image except ImportError:
@@ -51,13 +51,23 @@ def preprocess_vm(test, params, env, name): """ logging.debug("Preprocessing VM '%s'", name) vm = env.get_vm(name) + vm_type = params.get('vm_type') if not vm: logging.debug("VM object for '%s' does not exist, creating it", name) - vm_type = params.get('vm_type') if vm_type == 'kvm': vm = kvm_vm.VM(name, params, test.bindir, env.get("address_cache")) + if vm_type == 'libvirt': + vm = libvirt_vm.VM(name, params, test.bindir, env.get("address_cache")) env.register_vm(name, vm) + remove_vm = False + if params.get("force_remove_vm") == "yes": + logging.debug("'force_remove_vm' specified; removing VM...") + remove_vm = True + + if remove_vm and not libvirt_vm.virsh_remove_domain(name): + raise error.TestError("Could not remove VM") + start_vm = False if params.get("restart_vm") == "yes":
@@ -68,18 +78,31 @@ def preprocess_vm(test, params, env, name): "incoming migration mode") start_vm = True elif params.get("start_vm") == "yes": - if not vm.is_alive(): - logging.debug("VM is not alive, starting it") - start_vm = True - if vm.needs_restart(name=name, params=params, basedir=test.bindir): - logging.debug("Current VM specs differ from requested one; " - "restarting it") - start_vm = True + # need to deal with libvirt VM differently than qemu + if vm_type == 'libvirt': + if not libvirt_vm.virsh_is_alive(name): + logging.debug("VM is not alive; starting it...") + start_vm = True + else: + if not vm.is_alive(): + logging.debug("VM is not alive, starting it") + start_vm = True + if vm.needs_restart(name=name, params=params, basedir=test.bindir): + logging.debug("Current VM specs differ from requested one; " + "restarting it") + start_vm = True if start_vm: - # Start the VM (or restart it if it's already up) - vm.create(name, params, test.bindir, - migration_mode=params.get("migration_mode")) + if vm_type == 'libvirt' and params.get("type") != "unattended_install": + libvirt_vm.virsh_start(name, vm) + # Wait for the domain to be created + virt_utils.wait_for(func=vm.is_alive, timeout=60, + text=("waiting for domain %s to start" % + vm.name)) + else: + # Start the VM (or restart it if it's already up) + vm.create(name, params, test.bindir, + migration_mode=params.get("migration_mode")) else: # Don't start the VM, just update its params vm.params = params
@@ -277,6 +300,8 @@ def preprocess(test, params, env): if params.get("setup_hugepages") == "yes": h = virt_test_setup.HugePageConfig(params) h.setup() + if params.get("vm_type") == "libvirt": + libvirt_vm.libvirtd_restart() # Execute any pre_commands if params.get("pre_command"):
@@ -377,6 +402,8 @@ def postprocess(test, params, env): if params.get("setup_hugepages") == "yes": h = virt_test_setup.HugePageConfig(params) h.cleanup() + if params.get("vm_type") == "libvirt": + libvirt_vm.libvirtd_restart() # Execute any post_commands if params.get("post_command"):
Signature · 1 line
1.7.6.4
PATCH 8/11 client.tests: Introducing libvirt test
In reply to Lucas Meneghel RodriguesIntroduce libvirt test. The small amount of actual code on this test is made possible by code reuse, made possible by the kvm refactor patchset + the previous patches on this set.
The obvious difference is that some new parameters had to be introduced to accomplish libvirt testing. A more complete description of such parameters will be present on our online documentation (wiki).
--- client/tests/libvirt/README | 11 + client/tests/libvirt/cdkeys.cfg.sample | 18 + client/tests/libvirt/common.py | 8 + client/tests/libvirt/control | 64 + client/tests/libvirt/get_started.py | 22 + client/tests/libvirt/libvirt.py | 9 + client/tests/libvirt/tests.cfg.sample | 73 + client/tests/libvirt/tests_base.cfg.sample | 2918 ++++++++++++++++++++++++++++ client/tests/libvirt/virtio-win.cfg.sample | 235 +++ 9 files changed, 3358 insertions(+), 0 deletions(-) create mode 100644 client/tests/libvirt/README create mode 100644 client/tests/libvirt/cdkeys.cfg.sample create mode 100644 client/tests/libvirt/common.py create mode 100644 client/tests/libvirt/control create mode 100755 client/tests/libvirt/get_started.py create mode 100644 client/tests/libvirt/libvirt.py create mode 100644 client/tests/libvirt/tests.cfg.sample create mode 100644 client/tests/libvirt/tests_base.cfg.sample create mode 100644 client/tests/libvirt/virtio-win.cfg.sample
client/tests/libvirt/README new file +11 -0
@@ -0,0 +1,11 @@ +For the impatient: + +Execute the get_started.py script located on this directory, +that will guide you through setting up the default libvirt test +scenario: + + * Guest install with Fedora 15 + * Boot, reboot and shutdown test + +The script will help you to create all the directories, and +even get the OS iso in case you don't have it yet.
client/tests/libvirt/cdkeys.cfg.sample new file +18 -0
@@ -0,0 +1,18 @@ +# Copy this file to cdkeys.cfg and edit it. +# +# Replace the 'CDKEY' strings with real cdkeys where necessary. +# Feel free to add additional guests as required. + +RHEL.5.3.i386: cdkey = CDKEY +RHEL.5.3.x86_64: cdkey = CDKEY +Win2000: cdkey = CDKEY +WinXP.32: cdkey = CDKEY +WinXP.64: cdkey = CDKEY +Win2003.32: cdkey = CDKEY +Win2003.64: cdkey = CDKEY +WinVista.32: cdkey = CDKEY +WinVista.64: cdkey = CDKEY +Win2008.32: cdkey = CDKEY +Win2008.64: cdkey = CDKEY +Win7.32: cdkey = CDKEY +Win7.64: cdkey = CDKEY
client/tests/libvirt/common.py new file +8 -0
@@ -0,0 +1,8 @@ +import os, sys +dirname = os.path.dirname(sys.modules[__name__].__file__) +client_dir = os.path.abspath(os.path.join(dirname, "..", "..")) +sys.path.insert(0, client_dir) +import setup_modules +sys.path.pop(0) +setup_modules.setup(base_path=client_dir, + root_module_name="autotest_lib.client")
client/tests/libvirt/control new file +64 -0
64 lines not on this page · raw message
client/tests/libvirt/get_started.py new file +22 -0
@@ -0,0 +1,22 @@ +#!/usr/bin/python +""" +Program to help setup libvirt test environment + +@copyright: Red Hat 2011 +""" +import os, sys +import common +from autotest_lib.client.virt import virt_utils + +test_name = "libvirt" +test_dir = os.path.dirname(sys.modules[__name__].__file__) +test_dir = os.path.abspath(test_dir) +base_dir = "/tmp/libvirt_autotest_root" +default_userspace_paths = ["/usr/bin/virt-install"] +check_modules = None +online_docs_url = None + +if __name__ == "__main__": + virt_utils.virt_test_assistant(test_name, test_dir, base_dir, + default_userspace_paths, check_modules, + online_docs_url)
client/tests/libvirt/libvirt.py new file +9 -0
@@ -0,0 +1,9 @@ +from autotest_lib.client.virt import virt_test + +class libvirt(virt_test.virt_test): + """ + Suite of libvirt virtualization functional tests. + + @copyright: Red Hat 2011 + """ + pass
client/tests/libvirt/tests.cfg.sample new file +73 -0
73 lines not on this page · raw message
client/tests/libvirt/tests_base.cfg.sample new file +2918 -0
2,794 lines not on this page · raw message
client/tests/libvirt/virtio-win.cfg.sample new file +235 -0
235 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 6 lines
1.7.6.4 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
Part of the diff is not shown here. View the raw message.
PATCH 9/11 Virt: builtin HTTP server for unattended installs
In reply to Lucas Meneghel RodriguesFrom: Cleber Rosa <[email protected]>
This adds a simple HTTP server that is good enought to support unattended installs. Tested serving kickstart files and RHEL/Fedora content to anaconda.
--- client/virt/virt_http_server.py | 124 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 124 insertions(+), 0 deletions(-) create mode 100644 client/virt/virt_http_server.py
client/virt/virt_http_server.py new file +124 -0
@@ -0,0 +1,124 @@ +import os, posixpath, urlparse, urllib, logging +import BaseHTTPServer, SimpleHTTPServer + + +class HTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): + + def do_GET(self): + """ + Serve a GET request. + """ + range = self.parse_header_byte_range() + if range: + f = self.send_head_range(range[0], range[1]) + if f: + self.copyfile_range(f, self.wfile, range[0], range[1]) + f.close() + else: + f = self.send_head() + if f: + self.copyfile(f, self.wfile) + f.close() + + + def parse_header_byte_range(self): + range_param = 'Range' + range_discard = 'bytes=' + if self.headers.has_key(range_param): + range = self.headers.get(range_param) + if range.startswith(range_discard): + range = range[len(range_discard):] + begin, end = range.split('-') + return (int(begin), int(end)) + return None + + + def copyfile_range(self, source_file, output_file, range_begin, range_end): + """ + Copies a range of a file to destination. + """ + range_size = range_end - range_begin + 1 + source_file.seek(range_begin) + buf = source_file.read(range_size) + output_file.write(buf) + + + def send_head_range(self, range_begin, range_end): + path = self.translate_path(self.path) + f = None + if os.path.isdir(path): + for index in "index.html", "index.htm": + index = os.path.join(path, index) + if os.path.exists(index): + path = index + break + else: + return self.list_directory(path) + ctype = self.guess_type(path) + try: + # Always read in binary mode. Opening files in text mode may cause + # newline translations, making the actual size of the content + # transmitted *less* than the content-length! + f = open(path, 'rb') + except IOError: + self.send_error(404, "File not found") + return None + self.send_response(206, "Partial Content") + file_size = str(os.fstat(f.fileno())[6]) + range_size = str(range_end - range_begin + 1) + self.send_header("Accept-Ranges", "bytes") + self.send_header("Content-Length", range_size) + self.send_header("Content-Range", "bytes %s-%s/%s" % (range_begin, + range_end, + file_size)) + self.send_header("Content-type", ctype) + self.end_headers() + return f + + + def translate_path(self, path): + """ + Translate a /-separated PATH to the local filename syntax. + + Components that mean special things to the local file system + (e.g. drive or directory names) are ignored. (XXX They should + probably be diagnosed.) + + """ + # abandon query parameters + path = urlparse.urlparse(path)[2] + path = posixpath.normpath(urllib.unquote(path)) + words = path.split('/') + words = filter(None, words) + path = self.server.cwd + for word in words: + drive, word = os.path.splitdrive(word) + head, word = os.path.split(word) + if word in (os.curdir, os.pardir): continue + path = os.path.join(path, word) + return path + + + def log_message(self, format, *args): + logging.debug("builtin http server handling request from %s: %s" % + (self.address_string(), format%args)) + + +def http_server(port=8000, cwd=None, terminate_callable=None): + http = BaseHTTPServer.HTTPServer(('', port), HTTPRequestHandler) + if cwd is None: + cwd = os.getcwd() + http.cwd = cwd + + while True: + if terminate_callable is not None: + terminate = terminate_callable() + else: + terminate = False + + if not terminate: + http.handle_request() + + +if __name__ == '__main__': + http_server()
Signature · 1 line
1.7.6.4
PATCH 10/11 Virt: support XEN via libvirt and auto url installer
In reply to Lucas Meneghel RodriguesFrom: Cleber Rosa <[email protected]>
This patchs adds proper detection of active (alive) XEN domains via libvirt; a quick way to determine whether the current connected hypervisor is XEN or QEMU/KVM and also deals with virt-install options and syntax supported on RHEL 5 libvirt+XEN.
--- client/virt/libvirt_vm.py | 54 ++++++++++++++++++++++++++++---------------- 1 files changed, 34 insertions(+), 20 deletions(-)
client/virt/libvirt_vm.py +34 -20
@@ -104,8 +104,8 @@ def virsh_is_dead(name): @param name: VM name """ - if (virsh_domstate(name) == 'running' or - virsh_domstate(name) == 'idle'): + state = virsh_domstate(name) + if state in ('running', 'idle', 'no state'): return False else: return True
@@ -250,6 +250,15 @@ def virsh_domain_exists(name): logging.warning("VM %s does not exist", name) return False +VIRSH_DEFAULT_URI = virsh_uri() +LIBVIRT_QEMU = False +LIBVIRT_XEN = False + +if VIRSH_DEFAULT_URI == 'qemu:///system': + LIBVIRT_QEMU = True +elif VIRSH_DEFAULT_URI == 'xen:///': + LIBVIRT_XEN = True + class VM(virt_vm.BaseVM): """
@@ -410,7 +419,6 @@ class VM(virt_vm.BaseVM): return " --vcpu=%s" % smp def add_location(help, location): - #return " --location %s" % location if has_option(help, "location"): return " --location %s" % location else:
@@ -563,7 +571,9 @@ class VM(virt_vm.BaseVM): # TODO: directory location for vmlinuz/kernel for cdrom install ? location = None if params.get("medium") == 'url': - location = params.get("url") + if params.get("url") == 'auto': + location = params.get('auto_content_url') + elif params.get("medium") == 'kernel_initrd': # directory location of kernel/initrd pair (directory layout must # be in format libvirt will recognize)
@@ -634,19 +644,20 @@ class VM(virt_vm.BaseVM): image_params.get("drive_cache"), image_params.get("image_format")) - for cdrom in params.objects("cdroms"): - cdrom_params = params.object_params(cdrom) - iso = cdrom_params.get("cdrom") - if params.get("use_libvirt_cdrom_switch") == 'yes': - # we don't want to skip the winutils iso - if not cdrom == 'winutils': - logging.debug("Using --cdrom instead of --disk for install") - logging.debug("Skipping CDROM:%s:%s", cdrom, iso) - continue - if params.get("medium") == 'cdrom_no_kernel_initrd': - if iso == params.get("cdrom_cd1"): - logging.debug("Using cdrom or url for install") - logging.debug("Skipping CDROM: %s", iso) + if LIBVIRT_QEMU: + for cdrom in params.objects("cdroms"): + cdrom_params = params.object_params(cdrom) + iso = cdrom_params.get("cdrom") + if params.get("use_libvirt_cdrom_switch") == 'yes': + # we don't want to skip the winutils iso + if not cdrom == 'winutils': + logging.debug("Using --cdrom instead of --disk for install") + logging.debug("Skipping CDROM:%s:%s", cdrom, iso) + continue + if params.get("medium") == 'cdrom_no_kernel_initrd': + if iso == params.get("cdrom_cd1"): + logging.debug("Using cdrom or url for install") + logging.debug("Skipping CDROM: %s", iso) continue if iso:
@@ -685,9 +696,12 @@ class VM(virt_vm.BaseVM): virt_install_cmd += " --mac %s" % mac self.nic_mac = mac - virt_install_cmd += (" --network %s,model=%s" % - (params.get("virsh_network"), - params.get("nic_model"))) + if LIBVIRT_XEN: + virt_install_cmd += (" --network=%s" % params.get("virsh_network")) + elif LIBVIRT_QEMU: + virt_install_cmd += (" --network=%s,model=%s" % + (params.get("virsh_network"), + params.get("nic_model"))) if params.get("use_no_reboot") == "yes": virt_install_cmd += " --noreboot"
Signature · 1 line
1.7.6.4
PATCH 11/11 Virt: add support for XEN via libvirt installs and auto url
In reply to Lucas Meneghel RodriguesFrom: Cleber Rosa <[email protected]>
This patch adds support to unattended installs via libvirt+XEN and serving installation content via the auto url feature (using a builtin http server).
A sample configuration is provided to run a Fedora 15 64 bits PV based test (libvirt_xenpv_f15_quick).
--- client/tests/libvirt/tests.cfg.sample | 15 ++ client/tests/libvirt/tests_base.cfg.sample | 7 + client/virt/tests/unattended_install.py | 197 +++++++++++++++++++++++++--- 3 files changed, 203 insertions(+), 16 deletions(-)
client/tests/libvirt/tests.cfg.sample +15 -0
@@ -38,6 +38,21 @@ variants: only Fedora.15.64 only unattended_install.cdrom, boot, reboot, shutdown + # Runs virt-install, f15 64 as a 64 bit PV guest OS, install, boot, shutdown + - @libvirt_xenpv_f15_quick: + virt_install_binary = /usr/bin/virt-install + qemu_img_binary = /usr/bin/qemu-img + url = auto + cdrom_cd1 = isos/linux/Fedora-15-x86_64-DVD.iso + only raw + only xennet + only xenblk + only smp2 + only no_pci_assignable + only smallpages + only Fedora.15.64 + only unattended_install.url, boot, reboot, shutdown + # Runs virt-install, RHEL 6.0 64 bit guest OS, install, boot, shutdown - @libvirt_rhel60_quick: virt_install_binary = /usr/bin/virt-install
client/tests/libvirt/tests_base.cfg.sample +7 -0
@@ -90,6 +90,9 @@ use_os_variant = no use_os_type = yes # libvirt network to use examples network=default or bridge=br0 virsh_network = network=default +# if using 'url = auto' to install, url_auto_ip must match IP on +# selected virsh network or bridge +url_auto_ip = 192.168.122.1 # wait in minutes for virt-install to finish (bz still open) use_virt_install_wait = no virt_install_wait_time = 300
@@ -1165,6 +1168,8 @@ variants: # Device selection for the NDISTest server machine dp_regex_servermsgdev = VirtIO Ethernet Adapter$ dp_regex_serversupportdev = VirtIO Ethernet Adapter #2$ + -xennet: + # placeholder # Guests variants:
@@ -2865,6 +2870,8 @@ variants: drive_format=usb2 - usb.cdrom: cd_format=usb2 + - xenblk: + # placeholder virtio_net, virtio_blk, e1000, balloon_check:
client/virt/tests/unattended_install.py +181 -16
263 lines not on this page · raw message
Signature · 1 line
1.7.6.4