# HG changeset patch # User Cole Robinson # Date 1253562724 14400 # Node ID aff98f0152935ad7cd57e86c4172a6683e6306c5 # Parent 143b09da8bccc3b6b2069c29073ea5a6ef9ce69b VirtualDisk: Don't use 'iso' as a qemu driver name (bz 524109) diff -r 143b09da8bcc -r aff98f015293 tests/testdriver.xml --- a/tests/testdriver.xml Mon Sep 21 15:47:33 2009 -0400 +++ b/tests/testdriver.xml Mon Sep 21 15:52:04 2009 -0400 @@ -67,6 +67,22 @@ + iso-vol + 1000000 + 50000 + + + + + + bochs-vol + 1000000 + 50000 + + + + + testvol1.img 1000000 50000 diff -r 143b09da8bcc -r aff98f015293 tests/xmlconfig-xml/misc-qemu-iso-disk.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/xmlconfig-xml/misc-qemu-iso-disk.xml Mon Sep 21 15:52:04 2009 -0400 @@ -0,0 +1,36 @@ + + TestGuest + 204800 + 409600 + 12345678-1234-1234-1234-123456789012 + + hvm + /usr/lib/xen/boot/hvmloader + + + + + + + destroy + destroy + destroy + 5 + + /usr/lib/xen/bin/qemu-dm + + + + + + + + + + + + + + + + diff -r 143b09da8bcc -r aff98f015293 tests/xmlconfig.py --- a/tests/xmlconfig.py Mon Sep 21 15:47:33 2009 -0400 +++ b/tests/xmlconfig.py Mon Sep 21 15:52:04 2009 -0400 @@ -302,9 +302,15 @@ g.disks.append(get_blkdisk()) self._compare(g, "misc-qemu-driver-name", True) + VirtualDisk._get_uri = new_get_uri g = get_basic_fullyvirt_guest() g.disks.append(get_filedisk()) self._compare(g, "misc-qemu-driver-type", True) + + VirtualDisk._get_uri = new_get_uri + g = get_basic_fullyvirt_guest() + g.disks.append(get_filedisk("/default-pool/iso-vol")) + self._compare(g, "misc-qemu-iso-disk", True) finally: VirtualDisk._get_uri = oldgetdriver diff -r 143b09da8bcc -r aff98f015293 virtinst/VirtualDisk.py --- a/virtinst/VirtualDisk.py Mon Sep 21 15:47:33 2009 -0400 +++ b/virtinst/VirtualDisk.py Mon Sep 21 15:52:04 2009 -0400 @@ -55,6 +55,20 @@ except OSError: return False +def _qemu_sanitize_drvtype(phystype, fmt): + """ + Sanitize libvirt storage volume format to a valid qemu driver type + """ + raw_list = [ "iso" ] + + if phystype == VirtualDisk.TYPE_BLOCK: + return VirtualDisk.DRIVER_QEMU_RAW + + if fmt in raw_list: + return VirtualDisk.DRIVER_QEMU_RAW + + return fmt + class VirtualDisk(VirtualDevice): """ Builds a libvirt domain disk xml description @@ -490,8 +504,8 @@ http://lists.gnu.org/archive/html/qemu-devel/2008-04/msg00675.html """ - drvname = None - drvtype = None + drvname = self._driverName + drvtype = self._driverType if self.conn: driver = _util.get_uri_driver(self._get_uri()) @@ -499,15 +513,15 @@ drvname = self.DRIVER_QEMU if self.vol_object: - drvtype = _util.get_xml_path(self.vol_object.XMLDesc(0), - "/volume/target/format/@type") + fmt = _util.get_xml_path(self.vol_object.XMLDesc(0), + "/volume/target/format/@type") + if drvname == self.DRIVER_QEMU: + drvtype = _qemu_sanitize_drvtype(self.type, fmt) elif self.vol_install: if drvname == self.DRIVER_QEMU: - if self.vol_install.file_type == libvirt.VIR_STORAGE_VOL_FILE: - drvtype = self.vol_install.format - else: - drvtype = self.DRIVER_QEMU_RAW + drvtype = _qemu_sanitize_drvtype(self.type, + self.vol_install.format) elif self.__creating_storage(): if drvname == self.DRIVER_QEMU: @@ -729,8 +743,10 @@ managed_storage = self.__storage_specified() create_media = self.__creating_storage() + self.__set_dev_type() self.__set_size() self.__set_format() + self.__set_driver() if not self.selinux_label: # If we are using existing storage, pull the label from it @@ -745,9 +761,6 @@ self._selinux_label = context or "" - # Set driverName + driverType - self.__set_driver() - # If not creating the storage, our job is easy if not create_media: # Make sure we have access to the local path @@ -757,7 +770,6 @@ raise ValueError(_("The path '%s' must be a file or a " "device, not a directory") % self.path) - self.__set_dev_type() return True @@ -770,7 +782,6 @@ if self.type is self.TYPE_BLOCK: raise ValueError, _("Local block device path '%s' must " "exist.") % self.path - self.set_type(self.TYPE_FILE, validate=False) # Path doesn't exist: make sure we have write access to dir if not os.access(os.path.dirname(self.path), os.R_OK): @@ -782,9 +793,6 @@ if not os.access(os.path.dirname(self.path), os.W_OK): raise ValueError, _("No write access to directory '%s'") % \ os.path.dirname(self.path) - else: - # Set dev type from existing storage - self.__set_dev_type() # Applicable for managed or local storage ret = self.is_size_conflict()