On Tue, Jul 3, 2018 at 11:32 AM Ranjit DSouza <Ranjit.DSouza@veritas.com> wrote:

We had a conversation with Pavan Chavva for supporting RHV. He had suggested to contact you with queries related to oVirt APIs we plan to use.

We have following queries:


1.       While downloading a snapshot disk, can we identify allocated extents and download only those using oVirt API? We are able to download the disk using the Image Transfer API mechanism.

However, this method downloads the entire disk including the non-allocated extents, which is a performance overhead. If this functionality does not exist at this point will it be available in near future?

Hi Ranjit,

There is no way to do this in current 4.2, but we plan to introduce in in 4.2.z.

The API will be something like:

GET /images/xxx-yyy/map
[{ "start": 0, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": 0},
{ "start": 65536, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": 65536},
{ "start": 1048576, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": 1048576},
{ "start": 1114112, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": 1114112},
{ "start": 5465571328, "length": 22675456, "depth": 0, "zero": false, "data": true, "offset": 5465571328},
{ "start": 5488246784, "length": 954138624, "depth": 0, "zero": true, "data": false, "offset": 5488246784},
{ "start": 6442385408, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": 6442385408}]

This is basically what you get using qemu-img map.

You can test play this with this using:

    virt-builder Fedora-27 -o /var/tmp/fedora-27.img
    qemu-img map -f raw --output json /var/tmp/fedora-27.img

This is the first data segment:
{ "start": 0, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": 0}

This is a hole between the first data segment and the second:
{ "start": 65536, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": 65536}

This is the second data segment:
{ "start": 1048576, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": 1048576}

Based on this output, you will be able to get the allocated parts of the image using:


    GET /image/xxx-yyy HTTP/1.1
    Range: bytes=0-65535


    HTTP/1.1 206 Partial Content
    Content-Range: bytes 0-65535/6442450944
    <data of first segment>


    GET /image/xxx-yyy HTTP/1.1
    Range: bytes=1048576-1114111


    HTTP/1.1 206 Partial Content
    Content-Range: bytes 1048576-1114111/6442450944
    <data of second segment>

And so on.
If you create a sparse file on your backup media, and download and write
the data segments at the correct offset, you will get the a sparse version of
the image as on the server side.

This will work for raw or qcow2 images on NFS >= 4.2, or for qcow2 images on block

For older NFS versions, or raw images on block storage, we can solve the issue by
reading the entire image and detecting zeroes - which is quite expensive, so I'm not
sure we will implement this, maybe it will be done later.

We have experimental patch using special sparse format, that can support this use 
case, downloading entire image in one pass. This commit message explain the 

For more info on using random I/O APIs, see:
(available since 4.2.3)

For example code uploading sparse images see:

For best performance, you should run your application on a oVirt host, using unix
socket to communicate with imageio. See:
(will be available in 4.2.5)

All this will work only for the non-active layer in a qcow2 chain. We are working now
on incremental backup which will allow the same for the active layer with a running
vm. This is expected in 4.3, and we may have a tech preview at some point in 4.2.z.
Incremantal backup will use the similar API, allowing detection of dirty parts of an image,
so you can download only the data that was changed since the last backup.
Please watch and comment on the feature page:

We are also considering exposing images using NBD. This will allow downloading
and uploading images using qemu-img from any host. This work depends on TLS-PSK
support in qemu-img and qemu-nbd. You can follow this work here:

2.       Is there an alternate method to transfer a snapshot to and from RHV storage? Are there other methods such as NFS share where we can download snapshot image to and from RHV storage?

We don't support direct access to storage by 3rd party. You should use imageio API.

Can you file RFE for this, explaning the use case and the current performance 
issues you experience?