storage: conf: Don't output owner/group -1

-1 is just an internal placeholder and is meaningless to output in the XML.
This commit is contained in:
Cole Robinson 2015-05-05 11:58:12 -04:00
parent b903b3b01e
commit c4d27bdddf
8 changed files with 30 additions and 33 deletions

View File

@ -101,18 +101,22 @@
<element name='mode'> <element name='mode'>
<ref name='octalMode'/> <ref name='octalMode'/>
</element> </element>
<element name='owner'> <optional>
<choice> <element name='owner'>
<ref name='unsignedInt'/> <choice>
<value>-1</value> <ref name='unsignedInt'/>
</choice> <value>-1</value>
</element> </choice>
<element name='group'> </element>
<choice> </optional>
<ref name='unsignedInt'/> <optional>
<value>-1</value> <element name='group'>
</choice> <choice>
</element> <ref name='unsignedInt'/>
<value>-1</value>
</choice>
</element>
</optional>
<optional> <optional>
<element name='label'> <element name='label'>
<text/> <text/>

View File

@ -759,6 +759,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
if (virXPathNode("./owner", ctxt) == NULL) { if (virXPathNode("./owner", ctxt) == NULL) {
perms->uid = (uid_t) -1; perms->uid = (uid_t) -1;
} else { } else {
/* We previously could output -1, so continue to parse it */
if (virXPathLongLong("number(./owner)", ctxt, &val) < 0 || if (virXPathLongLong("number(./owner)", ctxt, &val) < 0 ||
((uid_t)val != val && ((uid_t)val != val &&
val != -1)) { val != -1)) {
@ -773,6 +774,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
if (virXPathNode("./group", ctxt) == NULL) { if (virXPathNode("./group", ctxt) == NULL) {
perms->gid = (gid_t) -1; perms->gid = (gid_t) -1;
} else { } else {
/* We previously could output -1, so continue to parse it */
if (virXPathLongLong("number(./group)", ctxt, &val) < 0 || if (virXPathLongLong("number(./group)", ctxt, &val) < 0 ||
((gid_t) val != val && ((gid_t) val != val &&
val != -1)) { val != -1)) {
@ -1187,10 +1189,12 @@ virStoragePoolDefFormatBuf(virBufferPtr buf,
virBufferAdjustIndent(buf, 2); virBufferAdjustIndent(buf, 2);
virBufferAsprintf(buf, "<mode>0%o</mode>\n", virBufferAsprintf(buf, "<mode>0%o</mode>\n",
def->target.perms.mode); def->target.perms.mode);
virBufferAsprintf(buf, "<owner>%d</owner>\n", if (def->target.perms.uid != (uid_t) -1)
(int) def->target.perms.uid); virBufferAsprintf(buf, "<owner>%d</owner>\n",
virBufferAsprintf(buf, "<group>%d</group>\n", (int) def->target.perms.uid);
(int) def->target.perms.gid); if (def->target.perms.gid != (gid_t) -1)
virBufferAsprintf(buf, "<group>%d</group>\n",
(int) def->target.perms.gid);
virBufferEscapeString(buf, "<label>%s</label>\n", virBufferEscapeString(buf, "<label>%s</label>\n",
def->target.perms.label); def->target.perms.label);
@ -1522,11 +1526,12 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
virBufferAsprintf(buf, "<mode>0%o</mode>\n", virBufferAsprintf(buf, "<mode>0%o</mode>\n",
def->perms->mode); def->perms->mode);
virBufferAsprintf(buf, "<owner>%d</owner>\n", if (def->perms->uid != (uid_t) -1)
(int) def->perms->uid); virBufferAsprintf(buf, "<owner>%d</owner>\n",
virBufferAsprintf(buf, "<group>%d</group>\n", (int) def->perms->uid);
(int) def->perms->gid); if (def->perms->gid != (gid_t) -1)
virBufferAsprintf(buf, "<group>%d</group>\n",
(int) def->perms->gid);
virBufferEscapeString(buf, "<label>%s</label>\n", virBufferEscapeString(buf, "<label>%s</label>\n",
def->perms->label); def->perms->label);

View File

@ -10,8 +10,6 @@
<path>/var/lib/libvirt/&lt;images&gt;</path> <path>/var/lib/libvirt/&lt;images&gt;</path>
<permissions> <permissions>
<mode>0700</mode> <mode>0700</mode>
<owner>-1</owner>
<group>-1</group>
<label>some_label_t</label> <label>some_label_t</label>
</permissions> </permissions>
</target> </target>

View File

@ -10,8 +10,6 @@
<path>/var/lib/libvirt/images</path> <path>/var/lib/libvirt/images</path>
<permissions> <permissions>
<mode>0700</mode> <mode>0700</mode>
<owner>-1</owner>
<group>-1</group>
<label>some_label_t</label> <label>some_label_t</label>
</permissions> </permissions>
</target> </target>

View File

@ -13,8 +13,6 @@
<path>/mnt/gluster</path> <path>/mnt/gluster</path>
<permissions> <permissions>
<mode>0755</mode> <mode>0755</mode>
<owner>-1</owner>
<group>-1</group>
</permissions> </permissions>
</target> </target>
</pool> </pool>

View File

@ -10,8 +10,6 @@
<format type='dir'/> <format type='dir'/>
<permissions> <permissions>
<mode>0600</mode> <mode>0600</mode>
<owner>-1</owner>
<group>-1</group>
</permissions> </permissions>
</target> </target>
</volume> </volume>

View File

@ -10,8 +10,6 @@
<format type='dir'/> <format type='dir'/>
<permissions> <permissions>
<mode>0600</mode> <mode>0600</mode>
<owner>-1</owner>
<group>-1</group>
</permissions> </permissions>
</target> </target>
</volume> </volume>

View File

@ -9,8 +9,6 @@
<format type='unknown'/> <format type='unknown'/>
<permissions> <permissions>
<mode>0600</mode> <mode>0600</mode>
<owner>-1</owner>
<group>-1</group>
</permissions> </permissions>
</target> </target>
</volume> </volume>