diff mbox series

[PATCH-for-9.1] hw/i386: Add a config to only build the microvm machine

Message ID 20240326131410.93866-1-philmd@linaro.org
State New
Headers show
Series [PATCH-for-9.1] hw/i386: Add a config to only build the microvm machine | expand

Commit Message

Philippe Mathieu-Daudé March 26, 2024, 1:14 p.m. UTC
Add a config file to build a binary only containing the
microvm machine, inspired by a discussion on the list:
https://lore.kernel.org/qemu-devel/604bf457-23a7-4d06-b59f-a7b46945c626@tls.msk.ru/

As suggested in commit d1d5e9eefd ("configure: allow the
selection of alternate config in the build"), it can be
built using:

  $ ../configure --without-default-features \
                 --target-list=x86_64-softmmu \
                 --with-devices-x86_64=microvm

Inspired-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 configs/devices/x86_64-softmmu/microvm.mak | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 configs/devices/x86_64-softmmu/microvm.mak

Comments

Michael Tokarev March 26, 2024, 3:48 p.m. UTC | #1
26.03.2024 16:14, Philippe Mathieu-Daudé wrote:
> Add a config file to build a binary only containing the
> microvm machine, inspired by a discussion on the list:
> https://lore.kernel.org/qemu-devel/604bf457-23a7-4d06-b59f-a7b46945c626@tls.msk.ru/
> 
> As suggested in commit d1d5e9eefd ("configure: allow the
> selection of alternate config in the build"), it can be
> built using:
> 
>    $ ../configure --without-default-features \
>                   --target-list=x86_64-softmmu \
>                   --with-devices-x86_64=microvm
> 
> Inspired-by: Michael Tokarev <mjt@tls.msk.ru>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   configs/devices/x86_64-softmmu/microvm.mak | 20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)
>   create mode 100644 configs/devices/x86_64-softmmu/microvm.mak

This is not enough.  This step is good already, but it lacks default machine
type selection.  In debian we carry a tiny patch to make microvm the default
machine type or else it crashes at startup not finding "pc" machine or one
of its required devices.

/mjt

> diff --git a/configs/devices/x86_64-softmmu/microvm.mak b/configs/devices/x86_64-softmmu/microvm.mak
> new file mode 100644
> index 0000000000..fe48b5b4a7
> --- /dev/null
> +++ b/configs/devices/x86_64-softmmu/microvm.mak
> @@ -0,0 +1,20 @@
> +# SPDX-FileCopyrightText: 2024 Linaro Ltd.
> +#
> +# Config that only supports the 64-bit microvm machine.
> +# This avoids bringing in any of numerous legacy features from
> +# the legacy machines or the 32bit platform.
> +#
> +
> +CONFIG_MICROVM=y
> +CONFIG_PCI_DEVICES=n
> +CONFIG_SMBIOS=y
> +CONFIG_SMBIOS_LEGACY=n
> +CONFIG_VIRTIO_BALLOON=y
> +CONFIG_VIRTIO_BLK=y
> +CONFIG_VIRTIO_CRYPTO=y
> +CONFIG_VIRTIO_GPU=y
> +CONFIG_VIRTIO_INPUT=y
> +CONFIG_VIRTIO_NET=y
> +CONFIG_VIRTIO_RNG=y
> +CONFIG_VIRTIO_SCSI=y
> +CONFIG_VIRTIO_SERIAL=y
Philippe Mathieu-Daudé March 26, 2024, 3:58 p.m. UTC | #2
On 26/3/24 16:48, Michael Tokarev wrote:
> 26.03.2024 16:14, Philippe Mathieu-Daudé wrote:
>> Add a config file to build a binary only containing the
>> microvm machine, inspired by a discussion on the list:
>> https://lore.kernel.org/qemu-devel/604bf457-23a7-4d06-b59f-a7b46945c626@tls.msk.ru/
>>
>> As suggested in commit d1d5e9eefd ("configure: allow the
>> selection of alternate config in the build"), it can be
>> built using:
>>
>>    $ ../configure --without-default-features \
>>                   --target-list=x86_64-softmmu \
>>                   --with-devices-x86_64=microvm
>>
>> Inspired-by: Michael Tokarev <mjt@tls.msk.ru>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   configs/devices/x86_64-softmmu/microvm.mak | 20 ++++++++++++++++++++
>>   1 file changed, 20 insertions(+)
>>   create mode 100644 configs/devices/x86_64-softmmu/microvm.mak
> 
> This is not enough.  This step is good already, but it lacks default 
> machine
> type selection.  In debian we carry a tiny patch to make microvm the 
> default
> machine type or else it crashes at startup not finding "pc" machine or one
> of its required devices.

No crash here, what is your base commit?

./qemu-system-x86_64
qemu-system-x86_64: No machine specified, and there is no default
Use -machine help to list supported machines
$ ./qemu-system-x86_64 -M help
Supported machines are:
microvm              microvm (i386)
none                 empty machine
$

> 
> /mjt
Michael Tokarev March 26, 2024, 4:01 p.m. UTC | #3
26.03.2024 18:58, Philippe Mathieu-Daudé:

>> This is not enough.  This step is good already, but it lacks default machine
>> type selection.  In debian we carry a tiny patch to make microvm the default
>> machine type or else it crashes at startup not finding "pc" machine or one
>> of its required devices.
> 
> No crash here, what is your base commit?
> 
> ./qemu-system-x86_64
> qemu-system-x86_64: No machine specified, and there is no default
> Use -machine help to list supported machines

Well, this is definitely better than a crash.  I haven't looked at that for
a long time, initially it just crashed.

Still, this current behavior isn't nice, - in my opinion it should select
microvm by default in this case.

https://salsa.debian.org/qemu-team/qemu/-/blob/master/debian/patches/microvm-default-machine-type.patch
is the outline (from more than 4 years ago), - it's a hack but shows what
I mean.

/mjt
Peter Maydell March 26, 2024, 4:26 p.m. UTC | #4
On Tue, 26 Mar 2024 at 16:03, Michael Tokarev <mjt@tls.msk.ru> wrote:
>
> 26.03.2024 18:58, Philippe Mathieu-Daudé:
>
> >> This is not enough.  This step is good already, but it lacks default machine
> >> type selection.  In debian we carry a tiny patch to make microvm the default
> >> machine type or else it crashes at startup not finding "pc" machine or one
> >> of its required devices.
> >
> > No crash here, what is your base commit?
> >
> > ./qemu-system-x86_64
> > qemu-system-x86_64: No machine specified, and there is no default
> > Use -machine help to list supported machines
>
> Well, this is definitely better than a crash.  I haven't looked at that for
> a long time, initially it just crashed.
>
> Still, this current behavior isn't nice, - in my opinion it should select
> microvm by default in this case.

I disagree. We shouldn't present users with a situation
where qemu-system-x86_64 binary A has a default of "pc" and
qemu-system-x86_64 binary B has a default of "microvm", just
because of the way they happened to be compiled. That seems
liable to lead to confusion. (In general I think that default
machine types are not a great piece of UI which we mostly have
for historical reasons and because all x86 machines look
very similar.)

-- PMM
Igor Mammedov March 26, 2024, 4:32 p.m. UTC | #5
On Tue, 26 Mar 2024 19:01:50 +0300
Michael Tokarev <mjt@tls.msk.ru> wrote:

> 26.03.2024 18:58, Philippe Mathieu-Daudé:
> 
> >> This is not enough.  This step is good already, but it lacks default machine
> >> type selection.  In debian we carry a tiny patch to make microvm the default
> >> machine type or else it crashes at startup not finding "pc" machine or one
> >> of its required devices.  
> > 
> > No crash here, what is your base commit?
> > 
> > ./qemu-system-x86_64
> > qemu-system-x86_64: No machine specified, and there is no default
> > Use -machine help to list supported machines  
> 
> Well, this is definitely better than a crash.  I haven't looked at that for
> a long time, initially it just crashed.
> 
> Still, this current behavior isn't nice, - in my opinion it should select
> microvm by default in this case.

In arm we also don't have default => consensus was to let user pick poison explicitly.
Would've don the same for x86 modulo that would break user's scripts
expecting default machine.

If it's something new like microvm, I wouldn't set default machine
that way there won't expectations and won't be a discussion in future
when new shiny not-microvm is around and one want's to ship both
(like we had with pc vs q35).


> https://salsa.debian.org/qemu-team/qemu/-/blob/master/debian/patches/microvm-default-machine-type.patch
> is the outline (from more than 4 years ago), - it's a hack but shows what
> I mean.
> 
> /mjt
>
diff mbox series

Patch

diff --git a/configs/devices/x86_64-softmmu/microvm.mak b/configs/devices/x86_64-softmmu/microvm.mak
new file mode 100644
index 0000000000..fe48b5b4a7
--- /dev/null
+++ b/configs/devices/x86_64-softmmu/microvm.mak
@@ -0,0 +1,20 @@ 
+# SPDX-FileCopyrightText: 2024 Linaro Ltd.
+#
+# Config that only supports the 64-bit microvm machine.
+# This avoids bringing in any of numerous legacy features from
+# the legacy machines or the 32bit platform.
+#
+
+CONFIG_MICROVM=y
+CONFIG_PCI_DEVICES=n
+CONFIG_SMBIOS=y
+CONFIG_SMBIOS_LEGACY=n
+CONFIG_VIRTIO_BALLOON=y
+CONFIG_VIRTIO_BLK=y
+CONFIG_VIRTIO_CRYPTO=y
+CONFIG_VIRTIO_GPU=y
+CONFIG_VIRTIO_INPUT=y
+CONFIG_VIRTIO_NET=y
+CONFIG_VIRTIO_RNG=y
+CONFIG_VIRTIO_SCSI=y
+CONFIG_VIRTIO_SERIAL=y