On Tue, 2015-09-08 at 17:29 +0100, Daniel P. Berrange wrote: > From: Eren Yagdiran <erenyagdiran@xxxxxxxxx> > > Allow users to add custom environment variables to their sandbox. > > Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx> > --- > bin/virt-sandbox.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/bin/virt-sandbox.c b/bin/virt-sandbox.c > index 332e53e..4c400d5 100644 > --- a/bin/virt-sandbox.c > +++ b/bin/virt-sandbox.c > @@ -80,6 +80,7 @@ int main(int argc, char **argv) { > GError *error = NULL; > gchar *name = NULL; > gchar **disks = NULL; > + gchar **envs = NULL; > gchar **mounts = NULL; > gchar **includes = NULL; > gchar *includefile = NULL; > @@ -111,6 +112,8 @@ int main(int argc, char **argv) { > N_("root directory of the sandbox"), "DIR" }, > { "disk", ' ', 0, G_OPTION_ARG_STRING_ARRAY, &disks, > N_("add a disk in the guest"), "TYPE:TAGNAME=SOURCE,format=FORMAT" }, > + { "env", 'e', 0, G_OPTION_ARG_STRING_ARRAY, &envs, > + N_("add a environment variable for the sandbox"), "KEY=VALUE" }, > { "mount", 'm', 0, G_OPTION_ARG_STRING_ARRAY, &mounts, > N_("mount a filesystem in the guest"), "TYPE:TARGET=SOURCE" }, > { "include", 'i', 0, G_OPTION_ARG_STRING_ARRAY, &includes, > @@ -201,6 +204,13 @@ int main(int argc, char **argv) { > gvir_sandbox_config_set_username(cfg, "root"); > } > > + if (envs && > + !gvir_sandbox_config_add_env_strv(cfg, envs, &error)) { > + g_printerr(_("Unable to parse custom environment variables: %s\n"), > + error && error->message ? error->message : _("Unknown failure")); > + goto cleanup; > + } > + > if (disks && > !gvir_sandbox_config_add_disk_strv(cfg, disks, &error)) { > g_printerr(_("Unable to parse disks: %s\n"), > @@ -350,6 +360,10 @@ inheriting the host's root filesystem. > NB. C<DIR> must contain a matching install of the libvirt-sandbox > package. This restriction may be lifted in a future version. > > +=item B<--env key=value> > + > +Sets up a custom environment variable on a running sandbox. > + > =item B<--disk TYPE:TAGNAME=SOURCE,format=FORMAT> > > Sets up a disk inside the sandbox by using B<SOURCE> with a symlink named as B<TAGNAME> ACK -- Cedric -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list