[OpenWrt-Devel] [PATCH] kernel: Hyper-V support for Linux 3.18

Hauke Mehrtens hauke at hauke-m.de
Wed Dec 2 17:13:09 EST 2015


On 11/27/2015 05:25 PM, Ning Ye wrote:
> kernel: Update Hyper-V support for Linux 3.18 and OpenWRT  trunk.  Now
> requires at least 96 MB memory for VM.
> 
> Signed-off-by: Ning Ye <ning at oaklight.us>

Getting Hyper-V guest support into OpenWrt is a good plan.

I am still thinking about how it should be integrated.

hyperv needs some parts build into the kernel image, so these parts
should not be selected in the virtual.mk file. As most of the parts
which have to be build in are already in the kvm subtarget I would
suggest to extend the kvm and the 64 subtarget to also support hyperv.

You should make your hyperv packages depend on
DEPENDS:=@TARGET_x86_kvm_guest||TARGET_x86_64
These subtargets already have CONFIG_HYPERVISOR_GUEST=y set.

Then you can add OpenWrt kernel packages for the modules you already
added modules and please also make CONFIG_HYPERV a module if it is
possible.

> ---
>  config/Config-images.in                 | 10 ++++
>  package/kernel/linux/modules/virtual.mk | 86
> +++++++++++++++++++++++++++++++++
>  target/linux/x86/config-3.18            |  9 ++++
>  target/linux/x86/image/Makefile         | 10 ++++
>  4 files changed, 115 insertions(+)
> 
> diff --git a/config/Config-images.in b/config/Config-images.in index
> a60dd50..ff16ef0 100644
> --- a/config/Config-images.in
> +++ b/config/Config-images.in
> @@ -238,6 +238,16 @@ menu "Target Images"
>  		select TARGET_IMAGES_PAD
>  		select PACKAGE_kmod-e1000
>  
> +	config VHD_IMAGES
> +		bool "Build Hyper-V image files (VHD)"
> +		depends on TARGET_x86 || TARGET_x86_64
> +		select GRUB_IMAGES
> +		select TARGET_IMAGES_PAD
> +		select PACKAGE_kmod-hyperv-balloon
> +		select PACKAGE_kmod-hyperv-net-vsc
> +		select PACKAGE_kmod-hyperv-util
> +		select PACKAGE_kmod-hyperv-storage
> +
>  	config TARGET_IMAGES_PAD
>  		bool "Pad images to filesystem size (for JFFS2)"
>  		depends on GRUB_IMAGES
> diff --git a/package/kernel/linux/modules/virtual.mk
> b/package/kernel/linux/modules/virtual.mk
> index 61a8a87..2d9f8dd 100644
> --- a/package/kernel/linux/modules/virtual.mk
> +++ b/package/kernel/linux/modules/virtual.mk
> @@ -169,3 +169,89 @@ define KernelPackage/xen-pcidev/description
>  endef
>  
>  $(eval $(call KernelPackage,xen-pcidev))
> +
> +#
> +# Hyper-V Drives depends on x86 or x86_64.
> +#
> +define KernelPackage/hyperv-balloon
> +  SUBMENU:=$(VIRTUAL_MENU)
> +  DEPENDS:=@(TARGET_x86||TARGET_x86_64)
> +  TITLE:=Microsoft Hyper-V Balloon Driver
> +  KCONFIG:= \
> +    CONFIG_HYPERV_BALLOON \
> +    CONFIG_HYPERVISOR_GUEST=y \
> +    CONFIG_PARAVIRT=n \
> +    CONFIG_HYPERV=y
> +  FILES:=$(LINUX_DIR)/drivers/hv/hv_balloon.ko \
> +    $(LINUX_DIR)/drivers/hv/hv_vmbus.ko
> +  AUTOLOAD:=$(call AutoLoad,06,hv_balloon) endef
> +
> +define KernelPackage/hyperv-balloon/description
> +  Microsofot Hyper-V balloon driver.
> +endef
> +
> +$(eval $(call KernelPackage,hyperv-balloon))
> +
> +define KernelPackage/hyperv-net-vsc
> +  SUBMENU:=$(VIRTUAL_MENU)
> +  DEPENDS:=@(TARGET_x86||TARGET_x86_64)
> +  TITLE:=Microsoft Hyper-V Network Driver
> +  KCONFIG:= \
> +    CONFIG_HYPERV_NET \
> +    CONFIG_HYPERVISOR_GUEST=y \
> +    CONFIG_PARAVIRT=n \
> +    CONFIG_HYPERV=y
> +  FILES:=$(LINUX_DIR)/drivers/net/hyperv/hv_netvsc.ko \
> +    $(LINUX_DIR)/drivers/hv/hv_vmbus.ko
> +  AUTOLOAD:=$(call AutoLoad,35,hv_netvsc) endef
> +
> +define KernelPackage/hyperv-net-vsc/description
> +  Microsoft Hyper-V Network Driver
> +endef
> +
> +$(eval $(call KernelPackage,hyperv-net-vsc))
> +
> +define KernelPackage/hyperv-util
> +  SUBMENU:=$(VIRTUAL_MENU)
> +  DEPENDS:=@(TARGET_x86||TARGET_x86_64)
> +  TITLE:=Microsoft Hyper-V Utility Driver
> +  KCONFIG:= \
> +    CONFIG_HYPERV_UTILS \
> +    CONFIG_HYPERVISOR_GUEST=y \
> +    CONFIG_PARAVIRT=n \
> +    CONFIG_HYPERV=y
> +  FILES:=$(LINUX_DIR)/drivers/hv/hv_util.ko \
> +    $(LINUX_DIR)/drivers/hv/hv_vmbus.ko
> +  AUTOLOAD:=$(call AutoLoad,10,hv_util) endef
> +
> +define KernelPackage/hyperv-util/description
> +  Microsoft Hyper-V Utility Driver
> +endef
> +
> +$(eval $(call KernelPackage,hyperv-util))
> +
> +#
> +# Hyper-V Storage Drive needs to be in kernel rather than module to load
> the root fs.
> +#
> +define KernelPackage/hyperv-storage
> +  SUBMENU:=$(VIRTUAL_MENU)
> +  DEPENDS:=@(TARGET_x86||TARGET_x86_64) +kmod-scsi-core
> +  TITLE:=Microsoft Hyper-V Storage Driver
> +  KCONFIG:= \
> +    CONFIG_HYPERV_STORAGE=y \
> +    CONFIG_HYPERVISOR_GUEST=y \
> +    CONFIG_PARAVIRT=n \
> +    CONFIG_HYPERV=y
> +  FILES:=$(LINUX_DIR)/drivers/scsi/hv_storvsc.ko \
> +    $(LINUX_DIR)/drivers/hv/hv_vmbus.ko
> +  AUTOLOAD:=$(call AutoLoad,40,hv_storvsc) endef
> +
> +define KernelPackage/hyperv-storage/description
> +  Microsoft Hyper-V Storage Driver
> +endef
> +
> +$(eval $(call KernelPackage,hyperv-storage))
> diff --git a/target/linux/x86/config-3.18 b/target/linux/x86/config-3.18
> index bb647c8..8ac3709 100644
> --- a/target/linux/x86/config-3.18
> +++ b/target/linux/x86/config-3.18
> @@ -204,6 +204,15 @@ CONFIG_HW_RANDOM=y
>  CONFIG_HW_RANDOM_GEODE=y
>  CONFIG_HW_RANDOM_VIA=y
>  # CONFIG_HYPERVISOR_GUEST is not set
> +# CONFIG_HYPERV is not set
> +# CONFIG_HYPERV_BALLOON is not set
> +# CONFIG_HYPERV_NET is not set
> +# CONFIG_HYPERV_STORAGE is not set
> +# CONFIG_HYPERV_UTILS is not set
> +# CONFIG_HYPERV_KEYBOARD is not set
> +# CONFIG_FB_HYPERV is not set
> +# CONFIG_HID_HYPERV_MOUSE is not set
> +# CONFIG_VMWARE_BALLOON is not set
>  CONFIG_HZ_PERIODIC=y
>  CONFIG_I8253_LOCK=y
>  # CONFIG_I8K is not set
> diff --git a/target/linux/x86/image/Makefile
> b/target/linux/x86/image/Makefile index 8e56372..50507a7 100644
> --- a/target/linux/x86/image/Makefile
> +++ b/target/linux/x86/image/Makefile
> @@ -148,6 +148,15 @@ ifneq ($(CONFIG_VMDK_IMAGES),)
>    endef
>  endif
>  
> +ifneq ($(CONFIG_VHD_IMAGES),)
> +  define Image/Build/vhd
> +	rm $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vhd || true
> +	qemu-img convert -f raw -O vpc \
> +		$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \
> +		$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vhd
> +  endef
> +endif
> +
>  define Image/Build/gzip
>  	gzip -f9n $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img
>  	gzip -f9n $(BIN_DIR)/$(IMG_PREFIX)-rootfs-$(1).img
> @@ -219,6 +228,7 @@ define Image/Build
>  	$(call Image/Build/grub2,$(1))
>  	$(call Image/Build/vdi,$(1))
>  	$(call Image/Build/vmdk,$(1))
> +	$(call Image/Build/vhd,$(1))
>  	$(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-rootfs-$(1).img
>    else
>  	$(CP) $(KDIR)/root.iso $(BIN_DIR)/$(IMG_PREFIX).iso
> --
> 1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list