Volume and pool formatting functions took different approaches to
unspecified uids/gids. When unknown, it is always parsed as -1, but one
of the functions formatted it as unsigned int (wrong) and one as
int (better). Due to that, our two of our XML files from tests cannot
be parsed on 32-bit machines.
RNG schema needs to be modified as well, but because both
storagepool.rng and storagevol.rng need same schema for permission
element, save some space by moving it to storagecommon.rng.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
docs/schemas/storagecommon.rng | 29 +++++++++++++++++++++++++
docs/schemas/storagepool.rng | 30 +-------------------------
docs/schemas/storagevol.rng | 23 --------------------
src/conf/storage_conf.c | 9 ++++----
tests/storagevolxml2xmlout/vol-gluster-dir.xml | 4 ++--
tests/storagevolxml2xmlout/vol-sheepdog.xml | 4 ++--
6 files changed, 38 insertions(+), 61 deletions(-)
diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng
index 06b2f81..629505f 100644
--- a/docs/schemas/storagecommon.rng
+++ b/docs/schemas/storagecommon.rng
@@ -93,4 +93,33 @@
<notAllowed/>
</define>
+ <define name='permissions'>
+ <optional>
+ <element name='permissions'>
+ <interleave>
+ <element name='mode'>
+ <ref name='octalMode'/>
+ </element>
+ <element name='owner'>
+ <choice>
+ <ref name='unsignedInt'/>
+ <value>-1</value>
+ </choice>
+ </element>
+ <element name='group'>
+ <choice>
+ <ref name='unsignedInt'/>
+ <value>-1</value>
+ </choice>
+ </element>
+ <optional>
+ <element name='label'>
+ <text/>
+ </element>
+ </optional>
+ </interleave>
+ </element>
+ </optional>
+ </define>
+
</grammar>
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index 0f05c5c..db6ff49 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -3,6 +3,7 @@
<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<include href='basictypes.rng'/>
+ <include href='storagecommon.rng'/>
<start>
<ref name='pool'/>
</start>
@@ -224,35 +225,6 @@
</interleave>
</define>
- <define name='permissions'>
- <optional>
- <element name='permissions'>
- <interleave>
- <element name='mode'>
- <ref name='octalMode'/>
- </element>
- <element name='owner'>
- <choice>
- <ref name='unsignedInt'/>
- <value>-1</value>
- </choice>
- </element>
- <element name='group'>
- <choice>
- <ref name='unsignedInt'/>
- <value>-1</value>
- </choice>
- </element>
- <optional>
- <element name='label'>
- <text/>
- </element>
- </optional>
- </interleave>
- </element>
- </optional>
- </define>
-
<define name='target'>
<element name='target'>
<interleave>
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 1b2d4cc..7450547 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -59,29 +59,6 @@
</interleave>
</define>
- <define name='permissions'>
- <optional>
- <element name='permissions'>
- <interleave>
- <element name='mode'>
- <ref name='octalMode'/>
- </element>
- <element name='owner'>
- <ref name='unsignedInt'/>
- </element>
- <element name='group'>
- <ref name='unsignedInt'/>
- </element>
- <optional>
- <element name='label'>
- <text/>
- </element>
- </optional>
- </interleave>
- </element>
- </optional>
- </define>
-
<define name='timestamps'>
<optional>
<element name='timestamps'>
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 3987470..e1be064 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1203,7 +1203,6 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
(int) def->target.perms.uid);
virBufferAsprintf(&buf, "<group>%d</group>\n",
(int) def->target.perms.gid);
-
virBufferEscapeString(&buf, "<label>%s</label>\n",
def->target.perms.label);
@@ -1527,10 +1526,10 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
virBufferAsprintf(buf, "<mode>0%o</mode>\n",
def->perms->mode);
- virBufferAsprintf(buf, "<owner>%u</owner>\n",
- (unsigned int) def->perms->uid);
- virBufferAsprintf(buf, "<group>%u</group>\n",
- (unsigned int) def->perms->gid);
+ virBufferAsprintf(buf, "<owner>%d</owner>\n",
+ (int) def->perms->uid);
+ virBufferAsprintf(buf, "<group>%d</group>\n",
+ (int) def->perms->gid);
virBufferEscapeString(buf, "<label>%s</label>\n",
diff --git a/tests/storagevolxml2xmlout/vol-gluster-dir.xml
b/tests/storagevolxml2xmlout/vol-gluster-dir.xml
index f188ceb..538b31d 100644
--- a/tests/storagevolxml2xmlout/vol-gluster-dir.xml
+++ b/tests/storagevolxml2xmlout/vol-gluster-dir.xml
@@ -10,8 +10,8 @@
<format type='dir'/>
<permissions>
<mode>0600</mode>
- <owner>4294967295</owner>
- <group>4294967295</group>
+ <owner>-1</owner>
+ <group>-1</group>
</permissions>
</target>
</volume>
diff --git a/tests/storagevolxml2xmlout/vol-sheepdog.xml
b/tests/storagevolxml2xmlout/vol-sheepdog.xml
index e08e36c..0a1f32c 100644
--- a/tests/storagevolxml2xmlout/vol-sheepdog.xml
+++ b/tests/storagevolxml2xmlout/vol-sheepdog.xml
@@ -9,8 +9,8 @@
<format type='unknown'/>
<permissions>
<mode>0600</mode>
- <owner>4294967295</owner>
- <group>4294967295</group>
+ <owner>-1</owner>
+ <group>-1</group>
</permissions>
</target>
</volume>
--
2.2.0