From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6704144668026732544 Date: Wed, 19 Jun 2019 00:45:18 -0700 (PDT) From: chombourger@gmail.com To: isar-users Message-Id: Subject: [QUERY] wic running in buildchroot-target MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_2529_718258907.1560930318729" X-Google-Token: EI7Qp-gFjcpyGzgeTPY0 X-Google-IP: 95.176.90.117 X-TUID: ik5cjmIOTevj ------=_Part_2529_718258907.1560930318729 Content-Type: multipart/alternative; boundary="----=_Part_2530_1004751492.1560930318729" ------=_Part_2530_1004751492.1560930318729 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hello all, I am continuing my journey on the MIPS architecture. I wanted to add wks files for my MIPS target (Creator Ci40) and do_wic_image failed: INFO: Creating image(s)... -rw-r--r-- 1 root root 697932185 Jun 18 13:34 /tmp/development-image-mel-omni-img-creator-ci40.wic/tmp.wic.n3m8x3xo/rootfs_platforma.1.ext4 Unsupported ioctl: cmd=0x0002 Traceback (most recent call last): File "/home/chombourger/Projects/isar/scripts/lib/wic/filemap.py", line 40, in get_block_size binary_data = fcntl.ioctl(file_obj, 2, struct.pack('I', 0)) OSError: [Errno 89] Function not implemented During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/chombourger/Projects/isar/scripts/lib/wic/filemap.py", line 103, in __init__ self.block_size = get_block_size(self._f_image) File "/home/chombourger/Projects/isar/scripts/lib/wic/filemap.py", line 42, in get_block_size raise IOError("Unable to determine block size") OSError: Unable to determine block size wic appears to be running from buildchroot-target and therefore under qemu--static evidently mips does not implement the FIGETBSZ ioctl My options would be: (1) check if a more recent version of qemu does implement this ioctl (2) add support for this ioctl in qemu-user (3) work-around it in wic with something like: diff --git a/scripts/lib/wic/filemap.py b/scripts/lib/wic/filemap.py index 080668e..1ce3ace 100644 --- a/scripts/lib/wic/filemap.py +++ b/scripts/lib/wic/filemap.py @@ -40,8 +40,13 @@ def get_block_size(file_obj): # Get the block size of the host file-system for the image file by calling # the FIGETBSZ ioctl (number 2). - binary_data = ioctl(file_obj, 2, struct.pack('I', 0)) - return struct.unpack('I', binary_data)[0] + try: + binary_data = ioctl(file_obj, 2, struct.pack('I', 0)) + return struct.unpack('I', binary_data)[0] + except OSError as err: + if err.errno == os.errno.ENOSYS: + return 4096 + raise err class ErrorNotSupp(Exception): """ Ok. But why are we running wic in buildchroot-target. Comments I have seen in the code only say that it is a prerequisite but do not say why (I should probably check git logs as well) I wonder if it should run in buildchroot-host context instead (so we still use a host environment we control) but avoid the overhead of qemu emulation for DISTRO_ARCH != amd64 What are your thoughts? Cedric ------=_Part_2530_1004751492.1560930318729 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hello all,

I am continuing my journey o= n the MIPS architecture.
I wanted to add wks files for my MIPS ta= rget (Creator Ci40) and do_wic_image failed:

= INFO: Creating image(s)...

-rw-r--r-- 1 root root = 697932185 Jun 18 13:34 /tmp/development-image-mel-omni-img-creator-ci40.wic= /tmp.wic.n3m8x3xo/rootfs_platforma.1.ext4
Unsupported ioctl: cmd= =3D0x0002
Traceback (most recent call last):
=C2=A0= File "/home/chombourger/Projects/isar/scripts/lib/wic/filemap.py"= ;, line 40, in get_block_size
=C2=A0 =C2=A0 binary_data =3D fcntl= .ioctl(file_obj, 2, struct.pack('I', 0))
OSError: [Errno = 89] Function not implemented

During handling of th= e above exception, another exception occurred:

Tra= ceback (most recent call last):
=C2=A0 File "/home/chombourg= er/Projects/isar/scripts/lib/wic/filemap.py", line 103, in __init__
=C2=A0 =C2=A0 self.block_size =3D get_block_size(self._f_image)
=C2=A0 File "/home/chombourger/Projects/isar/scripts/lib/wic/fi= lemap.py", line 42, in get_block_size
=C2=A0 =C2=A0 raise IO= Error("Unable to determine block size")
OSError: Unable= to determine block size

wic appears to be r= unning from buildchroot-target and therefore under qemu-<arch>-static=
evidently mips does not implement the=C2=A0FIGETBSZ ioctl
<= div>
My options would be:

(1) check = if a more recent version of qemu does implement this ioctl
(2) ad= d support for this ioctl in qemu-user
(3) work-around it in wic w= ith something like:

diff --git a/scripts/lib/= wic/filemap.py b/scripts/lib/wic/filemap.py
index 080668e..1ce3ac= e 100644
--- a/scripts/lib/wic/filemap.py
+++ b/scripts= /lib/wic/filemap.py
@@ -40,8 +40,13 @@ def get_block_size(file_ob= j):
=C2=A0
=C2=A0 =C2=A0 =C2=A0# Get the block size of = the host file-system for the image file by calling
=C2=A0 =C2=A0 = =C2=A0# the FIGETBSZ ioctl (number 2).
-=C2=A0 =C2=A0 binary_data= =3D ioctl(file_obj, 2, struct.pack('I', 0))
-=C2=A0 =C2= =A0 return struct.unpack('I', binary_data)[0]
+=C2=A0 =C2= =A0 try:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 binary_data =3D ioctl(file_= obj, 2, struct.pack('I', 0))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0= return struct.unpack('I', binary_data)[0]
+=C2=A0 =C2=A0= except OSError as err:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if err.errno= =3D=3D os.errno.ENOSYS:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 return 4096
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 raise err
= =C2=A0
=C2=A0class ErrorNotSupp(Exception):
=C2=A0 =C2= =A0 =C2=A0"""

Ok.
<= br>
But why are we running wic in buildchroot-target. Comments I = have seen in the code only say that it is a prerequisite but do not say why= (I should probably check git logs as well)
I wonder if it should= run in buildchroot-host context instead (so we still use a host environmen= t we control) but avoid the overhead of qemu emulation for DISTRO_ARCH !=3D= amd64

What are your thoughts?

Cedric

------=_Part_2530_1004751492.1560930318729-- ------=_Part_2529_718258907.1560930318729--