Skip to contentSkip to conversation

package/qemu: add option to enable guest agent

PATCH In review [email protected] 3 participants 8 messages Nov 4, 2022 – Nov 5, 2022

lore
Share & tools
lore
#0 lore raw

cover package/qemu: add option to enable guest agent

From: Carlos Santos <[email protected]>

Before doing it, fix two small erros in the configuration menu that can lead to build failures.

Carlos Santos (3):
package/qemu: make "custom targets" config depend on !BR2_STATIC_LIBS package/qemu: select FDT for custom targets too package/qemu: add option to enable guest agent

 package/qemu/Config.in | 18 +++++++++++++++++-
 package/qemu/qemu.mk   |  6 ++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
Signature · 6 lines
2.31.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 1/3 package/qemu: make "custom targets" config depend on !BR2_STATIC_LIBS

From: Carlos Santos <[email protected]>

Custom targets selects system and Linux user-land emulation, which in their turn require shared libraries.

---
 package/qemu/Config.in | 1 +
 1 file changed, 1 insertion(+)
package/qemu/Config.in +1 -0
index 15d6c7d6b5..8b8a999885 100644
@@ -51,6 +51,7 @@ comment "Emulators selection"
 
 config BR2_PACKAGE_QEMU_CUSTOM_TARGETS
 	string "Enable specific targets"
+	depends on !BR2_STATIC_LIBS # dtc
 	help
 	  Enter here the list of QEMU targets you want to build. For
 	  example:
Signature · 6 lines
2.31.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [PATCH 1/3] package/qemu: make "custom targets" config depend on !BR2_STATIC_LIBS

Hello Carlos,

Quoted 6 lines · On Fri, 4 Nov 2022 20:57:25 -0300 [email protected] wrote:

From: Carlos Santos <[email protected]>

Custom targets selects system and Linux user-land emulation, which in their turn require shared libraries.

Could you clarify which configuration fails to build?

package/qemu/Config.in comment "Emulators selection" · line 54

Quoted 3 lines

config BR2_PACKAGE_QEMU_CUSTOM_TARGETS

package/qemu/Config.in +1 -0
 	string "Enable specific targets"
+	depends on !BR2_STATIC_LIBS # dtc

What is the relationship with DTC here?

Also, when we have a !BR2_STATIC_LIBS dependency, we normally add a Config.in comment:

comment "specific targets need a toolchain w/ shared library"
depends on BR2_STATIC_LIBS

But really the most important thing is to get more details to understand better the problem.

Thanks!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

PATCH 2/3 package/qemu: select FDT for custom targets too

In reply to [email protected]

From: Carlos Santos <[email protected]>

Custom targets selects system and Linux user-land emulation, which in their turn require FDT. Move the BR2_PACKAGE_QEMU_FDT selection to the BR2_PACKAGE_QEMU_HAS_EMULS hidden boolean, to cover all cases.

---
 package/qemu/Config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/qemu/Config.in +1 -1
index 8b8a999885..9e0cbd4acf 100644
@@ -95,7 +95,6 @@ comment "... or you can select emulator families to enable, below:"
 config BR2_PACKAGE_QEMU_SYSTEM
 	bool "Enable all systems emulation"
 	depends on !BR2_STATIC_LIBS # dtc
-	select BR2_PACKAGE_QEMU_FDT
 	help
 	  Say 'y' to build all system emulators/virtualisers that QEMU
 	  supports.
@@ -121,6 +120,7 @@ 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 != ""
+	select BR2_PACKAGE_QEMU_FDT
 
 if BR2_PACKAGE_QEMU_HAS_EMULS
 
Signature · 6 lines
2.31.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

Re: [Buildroot] [PATCH 2/3] package/qemu: select FDT for custom targets too

Am Fri, 4 Nov 2022 20:57:26 -0300
schrieb [email protected]:

Quoted 24 lines

From: Carlos Santos <[email protected]>

