[PATCH RFC 0/2] Report OOM on VIR_ALLOC failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently, our code is plenty of following scheme:

  if (VIR_ALLOC(dummyPtr) < 0) {
      virReportOOMError();
      goto cleanup;
  }

or something similar. What if we just move the OOM reporting into
VIR_ALLOC? It would have three nice features:

1) sizeof(code base) gets lower. A lot lower.

2) even for callers which don't follow the schema described
   above, there is no harm reporting so serious error in the
   logs. No matter that the callee may fall back and return
   success.

3) Removing virReportOOMError() from the schema does not need to
   be done at once, but can be split into several patches. In the
   worst case scenario - the error gets reported twice.

But before I start working on other areas of code, I want to make
sure there's an agreement if this is even desired. As an example,
how much the code base will lose on weight, I've done the
conversion under src/util/:

  30 files changed, 81 insertions(+), 221 deletions(-)

Michal Privoznik (2):
  viralloc: Report OOM error on failure
  util: Don't report OOM twice

 src/util/iohelper.c              |  4 +---
 src/util/viralloc.c              | 23 ++++++++++++++++++-----
 src/util/viralloc.h              | 13 ++++++++-----
 src/util/virauthconfig.c         |  8 ++------
 src/util/vircommand.c            | 13 +++----------
 src/util/virconf.c               | 10 ++--------
 src/util/virdnsmasq.c            | 19 +++++++------------
 src/util/virerror.c              |  2 +-
 src/util/vireventpoll.c          |  4 +---
 src/util/virfile.c               |  4 +---
 src/util/virhash.c               | 10 ++--------
 src/util/virkeyfile.c            |  4 +---
 src/util/virlockspace.c          | 11 +++--------
 src/util/virnetdev.c             |  4 +---
 src/util/virnetdevbandwidth.c    | 12 +++---------
 src/util/virnetdevmacvlan.c      |  4 ++--
 src/util/virnetdevvlan.c         |  4 +---
 src/util/virnetdevvportprofile.c |  4 +---
 src/util/virnetlink.c            |  8 ++------
 src/util/virobject.c             |  9 ++++-----
 src/util/virpci.c                | 13 +++----------
 src/util/virprocess.c            |  4 +---
 src/util/virsexpr.c              |  4 +---
 src/util/virstoragefile.c        | 24 ++++++------------------
 src/util/virstring.c             |  5 +++--
 src/util/virsysinfo.c            |  8 +++-----
 src/util/virthreadpool.c         | 21 +++++----------------
 src/util/virtime.c               |  8 ++------
 src/util/virtypedparam.c         | 36 +++++++++---------------------------
 src/util/viruri.c                |  2 +-
 src/util/virusb.c                |  8 ++------
 src/util/virutil.c               | 36 ++++++++----------------------------
 src/util/virxml.c                |  1 -
 33 files changed, 108 insertions(+), 232 deletions(-)

-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]