* [PATCH] hw/i386/vmmouse: Fix crash when using the vmmouse on a machine without vmport
@ 2020-01-29 11:29 Thomas Huth
2020-01-29 11:35 ` Darren Kenny
2020-02-06 10:03 ` Laurent Vivier
0 siblings, 2 replies; 3+ messages in thread
From: Thomas Huth @ 2020-01-29 11:29 UTC (permalink / raw)
To: qemu-devel, Michael S . Tsirkin , Marcel Apfelbaum
Cc: qemu-trivial, Paolo Bonzini, Eduardo Habkost
QEMU currently crashes when the user tries to use the "vmmouse" on a
machine without vmport, e.g.:
$ x86_64-softmmu/qemu-system-x86_64 -machine microvm -device vmmouse
Segmentation fault (core dumped)
or:
$ x86_64-softmmu/qemu-system-x86_64 -device vmmouse -M pc,vmport=off
Segmentation fault (core dumped)
Let's avoid the crash by checking for the vmport device first.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
hw/i386/vmmouse.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c
index 7c2a375527..e8e62bd96b 100644
--- a/hw/i386/vmmouse.c
+++ b/hw/i386/vmmouse.c
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
+#include "qapi/error.h"
#include "ui/console.h"
#include "hw/i386/pc.h"
#include "hw/input/i8042.h"
@@ -269,6 +270,11 @@ static void vmmouse_realizefn(DeviceState *dev, Error **errp)
DPRINTF("vmmouse_init\n");
+ if (!object_resolve_path_type("", TYPE_VMPORT, NULL)) {
+ error_setg(errp, "vmmouse needs a machine with vmport");
+ return;
+ }
+
vmport_register(VMMOUSE_STATUS, vmmouse_ioport_read, s);
vmport_register(VMMOUSE_COMMAND, vmmouse_ioport_read, s);
vmport_register(VMMOUSE_DATA, vmmouse_ioport_read, s);
--
2.18.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hw/i386/vmmouse: Fix crash when using the vmmouse on a machine without vmport
2020-01-29 11:29 [PATCH] hw/i386/vmmouse: Fix crash when using the vmmouse on a machine without vmport Thomas Huth
@ 2020-01-29 11:35 ` Darren Kenny
2020-02-06 10:03 ` Laurent Vivier
1 sibling, 0 replies; 3+ messages in thread
From: Darren Kenny @ 2020-01-29 11:35 UTC (permalink / raw)
To: Thomas Huth
Cc: Eduardo Habkost, Michael S . Tsirkin ,
qemu-trivial, qemu-devel, Paolo Bonzini
On Wed, Jan 29, 2020 at 12:29:54PM +0100, Thomas Huth wrote:
>QEMU currently crashes when the user tries to use the "vmmouse" on a
>machine without vmport, e.g.:
>
> $ x86_64-softmmu/qemu-system-x86_64 -machine microvm -device vmmouse
> Segmentation fault (core dumped)
>
>or:
>
> $ x86_64-softmmu/qemu-system-x86_64 -device vmmouse -M pc,vmport=off
> Segmentation fault (core dumped)
>
>Let's avoid the crash by checking for the vmport device first.
>
>Signed-off-by: Thomas Huth <thuth@redhat.com>
Makes sense.
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Thanks,
Darren
>---
> hw/i386/vmmouse.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
>diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c
>index 7c2a375527..e8e62bd96b 100644
>--- a/hw/i386/vmmouse.c
>+++ b/hw/i386/vmmouse.c
>@@ -23,6 +23,7 @@
> */
>
> #include "qemu/osdep.h"
>+#include "qapi/error.h"
> #include "ui/console.h"
> #include "hw/i386/pc.h"
> #include "hw/input/i8042.h"
>@@ -269,6 +270,11 @@ static void vmmouse_realizefn(DeviceState *dev, Error **errp)
>
> DPRINTF("vmmouse_init\n");
>
>+ if (!object_resolve_path_type("", TYPE_VMPORT, NULL)) {
>+ error_setg(errp, "vmmouse needs a machine with vmport");
>+ return;
>+ }
>+
> vmport_register(VMMOUSE_STATUS, vmmouse_ioport_read, s);
> vmport_register(VMMOUSE_COMMAND, vmmouse_ioport_read, s);
> vmport_register(VMMOUSE_DATA, vmmouse_ioport_read, s);
>--
>2.18.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hw/i386/vmmouse: Fix crash when using the vmmouse on a machine without vmport
2020-01-29 11:29 [PATCH] hw/i386/vmmouse: Fix crash when using the vmmouse on a machine without vmport Thomas Huth
2020-01-29 11:35 ` Darren Kenny
@ 2020-02-06 10:03 ` Laurent Vivier
1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2020-02-06 10:03 UTC (permalink / raw)
To: Thomas Huth, qemu-devel, Michael S . Tsirkin, Marcel Apfelbaum
Cc: qemu-trivial, Paolo Bonzini, Eduardo Habkost
Le 29/01/2020 à 12:29, Thomas Huth a écrit :
> QEMU currently crashes when the user tries to use the "vmmouse" on a
> machine without vmport, e.g.:
>
> $ x86_64-softmmu/qemu-system-x86_64 -machine microvm -device vmmouse
> Segmentation fault (core dumped)
>
> or:
>
> $ x86_64-softmmu/qemu-system-x86_64 -device vmmouse -M pc,vmport=off
> Segmentation fault (core dumped)
>
> Let's avoid the crash by checking for the vmport device first.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> hw/i386/vmmouse.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c
> index 7c2a375527..e8e62bd96b 100644
> --- a/hw/i386/vmmouse.c
> +++ b/hw/i386/vmmouse.c
> @@ -23,6 +23,7 @@
> */
>
> #include "qemu/osdep.h"
> +#include "qapi/error.h"
> #include "ui/console.h"
> #include "hw/i386/pc.h"
> #include "hw/input/i8042.h"
> @@ -269,6 +270,11 @@ static void vmmouse_realizefn(DeviceState *dev, Error **errp)
>
> DPRINTF("vmmouse_init\n");
>
> + if (!object_resolve_path_type("", TYPE_VMPORT, NULL)) {
> + error_setg(errp, "vmmouse needs a machine with vmport");
> + return;
> + }
> +
> vmport_register(VMMOUSE_STATUS, vmmouse_ioport_read, s);
> vmport_register(VMMOUSE_COMMAND, vmmouse_ioport_read, s);
> vmport_register(VMMOUSE_DATA, vmmouse_ioport_read, s);
>
Applied to my trivial-patches branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-06 10:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-29 11:29 [PATCH] hw/i386/vmmouse: Fix crash when using the vmmouse on a machine without vmport Thomas Huth
2020-01-29 11:35 ` Darren Kenny
2020-02-06 10:03 ` Laurent Vivier
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).