On Tue 21 Jun 2016 11:36:24 PM CEST, Eric Blake <[email protected]> wrote: > On 06/21/2016 06:27 AM, Alberto Garcia wrote: >> On Mon 20 Jun 2016 08:53:08 PM CEST, Eric Blake wrote: >>>> +static BlockJob *find_block_job(const char *id, const char *device, >>>> + AioContext **aio_context, Error **errp) >>> >>> Can this signature just be const char *id_or_device, rather than two >>> parameters,... >> >> But what if there's a name clash? > > All jobs have an id. And legacy users never set an id, so the id of > legacy jobs will always be generated (and you can tell by the # > character in the name that it was a generated id). Basically, I'm > proposing a hierarchical lookup: If the id matches, then you use it. If > the id doesn't match, then do a device lookup name. New code that knows > to set the id should never pass anything but valid ids, so we only have > to worry about the case of new code trying to check the status of a job > that no longer exists and accidentally getting the status of an > unrelated job that happened to belong to a device with the same name - > but any new code shouldn't be that stupid as to use job ids that match > device ids.
Yeah, it *shouldn't*, but is it a good idea to leave this door open just to have a slightly simpler internal API? Berto
