[libvirt] [PATCH] bhyve: fix process reconnect
Michal Privoznik
mprivozn at redhat.com
Tue Aug 14 12:07:20 UTC 2018
On 08/05/2018 05:54 PM, Roman Bogorodskiy wrote:
> 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;
s/int/size_t/
> + for (; proc_argv[i+1]; i++);
Ugrh. It is very easy to miss the trailing semicolon. Please move it
onto a separate line.
> + if ((i != 0) && (STREQ(vm->def->name, proc_argv[i])))
> + ret = 0;
> }
> }
> }
>
I suggest squashing this in:
diff --git i/src/bhyve/bhyve_process.c w/src/bhyve/bhyve_process.c
index 78d6ff1389..47a5dc3f94 100644
--- i/src/bhyve/bhyve_process.c
+++ w/src/bhyve/bhyve_process.c
@@ -418,9 +418,11 @@ virBhyveProcessReconnect(virDomainObjPtr vm,
ret = 0;
} 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])))
+ size_t i;
+
+ for (i = 0; proc_argv[i+1]; i++)
+ ;
+ if ((STREQ(vm->def->name, proc_argv[i])))
ret = 0;
}
}
ACK
Michal
More information about the libvir-list
mailing list