[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 02/16] Current virt-sandbox-service-util only supports service sandbox/containers



On Tue, Apr 02, 2013 at 06:11:18PM -0400, Dan Walsh wrote:
> We need to add support for interactive sandbox/containers for OpenShift.
> 
> This patch will create the correct container type based off the /etc/libvirt-sandbox/service/*
> 
> Signed-off-by: Dan Walsh <dwalsh redhat com>
> ---
>  bin/virt-sandbox-service-util.c | 31 +++++++++++++++++++++++--------
>  1 file changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/bin/virt-sandbox-service-util.c b/bin/virt-sandbox-service-util.c
> index 430518f..2630109 100644
> --- a/bin/virt-sandbox-service-util.c
> +++ b/bin/virt-sandbox-service-util.c
> @@ -352,6 +352,7 @@ static gboolean libvirt_lxc_attach(const gchar *option_name,
>  
>  int main(int argc, char **argv) {
>      GMainLoop *loop = NULL;
> +    GVirSandboxConfigInteractive *interactive_cfg = NULL;
>      GVirSandboxConfigService *cfg = NULL;
>      GVirSandboxConfig *config = NULL;

This is rather overkill - just have the single 'GVirSandboxConfig *config'
variable and cast it where needed, removing the intermediate variables.

>      GVirSandboxContext *ctx = NULL;
> @@ -360,7 +361,6 @@ int main(int argc, char **argv) {
>      int ret = EXIT_FAILURE;
>      pid_t pid = 0;
>      gchar *buf=NULL;
> -    GVirSandboxContextService *service;
>      gchar *uri = NULL;
>      gchar *command = NULL;
>  
> @@ -451,16 +451,28 @@ int main(int argc, char **argv) {
>          goto cleanup;
>      }
>  
> -    cfg = GVIR_SANDBOX_CONFIG_SERVICE(config);
> +    if (GVIR_SANDBOX_IS_CONFIG_INTERACTIVE(config)) {
> +        GVirSandboxContextInteractive *service;
> +        interactive_cfg = GVIR_SANDBOX_CONFIG_INTERACTIVE(config);
>  
> -    if (!(service = gvir_sandbox_context_service_new(hv, cfg))) {
> -        g_printerr(_("Unable to create new context service: %s\n"),
> -                   err && err->message ? err->message : _("unknown"));
> -        goto cleanup;
> +        if (!(service = gvir_sandbox_context_interactive_new(hv, interactive_cfg))) {

Replace 'interactive_cfg' with a direct call to
 GVIR_SANDBOX_CONFIG_INTERACTIVE(config)


> +                g_printerr(_("Unable to create new context service: %s\n"),
> +                           err && err->message ? err->message : _("unknown"));
> +                goto cleanup;
> +        }
> +        ctx = GVIR_SANDBOX_CONTEXT(service);
> +    } else {
> +        GVirSandboxContextService *service;
> +        cfg = GVIR_SANDBOX_CONFIG_SERVICE(config);
> +
> +        if (!(service = gvir_sandbox_context_service_new(hv, cfg))) {
> +                g_printerr(_("Unable to create new context service: %s\n"),
> +                           err && err->message ? err->message : _("unknown"));
> +                goto cleanup;
> +        }
> +        ctx = GVIR_SANDBOX_CONTEXT(service);
>      }
>  
> -    ctx = GVIR_SANDBOX_CONTEXT(service);
> -
>      if (command) {
>          container_execute(ctx, command, pid);
>      }
> @@ -475,6 +487,9 @@ cleanup:
>  
>      free(buf);
>  
> +    if (interactive_cfg)
> +        g_object_unref(interactive_cfg);
> +
>      if (cfg)
>          g_object_unref(cfg);

And thus instead of needing these 2 blocks you can now just do

  if (config)
     g_object_unref(config)

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]