2013-11-20 04:14:54 +08:00
|
|
|
<volume type='file'>
|
2009-01-27 23:29:53 +08:00
|
|
|
<name>OtherDemo.img</name>
|
storage: use valid XML for awkward volume names
$ touch /var/lib/libvirt/images/'a<b>c'
$ virsh pool-refresh default
$ virsh vol-dumpxml 'a<b>c' default | head -n2
<volume>
<name>a<b>c</name>
Oops. That's not valid XML. And when we fix the XML
generation, it fails RelaxNG validation.
I'm also tired of seeing <key>(null)</key> in the example
output for volume xml; while we used NULLSTR() to avoid
a NULL deref rather than relying on glibc's printf
extension behavior, it's even better if we avoid the issue
in the first place. But this requires being careful that
we don't invalidate any storage backends that were relying
on key being unassigned during virStoragVolCreateXML[From].
I would have split this into two patches (one for escaping,
one for avoiding <key>(null)</key>), but since they both
end up touching a lot of the same test files, I ended up
merging it into one.
Note that this patch allows pretty much any volume name
that can appear in a directory (excluding . and .. because
those are special), but does nothing to change the current
(unenforced) RelaxNG claim that pool names will consist
only of letters, numbers, _, -, and +. Tightening the C
code to match RelaxNG patterns and/or relaxing the grammar
to match the C code for pool names is a task for another
day (but remember, we DID recently tighten C code for
domain names to exclude a leading '.').
* src/conf/storage_conf.c (virStoragePoolSourceFormat)
(virStoragePoolDefFormat, virStorageVolTargetDefFormat)
(virStorageVolDefFormat): Escape user-controlled strings.
(virStorageVolDefParseXML): Parse key, for use in unit tests.
* src/storage/storage_driver.c (storageVolCreateXML)
(storageVolCreateXMLFrom): Ensure parsed key doesn't confuse
volume creation.
* docs/schemas/basictypes.rng (volName): Relax definition.
* tests/storagepoolxml2xmltest.c (mymain): Test it.
* tests/storagevolxml2xmltest.c (mymain): Likewise.
* tests/storagepoolxml2xmlin/pool-dir-naming.xml: New file.
* tests/storagepoolxml2xmlout/pool-dir-naming.xml: Likewise.
* tests/storagevolxml2xmlin/vol-file-naming.xml: Likewise.
* tests/storagevolxml2xmlout/vol-file-naming.xml: Likewise.
* tests/storagevolxml2xmlout/vol-*.xml: Fix fallout.
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-11-21 08:04:05 +08:00
|
|
|
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
2009-01-27 23:29:53 +08:00
|
|
|
<source>
|
|
|
|
</source>
|
2012-02-23 08:48:38 +08:00
|
|
|
<capacity unit='bytes'>5368709120</capacity>
|
|
|
|
<allocation unit='bytes'>294912</allocation>
|
2009-01-27 23:29:53 +08:00
|
|
|
<target>
|
|
|
|
<path>/var/lib/libvirt/images/OtherDemo.img</path>
|
|
|
|
<format type='qcow2'/>
|
|
|
|
<permissions>
|
2009-10-10 02:17:21 +08:00
|
|
|
<mode>0644</mode>
|
2009-01-27 23:29:53 +08:00
|
|
|
<owner>0</owner>
|
|
|
|
<group>0</group>
|
|
|
|
<label>unconfined_u:object_r:virt_image_t:s0</label>
|
|
|
|
</permissions>
|
2009-07-21 06:28:11 +08:00
|
|
|
<encryption format='qcow'>
|
|
|
|
<secret type='passphrase' uuid='e78d4b51-a2af-485f-b0f5-afca709a80f4'/>
|
|
|
|
</encryption>
|
2009-01-27 23:29:53 +08:00
|
|
|
</target>
|
|
|
|
<backingStore>
|
2013-07-22 21:44:06 +08:00
|
|
|
<path>/dev/null</path>
|
2009-01-27 23:29:53 +08:00
|
|
|
<format type='raw'/>
|
|
|
|
<permissions>
|
2009-10-10 02:17:21 +08:00
|
|
|
<mode>0644</mode>
|
2009-01-27 23:29:53 +08:00
|
|
|
<owner>0</owner>
|
|
|
|
<group>0</group>
|
|
|
|
<label>unconfined_u:object_r:virt_image_t:s0</label>
|
|
|
|
</permissions>
|
|
|
|
</backingStore>
|
|
|
|
</volume>
|