virtinst: Guest: Remove back compat static device lists

This commit is contained in:
Cole Robinson 2013-04-12 09:39:34 -04:00
parent 248a1a509f
commit baf531f710
11 changed files with 138 additions and 158 deletions

View File

@ -203,9 +203,9 @@ def build_win_kvm(path=None):
g = get_basic_fullyvirt_guest("kvm")
g.os_type = "windows"
g.os_variant = "winxp"
g.disks.append(get_filedisk(path))
g.disks.append(get_blkdisk())
g.nics.append(get_virtual_network())
g.add_device(get_filedisk(path))
g.add_device(get_blkdisk())
g.add_device(get_virtual_network())
g.add_device(VirtualAudio())
g.add_device(VirtualVideoDevice(g.conn))

View File

@ -129,7 +129,7 @@ class TestXMLConfig(unittest.TestCase):
def testBootParavirtDiskFile(self):
g = utils.get_basic_paravirt_guest()
g.disks.append(utils.get_filedisk("/tmp/somerandomfilename.img"))
g.add_device(utils.get_filedisk("/tmp/somerandomfilename.img"))
self._compare(g, "boot-paravirt-disk-file", False)
# Just cram some post_install_checks in here
@ -139,13 +139,14 @@ class TestXMLConfig(unittest.TestCase):
except OSError:
pass
g.disks[0].path = "virt-install"
disk = g.get_devices("disk")[0]
disk.path = "virt-install"
self.assertEquals(g.post_install_check(), False)
g.disks[0].driver_type = "raw"
disk.driver_type = "raw"
self.assertEquals(g.post_install_check(), False)
g.disks[0].driver_type = "foobar"
disk.driver_type = "foobar"
self.assertEquals(g.post_install_check(), True)
def testBootParavirtDiskFileBlktapCapable(self):
@ -153,35 +154,35 @@ class TestXMLConfig(unittest.TestCase):
try:
virtinst.util.is_blktap_capable = lambda: True
g = utils.get_basic_paravirt_guest()
g.disks.append(utils.get_filedisk())
g.add_device(utils.get_filedisk())
self._compare(g, "boot-paravirt-disk-drv-tap", False)
finally:
virtinst.util.is_blktap_capable = oldblktap
def testBootParavirtDiskBlock(self):
g = utils.get_basic_paravirt_guest()
g.disks.append(utils.get_blkdisk())
g.add_device(utils.get_blkdisk())
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
g.disks.append(disk)
g.add_device(disk)
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
g.disks.append(disk)
g.add_device(disk)
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
g.disks.append(disk)
g.add_device(disk)
self._compare(g, "boot-paravirt-disk-drv-tap", False)
def testBootParavirtDiskDrvTapQCow(self):
@ -189,7 +190,7 @@ class TestXMLConfig(unittest.TestCase):
disk = utils.get_filedisk()
disk.driver_name = VirtualDisk.DRIVER_TAP
disk.driver_type = VirtualDisk.DRIVER_TAP_QCOW
g.disks.append(disk)
g.add_device(disk)
self._compare(g, "boot-paravirt-disk-drv-tap-qcow", False)
def testBootParavirtManyDisks(self):
@ -198,52 +199,52 @@ class TestXMLConfig(unittest.TestCase):
disk.driver_name = VirtualDisk.DRIVER_TAP
disk.driver_type = VirtualDisk.DRIVER_TAP_QCOW
g.disks.append(utils.get_filedisk("/tmp/test1.img"))
g.disks.append(disk)
g.disks.append(utils.get_blkdisk())
g.add_device(utils.get_filedisk("/tmp/test1.img"))
g.add_device(disk)
g.add_device(utils.get_blkdisk())
self._compare(g, "boot-paravirt-many-disks", False)
def testBootFullyvirtDiskFile(self):
g = utils.get_basic_fullyvirt_guest()
g.disks.append(utils.get_filedisk())
g.add_device(utils.get_filedisk())
self._compare(g, "boot-fullyvirt-disk-file", False)
def testBootFullyvirtDiskBlock(self):
g = utils.get_basic_fullyvirt_guest()
g.disks.append(utils.get_blkdisk())
g.add_device(utils.get_blkdisk())
self._compare(g, "boot-fullyvirt-disk-block", False)
def testInstallParavirtDiskFile(self):
g = utils.get_basic_paravirt_guest()
g.disks.append(utils.get_filedisk())
g.add_device(utils.get_filedisk())
self._compare(g, "install-paravirt-disk-file", True)
def testInstallParavirtDiskBlock(self):
g = utils.get_basic_paravirt_guest()
g.disks.append(utils.get_blkdisk())
g.add_device(utils.get_blkdisk())
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
g.disks.append(disk)
g.add_device(disk)
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
g.disks.append(disk)
g.add_device(disk)
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
g.disks.append(disk)
g.add_device(disk)
self._compare(g, "install-paravirt-disk-drv-tap", True)
def testInstallParavirtDiskDrvTapQCow(self):
@ -251,7 +252,7 @@ class TestXMLConfig(unittest.TestCase):
disk = utils.get_filedisk()
disk.driver_name = VirtualDisk.DRIVER_TAP
disk.driver_type = VirtualDisk.DRIVER_TAP_QCOW
g.disks.append(disk)
g.add_device(disk)
self._compare(g, "install-paravirt-disk-drv-tap-qcow", True)
def testInstallParavirtManyDisks(self):
@ -260,37 +261,37 @@ class TestXMLConfig(unittest.TestCase):
disk.driver_name = VirtualDisk.DRIVER_TAP
disk.driver_type = VirtualDisk.DRIVER_TAP_QCOW
g.disks.append(utils.get_filedisk("/tmp/test1.img"))
g.disks.append(disk)
g.disks.append(utils.get_blkdisk())
g.add_device(utils.get_filedisk("/tmp/test1.img"))
g.add_device(disk)
g.add_device(utils.get_blkdisk())
self._compare(g, "install-paravirt-many-disks", True)
def testInstallFullyvirtDiskFile(self):
g = utils.get_basic_fullyvirt_guest()
g.disks.append(utils.get_filedisk())
g.add_device(utils.get_filedisk())
self._compare(g, "install-fullyvirt-disk-file", True)
def testInstallFullyvirtDiskBlock(self):
g = utils.get_basic_fullyvirt_guest()
g.disks.append(utils.get_blkdisk())
g.add_device(utils.get_blkdisk())
self._compare(g, "install-fullyvirt-disk-block", True)
def testInstallFVPXE(self):
i = utils.make_pxe_installer()
g = utils.get_basic_fullyvirt_guest(installer=i)
g.disks.append(utils.get_filedisk())
g.add_device(utils.get_filedisk())
self._compare(g, "install-fullyvirt-pxe", True)
def testBootFVPXE(self):
i = utils.make_pxe_installer()
g = utils.get_basic_fullyvirt_guest(installer=i)
g.disks.append(utils.get_filedisk())
g.add_device(utils.get_filedisk())
self._compare(g, "boot-fullyvirt-pxe", False)
def testBootFVPXEAlways(self):
i = utils.make_pxe_installer()
g = utils.get_basic_fullyvirt_guest(installer=i)
g.disks.append(utils.get_filedisk())
g.add_device(utils.get_filedisk())
g.installer.bootconfig.bootorder = [
g.installer.bootconfig.BOOT_DEVICE_NETWORK]
@ -323,7 +324,7 @@ class TestXMLConfig(unittest.TestCase):
def testDefaultDeviceRemoval(self):
g = utils.get_basic_fullyvirt_guest()
g.disks.append(utils.get_filedisk())
g.add_device(utils.get_filedisk())
inp = VirtualInputDevice(g.conn)
cons = VirtualCharDevice.get_dev_instance(g.conn,
@ -349,10 +350,10 @@ class TestXMLConfig(unittest.TestCase):
do_install = False
g.installer.cdrom = True
g.disks.append(utils.get_floppy())
g.disks.append(utils.get_filedisk())
g.disks.append(utils.get_blkdisk())
g.nics.append(utils.get_virtual_network())
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())
# Call get_xml_config sets first round of defaults w/o os_variant set
g.get_xml_config(do_install)
@ -364,14 +365,14 @@ class TestXMLConfig(unittest.TestCase):
i = utils.make_import_installer()
g = utils.get_basic_fullyvirt_guest(installer=i)
g.disks.append(utils.get_filedisk())
g.add_device(utils.get_filedisk())
self._compare(g, "install-fullyvirt-import", False)
def testInstallFVImportKernel(self):
i = utils.make_import_installer()
g = utils.get_basic_fullyvirt_guest(installer=i)
g.disks.append(utils.get_filedisk())
g.add_device(utils.get_filedisk())
g.installer.bootconfig.kernel = "kernel"
g.installer.bootconfig.initrd = "initrd"
g.installer.bootconfig.kernel_args = "my kernel args"
@ -384,40 +385,40 @@ class TestXMLConfig(unittest.TestCase):
g.installer.bootconfig.enable_bootmenu = False
g.installer.bootconfig.bootorder = ["hd", "fd", "cdrom", "network"]
g.disks.append(utils.get_filedisk())
g.add_device(utils.get_filedisk())
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)
g.disks.append(utils.get_filedisk())
g.add_device(utils.get_filedisk())
self._compare(g, "install-paravirt-import", False)
def testQEMUDriverName(self):
utils.set_conn(_plainkvm)
g = utils.get_basic_fullyvirt_guest()
g.disks.append(utils.get_blkdisk())
g.add_device(utils.get_blkdisk())
self._compare(g, "misc-qemu-driver-name", True)
g = utils.get_basic_fullyvirt_guest()
g.disks.append(utils.get_filedisk())
g.disks.append(utils.get_blkdisk("/iscsi-pool/diskvol1"))
g.add_device(utils.get_filedisk())
g.add_device(utils.get_blkdisk("/iscsi-pool/diskvol1"))
self._compare(g, "misc-qemu-driver-type", True)
g = utils.get_basic_fullyvirt_guest()
g.disks.append(utils.get_filedisk("/default-pool/iso-vol"))
g.add_device(utils.get_filedisk("/default-pool/iso-vol"))
self._compare(g, "misc-qemu-iso-disk", True)
g = utils.get_basic_fullyvirt_guest()
g.disks.append(utils.get_filedisk("/default-pool/iso-vol"))
g.disks[0].driver_type = "qcow2"
g.add_device(utils.get_filedisk("/default-pool/iso-vol"))
g.get_devices("disk")[0].driver_type = "qcow2"
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"
g.disks.append(utils.get_filedisk("/tmp/ISO&'&s"))
g.add_device(utils.get_filedisk("/tmp/ISO&'&s"))
self._compare(g, "misc-xml-escaping", True)
# OS Type/Version configurations
@ -428,9 +429,9 @@ class TestXMLConfig(unittest.TestCase):
g.os_type = "linux"
g.os_variant = "fedora10"
g.disks.append(utils.get_filedisk())
g.disks.append(utils.get_blkdisk())
g.nics.append(utils.get_virtual_network())
g.add_device(utils.get_filedisk())
g.add_device(utils.get_blkdisk())
g.add_device(utils.get_virtual_network())
self._compare(g, "install-f10", True)
def testF11(self):
@ -441,10 +442,10 @@ class TestXMLConfig(unittest.TestCase):
g.os_type = "linux"
g.os_variant = "fedora11"
g.installer.cdrom = True
g.disks.append(utils.get_floppy())
g.disks.append(utils.get_filedisk())
g.disks.append(utils.get_blkdisk())
g.nics.append(utils.get_virtual_network())
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())
self._compare(g, "install-f11", False)
def testF11AC97(self):
@ -455,10 +456,10 @@ class TestXMLConfig(unittest.TestCase):
g.os_type = "linux"
g.os_variant = "fedora11"
g.installer.cdrom = True
g.disks.append(utils.get_floppy())
g.disks.append(utils.get_filedisk())
g.disks.append(utils.get_blkdisk())
g.nics.append(utils.get_virtual_network())
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())
g.add_device(VirtualAudio())
return g
@ -496,10 +497,10 @@ class TestXMLConfig(unittest.TestCase):
g.os_type = "linux"
g.os_variant = "fedora11"
g.installer.cdrom = True
g.disks.append(utils.get_floppy())
g.disks.append(utils.get_filedisk())
g.disks.append(utils.get_blkdisk())
g.nics.append(utils.get_virtual_network())
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())
self._compare(g, "install-f11-qemu", False)
def testF11Xen(self):
@ -510,10 +511,10 @@ class TestXMLConfig(unittest.TestCase):
g.os_type = "linux"
g.os_variant = "fedora11"
g.installer.cdrom = True
g.disks.append(utils.get_floppy())
g.disks.append(utils.get_filedisk())
g.disks.append(utils.get_blkdisk())
g.nics.append(utils.get_virtual_network())
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())
self._compare(g, "install-f11-xen", False)
def testInstallWindowsKVM(self):
@ -537,9 +538,9 @@ class TestXMLConfig(unittest.TestCase):
g = utils.get_basic_fullyvirt_guest("xen")
g.os_type = "windows"
g.os_variant = "winxp"
g.disks.append(utils.get_filedisk())
g.disks.append(utils.get_blkdisk())
g.nics.append(utils.get_virtual_network())
g.add_device(utils.get_filedisk())
g.add_device(utils.get_blkdisk())
g.add_device(utils.get_virtual_network())
g.add_device(VirtualAudio())
return g
@ -556,27 +557,27 @@ class TestXMLConfig(unittest.TestCase):
i = utils.make_pxe_installer()
g = utils.get_basic_fullyvirt_guest(installer=i)
g.disks.append(utils.get_filedisk())
g.disks.append(utils.get_blkdisk())
g.disks.append(VirtualDisk(conn=g.conn, path="/dev/loop0",
g.add_device(utils.get_filedisk())
g.add_device(utils.get_blkdisk())
g.add_device(VirtualDisk(conn=g.conn, path="/dev/loop0",
device=VirtualDisk.DEVICE_CDROM,
driverType="raw"))
g.disks.append(VirtualDisk(conn=g.conn, path="/dev/loop0",
g.add_device(VirtualDisk(conn=g.conn, path="/dev/loop0",
device=VirtualDisk.DEVICE_DISK,
driverName="qemu", format="qcow2"))
g.disks.append(VirtualDisk(conn=g.conn, path=None,
g.add_device(VirtualDisk(conn=g.conn, path=None,
device=VirtualDisk.DEVICE_CDROM,
bus="scsi"))
g.disks.append(VirtualDisk(conn=g.conn, path=None,
g.add_device(VirtualDisk(conn=g.conn, path=None,
device=VirtualDisk.DEVICE_FLOPPY))
g.disks.append(VirtualDisk(conn=g.conn, path="/dev/loop0",
g.add_device(VirtualDisk(conn=g.conn, path="/dev/loop0",
device=VirtualDisk.DEVICE_FLOPPY,
driverName="phy", driverCache="none"))
disk = VirtualDisk(conn=g.conn, path="/dev/loop0",
bus="virtio", driverName="qemu",
driverType="qcow2", driverCache="none")
disk.driver_io = "threads"
g.disks.append(disk)
g.add_device(disk)
self._compare(g, "boot-many-disks2", False)
@ -596,11 +597,11 @@ class TestXMLConfig(unittest.TestCase):
macaddr="00:11:00:22:00:33")
net5.source_dev = "testeth1"
g.nics.append(net1)
g.nics.append(net2)
g.nics.append(net3)
g.nics.append(net4)
g.nics.append(net5)
g.add_device(net1)
g.add_device(net2)
g.add_device(net3)
g.add_device(net4)
g.add_device(net5)
self._compare(g, "boot-many-nics", False)
def testManyHostdevs(self):
@ -616,18 +617,18 @@ class TestXMLConfig(unittest.TestCase):
dev2.slot = "0x2"
dev2.function = "0x3"
g.hostdevs.append(dev1)
g.hostdevs.append(dev2)
g.add_device(dev1)
g.add_device(dev2)
self._compare(g, "boot-many-hostdevs", False)
def testManySounds(self):
i = utils.make_pxe_installer()
g = utils.get_basic_fullyvirt_guest(installer=i)
g.sound_devs.append(VirtualAudio("sb16", conn=g.conn))
g.sound_devs.append(VirtualAudio("es1370", conn=g.conn))
g.sound_devs.append(VirtualAudio("pcspk", conn=g.conn))
g.sound_devs.append(VirtualAudio(conn=g.conn))
g.add_device(VirtualAudio("sb16", conn=g.conn))
g.add_device(VirtualAudio("es1370", conn=g.conn))
g.add_device(VirtualAudio("pcspk", conn=g.conn))
g.add_device(VirtualAudio(conn=g.conn))
self._compare(g, "boot-many-sounds", False)
@ -699,22 +700,22 @@ class TestXMLConfig(unittest.TestCase):
dev1 = VirtualHostDeviceUSB(g.conn)
dev1.product = "0x1234"
dev1.vendor = "0x4321"
g.hostdevs.append(dev1)
g.add_device(dev1)
# Sound devices
g.sound_devs.append(VirtualAudio("sb16", conn=g.conn))
g.sound_devs.append(VirtualAudio("es1370", conn=g.conn))
g.add_device(VirtualAudio("sb16", conn=g.conn))
g.add_device(VirtualAudio("es1370", conn=g.conn))
# Disk devices
g.disks.append(VirtualDisk(conn=g.conn, path="/dev/loop0",
g.add_device(VirtualDisk(conn=g.conn, path="/dev/loop0",
device=VirtualDisk.DEVICE_FLOPPY))
g.disks.append(VirtualDisk(conn=g.conn, path="/dev/loop0",
g.add_device(VirtualDisk(conn=g.conn, path="/dev/loop0",
bus="scsi"))
g.disks.append(VirtualDisk(conn=g.conn, path="/tmp", device="floppy"))
g.add_device(VirtualDisk(conn=g.conn, path="/tmp", device="floppy"))
d3 = VirtualDisk(conn=g.conn, path="/default-pool/testvol1.img",
bus="scsi", driverName="qemu")
d3.address.type = "spapr-vio"
g.disks.append(d3)
g.add_device(d3)
# Controller devices
c1 = VirtualController.get_class_for_type(VirtualController.CONTROLLER_TYPE_IDE)(g.conn)
@ -734,9 +735,9 @@ class TestXMLConfig(unittest.TestCase):
macaddr="22:22:22:22:22:22", network="default")
net3.model = "spapr-vlan"
net3.set_address("spapr-vio")
g.nics.append(net1)
g.nics.append(net2)
g.nics.append(net3)
g.add_device(net1)
g.add_device(net2)
g.add_device(net3)
# Character devices
cdev1 = VirtualCharDevice.get_dev_instance(g.conn,
@ -878,10 +879,10 @@ class TestXMLConfig(unittest.TestCase):
location="tests/cli-test-xml/fakerhel6tree",
gtype="kvm")
g = utils.get_basic_fullyvirt_guest("kvm", installer=i)
g.disks.append(utils.get_floppy())
g.disks.append(utils.get_filedisk("/default-pool/rhel6.img"))
g.disks.append(utils.get_blkdisk())
g.nics.append(utils.get_virtual_network())
g.add_device(utils.get_floppy())
g.add_device(utils.get_filedisk("/default-pool/rhel6.img"))
g.add_device(utils.get_blkdisk())
g.add_device(utils.get_virtual_network())
g.add_device(VirtualAudio())
g.add_device(VirtualVideoDevice(g.conn))
g.os_autodetect = True

View File

@ -242,11 +242,12 @@ class XMLParseTest(unittest.TestCase):
# XXX: Set size up front. VirtualDisk validation is kind of
# convoluted. If trying to change a non-existing one and size wasn't
# already specified, we will error out.
disk1 = guest.disks[0]
disks = guest.get_devices("disk")
disk1 = disks[0]
disk1.size = 1
disk2 = guest.disks[2]
disk2 = disks[2]
disk2.size = 1
disk3 = guest.disks[5]
disk3 = disks[5]
disk3.size = 1
check = self._make_checker(disk1)

View File

@ -53,12 +53,14 @@ def install_specified(location, cdpath, pxe, import_install):
return bool(pxe or cdpath or location or import_install)
def cdrom_specified(guest, diskopts=None):
for disk in guest.disks:
disks = guest.get_devices("disk")
for disk in disks:
if disk.device == virtinst.VirtualDisk.DEVICE_CDROM:
return True
# Probably haven't set up disks yet
if not guest.disks and diskopts:
if not disks and diskopts:
for opts in diskopts:
if opts.count("device=cdrom"):
return True
@ -155,7 +157,7 @@ def get_disk(diskopts, size, sparse, guest, is_file_path):
except ValueError, e:
fail(_("Error with storage parameters: %s" % str(e)))
guest.disks.append(d)
guest.add_device(d)
def get_disks(guest, file_paths, disk_paths, size, sparse, need_storage):
is_file_path = (file_paths or (not disk_paths and cli.is_prompt()))

View File

@ -869,8 +869,9 @@ class vmmCreate(vmmGObjectUI):
install = _("Operating system container")
storagetmpl = "<span size='small' color='#484848'>%s</span>"
if len(self.guest.disks):
disk = self.guest.disks[0]
disks = self.guest.get_devices("disk")
if disks:
disk = disks[0]
storage = "%s" % self.pretty_storage(disk.size)
storage += " " + (storagetmpl % disk.path)
elif len(self.guest.get_devices("filesystem")):
@ -1004,8 +1005,9 @@ class vmmCreate(vmmGObjectUI):
def get_default_path(self, name):
# Don't generate a new path if the install failed
if self.failed_guest:
if len(self.failed_guest.disks) > 0:
return self.failed_guest.disks[0].path
disks = self.failed_guest.get_devices("disk")
if disks:
return disks[0].path
return util.get_default_path(self.conn, name)
@ -1825,7 +1827,8 @@ class vmmCreate(vmmGObjectUI):
self.rebuild_guest()
guest = self.guest
disk = len(guest.disks) and guest.disks[0]
disks = guest.get_devices("disk")
disk = disks and disks[0]
logging.debug("Creating a VM %s" % guest.name +
"\n Type: %s,%s" % (guest.type,

View File

@ -498,8 +498,7 @@ class LibvirtWorker:
self.__guest.add_device(
virtinst.VirtualGraphics(type=virtinst.VirtualGraphics.TYPE_VNC))
self.__guest.sound_devs = []
self.__guest.sound_devs.append(virtinst.VirtualAudio(model="es1370"))
self.__guest.add_device(virtinst.VirtualAudio())
self._setup_nics(config)
self._setup_disks(config)
@ -508,19 +507,17 @@ class LibvirtWorker:
self.__domain = self.__guest.start_install(False, meter=meter)
def _setup_nics(self, config):
self.__guest.nics = []
nic = virtinst.VirtualNetworkInterface(type=virtinst.VirtualNetworkInterface.TYPE_VIRTUAL,
bridge=config.get_network_bridge(),
network=config.get_network_bridge(),
macaddr=config.get_mac_address())
self.__guest.nics.append(nic)
self.__guest.add_device(nic)
# ensure the network is running
if config.get_network_bridge() not in self.__conn.listNetworks():
network = self.__conn.networkLookupByName(config.get_network_bridge())
network.create()
def _setup_disks(self, config):
self.__guest.disks = []
if config.get_enable_storage():
path = None
if config.get_use_local_storage():
@ -540,5 +537,5 @@ class LibvirtWorker:
storage = virtinst.VirtualDisk(conn=self.__conn,
path=path,
size=config.get_storage_size())
self.__guest.disks.append(storage)
self.__guest.add_device(storage)
self.__guest.conn = self.__conn

View File

@ -205,12 +205,6 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
self._os_variant = None
self._os_autodetect = False
# DEPRECATED: Public device lists unaltered by install process
self.disks = []
self.nics = []
self.sound_devs = []
self.hostdevs = []
# General device list. Only access through API calls (even internally)
self._devices = []
@ -601,16 +595,7 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
self._default_console_device = None
# Actually add the device
if devtype == VirtualDevice.VIRTUAL_DEV_DISK:
self.disks.append(dev)
elif devtype == VirtualDevice.VIRTUAL_DEV_NET:
self.nics.append(dev)
elif devtype == VirtualDevice.VIRTUAL_DEV_AUDIO:
self.sound_devs.append(dev)
elif devtype == VirtualDevice.VIRTUAL_DEV_HOSTDEV:
self.hostdevs.append(dev)
else:
self._devices.append(dev)
self._devices.append(dev)
def get_devices(self, devtype):
@ -621,17 +606,7 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
@param devtype: Device type to search for (one of
VirtualDevice.virtual_device_types)
"""
if devtype == VirtualDevice.VIRTUAL_DEV_DISK:
devlist = self.disks[:]
elif devtype == VirtualDevice.VIRTUAL_DEV_NET:
devlist = self.nics[:]
elif devtype == VirtualDevice.VIRTUAL_DEV_AUDIO:
devlist = self.sound_devs[:]
elif devtype == VirtualDevice.VIRTUAL_DEV_HOSTDEV:
devlist = self.hostdevs[:]
else:
devlist = self._dev_build_list(devtype)
devlist = self._dev_build_list(devtype)
devlist.extend(self._install_devices)
return self._dev_build_list(devtype, devlist)
@ -651,8 +626,7 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
@param dev: VirtualDevice instance
"""
found = False
for devlist in [self.disks, self.nics, self.sound_devs, self.hostdevs,
self._devices, self._install_devices]:
for devlist in [self._devices, self._install_devices]:
if found:
break

View File

@ -42,9 +42,10 @@ class ImportInstaller(Installer.Installer):
# Private methods
def _get_bootdev(self, isinstall, guest):
if not guest.disks:
disks = guest.get_devices("disk")
if not disks:
return self.bootconfig.BOOT_DEVICE_HARDDISK
return self._disk_to_bootdev(guest.disks[0])
return self._disk_to_bootdev(disks[0])
def _disk_to_bootdev(self, disk):
if disk.device == VirtualDisk.DEVICE_DISK:

View File

@ -416,12 +416,13 @@ class Installer(XMLBuilderDomain.XMLBuilderDomain):
# XXX: Use block peek for this?
return True
if (len(guest.disks) == 0 or
guest.disks[0].device != VirtualDisk.DEVICE_DISK):
disks = guest.get_devices("disk")
if not disks:
return True
disk = guest.disks[0]
disk = disks[0]
if disk.device != VirtualDisk.DEVICE_DISK:
return True
if util.is_vdisk(disk.path):
return True

View File

@ -30,7 +30,8 @@ class PXEInstaller(Installer.Installer):
bootdev = self.bootconfig.BOOT_DEVICE_NETWORK
if (not isinstall and
[d for d in guest.disks if d.device == d.DEVICE_DISK]):
[d for d in guest.get_devices("disk") if
d.device == d.DEVICE_DISK]):
# If doing post-install boot and guest has an HD attached
bootdev = self.bootconfig.BOOT_DEVICE_HARDDISK

View File

@ -974,8 +974,7 @@ def get_video(guest, video_models=None):
def get_sound(old_sound_bool, sound_opts, guest):
if not sound_opts:
if old_sound_bool:
# Use os default
guest.sound_devs.append(VirtualAudio(conn=guest.conn))
guest.add_device(VirtualAudio(conn=guest.conn))
return
for opts in listify(sound_opts):