A couple minor notes below On Fri, 2020-04-03 at 17:15 +0200, Rafael Fonseca wrote: > Signed-off-by: Rafael Fonseca <r4f4rfs@xxxxxxxxx> > --- > src/conf/capabilities.c | 3 +- > src/conf/domain_conf.c | 21 +++--- > src/util/virresctrl.c | 137 ++++++++++++++++++++++-------------- > ---- > src/util/virresctrl.h | 15 +++-- > tests/virresctrltest.c | 3 +- > 5 files changed, 97 insertions(+), 82 deletions(-) > > diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c > index 99b69aebb5..2c91461a54 100644 > [SNIP] > @@ -419,38 +423,62 @@ virResctrlAllocDispose(void *obj) > VIR_FREE(alloc->id); > VIR_FREE(alloc->path); > VIR_FREE(alloc->levels); > + > + G_OBJECT_CLASS(vir_resctrl_alloc_parent_class)->finalize(obj); > } > > > static void > -virResctrlMonitorDispose(void *obj) > +virResctrlMonitorFinalize(GObject *obj) > { > - virResctrlMonitorPtr monitor = obj; > + virResctrlMonitorPtr monitor = VIR_RESCTRL_MONITOR(obj); > > - virObjectUnref(monitor->alloc); > + if (monitor->alloc) > + g_object_unref(monitor->alloc); In general, releasing a reference to a member GObject should be done in the 'dispose' function rather than the 'finalize' function. In this specific case, it probably doesn't make any real difference, but I'd rather stick to recommended behavior. See https://developer.gnome.org/gobject/stable/gobject-memory.html#gobject-memory-cycles for more details. [SNIP] > @@ -1884,8 +1898,8 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr > info) > virBitmapFree(mask); > return ret; > error: > - virObjectUnref(ret); > - ret = NULL; > + if (ret) > + g_clear_object(&ret); g_clear_object() does nothing if ret is NULL, so there's no need to check for non-NULL before calling it.