From: "Daniel P. Berrange" <berrange@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Michal Privoznik" <mprivozn@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@gmail.com>,
"QEMU Developers" <qemu-devel@nongnu.org>,
"Markus Armbruster" <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] qemu_opt_foreach: Fix crasher
Date: Thu, 6 Oct 2016 14:41:00 +0100 [thread overview]
Message-ID: <20161006134059.GI14680@redhat.com> (raw)
In-Reply-To: <CAFEAcA-jq=a9ux5yOYCc456Lc8N=OMx8amBt7KMUC9pid9at-A@mail.gmail.com>
On Thu, Oct 06, 2016 at 02:10:17PM +0100, Peter Maydell wrote:
> On 6 October 2016 at 14:02, Peter Maydell <peter.maydell@linaro.org> wrote:
> > On 6 October 2016 at 13:39, Michal Privoznik <mprivozn@redhat.com> wrote:
> >> 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?
>
> FWIW, a quick check of who uses this field (by commenting it out
> and looking for the compile errors) shows:
> net/vhost-user.c
> net/colo-compare.c (which also just does a foreach on it)
> qemu-char.c (in qemu_chr_new_from_opts and qemu_chr_free_common)
>
> Alternative possible approach: if you can create a CharDriver
> validly with no opts, then the net/ code shouldn't be looking
> at opts at all (but should instead look at wherever the config
> stuff goes for the 'opts is null' case, which we should make
> sure is correct regardless of how the CharDriver was created).
Agreed, that net/vhost-user.c code is just evil - it has no business
poking around the chardev internals in that way. AFAICT, the only
reason it is doing that is so that it can report an error if you
try to connect the vhost-suer to a chardev that isn't socket
backed.
If it requires some particular feature of the chardev backend, then
we should make a way to query for existance of that feature directly.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|
next prev parent reply other threads:[~2016-10-06 13:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-06 12:39 [Qemu-devel] [PATCH v2] qemu_opt_foreach: Fix crasher Michal Privoznik
2016-10-06 13:02 ` Peter Maydell
2016-10-06 13:10 ` Peter Maydell
2016-10-06 13:41 ` Daniel P. Berrange [this message]
2016-10-06 14:51 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161006134059.GI14680@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=mprivozn@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).