[libvirt] [sandbox][PATCH] Add module directory prefix selection feature

Add module directory prefix selection feature This is useful when running as a non-privileged user if we want to boot a custom compiled kernel: we might not have rights to install in /lib/modules/<kernel release> so when compiling the kernel we can use "make modules_install INSTALL_MOD_PATH=/path" which installs in /path/lib/modules/<kernel release>. By setting with gvir_sandbox_config_set_moddirprefix(cfg, "/path") we can now achieve just that.

On Tue, Jun 19, 2012 at 01:33:40PM +0300, Radu Caragea wrote:
Add module directory prefix selection feature
This is useful when running as a non-privileged user if we want to boot a custom compiled kernel: we might not have rights to install in /lib/modules/<kernel release> so when compiling the kernel we can use "make modules_install INSTALL_MOD_PATH=/path" which installs in /path/lib/modules/<kernel release>. By setting with gvir_sandbox_config_set_moddirprefix(cfg, "/path") we can now achieve just that.
libvirt-sandbox/libvirt-sandbox-builder-initrd.c | 3 +- libvirt-sandbox/libvirt-sandbox-builder-machine.c | 1 + libvirt-sandbox/libvirt-sandbox-config-initrd.c | 50 ++++++++++++++++ libvirt-sandbox/libvirt-sandbox-config-initrd.h | 3 + libvirt-sandbox/libvirt-sandbox-config.c | 63 +++++++++++++++++++++ libvirt-sandbox/libvirt-sandbox-config.h | 3 + libvirt-sandbox/libvirt-sandbox.sym | 3 + 7 files changed, 125 insertions(+), 1 deletions(-)
diff --git a/libvirt-sandbox/libvirt-sandbox-builder-initrd.c b/libvirt-sandbox/libvirt-sandbox-builder-initrd.c index dd01c7a..0b13589 100644 --- a/libvirt-sandbox/libvirt-sandbox-builder-initrd.c +++ b/libvirt-sandbox/libvirt-sandbox-builder-initrd.c @@ -331,7 +331,8 @@ static GList *gvir_sandbox_builder_initrd_find_modules(GList *modnames, GVirSandboxConfigInitrd *config, GError **error) { - gchar *moddirpath = g_strdup_printf("/lib/modules/%s/kernel", + gchar *moddirpath = g_strdup_printf("%s/lib/modules/%s/kernel", + gvir_sandbox_config_initrd_get_moddirprefix(config),
I tend to think it would be more flexible, if instead of just the prefix, we used the API to set the base module dir, eg gvir_sandbox_config_initrd_set_moduledir("/lib/modules"); gvir_sandbox_config_initrd_set_moduledir("/some/other/prefix/lib/modules"); gvir_sandbox_config_initrd_set_moduledir("/some/other/dir") and then just append the version string to that. 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 :|

On Tue, Jun 19, 2012 at 6:31 PM, Daniel P. Berrange <berrange@redhat.com> wrote:
I tend to think it would be more flexible, if instead of just the prefix, we used the API to set the base module dir, eg
gvir_sandbox_config_initrd_set_moduledir("/lib/modules"); gvir_sandbox_config_initrd_set_moduledir("/some/other/prefix/lib/modules"); gvir_sandbox_config_initrd_set_moduledir("/some/other/dir")
and then just append the version string to that.
Daniel
Yes, I take your point. So basically the default moduledir should be "/lib/modules", the moddirpath corrected and the functions renamed a bit. But otherwise does it seem ok? I wasn't really sure about having a setter function both for the config and the initrd.

On Tue, Jun 19, 2012 at 06:48:51PM +0300, Radu Caragea wrote:
On Tue, Jun 19, 2012 at 6:31 PM, Daniel P. Berrange <berrange@redhat.com> wrote:
I tend to think it would be more flexible, if instead of just the prefix, we used the API to set the base module dir, eg
gvir_sandbox_config_initrd_set_moduledir("/lib/modules"); gvir_sandbox_config_initrd_set_moduledir("/some/other/prefix/lib/modules"); gvir_sandbox_config_initrd_set_moduledir("/some/other/dir")
and then just append the version string to that.
Daniel
Yes, I take your point. So basically the default moduledir should be "/lib/modules", the moddirpath corrected and the functions renamed a bit. But otherwise does it seem ok? I wasn't really sure about having a setter function both for the config and the initrd.
I think on GVirSandboxConfig we should have a 'kmodpath' property and gvir_sandbox_confijg_{get,set}_kmodpath() APIs. These would accept something like '/lib/modules'. On GVirSandboxConfigInitrd, we should hve a 'kmoddir' property and corresponding APIs. These would be given the full path eg '/lib/modules/x.y.z/kernel' THus the gvir_sandbox_builder_initrd_find_modules method would no longer need to figure out this path itself. 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 :|

Add module directory selection feature This is useful when running as a non-privileged user if we want to boot a custom compiled kernel: we might not have rights to install in /lib/modules/<kernel release> so when compiling the kernel we can use "make modules_install INSTALL_MOD_PATH=/path" which installs in /path/lib/modules/<kernel release>. By setting with gvir_sandbox_config_set_kmodpath(cfg, "/path/lib/modules") we can now achieve just that.

On Wed, Jun 20, 2012 at 10:17:42AM +0300, Radu Caragea wrote:
Add module directory selection feature
This is useful when running as a non-privileged user if we want to boot a custom compiled kernel: we might not have rights to install in /lib/modules/<kernel release> so when compiling the kernel we can use "make modules_install INSTALL_MOD_PATH=/path" which installs in /path/lib/modules/<kernel release>. By setting with gvir_sandbox_config_set_kmodpath(cfg, "/path/lib/modules") we can now achieve just that.
Thanks, I have applied this patch to GIT master. 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 :|
participants (2)
-
Daniel P. Berrange
-
Radu Caragea