Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic Kconfig support for lima-guestagent #1790

Merged
merged 4 commits into from
Sep 21, 2023

Conversation

afbjorklund
Copy link
Member

@afbjorklund afbjorklund commented Sep 13, 2023

Make it possible to choose which lima-guestagent binaries to build...

This makes it possible to have optional binaries, such as FreeBSD etc.

There is support for "make config":

*
* Lima
*
guestagent OS: Linux (GUESTAGENT_OS_LINUX) [Y/n/?] 
guestagent Arch: x86_64 (GUESTAGENT_ARCH_X8664) [Y/n/?] 
guestagent Arch: aarch64 (GUESTAGENT_ARCH_AARCH64) [Y/n/?] 
guestagent Arch: armv7l (GUESTAGENT_ARCH_ARMV7L) [Y/n/?] 
guestagent Arch: riscv64 (GUESTAGENT_ARCH_RISCV64) [Y/n/?] 
#
# No change to .config
#

And also for "make menuconfig":

lima-kconfig-menuconfig

It is possible to just edit the .configfile (marked DO NOT EDIT).

Regenerating it requires one of the standalone Kconfig programs:

See also: https://www.kernel.org/doc/html/next/kbuild/kconfig-language.html

Makefile Outdated
@@ -7,6 +7,9 @@ TAR ?= tar
ZIP ?= zip
PLANTUML ?= plantuml # may also be "java -jar plantuml.jar" if installed elsewhere

KCONFIG_CONF ?= conf
KCONFIG_MCONF ?= mconf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commands are rarely available on macOS, so I don't think we should depend on this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative would be compile them from source in the project, which I would like to avoid.
There is a good rationale in https://github.com/WangNan0/kbuild-standalone (or use python?)

It is also only needed, if making major changes to the Kconfig file itself. Otherwise, edit .config.
The format should be quite straight-forward, even if one needs to comment out - not set as 'n'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should just adopt vi .config or ./configure --enable-XXX

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding support for autoconf would require more infrastructure and generate more boilerplate, imho

@afbjorklund
Copy link
Member Author

We could remove the scary "DO NOT EDIT" comment, for instance python's alldefconfig et al does not add it.

@@ -1,9 +1,5 @@
-#
-# Automatically generated file; DO NOT EDIT.
-# Lima
-#
 CONFIG_GUESTAGENT_OS_LINUX=y
 CONFIG_GUESTAGENT_ARCH_X8664=y
 CONFIG_GUESTAGENT_ARCH_AARCH64=y
 CONFIG_GUESTAGENT_ARCH_ARMV7L=y
 CONFIG_GUESTAGENT_ARCH_RISCV64=y

It also has an alternative guiconfig (in Tkinter), which might be cross-platform enough (unlike gconf and qconf)

lima-kconfig-guiconfig

@afbjorklund
Copy link
Member Author

afbjorklund commented Sep 13, 2023

Making a homebrew "formula" for the kbuild-standalone programs could be a good idea?

https://github.com/WangNan0/kbuild-standalone (which is GPLv2 licensed, like the kernel)

  • kbuild-conf

  • kbuild-mconf


EDIT: Apparently they get a prefix added to them, when installed globally.

Just like the "kconfig-conf" and "kconfig-mconf", from kconfig-frontends...

But it is probably easier to just pip3 install --user kconfiglib, to start with.

So changed the default to use those programs, instead of the ones in C...

@afbjorklund
Copy link
Member Author

Changed it to look for all three systems, and to allow editing the .config file and setting the value to n as well.

Makefile Outdated Show resolved Hide resolved
help:
@echo ' binaries - Build all binaries'
@echo ' manpages - Build manual pages'

exe: _output/bin/limactl$(exe)

.PHONY: minimal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make minimal should now generate a new .config and run make binary ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not everything is configurable, and there is no mechanism for "host arch"

.config Outdated Show resolved Hide resolved
@afbjorklund
Copy link
Member Author

afbjorklund commented Sep 14, 2023

I added some (very) basic help text, mostly because it was mentioned in the output and interface.

export KCONFIG_CONF=kconfig-conf
export KCONFIG_MCONF=kconfig-mconf

*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

And the guiconfig/gconf/qconf was complaining, when there was a config option without a help.

README.md Outdated Show resolved Hide resolved
config.default Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fear this file to be misinterpreted as the default lima YAML config.

Can we just generate the default config with heredoc?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or put this file to somewhere like Makefile.d/ or Kconfig.d/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed it to config.mk, hopefully there will be no confusion.

It is possible to edit this file (if not using kconfig tools).
The main difference is that it is checked into the repository.
To make user-specific config, it is better to edit .config.
The default make target will copy config.mk, if it is missing.

@afbjorklund afbjorklund marked this pull request as draft September 15, 2023 06:12
@afbjorklund
Copy link
Member Author

afbjorklund commented Sep 15, 2023

It is also a problem that the python library does not implement oldaskconfig, the default mode.

@afbjorklund
Copy link
Member Author

I updated the kconfig-frontends from v4.11 to v4.19, just in case. The old repo seemed missing?

And the debian packaging only had an import of the generated files, not the original git sources.

https://github.com/afbjorklund/kconfig-frontends

http://ymorin.is-a-geek.org/git/kconfig-frontends

2017-05-03: 4.11.0.1 has been released
2013-11-09: 3.12.0.0 has been released
2012-03-19: first release ever: 3.3.0-1 has been released
2012-01-25: this project announced

AkihiroSuda
AkihiroSuda previously approved these changes Sep 15, 2023
@AkihiroSuda AkihiroSuda added this to the v0.18.0 milestone Sep 15, 2023
@AkihiroSuda AkihiroSuda requested a review from a team September 15, 2023 18:39
README.md Outdated Show resolved Hide resolved
Refactor the list of helpers and lima-guestagent binaries.

This makes it easier to make them into optional, later on.

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Make it possible to configure which guestagents to build.

Regenerating config file requires kconfig or kbuild tools.

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>

This requires kconfig tools installed, it is also possible to edit `.config`.
The default configuration can be found in the file `config.mk` (make syntax).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraphs should be inside ## Kconfig tools

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was for the user that doesn't have any tools, but edits the config as text

This requires kconfig tools installed, it is also possible to edit `.config`.
The default configuration can be found in the file `config.mk` (make syntax).

## Kconfig tools
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Kconfig tools
## Kconfig tools (optional)

@AkihiroSuda AkihiroSuda merged commit 2a1feb2 into lima-vm:master Sep 21, 2023
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants