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

Conversation

@jjlakis
Copy link

@jjlakis jjlakis commented Jul 20, 2016

Extending current makefile mechanism to build more than one image for single flavor (with differences in rootfs) and adding QEMU as a hypervisor.
PR contains:

  • Refactor of stage1/stage1.mk, more specific: STAGE1_ACI_RULE to accept two parameters (flavor and list of images), instead of just one (flavor). List of images are parsed directly in stage1.mk, common and hv-specific files are done still in usr_from_flavor makefiles. STAGE1_ACI_RULE is now responsible to copy files from common directory and build images (added new rule).
  • stage1/usr_from_kvm/qemu.mk - responsible for cloning sources, building qemu and including its binaries in stage1-kvm.aci.
  • stage1/init/kvm/hypervisor/qemu_driver.go - similar to lkvm_driver.go in the form created in KVM: Hypervisor support for KVM flavor #2684
  • Refactor of kvm init part. All functions for starting hypervisors are included, init is checking what binary is contained in aci image, and calls proper command line. Due to this, none_driver.go is removed.

lkvm is still default hypervisor

To build rkt with qemu support, type:
./configure --with-stage1-kvm-hypervisors=qemu

To built rkt with both qemu and lkvm support, type:
./configure --with-stage1-kvm-hypervisors=lkvm,qemu

And you will get two images:
stage1-kvm-lkvm.aci
stage1-kvm-qemu.aci

(if only one hypervisor is specified, its name will remain as stage1-kvm.aci)

To be clarified / To do

  • Documentation needs to be changed. If no new flavor is needed, I would extend existing paper
  • Should we check dependencies for qemu or just notice user to take care of them?

cc @coreos/rkt-kvm-maintainers

@iaguis
Copy link
Member

iaguis commented Jul 20, 2016

I can't compile it on my system.

First, my default python is 3.x so the build didn't work. I added a workaround:

diff --git a/stage1/usr_from_kvm/qemu.mk b/stage1/usr_from_kvm/qemu.mk
index 0b4a3cd..ac7160b 100644
--- a/stage1/usr_from_kvm/qemu.mk
+++ b/stage1/usr_from_kvm/qemu.mk
@@ -53,7 +53,7 @@ $(call generate-stamp-rule,$(QEMU_BUILD_STAMP),$(QEMU_CONF_STAMP),, \

 $(call generate-stamp-rule,$(QEMU_CONF_STAMP),$(QEMU_CLONE_STAMP),, \
        $(call vb,vt,CONFIG EXT,qemu) \
-       cd $(QEMU_SRCDIR); ./configure $(QEMU_CONFIGURATOR) $(QEMU_CONFIGURATION_OPTS) $(call vl2,>/dev/null))
+       cd $(QEMU_SRCDIR); ./configure --python=/usr/bin/python2 $(QEMU_CONFIGURATOR) $(QEMU_CONFIGURATION_OPTS) $(call vl2,>/dev/null))

 # Generate filelist of qemu directory (this is both srcdir and
 # builddir). Can happen after build finished.

And then the next failure is:

ERROR: sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T.
       You probably need to set PKG_CONFIG_LIBDIR
       to point to the right pkg-config files for your
       build target

I tried setting up PKG_CONFIG_LIBDIR, GLIB_SIZEOF_SIZE_T, the patch mentioned in https://bugs.launchpad.net/qemu/+bug/1579565, adding --extra-cflags="-m64" but I couldn't make it work.

@alban alban added this to the v1.12.0 milestone Jul 20, 2016
@jjlakis
Copy link
Author

jjlakis commented Jul 21, 2016

@iaguis What version of gcc you are using?

@iaguis
Copy link
Member

iaguis commented Jul 21, 2016

$ gcc --version
gcc (GCC) 6.1.1 20160707
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@jellonek
Copy link
Contributor

Could You give there produced error string? AFAIR gcc4.9 "does the job".

@iaguis
Copy link
Member

iaguis commented Jul 21, 2016

The error string is mentioned in #2952 (comment):

ERROR: sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T.
       You probably need to set PKG_CONFIG_LIBDIR
       to point to the right pkg-config files for your
       build target

@jellonek
Copy link
Contributor

ack.

@jjlakis jjlakis force-pushed the jlakis-hypervisor2 branch from 89f9c3f to bf2d258 Compare July 21, 2016 13:52
@jjlakis
Copy link
Author

jjlakis commented Jul 21, 2016

Can't reproduce it locally with different versions of gcc. In the link you attached, on the bottom, the solution was to reinstall glib, have you tried it?
I also changed qemu version to 2.6.0-rc5.

@alban
Copy link
Member

alban commented Jul 21, 2016

I get the following error when trying to compile it:

ERROR: zlib check failed
       Make sure to have the zlib libs and headers installed.

The error probably comes from ./build-rkt-1.11.0+git/tmp/usr_from_kvm/qemu/src/configure:

#########################################
# zlib check

if test "$zlib" != "no" ; then
    cat > $TMPC << EOF
