[libvirt] [GSoC] Design ideas for implementing cleanup attribute

2018-03-24 Thread Sukrit Bhatnagar
Hi,

I am interested in implementing the GCC cleanup attribute for automatic
resource freeing as part of GSoC'18. I have shared a proposal for the same.

This mail is to discuss the code design for implementing it.


Here are some of my ideas:

This attribute requires a cleanup function that is called automatically
when the corresponding variable goes out of scope. There are some functions
whose logic can be reused:

- Functions such as virCommandFree, virConfFreeList and virCgroupFree can
be directly used as cleanup functions. They have parameter and return type
valid for a cleanup function.

- Functions such as virFileClose and virFileFclose need some additional
consideration as they return a value. I think we can set some global
variable in a separate source file (just like errno variable from errno.h).
Then the value to be returned can be accessed globally.

- Functions such as virDomainEventGraphicsDispose need an entirely new
design. They are used as callbacks in object classes and passed as an
argument in virClassNew. This would require making changes to
virObjectUnref's code too. *This is the part I am not sure how to implement
cleanup logic for.*


Also, since the __attribute__((__cleanup__(anyfunc))) looks ugly, a macro
like autoclean (ideas for macro name welcome!) can be used instead. As
Martin pointed out in my proposal, for some types, this can be done right
after typedef declarations, so that the type itself contains this attribute.

Basically, at most places where VIR_FREE is used to release memory
explicitly, the corresponding variable can use the attribute. The existing
virFree function also can be reused as it takes void pointer as an argument
and returns nothing.
One of the exceptions to this will be those variables which are struct
members. The cleanup of member has to be done when the enclosing struct
variable is cleaned.

I can create new files vircleanup.{c,h} for defining cleanup functions for
types which do not have an existing cleanup/free function. This can be done
separately for each driver supported.
For example, cleanups pertaining to lxc driver will be in
src/lxc/lxc_cleanup.c.


Your suggestions are welcome.


Thanks,
Sukrit Bhatnagar
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] build: Remove --with-xml-catalog-file option

2018-03-24 Thread Ján Tomko

On Fri, Mar 23, 2018 at 09:36:34PM +0100, Rainer Müller wrote:

After validation against XHTML 1.0 was dropped in f802c9de0,
the XML_CATALOG_FILE is not in use anymore. Therefore the checks in
configure can be removed.
---
configure.ac   |  3 ---
m4/virt-xml-catalog.m4 | 33 -
2 files changed, 36 deletions(-)
delete mode 100644 m4/virt-xml-catalog.m4


Nice diffstat!

However, as said in our HACKING guide, general tip #6:
https://libvirt.org/hacking.html#patches
we require a sign-off for every patch.

Could you please provide one to certify that you deleted all those
useless lines of code in compliance with DCO:
https://developercertificate.org/

Thanks,

Jan


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list