Skip to content

Commit c134529

Browse files
committed
Introduce LocalVM to extract BaseVM being smaller class
It prepares the work for RemoteVM.
1 parent 039b7d3 commit c134529

14 files changed

+147
-109
lines changed

doc/qubes-features.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ request in ``features-request`` event handler. If no extension handles given
7272
feature request, it will be ignored. The extension should carefuly validate
7373
requested features (ignoring those not recognized - may be for another
7474
extension) and only then set appropriate value on VM object
75-
(:py:attr:`qubes.vm.BaseVM.features`). It is recommended to make the
75+
(:py:attr:`qubes.vm.LocalVM.features`). It is recommended to make the
7676
verification code as bulletproof as possible (for example allow only specific
7777
simple values, instead of complex structures), because feature requests come
7878
from untrusted sources. The features actually set on the VM in some cases may

doc/qubes-vm/index.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ two, the :py:class:`qubes.vm.qubesvm.QubesVM` cares about Qubes-specific
1919
actions, that are more or less directly related to security model. It is
2020
intended to be easily auditable by non-expert programmers (ie. we don't use
2121
Python's magic there). The second class is its parent,
22-
:py:class:`qubes.vm.BaseVM`, which is concerned about technicalities like XML
22+
:py:class:`qubes.vm.LocalVM`, which is concerned about technicalities like XML
2323
serialising/deserialising. It is of less concern to threat model auditors, but
2424
still relevant to overall security of the Qubes OS. It is written for
2525
programmers by programmers.
2626

2727
The second object is the XML node that refers to the domain. It can be accessed
28-
as :py:attr:`Qubes.vm.BaseVM.xml` attribute of the domain object. The third one
28+
as :py:attr:`Qubes.vm.LocalVM.xml` attribute of the domain object. The third one
2929
is :py:attr:`Qubes.vm.qubesvm.QubesVM.libvirt_domain` object for directly
3030
interacting with libvirt. Those objects are intended to be used from core and/or
3131
plugins, but not directly by user or from qvm-tools. They are however public, so
@@ -48,7 +48,7 @@ Package contents
4848
Main public classes
4949
^^^^^^^^^^^^^^^^^^^
5050

51-
.. autoclass:: qubes.vm.BaseVM
51+
.. autoclass:: qubes.vm.LocalVM
5252
:members:
5353
:show-inheritance:
5454

qubes/app.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -503,17 +503,19 @@ def vms(self):
503503
def add(self, value, _enable_events=True):
504504
"""Add VM to collection
505505
506-
:param qubes.vm.BaseVM value: VM to add
506+
:param qubes.vm.LocalVM value: VM to add
507507
:param _enable_events:
508508
:raises TypeError: when value is of wrong type
509509
:raises ValueError: when there is already VM which has equal ``qid``
510510
"""
511511

512512
# this violates duck typing, but is needed
513513
# for VMProperty to function correctly
514-
if not isinstance(value, qubes.vm.BaseVM):
514+
if not isinstance(value, qubes.vm.LocalVM):
515515
raise TypeError(
516-
"{} holds only BaseVM instances".format(self.__class__.__name__)
516+
"{} holds only LocalVM instances".format(
517+
self.__class__.__name__
518+
)
517519
)
518520

519521
if value.qid in self:
@@ -543,7 +545,7 @@ def __getitem__(self, key):
543545
return vm
544546
raise KeyError(key)
545547

546-
if isinstance(key, qubes.vm.BaseVM):
548+
if isinstance(key, qubes.vm.LocalVM):
547549
key = key.uuid
548550

549551
if isinstance(key, uuid.UUID):

qubes/ext/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def decorator(func):
9494
elif "vm" in kwargs:
9595
func.ha_vm = kwargs["vm"]
9696
else:
97-
func.ha_vm = qubes.vm.BaseVM
97+
func.ha_vm = qubes.vm.LocalVM
9898

9999
return func
100100

qubes/features.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def _recursive_check(
161161
raise NotImplementedError("app does not have features yet")
162162

163163
assert isinstance(
164-
self.subject, _vm.BaseVM
164+
self.subject, _vm.LocalVM
165165
), "recursive checks do not work for {}".format(
166166
type(self.subject).__name__
167167
)

qubes/tests/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def cleanup_gc(self):
507507
obj,
508508
(
509509
qubes.Qubes,
510-
qubes.vm.BaseVM,
510+
qubes.vm.LocalVM,
511511
libvirt.virConnect,
512512
libvirt.virDomain,
513513
),

qubes/tests/init.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def test_010_property_require(self):
402402
pass
403403

404404

405-
class TestVM(qubes.vm.BaseVM):
405+
class TestVM(qubes.vm.LocalVM):
406406
qid = qubes.property("qid", type=int)
407407
name = qubes.property("name")
408408
uuid = uuid.uuid5(uuid.NAMESPACE_DNS, "testvm")

qubes/tests/integ/backupcompatibility.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def assertRestored(self, name, **kwargs):
494494
)
495495
else:
496496
actual_value = getattr(vm, prop)
497-
if isinstance(actual_value, qubes.vm.BaseVM):
497+
if isinstance(actual_value, qubes.vm.LocalVM):
498498
self.assertEqual(
499499
value,
500500
actual_value.name,

qubes/tests/storage_callback.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def tearDown(self):
240240
self.app.close()
241241
del self.app
242242
for attr in dir(self):
243-
if isinstance(getattr(self, attr), qubes.vm.BaseVM):
243+
if isinstance(getattr(self, attr), qubes.vm.LocalVM):
244244
delattr(self, attr)
245245

246246
if os.path.exists(self.test_log):

qubes/tests/storage_lvm.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def tearDown(self):
176176
self.app.close()
177177
del self.app
178178
for attr in dir(self):
179-
if isinstance(getattr(self, attr), qubes.vm.BaseVM):
179+
if isinstance(getattr(self, attr), qubes.vm.LocalVM):
180180
delattr(self, attr)
181181

182182
def test_000_default_thin_pool(self):
@@ -1488,7 +1488,7 @@ def tearDown(self):
14881488
self.app.close()
14891489
del self.app
14901490
for attr in dir(self):
1491-
if isinstance(getattr(self, attr), qubes.vm.BaseVM):
1491+
if isinstance(getattr(self, attr), qubes.vm.LocalVM):
14921492
delattr(self, attr)
14931493

14941494
def test_000_search_thin_pool(self):

qubes/tests/vm/init.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(self):
4444
self.vmm = TestVMM()
4545

4646

47-
class TestVM(qubes.vm.BaseVM):
47+
class TestVM(qubes.vm.LocalVM):
4848
qid = qubes.property("qid", type=int)
4949
name = qubes.property("name")
5050
testprop = qubes.property("testprop")
@@ -55,7 +55,7 @@ def is_running(self):
5555
return False
5656

5757

58-
class TC_10_BaseVM(qubes.tests.QubesTestCase):
58+
class TC_10_LocalVM(qubes.tests.QubesTestCase):
5959
def setUp(self):
6060
super().setUp()
6161
self.xml = lxml.etree.XML(

0 commit comments

Comments
 (0)