#include <zlib.h>
int main(void) { zlibVersion(); return 0; }
EOF
    if compile_prog "" "-lz" ; then
        :
    else
        error_exit "zlib check failed" \
            "Make sure to have the zlib libs and headers installed."
    fi
fi
LIBS="$LIBS -lz"

But zlib-devel-1.2.8-10.fc24.x86_64 is installed and when I try manually, it works:

$ cat test-zlib.c 
#include <zlib.h>
int main(void) { zlibVersion(); return 0; }

$ gcc -o test-zlib -lz test-zlib.c 
$ ldd test-zlib
    linux-vdso.so.1 (0x00007ffe4edd2000)
    libz.so.1 => /lib64/libz.so.1 (0x00007fdd92665000)
    libc.so.6 => /lib64/libc.so.6 (0x00007fdd922a3000)
    /lib64/ld-linux-x86-64.so.2 (0x0000555e63a21000)
$ gcc --version
gcc (GCC) 6.1.1 20160621 (Red Hat 6.1.1-3)

Any ideas?

@jjlakis
Copy link
Author

jjlakis commented Jul 21, 2016

No idea about inconsistency in check of zlib inside and outside of configure. My zlib packages:

$ apt list --installed | grep zlib
zlib1g/xenial,now 1:1.2.8.dfsg-2ubuntu4 amd64 [installed]
zlib1g-dev/xenial,now 1:1.2.8.dfsg-2ubuntu4 amd64 [installed,automatic]

@alban
Copy link
Member

alban commented Jul 21, 2016

@krnowak solved my issue by installing the package "zlib-static" (zlib and zlib-devel are not enough).

@alban
Copy link
Member

alban commented Jul 21, 2016

dependencies.md needs to be updated with the zlib-static.

Then I have the same issue as #2952 (comment) with "sizeof(size_t)".

@jjlakis
Copy link
Author

jjlakis commented Jul 21, 2016

@alban Should I add checking zlib-static in rkt ./configure?

@krnowak
Copy link
Collaborator

krnowak commented Jul 21, 2016

I remember removing all the checks for 3rd party projects like kvm, kernel, etc from configure and writing a note to make sure that all the dependencies are met. Not dure anout mentioning such deps in documentation either.

@iaguis
Copy link
Member

iaguis commented Jul 22, 2016

I could compile it by removing the --static option in QEMU_CONFIGURATION_OPTS.

@iaguis
Copy link
Member

iaguis commented Jul 25, 2016

If I start an interactive container, pressing Ctrl+C will terminate qemu:

/ # #gonna press Ctrl+C
/ # qemu: terminating on signal 2
$

@iaguis
Copy link
Member

iaguis commented Jul 25, 2016

Also, systemd output is printed even though we didn't specify --debug:

$ sudo rkt run kinvolk.io/aci/busybox --interactive
image: using image from file /home/iaguis/work/coreos/go/src/github.com/coreos/rkt/build-rkt/target/bin/stage1-kvm.aci
image: using image from local store for image name kinvolk.io/aci/busybox
networking: loading networks from /etc/rkt/net.d

Welcome to Linux!

[  OK  ] Created slice system.slice.
[  OK  ] Created slice system-prepare\x2dapp.slice.
[  OK  ] Listening on Journal Socket.
[  OK  ] Started Pod shutdown.
         Starting Network configuration for device: eth0...
         Starting Create /etc/passwd and /etc/group...
[  OK  ] Listening on OpenSSH Server Socket for entering purpose.
[  OK  ] Started busybox Reaper.
[  OK  ] Listening on Journal Socket (/dev/log).
         Starting Journal Service...
[  OK  ] Started Create /etc/passwd and /etc/group.
[  OK  ] Started Network configuration for device: eth0.
[  OK  ] Started Journal Service.
         Starting Prepare minimum environment for chrooted applications...
[  OK  ] Started Prepare minimum environment for chrooted applications.
[  OK  ] Started Application=busybox Image=kinvolk.io/aci/busybox.
[  OK  ] Reached target rkt apps target.
/ # 

@jjlakis jjlakis force-pushed the jlakis-hypervisor2 branch from bf2d258 to 4008ce8 Compare July 26, 2016 13:24
@jjlakis
Copy link
Author

jjlakis commented Jul 26, 2016

Added some fixes, TestDiagnostic is passing and there's no reduntant output while starting pod (#2952 (comment))

$(call setup-stamp-file,UFK_CBU_STAMP,cbu)
$(call setup-tmp-dir,UFK_TMPDIR)

HV_BUILD_FILE :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

This may break make clean in a certain scenario (configure with kvm-qemu flavor, make, configure with kvm-lkvm flavor, make, make clean).

I would prefer if you included both lkvm.mk and qemu.mk unconditionally, but instead modify the S1_RF_SECONDARY_STAMPS conditionally, like as follows:

UFK_INCLUDES := \
    kernel.mk \
    files.mk \
    lkvm.mk \
    qemu.mk
...
$(call inc-many,$(UFK_INCLUDES))

ifeq ($(KVM_HV_TAG),"hv_lkvm")
    S1_RF_SECONDARY_STAMPS += $(LKVM_STAMP)
