From: Programmingkid <programmingkidx@gmail.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>, "Jeff Cody" <jcody@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"qemu-devel qemu-devel" <qemu-devel@nongnu.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] Should we auto-generate IDs? (was: [PATCH] qdev-monitor.c: Add device id generation)
Date: Wed, 26 Aug 2015 14:01:41 -0400 [thread overview]
Message-ID: <C68FAD04-1AC1-4285-A171-CF63F439719A@gmail.com> (raw)
In-Reply-To: <20150826175359.GA4528@redhat.com>
On Aug 26, 2015, at 1:53 PM, Daniel P. Berrange wrote:
> On Wed, Aug 26, 2015 at 01:46:43PM -0400, Programmingkid wrote:
>>
>> On Aug 26, 2015, at 1:28 PM, Daniel P. Berrange wrote:
>>
>>> On Tue, Aug 25, 2015 at 02:38:17PM +0200, 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 <programmingkidx@gmail.com> writes:
>>>>
>>>>> Add device ID generation to each device if an ID isn't given.
>>>>>
>>>>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>>>>>
>>>>> ---
>>>>> 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.
>>>>
>>>> Another useful addition would be *why* you want generated IDs. I
>>>> believe you do because you need them for device_del.
>>>>
>>>> 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.
>>>>
>>>> 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.
>>>>
>>>> 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).
>>>> Rule 3 then becomes moot.
>>>
>>> If QEMU auto-generates IDs, then the user still has to query QEMU to
>>> figure out what ID was assigned.
>>
>> Querying can be easy to do. Typing "info usb" in the monitor and
>> seeing the ID seems easy enough. The user can use the "device_del <id>" to
>> remove the device. I made a patch for "info usb" to print the ID of each
>> usb device.
>
> That only works if you look 'info usb' after adding each device. If
> you added multiple devices and then try to identify the ID after the
> fact it is not guaranteed unambiguous. Using 'info usb' is also not
> a general solution to the problem for other types of device.
>
>>> If the device was not assigned an
>>> ID, then it surely becomes hard for the user to identify which device
>>> they just added in order to ask what its ID is. Which is a chicken
>>> and egg problem. Even if the user could figure out what device they
>>> just added, why go to the extra trouble of querying QEMU to find out
>>> the auto-generated ID, when you could just provide an ID explicitly
>>> upfront avoiding the entire problem. IMHO auto-generating IDs is a
>>> just road to nowhere. Ideally we would mandate user provided IDs
>>> but we sadly can't for back-compat reasons.
>>
>> Auto-generated ID's can be a good thing. If the user adds a usb device
>> to QEMU, but forgot to give it an ID, QEMU can be nice enough to do it for
>> that user. This feature would make the monitor command device_del
>> actually useful in this situation. Right now if the user forgets to give a
>> device an ID, that user is out of luck when it comes time to removing
>> the device. This device id generation feature makes QEMU more
>> robust.
>
> If a user is talking to the QEMU monitor directly there are plenty of ways
> to go wrong, of which forgetting to provide an ID is a really minor one.
What other problems did you have in mind?
> That's why it is generally left to higher level mgmt layers to talk to
> QEMU and deal with all the issues in this area. IOW if users are talking
> to the monitor directly, IMHO they've already lost.
I'm not following you. What do you mean by higher level mgmt layers?
Let me put it this way, if a user were to add a usb device to QEMU, say
a usb-mouse, but forgot to give it an ID. How do you expect that user to
remove the device from QEMU?
next prev parent reply other threads:[~2015-08-26 18:01 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 18:53 [Qemu-devel] [PATCH] qdev-monitor.c: Add device id generation Programmingkid
2015-08-24 22:21 ` Eric Blake
2015-08-25 12:42 ` Markus Armbruster
2015-08-25 15:25 ` Programmingkid
2015-08-25 15:33 ` Peter Maydell
2015-08-25 15:50 ` Programmingkid
2015-08-25 18:30 ` Markus Armbruster
2015-08-25 19:05 ` Programmingkid
2015-08-25 14:33 ` Programmingkid
2015-08-25 12:38 ` [Qemu-devel] Should we auto-generate IDs? (was: [PATCH] qdev-monitor.c: Add device id generation) Markus Armbruster
2015-08-25 15:15 ` Programmingkid
2015-08-26 14:52 ` Programmingkid
2015-08-26 16:31 ` [Qemu-devel] Should we auto-generate IDs? Markus Armbruster
2015-08-26 17:16 ` Programmingkid
2015-08-26 18:45 ` Peter Maydell
2015-08-26 21:48 ` Programmingkid
2015-08-26 22:08 ` John Snow
2015-08-27 3:40 ` Programmingkid
2015-08-27 5:39 ` Markus Armbruster
2015-08-27 15:39 ` Programmingkid
2015-08-26 17:25 ` Jeff Cody
2015-08-26 17:29 ` Programmingkid
2015-08-26 18:08 ` Jeff Cody
2015-08-26 18:17 ` Programmingkid
2015-08-26 22:01 ` Jeff Cody
2015-08-26 22:04 ` John Snow
2015-08-27 3:26 ` Programmingkid
2015-08-27 3:22 ` Programmingkid
2015-08-27 12:32 ` Jeff Cody
2015-08-27 13:00 ` Eric Blake
2015-08-27 13:39 ` Programmingkid
2015-08-27 13:51 ` Daniel P. Berrange
2015-08-27 14:01 ` Eric Blake
2015-08-27 14:18 ` Jeff Cody
2015-08-27 14:19 ` Programmingkid
2015-08-27 14:01 ` Programmingkid
2015-08-27 18:59 ` John Snow
2015-08-27 19:20 ` Eric Blake
2015-08-27 13:33 ` Programmingkid
2015-08-27 13:49 ` Daniel P. Berrange
2015-08-27 13:56 ` Programmingkid
2015-08-27 14:02 ` Eric Blake
2015-08-27 14:34 ` Programmingkid
2015-08-27 14:42 ` Daniel P. Berrange
2015-08-27 15:20 ` Programmingkid
2015-08-27 15:40 ` Jeff Cody
2015-08-27 15:58 ` Programmingkid
2015-08-27 16:02 ` Daniel P. Berrange
2015-08-27 16:08 ` Programmingkid
2015-08-27 16:22 ` Daniel P. Berrange
2015-08-27 16:49 ` Programmingkid
2015-08-27 20:15 ` Programmingkid
2015-08-27 19:08 ` Jeff Cody
2015-08-27 19:27 ` Eric Blake
2015-08-27 20:37 ` Jeff Cody
2015-08-27 14:06 ` Daniel P. Berrange
2015-08-27 14:54 ` Programmingkid
2015-08-27 14:07 ` Jeff Cody
2015-08-27 15:13 ` Programmingkid
2015-08-27 15:19 ` Daniel P. Berrange
2015-08-27 15:22 ` Programmingkid
2015-08-27 15:55 ` Daniel P. Berrange
2015-08-27 16:03 ` Programmingkid
2015-08-27 16:06 ` Daniel P. Berrange
2015-08-27 16:08 ` Eric Blake
2015-09-01 12:34 ` Kevin Wolf
2015-09-01 14:18 ` Programmingkid
2015-09-01 14:43 ` Kevin Wolf
2015-09-01 15:55 ` Programmingkid
2015-09-03 14:34 ` Programmingkid
2015-09-03 14:43 ` Jeff Cody
2015-09-03 15:55 ` Programmingkid
2015-09-03 16:12 ` [Qemu-devel] [PATCH v3] qdev-monitor.c: Add device id generation Programmingkid
2015-08-26 17:28 ` [Qemu-devel] Should we auto-generate IDs? (was: [PATCH] qdev-monitor.c: Add device id generation) Daniel P. Berrange
2015-08-26 17:46 ` Programmingkid
2015-08-26 17:53 ` Daniel P. Berrange
2015-08-26 18:01 ` Programmingkid [this message]
2015-08-27 13:54 ` Daniel P. Berrange
2015-08-27 14:03 ` Programmingkid
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C68FAD04-1AC1-4285-A171-CF63F439719A@gmail.com \
--to=programmingkidx@gmail.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).