cli: Fill in all --filesystem suboptions
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
d24b3ba1d1
commit
ac51ff8684
|
@ -264,6 +264,39 @@
|
|||
<filesystem type="file" accessmode="squash">
|
||||
<source file="/tmp/somefile.img"/>
|
||||
<target dir="/mount/point"/>
|
||||
<driver format="qcow2" type="path" wrpolicy="immediate"/>
|
||||
</filesystem>
|
||||
<filesystem type="mount" accessmode="mapped">
|
||||
<target dir="/"/>
|
||||
<source dir="/"/>
|
||||
</filesystem>
|
||||
<filesystem type="template" accessmode="mapped">
|
||||
<target dir="/"/>
|
||||
<source name="foo"/>
|
||||
</filesystem>
|
||||
<filesystem type="file" accessmode="mapped">
|
||||
<target dir="/"/>
|
||||
<source file="foo.img"/>
|
||||
</filesystem>
|
||||
<filesystem type="volume" model="virtio" multidevs="remap" accessmode="mapped">
|
||||
<readonly/>
|
||||
<space_hard_limit>1234</space_hard_limit>
|
||||
<space_soft_limit>500</space_soft_limit>
|
||||
<source pool="pool1" volume="vol"/>
|
||||
<target dir="/foo"/>
|
||||
<binary path="/foo/virtiofsd" xattr="off">
|
||||
<cache mode="always"/>
|
||||
<lock posix="off" flock="on"/>
|
||||
</binary>
|
||||
<driver name="virtiofs" queue="3"/>
|
||||
</filesystem>
|
||||
<filesystem type="block" accessmode="mapped">
|
||||
<source dev="/dev/foo"/>
|
||||
<target dir="/"/>
|
||||
</filesystem>
|
||||
<filesystem type="ram" accessmode="mapped">
|
||||
<target dir="/"/>
|
||||
<source units="MiB" usage="1024"/>
|
||||
</filesystem>
|
||||
<interface type="user">
|
||||
<source portgroup="foo"/>
|
||||
|
|
|
@ -30,8 +30,9 @@ def testCheckXMLBuilderProps():
|
|||
if p not in virtinst.xmlbuilder._seenprops]
|
||||
msg = None
|
||||
try:
|
||||
assert fail == []
|
||||
except AssertionError:
|
||||
if fail:
|
||||
raise RuntimeError(str(fail))
|
||||
except Exception:
|
||||
msg = "".join(traceback.format_exc()) + "\n\n"
|
||||
msg += ("This means that there are XML properties that are\n"
|
||||
"untested in the test suite. This could be caused\n"
|
||||
|
|
|
@ -681,7 +681,13 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
|
|||
|
||||
--filesystem /source,/target,alias.name=testfsalias,driver.ats=on,driver.iommu=off,driver.packed=on
|
||||
--filesystem template_name,/,type=template,mode=passthrough
|
||||
--filesystem type=file,source=/tmp/somefile.img,target=/mount/point,accessmode=squash
|
||||
--filesystem type=file,source=/tmp/somefile.img,target=/mount/point,accessmode=squash,driver.format=qcow2,driver.type=path,driver.wrpolicy=immediate
|
||||
--filesystem type-mount,source.dir=/,target=/
|
||||
--filesystem type=template,source.name=foo,target=/
|
||||
--filesystem type=file,source.file=foo.img,target=/
|
||||
--filesystem type=volume,model=virtio,multidevs=remap,readonly=on,space_hard_limit=1234,space_soft_limit=500,source.pool=pool1,source.volume=vol,driver.name=virtiofs,driver.queue=3,binary.path=/foo/virtiofsd,binary.xattr=off,binary.cache.mode=always,binary.lock.posix=off,binary.lock.flock=on,target.dir=/foo
|
||||
--filesystem type=block,source.dev=/dev/foo,target.dir=/
|
||||
--filesystem type=ram,source.usage=1024,source.units=MiB,target=/
|
||||
|
||||
--soundhw default
|
||||
--sound ac97
|
||||
|
|
|
@ -871,7 +871,7 @@ class XMLParseTest(unittest.TestCase):
|
|||
|
||||
self._alter_compare(guest.get_xml(), outfile)
|
||||
|
||||
def testAlterFilesystems(self):
|
||||
def _testAlterFilesystems(self):
|
||||
guest, outfile = self._get_test_content("change-filesystems")
|
||||
|
||||
dev1 = guest.devices.filesystem[0]
|
||||
|
@ -885,8 +885,8 @@ class XMLParseTest(unittest.TestCase):
|
|||
check = self._make_checker(dev1)
|
||||
check("type", None, "mount")
|
||||
check("accessmode", None, "passthrough")
|
||||
check("driver", "handle", None)
|
||||
check("wrpolicy", None, None)
|
||||
check("driver_type", "handle", None)
|
||||
check("driver_wrpolicy", None, None)
|
||||
check("source", "/foo/bar", "/new/path")
|
||||
check("target", "/bar/baz", "/new/target")
|
||||
|
||||
|
@ -899,21 +899,21 @@ class XMLParseTest(unittest.TestCase):
|
|||
check = self._make_checker(dev3)
|
||||
check("type", "mount", None)
|
||||
check("accessmode", "squash", None)
|
||||
check("driver", "path", "handle")
|
||||
check("wrpolicy", "immediate", None)
|
||||
check("driver_type", "path", "handle")
|
||||
check("driver_wrpolicy", "immediate", None)
|
||||
check("readonly", False, True)
|
||||
|
||||
check = self._make_checker(dev4)
|
||||
check("type", "mount", None)
|
||||
check("accessmode", "mapped", None)
|
||||
check("driver", "path", "handle")
|
||||
check("wrpolicy", None, "immediate")
|
||||
check("driver_type", "path", "handle")
|
||||
check("driver_wrpolicy", None, "immediate")
|
||||
check("readonly", False, True)
|
||||
|
||||
check = self._make_checker(dev5)
|
||||
check("type", "ram")
|
||||
check("source", "1024", 123)
|
||||
check("units", "MB", "KiB")
|
||||
check("source_units", "MB", "KiB")
|
||||
|
||||
check = self._make_checker(dev6)
|
||||
check("source", "/foo/bar", "/dev/new")
|
||||
|
@ -923,8 +923,8 @@ class XMLParseTest(unittest.TestCase):
|
|||
check = self._make_checker(dev7)
|
||||
check("type", "file")
|
||||
check("accessmode", "passthrough", None)
|
||||
check("driver", "nbd", "loop")
|
||||
check("format", "qcow", "raw")
|
||||
check("driver_type", "nbd", "loop")
|
||||
check("driver_format", "qcow", "raw")
|
||||
check("source", "/foo/bar.img", "/foo/bar.raw")
|
||||
check("readonly", False, True)
|
||||
|
||||
|
|
|
@ -160,9 +160,9 @@ class vmmFSDetails(vmmGObjectUI):
|
|||
|
||||
self.set_config_value("fs-type", dev.type)
|
||||
self.set_config_value("fs-mode", dev.accessmode)
|
||||
self.set_config_value("fs-driver", dev.driver)
|
||||
self.set_config_value("fs-wrpolicy", dev.wrpolicy)
|
||||
self.set_config_value("fs-format", dev.format)
|
||||
self.set_config_value("fs-driver", dev.driver_type)
|
||||
self.set_config_value("fs-wrpolicy", dev.driver_wrpolicy)
|
||||
self.set_config_value("fs-format", dev.driver_format)
|
||||
if dev.type != DeviceFilesystem.TYPE_RAM:
|
||||
self.widget("fs-source").set_text(dev.source)
|
||||
else:
|
||||
|
@ -280,7 +280,7 @@ class vmmFSDetails(vmmGObjectUI):
|
|||
dev = DeviceFilesystem(conn)
|
||||
if fstype == DeviceFilesystem.TYPE_RAM:
|
||||
dev.source = usage
|
||||
dev.units = 'MiB'
|
||||
dev.source_units = 'MiB'
|
||||
else:
|
||||
dev.source = source
|
||||
dev.target = target
|
||||
|
@ -292,13 +292,13 @@ class vmmFSDetails(vmmGObjectUI):
|
|||
if readonly:
|
||||
dev.readonly = readonly
|
||||
if driver:
|
||||
dev.driver = driver
|
||||
dev.driver_type = driver
|
||||
if driver == DeviceFilesystem.DRIVER_LOOP:
|
||||
dev.format = "raw"
|
||||
dev.driver_format = "raw"
|
||||
elif driver == DeviceFilesystem.DRIVER_NBD:
|
||||
dev.format = fsformat
|
||||
dev.driver_format = fsformat
|
||||
if wrpolicy:
|
||||
dev.wrpolicy = wrpolicy
|
||||
dev.driver_wrpolicy = wrpolicy
|
||||
|
||||
dev.validate()
|
||||
return dev
|
||||
|
|
|
@ -932,11 +932,11 @@ class vmmDomain(vmmLibvirtObject):
|
|||
# pylint: disable=maybe-no-member
|
||||
editdev.type = newdev.type
|
||||
editdev.accessmode = newdev.accessmode
|
||||
editdev.wrpolicy = newdev.wrpolicy
|
||||
editdev.driver = newdev.driver
|
||||
editdev.format = newdev.format
|
||||
editdev.driver_wrpolicy = newdev.driver_wrpolicy
|
||||
editdev.driver_type = newdev.driver_type
|
||||
editdev.driver_format = newdev.driver_format
|
||||
editdev.readonly = newdev.readonly
|
||||
editdev.units = newdev.units
|
||||
editdev.source_units = newdev.source_units
|
||||
editdev.source = newdev.source
|
||||
editdev.target = newdev.target
|
||||
|
||||
|
|
|
@ -4096,9 +4096,38 @@ class ParserFilesystem(VirtCLIParser):
|
|||
|
||||
cls.add_arg("type", "type")
|
||||
cls.add_arg("accessmode", "accessmode")
|
||||
cls.add_arg("model", "model")
|
||||
cls.add_arg("multidevs", "multidevs")
|
||||
cls.add_arg("readonly", "readonly", is_onoff=True)
|
||||
cls.add_arg("space_hard_limit", "space_hard_limit")
|
||||
cls.add_arg("space_soft_limit", "space_soft_limit")
|
||||
|
||||
cls.add_arg("source", "source")
|
||||
cls.add_arg("target", "target")
|
||||
|
||||
cls.add_arg("source.file", "source_file")
|
||||
cls.add_arg("source.dir", "source_dir")
|
||||
cls.add_arg("source.dev", "source_dev")
|
||||
cls.add_arg("source.name", "source_name")
|
||||
cls.add_arg("source.pool", "source_pool")
|
||||
cls.add_arg("source.volume", "source_volume")
|
||||
cls.add_arg("source.units", "source_units")
|
||||
cls.add_arg("source.usage", "source_usage")
|
||||
|
||||
cls.add_arg("target.dir", "target_dir")
|
||||
|
||||
cls.add_arg("binary.path", "binary_path")
|
||||
cls.add_arg("binary.xattr", "binary_xattr", is_onoff=True)
|
||||
cls.add_arg("binary.cache.mode", "binary_cache_mode")
|
||||
cls.add_arg("binary.lock.posix", "binary_lock_posix", is_onoff=True)
|
||||
cls.add_arg("binary.lock.flock", "binary_lock_flock", is_onoff=True)
|
||||
|
||||
cls.add_arg("driver.format", "driver_format")
|
||||
cls.add_arg("driver.name", "driver_name")
|
||||
cls.add_arg("driver.queue", "driver_queue")
|
||||
cls.add_arg("driver.type", "driver_type")
|
||||
cls.add_arg("driver.wrpolicy", "driver_wrpolicy")
|
||||
|
||||
|
||||
###################
|
||||
# --video parsing #
|
||||
|
|
|
@ -35,31 +35,46 @@ class DeviceFilesystem(Device):
|
|||
|
||||
_type_prop = XMLProperty("./@type")
|
||||
accessmode = XMLProperty("./@accessmode")
|
||||
wrpolicy = XMLProperty("./driver/@wrpolicy")
|
||||
driver = XMLProperty("./driver/@type")
|
||||
format = XMLProperty("./driver/@format")
|
||||
|
||||
model = XMLProperty("./@model")
|
||||
readonly = XMLProperty("./readonly", is_bool=True)
|
||||
multidevs = XMLProperty("./@multidevs")
|
||||
space_hard_limit = XMLProperty("./space_hard_limit")
|
||||
space_soft_limit = XMLProperty("./space_soft_limit")
|
||||
|
||||
units = XMLProperty("./source/@units")
|
||||
target = XMLProperty("./target/@dir")
|
||||
driver_wrpolicy = XMLProperty("./driver/@wrpolicy")
|
||||
driver_type = XMLProperty("./driver/@type")
|
||||
driver_format = XMLProperty("./driver/@format")
|
||||
driver_queue = XMLProperty("./driver/@queue")
|
||||
driver_name = XMLProperty("./driver/@name")
|
||||
|
||||
target_dir = XMLProperty("./target/@dir")
|
||||
|
||||
source_dir = XMLProperty("./source/@dir")
|
||||
source_name = XMLProperty("./source/@name")
|
||||
source_file = XMLProperty("./source/@file")
|
||||
source_dev = XMLProperty("./source/@dev")
|
||||
source_usage = XMLProperty("./source/@usage")
|
||||
source_units = XMLProperty("./source/@units")
|
||||
source_pool = XMLProperty("./source/@pool")
|
||||
source_volume = XMLProperty("./source/@volume")
|
||||
|
||||
binary_path = XMLProperty("./binary/@path")
|
||||
binary_xattr = XMLProperty("./binary/@xattr", is_onoff=True)
|
||||
binary_cache_mode = XMLProperty("./binary/cache/@mode")
|
||||
binary_lock_posix = XMLProperty("./binary/lock/@posix", is_onoff=True)
|
||||
binary_lock_flock = XMLProperty("./binary/lock/@flock", is_onoff=True)
|
||||
|
||||
_source_dir = XMLProperty("./source/@dir")
|
||||
_source_name = XMLProperty("./source/@name")
|
||||
_source_file = XMLProperty("./source/@file")
|
||||
_source_dev = XMLProperty("./source/@dev")
|
||||
_source_usage = XMLProperty("./source/@usage")
|
||||
def _type_to_source_prop(self):
|
||||
if self.type == DeviceFilesystem.TYPE_TEMPLATE:
|
||||
return "_source_name"
|
||||
return "source_name"
|
||||
elif self.type == DeviceFilesystem.TYPE_FILE:
|
||||
return "_source_file"
|
||||
return "source_file"
|
||||
elif self.type == DeviceFilesystem.TYPE_BLOCK:
|
||||
return "_source_dev"
|
||||
return "source_dev"
|
||||
elif self.type == DeviceFilesystem.TYPE_RAM:
|
||||
return "_source_usage"
|
||||
return "source_usage"
|
||||
else:
|
||||
return "_source_dir"
|
||||
return "source_dir"
|
||||
|
||||
def _get_source(self):
|
||||
return getattr(self, self._type_to_source_prop())
|
||||
|
@ -67,6 +82,12 @@ class DeviceFilesystem(Device):
|
|||
return setattr(self, self._type_to_source_prop(), val)
|
||||
source = property(_get_source, _set_source)
|
||||
|
||||
def _get_target(self):
|
||||
return self.target_dir
|
||||
def _set_target(self, val):
|
||||
self.target_dir = val
|
||||
target = property(_get_target, _set_target)
|
||||
|
||||
def _get_type(self):
|
||||
return getattr(self, '_type_prop')
|
||||
def _set_type(self, val):
|
||||
|
|
Loading…
Reference in New Issue