qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Should we auto-generate IDs? (was: [PATCH] qdev-monitor


From: Programmingkid
Subject: Re: [Qemu-devel] Should we auto-generate IDs? (was: [PATCH] qdev-monitor.c: Add device id generation)
Date: Tue, 25 Aug 2015 11:15:01 -0400

On Aug 25, 2015, at 8:38 AM, Markus Armbruster wrote:

> You're proposing to revise a qdev design decision, namely the purpose of
> IDs.  This has been discussed before, and IDs remained unchanged.
> Perhaps it's time to revisit this issue.  Cc'ing a few more people.
> 
> Relevant prior threads:
> * [PATCH] qdev: Reject duplicate and anti-social device IDs
>  http://thread.gmane.org/gmane.comp.emulators.qemu/71230/focus=72272
> * [PATCH 6/6] qdev: Generate IDs for anonymous devices
>  http://thread.gmane.org/gmane.comp.emulators.qemu/114853/focus=114858
> * [PATCH] qdev: Assign a default device ID when none is provided.
>  http://thread.gmane.org/gmane.comp.emulators.qemu/249702
> * IDs in QOM (was: [PATCH] util: Emancipate id_wellformed() from QemuOpt
>  http://thread.gmane.org/gmane.comp.emulators.qemu/299945/focus=300381
> 
> Probably more I can't remember anymore :)
> 
> Programmingkid <address@hidden> writes:
> 
>> Add device ID generation to each device if an ID isn't given.
>> 
>> Signed-off-by: John Arbuckle <address@hidden>
>> 
>> ---
>> This patch can be tested by adding adding usb devices using the monitor.
>> Start QEMU with the -usb option. Then go to the monitor and type
>> "device_add usb-mouse". The ID of the device will be set to a number.
>> Since QEMU will not allow an user to add a device with an ID set to a
>> number, there is no chance for ID collisions. 
> 
> The second sentence should really be part of your commit message.
> The first sentence wouldn't hurt, either.
Ok.

> Another useful addition would be *why* you want generated IDs.  I
> believe you do because you need them for device_del.
Sounds like a good idea.

> 
> In prior discussion, we always concluded that device_del should accept
> QOM paths.  It still doesn't.
> 
> Many things in QEMU have IDs.  They all work pretty much the same:
> 
> 1. The ID is set by the user.  If the user doesn't, there is none.
> 
>   Exception: a few old interfaces set well-known IDs.  If the user uses
>   these interfaces, he needs to take care that his own IDs don't clash.
> 
>   Example: drive_add picks an ID based on interface type, media type,
>   bus and unit number.  blockdev_add doesn't.  Instead, it requires the
>   user to pick one.
> 
> 2. The ID must be well-formed.
> 
>   Exception: inconsistently enforced for QOM, see last thread quoted
>   above.

This is a definite possibility. All USB devices could be given a id like this:
USB<number>. All block devices could be HD<number>. 

> 
> 3. If the user may need to address the thing, either the ID must be
>   mandatory, or there has to be another way to address it.
> 
>   Example: netdev-add requires ID.  Rationale: the only way to put it
>   to use is referencing it from a device, and that requires an ID.
> 
>   Example: device_add doesn't require ID.  If you don't specify one,
>   you can't device_del it.  Annoying trap for the unwary.  There are
>   *two* other ways to address it: qdev path and QOM path.  qdev path is
>   basically too botched to be usable.  QOM path should do just fine,
>   but device_del doesn't accept it.  It could.
After looking up what a QOM path looks like 
(/i440fx/slot[1.0]/bus/piix3/i8042/aux)
I'm thinking that would not be a good idea. It is an awful
lot to type. It isn't as user friendly as using something simple like USB1 or 
HD3. 

> We could revise rule 1 to always generate IDs, in a way that can't clash
> with the user's IDs (impossible unless rule 2 is actually observed).

I think if we follow the rule that only QEMU can give an ID that is only a 
number,
we should be fine. That seems to be the rule now. 

> Rule 3 then becomes moot.
> 
> Whatever we do, I want it done consistently.  I don't want different
> rules for different kinds of IDs.
Agreed. Maybe we should include an easy and consistent way of finding out these 
ID's.

Wow, didn't think this patch to fix USB device removal would have such 
consequences. 



reply via email to

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