Top | ![]() |
![]() |
![]() |
![]() |
gchar * | arch | Read / Write |
guint | gid | Read / Write |
gchar * | homedir | Read / Write |
gchar * | kernpath | Read / Write |
gchar * | kernrelease | Read / Write |
gchar * | kmodpath | Read / Write |
gchar * | name | Read / Write / Construct Only |
gchar * | root | Read / Write |
gboolean | security-dynamic | Read / Write |
gchar * | security-label | Read / Write |
gchar * | shell | Read / Write |
guint | uid | Read / Write |
gchar * | username | Read / Write |
gchar * | uuid | Read / Write / Construct Only |
GObject ╰── GVirSandboxConfig ├── GVirSandboxConfigInteractive ╰── GVirSandboxConfigService
Provides a base object to store configurations for the application sandbox
The GVirSandboxConfig object stores the basic information required to create application sandboxes with a simple text based console.
GVirSandboxConfig * gvir_sandbox_config_load_from_path (const gchar *path
,GError **error
);
GVirSandboxConfig * gvir_sandbox_config_load_from_data (const gchar *data
,GError **error
);
gboolean gvir_sandbox_config_save_to_path (GVirSandboxConfig *config
,const gchar *path
,GError **error
);
gchar * gvir_sandbox_config_save_to_data (GVirSandboxConfig *config
,GError **error
);
const gchar *
gvir_sandbox_config_get_name (GVirSandboxConfig *config
);
Retrieves the sandbox name
void gvir_sandbox_config_set_uuid (GVirSandboxConfig *config
,const gchar *uuid
);
Set the UUID for the container, to overide the automatically generated value.
const gchar *
gvir_sandbox_config_get_uuid (GVirSandboxConfig *config
);
Retrieves the sandbox UUID
void gvir_sandbox_config_set_root (GVirSandboxConfig *config
,const gchar *hostdir
);
Set the host directory to use as the root for the sandbox. The defualt root is "/".
const gchar *
gvir_sandbox_config_get_root (GVirSandboxConfig *config
);
Retrieves the sandbox root directory
void gvir_sandbox_config_set_arch (GVirSandboxConfig *config
,const gchar *arch
);
Set the architecture to use in the sandbox. If none is provided, it will default to matching the host architecture.
const gchar *
gvir_sandbox_config_get_arch (GVirSandboxConfig *config
);
Retrieves the sandbox binary architecture
void gvir_sandbox_config_set_kernrelease (GVirSandboxConfig *config
,const gchar *kernrelease
);
Set the kernel release version to use in the sandbox. If none is provided, it will default to matching the current running kernel.
const gchar *
gvir_sandbox_config_get_kernrelease (GVirSandboxConfig *config
);
Retrieves the sandbox kernel release version
void gvir_sandbox_config_set_kernpath (GVirSandboxConfig *config
,const gchar *kernpath
);
Set the kernel image path to use in the sandbox. If none is provided, it will default to matching /boot/vmlinuz-[kernel release].
const gchar *
gvir_sandbox_config_get_kernpath (GVirSandboxConfig *config
);
Retrieves the sandbox kernel image path
void gvir_sandbox_config_set_kmodpath (GVirSandboxConfig *config
,const gchar *kmodpath
);
Sets the generic path to the kernel modules directory. It will default to "/lib/modules", modules being searched in /lib/modules/[kernel release]. If "/path" is given as argument modules will be searched in /path/[kernel release]
const gchar *
gvir_sandbox_config_get_kmodpath (GVirSandboxConfig *config
);
Retrieves the sandbox kernel modules path
void gvir_sandbox_config_set_shell (GVirSandboxConfig *config
,gboolean shell
);
Set whether the container console should have a interactive shell.
gboolean
gvir_sandbox_config_get_shell (GVirSandboxConfig *config
);
Retrieves the sandbox shell flag
void gvir_sandbox_config_set_userid (GVirSandboxConfig *config
,guint uid
);
Set the user ID to invoke the sandbox application under. Defaults to the user ID of the current program.
guint
gvir_sandbox_config_get_userid (GVirSandboxConfig *config
);
Get the user ID to invoke the sandbox application under.
void gvir_sandbox_config_set_groupid (GVirSandboxConfig *config
,guint gid
);
Set the group ID to invoke the sandbox application under. Defaults to the group ID of the current program.
guint
gvir_sandbox_config_get_groupid (GVirSandboxConfig *config
);
Get the group ID to invoke the sandbox application under.
void gvir_sandbox_config_set_username (GVirSandboxConfig *config
,const gchar *username
);
Set the user name associated with the sandbox user ID. Defaults to the user name of the current program.
const gchar *
gvir_sandbox_config_get_username (GVirSandboxConfig *config
);
Get the user name to invoke the sandbox application under.
void gvir_sandbox_config_set_homedir (GVirSandboxConfig *config
,const gchar *homedir
);
Set the home directory associated with the sandbox user ID. Defaults to the home directory of the current program.
const gchar *
gvir_sandbox_config_get_homedir (GVirSandboxConfig *config
);
Get the home directory associated with the sandbox user ID
void gvir_sandbox_config_add_network (GVirSandboxConfig *config
,GVirSandboxConfigNetwork *network
);
Adds a new network connection to the sandbox
GList *
gvir_sandbox_config_get_networks (GVirSandboxConfig *config
);
Retrieves the list of custom networks in the sandbox
gboolean gvir_sandbox_config_add_network_opts (GVirSandboxConfig *config
,const gchar *network
,GError **error
);
Parses network
whose elements are in the format
KEY=VALUE, creating GVirSandboxConfigNetwork
instances for each element.
dhcp,source=default
source=private,address=192.168.122.1/24192
.168.122.255,
address=192.168.122.1/24192
.168.122.255,address=2001:212::204:2/64
route=192.168.122.255/24192
.168.1.1
filter=clean-traffic
filter.ip=192.168.122.1
gboolean gvir_sandbox_config_add_network_strv (GVirSandboxConfig *config
,gchar **networks
,GError **error
);
Parses networks
whose elements are in the format
KEY=VALUE, creating GVirSandboxConfigNetwork
instances for each element.
gboolean
gvir_sandbox_config_has_networks (GVirSandboxConfig *config
);
void gvir_sandbox_config_add_env (GVirSandboxConfig *config
,gchar *key
,gchar *value
);
Adds a new environment variable to the sandbox
GHashTable *
gvir_sandbox_config_get_envs (GVirSandboxConfig *config
);
Retrieves the hashtable of custom environment variables in the sandbox
gboolean gvir_sandbox_config_add_env_strv (GVirSandboxConfig *config
,gchar **envs
,GError **error
);
Parses envs
whose elements are in the format KEY=VALUE
--env KEY=VALUE
gboolean gvir_sandbox_config_add_env_opts (GVirSandboxConfig *config
,const char *env
,GError **error
);
Parses env
in the format KEY=VALUE
creating GVirSandboxConfigEnv instances for each element. For
example
--env KEY=VALUE
void gvir_sandbox_config_add_disk (GVirSandboxConfig *config
,GVirSandboxConfigDisk *dsk
);
Adds a new custom disk to the sandbox
GList *
gvir_sandbox_config_get_disks (GVirSandboxConfig *config
);
Retrieves the list of custom disks in the sandbox
gboolean gvir_sandbox_config_add_disk_strv (GVirSandboxConfig *config
,gchar **disks
,GError **error
);
Parses disks
whose elements are in the format TYPE:TAG=SOURCE,format=FORMAT
creating GVirSandboxConfigMount instances for each element. For
example
file:cache=/var/lib/sandbox/demo/tmp.qcow2,format=qcow2
gboolean gvir_sandbox_config_add_disk_opts (GVirSandboxConfig *config
,const char *disk
,GError **error
);
Parses disk
in the format TYPE:TAG=SOURCE,format=FORMAT
creating GVirSandboxConfigDisk instances for each element. For
example
file:cache=/var/lib/sandbox/demo/tmp.qcow2,format=qcow2
gboolean
gvir_sandbox_config_has_disks (GVirSandboxConfig *config
);
void gvir_sandbox_config_add_mount (GVirSandboxConfig *config
,GVirSandboxConfigMount *mnt
);
Adds a new custom mount to the sandbox, to override part of the host filesystem
GList *
gvir_sandbox_config_get_mounts (GVirSandboxConfig *config
);
Retrieves the list of custom mounts in the sandbox
GList * gvir_sandbox_config_get_mounts_with_type (GVirSandboxConfig *config
,GType type
);
Retrieves the list of custom mounts in the sandbox
GVirSandboxConfigMount * gvir_sandbox_config_find_mount (GVirSandboxConfig *config
,const gchar *target
);
Finds the GVirSandboxConfigMount object corresponding to a guest
path of target
.
gboolean gvir_sandbox_config_add_mount_opts (GVirSandboxConfig *config
,const char *mount
,GError **error
);
Parses mount
whose elements are in the format TYPE:TARGET=SOURCE
creating GVirSandboxConfigMount instances for each element. For
example
host-bind:/tmp=/var/lib/sandbox/demo/tmp
host-image:/=/var/lib/sandbox/demo.img
host-image:/=/var/lib/sandbox/demo.qcow2,format=qcow2
guest-bind:/home=/tmp/home
ram:/tmp=500M
gboolean gvir_sandbox_config_add_mount_strv (GVirSandboxConfig *config
,gchar **mounts
,GError **error
);
Parses mounts
whose elements are in the format TYPE:TARGET=SOURCE
creating GVirSandboxConfigMount instances for each element. For
example
host-bind:/tmp=/var/lib/sandbox/demo/tmp
host-image:/=/var/lib/sandbox/demo.img
guest-bind:/home=/tmp/home
gboolean
gvir_sandbox_config_has_mounts (GVirSandboxConfig *config
);
gboolean gvir_sandbox_config_has_mounts_with_type (GVirSandboxConfig *config
,GType type
);
gboolean
gvir_sandbox_config_has_root_mount (GVirSandboxConfig *config
);
gboolean gvir_sandbox_config_add_host_include_strv (GVirSandboxConfig *config
,gchar **includes
,GError **error
);
Parses includes
whose elements are in the format
GUEST-TARGET=ROOT-PATH. If ROOT_PATH is omitted,
then it is assumed to be the same as GUEST-TARGET
gboolean gvir_sandbox_config_add_host_include_file (GVirSandboxConfig *config
,gchar *includefile
,GError **error
);
void gvir_sandbox_config_set_security_label (GVirSandboxConfig *config
,const gchar *label
);
Set the sandbox security label. By default a dynamic security label is chosen. A static security label must be specified if any custom mounts are added
const gchar *
gvir_sandbox_config_get_security_label
(GVirSandboxConfig *config
);
Retrieve the sandbox security label
void gvir_sandbox_config_set_security_dynamic (GVirSandboxConfig *config
,gboolean dynamic
);
Set the SELinux security dynamic for the sandbox. The default dynamic is "svirt_sandbox_t"
gboolean
gvir_sandbox_config_get_security_dynamic
(GVirSandboxConfig *config
);
Retrieve the sandbox security mode
gboolean gvir_sandbox_config_set_security_opts (GVirSandboxConfig *config
,const gchar *optstr
,GError **error
);
void gvir_sandbox_config_set_debug (GVirSandboxConfig *config
,gboolean debug
);
Set whether the container init should print debugging messages.
gboolean
gvir_sandbox_config_get_debug (GVirSandboxConfig *config
);
Retrieves the sandbox debug flag
void gvir_sandbox_config_set_verbose (GVirSandboxConfig *config
,gboolean verbose
);
Set whether the container init should be verbose.
gboolean
gvir_sandbox_config_get_verbose (GVirSandboxConfig *config
);
Retrieves the sandbox verbose flag
gchar **
gvir_sandbox_config_get_command (GVirSandboxConfig *config
);
Retrieve the sandbox command and arguments
struct GVirSandboxConfigClass { GObjectClass parent_class; gboolean (*load_config)(GVirSandboxConfig *config, GKeyFile *file, GError **error); void (*save_config)(GVirSandboxConfig *config, GKeyFile *file); gchar **(*get_command)(GVirSandboxConfig *config); gpointer padding[LIBVIRT_SANDBOX_CLASS_PADDING]; };
“arch”
property “arch” gchar *
The sandbox architecture.
Flags: Read / Write
Default value: NULL
“homedir”
property “homedir” gchar *
The home directory.
Flags: Read / Write
Default value: "/home/berrange"
“kernpath”
property “kernpath” gchar *
The kernel image path.
Flags: Read / Write
Default value: NULL
“kernrelease”
property “kernrelease” gchar *
The kernel release version.
Flags: Read / Write
Default value: NULL
“kmodpath”
property “kmodpath” gchar *
Kernel modules path.
Flags: Read / Write
Default value: NULL
“name”
property “name” gchar *
The sandbox name.
Flags: Read / Write / Construct Only
Default value: NULL
“security-dynamic”
property “security-dynamic” gboolean
The security mode.
Flags: Read / Write
Default value: TRUE
“security-label”
property “security-label” gchar *
The security label.
Flags: Read / Write
Default value: NULL
“username”
property “username” gchar *
The username.
Flags: Read / Write
Default value: "berrange"