tools/qvm-start-gui: avoid starting a VM just to send it monitor layout

If the VM is powered off shortly after startup, it may happen that
qubes.SetMonitorLayout would start it again. Avoid this by using
autostart=False argument to run_service() function.

Note that there is a vm.is_running() check at the beginning of the
function already, but if it happens while the VM is cleaned up, it may
still report that it's running, but at the time of run_service() call it
is not.
This commit is contained in:
Marek Marczykowski-Górecki 2019-09-21 04:51:43 +02:00
parent 98260ff148
commit e8c48ff7c8
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 7 additions and 3 deletions
qubesadmin

View File

@ -511,7 +511,7 @@ HDMI1 connected 2560x1920+0+0 (normal left inverted right x axis y axis) 206mm x
loop.run_until_complete(self.launcher.send_monitor_layout( loop.run_until_complete(self.launcher.send_monitor_layout(
vm, layout=monitor_layout, startup=True)) vm, layout=monitor_layout, startup=True))
mock_run_service.assert_called_once_with( mock_run_service.assert_called_once_with(
'qubes.SetMonitorLayout', b'1920 1080 0 0\n') 'qubes.SetMonitorLayout', autostart=False, input=b'1920 1080 0 0\n')
self.assertAllCalled() self.assertAllCalled()
def test_061_send_monitor_layout_exclude(self): def test_061_send_monitor_layout_exclude(self):

View File

@ -25,6 +25,8 @@ import signal
import subprocess import subprocess
import asyncio import asyncio
import re import re
import functools
import xcffib import xcffib
import xcffib.xproto # pylint: disable=unused-import import xcffib.xproto # pylint: disable=unused-import
@ -292,8 +294,10 @@ class GUILauncher(object):
try: try:
yield from asyncio.get_event_loop().run_in_executor(None, yield from asyncio.get_event_loop().run_in_executor(None,
vm.run_service_for_stdio, 'qubes.SetMonitorLayout', functools.partial(vm.run_service_for_stdio,
''.join(layout).encode()) 'qubes.SetMonitorLayout',
input=''.join(layout).encode(),
autostart=False))
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
vm.log.warning('Failed to send monitor layout: %s', e.stderr) vm.log.warning('Failed to send monitor layout: %s', e.stderr)