]> xenbits.xensource.com Git - libvirt.git/commit
util: restructure virNetDevReadNetConfig() to eliminate false error logs
authorLaine Stump <laine@laine.org>
Thu, 10 Aug 2017 00:49:26 +0000 (20:49 -0400)
committerLaine Stump <laine@laine.org>
Fri, 11 Aug 2017 23:09:49 +0000 (19:09 -0400)
commit9a08168301466dde301adedb9b567590b5968e32
tree80d753c218c7e14cf1220eb2e786fde02ee2fb71
parentb67eaa63518dcdc1f9176cf3e749823bc5da21d2
util: restructure virNetDevReadNetConfig() to eliminate false error logs

virHostdevRestoreNetConfig() calls virNetDevReadNetConfig() to try and
read the "original config" of a netdev, and if that fails, it tries
again with a different directory/netdev name. This achieves the
desired effect (we end up finding the config wherever it may be), but
for each failure, virNetDevReadNetConfig() places a nice error message
in the system logs. Experience has shown that false-positive error
logs like this lead to erroneous bug reports, and can often mislead
those searching for *real* bugs.

This patch changes virNetDevReadNetConfig() to explicitly check if the
file exists before calling virFileReadAll(); if it doesn't exist,
virNetDevReadNetConfig() returns a success, but leaves all the
variables holding the results as NULL. (This makes sense if you define
the purpose of the function as "read a netdev's config from its config
file *if that file exists*).

To take advantage of that change, the caller,
virHostdevRestoreNetConfig() is modified to fail immediately if
virNetDevReadNetConfig() returns an error, and otherwise to try the
different directory/netdev name if adminMAC & vlan & MAC are all NULL
after the preceding attempt.
src/util/virhostdev.c
src/util/virnetdev.c
src/util/virnetdevmacvlan.c