Custom targets selects system and Linux user-land emulation, which in their turn require FDT. Move the BR2_PACKAGE_QEMU_FDT selection to the BR2_PACKAGE_QEMU_HAS_EMULS hidden boolean, to cover all cases.

---
 package/qemu/Config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/qemu/Config.in +0 -1
index 8b8a999885..9e0cbd4acf 100644
@@ -95,7 +95,6 @@ comment "... or you can select emulator families to enable, below:"
 config BR2_PACKAGE_QEMU_SYSTEM
 	bool "Enable all systems emulation"
 	depends on !BR2_STATIC_LIBS # dtc
-	select BR2_PACKAGE_QEMU_FDT
 	help
 	  Say 'y' to build all system emulators/virtualisers that QEMU
 	  supports.

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

Quoted 4 lines
package/qemu/Config.in +1 -0
@@ -121,6 +120,7 @@ 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 != ""
+	select BR2_PACKAGE_QEMU_FDT

Technically, I think you don't need FDT if you are only compiling the linux-user targets ... so maybe it would be better to add this to the BR2_PACKAGE_QEMU_CUSTOM_TARGETS switch instead?

Thomas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#5 lore raw

Re: [Buildroot] [PATCH 2/3] package/qemu: select FDT for custom targets too

Quoted 37 lines · Thomas Huth

Am Fri, 4 Nov 2022 20:57:26 -0300
schrieb [email protected]:

Quoted 24 lines

From: Carlos Santos <[email protected]>

Custom targets selects system and Linux user-land emulation, which in their turn require FDT. Move the BR2_PACKAGE_QEMU_FDT selection to the BR2_PACKAGE_QEMU_HAS_EMULS hidden boolean, to cover all cases.

---
 package/qemu/Config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/qemu/Config.in +0 -1
index 8b8a999885..9e0cbd4acf 100644
@@ -95,7 +95,6 @@ comment "... or you can select emulator families to enable, below:"
 config BR2_PACKAGE_QEMU_SYSTEM
      bool "Enable all systems emulation"
      depends on !BR2_STATIC_LIBS # dtc
-     select BR2_PACKAGE_QEMU_FDT
      help
        Say 'y' to build all system emulators/virtualisers that QEMU
        supports.

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

Quoted 4 lines
package/qemu/Config.in +1 -0
@@ -121,6 +120,7 @@ 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 != ""
+     select BR2_PACKAGE_QEMU_FDT

Technically, I think you don't need FDT if you are only compiling the linux-user targets ... so maybe it would be better to add this to the BR2_PACKAGE_QEMU_CUSTOM_TARGETS switch instead?

Quoted 1 line

Thomas

BR2_PACKAGE_QEMU_CUSTOM_TARGETS is a string, so adding a "select BR2_PACKAGE_QEMU_FDT" does not have any effect.

A better solution for the case in which only linux-user targets are selected requires a more complex approach. I will submit a separate patch for this purpose. Meanwhile, let's put this series on hold.

Signature · 5 lines
Carlos Santos <[email protected]>
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#6 lore raw

Re: [Buildroot] [PATCH 2/3] package/qemu: select FDT for custom targets too

Quoted 6 lines · On Sat, 5 Nov 2022 17:23:53 -0300 Carlos Santos <[email protected]> wrote:

BR2_PACKAGE_QEMU_CUSTOM_TARGETS is a string, so adding a "select BR2_PACKAGE_QEMU_FDT" does not have any effect.

A better solution for the case in which only linux-user targets are selected requires a more complex approach. I will submit a separate patch for this purpose. Meanwhile, let's put this series on hold.

Hm, I think I start to understand the issue, and with the current organization of the Config.in options in package/qemu/Config.in, it's going to be difficult to fix in a correct way.

For example, it looks like the linux-user mode emulation doesn't work with the musl C library:

config BR2_PACKAGE_QEMU_LINUX_USER
bool "Enable all Linux user-land emulation" # Incompatible "struct sigevent" definition on musl depends on !BR2_TOOLCHAIN_USES_MUSL

