[OpenWrt-Devel] Hyper-V Support for X86 or X86_64

Ning Ye ning at oaklight.us
Wed Jan 21 14:04:13 EST 2015


This is the latest Hyper-V patch to support Linux 3.14.


Signed-off-by: Ning Ye <ning at oaklight.us>
--------------------------------------------------------
diff --git a/config/Config-images.in b/config/Config-images.in
old mode 100644
new mode 100755
index 5c2e79e..b8e9d9d
--- a/config/Config-images.in
+++ b/config/Config-images.in
@@ -239,6 +239,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 OLPC_BOOTSCRIPT_IMAGES || GRUB_IMAGES
diff --git a/package/kernel/linux/modules/virtual.mk b/package/kernel/linux/modules/virtual.mk
old mode 100644
new mode 100755
index 190d844..a67d71c
--- a/package/kernel/linux/modules/virtual.mk
+++ b/package/kernel/linux/modules/virtual.mk
@@ -186,3 +186,85 @@ 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
+  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
+  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
+  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
+  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.14 b/target/linux/x86/config-3.14
old mode 100644
new mode 100755
index 591fa17..f3f5456
--- a/target/linux/x86/config-3.14
+++ b/target/linux/x86/config-3.14
@@ -197,6 +197,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
old mode 100644
new mode 100755
index 5983718..80ef5cf
--- a/target/linux/x86/image/Makefile
+++ b/target/linux/x86/image/Makefile
@@ -178,6 +178,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 -f9 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img
 	gzip -f9 $(BIN_DIR)/$(IMG_PREFIX)-rootfs-$(1).img
@@ -252,6 +261,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
diff --git a/target/linux/x86_64/config-default b/target/linux/x86_64/config-default
old mode 100644
new mode 100755
index dde8b25..dee3266
--- a/target/linux/x86_64/config-default
+++ b/target/linux/x86_64/config-default
@@ -258,6 +258,13 @@ CONFIG_HW_RANDOM=y
 CONFIG_HW_RANDOM_INTEL=y
 # CONFIG_HW_RANDOM_VIRTIO is not set
 CONFIG_HYPERVISOR_GUEST=y
+# 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_FB_HYPERV is not set
+# CONFIG_HID_HYPERV_MOUSE is not set
 CONFIG_HZ_PERIODIC=y
 # CONFIG_I7300_IDLE is not set
 CONFIG_I8253_LOCK=y
diff --git a/target/linux/x86_64/image/Makefile b/target/linux/x86_64/image/Makefile
old mode 100644
new mode 100755
index e8d9ac1..a8fa85d
--- a/target/linux/x86_64/image/Makefile
+++ b/target/linux/x86_64/image/Makefile
@@ -158,6 +158,16 @@ 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 -f9 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img
 	gzip -f9 $(BIN_DIR)/$(IMG_PREFIX)-rootfs-$(1).img
@@ -201,6 +211,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
_______________________________________________
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