qvm-prefs: support resetting values
This commit is contained in:
parent
af1a6a49bd
commit
b0af95fa2b
@ -6,7 +6,7 @@
|
|||||||
Synopsis
|
Synopsis
|
||||||
--------
|
--------
|
||||||
|
|
||||||
:command:`qvm-prefs` qvm-prefs [-h] [--xml *XMLFILE*] [--verbose] [--quiet] [--force-root] [--help-properties] *VMNAME* [*PROPERTY* [*VALUE*]]
|
:command:`qvm-prefs` qvm-prefs [-h] [--xml *XMLFILE*] [--verbose] [--quiet] [--force-root] [--help-properties] *VMNAME* [*PROPERTY* [*VALUE*\|--delete]]
|
||||||
|
|
||||||
Options
|
Options
|
||||||
-------
|
-------
|
||||||
@ -35,6 +35,10 @@ Options
|
|||||||
|
|
||||||
Force to run as root.
|
Force to run as root.
|
||||||
|
|
||||||
|
.. option:: --unset, --default, --delete, -D
|
||||||
|
|
||||||
|
Unset the property. If is has default value, it will be used instead.
|
||||||
|
|
||||||
|
|
||||||
Common properties
|
Common properties
|
||||||
=================
|
=================
|
||||||
@ -54,11 +58,11 @@ include_in_backups
|
|||||||
works only in qubes-manager). You can always manually select or deselect
|
works only in qubes-manager). You can always manually select or deselect
|
||||||
any VM for backup.
|
any VM for backup.
|
||||||
|
|
||||||
pcidevs
|
pcidevs
|
||||||
PCI devices assigned to the VM. Should be edited using
|
PCI devices assigned to the VM. Should be edited using
|
||||||
:manpage:`qvm-pci(1)` tool.
|
:manpage:`qvm-pci(1)` tool.
|
||||||
|
|
||||||
pci_strictreset
|
pci_strictreset
|
||||||
Accepted values: ``True``, ``False``
|
Accepted values: ``True``, ``False``
|
||||||
|
|
||||||
Control whether prevent assigning to VM a device which does not support any
|
Control whether prevent assigning to VM a device which does not support any
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# TODO list properties for all classes
|
# TODO list properties for all classes
|
||||||
# TODO indicate default values
|
# TODO list only non-default properties
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
@ -72,9 +72,7 @@ class _HelpPropertiesAction(argparse.Action):
|
|||||||
|
|
||||||
parser = qubes.tools.get_parser_base(want_force_root=True)
|
parser = qubes.tools.get_parser_base(want_force_root=True)
|
||||||
|
|
||||||
#parser.add_argument('--property', '--prop', '-p',
|
parser.add_argument('--help-properties', action=_HelpPropertiesAction)
|
||||||
# action=qubes.tools.PropertyAction,
|
|
||||||
# help='set domain\'s property (may be given multiple times)')
|
|
||||||
|
|
||||||
parser.add_argument('name', metavar='VMNAME',
|
parser.add_argument('name', metavar='VMNAME',
|
||||||
help='name of the domain to change')
|
help='name of the domain to change')
|
||||||
@ -83,11 +81,17 @@ parser.add_argument('property', metavar='PROPERTY',
|
|||||||
nargs='?',
|
nargs='?',
|
||||||
help='name of the property to show or change')
|
help='name of the property to show or change')
|
||||||
|
|
||||||
parser.add_argument('value', metavar='VALUE',
|
parser_value = parser.add_mutually_exclusive_group()
|
||||||
|
|
||||||
|
parser_value.add_argument('value', metavar='VALUE',
|
||||||
nargs='?',
|
nargs='?',
|
||||||
help='new value of the property')
|
help='new value of the property')
|
||||||
|
|
||||||
parser.add_argument('--help-properties', action=_HelpPropertiesAction)
|
parser.add_argument('--unset', '--default', '--delete', '-D',
|
||||||
|
dest='delete',
|
||||||
|
action='store_true',
|
||||||
|
help='unset the property; if property has default value, it will be used'
|
||||||
|
' instead')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -123,12 +127,18 @@ def main():
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
if args.value is None:
|
if args.value is not None:
|
||||||
print(str(getattr(domain, args.property)))
|
setattr(domain, args.property, args.value)
|
||||||
|
app.save()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
setattr(domain, args.property, args.value)
|
if args.delete:
|
||||||
app.save()
|
delattr(domain, args.property)
|
||||||
|
app.save()
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
print(str(getattr(domain, args.property)))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user