[PATCH 00/15] qemu: Handle 'size' and 'offset' attributes of 'raw' format

Peter Krempa posted 15 patches 2 weeks ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/cover.1580975374.git.pkrempa@redhat.com
docs/formatdomain.html.in                     |  12 ++
docs/schemas/domaincommon.rng                 |  33 ++++
src/conf/domain_conf.c                        |  92 +++++++++++
src/qemu/qemu_block.c                         |  12 +-
src/qemu/qemu_domain.c                        |  15 ++
src/util/virstoragefile.c                     | 156 +++++++++++++-----
src/util/virstoragefile.h                     |  12 ++
.../disk-slices.x86_64-latest.args            |  50 ++++++
tests/qemuxml2argvdata/disk-slices.xml        |  45 +++++
tests/qemuxml2argvtest.c                      |   2 +
.../disk-slices.x86_64-latest.xml             |  56 +++++++
tests/qemuxml2xmltest.c                       |   2 +
tests/virstoragetest.c                        |  23 +++
13 files changed, 462 insertions(+), 48 deletions(-)
create mode 100644 tests/qemuxml2argvdata/disk-slices.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/disk-slices.xml
create mode 100644 tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml

[PATCH 00/15] qemu: Handle 'size' and 'offset' attributes of 'raw' format

Posted by Peter Krempa 2 weeks ago
This series fixes and improves the 'json:' pseudo-protocol parser and
implements the 'offset' and 'size' attributes and exposes them as
<slice> in the XML.

https://bugzilla.redhat.com/show_bug.cgi?id=1791788

Peter Krempa (15):
  virStorageSourceParseBackingJSON: Pass around original backing file
    string
  virStorageSourceParseBackingJSON: Move deflattening of json: URIs out
    of recursion
  virStorageSourceJSONDriverParser: annotate 'format' drivers
  virStorageSourceParseBackingJSON: Allow 'json:' pseudo URIs without
    'file' wrapper
  virStorageSourceParseBackingJSON: Prevent arbitrary nesting with
    format drivers
  tests: virstorage: Add test cases for "json:" pseudo-URI without
    'file' wrapper
  tests: virstorage: Add test data for json specified raw image with
    offset/size
  util: virstoragefile: Add data structure for storing storage source
    slices
  qemuBlockStorageSourceGetFormatRawProps: format 'offset' and 'size'
    for slice
  qemuDomainValidateStorageSource: Reject unsupported slices
  docs: formatdomain: Close <source> on one of disk examples
  docs: Document the new <slices> sub-element of disk's <source>
  conf: Implement support for <slices> of disk source
  tests: qemu: Add test data for the new <slice> element
  virStorageSourceParseBackingJSONRaw: Parse 'offset' and 'size'
    attributes

 docs/formatdomain.html.in                     |  12 ++
 docs/schemas/domaincommon.rng                 |  33 ++++
 src/conf/domain_conf.c                        |  92 +++++++++++
 src/qemu/qemu_block.c                         |  12 +-
 src/qemu/qemu_domain.c                        |  15 ++
 src/util/virstoragefile.c                     | 156 +++++++++++++-----
 src/util/virstoragefile.h                     |  12 ++
 .../disk-slices.x86_64-latest.args            |  50 ++++++
 tests/qemuxml2argvdata/disk-slices.xml        |  45 +++++
 tests/qemuxml2argvtest.c                      |   2 +
 .../disk-slices.x86_64-latest.xml             |  56 +++++++
 tests/qemuxml2xmltest.c                       |   2 +
 tests/virstoragetest.c                        |  23 +++
 13 files changed, 462 insertions(+), 48 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/disk-slices.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/disk-slices.xml
 create mode 100644 tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml

-- 
2.24.1

Re: [PATCH 00/15] qemu: Handle 'size' and 'offset' attributes of 'raw' format

Posted by Richard W.M. Jones 2 weeks ago
On Thu, Feb 06, 2020 at 08:51:52AM +0100, Peter Krempa wrote:
> This series fixes and improves the 'json:' pseudo-protocol parser and
> implements the 'offset' and 'size' attributes and exposes them as
> <slice> in the XML.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1791788
> 
> Peter Krempa (15):
>   virStorageSourceParseBackingJSON: Pass around original backing file
>     string
>   virStorageSourceParseBackingJSON: Move deflattening of json: URIs out
>     of recursion
>   virStorageSourceJSONDriverParser: annotate 'format' drivers
>   virStorageSourceParseBackingJSON: Allow 'json:' pseudo URIs without
>     'file' wrapper
>   virStorageSourceParseBackingJSON: Prevent arbitrary nesting with
>     format drivers
>   tests: virstorage: Add test cases for "json:" pseudo-URI without
>     'file' wrapper
>   tests: virstorage: Add test data for json specified raw image with
>     offset/size
>   util: virstoragefile: Add data structure for storing storage source
>     slices
>   qemuBlockStorageSourceGetFormatRawProps: format 'offset' and 'size'
>     for slice
>   qemuDomainValidateStorageSource: Reject unsupported slices
>   docs: formatdomain: Close <source> on one of disk examples
>   docs: Document the new <slices> sub-element of disk's <source>
>   conf: Implement support for <slices> of disk source
>   tests: qemu: Add test data for the new <slice> element
>   virStorageSourceParseBackingJSONRaw: Parse 'offset' and 'size'
>     attributes

So with this patch, virt-v2v -i ova now fails with:

  Original error from libvirt: unsupported configuration: format slice
  is not supported for format 'vmdk' [code=67 int1=-1]

The overlay was created (by virt-v2v) with:

$ qemu-img create -q -f qcow2 -b 'json:{ "file": { "driver": "raw", "offset": 512, "size": 349405696, "file": { "driver": "file", "filename": "/var/tmp/First.ova" } } }' -o 'compat=1.1,backing_fmt=vmdk' /tmp/v2vovl.qcow2

A simple test case to use is:

$ wget http://oirase.annexia.org/tmp/First.ova
$ virt-v2v -i ova First.ova -o null -v -x

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top