[libvirt] [PATCH] bhyve: fix process reconnect

Roman Bogorodskiy bogorodskiy at gmail.com
Sun Aug 5 15:54:28 UTC 2018


To reconnect to the bhyve process after deamon restart, a process
VM's pid points to is checked to have proctitle equal to 'bhyve: $vmname'.
However, there could be a bug in bhyve(8) which prevents it from
setting proctitle, so process arguments will look like:

 ['/usr/sbin/bhyve', ..., 'vmname', NULL]

Fall back to checking this format if proctitle doesn't match as a
workaround for this bug.
---
 src/bhyve/bhyve_process.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
index 9276d7d364..78d6ff1389 100644
--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -416,18 +416,28 @@ virBhyveProcessReconnect(virDomainObjPtr vm,
     if (proc_argv && proc_argv[0]) {
          if (STREQ(expected_proctitle, proc_argv[0])) {
              ret = 0;
-             priv->mon = bhyveMonitorOpen(vm, data->driver);
-             if (vm->def->ngraphics == 1 &&
-                 vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
-                 int vnc_port = vm->def->graphics[0]->data.vnc.port;
-                 if (virPortAllocatorSetUsed(vnc_port) < 0) {
-                     VIR_WARN("Failed to mark VNC port '%d' as used by '%s'",
-                              vnc_port, vm->def->name);
-                 }
+         } else {
+             if (STREQ(BHYVE, proc_argv[0])) {
+                 int i = 0;
+                 for (; proc_argv[i+1]; i++);
+                 if ((i != 0) && (STREQ(vm->def->name, proc_argv[i])))
+                     ret = 0;
              }
          }
     }
 
+    if (ret == 0) {
+        priv->mon = bhyveMonitorOpen(vm, data->driver);
+        if (vm->def->ngraphics == 1 &&
+            vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
+            int vnc_port = vm->def->graphics[0]->data.vnc.port;
+            if (virPortAllocatorSetUsed(vnc_port) < 0) {
+                VIR_WARN("Failed to mark VNC port '%d' as used by '%s'",
+                         vnc_port, vm->def->name);
+            }
+        }
+    }
+
  cleanup:
     if (ret < 0) {
         /* If VM is reported to be in active state, but we cannot find
-- 
2.18.0




More information about the libvir-list mailing list