|
19 | 19 | # with this program; if not, see <http://www.gnu.org/licenses/>. |
20 | 20 |
|
21 | 21 | import asyncio |
22 | | -from typing import Optional, Union, Iterator |
| 22 | +from typing import Optional, Union, Iterator, Tuple |
23 | 23 |
|
24 | 24 | import qubes.config |
25 | 25 | import qubes.events |
@@ -180,10 +180,11 @@ def on_feature_pre_set_preload_dispvm_max( |
180 | 180 | if not self.features.check_with_template("qrexec", None): |
181 | 181 | raise qubes.exc.QubesValueError("Qube does not support qrexec") |
182 | 182 |
|
183 | | - service = "qubes.WaitForRunningSystem" |
184 | | - if not self.supports_preload(): |
| 183 | + supported, missing_services = self.supports_preload() |
| 184 | + if not supported: |
185 | 185 | raise qubes.exc.QubesValueError( |
186 | | - "Qube does not support the RPC '%s'" % service |
| 186 | + "Qube does not support the RPC(s) '%s'" |
| 187 | + % ", ".join(missing_services) |
187 | 188 | ) |
188 | 189 |
|
189 | 190 | value = value or "0" |
@@ -445,11 +446,12 @@ async def on_domain_preload_dispvm_used( |
445 | 446 | if delay: |
446 | 447 | event_log += " with a delay of %s second(s)" % f"{delay:.1f}" |
447 | 448 | self.log.info(event_log) |
448 | | - service = "qubes.WaitForRunningSystem" |
449 | | - if not self.supports_preload(): |
| 449 | + |
| 450 | + supported, missing_services = self.supports_preload() |
| 451 | + if not supported: |
450 | 452 | raise qubes.exc.QubesValueError( |
451 | | - "Qube does not support the RPC '%s' but tried to preload, " |
452 | | - "check if template is outdated" % service |
| 453 | + "Qube does not support the RPC(s) '%s' but tried to preload, " |
| 454 | + "check if template is outdated" % ", ".join(missing_services) |
453 | 455 | ) |
454 | 456 | if delay: |
455 | 457 | await asyncio.sleep(delay) |
@@ -672,15 +674,21 @@ def remove_preload_excess( |
672 | 674 | dispvm = self.app.domains[unwanted_disp] |
673 | 675 | asyncio.ensure_future(dispvm.cleanup()) |
674 | 676 |
|
675 | | - def supports_preload(self) -> bool: |
| 677 | + def supports_preload(self) -> Tuple[bool, list]: |
676 | 678 | """ |
677 | | - Check if the necessary RPC is supported. |
| 679 | + Check if the necessary RPCs are supported. |
678 | 680 |
|
679 | | - :rtype: bool |
| 681 | + The first returned value indicates success while the second value is |
| 682 | + non empty and contains the missing services if they are not supported. |
| 683 | +
|
| 684 | + :rtype: (bool, list) |
680 | 685 | """ |
681 | 686 | assert isinstance(self, qubes.vm.BaseVM) |
682 | | - service = "qubes.WaitForRunningSystem" |
683 | | - supported_service = "supported-rpc." + service |
684 | | - if self.features.check_with_template(supported_service, False): |
685 | | - return True |
686 | | - return False |
| 687 | + supported = True |
| 688 | + missing_services = [] |
| 689 | + for service in ["qubes.WaitForRunningSystem", "qubes.WaitForSession"]: |
| 690 | + feature = "supported-rpc." + service |
| 691 | + if not self.features.check_with_template(feature, False): |
| 692 | + missing_services.append(service) |
| 693 | + supported = False |
| 694 | + return (supported, missing_services) |
0 commit comments