The hook scripts are called with specific command line arguments, depending upon
the script, and the operation being performed.
-The guest hook scripts, qemu, lxc and libxl are also given the **full** XML
-description for the domain on their stdin. This includes items such the UUID of
-the domain and its storage information, and is intended to provide all the
+The guest hook scripts, qemu, lxc, libxl and bhyve are also given the **full**
+XML description for the domain on their stdin. This includes items such the UUID
+of the domain and its storage information, and is intended to provide all the
libvirt information the script needs.
For all cases, stdin of the network hook script is provided with the full XML
</hookData>
Please note that this approach is different from other cases such as ``daemon``,
-``qemu``, ``lxc`` or ``libxl`` hook scripts, because two XMLs may be passed
-here, while in the other cases only a single XML is passed.
+``qemu``, ``lxc``, ``libxl`` or ``bhyve`` hook scripts, because two XMLs may be
+passed here, while in the other cases only a single XML is passed.
The command line arguments take this approach:
}
static int
-bhyveProcessStartHook(virDomainObj *vm, virHookBhyveOpType op)
+bhyveProcessStartHook(struct _bhyveConn *driver,
+ virDomainObj *vm,
+ virHookBhyveOpType op)
{
+ g_autofree char *xml = NULL;
+
if (!virHookPresent(VIR_HOOK_DRIVER_BHYVE))
return 0;
+ xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
+
return virHookCall(VIR_HOOK_DRIVER_BHYVE, vm->def->name, op,
- VIR_HOOK_SUBOP_BEGIN, NULL, NULL, NULL);
+ VIR_HOOK_SUBOP_BEGIN, NULL, xml, NULL);
}
static void
-bhyveProcessStopHook(virDomainObj *vm, virHookBhyveOpType op)
+bhyveProcessStopHook(struct _bhyveConn *driver,
+ virDomainObj *vm,
+ virHookBhyveOpType op)
{
- if (virHookPresent(VIR_HOOK_DRIVER_BHYVE))
- virHookCall(VIR_HOOK_DRIVER_BHYVE, vm->def->name, op,
- VIR_HOOK_SUBOP_END, NULL, NULL, NULL);
+ g_autofree char *xml = NULL;
+ if (!virHookPresent(VIR_HOOK_DRIVER_BHYVE))
+ return;
+
+ xml = virDomainDefFormat(vm->def, driver->xmlopt, 0);
+
+ virHookCall(VIR_HOOK_DRIVER_BHYVE, vm->def->name, op,
+ VIR_HOOK_SUBOP_END, NULL, xml, NULL);
}
static int
goto cleanup;
}
- if (bhyveProcessStartHook(vm, VIR_HOOK_BHYVE_OP_START) < 0)
+ if (bhyveProcessStartHook(driver, vm, VIR_HOOK_BHYVE_OP_START) < 0)
goto cleanup;
/* Now we can start the domain */
BHYVE_STATE_DIR) < 0)
goto cleanup;
- if (bhyveProcessStartHook(vm, VIR_HOOK_BHYVE_OP_STARTED) < 0)
+ if (bhyveProcessStartHook(driver, vm, VIR_HOOK_BHYVE_OP_STARTED) < 0)
goto cleanup;
ret = 0;
struct _bhyveConn *driver = conn->privateData;
/* Run an early hook to setup missing devices. */
- if (bhyveProcessStartHook(vm, VIR_HOOK_BHYVE_OP_PREPARE) < 0)
+ if (bhyveProcessStartHook(driver, vm, VIR_HOOK_BHYVE_OP_PREPARE) < 0)
return -1;
if (flags & VIR_BHYVE_PROCESS_START_AUTODESTROY)
if ((priv != NULL) && (priv->mon != NULL))
bhyveMonitorClose(priv->mon);
- bhyveProcessStopHook(vm, VIR_HOOK_BHYVE_OP_STOPPED);
+ bhyveProcessStopHook(driver, vm, VIR_HOOK_BHYVE_OP_STOPPED);
/* Cleanup network interfaces */
bhyveNetCleanup(vm);
vm->pid = 0;
vm->def->id = -1;
- bhyveProcessStopHook(vm, VIR_HOOK_BHYVE_OP_RELEASE);
+ bhyveProcessStopHook(driver, vm, VIR_HOOK_BHYVE_OP_RELEASE);
cleanup:
virPidFileDelete(BHYVE_STATE_DIR, vm->def->name);