diff mbox series

[RFC,v3,2/6] tests/acceptance: Add a kludge to not use the default console

Message ID 20181013151545.3731-3-f4bug@amsat.org
State New
Headers show
Series Avocado: more multi-arch tests | expand

Commit Message

Philippe Mathieu-Daudé Oct. 13, 2018, 3:15 p.m. UTC
The board already instantiate the proper devices, we don't want to
add extra devices but connect the chardev to one of the serial already
available.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 scripts/qemu.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Cleber Rosa Oct. 19, 2018, 5:37 p.m. UTC | #1
On 10/13/18 11:15 AM, Philippe Mathieu-Daudé wrote:
> The board already instantiate the proper devices, we don't want to
> add extra devices but connect the chardev to one of the serial already
> available.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  scripts/qemu.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/qemu.py b/scripts/qemu.py
> index fca9b76990..7e779954e6 100644
> --- a/scripts/qemu.py
> +++ b/scripts/qemu.py
> @@ -221,8 +221,10 @@ class QEMUMachine(object):
>                                                   self._name + "-console.sock")
>              chardev = ('socket,id=console,path=%s,server,nowait' %
>                         self._console_address)
> -            device = '%s,chardev=console' % self._console_device_type
> -            args.extend(['-chardev', chardev, '-device', device])
> +            args.extend(['-chardev', chardev])
> +            if len(self._console_device_type):

Considering `self._console_device_type` will come from `set_console()`,
either explicitly as the "device_type" parameter, or from the list on
CONSOLE_DEV_TYPES, wouldn't it make more sense to just drop the
definitions for the machine types that don't need an explicit device?

That way, self.set_console() could be called with no arguments (instead
of the empty string).  And this check would become:

  if self._console_device_type is not None:

> +                device = '%s,chardev=console' % self._console_device_type
> +                args.extend(['-device', device])
>          return args
>  
>      def _pre_launch(self):
>
Philippe Mathieu-Daudé Oct. 19, 2018, 5:45 p.m. UTC | #2
On 19/10/2018 19:37, Cleber Rosa wrote:
> On 10/13/18 11:15 AM, Philippe Mathieu-Daudé wrote:
>> The board already instantiate the proper devices, we don't want to
>> add extra devices but connect the chardev to one of the serial already
>> available.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  scripts/qemu.py | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/scripts/qemu.py b/scripts/qemu.py
>> index fca9b76990..7e779954e6 100644
>> --- a/scripts/qemu.py
>> +++ b/scripts/qemu.py
>> @@ -221,8 +221,10 @@ class QEMUMachine(object):
>>                                                   self._name + "-console.sock")
>>              chardev = ('socket,id=console,path=%s,server,nowait' %
>>                         self._console_address)
>> -            device = '%s,chardev=console' % self._console_device_type
>> -            args.extend(['-chardev', chardev, '-device', device])
>> +            args.extend(['-chardev', chardev])
>> +            if len(self._console_device_type):
> 
> Considering `self._console_device_type` will come from `set_console()`,
> either explicitly as the "device_type" parameter, or from the list on
> CONSOLE_DEV_TYPES, wouldn't it make more sense to just drop the
> definitions for the machine types that don't need an explicit device?
> 
> That way, self.set_console() could be called with no arguments (instead
> of the empty string).  And this check would become:
> 
>   if self._console_device_type is not None:

Clever Cleber!

> 
>> +                device = '%s,chardev=console' % self._console_device_type
>> +                args.extend(['-device', device])
>>          return args
>>  
>>      def _pre_launch(self):
>>
> 
>
diff mbox series

Patch

diff --git a/scripts/qemu.py b/scripts/qemu.py
index fca9b76990..7e779954e6 100644
--- a/scripts/qemu.py
+++ b/scripts/qemu.py
@@ -221,8 +221,10 @@  class QEMUMachine(object):
                                                  self._name + "-console.sock")
             chardev = ('socket,id=console,path=%s,server,nowait' %
                        self._console_address)
-            device = '%s,chardev=console' % self._console_device_type
-            args.extend(['-chardev', chardev, '-device', device])
+            args.extend(['-chardev', chardev])
+            if len(self._console_device_type):
+                device = '%s,chardev=console' % self._console_device_type
+                args.extend(['-device', device])
         return args
 
     def _pre_launch(self):