[PATCH 12/15] docs: Document the new <slices> sub-element of disk's <source>

Peter Krempa posted 15 patches 6 years ago
There is a newer version of this series
[PATCH 12/15] docs: Document the new <slices> sub-element of disk's <source>
Posted by Peter Krempa 6 years ago
We are going to add support for specifying offset and size attributes
which will allow controling where the image and where the guest data
itself starts in the source of the disk. This will be represented by
a <slices> element filled with either a <slice type='storage'> for the
offset of the image format itself. <slice type='format'> then controls
where the guest data starts in the image.

Add the XML documentation and RNG schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 docs/formatdomain.html.in     | 11 +++++++++++
 docs/schemas/domaincommon.rng | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index acb604e9c7..2143e57b11 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2878,6 +2878,9 @@
   &lt;disk type='block' device='lun'&gt;
     &lt;driver name='qemu' type='raw'/&gt;
     &lt;source dev='/dev/sda'&gt;
+      &lt;slices&gt;
+        &lt;slice type='format' offset='12345' size='123'/&gt;
+      &lt;/slices&gt;
       &lt;reservations managed='no'&gt;
         &lt;source type='unix' path='/path/to/qemu-pr-helper' mode='client'/&gt;
       &lt;/reservations&gt;
@@ -3360,6 +3363,14 @@
             controller.
             <span class="since">Since 6.0.0</span>
           </dd>
+          <dt><code>slices</code></dt>
+          <dd>The <code>slices</code> element using its <code>slice</code>
+            sub-elements allows configuring offset and size of either the
+            location of the image format (<code>slice type='storage'</code>) or
+            the guest data in the image container (<code>slice type='format'</code>).
+
+            The <code>offset</code> and <code>size</code> values are in bytes.
+          </dd>
         </dl>

         <p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index ea237a05e5..720e4e3da7 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1595,12 +1595,45 @@
     </optional>
   </define>

+  <define name="diskSourceSlice">
+    <attribute name='offset'>
+      <ref name="positiveInteger"/>
+    </attribute>
+    <attribute name='size'>
+      <ref name="positiveInteger"/>
+    </attribute>
+  </define>
+
   <define name="diskSourceCommon">
     <optional>
       <attribute name="index">
         <ref name="positiveInteger"/>
       </attribute>
     </optional>
+    <optional>
+      <element name='slices'>
+        <oneOrMore>
+          <choice>
+            <group>
+              <element name='slice'>
+                <attribute name='type'>
+                  <value>storage</value>
+                </attribute>
+                <ref name="diskSourceSlice"/>
+              </element>
+            </group>
+            <group>
+              <element name='slice'>
+                <attribute name='type'>
+                  <value>format</value>
+                </attribute>
+                <ref name="diskSourceSlice"/>
+              </element>
+            </group>
+          </choice>
+        </oneOrMore>
+      </element>
+    </optional>
   </define>

   <define name="diskSource">
-- 
2.24.1

Re: [PATCH 12/15] docs: Document the new <slices> sub-element of disk's <source>
Posted by Ján Tomko 6 years ago
On Thu, Feb 06, 2020 at 08:52:04AM +0100, Peter Krempa wrote:
>We are going to add support for specifying offset and size attributes
>which will allow controling where the image and where the guest data
>itself starts in the source of the disk. This will be represented by
>a <slices> element filled with either a <slice type='storage'> for the
>offset of the image format itself. <slice type='format'> then controls
>where the guest data starts in the image.
>
>Add the XML documentation and RNG schema.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> docs/formatdomain.html.in     | 11 +++++++++++
> docs/schemas/domaincommon.rng | 33 +++++++++++++++++++++++++++++++++
> 2 files changed, 44 insertions(+)
>
>diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
>index acb604e9c7..2143e57b11 100644
>--- a/docs/formatdomain.html.in
>+++ b/docs/formatdomain.html.in
>@@ -2878,6 +2878,9 @@
>   &lt;disk type='block' device='lun'&gt;
>     &lt;driver name='qemu' type='raw'/&gt;
>     &lt;source dev='/dev/sda'&gt;
>+      &lt;slices&gt;
>+        &lt;slice type='format' offset='12345' size='123'/&gt;
>+      &lt;/slices&gt;
>       &lt;reservations managed='no'&gt;
>         &lt;source type='unix' path='/path/to/qemu-pr-helper' mode='client'/&gt;
>       &lt;/reservations&gt;
>@@ -3360,6 +3363,14 @@
>             controller.
>             <span class="since">Since 6.0.0</span>
>           </dd>
>+          <dt><code>slices</code></dt>
>+          <dd>The <code>slices</code> element using its <code>slice</code>
>+            sub-elements allows configuring offset and size of either the
>+            location of the image format (<code>slice type='storage'</code>) or
>+            the guest data in the image container (<code>slice type='format'</code>).
>+
>+            The <code>offset</code> and <code>size</code> values are in bytes.

