Skip to content

Commit 43e9913

Browse files
author
anon
committed
remove 3.x compatibility interface
improve manpage
1 parent 1a623d1 commit 43e9913

3 files changed

Lines changed: 21 additions & 51 deletions

File tree

doc/manpages/qvm-ls.rst

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Synopsis
88

99
:command:`qvm-ls` [--verbose] [--quiet] [--help] [--all]
1010
[--exclude *EXCLUDE*] [--spinner] [--no-spinner]
11-
[--format *FORMAT* | --fields *FIELD* [*FIELD* ...] | --disk | --network | --kernel]
12-
[--tree] [--raw-data] [--raw-list] [--help-formats]
11+
[--format *FORMAT* | --fields *FIELD*[,*FIELD* ...]]
12+
[--tree] [--raw-data] [--help-formats]
1313
[--help-columns] [--class *CLASS* [*CLASS* ...]]
1414
[--label *LABEL* [*LABEL* ...]] [--tags *TAG* [*TAG* ...]]
1515
[--exclude-tags *TAG* [*TAG* ...]] [--running] [--paused]
@@ -75,9 +75,10 @@ Formatting options
7575

7676
.. option:: --fields=FIELD,..., -O FIELD,...
7777

78-
Sets format to specified set of columns. This gives more control over
79-
:option:`--format`. All columns along with short descriptions can be listed
80-
with :option:`--help-columns`.
78+
Sets format to a comma-separated list of columns. This gives more control
79+
over :option:`--format`. All predefined columns can be listed with
80+
:option:`--help-columns`. In addition, any VM property name (as shown by
81+
:program:`qvm-prefs --help-properties`) may be used as a column.
8182

8283
.. option:: --tree, -t
8384

@@ -89,23 +90,6 @@ Formatting options
8990
Output data in easy to parse format. Table header is skipped and columns are
9091
separated by `|` character.
9192

92-
.. option:: --raw-list
93-
94-
Give plain list of VM names, without header or separator. Useful in scripts.
95-
Same as --raw-data --fields=name
96-
97-
.. option:: --disk, -d
98-
99-
Same as --format=disk, for compatibility with Qubes 3.x
100-
101-
.. option:: --network, -n
102-
103-
Same as --format=network, for compatibility with Qubes 3.x
104-
105-
.. option:: --kernel, -k
106-
107-
Same as --format=kernel, for compatibility with Qubes 3.x
108-
10993
.. option:: --help-columns
11094

11195
List all available columns with short descriptions and exit.
@@ -160,13 +144,15 @@ Filtering options
160144

161145
.. option:: --features FEATURE=VALUE ...
162146

163-
Filter results to qubes that match all specified features. Omitted VALUE
164-
means None (unset). Empty value means "" or '' (blank)
147+
Filter results to qubes that match all specified features. ``KEY=``
148+
matches qubes where the feature is unset. ``KEY=''`` or
149+
``KEY=""`` matches qubes where the feature is set to a blank string.
165150

166151
.. option:: --prefs PREFERENCE=VALUE ...
167152

168-
Filter results to qubes that match all specified preferences. Omitted VALUE
169-
means None (unset). Empty value means "" or '' (blank)
153+
Filter results to qubes that match all specified preferences. ``KEY=``
154+
matches qubes where the preference is unset. ``KEY=''`` or ``KEY=""`` matches
155+
qubes where the preference is set to a blank string.
170156

171157
Sorting options
172158
---------------

qubesadmin/tests/tools/qvm_ls.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,6 @@ def test_102_list_selected(self):
117117
'NAME STATE CLASS LABEL TEMPLATE NETVM\n'
118118
'test-vm Running TestVM green template sys-net\n')
119119

120-
def test_102_raw_list(self):
121-
app = TestApp()
122-
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
123-
qubesadmin.tools.qvm_ls.main(['--raw-list'], app=app)
124-
self.assertEqual(stdout.getvalue(),
125-
'dom0\n'
126-
'test-vm\n')
127-
128120
def test_103_list_all(self):
129121
app = TestApp()
130122
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
@@ -150,28 +142,28 @@ def test_104_wildcards(self):
150142
]
151143
)
152144
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
153-
qubesadmin.tools.qvm_ls.main(['--raw-list', 'fedora*'], app=app)
145+
qubesadmin.tools.qvm_ls.main(['--raw-data', '--fields=name', 'fedora*'], app=app)
154146
self.assertEqual(stdout.getvalue(),
155147
'fedora-41\nfedora-41-minimal\nfedora-41-xfce\nfedora-rawhide\n')
156148

