<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Sun, Mar 25, 2018 at 1:36 AM Nir Soffer <<a href="mailto:nirsof@gmail.com">nirsof@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Thu, Mar 22, 2018 at 5:25 PM Richard W.M. Jones <<a href="mailto:rjones@redhat.com" target="_blank">rjones@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">PROBLEMS:<br>
 - -of qcow2 does not work, with multiple problems<br>
    * needs to set NBD size to something larger than virtual size<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>How is this related to the actual file size specified when you create a disk?</div><div><br></div><div>In block storage, qcow2 image is always on a thin provisioned disk, which</div><div>in oVirt is a regular logical volume, created at the requested "initial_size":</div><div><br></div><div>From:</div><div><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;color:rgb(36,41,46);width:1px;height:1px"><a href="https://github.com/oVirt/ovirt-engine-sdk/blob/aba2a83ec94ecac1594adfff62d3cfcfdbdef416/sdk/examples/upload_disk.py#L113" target="_blank">https://github.com/oVirt/ovirt-engine-sdk/blob/aba2a83ec94ecac1594adfff62d3cfcfdbdef416/sdk/examples/upload_disk.py#L113</a></pre></div><div><br></div><div><pre style="word-wrap:break-word;white-space:pre-wrap">if image_info["format"] == "qcow2":
    disk_format = types.DiskFormat.COW
else:
    disk_format = types.DiskFormat.RAW

disks_service = connection.system_service().disks_service()
disk = disks_service.add(
    disk=types.Disk(
        name=os.path.basename(image_path),
        description='Uploaded disk',
        format=disk_format,
        initial_size=image_size,
        provisioned_size=image_info["virtual-size"],
        sparse=disk_format == types.DiskFormat.COW,
        storage_domains=[
            types.StorageDomain(
                name='mydata'
            )
        ]
    )
)
</pre>Internally we do allocated 10% more then the requested initial_size</div><div>to leave room for qcow2 metadata.</div></div></div></blockquote><div><br></div><div>But best do not depend on this, I would like to remove it in the future.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>[snipped] <br></div></div></div><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+    # Create the disk.<br>
+    disks_service = system_service.disks_service()<br>
+    if params['disk_format'] == "raw":<br>
+        disk_format = types.DiskFormat.RAW<br>
+    else:<br>
+        disk_format = types.DiskFormat.COW<br>
+    disk = disks_service.add(<br>
+        disk = types.Disk(<br>
+            name = params['disk_name'],<br>
+            description = "Uploaded by virt-v2v",<br>
+            format = disk_format,<br>
+            provisioned_size = params['disk_size'],<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>This must be the virtual size.</div><div><br></div><div>You don't specify initial_size - in this case you get 1G, and most</div><div>images will fail to upload.</div></div></div></blockquote><div><br></div><div>Since you are using qemu-img convert, you must give initial_size that it big</div><div>enough to hold the image after conversion. The source image size may not</div><div>be enough, since it may contain compressed clusters.</div><div><br></div><div>The best way to estimate the size it to use the new "qemu-img measure"</div><div>command.</div><div><br></div><div>The oVirt sdk examples do not care about this since we just copy the image</div><div>as is to storage.</div><div><br></div><div>Nir</div></div></div>