1 /* 2 * virhook.h: internal entry points needed for synchronous hooks support 3 * 4 * Copyright (C) 2010 Red Hat, Inc. 5 * Copyright (C) 2010 Daniel Veillard 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library. If not, see 19 * <http://www.gnu.org/licenses/>. 20 */ 21 22 #pragma once 23 24 #include "internal.h" 25 26 typedef enum { 27 VIR_HOOK_DRIVER_DAEMON = 0, /* Daemon related events */ 28 VIR_HOOK_DRIVER_QEMU, /* QEMU domains related events */ 29 VIR_HOOK_DRIVER_LXC, /* LXC domains related events */ 30 VIR_HOOK_DRIVER_NETWORK, /* network related events */ 31 VIR_HOOK_DRIVER_LIBXL, /* Xen libxl domains related events */ 32 VIR_HOOK_DRIVER_BHYVE, /* Bhyve domains related events */ 33 34 VIR_HOOK_DRIVER_LAST, 35 } virHookDriverType; 36 37 typedef enum { 38 VIR_HOOK_DAEMON_OP_START, /* daemon is about to start */ 39 VIR_HOOK_DAEMON_OP_SHUTDOWN, /* daemon is about to shutdown */ 40 VIR_HOOK_DAEMON_OP_RELOAD, /* driver reload with SIGHUP */ 41 42 VIR_HOOK_DAEMON_OP_LAST, 43 } virHookDaemonOpType; 44 45 typedef enum { 46 VIR_HOOK_SUBOP_NONE, /* no sub-operation */ 47 VIR_HOOK_SUBOP_BEGIN, /* beginning of the operation */ 48 VIR_HOOK_SUBOP_END, /* end of the operation */ 49 50 VIR_HOOK_SUBOP_LAST, 51 } virHookSubopType; 52 53 typedef enum { 54 VIR_HOOK_QEMU_OP_START, /* domain is about to start */ 55 VIR_HOOK_QEMU_OP_STOPPED, /* domain has stopped */ 56 VIR_HOOK_QEMU_OP_PREPARE, /* domain startup initiated */ 57 VIR_HOOK_QEMU_OP_RELEASE, /* domain destruction is over */ 58 VIR_HOOK_QEMU_OP_MIGRATE, /* domain is being migrated */ 59 VIR_HOOK_QEMU_OP_STARTED, /* domain has started */ 60 VIR_HOOK_QEMU_OP_RECONNECT, /* domain is being reconnected by libvirt */ 61 VIR_HOOK_QEMU_OP_ATTACH, /* domain is being attached to be libvirt */ 62 VIR_HOOK_QEMU_OP_RESTORE, /* domain is being restored */ 63 64 VIR_HOOK_QEMU_OP_LAST, 65 } virHookQemuOpType; 66 67 typedef enum { 68 VIR_HOOK_LXC_OP_START, /* domain is about to start */ 69 VIR_HOOK_LXC_OP_STOPPED, /* domain has stopped */ 70 VIR_HOOK_LXC_OP_PREPARE, /* domain startup initiated */ 71 VIR_HOOK_LXC_OP_RELEASE, /* domain destruction is over */ 72 VIR_HOOK_LXC_OP_STARTED, /* domain has started */ 73 VIR_HOOK_LXC_OP_RECONNECT, /* domain is being reconnected by libvirt */ 74 75 VIR_HOOK_LXC_OP_LAST, 76 } virHookLxcOpType; 77 78 typedef enum { 79 VIR_HOOK_NETWORK_OP_START, /* network is about to start */ 80 VIR_HOOK_NETWORK_OP_STARTED, /* network has start */ 81 VIR_HOOK_NETWORK_OP_STOPPED, /* network has stopped */ 82 VIR_HOOK_NETWORK_OP_PORT_CREATED, /* port has been created in the network */ 83 VIR_HOOK_NETWORK_OP_PORT_DELETED, /* port has been deleted in the network */ 84 VIR_HOOK_NETWORK_OP_UPDATED, /* network has been updated */ 85 86 VIR_HOOK_NETWORK_OP_LAST, 87 } virHookNetworkOpType; 88 89 typedef enum { 90 VIR_HOOK_LIBXL_OP_START, /* domain is about to start */ 91 VIR_HOOK_LIBXL_OP_STOPPED, /* domain has stopped */ 92 VIR_HOOK_LIBXL_OP_PREPARE, /* domain startup initiated */ 93 VIR_HOOK_LIBXL_OP_RELEASE, /* domain destruction is over */ 94 VIR_HOOK_LIBXL_OP_MIGRATE, /* domain is being migrated */ 95 VIR_HOOK_LIBXL_OP_STARTED, /* domain has started */ 96 VIR_HOOK_LIBXL_OP_RECONNECT, /* domain is being reconnected by libvirt */ 97 98 VIR_HOOK_LIBXL_OP_LAST, 99 } virHookLibxlOpType; 100 101 typedef enum { 102 VIR_HOOK_BHYVE_OP_START, /* domain is about to start */ 103 VIR_HOOK_BHYVE_OP_STOPPED, /* domain has stopped */ 104 VIR_HOOK_BHYVE_OP_PREPARE, /* domain startup initiated */ 105 VIR_HOOK_BHYVE_OP_RELEASE, /* domain destruction is over */ 106 VIR_HOOK_BHYVE_OP_STARTED, /* domain has started */ 107 108 VIR_HOOK_BHYVE_OP_LAST, 109 } virHookBhyveOpType; 110 111 int virHookInitialize(void); 112 113 int virHookPresent(int driver); 114 115 int virHookCall(int driver, const char *id, int op, int sub_op, 116 const char *extra, const char *input, char **output); 117