Change in vdsm[ovirt-3.5]: virt: Set cloexec flag on channel sockets
vfeenstr at redhat.com
vfeenstr at redhat.com
Fri Jan 15 08:18:37 UTC 2016
Hello Nir Soffer, Francesco Romani,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/51878
to review the following change.
Change subject: virt: Set cloexec flag on channel sockets
......................................................................
virt: Set cloexec flag on channel sockets
To counter act potential leakage of open handles, this patch is setting the
CLOEXEC flag on the sockets used for the guest agent channels.
It is known that this is not totally race free however it will still improve
the number of file handles leaked.
Change-Id: Ic4a452f7837267434bc836fced4c2efd92d745cf
Bug-Url: https://bugzilla.redhat.com/1226911
Signed-off-by: Vinzenz Feenstra <vfeenstr at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/42570
Reviewed-by: Francesco Romani <fromani at redhat.com>
Continuous-Integration: Jenkins CI
Reviewed-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/virt/guestagent.py
1 file changed, 10 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/78/51878/1
diff --git a/vdsm/virt/guestagent.py b/vdsm/virt/guestagent.py
index 3bab490..b5b45b7 100644
--- a/vdsm/virt/guestagent.py
+++ b/vdsm/virt/guestagent.py
@@ -27,6 +27,7 @@
# TODO: in future import from ..
import supervdsm
+from vdsm.infra import filecontrol
from . import vmstatus
@@ -97,6 +98,13 @@
return filt(obj)
+def _create_socket():
+ sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ filecontrol.set_close_on_exec(sock.fileno())
+ sock.setblocking(0)
+ return sock
+
+
class MessageState:
NORMAL = 'normal'
TOO_BIG = 'too-big'
@@ -117,7 +125,7 @@
self.effectiveApiVersion = _IMPLICIT_API_VERSION_ZERO
self.log = log
self._socketName = socketName
- self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ self._sock = _create_socket()
self._stopped = True
self.guestStatus = None
self.guestDiskMapping = {}
@@ -189,8 +197,7 @@
@staticmethod
def _create(self):
self._sock.close()
- self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- self._sock.setblocking(0)
+ self._sock = _create_socket()
return self._sock.fileno()
@staticmethod
--
To view, visit https://gerrit.ovirt.org/51878
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic4a452f7837267434bc836fced4c2efd92d745cf
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Vinzenz Feenstra <vfeenstr at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
More information about the vdsm-patches
mailing list