]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virNWFilterBindingObjListAddLocked: Produce better error message than 'Duplicate...
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 19 Mar 2019 13:39:20 +0000 (14:39 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 4 Apr 2019 07:16:24 +0000 (09:16 +0200)
commitb701e45be5e80b4670dadacac70d9fa51599dec8
tree0c9618ce554f02640f23b0e472e03f338044da32
parenta5c71129bf2c12a827f1bc00149acd1c572ffe9c
virNWFilterBindingObjListAddLocked: Produce better error message than 'Duplicate key'

If there are two concurrent threads, one of which is removing an
nwfilter from the list and the other is trying to add it back they
may serialize in the following order:

1) obj->removing is set and @obj is unlocked.
2) The tread that's trying to add the nwfilter onto the list locks
   the list and tries to find, if the nwfilter already exists.
3) Our lookup functions say it doesn't, so the thread proceeds to
   virHashAddEntry() which fails with 'Duplicate key' error.

This is obviously not helpful error message at all.

The problem lies in our lookup function
(virNWFilterBindingObjListFindByPortDevLocked()) which return
NULL even if the object is still on the list. They do this so
that the object is not mistakenly looked up by some API. The fix
consists of moving 'removing' check one level up and thus
allowing virNWFilterBindingObjListAddLocked() to produce
meaningful error message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
src/conf/virnwfilterbindingobjlist.c