else ifeq ($(KVM_HV_TAG),"hv_qemu")
    S1_RF_SECONDARY_STAMPS += $(QEMU_STAMP)
endif

For this to work, you should also exclude both QEMU_STAMP and LKVM_STAMP from the namespace undefine mechanism. You can do it like so:

in lkvm.mk at the bottom of the file:

$(call undefine-namespaces,LKVM,LKVM_STAMP)

in qemu.mk at the bottom of the file:

$(call undefine-namespaces,QEMU,QEMU_STAMP)

And remove the lines in lkvm.mk and qemu.mk modifying the S1_RF_SECONDARY_STAMPS variable.

@squeed
Copy link
Contributor

squeed commented Jul 26, 2016

I agree with @alban, I think that the kvm / qemu should be different flavors. For the formal release process, we're going to want to build and distribute both.

@jjlakis
Copy link
Author

jjlakis commented Jul 27, 2016

@squeed Same flavor but separate images also allow to build and distribute both.

@jonboulle
Copy link
Contributor

Are we good to go here?

@jellonek
Copy link
Contributor

👍

@jjlakis
Copy link
Author

jjlakis commented Sep 12, 2016

Doc files updated 8a17e58

@s-urbaniak
Copy link
Contributor

I still get a compilation error as mentioned in #2952 (comment).

@s-urbaniak
Copy link
Contributor

(And by removing --static fixes it), but again, this will fail in i.e. Arch upstream.

@s-urbaniak
Copy link
Contributor

I also suggest to set --disable-werror in QEMU_CONFIGURATION_OPTS, since new compilers have more restrictions, like here with deprecation warnings:

$ make
  CONFIG EXT   qemu
  BUILD EXT    qemu
hw/9pfs/9p-local.c: In function ‘local_readdir_r’:
hw/9pfs/9p-local.c:398:5: warning: ‘readdir_r’ is deprecated [-Wdeprecated-declarations]
...
$ gcc --version
gcc (GCC) 6.2.1 20160830
...

@s-urbaniak
Copy link
Contributor

I have started a qemu based container, locally, great work @jjlakis ! 👍 👍

So this LGTM modulo the --static issue ;-)

@jellonek
Copy link
Contributor

Binaries built without --static can fail on other os distro/version (especially built on other than glibc libcs - alpine for example) so removal of this option would be IMO wrong.

@s-urbaniak
Copy link
Contributor

FYI: apparently Arch won't include the static libraries for glib2: https://bugs.archlinux.org/task/35758

@jjlakis
Copy link
Author

jjlakis commented Sep 13, 2016

@s-urbaniak @iaguis If qemu static build for Arch is not possible and looks like it won't be, it has to be documented. Or maybe we can recommend using rocket-in-rocket build? Of course I can add rkt configure option for static/non-static qemu build, but it wouldn't be so pretty IMO.

@jellonek
Copy link
Contributor

As @iaguis pointed on irc - there is hope also for Arch - https://aur.archlinux.org/packages/glib2-static/
Still this is issue IMO out of scope of ... this issue and i think that option to build non-static qemu is unnecessary.

IMO this PR is complete and ready to be merged.

@s-urbaniak
Copy link
Contributor

ok, this LGTM then, do you want to create follow-up issues for #2952 (comment), and #2952 (comment), or is this also resolved here already?

@lucab
Copy link
Member

lucab commented Sep 13, 2016

So, we can keep the static version for the moment and merge it as-is. This looks still rough around the edges, so a bit more exposure will help finding and fixing more issues. Arch downstream (and anybody else missing some .a) will probably not opt-in for the moment and just use our .aci if they want to play with it. If we have other issues related to linking, we may explore the dynamic linking way as a last resort. As a non-default kvm flavor, LGTM too.

Side question: how does https://github.com/01org/qemu-lite relate to this? I see it is not used here, but it is part of the ClearContainers brand.

@s-urbaniak s-urbaniak merged commit fc228dc into rkt:master Sep 13, 2016
@jellonek
Copy link
Contributor

@lucab when i was still at Intel there was a plan to switch from plain qemu to this qemu-lite, but at the moment this project was unreleased, so this was a goal for future, so the question if if Intel guys have this still in backlog.

@jjlakis
Copy link
Author

jjlakis commented Sep 13, 2016

Thanks! That was PR of my life 💃
@lucab Definetely we will work on optimized QEMU
@s-urbaniak Issues with Ctrl+C and redundant output are resolved :)

@pskrzyns pskrzyns deleted the jlakis-hypervisor2 branch September 13, 2016 15:16
jjlakis referenced this pull request in rbradford/rkt Sep 30, 2016
This change adds the ability to configure rkt to use qemu-lite
(implementing the pc-lite machine) over qemu.

This change comprises of two parts:

* The build system to retrieve qemu-lite source, configure and build
  (derived from the exiting qemu.mk)
* A fork of the hvqemu package to support the slightly different command
  line options required for qemu.

Signed-off-by: Rob Bradford <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants