Re: Configuration vs. compat hints [was Re: [Qemu-devel] [PATCHv3 03/13] qemu: add routines to manage PCI capabilities]

Anthony Liguori
2009-06-15T13:20:30Z

Avi Kivity wrote:
> On 06/15/2009 03:45 PM, Anthony Liguori wrote:
>>>> This last option makes sense to me: in a real world the user has
>>>> control over where he places the device on the bus, so why
>>>> not with qemu?
>>>
>>> Yes, the user build the machine using the command line and monitor
>>> (or, in 2017, the machine configuration file),
>>
>>
>> Considering pbrook just posted a machine config for arm, I think it
>> would be rather sad if pc wasn't converted to it by 2017...
>
> I'd be sad too, but not surprised.
>
>>> then turns on the power. Command line options are the parts lying
>>> around when we start.
>>>
>>> btw, -drive needs to be separated:
>>>
>>> -controller type=lsi1234,pci_addr=foobar,name=blah
>>> -drive file=foo.img,controller=blah,index=0
>>> -drive file=bar.img,controller=blah,index=1
>>>
>>> Drives to not have pci addresses.
>>
>> Drivers don't have indexes and buses but we specify it on the -drive
>> line.
>
> Drives do have indexes. On old parallel scsi drives you set the index
> by clicking a button on the back of the drive to cycle through scsi
> addresses 0-7. An IDE drive's index is determined by the cable
> (master/slave). A SATA drive's index is determined by which header on
> the motherboard the drive connects to.

It's not at all that simple. SCSI has a hierarchical address mechanism
with 0-7 targets but then potentially multiple LUNs per target. Today,
we always emulate a single LUN per target but if we ever wanted to
support more than 7 disks on a SCSI controller, we would have to add
multiple LUN support too. So the current linear unit= parameter is
actually pretty broken for SCSI.

For IDE, it's a combination of bus, slot, and master/slave. For virtio,
it's just a PCI address. What we really need is something that is more
opaque and controller specific. For instance, if we were going to do
controllers...

-controller type=lsi1234,pci_addr=foobar,name=blah
-controller-disk controller=blah,target=0,lun=1,name=sda

-controller type=ide,pci_addr=barfoo,name=ide
-controller-disk controller=ide,slot=secondary,cable=slave,name=hdd

-drive file=foo.img,controller-disk=sda
-drive file=bar.img,controller-disk=hdd

And having "-hdd file=foo.img" be short-hand for "-drive
file=%s,controller-disk=%s".

>
>
> If by bus you mean the if= parameter, then drives certainly do have
> buses. Just try connecting the scsi drive from the previous paragraph
> to a USB port.

No, I meant drive file=foo.img,bus=3. If that doesn't seem obvious what
it should do to you that's because it isn't at all obvious :-) It ends
up skipping a predefined number of locations in the drive table. This
is pretty broken fundamentally because it assumes controllers always
support a fixed number of devices. Nothing really respects bus_id
though so in practice, I assume it's almost universally broken.

Regards,

Anthony Liguori