From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ThNvK-0005WW-Cg for qemu-devel@nongnu.org; Sat, 08 Dec 2012 12:10:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ThNvI-0007XL-Ut for qemu-devel@nongnu.org; Sat, 08 Dec 2012 12:10:46 -0500 Received: from moutng.kundenserver.de ([212.227.17.9]:58574) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ThNvI-0007XH-JU for qemu-devel@nongnu.org; Sat, 08 Dec 2012 12:10:44 -0500 Message-ID: <1354986641.12642.19.camel@Quad> From: Laurent Vivier Date: Sat, 08 Dec 2012 18:10:41 +0100 In-Reply-To: References: <1354979928-19000-1-git-send-email-laurent@vivier.eu> Content-Type: multipart/mixed; boundary="=-jlMkrUb2kIgj2NGgE+rR" Mime-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] linux-user: correctly align types in thunking code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Riku Voipio , qemu-devel@nongnu.org --=-jlMkrUb2kIgj2NGgE+rR Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le samedi 08 d=C3=A9cembre 2012 =C3=A0 16:40 +0000, Peter Maydell a =C3=A9c= rit : > On 8 December 2012 15:18, Laurent Vivier wrote: > > Signed-off-by: Laurent Vivier >=20 > This kind of patch really needs an explanation (and ideally > test case) of what the bug is that it is attempting to fix... Yes... of course, but sometime no one reads my patches, so I was lazy ;-) The 3 first patches I sent today allow to run netstat and route in a linux container with qemu linux-user (qemu-m68k in my case). The first one, obviously, allows to have IP addresses in correct order in the case of "netstat -nr". The second one, allows to use the command "route". This is a follow up of patch: commit c2e3dee6e03527baf8698698cce76b1a3174969a Author: Laurent Vivier Date: Sun Feb 13 23:37:34 2011 +0100 =20 linux-user: Define target alignment size In my case m68k aligns "int" on 2 not 4. You can check this with the following program: #include #include #include int main(void) { struct rtentry rt; printf("rt_pad1 %ld %zd\n", offsetof(struct rtentry, rt_pad1), sizeof(rt.rt_pad1)); printf("rt_dst %ld %zd\n", offsetof(struct rtentry, rt_dst), sizeof(rt.rt_dst)); printf("rt_gateway %ld %zd\n", offsetof(struct rtentry, rt_gateway)= , sizeof(rt.rt_gateway)); printf("rt_genmask %ld %zd\n", offsetof(struct rtentry, rt_genmask)= , sizeof(rt.rt_genmask)); printf("rt_flags %ld %zd\n", offsetof(struct rtentry, rt_flags), sizeof(rt.rt_flags)); printf("rt_pad2 %ld %zd\n", offsetof(struct rtentry, rt_pad2), sizeof(rt.rt_pad2)); printf("rt_pad3 %ld %zd\n", offsetof(struct rtentry, rt_pad3), sizeof(rt.rt_pad3)); printf("rt_pad4 %ld %zd\n", offsetof(struct rtentry, rt_pad4), sizeof(rt.rt_pad4)); printf("rt_metric %ld %zd\n", offsetof(struct rtentry, rt_metric), sizeof(rt.rt_metric)); printf("rt_dev %ld %zd\n", offsetof(struct rtentry, rt_dev), sizeof(rt.rt_dev)); } On x86_64: rt_pad1 0 8 rt_dst 8 16 rt_gateway 24 16 rt_genmask 40 16 rt_flags 56 2 rt_pad2 58 2 rt_pad3 64 8 rt_pad4 74 6 rt_metric 80 2 rt_dev 88 8 on m68k: rt_pad1 0 4 rt_dst 4 16 rt_gateway 20 16 rt_genmask 36 16 rt_flags 52 2 rt_pad2 54 2 rt_pad3 56 4 rt_pad4 62 2 rt_metric 64 2 rt_dev 66 4 The third one, allows to set the interface for the command "route", for instance : route add -net default gw 10.0.3.1 eth0 Obviously, If patches seem correct for everyone, I can resend them with comments and in a serie. Bonus: To test this, find attached a little script that will compile qemu-m68k, install debian etch-m68k in a linux container. Then you will be able to run debian m68k system with "sudo lxc-start -n virtm68k". (tested on an ubuntu 12.10, you should check that lxc creates a lxcbr0 bridge with IP address 10.0.3.1). Check variable at the beginning for the paths used. Regards, Laurent -- "Just play. Have fun. Enjoy the game." --=-jlMkrUb2kIgj2NGgE+rR Content-Type: application/x-shellscript; name="create-m68k-lxc.sh" Content-Disposition: attachment; filename="create-m68k-lxc.sh" Content-Transfer-Encoding: 7bit CONTAINER_NAME=virtm68k CONTAINER_PATH=/containers/m68k QEMU_PATH=$HOME/qemu-m68k LXC_CONF=$HOME/lxc-m68k.conf installed_dpkg() { dpkg --status "$1" > /dev/null 2>&1 } check_env() { for pkg in git zlib1g gcc make debootstrap lxc do if ! installed_dpkg $pkg then echo "$pkg is needed" 1>&2 exit 1 fi done } create_qemu() { if [ -e "${QEMU_PATH}/build-m68k/m68k-linux-user/qemu-m68k" ] then if ${QEMU_PATH}/build-m68k/m68k-linux-user/qemu-m68k -cpu ? | grep -q ">m68040" then echo "Found an existing qemu-m68k, use it !" 1>&2 return 0 fi echo "Found an existing qemu-m68k, but with no m68040 emulation" 1>&2 echo "Please, remove it" 1>&2 exit 1 fi if [ -e "${QEMU_PATH}" ] then echo "Found an existing qemu-m68k directory, with no qemu-m68k binary" 1>&2 echo "Please, remove it" 1>&2 exit 1 fi echo " git clone git://gitorious.org/qemu-m68k/qemu-m68k.git ${QEMU_PATH} && \ cd ${QEMU_PATH} && \ mkdir build-m68k && \ cd build-m68k && \ ../configure --static \ --target-list=m68k-linux-user \ --m68k-default-cpu=m68040 && \ make" | sudo -i -u ${SUDO_USER} } create_m68k_root() { if [ -e "${CONTAINER_PATH}" ] then echo "${CONTAINER_PATH} already exists" 1>&2 echo "Please, remove it" 1>&2 exit 1 fi mkdir -p "${CONTAINER_PATH}" debootstrap --foreign \ --arch=m68k \ etch-m68k ${CONTAINER_PATH} \ http://archive.debian.org/debian && \ rm -fr ${CONTAINER_PATH}/usr/bin/qemu-m68k && \ cp ${QEMU_PATH}/build-m68k/m68k-linux-user/qemu-m68k \ ${CONTAINER_PATH}/usr/bin && \ chown root:root ${CONTAINER_PATH}/usr/bin/qemu-m68k && \ chmod +s ${CONTAINER_PATH}/usr/bin/qemu-m68k && \ ${QEMU_PATH}/scripts/set_binfmt_m68k && \ chroot ${CONTAINER_PATH} debootstrap/debootstrap --second-stage cat >> ${CONTAINER_PATH}/etc/fstab < proc /proc proc nodev,noexec,nosuid 0 1 sys /sys sysfs nodev,noexec,nosuid 0 1 devpts /dev/pts devpts nodev,noexec,nosuid 0 1 !EOF echo "c:2345:respawn:/sbin/getty 38400 console" >> ${CONTAINER_PATH}/etc/inittab cat >> ${CONTAINER_PATH}/etc/network/interfaces < ${CONTAINER_PATH}/etc/resolv.conf cat >> ${CONTAINER_PATH}/etc/apt/sources.list < ${LXC_CONF} <&2 echo "you can remove it with :" 1>&2 echo " sudo lxc-destroy -n ${CONTAINER_NAME}" 1>&2 echo "[WARNING: this will remove the directory too]" 1>&2 exit 2 fi if [ "$USER" != "root" ] then echo "You need to be root to run this command" 2>&1 exit 3 fi create_qemu && create_m68k_root && create_m68k_lxc chroot ${CONTAINER_PATH} uname -a echo "you can now start your container using:" echo " sudo lxc-start -n ${CONTAINER_NAME}" --=-jlMkrUb2kIgj2NGgE+rR--