mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-04 08:57:20 +00:00
Merge pull request #2630 from brauner/2018-09-20/remove_locking
api_extensions: introduce lxc_has_api_extension()
This commit is contained in:
commit
7c887243d3
34
doc/api-extensions.md
Normal file
34
doc/api-extensions.md
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# API extensions
|
||||||
|
|
||||||
|
The changes below were introduced to the LXC API after the 3.0 API was finalized.
|
||||||
|
|
||||||
|
They are all backward compatible and can be detected by client tools by
|
||||||
|
called the `lxc_has_api_extension` function.
|
||||||
|
|
||||||
|
## lxc\_log
|
||||||
|
|
||||||
|
This introduces a way to initialize a logging instance from the API for a given
|
||||||
|
container.
|
||||||
|
|
||||||
|
## lxc\_config\_item\_is\_supported
|
||||||
|
|
||||||
|
This introduces the `lxc_config_item_is_supported` function. It allows users to
|
||||||
|
check whether their LXC instance supports a given configuration key.
|
||||||
|
|
||||||
|
## console\_log
|
||||||
|
|
||||||
|
This adds support to container's console log. The console log is implemented as
|
||||||
|
an efficient ringbuffer.
|
||||||
|
|
||||||
|
## reboot2
|
||||||
|
|
||||||
|
This adds `reboot2()` as a new API extension. This function properly waits
|
||||||
|
until a reboot succeeded. It takes a timeout argument. When set to `> 0`
|
||||||
|
`reboot2()` will block until the timeout is reached, if timeout is set to zero
|
||||||
|
`reboot2()` will not block, if set to -1 `reboot2()` will block indefinitly.
|
||||||
|
|
||||||
|
## mount\_injection
|
||||||
|
|
||||||
|
This adds support for injecting and removing mounts into/from a running
|
||||||
|
containers. Two new API functions `mount()` and `umount()` are added. They
|
||||||
|
mirror the current mount and umount API of the kernel.
|
@ -2,7 +2,8 @@ pkginclude_HEADERS = attach_options.h \
|
|||||||
lxccontainer.h \
|
lxccontainer.h \
|
||||||
version.h
|
version.h
|
||||||
|
|
||||||
noinst_HEADERS = attach.h \
|
noinst_HEADERS = api_extensions.h \
|
||||||
|
attach.h \
|
||||||
caps.h \
|
caps.h \
|
||||||
cgroups/cgroup.h \
|
cgroups/cgroup.h \
|
||||||
cgroups/cgroup_utils.h \
|
cgroups/cgroup_utils.h \
|
||||||
@ -85,6 +86,7 @@ endif
|
|||||||
|
|
||||||
lib_LTLIBRARIES = liblxc.la
|
lib_LTLIBRARIES = liblxc.la
|
||||||
liblxc_la_SOURCES = af_unix.c af_unix.h \
|
liblxc_la_SOURCES = af_unix.c af_unix.h \
|
||||||
|
api_extensions.h \
|
||||||
attach.c attach.h \
|
attach.c attach.h \
|
||||||
caps.c caps.h \
|
caps.c caps.h \
|
||||||
cgroups/cgfsng.c \
|
cgroups/cgfsng.c \
|
||||||
|
48
src/lxc/api_extensions.h
Normal file
48
src/lxc/api_extensions.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/* liblxcapi
|
||||||
|
*
|
||||||
|
* Copyright © 2018 Christian Brauner <christian.brauner@ubuntu.com>.
|
||||||
|
* Copyright © 2018 Canonical Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LXC_API_EXTENSIONS_H
|
||||||
|
#define __LXC_API_EXTENSIONS_H
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* api_extensions is the list of all API extensions in the order they were
|
||||||
|
* added.
|
||||||
|
|
||||||
|
The following kind of changes come with a new extensions:
|
||||||
|
|
||||||
|
- New public functions
|
||||||
|
- New configuration key
|
||||||
|
- New valid values for a configuration key
|
||||||
|
*/
|
||||||
|
static char *api_extensions[] = {
|
||||||
|
"lxc_log",
|
||||||
|
"lxc_config_item_is_supported",
|
||||||
|
"console_log",
|
||||||
|
"reboot2",
|
||||||
|
"mount_injection",
|
||||||
|
"cgroup_relative",
|
||||||
|
};
|
||||||
|
|
||||||
|
static size_t nr_api_extensions = sizeof(api_extensions) / sizeof(*api_extensions);
|
||||||
|
|
||||||
|
#endif /* __LXC_API_EXTENSIONS_H */
|
@ -42,6 +42,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "af_unix.h"
|
#include "af_unix.h"
|
||||||
|
#include "api_extensions.h"
|
||||||
#include "attach.h"
|
#include "attach.h"
|
||||||
#include "cgroup.h"
|
#include "cgroup.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
@ -5671,3 +5672,16 @@ bool lxc_config_item_is_supported(const char *key)
|
|||||||
{
|
{
|
||||||
return !!lxc_get_config(key);
|
return !!lxc_get_config(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lxc_has_api_extension(const char *extension)
|
||||||
|
{
|
||||||
|
/* The NULL API extension is always present. :) */
|
||||||
|
if (!extension)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < nr_api_extensions; i++)
|
||||||
|
if (strcmp(api_extensions[i], extension) == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -1123,6 +1123,13 @@ void lxc_log_close(void);
|
|||||||
*/
|
*/
|
||||||
bool lxc_config_item_is_supported(const char *key);
|
bool lxc_config_item_is_supported(const char *key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Check if an API extension is supported by this LXC instance.
|
||||||
|
*
|
||||||
|
* \param extension API extension to check for.
|
||||||
|
*/
|
||||||
|
bool lxc_has_api_extension(const char *extension);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user