On 17.12.24 18:33, Anthony PERARD wrote:
On Tue, Dec 17, 2024 at 03:22:18PM +0100, Juergen Gross wrote:diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index 64c8fd0cc3..a6506a5bb2 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -1258,15 +1248,9 @@ void domain_early_init(void) if (!domhash) barf_perror("Failed to allocate domain hashtable");- xc_handle = talloc(talloc_autofree_context(), xc_interface*);- if (!xc_handle) - barf_perror("Failed to allocate domain handle"); - - *xc_handle = xc_interface_open(0,0,0); - if (!*xc_handle) - barf_perror("Failed to open connection to hypervisor"); - - talloc_set_destructor(xc_handle, close_xc_handle); + xm_handle = xenmanage_open(NULL, 0); + if (!xm_handle) + barf_perror("Failed to open connection to libxenmanage");xgt_handle = talloc(talloc_autofree_context(), xengnttab_handle*);if (!xgt_handle) @@ -1306,6 +1290,8 @@ void domain_deinit(void) { if (virq_port) xenevtchn_unbind(xce_handle, virq_port); + + xenmanage_close(xm_handle);Is this the rigth place to free `xm_handle`? domain_deinit() seems to only be called by the live update code. All the other initialisation done in domain_early_init() are free via talloc_autofree() it seems, which is called by atexit(). So, shouldn't `xm_handle` by handle with talloc like the others?
No, I don't think so. TBH, I'm questioning the talloc() allocation of the other handles, too. The only case where xenstored is stopped IS the live update case. Apart from crashes, of course, but those won't execute the destructors either. Juergen
OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key
OpenPGP_signature.asc
Description: OpenPGP digital signature