Commit b1acf293 authored by Daniel P. Berrange's avatar Daniel P. Berrange

Add API for attaching a context to an existing sandbox

parent dbdab279
......@@ -413,6 +413,32 @@ error:
}
gboolean gvir_sandbox_context_attach(GVirSandboxContext *ctxt, GError **error)
{
GVirSandboxContextPrivate *priv = ctxt->priv;
if (priv->domain) {
*error = g_error_new(GVIR_SANDBOX_CONTEXT_ERROR, 0,
"%s", "A previously built sandbox still exists");
return FALSE;
}
if (!gvir_connection_fetch_domains(priv->connection, NULL, error))
return FALSE;
if (!(priv->domain = gvir_connection_find_domain_by_name(
priv->connection,
gvir_sandbox_config_get_name(priv->config)))) {
*error = g_error_new(GVIR_SANDBOX_CONTEXT_ERROR, 0,
"Sandbox %s does not exist",
gvir_sandbox_config_get_name(priv->config));
return FALSE;
}
return TRUE;
}
gboolean gvir_sandbox_context_stop(GVirSandboxContext *ctxt, GError **error)
{
GVirSandboxContextPrivate *priv = ctxt->priv;
......
......@@ -67,6 +67,7 @@ GVirSandboxCleaner *gvir_sandbox_context_get_cleaner(GVirSandboxContext *ctxt);
gboolean gvir_sandbox_context_start(GVirSandboxContext *ctxt, GError **error);
gboolean gvir_sandbox_context_stop(GVirSandboxContext *ctxt, GError **error);
gboolean gvir_sandbox_context_attach(GVirSandboxContext *ctxt, GError **error);
GVirDomain *gvir_sandbox_context_get_domain(GVirSandboxContext *ctxt);
GVirConnection *gvir_sandbox_context_get_connection(GVirSandboxContext *ctxt);
......
......@@ -101,6 +101,7 @@ LIBVIRT_SANDBOX_0.0.1 {
gvir_sandbox_console_attach_stdio;
gvir_sandbox_console_detach;
gvir_sandbox_context_attach;
gvir_sandbox_context_get_type;
gvir_sandbox_context_get_config;
gvir_sandbox_context_get_domain;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment