Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vm.icon property #342

Merged
merged 3 commits into from
May 10, 2020
Merged

Add vm.icon property #342

merged 3 commits into from
May 10, 2020

Conversation

marmarta
Copy link
Member

@marmarta marmarta commented May 5, 2020

This is a property for handling vm icons that change depending on vm type.
Depends on QubesOS/qubes-artwork#17

references QubesOS/qubes-issues#5767

This is a property for handling vm icons that change depending on
vm type.
Depends on QubesOS/qubes-artwork#17

references QubesOS/qubes-issues#5767
@codecov
Copy link

codecov bot commented May 5, 2020

Codecov Report

Merging #342 into master will increase coverage by 0.35%.
The diff coverage is 95.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #342      +/-   ##
==========================================
+ Coverage   63.58%   63.94%   +0.35%     
==========================================
  Files          50       49       -1     
  Lines        8978     9036      +58     
==========================================
+ Hits         5709     5778      +69     
+ Misses       3269     3258      -11     
Flag Coverage Δ
#unittests 63.94% <95.23%> (+0.35%) ⬆️
Impacted Files Coverage Δ
qubes/ext/core_features.py 97.14% <91.66%> (-2.86%) ⬇️
qubes/vm/qubesvm.py 52.23% <100.00%> (+1.46%) ⬆️
qubes/tools/qmemmand.py 0.00% <0.00%> (ø)
qubes/api/admin.py 91.34% <0.00%> (+0.21%) ⬆️
qubes/api/internal.py 91.89% <0.00%> (+0.22%) ⬆️
qubes/api/__init__.py 75.46% <0.00%> (+0.46%) ⬆️
qubes/ext/admin.py 87.71% <0.00%> (+16.29%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f0ec59...419b4d5. Read the comment docs.

A fossil from Qubes 3.2 times.
@qubes.ext.handler('property-del:provides_network')
def on_property_del(self, subject, event, name):
# pylint: disable=unused-argument
self.set_servicevm_feature(subject)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all will work fine for new VMs, because default value for provides_network is false (so default not having servicevm feature is correct).
But the above miss adding the feature for existing VMs (on system update from the version before this change). The easiest way to do that is adding similar handler for domain-load event (loading a domain from qubes.xml - basically qubesd service start).

marmarta added a commit to marmarta/qubes-desktop-linux-common that referenced this pull request May 8, 2020
marmarta added a commit to marmarta/qubes-desktop-linux-common that referenced this pull request May 8, 2020
marmarta added a commit to marmarta/qubes-desktop-linux-common that referenced this pull request May 8, 2020
del subject.features['servicevm']

@qubes.ext.handler('property-set:provides_network')
def on_property_set(self, subject, _event, _name, _newvalue,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work - event's arguments are keyword arguments so must have specific names (see tests that fail now).

self.set_servicevm_feature(subject)

@qubes.ext.handler('domain-load')
def on_property_del(self, subject, _event):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated function name (see pylint).

Used by vm.icon method, at the moment features['servicevm'] is set
when a VM provides_network.
@marmarek marmarek merged commit c7d3635 into QubesOS:master May 10, 2020
marmarta added a commit to marmarta/qubes-desktop-linux-common that referenced this pull request May 11, 2020
if getattr(subject, 'provides_network', False):
subject.features['servicevm'] = 1
elif 'servicevm' in subject.features:
del subject.features['servicevm']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was deleting servicevm necessary? Later on this commit:

Came here from QubesOS/qubes-mgmt-salt-dom0-virtual-machines#63

    def test_100_servicevm_feature(self):
        self.vm.provides_network = True
        self.ext.set_servicevm_feature(self.vm)
        self.assertEqual(self.features['servicevm'], 1)

        self.vm.provides_network = False
        self.ext.set_servicevm_feature(self.vm)
        self.assertNotIn('servicevm', self.features)

I don't think not having provides_network must enforce not having servicevm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants