Commit 6f80f10e authored by Daniel P. Berrange's avatar Daniel P. Berrange

Add classes for building & running containers

parent 631dae32
......@@ -9,11 +9,19 @@ SANDBOX_HEADER_FILES = \
libvirt-sandbox-config.h \
libvirt-sandbox-config-graphical.h \
libvirt-sandbox-config-mount.h \
libvirt-sandbox-builder.h \
libvirt-sandbox-builder-machine.h \
libvirt-sandbox-builder-container.h \
libvirt-sandbox-context.h \
$(NULL)
SANDBOX_SOURCE_FILES = \
libvirt-sandbox-config.c \
libvirt-sandbox-config-graphical.c \
libvirt-sandbox-config-mount.c \
libvirt-sandbox-builder.c \
libvirt-sandbox-builder-machine.c \
libvirt-sandbox-builder-container.c \
libvirt-sandbox-context.c \
$(NULL)
libvirt_sandbox_1_0_ladir = $(includedir)/libvirt-sandbox-1.0/libvirt-sandbox
......@@ -24,6 +32,7 @@ libvirt_sandbox_1_0_la_SOURCES = \
libvirt_sandbox_1_0_la_CFLAGS = \
-DDATADIR="\"$(datadir)\"" \
-DLIBVIRT_SANDBOX_BUILD \
-DLIBEXECDIR="\"$(libexecdir)\"" \
$(COVERAGE_CFLAGS) \
-I$(top_srcdir) \
$(LIBVIRT_GOBJECT_CFLAGS) \
......
/*
* libvirt-sandbox-builder-container.c: libvirt sandbox configuration
*
* Copyright (C) 2011 Red Hat
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#include <config.h>
#include <string.h>
#include "libvirt-sandbox/libvirt-sandbox.h"
#define GVIR_SANDBOX_BUILDER_CONTAINER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_SANDBOX_TYPE_BUILDER_CONTAINER, GVirSandboxBuilderContainerPrivate))
struct _GVirSandboxBuilderContainerPrivate
{
gboolean unused;
};
G_DEFINE_TYPE(GVirSandboxBuilderContainer, gvir_sandbox_builder_container, GVIR_SANDBOX_TYPE_BUILDER);
enum {
PROP_0,
};
enum {
LAST_SIGNAL
};
//static gint signals[LAST_SIGNAL];
#define GVIR_SANDBOX_BUILDER_CONTAINER_ERROR gvir_sandbox_builder_container_error_quark()
static GQuark
gvir_sandbox_builder_container_error_quark(void)
{
return g_quark_from_static_string("gvir-sandbox-builder-container");
}
static void gvir_sandbox_builder_container_get_property(GObject *object,
guint prop_id,
GValue *value G_GNUC_UNUSED,
GParamSpec *pspec)
{
#if 0
GVirSandboxBuilderContainer *builder = GVIR_SANDBOX_BUILDER_CONTAINER(object);
GVirSandboxBuilderContainerPrivate *priv = builder->priv;
#endif
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
}
static void gvir_sandbox_builder_container_set_property(GObject *object,
guint prop_id,
const GValue *value G_GNUC_UNUSED,
GParamSpec *pspec)
{
#if 0
GVirSandboxBuilderContainer *builder = GVIR_SANDBOX_BUILDER_CONTAINER(object);
GVirSandboxBuilderContainerPrivate *priv = builder->priv;
#endif
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
}
static void gvir_sandbox_builder_container_finalize(GObject *object)
{
#if 0
GVirSandboxBuilderContainer *builder = GVIR_SANDBOX_BUILDER_CONTAINER(object);
GVirSandboxBuilderContainerPrivate *priv = builder->priv;
#endif
G_OBJECT_CLASS(gvir_sandbox_builder_container_parent_class)->finalize(object);
}
static GVirConfigDomain *gvir_sandbox_builder_container_construct(GVirSandboxBuilder *builder G_GNUC_UNUSED,
GError **error G_GNUC_UNUSED)
{
GVirSandboxConfig *config = gvir_sandbox_builder_get_config(builder);
GString *str = g_string_new("<domain type='lxc'>\n");
GVirConfigDomain *dom;
const gchar *cmdline = "";
GList *mounts = NULL, *tmp = NULL;
g_string_append_printf(str, " <name>%s</name>\n",
gvir_sandbox_config_get_name(config));
g_string_append_printf(str, " <memory>%d</memory>\n", 512*1024);
g_string_append(str, " <os>\n");
g_string_append_printf(str, " <type arch='%s'>exe</type>\n",
gvir_sandbox_config_get_arch(config));
g_string_append_printf(str, " <init>%s</init>\n", LIBEXECDIR "/libvirt-sandbox-init-lxc");
g_string_append_printf(str, " <cmdline>%s</cmdline>\n", cmdline);
g_string_append(str, " </os>\n");
g_string_append(str, " <devices>\n");
g_string_append(str, " <console type='pty'/>\n");
g_string_append(str, " <filesystem type='mount' accessmode='passthrough'>\n");
g_string_append_printf(str, " <source dir='%s'/>\n",
gvir_sandbox_config_get_root(config));
g_string_append(str, " <target dir='/'/>\n");
g_string_append(str, " <readonly/>\n");
g_string_append(str, " </filesystem>\n");
tmp = mounts = gvir_sandbox_config_get_mounts(config);
while (tmp) {
GVirSandboxConfigMount *mconfig = tmp->data;
g_string_append(str, " <filesystem type='mount' accessmode='passthrough'>\n");
g_string_append_printf(str, " <source dir='%s'/>\n",
gvir_sandbox_config_mount_get_root(mconfig));
g_string_append_printf(str, " <target dir='%s'/>\n",
gvir_sandbox_config_mount_get_target(mconfig));
g_string_append(str, " <readonly/>\n");
g_string_append(str, " </filesystem>\n");
tmp = tmp->next;
}
g_list_foreach(mounts, (GFunc)g_object_unref, NULL);
g_list_free(mounts);
mounts = NULL;
if (GVIR_SANDBOX_IS_CONFIG_GRAPHICAL(config)) {
*error = g_error_new(GVIR_SANDBOX_BUILDER_CONTAINER_ERROR, 0,
"%s", "Graphical sandboxes are not supported for containers");
goto error;
}
g_string_append(str, " </devices>\n");
if (gvir_sandbox_config_get_security_level(config)) {
g_string_append(str, " <seclabel type='static' model='selinux'>\n");
g_string_append_printf(str, " <label>system_u:system_r:%s:s0:%s</label>\n",
gvir_sandbox_config_get_security_type(config),
gvir_sandbox_config_get_security_level(config));
g_string_append(str, " </seclabel>\n");
} else {
g_string_append(str, " <seclabel type='dynamic' model='selinux'>\n");
g_string_append_printf(str, " <baselabel>system_u:system_r:%s:s0</baselabel>\n",
gvir_sandbox_config_get_security_type(config));
g_string_append(str, " </seclabel>\n");
}
g_string_append(str, "</domain>");
dom = gvir_config_domain_new_from_xml(str->str, error);
g_string_free(str, TRUE);
return dom;
error:
g_string_free(str, TRUE);
return NULL;
}
static void gvir_sandbox_builder_container_class_init(GVirSandboxBuilderContainerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
GVirSandboxBuilderClass *builder_class = GVIR_SANDBOX_BUILDER_CLASS(klass);
object_class->finalize = gvir_sandbox_builder_container_finalize;
object_class->get_property = gvir_sandbox_builder_container_get_property;
object_class->set_property = gvir_sandbox_builder_container_set_property;
builder_class->construct = gvir_sandbox_builder_container_construct;
g_type_class_add_private(klass, sizeof(GVirSandboxBuilderContainerPrivate));
}
static void gvir_sandbox_builder_container_init(GVirSandboxBuilderContainer *builder)
{
builder->priv = GVIR_SANDBOX_BUILDER_CONTAINER_GET_PRIVATE(builder);
}
/**
* gvir_sandbox_builder_container_new:
* @connection: (transfer none): the connection
* @config: (transfer none): the sandbox configuration
*
* Create a new graphical application sandbox builderuration
*
* Returns: (transfer full): a new graphical sandbox builder object
*/
GVirSandboxBuilderContainer *gvir_sandbox_builder_container_new(GVirConnection *connection,
GVirSandboxConfig *config)
{
return GVIR_SANDBOX_BUILDER_CONTAINER(g_object_new(GVIR_SANDBOX_TYPE_BUILDER_CONTAINER,
"connection", connection,
"config", config,
NULL));
}
/*
* libvirt-sandbox-builder-container.h: libvirt sandbox builder for virtual containers
*
* Copyright (C) 2011 Red Hat
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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_BUILDER_CONTAINER_H__
#define __LIBVIRT_SANDBOX_BUILDER_CONTAINER_H__
G_BEGIN_DECLS
#define GVIR_SANDBOX_TYPE_BUILDER_CONTAINER (gvir_sandbox_builder_container_get_type ())
#define GVIR_SANDBOX_BUILDER_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_SANDBOX_TYPE_BUILDER_CONTAINER, GVirSandboxBuilderContainer))
#define GVIR_SANDBOX_BUILDER_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_SANDBOX_TYPE_BUILDER_CONTAINER, GVirSandboxBuilderContainerClass))
#define GVIR_SANDBOX_IS_BUILDER_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_SANDBOX_TYPE_BUILDER_CONTAINER))
#define GVIR_SANDBOX_IS_BUILDER_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_SANDBOX_TYPE_BUILDER_CONTAINER))
#define GVIR_SANDBOX_BUILDER_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_SANDBOX_TYPE_BUILDER_CONTAINER, GVirSandboxBuilderContainerClass))
typedef struct _GVirSandboxBuilderContainer GVirSandboxBuilderContainer;
typedef struct _GVirSandboxBuilderContainerPrivate GVirSandboxBuilderContainerPrivate;
typedef struct _GVirSandboxBuilderContainerClass GVirSandboxBuilderContainerClass;
struct _GVirSandboxBuilderContainer
{
GVirSandboxBuilder parent;
GVirSandboxBuilderContainerPrivate *priv;
/* Do not add fields to this struct */
};
struct _GVirSandboxBuilderContainerClass
{
GVirSandboxBuilderClass parent_class;
};
GType gvir_sandbox_builder_container_get_type(void);
GVirSandboxBuilderContainer *gvir_sandbox_builder_container_new(GVirConnection *connection,
GVirSandboxConfig *config);
G_END_DECLS
#endif /* __LIBVIRT_SANDBOX_BUILDER_CONTAINER_H__ */
/*
* libvirt-sandbox-builder-machine.c: libvirt sandbox configuration
*
* Copyright (C) 2011 Red Hat
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#include <config.h>
#include <string.h>
#include "libvirt-sandbox/libvirt-sandbox.h"
#define GVIR_SANDBOX_BUILDER_MACHINE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_SANDBOX_TYPE_BUILDER_MACHINE, GVirSandboxBuilderMachinePrivate))
struct _GVirSandboxBuilderMachinePrivate
{
gboolean unused;
};
G_DEFINE_TYPE(GVirSandboxBuilderMachine, gvir_sandbox_builder_machine, GVIR_SANDBOX_TYPE_BUILDER);
enum {
PROP_0,
};
enum {
LAST_SIGNAL
};
//static gint signals[LAST_SIGNAL];
#define GVIR_SANDBOX_BUILDER_MACHINE_ERROR gvir_sandbox_builder_machine_error_quark()
static GQuark
gvir_sandbox_builder_machine_error_quark(void)
{
return g_quark_from_static_string("gvir-sandbox-builder-machine");
}
static void gvir_sandbox_builder_machine_get_property(GObject *object,
guint prop_id,
GValue *value G_GNUC_UNUSED,
GParamSpec *pspec)
{
#if 0
GVirSandboxBuilderMachine *builder = GVIR_SANDBOX_BUILDER_MACHINE(object);
GVirSandboxBuilderMachinePrivate *priv = builder->priv;
#endif
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
}
static void gvir_sandbox_builder_machine_set_property(GObject *object,
guint prop_id,
const GValue *value G_GNUC_UNUSED,
GParamSpec *pspec)
{
#if 0
GVirSandboxBuilderMachine *builder = GVIR_SANDBOX_BUILDER_MACHINE(object);
GVirSandboxBuilderMachinePrivate *priv = builder->priv;
#endif
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
}
static void gvir_sandbox_builder_machine_finalize(GObject *object)
{
#if 0
GVirSandboxBuilderMachine *builder = GVIR_SANDBOX_BUILDER_MACHINE(object);
GVirSandboxBuilderMachinePrivate *priv = builder->priv;
#endif
G_OBJECT_CLASS(gvir_sandbox_builder_machine_parent_class)->finalize(object);
}
static GVirConfigDomain *gvir_sandbox_builder_machine_construct(GVirSandboxBuilder *builder,
GError **error)
{
GVirSandboxConfig *config = gvir_sandbox_builder_get_config(builder);
GString *str = g_string_new("<domain type='kvm'>\n");
GVirConfigDomain *dom;
const gchar *kernel = "";
const gchar *initrd = "";
const gchar *cmdline = "";
GList *mounts = NULL, *tmp = NULL;
g_string_append_printf(str, " <name>%s</name>\n",
gvir_sandbox_config_get_name(config));
g_string_append_printf(str, " <memory>%d</memory>\n", 512*1024);
g_string_append(str, " <os>\n");
g_string_append_printf(str, " <type arch='%s'>hvm</type>\n",
gvir_sandbox_config_get_arch(config));
g_string_append_printf(str, " <kernel>%s</kernel>\n", kernel);
g_string_append_printf(str, " <initrd>%s</initrd>\n", initrd);
g_string_append_printf(str, " <cmdline>%s</cmdline>\n", cmdline);
g_string_append(str, " </os>\n");
g_string_append(str, " <features>\n");
g_string_append(str, " <acpi/>\n");
g_string_append(str, " </features>\n");
g_string_append(str, " <devices>\n");
g_string_append(str, " <console type='pty'/>\n");
g_string_append(str, " <filesystem type='mount' accessmode='passthrough'>\n");
g_string_append_printf(str, " <source dir='%s'/>\n",
gvir_sandbox_config_get_root(config));
g_string_append(str, " <target dir='sandbox:root'/>\n");
g_string_append(str, " <readonly/>\n");
g_string_append(str, " </filesystem>\n");
tmp = mounts = gvir_sandbox_config_get_mounts(config);
while (tmp) {
GVirSandboxConfigMount *mconfig = tmp->data;
const gchar *home = getenv("HOME");
const gchar *tgtsym;
const gchar *target = gvir_sandbox_config_mount_get_target(mconfig);
if (home &&
(strcmp(target, home) == 0))
tgtsym = "sandbox:home";
else if (strcmp(target, "/tmp") == 0)
tgtsym = "sandbox:tmp";
else {
*error = g_error_new(GVIR_SANDBOX_BUILDER_MACHINE_ERROR, 0,
"Cannot export mount to %s", target);
goto error;
}
g_string_append(str, " <filesystem type='mount' accessmode='passthrough'>\n");
g_string_append_printf(str, " <source dir='%s'/>\n",
gvir_sandbox_config_mount_get_root(mconfig));
g_string_append_printf(str, " <target dir='%s'/>\n", tgtsym);
g_string_append(str, " <readonly/>\n");
g_string_append(str, " </filesystem>\n");
tmp = tmp->next;
}
g_list_foreach(mounts, (GFunc)g_object_unref, NULL);
g_list_free(mounts);
mounts = NULL;
g_string_append(str, " <memballoon model='none'/>\n");
if (GVIR_SANDBOX_IS_CONFIG_GRAPHICAL(config)) {
const gchar *xauth = getenv("XAUTHORITY");
if (xauth)
g_string_append_printf(str, " <graphics type='sdl' display=':0' xauth='%s'/>\n", xauth);
else
g_string_append(str, " <graphics type='sdl' display=':0'/>\n");
}
g_string_append(str, " </devices>\n");
if (gvir_sandbox_config_get_security_level(config)) {
g_string_append(str, " <seclabel type='static' model='selinux'>\n");
g_string_append_printf(str, " <label>system_u:system_r:%s:s0:%s</label>\n",
gvir_sandbox_config_get_security_type(config),
gvir_sandbox_config_get_security_level(config));
g_string_append(str, " </seclabel>\n");
} else {
g_string_append(str, " <seclabel type='dynamic' model='selinux'>\n");
g_string_append_printf(str, " <baselabel>system_u:system_r:%s:s0</baselabel>\n",
gvir_sandbox_config_get_security_type(config));
g_string_append(str, " </seclabel>\n");
}
g_string_append(str, "</domain>");
dom = gvir_config_domain_new_from_xml(str->str, error);
g_string_free(str, TRUE);
return dom;
error:
g_list_foreach(mounts, (GFunc)g_object_unref, NULL);
g_list_free(mounts);
g_string_free(str, TRUE);
return NULL;
}
static void gvir_sandbox_builder_machine_class_init(GVirSandboxBuilderMachineClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
GVirSandboxBuilderClass *builder_class = GVIR_SANDBOX_BUILDER_CLASS(klass);
object_class->finalize = gvir_sandbox_builder_machine_finalize;
object_class->get_property = gvir_sandbox_builder_machine_get_property;
object_class->set_property = gvir_sandbox_builder_machine_set_property;
builder_class->construct = gvir_sandbox_builder_machine_construct;
g_type_class_add_private(klass, sizeof(GVirSandboxBuilderMachinePrivate));
}
static void gvir_sandbox_builder_machine_init(GVirSandboxBuilderMachine *builder)
{
builder->priv = GVIR_SANDBOX_BUILDER_MACHINE_GET_PRIVATE(builder);
}
/**
* gvir_sandbox_builder_machine_new:
* @connection: (transfer none): the connection
* @config: (transfer none): the sandbox configuration
*
* Create a new graphical application sandbox builderuration
*
* Returns: (transfer full): a new graphical sandbox builder object
*/
GVirSandboxBuilderMachine *gvir_sandbox_builder_machine_new(GVirConnection *connection,
GVirSandboxConfig *config)
{
return GVIR_SANDBOX_BUILDER_MACHINE(g_object_new(GVIR_SANDBOX_TYPE_BUILDER_MACHINE,
"connection", connection,
"config", config,
NULL));
}
/*
* libvirt-sandbox-builder-machine.h: libvirt sandbox builder for virtual machines
*
* Copyright (C) 2011 Red Hat
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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_BUILDER_MACHINE_H__
#define __LIBVIRT_SANDBOX_BUILDER_MACHINE_H__
G_BEGIN_DECLS
#define GVIR_SANDBOX_TYPE_BUILDER_MACHINE (gvir_sandbox_builder_machine_get_type ())
#define GVIR_SANDBOX_BUILDER_MACHINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_SANDBOX_TYPE_BUILDER_MACHINE, GVirSandboxBuilderMachine))
#define GVIR_SANDBOX_BUILDER_MACHINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_SANDBOX_TYPE_BUILDER_MACHINE, GVirSandboxBuilderMachineClass))
#define GVIR_SANDBOX_IS_BUILDER_MACHINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_SANDBOX_TYPE_BUILDER_MACHINE))
#define GVIR_SANDBOX_IS_BUILDER_MACHINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_SANDBOX_TYPE_BUILDER_MACHINE))
#define GVIR_SANDBOX_BUILDER_MACHINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_SANDBOX_TYPE_BUILDER_MACHINE, GVirSandboxBuilderMachineClass))
typedef struct _GVirSandboxBuilderMachine GVirSandboxBuilderMachine;
typedef struct _GVirSandboxBuilderMachinePrivate GVirSandboxBuilderMachinePrivate;
typedef struct _GVirSandboxBuilderMachineClass GVirSandboxBuilderMachineClass;
struct _GVirSandboxBuilderMachine
{
GVirSandboxBuilder parent;
GVirSandboxBuilderMachinePrivate *priv;
/* Do not add fields to this struct */
};
struct _GVirSandboxBuilderMachineClass
{
GVirSandboxBuilderClass parent_class;
};
GType gvir_sandbox_builder_machine_get_type(void);
GVirSandboxBuilderMachine *gvir_sandbox_builder_machine_new(GVirConnection *connection,
GVirSandboxConfig *config);
G_END_DECLS
#endif /* __LIBVIRT_SANDBOX_BUILDER_MACHINE_H__ */
/*
* libvirt-sandbox-builder.c: libvirt sandbox builder
*
* Copyright (C) 2011 Red Hat
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#include <config.h>
#include <string.h>
#include "libvirt-sandbox/libvirt-sandbox.h"
#define GVIR_SANDBOX_BUILDER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_SANDBOX_TYPE_BUILDER, GVirSandboxBuilderPrivate))
struct _GVirSandboxBuilderPrivate
{
GVirConnection *connection;
GVirSandboxConfig *config;
};
G_DEFINE_ABSTRACT_TYPE(GVirSandboxBuilder, gvir_sandbox_builder, G_TYPE_OBJECT);
enum {
PROP_0,
PROP_CONFIG,
PROP_CONNECTION,
};
enum {
LAST_SIGNAL
};
//static gint signals[LAST_SIGNAL];
#define GVIR_SANDBOX_BUILDER_ERROR gvir_sandbox_builder_error_quark()
static GQuark
gvir_sandbox_builder_error_quark(void)
{
return g_quark_from_static_string("gvir-sandbox-builder");
}
static void gvir_sandbox_builder_get_property(GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GVirSandboxBuilder *ctxt = GVIR_SANDBOX_BUILDER(object);
GVirSandboxBuilderPrivate *priv = ctxt->priv;
switch (prop_id) {
case PROP_CONFIG:
g_value_set_object(value, priv->config);
break;
case PROP_CONNECTION:
g_value_set_object(value, priv->connection);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
}