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.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to