qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 04/11] qdev: pcibus_dev_info


From: Luiz Capitulino
Subject: Re: [Qemu-devel] [PATCH 04/11] qdev: pcibus_dev_info
Date: Tue, 29 Dec 2009 15:08:40 -0200

On Sat, 26 Dec 2009 21:19:15 +0000
Nathan Baum <address@hidden> wrote:

> +static QObject *pcibus_dev_info(Monitor *mon, DeviceState *dev)
> +{
> +    PCIDevice *d = (PCIDevice *)dev;
> +    const pci_class_desc *desc;
> +    PCIIORegion *r;
> +    int i, class;
> +    QObject *retval;
> +    QList *regions;
> +    
> +    retval = qobject_from_jsonf("{ 'addr': { 'bus' : %d, 'slot' : %d, 
> 'func': %d }, "
> +                                "  'device': { 'vendor': %d, 'id': %d }, "
> +                                "  'subsystem': { 'vendor': %d, 'id': %d } "
> +                                "}",

 You can have 'address' here.

> +    class = pci_get_word(d->config + PCI_CLASS_DEVICE);
> +    desc = pci_class_descriptions;
> +    while (desc->desc && class != desc->class)
> +        desc++;
> +    if (desc->desc) {
> +        qdict_put(qobject_to_qdict(retval), "class", 
> qstring_from_str(desc->desc));
> +    } else {
> +        qdict_put(qobject_to_qdict(retval), "class", qint_from_int(class));
> +    }

 I think it's not good to return different data types for the same key, as
it will make clients more complex, what you can do here is to make 'class'
a QDict with members 'desc' and 'number'.




reply via email to

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