qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] hw/qdev-monitor: report error for -device <not-


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH] hw/qdev-monitor: report error for -device <not-a-device-type>
Date: Wed, 28 Nov 2012 13:15:02 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121025 Thunderbird/16.0.2

Am 28.11.2012 12:54, schrieb Luiz Capitulino:
> On Wed, 28 Nov 2012 10:54:33 +0200
> Alon Levy <address@hidden> wrote:
> 
>> Instead of aborting immediately after at DEVICE_CLASS(obj)
>>
>> Signed-off-by: Alon Levy <address@hidden>
>> ---
>>  hw/qdev-monitor.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
>> index 479eecd..3b70cdb 100644
>> --- a/hw/qdev-monitor.c
>> +++ b/hw/qdev-monitor.c
>> @@ -426,6 +426,11 @@ DeviceState *qdev_device_add(QemuOpts *opts)
>>          return NULL;
>>      }
>>  
>> +    if (!object_class_dynamic_cast(obj, "device")) {

"device" should be TYPE_DEVICE.

>> +        qerror_report(QERR_INVALID_PARAMETER_TYPE, "driver", "device type");
>> +        return NULL;
>> +    }
> 
> Gives me the impression that something is wrong before this, but it's
> better to ask a QOM guy (CC'ing them).

What is definitely wrong here is the naming: "obj" is used for
ObjectClass rather than Object.
Therefore the use of object_class_dynamic_cast() is correct. I don't see
an earlier place to error out.

> 
> How do you reproduce it btw?

My guess is that trying to instantiate a non-device type needs to be
caught before using the mentioned asserting DEVICE_CLASS() macro below.

I.e. something like -device x86_64-cpu (non-abstract non-device type
currently) on qemu-system-x86_64, or easier -device container.

Regards,
Andreas

> 
>> +
>>      k = DEVICE_CLASS(obj);
>>  
>>      /* find bus */
> 

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



reply via email to

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