[Kimchi-devel] [kimchi-devel][PATCHv4 5/7] Fix incomplete record when uploading

Aline Manera alinefm at linux.vnet.ibm.com
Mon May 4 20:16:59 UTC 2015



On 22/04/2015 05:02, lvroyce at linux.vnet.ibm.com wrote:
> 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 13ac55b..c2223f5 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 fd1f8f7..f20019d 100644
> --- a/src/kimchi/isoinfo.py
> +++ b/src/kimchi/isoinfo.py
> @@ -149,7 +149,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})

Will this error be displayed to user?

If so, I don't think it is needed. I mean, we know it is not completed 
due a upload process, so we should ignore it.

>       def _is_iso_remote(self):
>           if os.path.exists(self.path):




More information about the Kimchi-devel mailing list