From: Luiz Capitulino <lcapitulino@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Fix exit on 'pci_add' Monitor command
Date: Thu, 24 Sep 2009 16:31:23 -0300 [thread overview]
Message-ID: <20090924163123.5eec5c90@doriath> (raw)
In-Reply-To: <87iqf8ciup.fsf@pike.pond.sub.org>
On Thu, 24 Sep 2009 20:12:30 +0200
Markus Armbruster <armbru@redhat.com> wrote:
> Luiz Capitulino <lcapitulino@redhat.com> writes:
>
> > If the user issues one of the following commands to the Monitor:
> >
> > pci_add pci_addr=auto nic model=None
> > pci_add pci_addr=auto nic model=?
> >
> > QEMU will exit, because the function used to perform sanity
> > checks (qemu_check_nic_model_list()) exits on error.
>
> Yes. I meant to fix this, but you beat me to the line.
>
> There might be more bugs like this one.
Yeah.
> > This function is used by the startup code, where it makes
> > sense to exit on error, but in the Monitor it doesn't.
> >
> > Changing qemu_check_nic_model_list() to not exit on error
> > is not possible though, as it's used by the board init
> > code (the PC one), where all board specific code must have
> > void return.
> >
> > The way I've chosen to fix this was to introduce a new function
> > called pci_nic_supported(), which checks if the NIC is supported
> > and returns true or false accordingly.
> >
> > The new function is used only by the Monitor, it performs the
> > necessary check and returns an error in case the NIC is not
> > supported, thus qemu_check_nic_model_list()'s exit is never trigged.
> >
> > The following should be observed:
> >
> > 1. Only the specified NIC is checked, the default one is assumed
> > to be supported
> >
> > 2. The NIC query command (model=?) won't work with pci_add, the
> > right way to do this with the Monitor is to add a new command
> >
> > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
>
> It's a minimal fix, and I trust it works. But is it the proper fix?
Well, given the current situation I agree it's not perfect but
I think it's good enough.
> It works by checking the model before calling pci_nic_init() on behalf
> of monitor cmmand "pci_add ... nic ...", so that when pci_nic_init()
> checks the model again, it always succeeds, and thus never exits.
>
> My minor complaint is that the new model check pci_nic_supported()
> duplicates the existing check in qemu_check_nic_model_list().
Yes, I don't like this either.. Although qemu_check_nic_model_list()
also checks for the default model, this is a bonus check. :)
> My major complaint is that I'd rather see the code cleaned up there.
> It's perfectly fine for code that can run only during startup to
> terminate the program on configuration error. Code to be used after
> startup (used from monitor, in particular) must not do that. Instead,
> it should return failure up the call chain, until we reach either
> startup code or monitor code, where the policy how to handle the error
> resides.
What cleanup do you suggest?
Note that it's not only about exit(), the function also has some
fprintf()s. If a big refactor is needed to properly fix this,
I guess we will have to live with the bug for a long time...
next prev parent reply other threads:[~2009-09-24 19:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-24 14:16 [Qemu-devel] [PATCH] Fix exit on 'pci_add' Monitor command Luiz Capitulino
2009-09-24 18:12 ` Markus Armbruster
2009-09-24 19:31 ` Luiz Capitulino [this message]
2009-09-25 1:50 ` Markus Armbruster
2009-09-24 20:07 ` Mark McLoughlin
2009-09-25 1: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=20090924163123.5eec5c90@doriath \
--to=lcapitulino@redhat.com \
--cc=armbru@redhat.com \
--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).