getfd qmp command will be used to pass an fd using SCM_RIGHTS
and name it properly so that NIC hot-add can take place.

Signed-off-by: Dimitris Aragiorgis <[email protected]>
---
 lib/hypervisor/hv_kvm/monitor.py |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/lib/hypervisor/hv_kvm/monitor.py b/lib/hypervisor/hv_kvm/monitor.py
index bff82f2..8c266ed 100644
--- a/lib/hypervisor/hv_kvm/monitor.py
+++ b/lib/hypervisor/hv_kvm/monitor.py
@@ -432,6 +432,29 @@ class QmpConnection(MonitorSocket):
 
       return response[self._RETURN_KEY]
 
+  def GetFd(self, fd, fdname):
+    """Wrapper around getfd qmp command
+
+    Use fdsend to send fd to a running process via SCM_RIGHTS and then getfd
+    qmp command to name them properly so that they can be used later by NIC
+    hotplugging.
+
+    @type fd: int
+    @param fd: The file descriptor to pass
+    @raise errors.HypervisorError: If getfd fails for some reason
+
+    """
+    self._check_connection()
+    try:
+      fdsend.sendfds(self.sock, " ", fds=[fd])
+      arguments = {
+          "fdname": fdname,
+          }
+      self.Execute("getfd", arguments)
+    except errors.HypervisorError, err:
+      logging.info("Passing fd %s via SCM_RIGHTS failed: %s", fd, err)
+      raise
+
   def AddFd(self, fd):
     """Wrapper around add-fd qmp command
 
-- 
1.7.10.4

Reply via email to