a8a375285f
permissions for kernel/initrd download location (bz 523960)
197 lines
6.6 KiB
Diff
197 lines
6.6 KiB
Diff
# HG changeset patch
|
|
# User Cole Robinson <crobinso@redhat.com>
|
|
# 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 @@
|
|
</target>
|
|
</volume>
|
|
<volume>
|
|
+ <name>iso-vol</name>
|
|
+ <capacity>1000000</capacity>
|
|
+ <allocation>50000</allocation>
|
|
+ <target>
|
|
+ <format type='iso'/>
|
|
+ </target>
|
|
+ </volume>
|
|
+ <volume>
|
|
+ <name>bochs-vol</name>
|
|
+ <capacity>1000000</capacity>
|
|
+ <allocation>50000</allocation>
|
|
+ <target>
|
|
+ <format type='bochs'/>
|
|
+ </target>
|
|
+ </volume>
|
|
+ <volume>
|
|
<name>testvol1.img</name>
|
|
<capacity>1000000</capacity>
|
|
<allocation>50000</allocation>
|
|
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 @@
|
|
+<domain type='xen'>
|
|
+ <name>TestGuest</name>
|
|
+ <currentMemory>204800</currentMemory>
|
|
+ <memory>409600</memory>
|
|
+ <uuid>12345678-1234-1234-1234-123456789012</uuid>
|
|
+ <os>
|
|
+ <type arch='i686'>hvm</type>
|
|
+ <loader>/usr/lib/xen/boot/hvmloader</loader>
|
|
+ <boot dev='cdrom'/>
|
|
+ </os>
|
|
+ <features>
|
|
+ <acpi/><apic/>
|
|
+ </features>
|
|
+ <clock offset="utc"/>
|
|
+ <on_poweroff>destroy</on_poweroff>
|
|
+ <on_reboot>destroy</on_reboot>
|
|
+ <on_crash>destroy</on_crash>
|
|
+ <vcpu>5</vcpu>
|
|
+ <devices>
|
|
+ <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
|
|
+ <disk type='file' device='disk'>
|
|
+ <driver name='qemu' type='raw'/>
|
|
+ <source file='/default-pool/iso-vol'/>
|
|
+ <target dev='hda' bus='ide'/>
|
|
+ </disk>
|
|
+ <disk type='block' device='cdrom'>
|
|
+ <driver name='qemu'/>
|
|
+ <source dev='/dev/loop0'/>
|
|
+ <target dev='hdc' bus='ide'/>
|
|
+ <readonly/>
|
|
+ </disk>
|
|
+ <input type='mouse' bus='ps2'/>
|
|
+ <graphics type='sdl' display=':3.4' xauth='/testdir/.Xauthority'/>
|
|
+ <console type='pty'/>
|
|
+ </devices>
|
|
+</domain>
|
|
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()
|