Skip to contentSkip to conversation

package/qemu: allow building only the guest agent

PATCH Applied [email protected] 3 participants 5 messages Mar 22, 2023 – May 13, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/qemu: allow building only the guest agent

From: Carlos Santos <[email protected]>

Most of the tools are useful only on virtualization hosts. After the upgrade to QEMU 7.2.0, it is possible to build only quemu-ga, which makes more sense when we build guest VM images.

Also do not build the other tools by default if none of the emulators is selected, since the user does not necessarily wants them. Ideally, it should not be possible to select qemu without selecting at least one of the subcomponents but it is hard to guess what the user wants.

---
NOTE

This was also possible on older QEMU versions, but required a trick to force compiling the code required to link qemu-ga without building the other tools:

./configure --enable-system --target-list="" --disable-tools --enable-guest-agent

---
 package/qemu/Config.in | 8 +++++++-
 package/qemu/qemu.mk   | 6 ++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
package/qemu/Config.in +7 -1
index a446c0cf68..6a9b08648d 100644
@@ -26,7 +26,6 @@ menuconfig BR2_PACKAGE_QEMU
 	depends on BR2_USE_MMU # fork()
 	select BR2_PACKAGE_LIBGLIB2
 	select BR2_PACKAGE_ZLIB
-	select BR2_PACKAGE_QEMU_TOOLS if !BR2_PACKAGE_QEMU_SYSTEM && !BR2_PACKAGE_QEMU_LINUX_USER
 	help
 	  QEMU is a generic and open source machine emulator and
 	  virtualizer.
@@ -358,4 +357,11 @@ 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"
+	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".
+
 endif # BR2_PACKAGE_QEMU
package/qemu/qemu.mk +6 -0
index 3cbeffe213..4194670bb0 100644
@@ -165,6 +165,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
#1 lore raw

package/qemu/Config.in menuconfig BR2_PACKAGE_QEMU · line 29

Quoted 1 line · On Wed, 22 Mar 2023 20:15:11 -0300 [email protected] wrote:
package/qemu/Config.in +0 -1
-	select BR2_PACKAGE_QEMU_TOOLS if !BR2_PACKAGE_QEMU_SYSTEM && !BR2_PACKAGE_QEMU_LINUX_USER

Is the build working OK if neither the tools, nor qemu-system, nor qemu-user nor qemu-qa are enabled?

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
#2 lore raw
Quoted 9 lines · Thomas Petazzoni
Quoted 1 line · On Wed, 22 Mar 2023 20:15:11 -0300 [email protected] wrote:

- select BR2_PACKAGE_QEMU_TOOLS if !BR2_PACKAGE_QEMU_SYSTEM && !BR2_PACKAGE_QEMU_LINUX_USER

Is the build working OK if neither the tools, nor qemu-system, nor qemu-user nor qemu-qa are enabled?

Quoted 7 lines

Thanks!

Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com

Yes. It just does not install anything useful:

$ cat build/qemu-7.2.0/.files-list.txt
qemu,./usr/share/qemu/keymaps/sl
qemu,./usr/share/qemu/keymaps/sv
qemu,./usr/include/qemu-plugin.h
qemu,./usr/share/qemu/keymaps/ar
qemu,./usr/share/qemu/keymaps/bepo
qemu,./usr/share/qemu/keymaps/cz
qemu,./usr/share/qemu/keymaps/da
qemu,./usr/share/qemu/keymaps/de
qemu,./usr/share/qemu/keymaps/de-ch
qemu,./usr/share/qemu/keymaps/en-gb
qemu,./usr/share/qemu/keymaps/en-us
qemu,./usr/share/qemu/keymaps/es
qemu,./usr/share/qemu/keymaps/et
qemu,./usr/share/qemu/keymaps/fi
qemu,./usr/share/qemu/keymaps/fo
qemu,./usr/share/qemu/keymaps/fr
qemu,./usr/share/qemu/keymaps/fr-be
qemu,./usr/share/qemu/keymaps/fr-ca
qemu,./usr/share/qemu/keymaps/fr-ch
qemu,./usr/share/qemu/keymaps/hr
qemu,./usr/share/qemu/keymaps/hu
qemu,./usr/share/qemu/keymaps/is
qemu,./usr/share/qemu/keymaps/it
qemu,./usr/share/qemu/keymaps/ja
qemu,./usr/share/qemu/keymaps/lv
qemu,./usr/share/qemu/keymaps/lt
qemu,./usr/share/qemu/keymaps/mk
qemu,./usr/share/qemu/keymaps/nl
qemu,./usr/share/qemu/keymaps/no
qemu,./usr/share/qemu/keymaps/pl
qemu,./usr/share/qemu/keymaps/pt
qemu,./usr/share/qemu/keymaps/pt-br
qemu,./usr/share/qemu/keymaps/ru
qemu,./usr/share/qemu/keymaps/th
qemu,./usr/share/qemu/trace-events-all
qemu,./usr/share/qemu/keymaps/tr

