storage: Parse volume backingstore

This commit is contained in:
Cole Robinson 2013-09-28 19:11:27 -04:00
parent 7664e5762d
commit bc34df1dc7
6 changed files with 69 additions and 6 deletions

View File

@ -115,8 +115,8 @@
<source file='/tmp/foobar2'/>
<target dev='vdc' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<source file='/tmp/foobar3'/>
<disk type='block' device='disk'>
<source dev='/dev/default-pool/overlay.img'/>
<target dev='sdd' bus='usb'/>
</disk>
<disk type='file' device='disk'>
@ -864,6 +864,25 @@ test-many-devices, like an alternate RNG.
<allocation>50000</allocation>
<target/>
</volume>
<volume>
<name>backing.img</name>
<capacity>1000000</capacity>
<allocation>50000</allocation>
<target>
<format type='raw'/>
</target>
</volume>
<volume>
<name>overlay.img</name>
<capacity>1000000</capacity>
<allocation>50000</allocation>
<target>
<format type='qcow2'/>
</target>
<backingStore>
<path>/dev/default-pool/backing.img</path>
</backingStore>
</volume>
</pool>

View File

@ -0,0 +1,28 @@
<volume>
<name>pool-dir-vol</name>
<capacity>10737418240</capacity>
<allocation>5368709120</allocation>
<target>
<format type="raw"/>
<permissions>
<mode>0700</mode>
<owner>10736</owner>
<group>10736</group>
</permissions>
</target>
<backingStore>
<path>/foo/bar/baz</path>
<format type='qcow2'/>
<permissions>
<mode>0644</mode>
<owner>107</owner>
<group>107</group>
<label>system_u:object_r:virt_content_t:s0</label>
</permissions>
<timestamps>
<atime>1380391173.646500267</atime>
<mtime>1361141691.649777468</mtime>
<ctime>1380037213.225753249</ctime>
</timestamps>
</backingStore>
</volume>

View File

@ -12,4 +12,19 @@
</permissions>
<path>/foo/bar</path>
</target>
<backingStore>
<path>/my/backing</path>
<format type="qcow2"/>
<permissions>
<mode>0644</mode>
<owner>107</owner>
<group>107</group>
<label>system_u:object_r:virt_content_t:s0</label>
</permissions>
<timestamps>
<atime>1380391173.646500267</atime>
<mtime>1361141691.649777468</mtime>
<ctime>1380037213.225753249</ctime>
</timestamps>
</backingStore>
</volume>

View File

@ -971,7 +971,7 @@ class XMLParseTest(unittest.TestCase):
def testVol(self):
basename = "pool-dir-vol"
infile = "tests/storage-xml/%s.xml" % basename
infile = "tests/xmlparse-xml/%s-in.xml" % basename
outfile = "tests/xmlparse-xml/%s-out.xml" % basename
vol = virtinst.StorageVolume(conn, parsexml=file(infile).read())
@ -980,6 +980,7 @@ class XMLParseTest(unittest.TestCase):
check("allocation", 5368709120, 1000)
check("format", "raw", "qcow2")
check("target_path", None, "/foo/bar")
check("backing_store", "/foo/bar/baz", "/my/backing")
check = self._make_checker(vol.permissions)
check("mode", "0700", "0744")

View File

@ -332,9 +332,8 @@ class VirtualDisk(VirtualDevice):
@param conn: virConnect to check VMs
@param path: Path to check for
@param check_conflict: Only return names that are truly conflicting:
this will omit guests that are using the disk
with the 'shareable' flag, and possible other
heuristics
this will omit guests that are using the disk with the
'shareable' flag, and possible other heuristics
"""
if not path:
return

View File

@ -639,6 +639,7 @@ class StorageVolume(_StorageObject):
validate_cb=_validate_allocation)
format = XMLProperty("./target/format/@type", default_cb=_default_format)
target_path = XMLProperty("./target/path")
backing_store = XMLProperty("./backingStore/path")
######################