Univention Bugzilla – Attachment 2768 Details for
Bug 18765
OpenDVDI Instanzen clonen - Copy on write
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Implement CoW using qcow2 image files
18765_dvs_qcow2.diff (text/plain), 11.16 KB, created by
Philipp Hahn
on 2010-10-20 18:14:08 CEST
(
hide
)
Description:
Implement CoW using qcow2 image files
Filename:
MIME Type:
Creator:
Philipp Hahn
Created:
2010-10-20 18:14:08 CEST
Size:
11.16 KB
patch
obsolete
>Index: uvmm/univention-virtual-machine-manager-daemon/debian/changelog >=================================================================== >--- uvmm/univention-virtual-machine-manager-daemon/debian/changelog (Revision 20462) >+++ uvmm/univention-virtual-machine-manager-daemon/debian/changelog (Arbeitskopie) >@@ -1,3 +1,9 @@ >+univention-virtual-machine-manager-daemon (0.10.4-6) unstable; urgency=low >+ >+ * Support qcow2 image files (Bug #18765) >+ >+ -- Philipp Hahn <hahn@univention.de> Wed, 20 Oct 2010 16:08:36 +0200 >+ > univention-virtual-machine-manager-daemon (0.10.4-5) unstable; urgency=low > > * Sort list of servers (Bug #20345) >Index: uvmm/univention-virtual-machine-manager-daemon/src/univention-virtual-machine-manager >=================================================================== >--- uvmm/univention-virtual-machine-manager-daemon/src/univention-virtual-machine-manager (Revision 20322) >+++ uvmm/univention-virtual-machine-manager-daemon/src/univention-virtual-machine-manager (Arbeitskopie) >@@ -289,6 +289,10 @@ > except KeyError: pass > else: > raise "Unknown os/typ='%s'" % (domain.os_type,) >+ try: domain.bootloader = root.findtext('bootloader') >+ except AttributeError: pass >+ try: domain.bootloader_args = root.findtext('bootloader_args') >+ except AttributeError: pass > domain.maxMem = int(root.findtext('memory')) << 10 > from univention.uvmm.node import Disk, Interface, Graphic > for disk in root.find('devices').findall('disk'): >@@ -299,13 +303,26 @@ > try: d.driver = disk.find('driver').attrib['name'] > except AttributeError: pass > except KeyError: pass >- d.source = disk.find('source').attrib['file'] >+ try: d.driver_type = disk.find('driver').attrib['type'] >+ except AttributeError: pass >+ except KeyError: pass >+ try: d.driver_cache = d.map_cache(name=disk.find('driver').attrib['cache']) >+ except AttributeError: pass >+ except KeyError: pass >+ if d.type == Disk.TYPE_FILE: >+ d.source = disk.find('source').attrib['file'] >+ elif d.type == Disk.TYPE_BLOCK: >+ d.source = disk.find('source').attrib['dev'] >+ else: >+ d.source = None # FIXME > try: d.target_dev = disk.find('target').attrib['dev'] > except AttributeError: pass > except KeyError: pass > try: d.target_bus = disk.find('target').attrib['bus'] > except AttributeError: pass > except KeyError: pass >+ try: d.readonly = bool(disk.find('readonly')) >+ except KeyError: pass > domain.disks.append(d) > for interface in root.find('devices').findall('interface'): > i = Interface() >@@ -322,6 +339,9 @@ > try: i.target = interface.find('target').attrib['dev'] > except AttributeError: pass > except KeyError: pass >+ try: i.model = interface.find('model').attrib['type'] >+ except AttributeError: pass >+ except KeyError: pass > domain.interfaces.append(i) > for graphics in root.find('devices').findall('graphics'): > g = Graphic() >@@ -334,6 +354,8 @@ > except KeyError: pass > try: g.listen = graphics.attrib['listen'] > except KeyError: pass >+ try: g.passwd = graphics.attrib['passwd'] >+ except KeyError: pass > domain.graphics.append(g) > try: > for annotation in root.find('annotations').findall('annotation'): >Index: uvmm/univention-virtual-machine-manager-daemon/src/univention/uvmm/node.py >=================================================================== >--- uvmm/univention-virtual-machine-manager-daemon/src/univention/uvmm/node.py (Revision 20373) >+++ uvmm/univention-virtual-machine-manager-daemon/src/univention/uvmm/node.py (Arbeitskopie) >@@ -93,14 +93,18 @@ > DEVICE_MAP = { DEVICE_DISK : 'disk', DEVICE_CDROM : 'cdrom', DEVICE_FLOPPY : 'floppy' } > (TYPE_FILE, TYPE_BLOCK) = range(2) > TYPE_MAP = {TYPE_FILE: 'file', TYPE_BLOCK: 'block'} >+ (CACHE_DEFAULT, CACHE_NONE, CACHE_WT, CACHE_WB) = range(4) >+ CACHE_MAP = {CACHE_DEFAULT: 'default', CACHE_NONE: 'none', CACHE_WT: 'writethrough', CACHE_WB: 'writeback'} > def __init__( self ): >- self.type = Disk.TYPE_FILE >- self.device = Disk.DEVICE_DISK >- self.driver = 'file' >- self.source = '' >- self.readonly = False >- self.target_dev = '' >- self.target_bus = 'ide' >+ self.type = Disk.TYPE_FILE # disk/@type >+ self.device = Disk.DEVICE_DISK # disk/@device >+ self.driver = None # disk/driver/@name >+ self.driver_type = None # disk/driver/@type >+ self.driver_cache = Disk.CACHE_DEFAULT # disk/driver/@cache >+ self.source = '' # disk/source/@file | disk/source/@dev >+ self.readonly = False # disk/readonly >+ self.target_dev = '' # disk/target/@dev >+ self.target_bus = None # disk/target/@bus > self.size = None # not defined > > @staticmethod >@@ -111,6 +115,10 @@ > def map_type( id = None, name = None ): > return _map( Disk.TYPE_MAP, id, name ) > >+ @staticmethod >+ def map_cache(id=None, name=None): >+ return _map(Disk.CACHE_MAP, id, name) >+ > def __str__( self ): > return 'Disk(%s,%s): %s, %s' % ( Disk.map_device( id = self.device ), Disk.map_type( id = self.type ), self.source, self.target_dev ) > >@@ -366,6 +374,11 @@ > dev = Disk() > dev.type = Disk.map_type( name = disk.getAttribute( 'type' ) ) > dev.device = Disk.map_device( name = disk.getAttribute( 'device' ) ) >+ driver = disk.getElementsByTagName('driver') >+ if driver: >+ dev.driver = driver[0].getAttribute('name') >+ dev.driver_type = driver[0].getAttribute('type') >+ dev.driver_cache = driver[0].getAttribute('cache') > source = disk.getElementsByTagName( 'source' ) > if source: > if dev.type == Disk.TYPE_FILE: >@@ -843,10 +856,14 @@ > elem.setAttribute( 'device', disk.map_device( id = disk.device ) ) > devices.appendChild( elem ) > >- # FIXME: KVM doesn't like it -> Xen/libvirt adds this automatically >- # driver = doc.createElement( 'driver' ) >- # driver.setAttribute( 'name', disk.driver ) >- # elem.appendChild( driver ) >+ if disk.driver: >+ driver = doc.createElement('driver') >+ driver.setAttribute('name', disk.driver) >+ if disk.driver_type: >+ driver.setAttribute('type', disk.driver_type) >+ if disk.driver_cache: >+ driver.setAttribute('cache', disk.map_cache(id=disk.driver_cache)) >+ elem.appendChild(driver) > > source = doc.createElement( 'source' ) > if disk.type == Disk.TYPE_FILE: >@@ -861,7 +878,8 @@ > target = doc.createElement( 'target' ) > target.setAttribute( 'dev', disk.target_dev ) > # TODO: Xen an KVM have their default based on the device names >- # target.setAttribute( 'bus', disk.target_bus ) >+ if disk.target_bus: >+ target.setAttribute('bus', disk.target_bus) > elem.appendChild( target ) > > if disk.readonly: >Index: dvs/univention-dvs-node/univention-dvs-create-desktop >=================================================================== >--- dvs/univention-dvs-node/univention-dvs-create-desktop (Revision 20475) >+++ dvs/univention-dvs-node/univention-dvs-create-desktop (Arbeitskopie) >@@ -127,7 +127,7 @@ > continue > > origPath = disk.source >- diskPath = "%s_%d" % (userTemplate, i) >+ diskPath = "%s_%d.img" % (userTemplate, i) > if os.path.exists(diskPath): > if options.testing: > debug(1, 'Existing image: %s' % diskPath) >@@ -144,6 +144,39 @@ > debug(1, 'Using image: %s' % disk.source) > i += 1 > >+ elif cow == "qcow2": >+ i = 0 >+ for disk in desktopDescription.disks: >+ if disk.readonly or disk.type == disk.DEVICE_CDROM: >+ debug(1, 'Re-using image: %s' % disk.source) >+ continue >+ >+ origPath = disk.source >+ diskPath = "%s_%d.qcow2" % (userTemplate, i) >+ if os.path.exists(diskPath): >+ if options.testing: >+ debug(1, 'Existing image: %s' % diskPath) >+ continue >+ raise StorageException('Image already exists: %s' % diskPath) >+ >+ size = os.stat(origPath).st_size # TODO: add space for metadata overhead? >+ if desktopDescription.domain_type == 'xen': >+ img_bin = 'qemu-img-xen' >+ elif desktopDescription.domain_type == 'kvm': >+ img_bin = 'kvm-img' >+ else: >+ img_bin = 'qemu-img' >+ debug(1, "Creating '%s' based on '%s' using %s, size %d" % (diskPath, origPath, img_bin, size)) >+ p = subprocess.Popen([img_bin, "create", "-b", origPath, "-f", "qcow2", diskPath, str(size)]) >+ p.wait() >+ if p.returncode != 0: >+ raise StorageException("Failed to create image '%s' based on '%s'" % (diskPath, origPath)) >+ disk.source = diskPath >+ disk.driver = 'tap' >+ disk.driver_type = 'qcow2' >+ debug(1, 'Using image: %s' % disk.source) >+ i += 1 >+ > elif cow == "dm": > # FIXME: sub-directories are not supported by libvirt fs storage backend > if os.path.exists(userTemplate): >Index: dvs/univention-dvs-node/debian/changelog >=================================================================== >--- dvs/univention-dvs-node/debian/changelog (Revision 20475) >+++ dvs/univention-dvs-node/debian/changelog (Arbeitskopie) >@@ -1,3 +1,9 @@ >+univention-dvs-node (1.0.30-10) unstable; urgency=low >+ >+ * Implement qcow2 support (Bug #18765) >+ >+ -- Philipp Hahn <hahn@univention.de> Wed, 20 Oct 2010 16:58:51 +0200 >+ > univention-dvs-node (1.0.30-9) unstable; urgency=low > > * u-d-d-t: Import missing univention.debug (Bug #18192) >Index: dvs/univention-dvs-node/debian/univention-dvs-node.univention-config-registry-variables >=================================================================== >--- dvs/univention-dvs-node/debian/univention-dvs-node.univention-config-registry-variables (Revision 20475) >+++ dvs/univention-dvs-node/debian/univention-dvs-node.univention-config-registry-variables (Arbeitskopie) >@@ -35,8 +35,8 @@ > Categories=dvs > > [dvs/desktop/cow] >-Description[de]=Typ des Copy-on-Write-Image (no=kein Copy-on-Write, dm=dm-snapshots) >-Description[en]=Type of the Copy-on-Write-Image (no=no copy-on-write, dm=dm-snapshots) >+Description[de]=Typ des Copy-on-Write-Image (no=kein Copy-on-Write, dm=dm-snapshots, qcow2) >+Description[en]=Type of the Copy-on-Write-Image (no=no copy-on-write, dm=dm-snapshots, qcow2) > Type=str > Categories=dvs > >Index: dvs/univention-dvs-node/update-pickle >=================================================================== >--- dvs/univention-dvs-node/update-pickle (Revision 20475) >+++ dvs/univention-dvs-node/update-pickle (Arbeitskopie) >@@ -31,6 +31,12 @@ > for dsk in domain.disks: > if not hasattr(dsk, 'size'): > dsk.size = None >+ if not hasattr(dsk, 'driver_type'): >+ dsk.driver_type = None >+ if not hasattr(dsk, 'driver_cache'): >+ dsk.driver_cache = None >+ if dsk.target_bus == 'ide': >+ dsk.target_bus = None > # Update /volume/source s/opendvdi/dvs/ > for dsk in domain.disks: > dsk.source = dsk.source.replace('univention-opendvdi', 'univention-dvs') >Index: dvs/univention-dvs-node/README.txt >=================================================================== >--- dvs/univention-dvs-node/README.txt (Revision 20475) >+++ dvs/univention-dvs-node/README.txt (Arbeitskopie) >@@ -32,6 +32,10 @@ > > = Copy-on-Write = > >+== device-mapper == >+ >+ ucr set dvs/desktop/cow=qcow2 >+ > * since the fix for CVE-2008-2004 raw is no longer the default for unknown disk formats. > * known disk formats are hard-coded in qemu-dm using C-code. > * only "phy" and "file" are using "raw" as the format. >@@ -48,3 +52,9 @@ > If you want to use pools in libvirt, you MUST set the instance directory to something outside any pool! > mkdir /var/lib/univention-dvs-instances > ucr set dvs/desktop/directory=/var/lib/univention-dvs-instances >+ >+== qcow2 == >+ >+ ucr set dvs/desktop/cow=qcow2 >+ >+* Neewd univention-virtual-machine-manager-daemon (0.10.4-6)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 18765
: 2768 |
2769