|
From: | Anthony Liguori |
Subject: | Re: [Qemu-devel] qdev: Some ISA devices don't handle second instantiation gracefully |
Date: | Tue, 12 Oct 2010 08:27:21 -0500 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100915 Lightning/1.0b1 Thunderbird/3.0.8 |
On 10/12/2010 08:00 AM, Markus Armbruster wrote:
Markus Armbruster<address@hidden> writes:When I try -device isa-applesmc -device isa-applesmc, I get WARNING: Using AppleSMC with invalid key qemu: hardware error: register_ioport_read: invalid opaque [...] and a core dump. I know nothing about this device. Instantiating twice may well make no sense. But hw_error() is not a nice way to reject a command line option.Actually, ib700 and isa-debugcon fail the same way. They call register_ioport_write(), which aborts via hw_error() when the port is already in use. This is okay for non-configurable parts of a board emulation, but not okay for a qdev device, unless it has no_user set.
It's definitely right to fail but I agree, it's better to propagate the error.
Related: when isa_init_irq() finds the requested IRQ already in use, it fails with exit(1). Maybe register_ioport_write()& friends should do that as well. Or maybe qdev device models should have an "at most one" flag.
I think the proper thing to do is remove all exit(1)s and propagate errors instead.
A simple approach would be to make register_ioport_{read,write}() return an int, then do a query-replace on the source tree to make all invocations of it simply check the return value and exit if it's non-zero.
Regards, Anthony Liguori
[Prev in Thread] | Current Thread | [Next in Thread] |