return vm;
}
+static void
+bhyveNetCleanup(virDomainObjPtr vm)
+{
+ size_t i;
+
+ for (i = 0; i < vm->def->nnets; i++) {
+ virDomainNetDefPtr net = vm->def->nets[i];
+ int actualType = virDomainNetGetActualType(net);
+
+ if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) {
+ ignore_value(virNetDevBridgeRemovePort(
+ virDomainNetGetActualBridgeName(net),
+ net->ifname));
+ ignore_value(virNetDevTapDelete(net->ifname));
+ }
+ }
+}
+
int
virBhyveProcessStart(virConnectPtr conn,
bhyveConnPtr driver,
ignore_value(virCommandRun(destroy_cmd, NULL));
virCommandFree(destroy_cmd);
}
+
+ bhyveNetCleanup(vm);
}
virCommandFree(load_cmd);
virDomainObjPtr vm,
virDomainShutoffReason reason ATTRIBUTE_UNUSED)
{
- size_t i;
int ret = -1;
virCommandPtr cmd = NULL;
vm->def->name,
(int)vm->pid);
- for (i = 0; i < vm->def->nnets; i++) {
- virDomainNetDefPtr net = vm->def->nets[i];
- int actualType = virDomainNetGetActualType(net);
-
- if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) {
- ignore_value(virNetDevBridgeRemovePort(
- virDomainNetGetActualBridgeName(net),
- net->ifname));
- ignore_value(virNetDevTapDelete(net->ifname));
- }
- }
+ /* Cleanup network interfaces */
+ bhyveNetCleanup(vm);
/* No matter if shutdown was successful or not, we
* need to unload the VM */