157149
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
158-
qubesadmin.tools.qvm_ls.main(['--raw-list', '*minimal'], app=app)
150+
qubesadmin.tools.qvm_ls.main(['--raw-data', '--fields=name', '*minimal'], app=app)
159151
self.assertEqual(stdout.getvalue(),
160152
'debian-13-minimal\nfedora-41-minimal\n')
161153

162154
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
163-
qubesadmin.tools.qvm_ls.main(['--raw-list', '????'], app=app)
155+
qubesadmin.tools.qvm_ls.main(['--raw-data', '--fields=name', '????'], app=app)
164156
self.assertEqual(stdout.getvalue(),
165157
'dom0\n')
166158

167159
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
168-
qubesadmin.tools.qvm_ls.main(['--raw-list', '??????-[rs]*'],
160+
qubesadmin.tools.qvm_ls.main(['--raw-data', '--fields=name', '??????-[rs]*'],
169161
app=app)
170162
self.assertEqual(stdout.getvalue(),
171163
'debian-sid\nfedora-rawhide\n')
172164

173165
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
174-
qubesadmin.tools.qvm_ls.main(['--raw-list', '??????-[!14s]*'],
166+
qubesadmin.tools.qvm_ls.main(['--raw-data', '--fields=name', '??????-[!14s]*'],
175167
app=app)
176168
self.assertEqual(stdout.getvalue(),
177169
'fedora-rawhide\n')

qubesadmin/tools/qvm_ls.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ def tree_append_child(self, parent, level):
446446
def sort_to_tree(self, domains):
447447
'''Sort the domains as a network tree. It returns a list of sets. Each
448448
tuple stores the insertion of the cell name and the vm object.
449+
Note: mutates `domains` to an empty list
449450
450451
:param list() domains: The domains which will be sorted
451452
:return list(tuple()) tree: returns a list of tuple(insertion, vm)
@@ -527,13 +528,12 @@ def sort_numeric(field: str) -> int:
527528
continue
528529

529530

530-
#: Available formats. Feel free to plug your own one.
531+
# Available formats
531532
formats = {
532533
'simple': ('name', 'state', 'class', 'label', 'template', 'netvm'),
533534
'network': ('name', 'state', 'netvm', 'ip', 'ipback', 'gateway'),
534535
'kernel': ('name', 'state', 'class', 'template', 'kernel', 'kernelopts'),
535536
'full': ('name', 'state', 'class', 'label', 'qid', 'xid', 'uuid'),
536-
# 'perf': ('name', 'state', 'cpu', 'memory'),
537537
'prefs': ('name', 'label', 'template', 'netvm',
538538
'vcpus', 'initialmem', 'maxmem', 'virt_mode'),
539539
'disk': ('name', 'state', 'disk',
@@ -632,7 +632,7 @@ def get_parser():
632632
epilog='available formats (see --help-formats):\n{}\n\n'
633633
'available columns (see --help-columns):\n{}'.format(
634634
wrapper.fill(', '.join(sorted(formats.keys()))),
635-
wrapper.fill(', '.join(sorted(sorted(Column.columns.keys()))))))
635+
wrapper.fill(', '.join(sorted(Column.columns.keys())))))
636636

637637
parser_format = parser.add_argument_group(title='formatting options')
638638
parser_format_exclusive = parser_format.add_mutually_exclusive_group()
@@ -653,7 +653,7 @@ def get_parser():
653653
help='Display specify data of specified VMs. Intended for '
654654
'bash-parsing.')
655655

656-
# shortcuts, compatibility with Qubes 3.2
656+
# helpful shortcuts
657657
parser_format.add_argument('--raw-list', action='store_true',
658658
help='Same as --raw-data --fields=name')
659659

@@ -743,10 +743,6 @@ def get_parser():
743743

744744
parser.set_defaults(spinner=True)
745745

746-
# parser.add_argument('--conf', '-c',
747-
# action='store', metavar='CFGFILE',
748-
# help='Qubes config file')
749-
750746
return parser
751747

752748

@@ -769,10 +765,6 @@ def main(args=None, app=None):
769765
# one call per property
770766
args.app.cache_enabled = True
771767

772-
if args.raw_list:
773-
args.raw_data = True
774-
args.fields = 'name'
775-
776768
if args.fields:
777769
columns = [col.strip() for col in args.fields.split(',')]
778770
else:

0 commit comments

Comments
 (0)