[Kimchi-devel] [kimchi-devel][PATCHv3 5/6] Fix incomplete record when uploading

lvroyce at linux.vnet.ibm.com lvroyce at linux.vnet.ibm.com
Wed Jan 28 13:20:30 UTC 2015


From: Royce Lv <lvroyce at linux.vnet.ibm.com>

When uploading an ISO file, the ISO distro record may be incomplete because
uploading in progress.
"call_stack":"Traceback (most recent call last):
    File \"./src/kimchi/model/storagevolumes.py\", line 304, in lookup
        iso_img = IsoImage(path)
    File \"./src/kimchi/isoinfo.py\", line 149, in __init__
        self._scan()
    File \"./src/kimchi/isoinfo.py\", line 437, in _scan
        self._scan_el_torito(data)
    File \"./src/kimchi/isoinfo.py\", line 218, in _scan_el_torito
        ident, csum, key55, keyAA) = self._unpack(fmt, tmp_data)
    File \"./src/kimchi/isoinfo.py\", line 181, in _unpack
        return s.unpack(data[:s.size])
    error: unpack requires a string argument of length 32\n"
So wrap reading record with error handling so that error will not occur
in uploading.

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
 src/kimchi/i18n.py    | 1 +
 src/kimchi/isoinfo.py | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index af0dc4f..00e4a7d 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -67,6 +67,7 @@ messages = {
                      "to file access control lists for '%(user)s' user if possible, or add the "
                      "'%(user)s' to the ISO path group, or (not recommended) 'chmod -R o+x 'path_to_iso'."
                      "Details: %(err)s" ),
+    "KCHISO0009E": _("Incomplete record while reading ISO %(filename)s."),
 
     "KCHIMG0001E": _("An error occurred when probing image OS information."),
     "KCHIMG0002E": _("No OS information found in given image."),
diff --git a/src/kimchi/isoinfo.py b/src/kimchi/isoinfo.py
index 1e36a6d..18aa38e 100644
--- a/src/kimchi/isoinfo.py
+++ b/src/kimchi/isoinfo.py
@@ -147,7 +147,10 @@ class IsoImage(object):
         self.remote = self._is_iso_remote()
         self.volume_id = None
         self.bootable = False
-        self._scan()
+        try:
+            self._scan()
+        except:
+            raise IsoFormatError('KCHISO0009E', {'filename': self.path})
 
     def _is_iso_remote(self):
         if os.path.isfile(self.path):
-- 
2.1.0




More information about the Kimchi-devel mailing list