[libvirt] [sandbox PATCH 2/2] Use "/boot/vmlinuz-linux" as default kernel path

Radostin Stoyanov posted 2 patches 7 years, 2 months ago
[libvirt] [sandbox PATCH 2/2] Use "/boot/vmlinuz-linux" as default kernel path
Posted by Radostin Stoyanov 7 years, 2 months ago
On some linux distributions "/boot/vmlinuz-linux" is set as default
kernel path. If this file does not exist we fallback to the value
"/boot/vmlinuz-$KERNEL-VERSION"

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
---
 bin/virt-sandbox.c                                | 5 +++--
 libvirt-sandbox/libvirt-sandbox-builder-machine.c | 4 ++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/bin/virt-sandbox.c b/bin/virt-sandbox.c
index 6032562..930b85e 100644
--- a/bin/virt-sandbox.c
+++ b/bin/virt-sandbox.c
@@ -553,8 +553,9 @@ omitted, defaults to match the current running host version.
 
 =item B<--kernpath=FILE-PATH>
 
-Specify the path to the kernel binary. If omitted, defaults
-to C</boot/vmlinuz-$KERNEL-VERSION>.
+Specify the path to the kernel binary. If omitted, defaults to
+C</boot/vmlinuz-linux> if exists, otherwise
+C</boot/vmlinuz-$KERNEL-VERSION> will be used.
 
 =item B<--kmodpath=DIR-PATH>
 
diff --git a/libvirt-sandbox/libvirt-sandbox-builder-machine.c b/libvirt-sandbox/libvirt-sandbox-builder-machine.c
index a4a5dcd..2c305a7 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder-machine.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder-machine.c
@@ -133,11 +133,15 @@ static gchar *gvir_sandbox_builder_machine_get_kernrelease(GVirSandboxConfig *co
 static gchar *gvir_sandbox_builder_machine_get_kernpath(GVirSandboxConfig *config)
 {
     const gchar *kernpath = gvir_sandbox_config_get_kernpath(config);
+    const gchar *default_kernpath = "/boot/vmlinuz-linux";
     gchar *kver;
     gchar *ret;
     if (kernpath)
         return g_strdup(kernpath);
 
+    if (access(default_kernpath, F_OK ) != -1)
+        return g_strdup(default_kernpath);
+
     kver = gvir_sandbox_builder_machine_get_kernrelease(config);
     ret = g_strdup_printf("/boot/vmlinuz-%s", kver);
     g_free(kver);
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [sandbox PATCH 2/2] Use "/boot/vmlinuz-linux" as default kernel path
Posted by Daniel P. Berrangé 7 years, 2 months ago
On Tue, Nov 20, 2018 at 07:10:20PM +0000, Radostin Stoyanov wrote:
> On some linux distributions "/boot/vmlinuz-linux" is set as default
> kernel path. If this file does not exist we fallback to the value
> "/boot/vmlinuz-$KERNEL-VERSION"
> 
> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
> ---
>  bin/virt-sandbox.c                                | 5 +++--
>  libvirt-sandbox/libvirt-sandbox-builder-machine.c | 4 ++++
>  2 files changed, 7 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list