From 749e8497e340dea083be8e7c266dcc2fae12054e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 19 Nov 2017 15:01:44 +0100 Subject: [PATCH] api/admin: exclude regex attribute from DeviceInfo structure DeviceInfo may contain 'regex' attribute - it isn't intended to be reported through Admin API. Also, mark 'libvirt_regex' attribute as private. --- qubes/api/admin.py | 2 +- qubes/ext/pci.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qubes/api/admin.py b/qubes/api/admin.py index a8ffbba9..6e45cdbe 100644 --- a/qubes/api/admin.py +++ b/qubes/api/admin.py @@ -1067,7 +1067,7 @@ class QubesAdminAPI(qubes.api.AbstractQubesAPI): non_default_attrs = set(attr for attr in dir(dev) if not attr.startswith('_')).difference(( 'backend_domain', 'ident', 'frontend_domain', - 'description', 'options')) + 'description', 'options', 'regex')) properties_txt = ' '.join( '{}={!s}'.format(prop, value) for prop, value in itertools.chain( diff --git a/qubes/ext/pci.py b/qubes/ext/pci.py index 8ebb72b8..b369ff21 100644 --- a/qubes/ext/pci.py +++ b/qubes/ext/pci.py @@ -128,13 +128,13 @@ class PCIDevice(qubes.devices.DeviceInfo): # pylint: disable=too-few-public-methods regex = re.compile( r'^(?P[0-9a-f]+)_(?P[0-9a-f]+)\.(?P[0-9a-f]+)$') - libvirt_regex = re.compile( + _libvirt_regex = re.compile( r'^pci_0000_(?P[0-9a-f]+)_(?P[0-9a-f]+)_' r'(?P[0-9a-f]+)$') def __init__(self, backend_domain, ident, libvirt_name=None): if libvirt_name: - dev_match = self.libvirt_regex.match(libvirt_name) + dev_match = self._libvirt_regex.match(libvirt_name) assert dev_match ident = '{bus}_{device}.{function}'.format(**dev_match.groupdict())