So, it means that BR2_PACKAGE_QEMU_CUSTOM_TARGETS="i386-linux-user" will in fact fail to build with a musl toolchain...

I only sane way to address this I believe would be to remove BR2_PACKAGE_QEMU_CUSTOM_TARGETS entirely, and instead have BR2_PACKAGE_QEMU_SYSTEM_TARGETS and BR2_PACKAGE_QEMU_LINUX_USER_TARGETS, which would only be accessible when BR2_PACKAGE_QEMU_SYSTEM or BR2_PACKAGE_QEMU_LINUX_USER respectively are enabled. When BR2_PACKAGE_QEMU_SYSTEM_TARGETS is empty, all system emulation targets are built, otherwise only the specified ones are built. Ditto for the user emulation targets.

Obviously as usual, the main drawback is that is breaks backward compatibility with existing configurations...

The other approach, which you took, is to assume for the "worst", and assume that when BR2_PACKAGE_QEMU_CUSTOM_TARGETS != "", we might build system or user emulation targets, and therefore this option needs to have the combination of the dependencies of the system and user emulation options.... which would mean disabling this option with musl toolchains, for example.

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#7 lore raw

PATCH 3/3 package/qemu: add option to enable guest agent

In reply to [email protected]

From: Carlos Santos <[email protected]>

It requires --enable-system or --enable-tools to be built, so add a hidden boolean, BR2_PACKAGE_QEMU_HAS_SYSTEM_OR_TOOLS, to control it.

---
 package/qemu/Config.in | 15 +++++++++++++++
 package/qemu/qemu.mk   |  6 ++++++
 2 files changed, 21 insertions(+)
package/qemu/Config.in +15 -0
index 9e0cbd4acf..dd8b3d3491 100644
@@ -122,6 +122,10 @@ config BR2_PACKAGE_QEMU_HAS_EMULS
 	depends on BR2_PACKAGE_QEMU_SYSTEM || BR2_PACKAGE_QEMU_LINUX_USER || BR2_PACKAGE_QEMU_CUSTOM_TARGETS != ""
 	select BR2_PACKAGE_QEMU_FDT
 
+config BR2_PACKAGE_QEMU_HAS_SYSTEM_OR_TOOLS
+	def_bool y
+	depends on BR2_PACKAGE_QEMU_SYSTEM || BR2_PACKAGE_QEMU_CUSTOM_TARGETS != "" || BR2_PACKAGE_QEMU_TOOLS
+
 if BR2_PACKAGE_QEMU_HAS_EMULS
 
 comment "Frontends"
@@ -158,4 +162,15 @@ config BR2_PACKAGE_QEMU_TOOLS
 	  Say 'y' here to include tools packaged with QEMU
 	  (e.g. qemu-img).
 
+config BR2_PACKAGE_QEMU_GUEST_AGENT
+	bool "Enable guest agent"
+	depends on BR2_PACKAGE_QEMU_HAS_SYSTEM_OR_TOOLS
+	help
+	  Say 'y' here to include an agent to run on guests, which
+	  communicates with the host over a virtio-serial channel
+	  named "org.qemu.guest_agent.0".
+
+comment "Guest agent needs systems emulation or tools"
+	depends on !BR2_PACKAGE_QEMU_HAS_SYSTEM_OR_TOOLS
+
 endif # BR2_PACKAGE_QEMU
package/qemu/qemu.mk +6 -0
index a991d49993..d9bdfe0e84 100644
@@ -90,6 +90,12 @@ else
 QEMU_OPTS += --disable-tools
 endif
 
+ifeq ($(BR2_PACKAGE_QEMU_GUEST_AGENT),y)
+QEMU_OPTS += --enable-guest-agent
+else
+QEMU_OPTS += --disable-guest-agent
+endif
+
 ifeq ($(BR2_PACKAGE_LIBFUSE3),y)
 QEMU_OPTS += --enable-fuse --enable-fuse-lseek
 QEMU_DEPENDENCIES += libfuse3
Signature · 6 lines
2.31.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot