Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Conversation

@Crazykev
Copy link
Contributor

@Crazykev Crazykev commented Feb 8, 2017

Previous ipvsadm binary is fully static built, while static linking of glibc has some bad effect. And libraries also used by init and iptables binary like libm.so and libc.so should be shared.

To solve this, I try to link libraries like libnl and popt statically, glibc like libm/libc/libpthread dynamically. See Dockerfile and build script from https://github.com/Crazykev/dev-tools/tree/master/ipvsadm-static, and ipvsadm source code from https://github.com/Crazykev/ipvsadm.

To get this binary, you can use build a image with Dockerfile and build script from here, and run
hyperctl run --rm -v [ipvsadm-dir]:/data ipvsadm-static

This will reduce the size of hyperstart image from 5.4M to 5.1M in my environment.

cp busybox /tmp/hyperstart-rootfs/sbin/
cp iptables /tmp/hyperstart-rootfs/sbin/
cp ipvsadm /tmp/hyperstart-rootfs/sbin/
cp libm.so.6 /tmp/hyperstart-rootfs/lib64/
Copy link
Contributor

@laijs laijs Feb 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libm is still being used by iptables

ldd build/iptables
	linux-vdso.so.1 =>  (0x00007ffdfbbf8000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fe2be9a1000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fe2be5e0000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fe2becb0000)

for bin in ${LDD_BINARIES[@]}
do
ldd /tmp/hyperstart-rootfs/${bin} | while read line
do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix the indent


ldd /tmp/hyperstart-rootfs/init | while read line
LDD_BINARIES=(/init /sbin/ipvsadm /sbin/iptables)
for bin in ${LDD_BINARIES[@]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is recommended to use the libs provided by the src-tree or built from the src-tree.
currently /init use the host libs, it will be also fixed later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this because I meet some inconsistent issue when using libc(libc-2.23.so) on my host. Since All of them will be carried by hyperstart, it should be fine.
Just please include pthread.so, it's needed by ipvsadm.

Crazykev added 2 commits April 5, 2017 22:04
Signed-off-by: Crazykev <crazykev@zju.edu.cn>
Signed-off-by: Crazykev <crazykev@zju.edu.cn>
@Crazykev
Copy link
Contributor Author

Crazykev commented Apr 5, 2017

@laijs updated.

@laijs
Copy link
Contributor

laijs commented Apr 5, 2017

retest this please, hykins

@laijs laijs merged commit f2d1b34 into hyperhq:master Apr 5, 2017
@Crazykev Crazykev deleted the library branch April 5, 2017 16:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants