2010-03-26 14:49:45 +00:00
|
|
|
/*
|
2012-12-12 17:00:34 +00:00
|
|
|
* virhook.h: internal entry points needed for synchronous hooks support
|
2010-03-26 14:49:45 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Red Hat, Inc.
|
|
|
|
* Copyright (C) 2010 Daniel Veillard
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2010-03-26 14:49:45 +00:00
|
|
|
*/
|
|
|
|
|
2019-06-18 16:13:08 +00:00
|
|
|
#pragma once
|
2010-03-26 14:49:45 +00:00
|
|
|
|
2019-06-18 16:13:08 +00:00
|
|
|
#include "internal.h"
|
2010-03-26 14:49:45 +00:00
|
|
|
|
2014-04-27 00:15:22 +00:00
|
|
|
typedef enum {
|
2010-03-26 14:49:45 +00:00
|
|
|
VIR_HOOK_DRIVER_DAEMON = 0, /* Daemon related events */
|
2018-03-31 14:51:14 +00:00
|
|
|
VIR_HOOK_DRIVER_QEMU, /* QEMU domains related events */
|
2010-03-26 14:49:45 +00:00
|
|
|
VIR_HOOK_DRIVER_LXC, /* LXC domains related events */
|
2014-01-31 15:48:06 +00:00
|
|
|
VIR_HOOK_DRIVER_NETWORK, /* network related events */
|
2016-07-11 11:55:53 +00:00
|
|
|
VIR_HOOK_DRIVER_LIBXL, /* Xen libxl domains related events */
|
2020-02-24 06:46:18 +00:00
|
|
|
VIR_HOOK_DRIVER_BHYVE, /* Bhyve domains related events */
|
2010-03-26 14:49:45 +00:00
|
|
|
|
|
|
|
VIR_HOOK_DRIVER_LAST,
|
2014-04-27 00:15:22 +00:00
|
|
|
} virHookDriverType;
|
2010-03-26 14:49:45 +00:00
|
|
|
|
2014-04-27 00:15:22 +00:00
|
|
|
typedef enum {
|
2010-03-26 14:49:45 +00:00
|
|
|
VIR_HOOK_DAEMON_OP_START, /* daemon is about to start */
|
|
|
|
VIR_HOOK_DAEMON_OP_SHUTDOWN, /* daemon is about to shutdown */
|
|
|
|
VIR_HOOK_DAEMON_OP_RELOAD, /* driver reload with SIGHUP */
|
|
|
|
|
|
|
|
VIR_HOOK_DAEMON_OP_LAST,
|
2014-04-27 00:15:22 +00:00
|
|
|
} virHookDaemonOpType;
|
2010-03-26 14:49:45 +00:00
|
|
|
|
2014-04-27 00:15:22 +00:00
|
|
|
typedef enum {
|
2010-03-26 14:49:45 +00:00
|
|
|
VIR_HOOK_SUBOP_NONE, /* no sub-operation */
|
|
|
|
VIR_HOOK_SUBOP_BEGIN, /* beginning of the operation */
|
|
|
|
VIR_HOOK_SUBOP_END, /* end of the operation */
|
|
|
|
|
|
|
|
VIR_HOOK_SUBOP_LAST,
|
2014-04-27 00:15:22 +00:00
|
|
|
} virHookSubopType;
|
2010-03-26 14:49:45 +00:00
|
|
|
|
2014-04-27 00:15:22 +00:00
|
|
|
typedef enum {
|
2010-03-26 14:49:45 +00:00
|
|
|
VIR_HOOK_QEMU_OP_START, /* domain is about to start */
|
|
|
|
VIR_HOOK_QEMU_OP_STOPPED, /* domain has stopped */
|
2011-03-22 13:12:36 +00:00
|
|
|
VIR_HOOK_QEMU_OP_PREPARE, /* domain startup initiated */
|
|
|
|
VIR_HOOK_QEMU_OP_RELEASE, /* domain destruction is over */
|
2012-02-28 12:42:42 +00:00
|
|
|
VIR_HOOK_QEMU_OP_MIGRATE, /* domain is being migrated */
|
Add some missing hook functions
A core use case of the hook scripts is to be able to do things
to a guest's network configuration. It is possible to hook into
the 'start' operation for a QEMU guest which runs just before
the guest is started. The TAP devices will exist at this point,
but the QEMU process will not. It can be desirable to have a
'started' hook too, which runs once QEMU has started.
If libvirtd is restarted it will re-populate firewall rules,
but there is no QEMU hook to trigger for existing domains.
This is solved with a 'reconnect' hook.
Finally, if attaching to an external QEMU process there needs
to be an 'attach' hook script.
This all also applies to the LXC driver
* docs/hooks.html.in: Document new operations
* src/util/hooks.c, src/util/hooks.c: Add 'started', 'reconnect'
and 'attach' operations for QEMU. Add 'prepare', 'started',
'release' and 'reconnect' operations for LXC
* src/lxc/lxc_driver.c: Add hooks for 'prepare', 'started',
'release' and 'reconnect' operations
* src/qemu/qemu_process.c: Add hooks for 'started', 'reconnect'
and 'reconnect' operations
2012-05-28 14:04:31 +00:00
|
|
|
VIR_HOOK_QEMU_OP_STARTED, /* domain has started */
|
|
|
|
VIR_HOOK_QEMU_OP_RECONNECT, /* domain is being reconnected by libvirt */
|
|
|
|
VIR_HOOK_QEMU_OP_ATTACH, /* domain is being attached to be libvirt */
|
2014-09-17 09:38:39 +00:00
|
|
|
VIR_HOOK_QEMU_OP_RESTORE, /* domain is being restored */
|
2010-03-26 14:49:45 +00:00
|
|
|
|
|
|
|
VIR_HOOK_QEMU_OP_LAST,
|
2014-04-27 00:15:22 +00:00
|
|
|
} virHookQemuOpType;
|
2010-03-26 14:49:45 +00:00
|
|
|
|
2014-04-27 00:15:22 +00:00
|
|
|
typedef enum {
|
2010-03-26 14:49:45 +00:00
|
|
|
VIR_HOOK_LXC_OP_START, /* domain is about to start */
|
|
|
|
VIR_HOOK_LXC_OP_STOPPED, /* domain has stopped */
|
Add some missing hook functions
A core use case of the hook scripts is to be able to do things
to a guest's network configuration. It is possible to hook into
the 'start' operation for a QEMU guest which runs just before
the guest is started. The TAP devices will exist at this point,
but the QEMU process will not. It can be desirable to have a
'started' hook too, which runs once QEMU has started.
If libvirtd is restarted it will re-populate firewall rules,
but there is no QEMU hook to trigger for existing domains.
This is solved with a 'reconnect' hook.
Finally, if attaching to an external QEMU process there needs
to be an 'attach' hook script.
This all also applies to the LXC driver
* docs/hooks.html.in: Document new operations
* src/util/hooks.c, src/util/hooks.c: Add 'started', 'reconnect'
and 'attach' operations for QEMU. Add 'prepare', 'started',
'release' and 'reconnect' operations for LXC
* src/lxc/lxc_driver.c: Add hooks for 'prepare', 'started',
'release' and 'reconnect' operations
* src/qemu/qemu_process.c: Add hooks for 'started', 'reconnect'
and 'reconnect' operations
2012-05-28 14:04:31 +00:00
|
|
|
VIR_HOOK_LXC_OP_PREPARE, /* domain startup initiated */
|
|
|
|
VIR_HOOK_LXC_OP_RELEASE, /* domain destruction is over */
|
|
|
|
VIR_HOOK_LXC_OP_STARTED, /* domain has started */
|
|
|
|
VIR_HOOK_LXC_OP_RECONNECT, /* domain is being reconnected by libvirt */
|
2010-03-26 14:49:45 +00:00
|
|
|
|
|
|
|
VIR_HOOK_LXC_OP_LAST,
|
2014-04-27 00:15:22 +00:00
|
|
|
} virHookLxcOpType;
|
2010-03-26 14:49:45 +00:00
|
|
|
|
2014-04-27 00:15:22 +00:00
|
|
|
typedef enum {
|
2014-01-31 15:48:06 +00:00
|
|
|
VIR_HOOK_NETWORK_OP_START, /* network is about to start */
|
|
|
|
VIR_HOOK_NETWORK_OP_STARTED, /* network has start */
|
|
|
|
VIR_HOOK_NETWORK_OP_STOPPED, /* network has stopped */
|
2018-12-19 15:36:04 +00:00
|
|
|
VIR_HOOK_NETWORK_OP_PORT_CREATED, /* port has been created in the network */
|
|
|
|
VIR_HOOK_NETWORK_OP_PORT_DELETED, /* port has been deleted in the network */
|
2016-07-13 11:06:05 +00:00
|
|
|
VIR_HOOK_NETWORK_OP_UPDATED, /* network has been updated */
|
2014-01-31 15:48:06 +00:00
|
|
|
|
|
|
|
VIR_HOOK_NETWORK_OP_LAST,
|
2014-04-27 00:15:22 +00:00
|
|
|
} virHookNetworkOpType;
|
2014-01-31 15:48:06 +00:00
|
|
|
|
2016-07-11 11:55:53 +00:00
|
|
|
typedef enum {
|
|
|
|
VIR_HOOK_LIBXL_OP_START, /* domain is about to start */
|
|
|
|
VIR_HOOK_LIBXL_OP_STOPPED, /* domain has stopped */
|
|
|
|
VIR_HOOK_LIBXL_OP_PREPARE, /* domain startup initiated */
|
|
|
|
VIR_HOOK_LIBXL_OP_RELEASE, /* domain destruction is over */
|
|
|
|
VIR_HOOK_LIBXL_OP_MIGRATE, /* domain is being migrated */
|
|
|
|
VIR_HOOK_LIBXL_OP_STARTED, /* domain has started */
|
|
|
|
VIR_HOOK_LIBXL_OP_RECONNECT, /* domain is being reconnected by libvirt */
|
|
|
|
|
|
|
|
VIR_HOOK_LIBXL_OP_LAST,
|
|
|
|
} virHookLibxlOpType;
|
|
|
|
|
2020-02-24 06:46:18 +00:00
|
|
|
typedef enum {
|
|
|
|
VIR_HOOK_BHYVE_OP_START, /* domain is about to start */
|
|
|
|
VIR_HOOK_BHYVE_OP_STOPPED, /* domain has stopped */
|
|
|
|
VIR_HOOK_BHYVE_OP_PREPARE, /* domain startup initiated */
|
|
|
|
VIR_HOOK_BHYVE_OP_RELEASE, /* domain destruction is over */
|
|
|
|
VIR_HOOK_BHYVE_OP_STARTED, /* domain has started */
|
|
|
|
|
|
|
|
VIR_HOOK_BHYVE_OP_LAST,
|
|
|
|
} virHookBhyveOpType;
|
|
|
|
|
2010-03-26 14:49:45 +00:00
|
|
|
int virHookInitialize(void);
|
|
|
|
|
|
|
|
int virHookPresent(int driver);
|
|
|
|
|
|
|
|
int virHookCall(int driver, const char *id, int op, int sub_op,
|
2012-02-27 16:06:22 +00:00
|
|
|
const char *extra, const char *input, char **output);
|