On Thu, 02 May 2013 08:41:50 -0500
Anthony Liguori <[email protected]> wrote:
> >> +
> >> + if (strcmp(type, "ide-cd") == 0) {
> >> + disk_type = DT_CDROM;
> >> + } else if (strcmp(type, "isa-fdc") == 0) {
> >> + disk_type = DT_FLOPPY;
> >> + } else {
> >> + disk_type = DT_NORMAL;
> >> + }
> >
> > Same thing here, comparing against strings is a hack. Devices should
> > probably have a property that says what kind of device they are.
>
> Ack, this is nasty. I would like to eliminate this. There is a type
> field in BlockInfo but:
>
> # @type: This field is returned only for compatibility reasons, it should
> # not be used (always returns 'unknown')
>
> I vaguely remember this happening but I don't remember the specific
> reason why. I would definitely prefer that we filled out type
> correctly.
>
> I think Markus was involved in this. Markus or Luiz, do you remember
> the story here?
IIRC, we had a type field which was a string and Markus eliminated it
because it was unreliable. I was afraid that dropping fields from a QMP
output would be incompatible, so Markus maintained the field but it's
always set to 'unknown'.
It seems totally fine to me to have a new field with the device type
as an enum, but of course it has to be reliable.
PS: For more information about the reliableness of this field please
contact Markus :)