Commit 8930fd9a authored by Daniel P. Berrange's avatar Daniel P. Berrange

Refactor the GVirSandboxConfigMount class

The current GVirSandboxConfigMount classs is too inflexible,
since it specialized to deal with mounts that have a file
source. RAM filesystems do not, nor do various network FS.
Split it into two parsts, the base GVirSandboxConfigMount
holding the mount target info, and a subclass for the file
specific data GVirSandboxConfigMountFile.

Further specialize this to provide one subclass per type
of mount GVirSandboxConfigMountHostBind,
GVirSandboxConfigMountHostImage and GVirSandboxConfigMountGuestBind
parent a0ad3bd5
......@@ -244,15 +244,13 @@ WantedBy=multi-user.target
pass
def __add_mount(self, source, dest):
mount = LibvirtSandbox.ConfigMount.new(dest)
mount.set_root(source)
mount = LibvirtSandbox.ConfigMountHostBind.new(source, dest)
self.config.add_host_bind_mount(mount)
def __gen_filesystems(self):
if self.use_image:
self.image = self.DEFAULT_IMAGE % self.get_name()
mount = LibvirtSandbox.ConfigMount.new(self.dest)
mount.set_root(self.image)
mount = LibvirtSandbox.ConfigMountHostImage.new(self.image, self.dest)
self.config.add_host_image_mount(mount)
for d in self.SYSTEM_DIRS:
......
......@@ -58,6 +58,10 @@ SANDBOX_HEADER_FILES = \
libvirt-sandbox-config-network-address.h \
libvirt-sandbox-config-network-route.h \
libvirt-sandbox-config-mount.h \
libvirt-sandbox-config-mount-file.h \
libvirt-sandbox-config-mount-host-bind.h \
libvirt-sandbox-config-mount-host-image.h \
libvirt-sandbox-config-mount-guest-bind.h \
libvirt-sandbox-config-initrd.h \
libvirt-sandbox-config-graphical.h \
libvirt-sandbox-config-interactive.h \
......@@ -82,6 +86,10 @@ SANDBOX_SOURCE_FILES = \
libvirt-sandbox-config-network-address.c \
libvirt-sandbox-config-network-route.c \
libvirt-sandbox-config-mount.c \
libvirt-sandbox-config-mount-file.c \
libvirt-sandbox-config-mount-host-bind.c \
libvirt-sandbox-config-mount-host-image.c \
libvirt-sandbox-config-mount-guest-bind.c \
libvirt-sandbox-config-initrd.c \
libvirt-sandbox-config-graphical.c \
libvirt-sandbox-config-interactive.c \
......
......@@ -245,15 +245,15 @@ static gboolean gvir_sandbox_builder_container_construct_devices(GVirSandboxBuil
tmp = mounts = gvir_sandbox_config_get_host_bind_mounts(config);
while (tmp) {
GVirSandboxConfigMount *mconfig = tmp->data;
GVirSandboxConfigMountFile *mconfig = tmp->data;
fs = gvir_config_domain_filesys_new();
gvir_config_domain_filesys_set_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_MOUNT);
gvir_config_domain_filesys_set_access_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_ACCESS_PASSTHROUGH);
gvir_config_domain_filesys_set_source(fs,
gvir_sandbox_config_mount_get_root(mconfig));
gvir_sandbox_config_mount_file_get_source(mconfig));
gvir_config_domain_filesys_set_target(fs,
gvir_sandbox_config_mount_get_target(mconfig));
gvir_sandbox_config_mount_get_target(GVIR_SANDBOX_CONFIG_MOUNT(mconfig)));
gvir_config_domain_add_device(domain,
GVIR_CONFIG_DOMAIN_DEVICE(fs));
......@@ -267,15 +267,15 @@ static gboolean gvir_sandbox_builder_container_construct_devices(GVirSandboxBuil
tmp = mounts = gvir_sandbox_config_get_host_image_mounts(config);
while (tmp) {
GVirSandboxConfigMount *mconfig = tmp->data;
GVirSandboxConfigMountFile *mconfig = tmp->data;
fs = gvir_config_domain_filesys_new();
gvir_config_domain_filesys_set_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_FILE);
gvir_config_domain_filesys_set_access_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_ACCESS_PASSTHROUGH);
gvir_config_domain_filesys_set_source(fs,
gvir_sandbox_config_mount_get_root(mconfig));
gvir_sandbox_config_mount_file_get_source(mconfig));
gvir_config_domain_filesys_set_target(fs,
gvir_sandbox_config_mount_get_target(mconfig));
gvir_sandbox_config_mount_get_target(GVIR_SANDBOX_CONFIG_MOUNT(mconfig)));
gvir_config_domain_add_device(domain,
GVIR_CONFIG_DOMAIN_DEVICE(fs));
......
......@@ -449,14 +449,14 @@ static gboolean gvir_sandbox_builder_machine_construct_devices(GVirSandboxBuilde
tmp = mounts = gvir_sandbox_config_get_host_bind_mounts(config);
i = 0;
while (tmp) {
GVirSandboxConfigMount *mconfig = tmp->data;
GVirSandboxConfigMountFile *mconfig = tmp->data;
gchar *target = g_strdup_printf("sandbox:mount%d", i);
fs = gvir_config_domain_filesys_new();
gvir_config_domain_filesys_set_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_MOUNT);
gvir_config_domain_filesys_set_access_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_ACCESS_MAPPED);
gvir_config_domain_filesys_set_source(fs,
gvir_sandbox_config_mount_get_root(mconfig));
gvir_sandbox_config_mount_file_get_source(mconfig));
gvir_config_domain_filesys_set_target(fs, target);
gvir_config_domain_add_device(domain,
......@@ -474,13 +474,13 @@ static gboolean gvir_sandbox_builder_machine_construct_devices(GVirSandboxBuilde
tmp = mounts = gvir_sandbox_config_get_host_image_mounts(config);
i = 0;
while (tmp) {
GVirSandboxConfigMount *mconfig = tmp->data;
GVirSandboxConfigMountFile *mconfig = tmp->data;
gchar *target = g_strdup_printf("vd%c", 'a' + i);
disk = gvir_config_domain_disk_new();
gvir_config_domain_disk_set_type(disk, GVIR_CONFIG_DOMAIN_DISK_FILE);
gvir_config_domain_disk_set_source(disk,
gvir_sandbox_config_mount_get_root(mconfig));
gvir_sandbox_config_mount_file_get_source(mconfig));
gvir_config_domain_disk_set_target_dev(disk, target);
gvir_config_domain_add_device(domain,
......
/*
* libvirt-sandbox-config-mount-file.c: libvirt sandbox configuration
*
* Copyright (C) 2011-2012 Red Hat, Inc.
*
* 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
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#include <config.h>
#include <string.h>
#include "libvirt-sandbox/libvirt-sandbox.h"
/**
* SECTION: libvirt-sandbox-config-mount-file
* @short_description: Filesystem attachment configuration details
* @include: libvirt-sandbox/libvirt-sandbox.h
* @see_aloso: #GVirSandboxConfig
*
* Provides an object to store information about a filesystem attachment in the sandbox
*
* The GVirSandboxConfigMount object stores information required to attach
* a host filesystem to the application sandbox. The sandbox starts off with
* a complete view of the host filesystem. This object allows a specific
* area of the host filesystem to be hidden and replaced with alternate
* content.
*/
#define GVIR_SANDBOX_CONFIG_MOUNT_FILE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_FILE, GVirSandboxConfigMountFilePrivate))
struct _GVirSandboxConfigMountFilePrivate
{
gchar *source;
};
G_DEFINE_ABSTRACT_TYPE(GVirSandboxConfigMountFile, gvir_sandbox_config_mount_file, GVIR_SANDBOX_TYPE_CONFIG_MOUNT);
enum {
PROP_0,
PROP_SOURCE,
};
enum {
LAST_SIGNAL
};
//static gint signals[LAST_SIGNAL];
static void gvir_sandbox_config_mount_file_get_property(GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GVirSandboxConfigMountFile *config = GVIR_SANDBOX_CONFIG_MOUNT_FILE(object);
GVirSandboxConfigMountFilePrivate *priv = config->priv;
switch (prop_id) {
case PROP_SOURCE:
g_value_set_string(value, priv->source);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
}
static void gvir_sandbox_config_mount_file_set_property(GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GVirSandboxConfigMountFile *config = GVIR_SANDBOX_CONFIG_MOUNT_FILE(object);
GVirSandboxConfigMountFilePrivate *priv = config->priv;
switch (prop_id) {
case PROP_SOURCE:
g_free(priv->source);
priv->source = g_value_dup_string(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
}
static void gvir_sandbox_config_mount_file_finalize(GObject *object)
{
GVirSandboxConfigMountFile *config = GVIR_SANDBOX_CONFIG_MOUNT_FILE(object);
GVirSandboxConfigMountFilePrivate *priv = config->priv;
g_free(priv->source);
G_OBJECT_CLASS(gvir_sandbox_config_mount_file_parent_class)->finalize(object);
}
static void gvir_sandbox_config_mount_file_class_init(GVirSandboxConfigMountFileClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->finalize = gvir_sandbox_config_mount_file_finalize;
object_class->get_property = gvir_sandbox_config_mount_file_get_property;
object_class->set_property = gvir_sandbox_config_mount_file_set_property;
g_object_class_install_property(object_class,
PROP_SOURCE,
g_param_spec_string("source",
"Source",
"The source directory",
NULL,
G_PARAM_READABLE |
G_PARAM_WRITABLE |
G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB));
g_type_class_add_private(klass, sizeof(GVirSandboxConfigMountFilePrivate));
}
static void gvir_sandbox_config_mount_file_init(GVirSandboxConfigMountFile *config)
{
config->priv = GVIR_SANDBOX_CONFIG_MOUNT_FILE_GET_PRIVATE(config);
}
/**
* gvir_sandbox_config_mount_file_set_source:
* @config: (transfer none): the sandbox mount config
* @source: (transfer none): the host directory
*
* Sets the directory to map to the custom mount. If no
* directory is specified, an empty temporary directory will
* be created
*/
void gvir_sandbox_config_mount_file_set_source(GVirSandboxConfigMountFile *config, const gchar *source)
{
GVirSandboxConfigMountFilePrivate *priv = config->priv;
g_free(priv->source);
priv->source = g_strdup(source);
}
/**
* gvir_sandbox_config_mount_file_get_source:
* @config: (transfer none): the sandbox mount config
*
* Retrieves the directory mapped to the mount (if any)
*
* Returns: (transfer none): the source directory
*/
const gchar *gvir_sandbox_config_mount_file_get_source(GVirSandboxConfigMountFile *config)
{
GVirSandboxConfigMountFilePrivate *priv = config->priv;
return priv->source;
}
/*
* libvirt-sandbox-config-mount-file.h: libvirt sandbox configuration
*
* Copyright (C) 2011-2012 Red Hat, Inc.
*
* 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
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#if !defined(__LIBVIRT_SANDBOX_H__) && !defined(LIBVIRT_SANDBOX_BUILD)
#error "Only <libvirt-sandbox/libvirt-sandbox.h> can be included directly."
#endif
#ifndef __LIBVIRT_SANDBOX_CONFIG_MOUNT_FILE_H__
#define __LIBVIRT_SANDBOX_CONFIG_MOUNT_FILE_H__
G_BEGIN_DECLS
#define GVIR_SANDBOX_TYPE_CONFIG_MOUNT_FILE (gvir_sandbox_config_mount_file_get_type ())
#define GVIR_SANDBOX_CONFIG_MOUNT_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_FILE, GVirSandboxConfigMountFile))
#define GVIR_SANDBOX_CONFIG_MOUNT_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_FILE, GVirSandboxConfigMountFileClass))
#define GVIR_SANDBOX_IS_CONFIG_MOUNT_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_FILE))
#define GVIR_SANDBOX_IS_CONFIG_MOUNT_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_FILE))
#define GVIR_SANDBOX_CONFIG_MOUNT_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_FILE, GVirSandboxConfigMountFileClass))
typedef struct _GVirSandboxConfigMountFile GVirSandboxConfigMountFile;
typedef struct _GVirSandboxConfigMountFilePrivate GVirSandboxConfigMountFilePrivate;
typedef struct _GVirSandboxConfigMountFileClass GVirSandboxConfigMountFileClass;
struct _GVirSandboxConfigMountFile
{
GVirSandboxConfigMount parent;
GVirSandboxConfigMountFilePrivate *priv;
/* Do not add fields to this struct */
};
struct _GVirSandboxConfigMountFileClass
{
GVirSandboxConfigMountClass parent_class;
};
GType gvir_sandbox_config_mount_file_get_type(void);
void gvir_sandbox_config_mount_file_set_source(GVirSandboxConfigMountFile *config, const gchar *source);
const gchar *gvir_sandbox_config_mount_file_get_source(GVirSandboxConfigMountFile *config);
G_END_DECLS
#endif /* __LIBVIRT_SANDBOX_CONFIG_MOUNT_FILE_H__ */
/*
* libvirt-sandbox-config-mount-guest-bind.c: libvirt sandbox configuration
*
* Copyright (C) 2011-2012 Red Hat, Inc.
*
* 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
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#include <config.h>
#include <string.h>
#include "libvirt-sandbox/libvirt-sandbox.h"
/**
* SECTION: libvirt-sandbox-config-mount-bind
* @short_description: Bindsystem attachment configuration details
* @include: libvirt-sandbox/libvirt-sandbox.h
* @see_aloso: #GVirSandboxConfig
*
* Provides an object to store information about a bindsystem attachment in the sandbox
*
* The GVirSandboxConfigMount object stores information required to attach
* a guest bindsystem to the application sandbox. The sandbox starts off with
* a complete view of the guest bindsystem. This object allows a specific
* area of the guest bindsystem to be hidden and replaced with alternate
* content.
*/
#define GVIR_SANDBOX_CONFIG_MOUNT_GUEST_BIND_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_GUEST_BIND, GVirSandboxConfigMountGuestBindPrivate))
struct _GVirSandboxConfigMountGuestBindPrivate
{
gboolean unused;
};
G_DEFINE_TYPE(GVirSandboxConfigMountGuestBind, gvir_sandbox_config_mount_guest_bind, GVIR_SANDBOX_TYPE_CONFIG_MOUNT_FILE);
static void gvir_sandbox_config_mount_guest_bind_class_init(GVirSandboxConfigMountGuestBindClass *klass)
{
g_type_class_add_private(klass, sizeof(GVirSandboxConfigMountGuestBindPrivate));
}
static void gvir_sandbox_config_mount_guest_bind_init(GVirSandboxConfigMountGuestBind *config)
{
config->priv = GVIR_SANDBOX_CONFIG_MOUNT_GUEST_BIND_GET_PRIVATE(config);
}
/**
* gvir_sandbox_config_mount_guest_bind_new:
* @targetdir: (transfer none): the target directory
*
* Create a new custom mount mapped to the directory @targetdir
*
* Returns: (transfer full): a new sandbox mount object
*/
GVirSandboxConfigMountGuestBind *gvir_sandbox_config_mount_guest_bind_new(const gchar *source,
const gchar *targetdir)
{
return GVIR_SANDBOX_CONFIG_MOUNT_GUEST_BIND(g_object_new(GVIR_SANDBOX_TYPE_CONFIG_MOUNT_GUEST_BIND,
"source", source,
"target", targetdir,
NULL));
}
/*
* libvirt-sandbox-config-mount-guest-bind.h: libvirt sandbox configuration
*
* Copyright (C) 2011-2012 Red Hat, Inc.
*
* 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
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#if !defined(__LIBVIRT_SANDBOX_H__) && !defined(LIBVIRT_SANDBOX_BUILD)
#error "Only <libvirt-sandbox/libvirt-sandbox.h> can be included directly."
#endif
#ifndef __LIBVIRT_SANDBOX_CONFIG_MOUNT_GUEST_BIND_H__
#define __LIBVIRT_SANDBOX_CONFIG_MOUNT_GUEST_BIND_H__
G_BEGIN_DECLS
#define GVIR_SANDBOX_TYPE_CONFIG_MOUNT_GUEST_BIND (gvir_sandbox_config_mount_guest_bind_get_type ())
#define GVIR_SANDBOX_CONFIG_MOUNT_GUEST_BIND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_GUEST_BIND, GVirSandboxConfigMountGuestBind))
#define GVIR_SANDBOX_CONFIG_MOUNT_GUEST_BIND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_GUEST_BIND, GVirSandboxConfigMountGuestBindClass))
#define GVIR_SANDBOX_IS_CONFIG_MOUNT_GUEST_BIND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_GUEST_BIND))
#define GVIR_SANDBOX_IS_CONFIG_MOUNT_GUEST_BIND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_GUEST_BIND))
#define GVIR_SANDBOX_CONFIG_MOUNT_GUEST_BIND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_GUEST_BIND, GVirSandboxConfigMountGuestBindClass))
typedef struct _GVirSandboxConfigMountGuestBind GVirSandboxConfigMountGuestBind;
typedef struct _GVirSandboxConfigMountGuestBindPrivate GVirSandboxConfigMountGuestBindPrivate;
typedef struct _GVirSandboxConfigMountGuestBindClass GVirSandboxConfigMountGuestBindClass;
struct _GVirSandboxConfigMountGuestBind
{
GVirSandboxConfigMountFile parent;
GVirSandboxConfigMountGuestBindPrivate *priv;
/* Do not add fields to this struct */
};
struct _GVirSandboxConfigMountGuestBindClass
{
GVirSandboxConfigMountFileClass parent_class;
};
GType gvir_sandbox_config_mount_guest_bind_get_type(void);
GVirSandboxConfigMountGuestBind *gvir_sandbox_config_mount_guest_bind_new(const gchar *source,
const gchar *targetdir);
G_END_DECLS
#endif /* __LIBVIRT_SANDBOX_CONFIG_MOUNT_GUEST_BIND_H__ */
/*
* libvirt-sandbox-config-mount-host-bind.c: libvirt sandbox configuration
*
* Copyright (C) 2011-2012 Red Hat, Inc.
*
* 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
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#include <config.h>
#include <string.h>
#include "libvirt-sandbox/libvirt-sandbox.h"
/**
* SECTION: libvirt-sandbox-config-mount-bind
* @short_description: Bindsystem attachment configuration details
* @include: libvirt-sandbox/libvirt-sandbox.h
* @see_aloso: #GVirSandboxConfig
*
* Provides an object to store information about a bindsystem attachment in the sandbox
*
* The GVirSandboxConfigMount object stores information required to attach
* a host bindsystem to the application sandbox. The sandbox starts off with
* a complete view of the host bindsystem. This object allows a specific
* area of the host bindsystem to be hidden and replaced with alternate
* content.
*/
#define GVIR_SANDBOX_CONFIG_MOUNT_HOST_BIND_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_HOST_BIND, GVirSandboxConfigMountHostBindPrivate))
struct _GVirSandboxConfigMountHostBindPrivate
{
gboolean unused;
};
G_DEFINE_TYPE(GVirSandboxConfigMountHostBind, gvir_sandbox_config_mount_host_bind, GVIR_SANDBOX_TYPE_CONFIG_MOUNT_FILE);
static void gvir_sandbox_config_mount_host_bind_class_init(GVirSandboxConfigMountHostBindClass *klass)
{
g_type_class_add_private(klass, sizeof(GVirSandboxConfigMountHostBindPrivate));
}
static void gvir_sandbox_config_mount_host_bind_init(GVirSandboxConfigMountHostBind *config)
{
config->priv = GVIR_SANDBOX_CONFIG_MOUNT_HOST_BIND_GET_PRIVATE(config);
}
/**
* gvir_sandbox_config_mount_host_bind_new:
* @targetdir: (transfer none): the target directory
*
* Create a new custom mount mapped to the directory @targetdir
*
* Returns: (transfer full): a new sandbox mount object
*/
GVirSandboxConfigMountHostBind *gvir_sandbox_config_mount_host_bind_new(const gchar *source,
const gchar *targetdir)
{
return GVIR_SANDBOX_CONFIG_MOUNT_HOST_BIND(g_object_new(GVIR_SANDBOX_TYPE_CONFIG_MOUNT_HOST_BIND,
"source", source,
"target", targetdir,
NULL));
}
/*
* libvirt-sandbox-config-mount-host-bind.h: libvirt sandbox configuration
*
* Copyright (C) 2011-2012 Red Hat, Inc.
*
* 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
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#if !defined(__LIBVIRT_SANDBOX_H__) && !defined(LIBVIRT_SANDBOX_BUILD)
#error "Only <libvirt-sandbox/libvirt-sandbox.h> can be included directly."
#endif
#ifndef __LIBVIRT_SANDBOX_CONFIG_MOUNT_HOST_BIND_H__
#define __LIBVIRT_SANDBOX_CONFIG_MOUNT_HOST_BIND_H__
G_BEGIN_DECLS
#define GVIR_SANDBOX_TYPE_CONFIG_MOUNT_HOST_BIND (gvir_sandbox_config_mount_host_bind_get_type ())
#define GVIR_SANDBOX_CONFIG_MOUNT_HOST_BIND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_HOST_BIND, GVirSandboxConfigMountHostBind))
#define GVIR_SANDBOX_CONFIG_MOUNT_HOST_BIND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_HOST_BIND, GVirSandboxConfigMountHostBindClass))
#define GVIR_SANDBOX_IS_CONFIG_MOUNT_HOST_BIND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_HOST_BIND))
#define GVIR_SANDBOX_IS_CONFIG_MOUNT_HOST_BIND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_HOST_BIND))
#define GVIR_SANDBOX_CONFIG_MOUNT_HOST_BIND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_HOST_BIND, GVirSandboxConfigMountHostBindClass))
typedef struct _GVirSandboxConfigMountHostBind GVirSandboxConfigMountHostBind;
typedef struct _GVirSandboxConfigMountHostBindPrivate GVirSandboxConfigMountHostBindPrivate;
typedef struct _GVirSandboxConfigMountHostBindClass GVirSandboxConfigMountHostBindClass;
struct _GVirSandboxConfigMountHostBind
{
GVirSandboxConfigMountFile parent;
GVirSandboxConfigMountHostBindPrivate *priv;
/* Do not add fields to this struct */
};
struct _GVirSandboxConfigMountHostBindClass
{
GVirSandboxConfigMountFileClass parent_class;
};
GType gvir_sandbox_config_mount_host_bind_get_type(void);
GVirSandboxConfigMountHostBind *gvir_sandbox_config_mount_host_bind_new(const gchar *source,
const gchar *targetdir);
G_END_DECLS
#endif /* __LIBVIRT_SANDBOX_CONFIG_MOUNT_HOST_BIND_H__ */
/*
* libvirt-sandbox-config-mount-host-image.c: libvirt sandbox configuration
*
* Copyright (C) 2011-2012 Red Hat, Inc.
*
* 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
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#include <config.h>
#include <string.h>
#include "libvirt-sandbox/libvirt-sandbox.h"
/**
* SECTION: libvirt-sandbox-config-mount-image
* @short_description: Imagesystem attachment configuration details
* @include: libvirt-sandbox/libvirt-sandbox.h
* @see_aloso: #GVirSandboxConfig
*
* Provides an object to store information about a imagesystem attachment in the sandbox
*
* The GVirSandboxConfigMount object stores information required to attach
* a host imagesystem to the application sandbox. The sandbox starts off with
* a complete view of the host imagesystem. This object allows a specific
* area of the host imagesystem to be hidden and replaced with alternate
* content.
*/
#define GVIR_SANDBOX_CONFIG_MOUNT_HOST_IMAGE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_SANDBOX_TYPE_CONFIG_MOUNT_HOST_IMAGE, GVirSandboxConfigMountHostImagePrivate))
struct _GVirSandboxConfigMountHostImagePrivate
{
gboolean unused;
};
G_DEFINE_TYPE(GVirSandboxConfigMountHostImage, gvir_sandbox_config_mount_host_image, GVIR_SANDBOX_TYPE_CONFIG_MOUNT_FILE);
static void gvir_sandbox_config_mount_host_image_class_init(GVirSandboxConfigMountHostImageClass *klass)
{
g_type_class_add_private(klass, sizeof(GVirSandboxConfigMountHostImagePrivate));
}
static void gvir_sandbox_config_mount_host_image_init(GVirSandboxConfigMountHostImage *config)
{
config->priv = GVIR_SANDBOX_CONFIG_MOUNT_HOST_IMAGE_GET_PRIVATE(config);
}
/**
* gvir_sandbox_config_mount_host_image_new: