2013-03-18 05:06:52 +08:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
# MA 02110-1301 USA.
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import os
|
|
|
|
import logging
|
|
|
|
|
|
|
|
import urlgrabber.progress as progress
|
|
|
|
|
|
|
|
import virtinst
|
|
|
|
from virtinst import VirtualDisk
|
|
|
|
from virtinst import VirtualAudio
|
|
|
|
from virtinst import VirtualNetworkInterface
|
2013-07-16 05:45:43 +08:00
|
|
|
from virtinst import VirtualHostDevice
|
2013-07-16 21:14:37 +08:00
|
|
|
from virtinst import (VirtualChannelDevice, VirtualConsoleDevice,
|
|
|
|
VirtualParallelDevice, VirtualSerialDevice)
|
2013-03-18 05:06:52 +08:00
|
|
|
from virtinst import VirtualVideoDevice
|
|
|
|
from virtinst import VirtualController
|
|
|
|
from virtinst import VirtualWatchdog
|
|
|
|
from virtinst import VirtualMemballoon
|
2013-04-12 04:32:00 +08:00
|
|
|
|
2013-04-11 07:48:07 +08:00
|
|
|
from tests import utils
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2013-04-12 04:32:00 +08:00
|
|
|
# pylint: disable=W0212
|
|
|
|
# Access to protected member, needed to unittest stuff
|
|
|
|
|
2013-03-18 05:06:52 +08:00
|
|
|
_testconn = utils.open_testdriver()
|
|
|
|
_kvmconn = utils.open_testkvmdriver()
|
|
|
|
_plainkvm = utils.open_plainkvm()
|
|
|
|
_plainxen = utils.open_plainxen()
|
|
|
|
|
2013-04-14 02:34:52 +08:00
|
|
|
|
2013-03-18 05:06:52 +08:00
|
|
|
def qemu_uri():
|
|
|
|
return "qemu:///system"
|
|
|
|
|
2013-04-14 02:34:52 +08:00
|
|
|
|
2013-03-18 05:06:52 +08:00
|
|
|
def xen_uri():
|
|
|
|
return "xen:///"
|
|
|
|
|
2013-04-14 02:34:52 +08:00
|
|
|
|
2013-03-18 05:06:52 +08:00
|
|
|
def build_xmlfile(filebase):
|
|
|
|
if not filebase:
|
|
|
|
return None
|
|
|
|
return os.path.join("tests/xmlconfig-xml", filebase + ".xml")
|
|
|
|
|
2013-04-14 02:34:52 +08:00
|
|
|
|
2013-03-18 05:06:52 +08:00
|
|
|
class TestXMLConfig(unittest.TestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
utils.reset_conn()
|
|
|
|
logging.debug("Running %s", self.id())
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
if os.path.exists(utils.scratch):
|
|
|
|
os.rmdir(utils.scratch)
|
|
|
|
|
|
|
|
def _compare(self, guest, filebase, do_install, do_disk_boot=False,
|
|
|
|
do_create=True):
|
|
|
|
filename = filebase and build_xmlfile(filebase) or None
|
|
|
|
|
|
|
|
guest._prepare_install(progress.BaseMeter())
|
|
|
|
try:
|
2013-04-11 22:44:27 +08:00
|
|
|
actualXML = guest.get_xml_config(install=do_install,
|
2013-03-18 05:06:52 +08:00
|
|
|
disk_boot=do_disk_boot)
|
|
|
|
|
|
|
|
if filename:
|
|
|
|
utils.diff_compare(actualXML, filename)
|
|
|
|
if do_create:
|
|
|
|
utils.test_create(guest.conn, actualXML)
|
|
|
|
finally:
|
|
|
|
guest._cleanup_install()
|
|
|
|
|
|
|
|
def _testInstall(self, guest,
|
|
|
|
instxml=None, bootxml=None, contxml=None):
|
|
|
|
instname = build_xmlfile(instxml)
|
|
|
|
bootname = build_xmlfile(bootxml)
|
|
|
|
contname = build_xmlfile(contxml)
|
|
|
|
consolecb = None
|
|
|
|
meter = None
|
|
|
|
removeOld = None
|
|
|
|
wait = True
|
|
|
|
dom = None
|
|
|
|
|
|
|
|
try:
|
|
|
|
dom = guest.start_install(consolecb, meter, removeOld, wait)
|
|
|
|
dom.destroy()
|
|
|
|
|
|
|
|
# Replace kernel/initrd with known info
|
2013-07-17 08:05:24 +08:00
|
|
|
if guest.installer._install_kernel:
|
|
|
|
guest.installer._install_kernel = "kernel"
|
|
|
|
guest.installer._install_initrd = "initrd"
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2013-04-11 22:44:27 +08:00
|
|
|
xmlinst = guest.get_xml_config(True, False)
|
|
|
|
xmlboot = guest.get_xml_config(False, False)
|
|
|
|
xmlcont = guest.get_xml_config(True, True)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
if instname:
|
|
|
|
utils.diff_compare(xmlinst, instname)
|
|
|
|
if contname:
|
|
|
|
utils.diff_compare(xmlcont, contname)
|
|
|
|
if bootname:
|
|
|
|
utils.diff_compare(xmlboot, bootname)
|
|
|
|
|
|
|
|
if guest.get_continue_inst():
|
|
|
|
guest.continue_install(consolecb, meter, wait)
|
|
|
|
|
|
|
|
finally:
|
|
|
|
if dom:
|
|
|
|
try:
|
|
|
|
dom.destroy()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
dom.undefine()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def testBootParavirtDiskFile(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk("/tmp/somerandomfilename.img"))
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-paravirt-disk-file", False)
|
|
|
|
|
|
|
|
def testBootParavirtDiskFileBlktapCapable(self):
|
2013-04-11 22:27:02 +08:00
|
|
|
oldblktap = virtinst.util.is_blktap_capable
|
2013-03-18 05:06:52 +08:00
|
|
|
try:
|
2013-07-07 00:44:53 +08:00
|
|
|
virtinst.util.is_blktap_capable = lambda ignore: True
|
2013-03-18 05:06:52 +08:00
|
|
|
g = utils.get_basic_paravirt_guest()
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-paravirt-disk-drv-tap", False)
|
|
|
|
finally:
|
2013-04-11 22:27:02 +08:00
|
|
|
virtinst.util.is_blktap_capable = oldblktap
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
def testBootParavirtDiskBlock(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_blkdisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-paravirt-disk-block", False)
|
|
|
|
|
|
|
|
def testBootParavirtDiskDrvPhy(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
|
|
|
disk = utils.get_blkdisk()
|
|
|
|
disk.driver_name = VirtualDisk.DRIVER_PHY
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(disk)
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-paravirt-disk-drv-phy", False)
|
|
|
|
|
|
|
|
def testBootParavirtDiskDrvFile(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
|
|
|
disk = utils.get_filedisk()
|
|
|
|
disk.driver_name = VirtualDisk.DRIVER_FILE
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(disk)
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-paravirt-disk-drv-file", False)
|
|
|
|
|
|
|
|
def testBootParavirtDiskDrvTap(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
|
|
|
disk = utils.get_filedisk()
|
|
|
|
disk.driver_name = VirtualDisk.DRIVER_TAP
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(disk)
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-paravirt-disk-drv-tap", False)
|
|
|
|
|
|
|
|
def testBootParavirtDiskDrvTapQCow(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
|
|
|
disk = utils.get_filedisk()
|
|
|
|
disk.driver_name = VirtualDisk.DRIVER_TAP
|
|
|
|
disk.driver_type = VirtualDisk.DRIVER_TAP_QCOW
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(disk)
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-paravirt-disk-drv-tap-qcow", False)
|
|
|
|
|
|
|
|
def testBootParavirtManyDisks(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
|
|
|
disk = utils.get_filedisk("/tmp/test2.img")
|
|
|
|
disk.driver_name = VirtualDisk.DRIVER_TAP
|
|
|
|
disk.driver_type = VirtualDisk.DRIVER_TAP_QCOW
|
|
|
|
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk("/tmp/test1.img"))
|
|
|
|
g.add_device(disk)
|
|
|
|
g.add_device(utils.get_blkdisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-paravirt-many-disks", False)
|
|
|
|
|
|
|
|
def testBootFullyvirtDiskFile(self):
|
|
|
|
g = utils.get_basic_fullyvirt_guest()
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-fullyvirt-disk-file", False)
|
|
|
|
|
|
|
|
def testBootFullyvirtDiskBlock(self):
|
|
|
|
g = utils.get_basic_fullyvirt_guest()
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_blkdisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-fullyvirt-disk-block", False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def testInstallParavirtDiskFile(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-paravirt-disk-file", True)
|
|
|
|
|
|
|
|
def testInstallParavirtDiskBlock(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_blkdisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-paravirt-disk-block", True)
|
|
|
|
|
|
|
|
def testInstallParavirtDiskDrvPhy(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
|
|
|
disk = utils.get_blkdisk()
|
|
|
|
disk.driver_name = VirtualDisk.DRIVER_PHY
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(disk)
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-paravirt-disk-drv-phy", True)
|
|
|
|
|
|
|
|
def testInstallParavirtDiskDrvFile(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
|
|
|
disk = utils.get_filedisk()
|
|
|
|
disk.driver_name = VirtualDisk.DRIVER_FILE
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(disk)
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-paravirt-disk-drv-file", True)
|
|
|
|
|
|
|
|
def testInstallParavirtDiskDrvTap(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
|
|
|
disk = utils.get_filedisk()
|
|
|
|
disk.driver_name = VirtualDisk.DRIVER_TAP
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(disk)
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-paravirt-disk-drv-tap", True)
|
|
|
|
|
|
|
|
def testInstallParavirtDiskDrvTapQCow(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
|
|
|
disk = utils.get_filedisk()
|
|
|
|
disk.driver_name = VirtualDisk.DRIVER_TAP
|
|
|
|
disk.driver_type = VirtualDisk.DRIVER_TAP_QCOW
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(disk)
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-paravirt-disk-drv-tap-qcow", True)
|
|
|
|
|
|
|
|
def testInstallParavirtManyDisks(self):
|
|
|
|
g = utils.get_basic_paravirt_guest()
|
|
|
|
disk = utils.get_filedisk("/tmp/test2.img")
|
|
|
|
disk.driver_name = VirtualDisk.DRIVER_TAP
|
|
|
|
disk.driver_type = VirtualDisk.DRIVER_TAP_QCOW
|
|
|
|
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk("/tmp/test1.img"))
|
|
|
|
g.add_device(disk)
|
|
|
|
g.add_device(utils.get_blkdisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-paravirt-many-disks", True)
|
|
|
|
|
|
|
|
def testInstallFullyvirtDiskFile(self):
|
|
|
|
g = utils.get_basic_fullyvirt_guest()
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-fullyvirt-disk-file", True)
|
|
|
|
|
|
|
|
def testInstallFullyvirtDiskBlock(self):
|
|
|
|
g = utils.get_basic_fullyvirt_guest()
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_blkdisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-fullyvirt-disk-block", True)
|
|
|
|
|
|
|
|
def testInstallFVPXE(self):
|
|
|
|
i = utils.make_pxe_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-fullyvirt-pxe", True)
|
|
|
|
|
|
|
|
def testBootFVPXE(self):
|
|
|
|
i = utils.make_pxe_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-fullyvirt-pxe", False)
|
|
|
|
|
|
|
|
def testBootFVPXEAlways(self):
|
|
|
|
i = utils.make_pxe_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
g.installer.bootconfig.bootorder = [
|
|
|
|
g.installer.bootconfig.BOOT_DEVICE_NETWORK]
|
|
|
|
g.installer.bootconfig.enable_bootmenu = True
|
|
|
|
|
|
|
|
self._compare(g, "boot-fullyvirt-pxe-always", False)
|
|
|
|
|
|
|
|
def testInstallFVPXENoDisks(self):
|
|
|
|
i = utils.make_pxe_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
self._compare(g, "install-fullyvirt-pxe-nodisks", True)
|
|
|
|
|
|
|
|
def testBootFVPXENoDisks(self):
|
|
|
|
i = utils.make_pxe_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
self._compare(g, "boot-fullyvirt-pxe-nodisks", False)
|
|
|
|
|
|
|
|
def testInstallFVLiveCD(self):
|
|
|
|
i = utils.make_live_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
self._compare(g, "install-fullyvirt-livecd", False)
|
|
|
|
|
|
|
|
def testDoubleInstall(self):
|
|
|
|
# Make sure that installing twice generates the same XML, to ensure
|
|
|
|
# we aren't polluting the device list during the install process
|
|
|
|
i = utils.make_live_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
self._compare(g, "install-fullyvirt-livecd", False)
|
|
|
|
self._compare(g, "install-fullyvirt-livecd", False)
|
|
|
|
|
|
|
|
def testOSDeviceDefaultChange(self):
|
|
|
|
"""
|
|
|
|
Make sure device defaults are properly changed if we change OS
|
|
|
|
distro/variant mid process
|
|
|
|
"""
|
|
|
|
utils.set_conn(_plainkvm)
|
|
|
|
|
|
|
|
i = utils.make_distro_installer(gtype="kvm")
|
|
|
|
g = utils.get_basic_fullyvirt_guest("kvm", installer=i)
|
|
|
|
|
|
|
|
do_install = False
|
|
|
|
g.installer.cdrom = True
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_floppy())
|
|
|
|
g.add_device(utils.get_filedisk())
|
|
|
|
g.add_device(utils.get_blkdisk())
|
|
|
|
g.add_device(utils.get_virtual_network())
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2013-04-11 22:44:27 +08:00
|
|
|
# Call get_xml_config sets first round of defaults w/o os_variant set
|
2013-03-18 05:06:52 +08:00
|
|
|
g.get_xml_config(do_install)
|
|
|
|
|
|
|
|
g.os_variant = "fedora11"
|
|
|
|
self._compare(g, "install-f11", do_install)
|
|
|
|
|
2013-07-14 07:38:38 +08:00
|
|
|
try:
|
|
|
|
virtinst.enable_rhel_defaults = True
|
|
|
|
self._compare(g, "install-f11-rheldefaults", do_install)
|
|
|
|
finally:
|
|
|
|
virtinst.enable_rhel_defaults = False
|
|
|
|
|
|
|
|
# Verify main guest wasn't polluted
|
|
|
|
self._compare(g, "install-f11", do_install)
|
|
|
|
|
2013-03-18 05:06:52 +08:00
|
|
|
def testInstallFVImport(self):
|
|
|
|
i = utils.make_import_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-fullyvirt-import", False)
|
|
|
|
|
|
|
|
def testInstallFVImportKernel(self):
|
|
|
|
i = utils.make_import_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
g.installer.bootconfig.kernel = "kernel"
|
|
|
|
g.installer.bootconfig.initrd = "initrd"
|
|
|
|
g.installer.bootconfig.kernel_args = "my kernel args"
|
|
|
|
|
|
|
|
self._compare(g, "install-fullyvirt-import-kernel", False)
|
|
|
|
|
|
|
|
def testInstallFVImportMulti(self):
|
|
|
|
i = utils.make_import_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
|
|
|
|
g.installer.bootconfig.enable_bootmenu = False
|
|
|
|
g.installer.bootconfig.bootorder = ["hd", "fd", "cdrom", "network"]
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-fullyvirt-import-multiboot", False)
|
|
|
|
|
|
|
|
def testInstallPVImport(self):
|
|
|
|
i = utils.make_import_installer("xen")
|
|
|
|
g = utils.get_basic_paravirt_guest(installer=i)
|
|
|
|
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-paravirt-import", False)
|
|
|
|
|
|
|
|
def testQEMUDriverName(self):
|
|
|
|
utils.set_conn(_plainkvm)
|
|
|
|
g = utils.get_basic_fullyvirt_guest()
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_blkdisk())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "misc-qemu-driver-name", True)
|
|
|
|
|
|
|
|
g = utils.get_basic_fullyvirt_guest()
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
|
|
|
g.add_device(utils.get_blkdisk("/iscsi-pool/diskvol1"))
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "misc-qemu-driver-type", True)
|
|
|
|
|
|
|
|
g = utils.get_basic_fullyvirt_guest()
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk("/default-pool/iso-vol"))
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "misc-qemu-iso-disk", True)
|
|
|
|
|
|
|
|
g = utils.get_basic_fullyvirt_guest()
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk("/default-pool/iso-vol"))
|
|
|
|
g.get_devices("disk")[0].driver_type = "qcow2"
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "misc-qemu-driver-overwrite", True)
|
|
|
|
|
|
|
|
def testXMLEscaping(self):
|
|
|
|
g = utils.get_basic_fullyvirt_guest()
|
|
|
|
g.description = "foooo barrrr \n baz && snarf. '' \"\" @@$\n"
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk("/tmp/ISO&'&s"))
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "misc-xml-escaping", True)
|
|
|
|
|
|
|
|
# OS Type/Version configurations
|
|
|
|
def testF10(self):
|
|
|
|
utils.set_conn(_plainkvm)
|
|
|
|
i = utils.make_pxe_installer(gtype="kvm")
|
|
|
|
g = utils.get_basic_fullyvirt_guest("kvm", installer=i)
|
|
|
|
|
|
|
|
g.os_type = "linux"
|
|
|
|
g.os_variant = "fedora10"
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
|
|
|
g.add_device(utils.get_blkdisk())
|
|
|
|
g.add_device(utils.get_virtual_network())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-f10", True)
|
|
|
|
|
|
|
|
def testF11(self):
|
|
|
|
utils.set_conn(_plainkvm)
|
|
|
|
i = utils.make_distro_installer(gtype="kvm")
|
|
|
|
g = utils.get_basic_fullyvirt_guest("kvm", installer=i)
|
|
|
|
|
|
|
|
g.os_type = "linux"
|
|
|
|
g.os_variant = "fedora11"
|
|
|
|
g.installer.cdrom = True
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_floppy())
|
|
|
|
g.add_device(utils.get_filedisk())
|
|
|
|
g.add_device(utils.get_blkdisk())
|
|
|
|
g.add_device(utils.get_virtual_network())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-f11", False)
|
|
|
|
|
|
|
|
def testF11AC97(self):
|
|
|
|
def build_guest():
|
|
|
|
i = utils.make_distro_installer(gtype="kvm")
|
|
|
|
g = utils.get_basic_fullyvirt_guest("kvm", installer=i)
|
|
|
|
|
|
|
|
g.os_type = "linux"
|
|
|
|
g.os_variant = "fedora11"
|
|
|
|
g.installer.cdrom = True
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_floppy())
|
|
|
|
g.add_device(utils.get_filedisk())
|
|
|
|
g.add_device(utils.get_blkdisk())
|
|
|
|
g.add_device(utils.get_virtual_network())
|
2013-07-06 08:14:57 +08:00
|
|
|
g.add_device(VirtualAudio(g.conn))
|
2013-03-18 05:06:52 +08:00
|
|
|
return g
|
|
|
|
|
|
|
|
utils.set_conn(utils.open_plainkvm(connver=11000))
|
|
|
|
g = build_guest()
|
|
|
|
self._compare(g, "install-f11-ac97", False)
|
|
|
|
|
2013-07-07 03:39:00 +08:00
|
|
|
utils.set_conn(utils.open_plainkvm(libver=5000))
|
|
|
|
g = build_guest()
|
|
|
|
self._compare(g, "install-f11-noac97", False)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
utils.set_conn(utils.open_plainkvm(connver=10000))
|
|
|
|
g = build_guest()
|
|
|
|
self._compare(g, "install-f11-noac97", False)
|
|
|
|
|
|
|
|
def testKVMKeymap(self):
|
|
|
|
conn = utils.open_plainkvm(connver=10000)
|
2013-07-16 08:43:41 +08:00
|
|
|
g = virtinst.VirtualGraphics(conn)
|
|
|
|
g.type = "vnc"
|
2013-04-14 02:34:52 +08:00
|
|
|
self.assertTrue(g.keymap is not None)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
conn = utils.open_plainkvm(connver=11000)
|
2013-07-16 08:43:41 +08:00
|
|
|
g = virtinst.VirtualGraphics(conn)
|
|
|
|
g.type = "vnc"
|
2013-04-14 02:34:52 +08:00
|
|
|
self.assertTrue(g.keymap is None)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
def testF11Qemu(self):
|
|
|
|
utils.set_conn(_plainkvm)
|
|
|
|
i = utils.make_distro_installer(gtype="qemu")
|
|
|
|
g = utils.get_basic_fullyvirt_guest("qemu", installer=i)
|
|
|
|
|
|
|
|
g.os_type = "linux"
|
|
|
|
g.os_variant = "fedora11"
|
|
|
|
g.installer.cdrom = True
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_floppy())
|
|
|
|
g.add_device(utils.get_filedisk())
|
|
|
|
g.add_device(utils.get_blkdisk())
|
|
|
|
g.add_device(utils.get_virtual_network())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-f11-qemu", False)
|
|
|
|
|
|
|
|
def testF11Xen(self):
|
|
|
|
utils.set_conn(_plainxen)
|
|
|
|
i = utils.make_distro_installer(gtype="xen")
|
|
|
|
g = utils.get_basic_fullyvirt_guest("xen", installer=i)
|
|
|
|
|
|
|
|
g.os_type = "linux"
|
|
|
|
g.os_variant = "fedora11"
|
|
|
|
g.installer.cdrom = True
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_floppy())
|
|
|
|
g.add_device(utils.get_filedisk())
|
|
|
|
g.add_device(utils.get_blkdisk())
|
|
|
|
g.add_device(utils.get_virtual_network())
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "install-f11-xen", False)
|
|
|
|
|
|
|
|
def testInstallWindowsKVM(self):
|
|
|
|
utils.set_conn(_plainkvm)
|
|
|
|
g = utils.build_win_kvm("/default-pool/winxp.img")
|
|
|
|
self._compare(g, "winxp-kvm-stage1", True)
|
|
|
|
|
|
|
|
def testContinueWindowsKVM(self):
|
|
|
|
utils.set_conn(_plainkvm)
|
|
|
|
g = utils.build_win_kvm("/default-pool/winxp.img")
|
|
|
|
self._compare(g, "winxp-kvm-stage2", True, True)
|
|
|
|
|
|
|
|
def testBootWindowsKVM(self):
|
|
|
|
utils.set_conn(_plainkvm)
|
|
|
|
g = utils.build_win_kvm("/default-pool/winxp.img")
|
|
|
|
self._compare(g, "winxp-kvm-stage3", False)
|
|
|
|
|
|
|
|
|
|
|
|
def testInstallWindowsXenNew(self):
|
|
|
|
def make_guest():
|
|
|
|
g = utils.get_basic_fullyvirt_guest("xen")
|
|
|
|
g.os_type = "windows"
|
|
|
|
g.os_variant = "winxp"
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
|
|
|
g.add_device(utils.get_blkdisk())
|
|
|
|
g.add_device(utils.get_virtual_network())
|
2013-07-06 08:14:57 +08:00
|
|
|
g.add_device(VirtualAudio(g.conn))
|
2013-03-18 05:06:52 +08:00
|
|
|
return g
|
|
|
|
|
|
|
|
utils.set_conn(utils.open_plainxen(connver=3000001))
|
|
|
|
g = make_guest()
|
|
|
|
self._compare(g, "install-windowsxp-xenold", True)
|
|
|
|
|
|
|
|
utils.set_conn(utils.open_plainxen(connver=3100000))
|
|
|
|
g = make_guest()
|
|
|
|
self._compare(g, "install-windowsxp-xennew", True)
|
|
|
|
|
|
|
|
# Device heavy configurations
|
|
|
|
def testManyDisks2(self):
|
|
|
|
i = utils.make_pxe_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_filedisk())
|
|
|
|
g.add_device(utils.get_blkdisk())
|
2013-07-13 22:09:00 +08:00
|
|
|
|
|
|
|
d = VirtualDisk(g.conn)
|
|
|
|
d.path = "/dev/loop0"
|
|
|
|
d.device = d.DEVICE_CDROM
|
|
|
|
d.driver_type = "raw"
|
|
|
|
d.validate()
|
|
|
|
g.add_device(d)
|
|
|
|
|
|
|
|
d = VirtualDisk(g.conn)
|
|
|
|
d.path = "/dev/loop0"
|
|
|
|
d.device = d.DEVICE_DISK
|
|
|
|
d.driver_name = "qemu"
|
|
|
|
d.validate()
|
|
|
|
g.add_device(d)
|
|
|
|
|
|
|
|
d = VirtualDisk(g.conn)
|
|
|
|
d.path = None
|
|
|
|
d.device = d.DEVICE_CDROM
|
|
|
|
d.bus = "scsi"
|
|
|
|
d.validate()
|
|
|
|
g.add_device(d)
|
|
|
|
|
|
|
|
d = VirtualDisk(g.conn)
|
|
|
|
d.path = None
|
|
|
|
d.device = d.DEVICE_FLOPPY
|
2013-07-12 22:49:15 +08:00
|
|
|
d.iotune_tbs = 1
|
|
|
|
d.iotune_tis = 2
|
2013-07-13 22:09:00 +08:00
|
|
|
d.validate()
|
2013-07-12 22:49:15 +08:00
|
|
|
g.add_device(d)
|
|
|
|
|
2013-07-13 22:09:00 +08:00
|
|
|
d = VirtualDisk(g.conn)
|
|
|
|
d.path = "/dev/loop0"
|
|
|
|
d.device = d.DEVICE_FLOPPY
|
|
|
|
d.driver_name = "phy"
|
2013-07-12 22:49:15 +08:00
|
|
|
d.driver_cache = "none"
|
|
|
|
d.iotune_rbs = 5555
|
|
|
|
d.iotune_ris = 1234
|
|
|
|
d.iotune_wbs = 3
|
|
|
|
d.iotune_wis = 4
|
2013-07-13 22:09:00 +08:00
|
|
|
d.validate()
|
2013-07-12 22:49:15 +08:00
|
|
|
g.add_device(d)
|
|
|
|
|
2013-07-13 22:09:00 +08:00
|
|
|
d = VirtualDisk(g.conn)
|
|
|
|
d.path = "/dev/loop0"
|
|
|
|
d.bus = "virtio"
|
|
|
|
d.driver_name = "qemu"
|
|
|
|
d.driver_type = "qcow2"
|
2013-07-12 22:49:15 +08:00
|
|
|
d.driver_cache = "none"
|
|
|
|
d.driver_io = "threads"
|
2013-07-13 22:09:00 +08:00
|
|
|
d.validate()
|
2013-07-12 22:49:15 +08:00
|
|
|
g.add_device(d)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
self._compare(g, "boot-many-disks2", False)
|
|
|
|
|
|
|
|
def testManyNICs(self):
|
|
|
|
i = utils.make_pxe_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
|
2013-07-16 02:14:05 +08:00
|
|
|
net1 = VirtualNetworkInterface(g.conn)
|
|
|
|
net1.type = "user"
|
|
|
|
net1.macaddr = "22:11:11:11:11:11"
|
|
|
|
|
2013-03-18 05:06:52 +08:00
|
|
|
net2 = utils.get_virtual_network()
|
|
|
|
net3 = utils.get_virtual_network()
|
|
|
|
net3.model = "e1000"
|
2013-07-16 02:14:05 +08:00
|
|
|
|
|
|
|
net4 = VirtualNetworkInterface(g.conn)
|
|
|
|
net4.bridge = "foobr0"
|
|
|
|
net4.macaddr = "22:22:22:22:22:22"
|
2013-03-18 05:06:52 +08:00
|
|
|
net4.target_dev = "foo1"
|
2013-07-16 02:14:05 +08:00
|
|
|
|
|
|
|
net5 = VirtualNetworkInterface(g.conn)
|
|
|
|
net5.type = "ethernet"
|
|
|
|
net5.macaddr = "00:11:00:22:00:33"
|
2013-03-18 05:06:52 +08:00
|
|
|
net5.source_dev = "testeth1"
|
|
|
|
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(net1)
|
|
|
|
g.add_device(net2)
|
|
|
|
g.add_device(net3)
|
|
|
|
g.add_device(net4)
|
|
|
|
g.add_device(net5)
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-many-nics", False)
|
|
|
|
|
|
|
|
def testManyHostdevs(self):
|
|
|
|
i = utils.make_pxe_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
|
2013-07-16 05:45:43 +08:00
|
|
|
dev1 = VirtualHostDevice(g.conn)
|
|
|
|
dev1.type = "usb"
|
2013-03-18 05:06:52 +08:00
|
|
|
dev1.product = "0x1234"
|
|
|
|
dev1.vendor = "0x4321"
|
|
|
|
|
2013-07-16 05:45:43 +08:00
|
|
|
dev2 = VirtualHostDevice(g.conn)
|
|
|
|
dev2.type = "pci"
|
2013-03-18 05:06:52 +08:00
|
|
|
dev2.bus = "0x11"
|
|
|
|
dev2.slot = "0x2"
|
|
|
|
dev2.function = "0x3"
|
|
|
|
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(dev1)
|
|
|
|
g.add_device(dev2)
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-many-hostdevs", False)
|
|
|
|
|
|
|
|
def testManySounds(self):
|
|
|
|
i = utils.make_pxe_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
|
2013-07-16 10:00:08 +08:00
|
|
|
d = VirtualAudio(g.conn)
|
|
|
|
d.model = "sb16"
|
|
|
|
g.add_device(d)
|
|
|
|
|
|
|
|
d = VirtualAudio(g.conn)
|
|
|
|
d.model = "es1370"
|
|
|
|
g.add_device(d)
|
|
|
|
|
|
|
|
d = VirtualAudio(g.conn)
|
|
|
|
d.model = "pcspk"
|
|
|
|
g.add_device(d)
|
|
|
|
|
|
|
|
d = VirtualAudio(g.conn)
|
|
|
|
g.add_device(d)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
self._compare(g, "boot-many-sounds", False)
|
|
|
|
|
|
|
|
def testManyChars(self):
|
|
|
|
i = utils.make_pxe_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
|
2013-07-17 03:59:27 +08:00
|
|
|
dev = VirtualSerialDevice(g.conn)
|
|
|
|
dev.type = "null"
|
|
|
|
g.add_device(dev)
|
|
|
|
|
|
|
|
dev = VirtualParallelDevice(g.conn)
|
|
|
|
dev.type = "unix"
|
|
|
|
dev.source_path = "/tmp/foobar"
|
|
|
|
g.add_device(dev)
|
|
|
|
|
|
|
|
dev = VirtualSerialDevice(g.conn)
|
|
|
|
dev.type = "tcp"
|
|
|
|
dev.protocol = "telnet"
|
|
|
|
dev.source_host = "my.source.host"
|
|
|
|
dev.source_port = "1234"
|
|
|
|
g.add_device(dev)
|
|
|
|
|
|
|
|
dev = VirtualParallelDevice(g.conn)
|
|
|
|
dev.type = "udp"
|
|
|
|
dev.bind_host = "my.bind.host"
|
|
|
|
dev.bind_port = "1111"
|
|
|
|
dev.source_host = "my.source.host"
|
|
|
|
dev.source_port = "2222"
|
|
|
|
g.add_device(dev)
|
|
|
|
|
|
|
|
dev = VirtualChannelDevice(g.conn)
|
|
|
|
dev.type = "pty"
|
|
|
|
dev.target_type = dev.CHANNEL_TARGET_VIRTIO
|
|
|
|
dev.target_name = "foo.bar.frob"
|
|
|
|
g.add_device(dev)
|
|
|
|
|
|
|
|
dev = VirtualConsoleDevice(g.conn)
|
|
|
|
dev.type = "pty"
|
|
|
|
dev.target_type = dev.CONSOLE_TARGET_VIRTIO
|
|
|
|
g.add_device(dev)
|
|
|
|
|
|
|
|
dev = VirtualChannelDevice(g.conn)
|
|
|
|
dev.type = "pty"
|
|
|
|
dev.target_type = dev.CHANNEL_TARGET_GUESTFWD
|
|
|
|
dev.target_address = "1.2.3.4"
|
|
|
|
dev.target_port = "4567"
|
|
|
|
g.add_device(dev)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
self._compare(g, "boot-many-chars", False)
|
|
|
|
|
|
|
|
def testManyDevices(self):
|
|
|
|
i = utils.make_pxe_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
|
|
|
|
g.description = "foooo barrrr somedesc"
|
|
|
|
g.hugepage = True
|
|
|
|
|
|
|
|
# Hostdevs
|
2013-07-16 05:45:43 +08:00
|
|
|
dev1 = VirtualHostDevice(g.conn)
|
|
|
|
dev1.type = "usb"
|
2013-03-18 05:06:52 +08:00
|
|
|
dev1.vendor = "0x4321"
|
2013-07-16 05:45:43 +08:00
|
|
|
dev1.product = "0x1234"
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(dev1)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
# Sound devices
|
2013-07-16 10:00:08 +08:00
|
|
|
d = VirtualAudio(g.conn)
|
|
|
|
d.model = "sb16"
|
|
|
|
g.add_device(d)
|
|
|
|
|
|
|
|
d = VirtualAudio(g.conn)
|
|
|
|
d.model = "es1370"
|
|
|
|
g.add_device(d)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
# Disk devices
|
2013-07-13 22:09:00 +08:00
|
|
|
d = VirtualDisk(g.conn)
|
|
|
|
d.path = "/dev/loop0"
|
|
|
|
d.device = d.DEVICE_FLOPPY
|
|
|
|
d.validate()
|
|
|
|
g.add_device(d)
|
|
|
|
|
|
|
|
d = VirtualDisk(g.conn)
|
|
|
|
d.path = "/dev/loop0"
|
|
|
|
d.bus = "scsi"
|
|
|
|
d.validate()
|
|
|
|
g.add_device(d)
|
|
|
|
|
|
|
|
d = VirtualDisk(g.conn)
|
|
|
|
d.path = "/tmp"
|
|
|
|
d.device = d.DEVICE_FLOPPY
|
|
|
|
d.validate()
|
|
|
|
g.add_device(d)
|
|
|
|
|
|
|
|
d = VirtualDisk(g.conn)
|
|
|
|
d.path = "/default-pool/testvol1.img"
|
|
|
|
d.bus = "scsi"
|
|
|
|
d.driver_name = "qemu"
|
|
|
|
d.address.type = "spapr-vio"
|
|
|
|
d.validate()
|
|
|
|
g.add_device(d)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
# Controller devices
|
2013-07-16 09:52:18 +08:00
|
|
|
c1 = VirtualController(g.conn)
|
|
|
|
c1.type = "ide"
|
2013-03-18 05:06:52 +08:00
|
|
|
c1.index = "3"
|
2013-07-16 09:52:18 +08:00
|
|
|
c2 = VirtualController(g.conn)
|
|
|
|
c2.type = "virtio-serial"
|
2013-03-18 05:06:52 +08:00
|
|
|
c2.ports = "32"
|
|
|
|
c2.vectors = "17"
|
|
|
|
g.add_device(c1)
|
|
|
|
g.add_device(c2)
|
|
|
|
|
|
|
|
# Network devices
|
|
|
|
net1 = utils.get_virtual_network()
|
|
|
|
net1.model = "e1000"
|
2013-07-16 02:14:05 +08:00
|
|
|
|
|
|
|
net2 = VirtualNetworkInterface(g.conn)
|
|
|
|
net2.type = "user"
|
|
|
|
net2.macaddr = "22:11:11:11:11:11"
|
|
|
|
net3 = VirtualNetworkInterface(g.conn)
|
|
|
|
net3.type = virtinst.VirtualNetworkInterface.TYPE_VIRTUAL
|
|
|
|
net3.macaddr = "22:22:22:22:22:22"
|
|
|
|
net3.network = "default"
|
2013-03-18 05:06:52 +08:00
|
|
|
net3.model = "spapr-vlan"
|
2013-07-17 04:05:22 +08:00
|
|
|
net3.address.set_addrstr("spapr-vio")
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(net1)
|
|
|
|
g.add_device(net2)
|
|
|
|
g.add_device(net3)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
# Character devices
|
2013-07-16 21:14:37 +08:00
|
|
|
cdev1 = VirtualSerialDevice(g.conn)
|
|
|
|
cdev1.type = "null"
|
|
|
|
cdev2 = VirtualParallelDevice(g.conn)
|
|
|
|
cdev2.type = "unix"
|
2013-03-18 05:06:52 +08:00
|
|
|
cdev2.source_path = "/tmp/foobar"
|
2013-07-16 21:14:37 +08:00
|
|
|
cdev3 = VirtualChannelDevice(g.conn)
|
|
|
|
cdev3.type = "spicevmc"
|
2013-03-18 05:06:52 +08:00
|
|
|
g.add_device(cdev1)
|
|
|
|
g.add_device(cdev2)
|
|
|
|
g.add_device(cdev3)
|
|
|
|
|
|
|
|
# Video Devices
|
|
|
|
vdev1 = VirtualVideoDevice(g.conn)
|
2013-07-15 23:07:40 +08:00
|
|
|
vdev1.model = "vmvga"
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
vdev2 = VirtualVideoDevice(g.conn)
|
2013-07-15 23:07:40 +08:00
|
|
|
vdev2.model = "cirrus"
|
2013-03-18 05:06:52 +08:00
|
|
|
vdev2.vram = 10 * 1024
|
|
|
|
vdev2.heads = 3
|
|
|
|
|
|
|
|
vdev3 = VirtualVideoDevice(g.conn)
|
|
|
|
vdev4 = VirtualVideoDevice(g.conn)
|
2013-07-15 23:07:40 +08:00
|
|
|
vdev4.model = "qxl"
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
g.add_device(vdev1)
|
|
|
|
g.add_device(vdev2)
|
|
|
|
g.add_device(vdev3)
|
|
|
|
g.add_device(vdev4)
|
|
|
|
|
|
|
|
# Watchdog Devices
|
|
|
|
wdev2 = VirtualWatchdog(g.conn)
|
|
|
|
wdev2.model = "ib700"
|
|
|
|
wdev2.action = "none"
|
|
|
|
g.add_device(wdev2)
|
|
|
|
|
|
|
|
# Memballoon Devices
|
|
|
|
mdev1 = VirtualMemballoon(g.conn)
|
|
|
|
mdev1.model = "virtio"
|
|
|
|
g.add_device(mdev1)
|
|
|
|
|
|
|
|
# Check keymap autoconfig
|
2013-07-16 08:43:41 +08:00
|
|
|
gdev1 = virtinst.VirtualGraphics(g.conn)
|
|
|
|
gdev1.type = "vnc"
|
2013-04-14 02:34:52 +08:00
|
|
|
self.assertTrue(gdev1.keymap is not None)
|
2013-03-18 05:06:52 +08:00
|
|
|
gdev1.keymap = "en-us"
|
|
|
|
|
|
|
|
# Check keymap None
|
2013-07-16 08:43:41 +08:00
|
|
|
gdev2 = virtinst.VirtualGraphics(g.conn)
|
|
|
|
gdev2.type = "vnc"
|
2013-03-18 05:06:52 +08:00
|
|
|
gdev2.keymap = None
|
|
|
|
|
2013-07-16 08:43:41 +08:00
|
|
|
gdev3 = virtinst.VirtualGraphics(g.conn)
|
|
|
|
gdev3.type = "sdl"
|
|
|
|
gdev4 = virtinst.VirtualGraphics(g.conn)
|
|
|
|
gdev4.type = "spice"
|
2013-03-18 05:06:52 +08:00
|
|
|
gdev4.passwdValidTo = "foobar"
|
|
|
|
|
2013-07-16 08:43:41 +08:00
|
|
|
gdev5 = virtinst.VirtualGraphics(g.conn)
|
|
|
|
gdev5.type = "sdl"
|
2013-03-18 05:06:52 +08:00
|
|
|
gdev5.xauth = "fooxauth"
|
|
|
|
gdev5.display = "foodisplay"
|
|
|
|
g.add_device(gdev1)
|
|
|
|
g.add_device(gdev2)
|
|
|
|
g.add_device(gdev3)
|
|
|
|
g.add_device(gdev4)
|
|
|
|
g.add_device(gdev5)
|
|
|
|
|
|
|
|
g.clock.offset = "localtime"
|
|
|
|
|
2013-07-17 00:30:43 +08:00
|
|
|
g.seclabel.type = g.seclabel.TYPE_STATIC
|
2013-03-18 05:06:52 +08:00
|
|
|
g.seclabel.model = "selinux"
|
|
|
|
g.seclabel.label = "foolabel"
|
|
|
|
g.seclabel.imagelabel = "imagelabel"
|
|
|
|
|
2013-07-16 00:57:37 +08:00
|
|
|
redir1 = virtinst.VirtualRedirDevice(g.conn)
|
|
|
|
redir1.type = "spicevmc"
|
|
|
|
|
|
|
|
redir2 = virtinst.VirtualRedirDevice(g.conn)
|
|
|
|
redir2.type = "tcp"
|
|
|
|
redir2.parse_friendly_server("foobar.com:1234")
|
|
|
|
g.add_device(redir1)
|
|
|
|
g.add_device(redir2)
|
|
|
|
|
2013-03-18 05:06:52 +08:00
|
|
|
self._compare(g, "boot-many-devices", False)
|
|
|
|
|
|
|
|
def testCpuset(self):
|
2013-07-05 20:59:58 +08:00
|
|
|
normaltest = utils.open_testdefault()
|
2013-03-18 05:06:52 +08:00
|
|
|
utils.set_conn(normaltest)
|
|
|
|
g = utils.get_basic_fullyvirt_guest()
|
|
|
|
|
|
|
|
# Cpuset
|
|
|
|
cpustr = g.generate_cpuset(g.conn, g.memory)
|
|
|
|
g.cpuset = cpustr
|
|
|
|
g.maxvcpus = 7
|
|
|
|
|
|
|
|
g.cpu.model = "footest"
|
|
|
|
g.cpu.vendor = "Intel"
|
|
|
|
g.cpu.match = "minimum"
|
|
|
|
|
|
|
|
g.cpu.threads = "2"
|
|
|
|
g.cpu.sockets = "4"
|
|
|
|
g.cpu.cores = "5"
|
|
|
|
|
|
|
|
g.cpu.add_feature("x2apic", "force")
|
|
|
|
g.cpu.add_feature("lahf_lm", "forbid")
|
|
|
|
|
|
|
|
self._compare(g, "boot-cpuset", False)
|
|
|
|
|
|
|
|
# Test CPU topology determining
|
|
|
|
cpu = virtinst.CPU(g.conn)
|
|
|
|
cpu.sockets = "2"
|
|
|
|
cpu.set_topology_defaults(6)
|
|
|
|
self.assertEquals([cpu.sockets, cpu.cores, cpu.threads], [2, 3, 1])
|
|
|
|
|
|
|
|
cpu = virtinst.CPU(g.conn)
|
|
|
|
cpu.cores = "4"
|
|
|
|
cpu.set_topology_defaults(9)
|
|
|
|
self.assertEquals([cpu.sockets, cpu.cores, cpu.threads], [2, 4, 1])
|
|
|
|
|
|
|
|
cpu = virtinst.CPU(g.conn)
|
|
|
|
cpu.threads = "3"
|
|
|
|
cpu.set_topology_defaults(14)
|
|
|
|
self.assertEquals([cpu.sockets, cpu.cores, cpu.threads], [4, 1, 3])
|
|
|
|
|
|
|
|
cpu = virtinst.CPU(g.conn)
|
|
|
|
cpu.sockets = 5
|
|
|
|
cpu.cores = 2
|
|
|
|
self.assertEquals(cpu.vcpus_from_topology(), 10)
|
|
|
|
|
|
|
|
cpu = virtinst.CPU(g.conn)
|
|
|
|
self.assertEquals(cpu.vcpus_from_topology(), 1)
|
|
|
|
|
|
|
|
def testUsb2(self):
|
|
|
|
i = utils.make_pxe_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
|
|
|
|
|
|
|
g.add_usb_ich9_controllers()
|
|
|
|
|
|
|
|
self._compare(g, "boot-usb2", False)
|
|
|
|
|
|
|
|
|
|
|
|
def testFullKVMRHEL6(self):
|
|
|
|
utils.set_conn(_plainkvm)
|
|
|
|
i = utils.make_distro_installer(
|
|
|
|
location="tests/cli-test-xml/fakerhel6tree",
|
|
|
|
gtype="kvm")
|
|
|
|
g = utils.get_basic_fullyvirt_guest("kvm", installer=i)
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_floppy())
|
2013-07-13 22:09:00 +08:00
|
|
|
g.add_device(utils.get_filedisk("/default-pool/rhel6.img", fake=False))
|
2013-04-12 21:39:34 +08:00
|
|
|
g.add_device(utils.get_blkdisk())
|
|
|
|
g.add_device(utils.get_virtual_network())
|
2013-07-06 08:14:57 +08:00
|
|
|
g.add_device(VirtualAudio(g.conn))
|
2013-03-18 05:06:52 +08:00
|
|
|
g.add_device(VirtualVideoDevice(g.conn))
|
|
|
|
g.os_autodetect = True
|
|
|
|
|
|
|
|
# Do this ugly hack to make sure the test doesn't try and use vol
|
|
|
|
# upload
|
|
|
|
origscratch = getattr(i, "_get_system_scratchdir")
|
|
|
|
try:
|
|
|
|
setattr(i, "_get_system_scratchdir",
|
|
|
|
lambda: i.scratchdir)
|
|
|
|
self._testInstall(g, "rhel6-kvm-stage1", "rhel6-kvm-stage2")
|
|
|
|
finally:
|
|
|
|
setattr(i, "_get_system_scratchdir", origscratch)
|
|
|
|
|
|
|
|
def testFullKVMWinxp(self):
|
|
|
|
utils.set_conn(_plainkvm)
|
2013-07-13 22:09:00 +08:00
|
|
|
g = utils.build_win_kvm("/default-pool/winxp.img", fake=False)
|
2013-03-18 05:06:52 +08:00
|
|
|
self._testInstall(g, "winxp-kvm-stage1",
|
|
|
|
"winxp-kvm-stage3", "winxp-kvm-stage2")
|
|
|
|
|
|
|
|
def testCreateDisk(self):
|
|
|
|
"""
|
|
|
|
Doesn't really belong here, but what the hell :)
|
|
|
|
"""
|
|
|
|
path = "/tmp/__virtinst_create_test__.img"
|
|
|
|
sizegigs = .001
|
|
|
|
sizebytes = long(sizegigs * 1024L * 1024L * 1024L)
|
|
|
|
|
|
|
|
for sparse in [True, False]:
|
2013-07-13 22:09:00 +08:00
|
|
|
disk = VirtualDisk(utils.get_conn())
|
|
|
|
disk.path = path
|
|
|
|
disk.set_create_storage(size=sizegigs, sparse=sparse)
|
|
|
|
disk.validate()
|
2013-03-18 05:06:52 +08:00
|
|
|
disk.setup()
|
|
|
|
|
|
|
|
actualsize = long(os.path.getsize(path))
|
|
|
|
os.unlink(path)
|
|
|
|
self.assertEquals(sizebytes, actualsize)
|
|
|
|
|
|
|
|
def testDefaultBridge(self):
|
|
|
|
origfunc = None
|
|
|
|
util = None
|
|
|
|
try:
|
|
|
|
i = utils.make_pxe_installer()
|
|
|
|
g = utils.get_basic_fullyvirt_guest(installer=i)
|
2013-04-11 22:27:02 +08:00
|
|
|
util = getattr(virtinst, "util")
|
2013-04-11 23:14:13 +08:00
|
|
|
origfunc = util.default_bridge
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
def newbridge(ignore_conn):
|
|
|
|
return ["bridge", "br0"]
|
2013-04-11 23:14:13 +08:00
|
|
|
util.default_bridge = newbridge
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2013-07-06 08:14:57 +08:00
|
|
|
dev1 = virtinst.VirtualNetworkInterface(g.conn)
|
2013-03-18 05:06:52 +08:00
|
|
|
dev1.macaddr = "22:22:33:44:55:66"
|
|
|
|
g.add_device(dev1)
|
|
|
|
|
2013-07-06 08:14:57 +08:00
|
|
|
dev2 = virtinst.VirtualNetworkInterface(g.conn,
|
2013-07-17 00:48:52 +08:00
|
|
|
parsexml=dev1.get_xml_config().strip("\n"))
|
2013-03-18 05:06:52 +08:00
|
|
|
dev2.source = None
|
|
|
|
dev2.source = "foobr0"
|
|
|
|
dev2.macaddr = "22:22:33:44:55:67"
|
|
|
|
g.add_device(dev2)
|
|
|
|
|
2013-07-06 08:14:57 +08:00
|
|
|
dev3 = virtinst.VirtualNetworkInterface(g.conn,
|
2013-07-17 00:48:52 +08:00
|
|
|
parsexml=dev1.get_xml_config().strip("\n"))
|
2013-03-18 05:06:52 +08:00
|
|
|
dev3.source = None
|
|
|
|
dev3.macaddr = "22:22:33:44:55:68"
|
|
|
|
g.add_device(dev3)
|
|
|
|
|
|
|
|
self._compare(g, "boot-default-bridge", False, do_create=False)
|
|
|
|
dev3.type = dev3.TYPE_USER
|
|
|
|
self._compare(g, None, False)
|
|
|
|
finally:
|
|
|
|
if util and origfunc:
|
2013-04-11 23:14:13 +08:00
|
|
|
util.default_bridge = origfunc
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
def testCpustrToTuple(self):
|
|
|
|
conn = utils.get_conn()
|
|
|
|
base = [False] * 16
|
|
|
|
|
|
|
|
expect = base[:]
|
|
|
|
expect[1] = expect[2] = expect[3] = True
|
|
|
|
self.assertEquals(tuple(expect),
|
|
|
|
virtinst.Guest.cpuset_str_to_tuple(conn, "1-3"))
|
|
|
|
|
|
|
|
expect = base[:]
|
|
|
|
expect[1] = expect[3] = expect[5] = expect[10] = expect[11] = True
|
|
|
|
self.assertEquals(tuple(expect),
|
|
|
|
virtinst.Guest.cpuset_str_to_tuple(conn, "1,3,5,10-11"))
|
|
|
|
|
|
|
|
self.assertRaises(ValueError,
|
|
|
|
virtinst.Guest.cpuset_str_to_tuple,
|
|
|
|
conn, "16")
|
|
|
|
|
|
|
|
def testManyVirtio(self):
|
2013-07-13 22:09:00 +08:00
|
|
|
d = VirtualDisk(utils.get_conn())
|
|
|
|
d.bus = "virtio"
|
|
|
|
d.path = "/default-pool/testvol1.img"
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
targetlist = []
|
|
|
|
for ignore in range(0, (26 * 2) + 1):
|
|
|
|
d.target = None
|
|
|
|
d.generate_target(targetlist)
|
|
|
|
targetlist.append(d.target)
|
|
|
|
|
|
|
|
self.assertEquals("vdaa", targetlist[26])
|
|
|
|
self.assertEquals("vdba", targetlist[26 * 2])
|
|
|
|
|
|
|
|
def testFedoraTreeinfo(self):
|
|
|
|
i = utils.make_distro_installer(
|
|
|
|
location="tests/cli-test-xml/fakefedoratree",
|
|
|
|
gtype="kvm")
|
|
|
|
t, v = i.detect_distro()
|
|
|
|
self.assertEquals((t, v), ("linux", "fedora17"))
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|