Skip to content

Commit

Permalink
python/machine: move more variable initializations to _pre_launch
Browse files Browse the repository at this point in the history
No need to clear them only to set them later.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
Message-id: 20211118204620.1897674-5-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
  • Loading branch information
jnsnow committed Nov 22, 2021
1 parent 72b17fe commit b1ca991
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions python/qemu/machine/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,14 @@ def _pre_launch(self) -> None:
self._qemu_log_path = os.path.join(self.log_dir, self._name + ".log")
self._qemu_log_file = open(self._qemu_log_path, 'wb')

self._iolog = None
self._qemu_full_args = tuple(chain(
self._wrapper,
[self._binary],
self._base_args,
self._args
))

def _post_launch(self) -> None:
if self._qmp_connection:
self._qmp.accept(self._qmp_timer)
Expand Down Expand Up @@ -390,8 +398,6 @@ def launch(self) -> None:
if self._launched:
raise QEMUMachineError('VM already launched')

self._iolog = None
self._qemu_full_args = ()
try:
self._launch()
self._launched = True
Expand All @@ -410,12 +416,6 @@ def _launch(self) -> None:
Launch the VM and establish a QMP connection
"""
self._pre_launch()
self._qemu_full_args = tuple(
chain(self._wrapper,
[self._binary],
self._base_args,
self._args)
)
LOG.debug('VM launch command: %r', ' '.join(self._qemu_full_args))

# Cleaning up of this subprocess is guaranteed by _do_shutdown.
Expand Down

0 comments on commit b1ca991

Please sign in to comment.