ia64/xen-unstable

changeset 14519:b98832bcac53

Fixes to XendQCoWStorageRepo to match recent API changes, and fix the refreshing
after a VDI is deleted.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Thu Mar 22 17:02:02 2007 +0000 (2007-03-22)
parents 5f526fcc8e58
children f6845c09b872
files tools/python/xen/xend/XendQCoWStorageRepo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendQCoWStorageRepo.py	Thu Mar 22 16:32:18 2007 +0000
     1.2 +++ b/tools/python/xen/xend/XendQCoWStorageRepo.py	Thu Mar 22 17:02:02 2007 +0000
     1.3 @@ -208,7 +208,8 @@ class XendQCoWStorageRepo(XendStorageRep
     1.4          self.lock.acquire()
     1.5          try:
     1.6              if not self._has_space_available_for(desired_size_bytes):
     1.7 -                raise XendError("Not enough space")
     1.8 +                raise XendError("Not enough space (need %d)" %
     1.9 +                                desired_size_bytes)
    1.10  
    1.11              image_uuid = uuid.createString()
    1.12              qcow_path = os.path.join(self.location,
    1.13 @@ -251,6 +252,7 @@ class XendQCoWStorageRepo(XendStorageRep
    1.14                  except OSError:
    1.15                      log.exception("Failed to destroy image")
    1.16                  del self.images[image_uuid]
    1.17 +                self._refresh()
    1.18                  return True
    1.19          finally:
    1.20              self.lock.release()
    1.21 @@ -317,15 +319,12 @@ class XendQCoWStorageRepo(XendStorageRep
    1.22      def create_vdi(self, vdi_struct):
    1.23          image_uuid = None
    1.24          try:
    1.25 -            sector_count = int(vdi_struct.get('virtual_size', 0))
    1.26 -            sector_size = int(vdi_struct.get('sector_size', 1024))
    1.27 -            size_bytes = (sector_count * sector_size)
    1.28 +            size_bytes = int(vdi_struct.get('virtual_size', 0))
    1.29  
    1.30              image_uuid = self._create_image_files(size_bytes)
    1.31              
    1.32              image = self.images[image_uuid]
    1.33              image_cfg = {
    1.34 -                'sector_size': sector_size,
    1.35                  'virtual_size': size_bytes,
    1.36                  'type': vdi_struct.get('type', 'system'),
    1.37                  'name_label': vdi_struct.get('name_label', ''),
    1.38 @@ -350,17 +349,3 @@ class XendQCoWStorageRepo(XendStorageRep
    1.39              raise
    1.40  
    1.41          return image_uuid
    1.42 -
    1.43 -
    1.44 -# remove everything below this line!! for testing only
    1.45 -if __name__ == "__main__":
    1.46 -    xsr = XendStorageRepository()
    1.47 -    print 'Free Space: %d MB' % (xsr.free_space_bytes()/MB)
    1.48 -    print "Create Image:",
    1.49 -    print xsr._create_image_files(10 * MB)
    1.50 -    print 'Delete all images:'
    1.51 -    for image_uuid in xsr.list_images():
    1.52 -        print image_uuid,
    1.53 -        xsr._destroy_image_files(image_uuid)
    1.54 -
    1.55 -    print