[Kimchi-devel] [PATCH] imageinfo.py: Don't fail template creation if unable to detect OS

bbaude at redhat.com bbaude at redhat.com
Tue Oct 13 15:00:28 UTC 2015


From: Brent Baude <bbaude at redhat.com>

This patch slightly alters the behaviour when creating a template
from an exisiting disk image (i.e. qcow2).  If guestfs is unable
to detect what distro, version, etc is within the image, it should
not be a catastrophic error.  In fact, the vmtemplate.py handles
the return of distro == 'unknown' already by creating a
uuid for it.

This is important for operating systems like Atomic (RHEL, CentOS,
and Fedora) because they have a non-standard partition and disk
layout that guestfs cannot readily figure out.
---
 src/wok/plugins/kimchi/imageinfo.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/wok/plugins/kimchi/imageinfo.py b/src/wok/plugins/kimchi/imageinfo.py
index 8a22495..75cda76 100644
--- a/src/wok/plugins/kimchi/imageinfo.py
+++ b/src/wok/plugins/kimchi/imageinfo.py
@@ -51,14 +51,15 @@ def probe_image(image_path):
     g = guestfs.GuestFS(python_return_dict=True)
     g.add_drive_opts(image_path, readonly=1)
     g.launch()
-
     try:
         roots = g.inspect_os()
     except:
         raise ImageFormatError("KCHIMG0001E")
 
     if len(roots) == 0:
-        raise ImageFormatError("KCHIMG0002E")
+        # If we are unable to detect the OS, still add the image
+        # but make distro and vendor 'unknown'
+        return ("unknown", "unknown")
 
     for root in roots:
         version = "%d.%d" % (g.inspect_get_major_version(root),
-- 
2.4.3




More information about the Kimchi-devel mailing list