hyperhq / runv

Hypervisor-based Runtime for OCI
Apache License 2.0
826 stars 129 forks source link

Add bios+cbfs support for runv #453

Closed WeiZhang555 closed 7 years ago

WeiZhang555 commented 7 years ago

Export and Support starting VM with bios+cbfs from runv command line, also use CBFS as first choice when kernel also exists.

Signed-off-by: Zhang Wei zhangwei555@huawei.com

WeiZhang555 commented 7 years ago

Sadly, I found that cbfs.rom made from latest cbfs file exceed 8MB which makes it impossible to start container, I've modified our own qemu to remove this restriction, and it works well since then.

qemu patches:

diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 579461f..1effda7 100644
--- a/hw/i386/pc_sysfw.c
+++ b/hw/i386/pc_sysfw.c
@@ -81,7 +81,11 @@ static void pc_isa_bios_init(MemoryRegion *rom_memory,
  * only 18MB-4KB below 4G. For now, restrict the cumulative mapping to 8MB in
  * size.
  */  
+#ifdef TARGET_X86_64UVM
+#define FLASH_MAP_BASE_MIN ((hwaddr)(0x100000000ULL - 16*1024*1024))
+#else
 #define FLASH_MAP_BASE_MIN ((hwaddr)(0x100000000ULL - 8*1024*1024))
+#endif

 /* This function maps flash drives from 4G downward, in order of their unit
  * numbers. The mapping starts at unit#0, with unit number increments of 1, and 
dvoytik commented 7 years ago

@WeiZhang555 see https://github.com/hyperhq/hyperstart/pull/280 how to solve this problem without patching QEMU.

WeiZhang555 commented 7 years ago

@dvoytik So the solution is, exclude kernel modules to make cbfs file smaller than 8MB? Are we sure we dont need these kernel modules for making runv work correctly?

gnawux commented 7 years ago

I think most of the modules are for netfilter or cgroup support. @WeiZhang555

dvoytik commented 7 years ago

This parameter by default is off -> the kernel modules are included. If one enables this parameter then apparently she uses a custom kernel (the name of the flag implies this). In my case I use custom kernel without modules, so I use this parameter.

Btw I don't understand who needs modules in guest kernel for containers, but it's another off-topic issue.

WeiZhang555 commented 7 years ago

If so, I think hyperhq/hyperstart#280 should make sense, by the way, @dvoytik is my colleague from our Germany Team working on this too :) @gnawux

WeiZhang555 commented 7 years ago

Refactored, ping @laijs

WeiZhang555 commented 7 years ago

ping @laijs Rebased.

laijs commented 7 years ago

514 was implemented for you...

WeiZhang555 commented 7 years ago

So are you suggesting me adding new flag "--cbfs" and "--kernel" directly for runv containerd? And as I can see, this new cbfs factory isn't needed any more.

laijs commented 7 years ago

Sure

WeiZhang555 commented 7 years ago

OK. I'll do a refactor~

WeiZhang555 commented 7 years ago

@laijs Updated again~