qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] baum: Truncate braille device size to 84x1
@ 2017-12-11  0:19 Samuel Thibault
  2017-12-11 14:30 ` Eric Blake
  0 siblings, 1 reply; 4+ messages in thread
From: Samuel Thibault @ 2017-12-11  0:19 UTC (permalink / raw)
  To: qemu-devel, pbonzini, marcandre.lureau; +Cc: Samuel Thibault

Baum device bigger than 84 do not actually exist, some guest drivers
would be upset by such sizes.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 chardev/baum.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/chardev/baum.c b/chardev/baum.c
index 67fd783a59..78b0c87625 100644
--- a/chardev/baum.c
+++ b/chardev/baum.c
@@ -1,7 +1,7 @@
 /*
  * QEMU Baum Braille Device
  *
- * Copyright (c) 2008, 2010-2011, 2016 Samuel Thibault
+ * Copyright (c) 2008, 2010-2011, 2016-2017 Samuel Thibault
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -239,6 +239,12 @@ static int baum_deferred_init(BaumChardev *baum)
         brlapi_perror("baum: brlapi__getDisplaySize");
         return 0;
     }
+    if (baum->y > 1) {
+        baum->y = 1;
+    }
+    if (baum->x > 84) {
+        baum->x = 84;
+    }
 
     con = qemu_console_lookup_by_index(0);
     if (con && qemu_console_is_graphic(con)) {
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] baum: Truncate braille device size to 84x1
  2017-12-11  0:19 [Qemu-devel] [PATCH] baum: Truncate braille device size to 84x1 Samuel Thibault
@ 2017-12-11 14:30 ` Eric Blake
  2017-12-11 14:51   ` Samuel Thibault
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Blake @ 2017-12-11 14:30 UTC (permalink / raw)
  To: Samuel Thibault, qemu-devel, pbonzini, marcandre.lureau

[-- Attachment #1: Type: text/plain, Size: 865 bytes --]

On 12/10/2017 06:19 PM, Samuel Thibault wrote:
> Baum device bigger than 84 do not actually exist, some guest drivers
> would be upset by such sizes.
> 
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
>  chardev/baum.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 

> @@ -239,6 +239,12 @@ static int baum_deferred_init(BaumChardev *baum)
>          brlapi_perror("baum: brlapi__getDisplaySize");
>          return 0;
>      }
> +    if (baum->y > 1) {
> +        baum->y = 1;
> +    }
> +    if (baum->x > 84) {
> +        baum->x = 84;
> +    }

Is magic clamping desirable, or is it better to make it a hard error if
the user configured a size that is not possible?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] baum: Truncate braille device size to 84x1
  2017-12-11 14:30 ` Eric Blake
@ 2017-12-11 14:51   ` Samuel Thibault
  2017-12-12 14:11     ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Samuel Thibault @ 2017-12-11 14:51 UTC (permalink / raw)
  To: Eric Blake; +Cc: qemu-devel, pbonzini, marcandre.lureau

Eric Blake, on lun. 11 déc. 2017 08:30:39 -0600, wrote:
> On 12/10/2017 06:19 PM, Samuel Thibault wrote:
> > Baum device bigger than 84 do not actually exist, some guest drivers
> > would be upset by such sizes.
> > 
> > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > ---
> >  chardev/baum.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> 
> > @@ -239,6 +239,12 @@ static int baum_deferred_init(BaumChardev *baum)
> >          brlapi_perror("baum: brlapi__getDisplaySize");
> >          return 0;
> >      }
> > +    if (baum->y > 1) {
> > +        baum->y = 1;
> > +    }
> > +    if (baum->x > 84) {
> > +        baum->x = 84;
> > +    }
> 
> Is magic clamping desirable, or is it better to make it a hard error if
> the user configured a size that is not possible?

The thing is: the user didn't configure something, she just happened to
use a braille device bigger than 84 to display qemu's braille output.

This is the same situation as for the virtual video card: qemu could
expose resolutions as big as the size of the X display where qemu is
running on, but it's not a good idea to expose them all because some
drivers could go crazy with sizes bigger than what is supposed to be
supported by the hardware (or just assume the device is bogus and refuse
to drive it), and one should thus rather clamp them to what an actual
video device would support.

Samuel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] baum: Truncate braille device size to 84x1
  2017-12-11 14:51   ` Samuel Thibault
@ 2017-12-12 14:11     ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2017-12-12 14:11 UTC (permalink / raw)
  To: Samuel Thibault, Eric Blake; +Cc: qemu-devel, marcandre.lureau

On 11/12/2017 15:51, Samuel Thibault wrote:
>> Is magic clamping desirable, or is it better to make it a hard error if
>> the user configured a size that is not possible?
> The thing is: the user didn't configure something, she just happened to
> use a braille device bigger than 84 to display qemu's braille output.

Makes sense, I clarified the commit message to

    Baum device bigger than 84 do not actually exist, but the user's own
    Braille device might be wider than 84 columns.  Some guest drivers
    would be upset by such sizes, so clamp the device size.

Thanks,

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-12 14:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-11  0:19 [Qemu-devel] [PATCH] baum: Truncate braille device size to 84x1 Samuel Thibault
2017-12-11 14:30 ` Eric Blake
2017-12-11 14:51   ` Samuel Thibault
2017-12-12 14:11     ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).