The keymaps should not be installed if no qemu-system is built. I already sent a patch upstream attempting to fix the problem but the problem is still there:

https://lists.gnu.org/archive/html/qemu-devel/2023-01/msg00084.html

I also have a patch to install trace-events-all only if necessary. Unfortunately, making these changes happen in qemu takes a long time.

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

Hello,

Quoted 1 line · On Fri, 24 Mar 2023 22:14:18 -0300 Carlos Santos <[email protected]> wrote:

Yes. It just does not install anything useful:

OK. As long as it builds, that's fine :-)

Quoted 8 lines

The keymaps should not be installed if no qemu-system is built. I already sent a patch upstream attempting to fix the problem but the problem is still there:

https://lists.gnu.org/archive/html/qemu-devel/2023-01/msg00084.html

I also have a patch to install trace-events-all only if necessary. Unfortunately, making these changes happen in qemu takes a long time.

Thanks for this work, definitely useful!

Best regards,

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
#4 lore raw
In reply to [email protected]

Carlos, All,

On 2023-03-22 20:15 -0300, [email protected] spake thusly:

Quoted 6 lines

From: Carlos Santos <[email protected]>

Most of the tools are useful only on virtualization hosts. After the upgrade to QEMU 7.2.0, it is possible to build only quemu-ga, which makes more sense when we build guest VM images.

Quoted 6 lines

Also do not build the other tools by default if none of the emulators is selected, since the user does not necessarily wants them. Ideally, it should not be possible to select qemu without selecting at least one of the subcomponents but it is hard to guess what the user wants.

I am not very happy that this means we can end up with a cconfiguration where nothing (meaningful) is installed, but fixing this becomes less obvious...

So be it...

Applied to master, thanks.

Regards,
Yann E. MORIN.

Quoted 61 lines

---
NOTE

This was also possible on older QEMU versions, but required a trick to force compiling the code required to link qemu-ga without building the other tools:

   ./configure --enable-system --target-list="" --disable-tools --enable-guest-agent
---
 package/qemu/Config.in | 8 +++++++-
 package/qemu/qemu.mk   | 6 ++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
package/qemu/Config.in +7 -1
index a446c0cf68..6a9b08648d 100644
@@ -26,7 +26,6 @@ menuconfig BR2_PACKAGE_QEMU
 	depends on BR2_USE_MMU # fork()
 	select BR2_PACKAGE_LIBGLIB2
 	select BR2_PACKAGE_ZLIB
-	select BR2_PACKAGE_QEMU_TOOLS if !BR2_PACKAGE_QEMU_SYSTEM && !BR2_PACKAGE_QEMU_LINUX_USER
 	help
 	  QEMU is a generic and open source machine emulator and
 	  virtualizer.
@@ -358,4 +357,11 @@ 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"
+	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".
+
 endif # BR2_PACKAGE_QEMU
package/qemu/qemu.mk +6 -0
index 3cbeffe213..4194670bb0 100644
@@ -165,6 +165,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
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot