Skip to contentSkip to conversation

qemu: add support for host-qemu-system

PATCH New Simon Maes 3 participants 14 messages May 4, 2016 – Jul 3, 2016

lore
Share & tools
lore

Simon Maes

author
#0 lore raw

PATCH 1/6 qemu: add support for host-qemu-system

Additional package configurations are:
- Enable system or linux user-land emulation
- Enable SDL frontend and FDT support
- Enable Qemu debug
- Disable stripped binary format

---
 package/qemu/Config.in.host | 66 +++++++++++++++++++++++++++++++++++++++++++++
 package/qemu/qemu.mk        | 39 ++++++++++++++++++++++-----
 2 files changed, 99 insertions(+), 6 deletions(-)
package/qemu/Config.in.host +66 -0
index c5c3f05..71f697e 100644
@@ -15,3 +15,69 @@ config BR2_PACKAGE_HOST_QEMU
 	  This option builds a user emulator for your selected architecture.
 
 	  http://www.qemu.org
+
+if BR2_PACKAGE_HOST_QEMU
+
+#
+# Configuration selection
+#
+
+comment "Emulators selection"
+
+config BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE
+	bool "Enable systems emulation"
+	depends on !BR2_STATIC_LIBS # dtc
+	select BR2_PACKAGE_HOST_QEMU_FDT
+	help
+	  Say 'y' to build system emulators/virtualisers.
+	  When building the host-qemu package for system emulation,
+	  qemu will be configured to support the Target Architecture,
+	  configured in Buildroot
+
+config BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE
+	bool "Enable Linux user-land emulation"
+	help
+	  Say 'y' to build Linux user-land emulators.
+
+config BR2_PACKAGE_HOST_QEMU_HAS_EMULS
+	def_bool y
+	depends on BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE || \
+		BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE
+
+if BR2_PACKAGE_HOST_QEMU_HAS_EMULS
+
+comment "Frontends"
+
+config BR2_PACKAGE_HOST_QEMU_SDL
+	bool "Enable SDL frontend"
+	select BR2_PACKAGE_SDL
+	help
+	  Say 'y' to enable the SDL frontend, that is, a graphical window
+	  presenting the VM's display.
+
+comment "Misc. features"
+
+config BR2_PACKAGE_HOST_QEMU_FDT
+	bool "Enable FDT"
+	depends on !BR2_STATIC_LIBS # dtc
+	select BR2_PACKAGE_DTC
+	help
+	  Say 'y' to have QEMU capable of constructing Device Trees,
+	  and passing them to the VMs.
+
+comment "FDT support needs a toolchain w/ dynamic library"
+	depends on BR2_STATIC_LIBS
+
+config BR2_PACKAGE_HOST_QEMU_DEBUG
+	bool "Enable debug"
+	help
+	  Say 'y' to enable build options for QEMU.
+
+config BR2_PACKAGE_HOST_QEMU_STRIP_BINARY
+	bool "Enable stripped binary format"
+	help
+	  Say 'y' to enable stripping of the QEMU binary.
+
+endif # BR2_PACKAGE_HOST_QEMU_HAS_EMULS
+
+endif # BR2_PACKAGE_HOST_QEMU
package/qemu/qemu.mk +33 -6
index 522910e..0e99138 100644
@@ -17,6 +17,8 @@ QEMU_LICENSE_FILES = COPYING COPYING.LIB
 # Host-qemu
 
 HOST_QEMU_DEPENDENCIES = host-pkgconf host-python host-zlib host-libglib2 host-pixman
+HOST_QEMU_SITE = $(QEMU_SITE)
+HOST_QEMU_SOURCE = $(QEMU_SOURCE)
 
 #       BR ARCH         qemu
 #       -------         ----
@@ -61,7 +63,6 @@ endif
 ifeq ($(HOST_QEMU_ARCH),sh4aeb)
 HOST_QEMU_ARCH = sh4eb
 endif
-HOST_QEMU_TARGETS = $(HOST_QEMU_ARCH)-linux-user
 
 ifeq ($(BR2_PACKAGE_HOST_QEMU),y)
 HOST_QEMU_HOST_SYSTEM_TYPE = $(shell uname -s)
@@ -69,10 +70,12 @@ ifneq ($(HOST_QEMU_HOST_SYSTEM_TYPE),Linux)
 $(error "qemu-user can only be used on Linux hosts")
 endif
 
-# kernel version as major*256 + minor
-HOST_QEMU_HOST_SYSTEM_VERSION = $(shell uname -r | awk -F. '{ print $$1 * 256 + $$2 }')
-HOST_QEMU_TARGET_SYSTEM_VERSION = $(shell echo $(BR2_TOOLCHAIN_HEADERS_AT_LEAST) | awk -F. '{ print $$1 * 256 + $$2 }')
-HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge $(HOST_QEMU_TARGET_SYSTEM_VERSION) && echo OK)
+ifeq ($(BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE),y)
+HOST_QEMU_TARGETS += $(HOST_QEMU_ARCH)-softmmu
+HOST_QEMU_OPTS += --enable-system
+else
+HOST_QEMU_OPTS += --disable-system
+endif
 
 #
 # The principle of qemu-user is that it emulates the instructions of
@@ -84,11 +87,34 @@ HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge $(
 # built with kernel headers that are older or the same as the kernel
 # version running on the host machine.
 #
+
+ifeq ($(BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE),y)
+HOST_QEMU_TARGETS += $(HOST_QEMU_ARCH)-linux-user
+HOST_QEMU_OPTS += --enable-linux-user
+
+# kernel version as major*256 + minor
+HOST_QEMU_HOST_SYSTEM_VERSION = $(shell uname -r | awk -F. '{ print $$1 * 256 + $$2 }')
+HOST_QEMU_TARGET_SYSTEM_VERSION = $(shell echo $(BR2_TOOLCHAIN_HEADERS_AT_LEAST) | awk -F. '{ print $$1 * 256 + $$2 }')
+HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge $(HOST_QEMU_TARGET_SYSTEM_VERSION) && echo OK)
+
 ifeq ($(BR_BUILDING),y)
 ifneq ($(HOST_QEMU_COMPARE_VERSION),OK)
 $(error "Refusing to build qemu-user: target Linux version newer than host's.")
 endif
+
+else
+HOST_QEMU_OPTS += --disable-linux-user
+endif
 endif
+
+ifeq ($(BR2_PACKAGE_HOST_QEMU_DEBUG),y)
+HOST_QEMU_OPTS += --enable-debug
+endif
+
+ifeq ($(BR2_PACKAGE_HOST_QEMU_STRIP_BINARY),n)
+HOST_QEMU_OPTS += --disable-strip
+endif
+
 endif
 
 define HOST_QEMU_CONFIGURE_CMDS
@@ -100,7 +126,8 @@ define HOST_QEMU_CONFIGURE_CMDS
 		--host-cc="$(HOSTCC)"                   \
 		--python=$(HOST_DIR)/usr/bin/python2    \
 		--extra-cflags="$(HOST_CFLAGS)"         \
-		--extra-ldflags="$(HOST_LDFLAGS)"
+		--extra-ldflags="$(HOST_LDFLAGS)"       \
+		$(HOST_QEMU_OPTS)
 endef
 
 define HOST_QEMU_BUILD_CMDS
Signature · 1 line
2.6.2
author
#1 lore raw

PATCH 2/6 qemu: make qemu and host-qemu packages' version (separately) configurable

---
 package/qemu/Config.in      |  8 ++++++++
 package/qemu/Config.in.host |  8 ++++++++
 package/qemu/qemu.mk        | 26 ++++++++++++++++++--------
 3 files changed, 34 insertions(+), 8 deletions(-)
package/qemu/Config.in +8 -0
index ea6b946..a16a65c 100644
@@ -36,6 +36,14 @@ config BR2_PACKAGE_QEMU
 
 if BR2_PACKAGE_QEMU
 
+config BR2_PACKAGE_QEMU_VERSION
+	string "qemu version"
+	default "2.5.0"
+	help
+	  QEMU version to use target qemu
+	  Sometimes the latest version is broken for some specific
+	  architecture or target machine
+
 comment "Emulators selection"
 
 config BR2_PACKAGE_QEMU_CUSTOM_TARGETS
package/qemu/Config.in.host +8 -0
index 71f697e..c86768f 100644
@@ -18,6 +18,14 @@ config BR2_PACKAGE_HOST_QEMU
 
 if BR2_PACKAGE_HOST_QEMU
 
+config BR2_PACKAGE_HOST_QEMU_VERSION
+	string "host qemu version"
+	default "2.5.0"
+	help
+	  QEMU version to use for host qemu
+	  Sometimes the latest version is broken for some specific
+	  architecture or target machine
+
 #
 # Configuration selection
 #
package/qemu/qemu.mk +18 -8
index 0e99138..151060b 100644
@@ -4,18 +4,19 @@
 #
 ################################################################################
 
-QEMU_VERSION = 2.5.1
-QEMU_SOURCE = qemu-$(QEMU_VERSION).tar.bz2
-QEMU_SITE = http://wiki.qemu.org/download
-QEMU_LICENSE = GPLv2, LGPLv2.1, MIT, BSD-3c, BSD-2c, Others/BSD-1c
-QEMU_LICENSE_FILES = COPYING COPYING.LIB
-#??NOTE: there is no top-level license file for non-(L)GPL licenses;
-#       the non-(L)GPL license texts are specified in the affected
-#       individual source files.
 
 #-------------------------------------------------------------
 # Host-qemu
 
+HOST_QEMU_VERSION = $(call qstrip,$(BR2_PACKAGE_HOST_QEMU_VERSION))
+HOST_QEMU_SOURCE = qemu-$(HOST_QEMU_VERSION).tar.bz2
+HOST_QEMU_SITE = http://wiki.qemu.org/download
+HOST_QEMU_LICENSE = GPLv2, LGPLv2.1, MIT, BSD-3c, BSD-2c, Others/BSD-1c
+HOST_QEMU_LICENSE_FILES = COPYING COPYING.LIB
+#??NOTE: there is no top-level license file for non-(L)GPL licenses;
+#       the non-(L)GPL license texts are specified in the affected
+#       individual source files.
+
 HOST_QEMU_DEPENDENCIES = host-pkgconf host-python host-zlib host-libglib2 host-pixman
 HOST_QEMU_SITE = $(QEMU_SITE)
 HOST_QEMU_SOURCE = $(QEMU_SOURCE)
@@ -146,6 +147,15 @@ QEMU_USER = $(HOST_DIR)/usr/bin/qemu-$(HOST_QEMU_ARCH)
 #-------------------------------------------------------------
 # Target-qemu
 
+QEMU_VERSION = $(call qstrip,$(BR2_PACKAGE_QEMU_VERSION))
+QEMU_SOURCE = qemu-$(QEMU_VERSION).tar.bz2
+QEMU_SITE = http://wiki.qemu.org/download
+QEMU_LICENSE = GPLv2, LGPLv2.1, MIT, BSD-3c, BSD-2c, Others/BSD-1c
+QEMU_LICENSE_FILES = COPYING COPYING.LIB
+#??NOTE: there is no top-level license file for non-(L)GPL licenses;
+#       the non-(L)GPL license texts are specified in the affected
+#       individual source files.
+
 QEMU_DEPENDENCIES = host-pkgconf host-python libglib2 zlib pixman
 
 # Need the LIBS variable because librt and libm are
Signature · 1 line
2.6.2
#2 lore raw

PATCH 2/6 qemu: make qemu and host-qemu packages' version (separately) configurable

Quoted 12 lines · Simon Maes
---
 package/qemu/Config.in      |  8 ++++++++
 package/qemu/Config.in.host |  8 ++++++++
 package/qemu/qemu.mk        | 26 ++++++++++++++++++--------
 3 files changed, 34 insertions(+), 8 deletions(-)
package/qemu/Config.in +0 -0
index ea6b946..a16a65c 100644

package/qemu/Config.in config BR2_PACKAGE_QEMU · line 41

Quoted 6 lines
package/qemu/Config.in +3 -0
@@ -36,6 +36,14 @@ config BR2_PACKAGE_QEMU
 
 if BR2_PACKAGE_QEMU
 
+config BR2_PACKAGE_QEMU_VERSION
+	string "qemu version"
+	default "2.5.0"

Our current version is 2.5.1, so the default should be that as well.

package/qemu/Config.in config BR2_PACKAGE_QEMU · line 43

Quoted 2 lines
package/qemu/Config.in +2 -0
+	help
+	  QEMU version to use target qemu
                              ^^for
Quoted 11 lines
package/qemu/Config.in +3 -0
+	  Sometimes the latest version is broken for some specific
+	  architecture or target machine
+
 comment "Emulators selection"
 
 config BR2_PACKAGE_QEMU_CUSTOM_TARGETS
package/qemu/Config.in.host +0 -0
index 71f697e..c86768f 100644

package/qemu/Config.in.host config BR2_PACKAGE_HOST_QEMU · line 23

Quoted 6 lines
package/qemu/Config.in.host +3 -0
@@ -18,6 +18,14 @@ config BR2_PACKAGE_HOST_QEMU
 
 if BR2_PACKAGE_HOST_QEMU
 
+config BR2_PACKAGE_HOST_QEMU_VERSION
+	string "host qemu version"
+	default "2.5.0"

Same here, default 2.5.1.

Quoted 14 lines
package/qemu/Config.in.host +5 -0
+	help
+	  QEMU version to use for host qemu
+	  Sometimes the latest version is broken for some specific
+	  architecture or target machine
+
 #
 # Configuration selection
 #
package/qemu/qemu.mk +0 -0
index 0e99138..151060b 100644
@@ -4,18 +4,19 @@
 #

package/qemu/qemu.mk line 14

Quoted 10 lines
package/qemu/qemu.mk +0 -8
 ################################################################################
 
-QEMU_VERSION = 2.5.1
-QEMU_SOURCE = qemu-$(QEMU_VERSION).tar.bz2
-QEMU_SITE = http://wiki.qemu.org/download
-QEMU_LICENSE = GPLv2, LGPLv2.1, MIT, BSD-3c, BSD-2c, Others/BSD-1c
-QEMU_LICENSE_FILES = COPYING COPYING.LIB
-# NOTE: there is no top-level license file for non-(L)GPL licenses;
-#       the non-(L)GPL license texts are specified in the affected
-#       individual source files.

There is no reason to move all this. When there are differences between host
and target, we put target first. So just replace

QEMU_VERSION = $(call qstrip,$(BR2_PACKAGE_QEMU_VERSION))

and leave the rest as is.

package/qemu/qemu.mk line 15

Quoted 9 lines
package/qemu/qemu.mk +5 -0
 #-------------------------------------------------------------
 # Host-qemu
 
+HOST_QEMU_VERSION = $(call qstrip,$(BR2_PACKAGE_HOST_QEMU_VERSION))
+HOST_QEMU_SOURCE = qemu-$(HOST_QEMU_VERSION).tar.bz2
+HOST_QEMU_SITE = http://wiki.qemu.org/download
+HOST_QEMU_LICENSE = GPLv2, LGPLv2.1, MIT, BSD-3c, BSD-2c, Others/BSD-1c
+HOST_QEMU_LICENSE_FILES = COPYING COPYING.LIB

Only the first two are needed, all the rest can be inherited from target.

Regards,
Arnout

Quoted 31 lines
package/qemu/qemu.mk +13 -0
+# NOTE: there is no top-level license file for non-(L)GPL licenses;
+#       the non-(L)GPL license texts are specified in the affected
+#       individual source files.
+
 HOST_QEMU_DEPENDENCIES = host-pkgconf host-python host-zlib host-libglib2 host-pixman
 HOST_QEMU_SITE = $(QEMU_SITE)
 HOST_QEMU_SOURCE = $(QEMU_SOURCE)
@@ -146,6 +147,15 @@ QEMU_USER = $(HOST_DIR)/usr/bin/qemu-$(HOST_QEMU_ARCH)
 #-------------------------------------------------------------
 # Target-qemu
 
+QEMU_VERSION = $(call qstrip,$(BR2_PACKAGE_QEMU_VERSION))
+QEMU_SOURCE = qemu-$(QEMU_VERSION).tar.bz2
+QEMU_SITE = http://wiki.qemu.org/download
+QEMU_LICENSE = GPLv2, LGPLv2.1, MIT, BSD-3c, BSD-2c, Others/BSD-1c
+QEMU_LICENSE_FILES = COPYING COPYING.LIB
+# NOTE: there is no top-level license file for non-(L)GPL licenses;
+#       the non-(L)GPL license texts are specified in the affected
+#       individual source files.
+
 QEMU_DEPENDENCIES = host-pkgconf host-python libglib2 zlib pixman
 
 # Need the LIBS variable because librt and libm are

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#3 lore raw

PATCH 2/6 qemu: make qemu and host-qemu packages' version (separately) configurable

In reply to Simon Maes

Simon,

package/qemu/Config.in config BR2_PACKAGE_QEMU · line 41

Quoted 3 lines · Simon Maes
package/qemu/Config.in +3 -0
+config BR2_PACKAGE_QEMU_VERSION
+	string "qemu version"
+	default "2.5.0"

Making the version selectable will break badly with the hash file: it will only work if you use a version for which a hash is listed in the hash file.

For now, we'd prefer to stick to a single supported version, and see if we really have situations where using an older version is mandatory.

Therefore, I've marked this patch as Rejected in our patch tracking system.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
author
#4 lore raw

PATCH 3/6 qemu: code cleanup - (mostly) wrapping lines at 80 characters

In reply to Simon Maes
---
 package/qemu/Config.in |  6 ++++--
 package/qemu/qemu.mk   | 49 ++++++++++++++++++++++++++++---------------------
 2 files changed, 32 insertions(+), 23 deletions(-)
package/qemu/Config.in +4 -2
index a16a65c..9447e11 100644
@@ -86,7 +86,9 @@ endif # BR2_PACKAGE_QEMU_CUSTOM_TARGETS == ""
 
 config BR2_PACKAGE_QEMU_HAS_EMULS
 	def_bool y
-	depends on BR2_PACKAGE_QEMU_SYSTEM || BR2_PACKAGE_QEMU_LINUX_USER || BR2_PACKAGE_QEMU_CUSTOM_TARGETS != ""
+	depends on BR2_PACKAGE_QEMU_SYSTEM ||     \
+			BR2_PACKAGE_QEMU_LINUX_USER ||    \
+			BR2_PACKAGE_QEMU_CUSTOM_TARGETS != ""
 
 if BR2_PACKAGE_QEMU_HAS_EMULS
 
@@ -106,7 +108,7 @@ config BR2_PACKAGE_QEMU_FDT
 	depends on !BR2_STATIC_LIBS # dtc
 	select BR2_PACKAGE_DTC
 	help
-	  Say 'y' here to have QEMU capable of constructing Device Trees,
+	  Say 'y' to have QEMU capable of constructing Device Trees,
 	  and passing them to the VMs.
 
 comment "FDT support needs a toolchain w/ dynamic library"
package/qemu/qemu.mk +28 -21

85 lines not on this page · raw message

Signature · 1 line
2.6.2
#5 lore raw

PATCH 3/6 qemu: code cleanup - (mostly) wrapping lines at 80 characters

Hello,

package/qemu/Config.in endif # BR2_PACKAGE_QEMU_CUSTOM_TARGETS == "" · line 91

Quoted 6 lines · Simon Maes

config BR2_PACKAGE_QEMU_HAS_EMULS

package/qemu/Config.in +3 -1
 	def_bool y
-	depends on BR2_PACKAGE_QEMU_SYSTEM || BR2_PACKAGE_QEMU_LINUX_USER || BR2_PACKAGE_QEMU_CUSTOM_TARGETS != ""
+	depends on BR2_PACKAGE_QEMU_SYSTEM ||     \
+			BR2_PACKAGE_QEMU_LINUX_USER ||    \
+			BR2_PACKAGE_QEMU_CUSTOM_TARGETS != ""

We indent continuation lines with just one more tab.

package/qemu/Config.in config BR2_PACKAGE_QEMU_FDT · line 111

Quoted 8 lines

if BR2_PACKAGE_QEMU_HAS_EMULS

package/qemu/Config.in +1 -1
@@ -106,7 +108,7 @@ config BR2_PACKAGE_QEMU_FDT
 	depends on !BR2_STATIC_LIBS # dtc
 	select BR2_PACKAGE_DTC
 	help
-	  Say 'y' here to have QEMU capable of constructing Device Trees,
+	  Say 'y' to have QEMU capable of constructing Device Trees,

Well, yes, but not super important.

Quoted 8 lines
package/qemu/Config.in +0 -0
 	  and passing them to the VMs.
 
 comment "FDT support needs a toolchain w/ dynamic library"
package/qemu/qemu.mk +0 -0
index 151060b..1910dbd 100644

package/qemu/qemu.mk HOST_QEMU_LICENSE_FILES = COPYING COPYING.LIB · line 21

Quoted 6 lines
package/qemu/qemu.mk +2 -1
@@ -17,7 +17,8 @@ HOST_QEMU_LICENSE_FILES = COPYING COPYING.LIB
 #       the non-(L)GPL license texts are specified in the affected
 #       individual source files.
 
-HOST_QEMU_DEPENDENCIES = host-pkgconf host-python host-zlib host-libglib2 host-pixman
+HOST_QEMU_DEPENDENCIES = host-pkgconf host-python host-zlib host-libglib2 \
+						 host-pixman

See above.

Quoted 9 lines
package/qemu/qemu.mk +0 -2
 HOST_QEMU_SITE = $(QEMU_SITE)
 HOST_QEMU_SOURCE = $(QEMU_SOURCE)
 
@@ -94,9 +95,15 @@ HOST_QEMU_TARGETS += $(HOST_QEMU_ARCH)-linux-user
 HOST_QEMU_OPTS += --enable-linux-user
 
 # kernel version as major*256 + minor
-HOST_QEMU_HOST_SYSTEM_VERSION = $(shell uname -r | awk -F. '{ print $$1 * 256 + $$2 }')
-HOST_QEMU_TARGET_SYSTEM_VERSION = $(shell echo $(BR2_TOOLCHAIN_HEADERS_AT_LEAST) | awk -F. '{ print $$1 * 256 + $$2 }')

package/qemu/qemu.mk HOST_QEMU_TARGETS += $(HOST_QEMU_ARCH)-linux-user · line 106

Quoted 10 lines
package/qemu/qemu.mk +9 -1
-HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge $(HOST_QEMU_TARGET_SYSTEM_VERSION) && echo OK)
+HOST_QEMU_HOST_SYSTEM_VERSION = $(shell uname -r | awk -F. \
+								'{ print $$1 * 256 + $$2 }')
+
+HOST_QEMU_TARGET_SYSTEM_VERSION = $(shell \
+								echo $(BR2_TOOLCHAIN_HEADERS_AT_LEAST) \
+								| awk -F. '{ print $$1 * 256 + $$2 }')
+
+HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge \
+							$(HOST_QEMU_TARGET_SYSTEM_VERSION) && echo OK)

This is actually a lot less readable than it was.

Quoted 12 lines
package/qemu/qemu.mk +0 -6
 ifeq ($(BR_BUILDING),y)
 ifneq ($(HOST_QEMU_COMPARE_VERSION),OK)
@@ -120,14 +127,14 @@ endif
 
 define HOST_QEMU_CONFIGURE_CMDS
 	cd $(@D); $(HOST_CONFIGURE_OPTS) ./configure    \
-		--target-list="$(HOST_QEMU_TARGETS)"    \
-		--prefix="$(HOST_DIR)/usr"              \
-		--interp-prefix=$(STAGING_DIR)          \
-		--cc="$(HOSTCC)"                        \
-		--host-cc="$(HOSTCC)"                   \
-		--python=$(HOST_DIR)/usr/bin/python2    \

package/qemu/qemu.mk endif · line 137

Quoted 10 lines
package/qemu/qemu.mk +8 -2
-		--extra-cflags="$(HOST_CFLAGS)"         \
-		--extra-ldflags="$(HOST_LDFLAGS)"       \
+		--target-list="$(HOST_QEMU_TARGETS)"        \
+		--prefix="$(HOST_DIR)/usr"                  \
+		--interp-prefix=$(STAGING_DIR)              \
+		--cc="$(HOSTCC)"                            \
+		--host-cc="$(HOSTCC)"                       \
+		--python=$(HOST_DIR)/usr/bin/python2        \
+		--extra-cflags="$(HOST_CFLAGS)"             \
+		--extra-ldflags="$(HOST_LDFLAGS)"           \

Our convention now is to put the \ just one space after the line.

package/qemu/qemu.mk define QEMU_BUILD_CMDS · line 265

Quoted 4 lines
package/qemu/qemu.mk +2 -1
 define QEMU_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(QEMU_MAKE_ENV) DESTDIR=$(TARGET_DIR) install
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(QEMU_MAKE_ENV) \
+			DESTDIR=$(TARGET_DIR) install

Only one more tab indentation for the continuation lines.

So, I've marked your patch as Changes Requested in patchwork. Feel free to submit an updated version that takes into account the comments if you're interested.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
author
#6 lore raw

PATCH 4/6 qemu: add qemu-system-run make target

In reply to Simon Maes

Additional configuration for qemu package:
- Save qemu commandline arguments to run qemu directly using 'make qemu-system-run'.

---
 package/qemu/Config.in.host | 7 +++++++
 package/qemu/qemu.mk        | 9 +++++++++
 2 files changed, 16 insertions(+)
package/qemu/Config.in.host +7 -0
index c86768f..8c07e71 100644
@@ -88,4 +88,11 @@ config BR2_PACKAGE_HOST_QEMU_STRIP_BINARY
 
 endif # BR2_PACKAGE_HOST_QEMU_HAS_EMULS
 
+config BR2_PACKAGE_HOST_QEMU_SYSTEM_ARGS
+	string "qemu-system command arguments"
+	depends on BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE
+	help
+	  Arguments to be used for your target host-qemu-system to run
+	  via "make qemu-system-run".
+
 endif # BR2_PACKAGE_HOST_QEMU
package/qemu/qemu.mk +9 -0
index 1910dbd..4de32b9 100644
@@ -151,6 +151,15 @@ $(eval $(host-generic-package))
 # variable used by other packages
 QEMU_USER = $(HOST_DIR)/usr/bin/qemu-$(HOST_QEMU_ARCH)
 
+ifeq ($(BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE),y)
+QEMU_SYSTEM = $(HOST_DIR)/usr/bin/qemu-system-$(HOST_QEMU_ARCH)
+
+.PHONY: qemu-system-run
+qemu-system-run:
+	$(QEMU_SYSTEM) $(call qstrip,$(BR2_PACKAGE_HOST_QEMU_SYSTEM_ARGS))
+endif
+
+
 #-------------------------------------------------------------
 # Target-qemu
 
Signature · 1 line
2.6.2
#7 lore raw

PATCH 4/6 qemu: add qemu-system-run make target

Hello,

Quoted 31 lines · Simon Maes

Additional configuration for qemu package:
- Save qemu commandline arguments to run qemu directly using 'make qemu-system-run'.

---
 package/qemu/Config.in.host | 7 +++++++
 package/qemu/qemu.mk        | 9 +++++++++
 2 files changed, 16 insertions(+)
package/qemu/Config.in.host +7 -0
index c86768f..8c07e71 100644
@@ -88,4 +88,11 @@ config BR2_PACKAGE_HOST_QEMU_STRIP_BINARY
 
 endif # BR2_PACKAGE_HOST_QEMU_HAS_EMULS
 
+config BR2_PACKAGE_HOST_QEMU_SYSTEM_ARGS
+	string "qemu-system command arguments"
+	depends on BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE
+	help
+	  Arguments to be used for your target host-qemu-system to run
+	  via "make qemu-system-run".
+
 endif # BR2_PACKAGE_HOST_QEMU
package/qemu/qemu.mk +0 -0
index 1910dbd..4de32b9 100644

package/qemu/qemu.mk $(eval $(host-generic-package)) · line 160

Quoted 10 lines
package/qemu/qemu.mk +7 -0
@@ -151,6 +151,15 @@ $(eval $(host-generic-package))
 # variable used by other packages
 QEMU_USER = $(HOST_DIR)/usr/bin/qemu-$(HOST_QEMU_ARCH)
 
+ifeq ($(BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE),y)
+QEMU_SYSTEM = $(HOST_DIR)/usr/bin/qemu-system-$(HOST_QEMU_ARCH)
+
+.PHONY: qemu-system-run
+qemu-system-run:
+	$(QEMU_SYSTEM) $(call qstrip,$(BR2_PACKAGE_HOST_QEMU_SYSTEM_ARGS))
+endif

We feel this is a bit "too special", and doesn't bring a lot of value compared to just having a shell script next to Buildroot. So for now, we prefer to keep this out of Buildroot.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
author
#8 lore raw

PATCH 5/6 vde2: enable building host package

In reply to Simon Maes

In preparation of enabling vde2 support in host-qemu package.

---
 package/vde2/vde2.mk | 1 +
 1 file changed, 1 insertion(+)
package/vde2/vde2.mk +1 -0
index bad758d..13fecd3 100644
@@ -38,3 +38,4 @@ VDE2_CONF_OPTS = \
 VDE2_MAKE = $(MAKE1)
 
 $(eval $(autotools-package))
+$(eval $(host-autotools-package))
Signature · 1 line
2.6.2
#9 lore raw

PATCH 5/6 vde2: enable building host package

Hello,

Quoted 12 lines · Simon Maes

In preparation of enabling vde2 support in host-qemu package.

---
 package/vde2/vde2.mk | 1 +
 1 file changed, 1 insertion(+)
package/vde2/vde2.mk +0 -0
index bad758d..13fecd3 100644

package/vde2/vde2.mk VDE2_CONF_OPTS = \ · line 41

Quoted 4 lines
package/vde2/vde2.mk +1 -0
@@ -38,3 +38,4 @@ VDE2_CONF_OPTS = \
 VDE2_MAKE = $(MAKE1)
 
 $(eval $(autotools-package))
+$(eval $(host-autotools-package))

You forgot to define HOST_VDE2_CONF_OPTS and HOST_VDE2_MAKE, so I've added these and sent the changed version as part of my respin. See
http://patchwork.ozlabs.org/patch/643848/.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
author
#10 lore raw

PATCH 6/6 qemu: add support for vde2

In reply to Simon Maes

Additional configuration for qemu package:
- Enable VDE2 support for qemu

---
 package/qemu/Config.in.host | 8 ++++++++
 package/qemu/qemu.mk        | 5 +++++
 2 files changed, 13 insertions(+)
package/qemu/Config.in.host +8 -0
index 8c07e71..13f13c1 100644
@@ -86,6 +86,14 @@ config BR2_PACKAGE_HOST_QEMU_STRIP_BINARY
 	help
 	  Say 'y' to enable stripping of the QEMU binary.
 
+config BR2_PACKAGE_HOST_QEMU_VDE2
+	bool "Enable VDE2 Support"
+	help
+	  Say 'y' to enable VDE2 build options for QEMU.
+	  VDE2 stands for Virtual Distributed Ethernet and can be
+	  used to create virtual switches to "plug" both physical
+	  and virtual machines in them.
+
 endif # BR2_PACKAGE_HOST_QEMU_HAS_EMULS
 
 config BR2_PACKAGE_HOST_QEMU_SYSTEM_ARGS
package/qemu/qemu.mk +5 -0
index 4de32b9..79f15e1 100644
@@ -123,6 +123,11 @@ ifeq ($(BR2_PACKAGE_HOST_QEMU_STRIP_BINARY),n)
 HOST_QEMU_OPTS += --disable-strip
 endif
 
+ifeq ($(BR2_PACKAGE_HOST_QEMU_VDE2),y)
+HOST_QEMU_OPTS += --enable-vde
+HOST_QEMU_DEPENDENCIES += host-vde2
+endif
+
 endif
 
 define HOST_QEMU_CONFIGURE_CMDS
Signature · 1 line
2.6.2
#11 lore raw

PATCH 6/6 qemu: add support for vde2

Hello,

Quoted 8 lines · Simon Maes

Additional configuration for qemu package:
- Enable VDE2 support for qemu

---
 package/qemu/Config.in.host | 8 ++++++++
 package/qemu/qemu.mk        | 5 +++++
 2 files changed, 13 insertions(+)

I also did a respin of this patch, in a very similar way. See
http://patchwork.ozlabs.org/patch/643850/.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#12 lore raw

PATCH 1/6 qemu: add support for host-qemu-system

In reply to Simon Maes

Hi Simon,

Thanks for working on this! You clearly understood the feedback that Thomas
gave to Gustavo's original patches.

I have a lot of feedback, mainly simplifying things a little.

Quoted 1 line · Simon Maes

Additional package configurations are:

Not very important, but we don't usually indent commit messages like this.
When you do "git log", an additional 4 spaces will be added so then it becomes really deep...

Quoted 4 lines

- Enable system or linux user-land emulation
- Enable SDL frontend and FDT support
- Enable Qemu debug
- Disable stripped binary format

Sounds to me like this could be split up into more patches. But in fact I
think all of the optional things can be removed (i.e. made non-optional).

Quoted 23 lines
---
 package/qemu/Config.in.host | 66 +++++++++++++++++++++++++++++++++++++++++++++
 package/qemu/qemu.mk        | 39 ++++++++++++++++++++++-----
 2 files changed, 99 insertions(+), 6 deletions(-)
package/qemu/Config.in.host +8 -0
index c5c3f05..71f697e 100644
@@ -15,3 +15,69 @@ config BR2_PACKAGE_HOST_QEMU
 	  This option builds a user emulator for your selected architecture.
 
 	  http://www.qemu.org
+
+if BR2_PACKAGE_HOST_QEMU
+
+#
+# Configuration selection
+#
+
+comment "Emulators selection"

package/qemu/Config.in.host config BR2_PACKAGE_HOST_QEMU · line 35

Quoted 10 lines
package/qemu/Config.in.host +10 -0
+
+config BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE
+	bool "Enable systems emulation"
+	depends on !BR2_STATIC_LIBS # dtc
+	select BR2_PACKAGE_HOST_QEMU_FDT
+	help
+	  Say 'y' to build system emulators/virtualisers.
+	  When building the host-qemu package for system emulation,
+	  qemu will be configured to support the Target Architecture,
+	  configured in Buildroot

Why does that second sentence come here? Isn't that just true for all qemu
builds? In fact, something similar is already in the general host-qemu help text.

package/qemu/Config.in.host config BR2_PACKAGE_HOST_QEMU · line 40

Quoted 5 lines
package/qemu/Config.in.host +5 -0
+
+config BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE
+	bool "Enable Linux user-land emulation"
+	help
+	  Say 'y' to build Linux user-land emulators.

Generally we try to stay compatible with existing configurations, so this
should default to y - otherwise, when you have host-qemu selected before this patch, and you do a 'make menuconfig' and just save, you will neither system mode nor user mode selected.

But in fact, it's silly to have neither. For target qemu, we can specify which
targets to build, but for host it's only system or user. And if neither of them is selected, we're actually not going to build anything.

So to avoid that, you can give this:

default y if !BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE

Alternatively, in BR2_PACKAGE_HOST_QEMU itself, you can add

select BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE if !BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE

which makes sure that one of them is always selected.

package/qemu/Config.in.host config BR2_PACKAGE_HOST_QEMU · line 45

Quoted 5 lines
package/qemu/Config.in.host +5 -0
+
+config BR2_PACKAGE_HOST_QEMU_HAS_EMULS
+	def_bool y
+	depends on BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE || \
+		BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE

This should always be true.

package/qemu/Config.in.host config BR2_PACKAGE_HOST_QEMU · line 53

Quoted 8 lines
package/qemu/Config.in.host +8 -0
+
+if BR2_PACKAGE_HOST_QEMU_HAS_EMULS
+
+comment "Frontends"
+
+config BR2_PACKAGE_HOST_QEMU_SDL
+	bool "Enable SDL frontend"
+	select BR2_PACKAGE_SDL

This makes no sense. The target SDL package has nothing to do with host-qemu.
Anyway, there isn't much point in building host-sdl either, because it doesn't have X11 support so most users can't do anything useful with it.

I think we should just rely on system-installed devel packages for SDL and
autodetection by configure. So add to the help text that you need libsdl1.2-dev (or whatever it is you need) to get graphical support.

package/qemu/Config.in.host config BR2_PACKAGE_HOST_QEMU · line 63

Quoted 10 lines
package/qemu/Config.in.host +10 -0
+	help
+	  Say 'y' to enable the SDL frontend, that is, a graphical window
+	  presenting the VM's display.
+
+comment "Misc. features"
+
+config BR2_PACKAGE_HOST_QEMU_FDT
+	bool "Enable FDT"
+	depends on !BR2_STATIC_LIBS # dtc
+	select BR2_PACKAGE_DTC

Again, target dtc has nothing to do with host-qemu. And again, I think it's OK
to always build dtc support in host-qemu.

package/qemu/Config.in.host config BR2_PACKAGE_HOST_QEMU · line 74

Quoted 11 lines
package/qemu/Config.in.host +11 -0
+	help
+	  Say 'y' to have QEMU capable of constructing Device Trees,
+	  and passing them to the VMs.
+
+comment "FDT support needs a toolchain w/ dynamic library"
+	depends on BR2_STATIC_LIBS
+
+config BR2_PACKAGE_HOST_QEMU_DEBUG
+	bool "Enable debug"
+	help
+	  Say 'y' to enable build options for QEMU.

build options? I guess debug options?

package/qemu/Config.in.host config BR2_PACKAGE_HOST_QEMU · line 79

Quoted 5 lines
package/qemu/Config.in.host +5 -0
+
+config BR2_PACKAGE_HOST_QEMU_STRIP_BINARY
+	bool "Enable stripped binary format"
+	help
+	  Say 'y' to enable stripping of the QEMU binary.

I don't see how this is useful for host-qemu.

Quoted 9 lines
package/qemu/Config.in.host +4 -0
+
+endif # BR2_PACKAGE_HOST_QEMU_HAS_EMULS
+
+endif # BR2_PACKAGE_HOST_QEMU
package/qemu/qemu.mk +0 -0
index 522910e..0e99138 100644

package/qemu/qemu.mk QEMU_LICENSE_FILES = COPYING COPYING.LIB · line 21

Quoted 5 lines
package/qemu/qemu.mk +2 -0
@@ -17,6 +17,8 @@ QEMU_LICENSE_FILES = COPYING COPYING.LIB
 # Host-qemu
 
 HOST_QEMU_DEPENDENCIES = host-pkgconf host-python host-zlib host-libglib2 host-pixman
+HOST_QEMU_SITE = $(QEMU_SITE)
+HOST_QEMU_SOURCE = $(QEMU_SOURCE)

This doesn't belong here, it's only relevant when the version of host and
target qemu can be selected independently.

package/qemu/qemu.mk endif · line 67

Quoted 10 lines
package/qemu/qemu.mk +0 -1
 #       BR ARCH         qemu
 #       -------         ----
@@ -61,7 +63,6 @@ endif
 ifeq ($(HOST_QEMU_ARCH),sh4aeb)
 HOST_QEMU_ARCH = sh4eb
 endif
-HOST_QEMU_TARGETS = $(HOST_QEMU_ARCH)-linux-user
 
 ifeq ($(BR2_PACKAGE_HOST_QEMU),y)

Since you're anyway moving things around: this condition (and the system check
immediately below) would be better placed together with the BR_BUILDING check below. And it would be better to do that in a separate patch BTW.

package/qemu/qemu.mk ifneq ($(HOST_QEMU_HOST_SYSTEM_TYPE),Linux) · line 74

Quoted 11 lines
package/qemu/qemu.mk +2 -4
 HOST_QEMU_HOST_SYSTEM_TYPE = $(shell uname -s)
@@ -69,10 +70,12 @@ ifneq ($(HOST_QEMU_HOST_SYSTEM_TYPE),Linux)
 $(error "qemu-user can only be used on Linux hosts")
 endif
 
-# kernel version as major*256 + minor
-HOST_QEMU_HOST_SYSTEM_VERSION = $(shell uname -r | awk -F. '{ print $$1 * 256 + $$2 }')
-HOST_QEMU_TARGET_SYSTEM_VERSION = $(shell echo $(BR2_TOOLCHAIN_HEADERS_AT_LEAST) | awk -F. '{ print $$1 * 256 + $$2 }')
-HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge $(HOST_QEMU_TARGET_SYSTEM_VERSION) && echo OK)
+ifeq ($(BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE),y)
+HOST_QEMU_TARGETS += $(HOST_QEMU_ARCH)-softmmu

Do we need this? Isn't --enable-system enough? Or will it build all arches then?

Why the softmmu version? Shouldn't that depend on BR2_USE_MMU?

package/qemu/qemu.mk HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge $( · line 89

Quoted 11 lines
package/qemu/qemu.mk +4 -0
+HOST_QEMU_OPTS += --enable-system
+else
+HOST_QEMU_OPTS += --disable-system
+endif
 
 #
 # The principle of qemu-user is that it emulates the instructions of
@@ -84,11 +87,34 @@ HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge $(
 # built with kernel headers that are older or the same as the kernel
 # version running on the host machine.
 #

You moved this comment away from the code that it applies to: the version check.

package/qemu/qemu.mk HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge $( · line 98

Quoted 9 lines
package/qemu/qemu.mk +9 -0
+
+ifeq ($(BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE),y)
+HOST_QEMU_TARGETS += $(HOST_QEMU_ARCH)-linux-user
+HOST_QEMU_OPTS += --enable-linux-user
+
+# kernel version as major*256 + minor
+HOST_QEMU_HOST_SYSTEM_VERSION = $(shell uname -r | awk -F. '{ print $$1 * 256 + $$2 }')
+HOST_QEMU_TARGET_SYSTEM_VERSION = $(shell echo $(BR2_TOOLCHAIN_HEADERS_AT_LEAST) | awk -F. '{ print $$1 * 256 + $$2 }')
+HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge $(HOST_QEMU_TARGET_SYSTEM_VERSION) && echo OK)

This bit should also go inside the BR_BUILDING, in a separate patch.

Regards,
Arnout

Quoted 33 lines
package/qemu/qemu.mk +16 -1
+
 ifeq ($(BR_BUILDING),y)
 ifneq ($(HOST_QEMU_COMPARE_VERSION),OK)
 $(error "Refusing to build qemu-user: target Linux version newer than host's.")
 endif
+
+else
+HOST_QEMU_OPTS += --disable-linux-user
+endif
 endif
+
+ifeq ($(BR2_PACKAGE_HOST_QEMU_DEBUG),y)
+HOST_QEMU_OPTS += --enable-debug
+endif
+
+ifeq ($(BR2_PACKAGE_HOST_QEMU_STRIP_BINARY),n)
+HOST_QEMU_OPTS += --disable-strip
+endif
+
 endif
 
 define HOST_QEMU_CONFIGURE_CMDS
@@ -100,7 +126,8 @@ define HOST_QEMU_CONFIGURE_CMDS
 		--host-cc="$(HOSTCC)"                   \
 		--python=$(HOST_DIR)/usr/bin/python2    \
 		--extra-cflags="$(HOST_CFLAGS)"         \
-		--extra-ldflags="$(HOST_LDFLAGS)"
+		--extra-ldflags="$(HOST_LDFLAGS)"       \
+		$(HOST_QEMU_OPTS)
 endef
 
 define HOST_QEMU_BUILD_CMDS
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#13 lore raw

PATCH 1/6 qemu: add support for host-qemu-system

In reply to Simon Maes

Hello,

Quoted 7 lines · Simon Maes

Additional package configurations are:
- Enable system or linux user-land emulation
- Enable SDL frontend and FDT support
- Enable Qemu debug
- Disable stripped binary format

I just respined a new version of this patch, which takes into account Arnout comments, and more. See:

https://patchwork.ozlabs.org/patch/643849/

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com