Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign uptests leak file descriptors #1380
Comments
marmarek
added
bug
P: minor
C: tests
labels
Nov 5, 2015
marmarek
added this to the Release 3.1 milestone
Nov 5, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
marmarek
Nov 5, 2015
Member
@woju any idea? This wouldn't be the first place where not properly releasing QubesVM objects have some downsides...
|
@woju any idea? This wouldn't be the first place where not properly releasing QubesVM objects have some downsides... |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
woju
Nov 5, 2015
Member
On Wed, Nov 04, 2015 at 05:44:11PM -0800, Marek Marczykowski-Górecki wrote:
@woju any idea? This wouldn't be the first place where not properly
releasing QubesVM objects have some downsides...
If self.conn.close() won't really close them, that's bug in libvirt or
that python wrapper of theirs...
|
On Wed, Nov 04, 2015 at 05:44:11PM -0800, Marek Marczykowski-Górecki wrote:
If self.conn.close() won't really close them, that's bug in libvirt or |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
marmarek
Nov 5, 2015
Member
self.conn.close() only decrease refcount, by design:
http://libvirt.org/html/libvirt-libvirt-host.html#virConnectClose
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
|
self.conn.close() only decrease refcount, by design: Best Regards, |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
woju
Nov 5, 2015
Member
On Thu, Nov 05, 2015 at 01:21:58PM -0800, Marek Marczykowski-Górecki wrote:
self.conn.close() only decrease refcount, by design:
http://libvirt.org/html/libvirt-libvirt-host.html#virConnectClose
Ah, if so, then judging by http://libvirt.org/git/?p=libvirt-python.git;a=blob;f=libvirt-override-virConnect.py#l11
the descriptor is freed when the virConnect is garbage collected.
See https://docs.python.org/2/reference/datamodel.html#object.__del__,
particulary the "Note:" there.
|
On Thu, Nov 05, 2015 at 01:21:58PM -0800, Marek Marczykowski-Górecki wrote:
Ah, if so, then judging by http://libvirt.org/git/?p=libvirt-python.git;a=blob;f=libvirt-override-virConnect.py#l11 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
marmarek
Nov 5, 2015
Member
Great. So how can we fix that? Preferably in some generic way...
As a workaround, I see we may simply iterate over each QubesVM object
and release vm.libvirt_domain (del?). But this is neither elegant, nor
complete (probably will not handle qubes.xml reload, VM restarts and
such).
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
|
Great. So how can we fix that? Preferably in some generic way... Best Regards, |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
woju
Nov 6, 2015
Member
On Thu, Nov 05, 2015 at 03:42:04PM -0800, Marek Marczykowski-Górecki wrote:
Great. So how can we fix that? Preferably in some generic way...
As a workaround, I see we may simply iterate over each QubesVM object
and release vm.libvirt_domain (del?). But this is neither elegant, nor
complete (probably will not handle qubes.xml reload, VM restarts and
such).
We could make a wrapper around the object, which will be wrapper's
private attribute. No one else will have reference to it. The wrapper
will pass most of the calls untouched, but the close() call will be done
in such a way that will ensure freeing the descriptor.
|
On Thu, Nov 05, 2015 at 03:42:04PM -0800, Marek Marczykowski-Górecki wrote:
We could make a wrapper around the object, which will be wrapper's |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
marmarek
Nov 6, 2015
Member
Ok, a simple test reveals that libvirt_conn.close() doesn't work at all:
c = libvirt.open('xen:///')
c.close()
del c
And the socket is still open. I'm still not sure where the problem is
- our usage, or libvirt pythin bindings. But I tend to think the later
one.
Anyway, can we not open a new libvirt connection for every single test?
Instead, reuse vmm.libvirt_conn for that. Any drawbacks?
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
|
Ok, a simple test reveals that libvirt_conn.close() doesn't work at all:
And the socket is still open. I'm still not sure where the problem is
Anyway, can we not open a new libvirt connection for every single test? Best Regards, |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
marmarek
Nov 6, 2015
Member
Found it. When some event loop implementation is registered (libvirt.virEventRegisterDefaultImpl), connections are closed as part of that event loop (libvirt.virEventRunDefaultImpl). We do not call it (when running tests).
Actually FD leak is not the only problem - the other is not sending keep-alives - which we had to disable on daemon side because of that.
Background
- We need that event loop for handling libvirt events, in Qubes Manager (through QubesWatch)
libvirt.virEventRegisterDefaultImpl(or otherlibvirt.virEventRegisterImpl) must be called before opening the connection
For now (R3.1 or even backport for R3.0)
I see two options here:
- Always start a event loop, not only in Qubes Manager
- Try to register event loop only when needed (which probably would involve opening another connection after registering it)
I think I've already tried the second option some time ago (but I maybe not tried with the second connection). That would be better (performance wise) than starting event loop for every qvm-ls. On the other hand, qvm-backup could use keep-alives. Anyway I'll retry the second option and fallback to the first one.
For R4.0/R4.1 (qubesd)
It will not be needed anymore, since "client" tools will not speak to libvirt directly.
|
Found it. When some event loop implementation is registered ( Background
For now (R3.1 or even backport for R3.0)I see two options here:
I think I've already tried the second option some time ago (but I maybe not tried with the second connection). That would be better (performance wise) than starting event loop for every For R4.0/R4.1 (qubesd)It will not be needed anymore, since "client" tools will not speak to libvirt directly. |
marmarek
self-assigned this
Nov 7, 2015
marmarek
closed this
in
QubesOS/qubes-core-admin@d388838
Nov 7, 2015
added a commit
to QubesOS/qubes-core-admin
that referenced
this issue
Nov 7, 2015
added a commit
to QubesOS/qubes-core-admin
that referenced
this issue
Nov 15, 2015
added a commit
to QubesOS/qubes-core-admin
that referenced
this issue
Nov 15, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
marmarek
Nov 15, 2015
Member
Automated announcement from builder-github
The package qubes-core-dom0-3.0.26-1.fc20 has been pushed to the r3.0 testing repository for dom0.
To test this update, please install it with the following command:
sudo qubes-dom0-update --enablerepo=qubes-dom0-current-testing
|
Automated announcement from builder-github The package
|
marmarek
added
the
r3.0-dom0-testing
label
Nov 15, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
marmarek
Nov 29, 2015
Member
Automated announcement from builder-github
The package qubes-core-dom0-3.0.26-1.fc20 has been pushed to the r3.0 stable repository for dom0.
To install this update, please use the standard update command:
sudo qubes-dom0-update
Or update dom0 via Qubes Manager.
|
Automated announcement from builder-github The package
Or update dom0 via Qubes Manager. |
marmarek commentedNov 5, 2015
When running a lot of tests in one call it eventually leads to "Too many open files" error.
Some preliminary debugging with strace reveals that:
self.conn.close()does not close themI guess it's because the connection is still referenced from a couple of QubesVm objects (
vm.libvirt_domain), which aren't garbage collected because of some circular dependency (or some other reason). The same probably applies to QubesDB connections.