qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] qemu_opt_foreach: Fix crasher


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v2] qemu_opt_foreach: Fix crasher
Date: Thu, 6 Oct 2016 14:02:42 +0100

On 6 October 2016 at 13:39, Michal Privoznik <address@hidden> wrote:
> The crash occurred when I tried to attach vhost-user net:
>
> {"execute":"chardev-add","arguments":{"id":"charnet2","backend":{"type":"socket","data":{"addr":{"type":"unix","data":{"path":"/var/run/openvswitch/vhost-user1"}},"wait":false,"server":false}}},"id":"libvirt-19"}
> {"return": {}, "id": "libvirt-19"}
> {"execute":"netdev_add","arguments":{"type":"vhost-user","chardev":"charnet2","id":"hostnet2"},"id":"libvirt-20"}
>
> 2016-08-16 14:52:18.274+0000: 6456: error : qemuMonitorIORead:586 : Unable to 
> read from monitor: Connection reset by peer
>
>
> The solution is to teach qemu_opt_foreach() to take a shortcut if
> @opts is NULL.
>
> Signed-off-by: Michal Privoznik <address@hidden>
> ---
>
> v2 of:
>
> http://lists.nongnu.org/archive/html/qemu-devel/2016-08/msg02933.html
>
> diff to v1:
> - Added comment to CharDriverState struct to warn others too.
>
>  include/sysemu/char.h | 1 +
>  util/qemu-option.c    | 5 +++++
>  2 files changed, 6 insertions(+)
>
> diff --git a/include/sysemu/char.h b/include/sysemu/char.h
> index 0d0465a..df58ef8 100644
> --- a/include/sysemu/char.h
> +++ b/include/sysemu/char.h
> @@ -93,6 +93,7 @@ struct CharDriverState {
>      int avail_connections;
>      int is_mux;
>      guint fd_in_tag;
> +    /* Be aware that in some cases @opts might be NULL. */
>      QemuOpts *opts;
>      bool replay;
>      QTAILQ_ENTRY(CharDriverState) next;

Wouldn't it be better to ensure that it can't be NULL regardless of
how the object was created?

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]