diff mbox series

[14/19] python/qemu/machine: Allow to use other serial consoles than default

Message ID 20190926173428.10713-15-f4bug@amsat.org
State New
Headers show
Series hw/arm/raspi: Improve Raspberry Pi 2/3 reliability | expand

Commit Message

Philippe Mathieu-Daudé Sept. 26, 2019, 5:34 p.m. UTC
Currently we are limited to use the first serial console available.
Some machines/guest might use another console than the first one as
the 'boot console'.

To be able to use the N 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>
---
 python/qemu/machine.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

bzt Sept. 27, 2019, 12:54 p.m. UTC | #1
Hi,

On 9/26/19, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> Currently we are limited to use the first serial console available.

I'm not so sure. Right now it works like this:

qemu -serial stdio
Connects the VM's UART0 (PL011) serial console to the host terminal

qemu -serial null -serial stdio
Connects the VM's UART1 (AUX) serial console to the host terminal

I think this is simple and good, please don't remove this option. If
your commit does not influence these cli args, I'm not against it.

bzt
Guenter Roeck Sept. 27, 2019, 1:26 p.m. UTC | #2
On Fri, Sep 27, 2019 at 02:54:10PM +0200, bzt wrote:
> Hi,
> 
> On 9/26/19, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> > Currently we are limited to use the first serial console available.
> 
> I'm not so sure. Right now it works like this:
> 
> qemu -serial stdio
> Connects the VM's UART0 (PL011) serial console to the host terminal
> 
> qemu -serial null -serial stdio
> Connects the VM's UART1 (AUX) serial console to the host terminal
> 
> I think this is simple and good, please don't remove this option. If
> your commit does not influence these cli args, I'm not against it.
> 
Agreed. I am using that mechanism (raspi3 uses the second console,
not pl011) in my scripts. Please don't take it away.

Guenter
Peter Maydell Sept. 27, 2019, 1:36 p.m. UTC | #3
On Fri, 27 Sep 2019 at 14:26, Guenter Roeck <linux@roeck-us.net> wrote:
>
> On Fri, Sep 27, 2019 at 02:54:10PM +0200, bzt wrote:
> > Hi,
> >
> > On 9/26/19, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> > > Currently we are limited to use the first serial console available.
> >
> > I'm not so sure. Right now it works like this:
> >
> > qemu -serial stdio
> > Connects the VM's UART0 (PL011) serial console to the host terminal
> >
> > qemu -serial null -serial stdio
> > Connects the VM's UART1 (AUX) serial console to the host terminal
> >
> > I think this is simple and good, please don't remove this option. If
> > your commit does not influence these cli args, I'm not against it.
> >
> Agreed. I am using that mechanism (raspi3 uses the second console,
> not pl011) in my scripts. Please don't take it away.

This patch is changing our python infrastructure that invokes
QEMU, not QEMU itself. What Philippe's message means is
"currently our code for running QEMU as part of tests like
this is limited to using the first serial console; this doesn't
work for raspi because we want to use the second (aux) console;
so make the test infrastructure able to handle machines like this."

thanks
-- PMM
Philippe Mathieu-Daudé Sept. 27, 2019, 2:44 p.m. UTC | #4
On 9/27/19 3:36 PM, Peter Maydell wrote:
> On Fri, 27 Sep 2019 at 14:26, Guenter Roeck <linux@roeck-us.net> wrote:
>>
>> On Fri, Sep 27, 2019 at 02:54:10PM +0200, bzt wrote:
>>> Hi,
>>>
>>> On 9/26/19, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>>> Currently we are limited to use the first serial console available.
>>>
>>> I'm not so sure. Right now it works like this:
>>>
>>> qemu -serial stdio
>>> Connects the VM's UART0 (PL011) serial console to the host terminal
>>>
>>> qemu -serial null -serial stdio
>>> Connects the VM's UART1 (AUX) serial console to the host terminal
>>>
>>> I think this is simple and good, please don't remove this option. If
>>> your commit does not influence these cli args, I'm not against it.
>>>
>> Agreed. I am using that mechanism (raspi3 uses the second console,
>> not pl011) in my scripts. Please don't take it away.
> 
> This patch is changing our python infrastructure that invokes
> QEMU, not QEMU itself. What Philippe's message means is
> "currently our code for running QEMU as part of tests like
> this is limited to using the first serial console; this doesn't
> work for raspi because we want to use the second (aux) console;
> so make the test infrastructure able to handle machines like this."

Exactly, thanks Peter for clarifying.

I'll try to come with a clearer commit description.

Regards,

Phil.
Cleber Rosa Oct. 9, 2019, 3:28 p.m. UTC | #5
On Thu, Sep 26, 2019 at 07:34:22PM +0200, Philippe Mathieu-Daudé wrote:
> Currently we are limited to use the first serial console available.
> Some machines/guest might use another console than the first one as
> the 'boot console'.
> 
> To be able to use the N 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>
> ---
>  python/qemu/machine.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/python/qemu/machine.py b/python/qemu/machine.py
> index 128a3d1dc2..302b158a18 100644
> --- a/python/qemu/machine.py
> +++ b/python/qemu/machine.py
> @@ -235,6 +235,8 @@ class QEMUMachine(object):
>                  '-display', 'none', '-vga', 'none']
>          if self._machine is not None:
>              args.extend(['-machine', self._machine])
> +        for i in range(self._console_id):
> +            args.extend(['-serial', 'null'])
>          if self._console_set:
>              self._console_address = os.path.join(self._temp_dir,
>                                                   self._name + "-console.sock")
> @@ -495,7 +497,7 @@ class QEMUMachine(object):
>          """
>          self._machine = machine_type
>  
> -    def set_console(self, device_type=None):
> +    def set_console(self, device_type=None, console_id=0):

My guts tell me that we'll need to support multiple devices of a single
type shortly, but for now, this looks fine.

Would you please add a docstring parameter entry for console_id
explaining its effect?

Thanks,
- Cleber.

>          """
>          Sets the device type for a console device
>  
> @@ -519,6 +521,7 @@ class QEMUMachine(object):
>          """
>          self._console_set = True
>          self._console_device_type = device_type
> +        self._console_id = console_id
>  
>      @property
>      def console_socket(self):
> -- 
> 2.20.1
>
diff mbox series

Patch

diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index 128a3d1dc2..302b158a18 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -235,6 +235,8 @@  class QEMUMachine(object):
                 '-display', 'none', '-vga', 'none']
         if self._machine is not None:
             args.extend(['-machine', self._machine])
+        for i in range(self._console_id):
+            args.extend(['-serial', 'null'])
         if self._console_set:
             self._console_address = os.path.join(self._temp_dir,
                                                  self._name + "-console.sock")
@@ -495,7 +497,7 @@  class QEMUMachine(object):
         """
         self._machine = machine_type
 
-    def set_console(self, device_type=None):
+    def set_console(self, device_type=None, console_id=0):
         """
         Sets the device type for a console device
 
@@ -519,6 +521,7 @@  class QEMUMachine(object):
         """
         self._console_set = True
         self._console_device_type = device_type
+        self._console_id = console_id
 
     @property
     def console_socket(self):