(<span class="since">Since 6.1.0</span>)

>+          </dd>
>         </dl>
>
>         <p>

>diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
>index ea237a05e5..720e4e3da7 100644
>--- a/docs/schemas/domaincommon.rng
>+++ b/docs/schemas/domaincommon.rng

[...]

>+            <group>
>+              <element name='slice'>
>+                <attribute name='type'>
>+                  <value>storage</value>
>+                </attribute>
>+                <ref name="diskSourceSlice"/>
>+              </element>
>+            </group>
>+            <group>
>+              <element name='slice'>
>+                <attribute name='type'>
>+                  <value>format</value>
>+                </attribute>
>+                <ref name="diskSourceSlice"/>

Not sure why you use groups if the only choice is between
the values of the type attribute.

>+              </element>
>+            </group>
>+          </choice>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
Re: [PATCH 12/15] docs: Document the new <slices> sub-element of disk's <source>
Posted by Peter Krempa 6 years ago
On Thu, Feb 06, 2020 at 16:49:05 +0100, Ján Tomko wrote:
> On Thu, Feb 06, 2020 at 08:52:04AM +0100, Peter Krempa wrote:

[...]

> > +            <group>
> > +              <element name='slice'>
> > +                <attribute name='type'>
> > +                  <value>storage</value>
> > +                </attribute>
> > +                <ref name="diskSourceSlice"/>
> > +              </element>
> > +            </group>
> > +            <group>
> > +              <element name='slice'>
> > +                <attribute name='type'>
> > +                  <value>format</value>
> > +                </attribute>
> > +                <ref name="diskSourceSlice"/>
> 
> Not sure why you use groups if the only choice is between
> the values of the type attribute.

What I really wanted to express is that I wanted to allow only 0 or 1
slice with type storage and 0 or 1 slice of type format in any order,
but my RNG-fu was not strong enough. I forgot to optimize it after the
attempts. :(

Any ideas how to achieve the above? Otherwise I'll optimize it.

Re: [PATCH 12/15] docs: Document the new <slices> sub-element of disk's <source>
Posted by Ján Tomko 6 years ago
On Thu, Feb 06, 2020 at 04:55:33PM +0100, Peter Krempa wrote:
>On Thu, Feb 06, 2020 at 16:49:05 +0100, Ján Tomko wrote:
>> On Thu, Feb 06, 2020 at 08:52:04AM +0100, Peter Krempa wrote:
>
>[...]
>
>> > +            <group>
>> > +              <element name='slice'>
>> > +                <attribute name='type'>
>> > +                  <value>storage</value>
>> > +                </attribute>
>> > +                <ref name="diskSourceSlice"/>
>> > +              </element>
>> > +            </group>
>> > +            <group>
>> > +              <element name='slice'>
>> > +                <attribute name='type'>
>> > +                  <value>format</value>
>> > +                </attribute>
>> > +                <ref name="diskSourceSlice"/>
>>
>> Not sure why you use groups if the only choice is between
>> the values of the type attribute.
>
>What I really wanted to express is that I wanted to allow only 0 or 1
>slice with type storage and 0 or 1 slice of type format in any order,
>but my RNG-fu was not strong enough. I forgot to optimize it after the
>attempts. :(
>
>Any ideas how to achieve the above? Otherwise I'll optimize it.

<interleave>
   <optional>
     <!-- storageSlice -->
   </optional>
   <optional>
     <!-- formatSlice -->
   </optional>
</interleave>

was my first thought, but the interleave element does not seem happy
with two slice elements.

My other idea is to enumerate all the options, which is just not worth
it IMO.

Jano