Re: [Qemu-block] [RFC v4 08/13] ide: enumerate_slots implementation

2017-08-18 Thread Eduardo Habkost
On Wed, Aug 16, 2017 at 05:46:18PM -0400, John Snow wrote:
> 
> 
> On 08/14/2017 05:57 PM, Eduardo Habkost wrote:
> > Example output when using "-machine q35":
> > 
> >   {
> > "available": true,
> > "count": 1,
> > "device-types": [
> >   "ide-device"
> > ],
> > "hotpluggable": false,
> > "opts": [
> >   { "option": "unit", "values": 0 },
> >   { "option": "bus", "values": "ide.2" }
> > ],
> > "opts-complete": true
> >   }
> >   {
> > "available": false,
> > "count": 1,
> > "device": "/machine/unattached/device[19]",
> > "device-types": [
> >   "ide-device"
> > ],
> > "hotpluggable": false,
> > "opts": [
> >   { "option": "unit", "values": 1 },
> >   { "option": "bus", "values": "ide.2" } ],
> > "opts-complete": true
> >   }
> >   {
> > "available": true,
> > "count": 10,
> > "device-types": [
> >   "ide-device"
> > ],
> > "hotpluggable": false,
> > "opts": [
> >   { "option": "unit", "values": [ [ 0, 1 ] ] },
> 
> Hm, these unit values aren't really correct -- we do not support
> primary/secondary semantics for IDE buses on the AHCI device. I guess
> they technically exist, but you cannot use them for anything.
> 
> Should I do something to "disable" or otherwise hide the unusable
> secondary unit slots for AHCI devices?

If the device is already rejecting -device ...,unit=1, then the
bug is in my implementation of enumerate_devices.  Maybe it
should just look at IDEBus::max_units to find that out?

-- 
Eduardo



Re: [Qemu-block] [RFC v4 08/13] ide: enumerate_slots implementation

2017-08-16 Thread John Snow


On 08/14/2017 05:57 PM, Eduardo Habkost wrote:
> Example output when using "-machine q35":
> 
>   {
> "available": true,
> "count": 1,
> "device-types": [
>   "ide-device"
> ],
> "hotpluggable": false,
> "opts": [
>   { "option": "unit", "values": 0 },
>   { "option": "bus", "values": "ide.2" }
> ],
> "opts-complete": true
>   }
>   {
> "available": false,
> "count": 1,
> "device": "/machine/unattached/device[19]",
> "device-types": [
>   "ide-device"
> ],
> "hotpluggable": false,
> "opts": [
>   { "option": "unit", "values": 1 },
>   { "option": "bus", "values": "ide.2" } ],
> "opts-complete": true
>   }
>   {
> "available": true,
> "count": 10,
> "device-types": [
>   "ide-device"
> ],
> "hotpluggable": false,
> "opts": [
>   { "option": "unit", "values": [ [ 0, 1 ] ] },

Hm, these unit values aren't really correct -- we do not support
primary/secondary semantics for IDE buses on the AHCI device. I guess
they technically exist, but you cannot use them for anything.

Should I do something to "disable" or otherwise hide the unusable
secondary unit slots for AHCI devices?

--js

>   { "option": "bus", "values": [ "ide.4", "ide.3", "ide.5", "ide.0", 
> "ide.1" ] }
> ],
> "opts-complete": true
>   }
> 
> Cc: John Snow 
> Cc: qemu-block@nongnu.org
> Signed-off-by: Eduardo Habkost 
> ---
>  hw/ide/qdev.c | 26 ++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
> index f17da1f..cc96f6f 100644
> --- a/hw/ide/qdev.c
> +++ b/hw/ide/qdev.c
> @@ -25,6 +25,7 @@
>  #include "sysemu/block-backend.h"
>  #include "sysemu/blockdev.h"
>  #include "hw/block/block.h"
> +#include "hw/qdev-slotinfo.h"
>  #include "sysemu/sysemu.h"
>  #include "qapi/visitor.h"
>  
> @@ -38,6 +39,30 @@ static Property ide_props[] = {
>  DEFINE_PROP_END_OF_LIST(),
>  };
>  
> +static DeviceSlotInfoList *ide_bus_enumerate_slots(BusState *bus)
> +{
> +int unit;
> +DeviceSlotInfoList *r = NULL;
> +IDEBus *ib = IDE_BUS(bus);
> +
> +for (unit = 0; unit < 2; unit++) {
> +DeviceSlotInfo *s = make_slot(bus);
> +IDEDevice *dev = (unit ? ib->master : ib->slave);
> +slot_add_opt_int(s, "unit", unit);
> +s->opts_complete = true;
> +s->has_count = true;
> +s->count = 1;
> +if (dev) {
> +s->available = false;
> +s->has_device = true;
> +s->device = object_get_canonical_path(OBJECT(dev));
> +}
> +slot_list_add_slot(, s);
> +}
> +
> +return r;
> +}
> +
>  static void ide_bus_class_init(ObjectClass *klass, void *data)
>  {
>  BusClass *k = BUS_CLASS(klass);
> @@ -45,6 +70,7 @@ static void ide_bus_class_init(ObjectClass *klass, void 
> *data)
>  k->get_fw_dev_path = idebus_get_fw_dev_path;
>  k->unrealize = idebus_unrealize;
>  k->device_type = TYPE_IDE_DEVICE;
> +k->enumerate_slots = ide_bus_enumerate_slots;
>  }
>  
>  static void idebus_unrealize(BusState *bus, Error **errp)
>