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

Conversation

@dlespiau
Copy link
Contributor

It'd be nice if we could use hyperstart as a regular daemon instead of just an init system. This allows us to:

  • Customise the OS we run inside the VM. There are configurations where we want a fuller OS than just an initrd+hyperstart. In those cases, hyperstart becomes a daemon started by systemd.
  • Something else that could be nice is to have hyperstart started by nsenter or systemd-nspawn so we can debug it on the host side (gdb, strace, ...). I have something like this sort of working and this series is the start of it.

NULL) == -1) {
perror("mount devpts failed");
return -1;
}
Copy link
Contributor

@laijs laijs Oct 19, 2016

Choose a reason for hiding this comment

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

I think we could move the above code and some init-related code into a function.
and the new function should be called only when argv[0] == "init".

Copy link
Contributor

Choose a reason for hiding this comment

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

I still consider moving the above code and some init-related code into a function better than introducing system_mount()? @dlespiau what do you think? it might be better in looking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, sure, I'll have a look.

Currently it's only the system mounts that are causing problems because they are actually trying to remount the already mounted file systems, so might just pull those in a separate function.

Copy link
Contributor

Choose a reason for hiding this comment

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

the commit for Regrouped the early setup code (system mounts, becoming session leader and setting up a controlling terminal in a single function that is skipped when not running as "init". is missing

@@ -1,3 +1,12 @@
AM_CFLAGS = -Wall -Werror
bin_PROGRAMS=init
init_SOURCES=init.c jsmn.c net.c util.c parse.c parson.c container.c exec.c event.c portmapping.c
Copy link
Contributor

Choose a reason for hiding this comment

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

we can compile it to src/hyperstart only.
and copy src/hyperstart to rootfs/init in the make-initrd.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooops, pushed the wrong branch, the new update should have the correct commmits.

@laijs
Copy link
Contributor

laijs commented Oct 19, 2016

trivis error:

checking for SYSTEMD... no
configure: error: Package requirements (systemd) were not met:
No package 'systemd' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables SYSTEMD_CFLAGS
and SYSTEMD_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

@dlespiau
Copy link
Contributor Author

PR updated:

  • Changed the binary name to "hyperstart" instead of "init" and change its name
    when being copied to the initrd image.
  • hyperstart now knows if it has been started as an init system or a regular
    daemon based on argv[0]
  • Added a trivial patch to ignore config.h.in~ I had lying around
  • Fixed the case where we don't have the systemd .pc file
  • Made sure we don't introduce a build-time dependency on pkg-config

@dlespiau
Copy link
Contributor Author

PR updated:

  • Remove read_cmdline() that wasn't doing anything.
  • Regrouped the early setup code (system mounts, becoming session leader and
    setting up a controlling terminal in a single function that is skipped when
    not running as "init".

#include "container.h"
#include "../config.h"

char *read_cmdline(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we should remove it, we may pass the debug level from it in future.
#170

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What the function does is "return NULL", I'm not really removing anything useful that would need to be rewritten :)

@dlespiau
Copy link
Contributor Author

PR updated:

  • dropped the commit removing read_cmdline()

@dlespiau
Copy link
Contributor Author

Is there anything else blocking this PR? Thanks!

@dlespiau
Copy link
Contributor Author

dlespiau commented Nov 9, 2016

ping! :)

@devimc
Copy link
Contributor

devimc commented Nov 10, 2016

👍

@dlespiau
Copy link
Contributor Author

dlespiau commented Dec 1, 2016

Hi,

Can I do anything to help this PR getting merged? Or maybe you do not want to support hyperstart as a regular daemon?

Thanks,

src/init.c Outdated
{
char *cmdline, *ctl_serial, *tty_serial;
if (!is_init)
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

cloud you move the test up (outside this hyper_setup_init_process())?

and it seams better to remove this global is_init since there is no other usage.

return -1;
}

cmdline = read_cmdline();
Copy link
Contributor

Choose a reason for hiding this comment

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

leave this in the hyper_setup_init_process()

@gnawux
Copy link
Member

gnawux commented Dec 2, 2016

@dlespiau Sorry for the delay, we are willing to enable the daemon mode, and we are working on get this to be merged soon. BTW, could you share some tests/comparison of the daemon mode?

@Jimmy-Xu
Copy link

Can one of the admins verify this patch?

1 similar comment
@Jimmy-Xu
Copy link

Can one of the admins verify this patch?

@laijs
Copy link
Contributor

laijs commented Dec 15, 2016

hello @dlespiau, could you update the pr please?

@laijs
Copy link
Contributor

laijs commented Dec 22, 2016

hyperstart uses devtmpfs for containers' /dev, but devtmpfs is the singleton in the whole system,
it is shared with all the containers and the rest of the system. it is Ok when hyperstart is the init process. is it Ok when hyperstart is daemon mode? if not we should convert it to tmpfs as the same as libcontainer.

Damien Lespiau and others added 5 commits February 10, 2017 12:27
I have one of the autoconf generated files not being ignored,
config.h.in~, it's usual to igore /config.* in one go.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
We'd like to be able to run hyperstart as a regular daemon as well as
the init system and have small behavioural differences between the two.
Start by renaming the binary to "hyperstart", it will be copied as
"init" when preparing the initrd.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
This commit adds a systemd service file to start hyperstart when
configured in daemon mode.

v2: Fix the case where we don't have have the systemd pkgconfig file (Damien)

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
We base this detection on the name of the binary: "init" means we've
been started as an init system.

When not running as an init system, we can skip the basic initialisation
as systemd or any other init system would have done that for us.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
@dlespiau
Copy link
Contributor Author

Updated PR:

  • Rebased onto master (needed to fix a couple of conflicts)
  • moved is_init inside main()

@dlespiau
Copy link
Contributor Author

@laijs we haven't seen any problems with the containers' /dev so far.

@laijs laijs merged commit a9aa2f7 into hyperhq:master Feb 10, 2017
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.

6 participants