The KVM daemon keeps a persistent connection to the instances' QMP
sockets, listening for asynchronous events. As each monitor socket
(either human, or QMP) can handle only one client at a time, this has
the side-effect that QMP cannot be used for regular instance operations.

We fix this by adding a dedicated QMP socket for use by kvmd and
changing kvmd to look only for sockets with the specific extension.

Note that this change means that kvmd will not be able to monitor
already running instances spawned by older versions of Ganeti.

Signed-off-by: Apollon Oikonomopoulos <[email protected]>
---
 lib/hypervisor/hv_kvm.py | 10 ++++++++++
 src/Ganeti/Kvmd.hs       |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py
index f3cc177..1ec4ccc 100644
--- a/lib/hypervisor/hv_kvm.py
+++ b/lib/hypervisor/hv_kvm.py
@@ -926,6 +926,13 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     return utils.PathJoin(cls._CTRL_DIR, "%s.qmp" % instance_name)
 
   @classmethod
+  def _InstanceKvmdMonitor(cls, instance_name):
+    """Returns the instance kvm daemon socket name
+
+    """
+    return utils.PathJoin(cls._CTRL_DIR, "%s.kvmd" % instance_name)
+
+  @classmethod
   def _InstanceShutdownMonitor(cls, instance_name):
     """Returns the instance QMP output filename
 
@@ -1929,6 +1936,9 @@ class KVMHypervisor(hv_base.BaseHypervisor):
       logging.debug("Enabling QMP")
       kvm_cmd.extend(["-qmp", "unix:%s,server,nowait" %
                       self._InstanceQmpMonitor(instance.name)])
+      # Add a second monitor for kvmd
+      kvm_cmd.extend(["-qmp", "unix:%s,server,nowait" %
+                      self._InstanceKvmdMonitor(instance.name)])
 
     # Configure the network now for starting instances and bridged interfaces,
     # during FinalizeMigration for incoming instances' routed interfaces
diff --git a/src/Ganeti/Kvmd.hs b/src/Ganeti/Kvmd.hs
index ecbf424..f8c9d3f 100644
--- a/src/Ganeti/Kvmd.hs
+++ b/src/Ganeti/Kvmd.hs
@@ -90,7 +90,7 @@ monitorDir :: String
 monitorDir = AutoConf.localstatedir </> "run/ganeti/kvm-hypervisor/ctrl/"
 
 monitorExtension :: String
-monitorExtension = ".qmp"
+monitorExtension = ".kvmd"
 
 isMonitorPath :: FilePath -> Bool
 isMonitorPath = (== monitorExtension) . takeExtension
-- 
1.9.2

Reply via email to