def create_cow_image(backing_file, path, size=None):
 base_cmd = ['qemu-img', 'create', '-f', 'qcow2']
 cow_opts = []
 if backing_file:
  cow_opts += [('backing_file=%s' % backing_file)]
  base_details = images.qemu_img_info(backing_file)
 else:
  base_details = None
 if (base_details and (base_details.cluster_size is not None)):
  cow_opts += [('cluster_size=%s' % base_details.cluster_size)]
 if (base_details and base_details.encryption):
  cow_opts += [('encryption=%s' % base_details.encryption)]
 if (size is not None):
  cow_opts += [('size=%s' % size)]
 if cow_opts:
  csv_opts = ','.join(cow_opts)
  cow_opts = ['-o', csv_opts]
 cmd = ((base_cmd + cow_opts) + [path])
 execute(*cmd)

def create_cow_image ( backing_file , path , size = None ) : base_cmd = [ 'qemu-img' , 'create' , '-f' , 'qcow2' ] cow_opts = [ ] if backing_file : cow_opts += [ ( 'backing_file=%s' % backing_file ) ] base_details = images . qemu_img_info ( backing_file ) else : base_details = None if ( base_details and ( base_details . cluster_size is not None ) ) : cow_opts += [ ( 'cluster_size=%s' % base_details . cluster_size ) ] if ( base_details and base_details . encryption ) : cow_opts += [ ( 'encryption=%s' % base_details . encryption ) ] if ( size is not None ) : cow_opts += [ ( 'size=%s' % size ) ] if cow_opts : csv_opts = ',' . join ( cow_opts ) cow_opts = [ '-o' , csv_opts ] cmd = ( ( base_cmd + cow_opts ) + [ path ] ) execute ( * cmd )
create cow image creates a cow image with the given backing file .