mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-10-06 19:19:41 +00:00
python/qemu/machine: Allow to use other serial consoles than default
Currently the QEMU Python module limits the QEMUMachine class to use the first serial console. Some machines/guest might use another console than the first one as the 'boot console'. For example the Raspberry Pi uses the second (AUX) console. To be able to use the Nth console as default, we simply need to connect all the N - 1 consoles to the null chardev. Add an index argument, so we can use a specific serial console as default. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Liam Merwick <liam.merwick@oracle.com> Tested-by: Liam Merwick <liam.merwick@oracle.com> Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Message-Id: <20200120235159.18510-5-f4bug@amsat.org> [PMD: zero-initialize _console_index in __init__()] Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This commit is contained in:
parent
52c68b8abb
commit
746f244d97
|
@ -112,6 +112,7 @@ def __init__(self, binary, args=None, wrapper=None, name=None,
|
|||
self._sock_dir = sock_dir
|
||||
self._launched = False
|
||||
self._machine = None
|
||||
self._console_index = 0
|
||||
self._console_set = False
|
||||
self._console_device_type = None
|
||||
self._console_address = None
|
||||
|
@ -241,6 +242,8 @@ def _base_args(self):
|
|||
'chardev=mon,mode=control'])
|
||||
if self._machine is not None:
|
||||
args.extend(['-machine', self._machine])
|
||||
for i in range(self._console_index):
|
||||
args.extend(['-serial', 'null'])
|
||||
if self._console_set:
|
||||
self._console_address = os.path.join(self._sock_dir,
|
||||
self._name + "-console.sock")
|
||||
|
@ -527,7 +530,7 @@ def set_machine(self, machine_type):
|
|||
"""
|
||||
self._machine = machine_type
|
||||
|
||||
def set_console(self, device_type=None):
|
||||
def set_console(self, device_type=None, console_index=0):
|
||||
"""
|
||||
Sets the device type for a console device
|
||||
|
||||
|
@ -548,9 +551,14 @@ def set_console(self, device_type=None):
|
|||
chardev:console" command line argument will
|
||||
be used instead, resorting to the machine's
|
||||
default device type.
|
||||
@param console_index: the index of the console device to use.
|
||||
If not zero, the command line will create
|
||||
'index - 1' consoles and connect them to
|
||||
the 'null' backing character device.
|
||||
"""
|
||||
self._console_set = True
|
||||
self._console_device_type = device_type
|
||||
self._console_index = console_index
|
||||
|
||||
@property
|
||||
def console_socket(self):
|
||||
|
|
Loading…
Reference in a new issue