cli: introduce snapshot_policy parameter for disk device

This allows to configure snapshot behavior for each disk.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1430642

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2017-09-06 09:13:44 +02:00
parent 04e35b2d85
commit af91d51fc8
4 changed files with 10 additions and 1 deletions

View File

@ -722,6 +722,12 @@ WD-WMAP9A966149
It defines what to do with the disk if the source file is not accessible. See
possible values in L<http://www.libvirt.org/formatdomain.html#elementsDisks>
=item B<snapshot_policy>
Defines default behavior of the disk during disk snapshots. See possible
values in L<http://www.libvirt.org/formatdomain.html#elementsDisks>,
"snapshot" attribute of the <disk> element.
=back
See the examples section for some uses. This option deprecates -f/--file,

View File

@ -626,6 +626,7 @@ c.add_valid("--disk /dev/zero") # Referencing a local unmanaged /dev node
c.add_valid("--disk pool=default,size=.00001") # Building 'default' pool
c.add_valid("--disk %(AUTOMANAGEIMG)s,size=.1") # autocreate the pool
c.add_valid("--disk %(NEWIMG1)s,sparse=true,size=100000000 --check disk_size=off") # Don't warn about fully allocated file exceeding disk space
c.add_valid("--disk %(EXISTIMG1)s,snapshot_policy=no") # Disable snasphot for disk
c.add_invalid("--file %(NEWIMG1)s --file-size 100000 --nonsparse") # Nonexisting file, size too big
c.add_invalid("--file %(NEWIMG1)s --file-size 100000") # Huge file, sparse, but no prompting
c.add_invalid("--file %(NEWIMG1)s") # Nonexisting file, no size

View File

@ -2069,6 +2069,7 @@ ParserDisk.add_arg("source_host_transport", "source_host_transport")
ParserDisk.add_arg("path", "path")
ParserDisk.add_arg("device", "device")
ParserDisk.add_arg("snapshot_policy", "snapshot_policy")
ParserDisk.add_arg("bus", "bus")
ParserDisk.add_arg("removable", "removable", is_onoff=True)
ParserDisk.add_arg("driver_cache", "cache")

View File

@ -468,7 +468,7 @@ class VirtualDisk(VirtualDevice):
_XML_PROP_ORDER = [
"type", "device",
"type", "device", "snapshot_policy",
"driver_name", "driver_type",
"driver_cache", "driver_discard", "driver_detect_zeroes",
"driver_io", "error_policy",
@ -727,6 +727,7 @@ class VirtualDisk(VirtualDevice):
device = XMLProperty("./@device",
default_cb=lambda s: s.DEVICE_DISK)
snapshot_policy = XMLProperty("./@snapshot")
driver_name = XMLProperty("./driver/@name",
default_cb=_get_default_driver_name)
driver_type = XMLProperty("./driver/@type",