Build fixes for minimal microvm
cover Build fixes for minimal microvm
Some build fixes for building a minmal qemu for microvm
cc -m64 @qemu-system-x86_64.rsp
ld: libqemu-x86_64-softmmu.a.p/target_i386_kvm_kvm.c.o: in function `hyperv_init_vcpu':
target/i386/kvm/kvm.c:1757:(.text+0x5d83): undefined reference to `hyperv_is_synic_enabled'
ld: libqemu-x86_64-softmmu.a.p/hw_i386_x86-common.c.o: in function `x86_bios_rom_reload':
hw/i386/x86-common.c:1104:(.text+0x240d): undefined reference to `x86_firmware_configure'
collect2: error: ld returned 1 exit status
The build is done with the devices file:
CONFIG_PCI_DEVICES=nCONFIG_MICROVM=yCONFIG_VIRTIO_BLK=yCONFIG_VIRTIO_SERIAL=yCONFIG_VIRTIO_INPUT=yCONFIG_VIRTIO_INPUT_HOST=yCONFIG_VHOST_USER_INPUT=yCONFIG_VIRTIO_NET=yCONFIG_VIRTIO_SCSI=yCONFIG_VIRTIO_RNG=yCONFIG_VIRTIO_CRYPTO=yCONFIG_VIRTIO_BALLOON=yCONFIG_VIRTIO_GPU=yCONFIG_VHOST_USER_GPU=y
and with these confiure options:
../../configure ${common_configure_opts} \
--without-default-features \
--target-list=x86_64-softmmu --enable-kvm --disable-tcg \
--enable-pixman --enable-vnc \
--enable-virtfs \
--enable-linux-aio --enable-linux-io-uring \
--enable-numa \
--enable-attr \
--enable-coroutine-pool \
--audio-drv-list="" \
--without-default-devices \
--with-devices-x86_64=microvm \
--enable-vhost-kernel --enable-vhost-net \
--enable-vhost-vdpa \
--enable-vhost-user --enable-vhost-user-blk-server \
--enable-vhost-crypto \
--enable-seccompAni Sinha (2):
i386/pc_sysfw: stub out x86_firmware_configure
i386/hyperv: add stubs for synic enablement
hw/i386/pc_sysfw_ovmf-stubs.c | 5 +++++ target/i386/kvm/hyperv-stub.c | 5 +++++ target/i386/kvm/hyperv.c | 9 +++++++++ target/i386/kvm/hyperv.h | 1 + target/i386/kvm/kvm.c | 12 +++++------- 5 files changed, 25 insertions(+), 7 deletions(-)
Signature · 1 line
2.42.0
PATCH 1/2 i386/pc_sysfw: stub out x86_firmware_configure
x86_firmware_configure requires ovmf support. Add a stub for this function call for cases where OVMF is not supported.
--- hw/i386/pc_sysfw_ovmf-stubs.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/i386/pc_sysfw_ovmf-stubs.c +5 -0
@@ -24,3 +24,8 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size) {g_assert_not_reached (); } + +void x86_firmware_configure (hwaddr gpa,void *ptr,int size) +{ +g_assert_not_reached (); +}
Signature · 1 line
2.42.0
Re: [PATCH for-11.0 1/2] i386/pc_sysfw: stub out x86_firmware_configure
Quoted 18 lines · Ani Sinha
x86_firmware_configurerequires ovmf support. Add a stub for this function call for cases where OVMF is not supported.Reported-by Michael Tokarev <[email protected]>Signed-off-by Ani Sinha <[email protected]>---
hw/i386/pc_sysfw_ovmf-stubs.c| 5 +++++1 file changed, 5 insertions(+)hw/i386/pc_sysfw_ovmf-stubs.c +0
-0
hw/i386/pc_sysfw_ovmf-stubs.c void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size) · line 31
Quoted 8 lines
hw/i386/pc_sysfw_ovmf-stubs.c +5
-0@@ -24,3 +24,8 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size) {g_assert_not_reached (); } + +void x86_firmware_configure (hwaddr gpa,void *ptr,int size) +{ +g_assert_not_reached (); +}
This change alone won’t work for the CONFIG_PC case. I need to move x86_firmware_configure() to pc_sysfw_ovmf.c Will fix in v2 after I run my changes through CI.
Quoted 3 lines
Signature · 1 line
2.42.0
PATCH 2/2 i386/hyperv: add stubs for synic enablement
In reply to Ani SinhaAdd a new call hyperv_enable_synic() that can be called whether or not CONFIG_HYPERV is enabled. This way genetic code in i396/kvm.c can call this function to enable synic for hyperv. For non-hyperv cases, the stub will be a noop.
--- target/i386/kvm/hyperv-stub.c | 5 +++++ target/i386/kvm/hyperv.c | 9 +++++++++ target/i386/kvm/hyperv.h | 1 + target/i386/kvm/kvm.c | 12 +++++------- 4 files changed, 20 insertions(+), 7 deletions(-)
target/i386/kvm/hyperv-stub.c +5 -0
@@ -61,3 +61,8 @@ uint64_t hyperv_syndbg_query_options(void) {return 0 ; } + +int hyperv_enable_synic (X86CPU *cpu) +{ +return 0 ; +}
target/i386/kvm/hyperv.c +9 -0
@@ -24,6 +24,15 @@ int hyperv_x86_synic_add(X86CPU *cpu)return 0 ; } +int hyperv_enable_synic (X86CPU *cpu) +{ +int ret =0 ; +if (!hyperv_is_synic_enabled ()) { + ret =hyperv_x86_synic_add (cpu); + } +return ret; +} +/* * All devices possibly using SynIC have to be reset before calling this to let * them remove their SINT routes first.
target/i386/kvm/hyperv.h +1 -0
@@ -23,6 +23,7 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit);#endif int hyperv_x86_synic_add (X86CPU *cpu); +int hyperv_enable_synic (X86CPU *cpu);void hyperv_x86_synic_reset (X86CPU *cpu);void hyperv_x86_synic_update (X86CPU *cpu);
target/i386/kvm/kvm.c +5 -7
@@ -1754,13 +1754,11 @@ static int hyperv_init_vcpu(X86CPU *cpu)return ret; } -if (!hyperv_is_synic_enabled ()) { - ret =hyperv_x86_synic_add (cpu); -if (ret <0 ) { -error_report ("failed to create HyperV SynIC: %s" , -strerror (-ret)); -return ret; - } + ret =hyperv_enable_synic (cpu); +if (ret <0 ) { +error_report ("failed to create HyperV SynIC: %s" , +strerror (-ret)); +return ret; } }
Signature · 1 line
2.42.0
Re: [PATCH for-11.0 2/2] i386/hyperv: add stubs for synic enablement
Hi Ani,
Quoted 72 lines · Ani Sinha
Add a new call
hyperv_enable_synic()that can be called whether or notCONFIG_HYPERVis enabled. This way genetic code ini396/kvm.ccan call this function to enable synic for hyperv. For non-hyperv cases, the stub will be a noop.Reported-by Michale Tokarev <[email protected]>Signed-off-by Ani Sinha <[email protected]>--- target/i386/kvm/hyperv-stub.c | 5 +++++ target/i386/kvm/hyperv.c | 9 +++++++++ target/i386/kvm/hyperv.h | 1 + target/i386/kvm/kvm.c | 12 +++++------- 4 files changed, 20 insertions(+), 7 deletions(-)target/i386/kvm/hyperv-stub.c +5
-0@@ -61,3 +61,8 @@ uint64_t hyperv_syndbg_query_options(void) {return 0 ; } + +int hyperv_enable_synic (X86CPU *cpu) +{ +return 0 ; +}target/i386/kvm/hyperv.c +9
-0@@ -24,6 +24,15 @@ int hyperv_x86_synic_add(X86CPU *cpu)return 0 ; } +int hyperv_enable_synic (X86CPU *cpu) +{ +int ret =0 ; +if (!hyperv_is_synic_enabled ()) { + ret =hyperv_x86_synic_add (cpu); + } +return ret; +} +/* * All devices possibly using SynIC have to be reset before calling this to let * them remove their SINT routes first. target/i386/kvm/hyperv.h +1
-0@@ -23,6 +23,7 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit);#endif int hyperv_x86_synic_add (X86CPU *cpu); +int hyperv_enable_synic (X86CPU *cpu);void hyperv_x86_synic_reset (X86CPU *cpu);void hyperv_x86_synic_update (X86CPU *cpu);target/i386/kvm/kvm.c +0
-5@@ -1754,13 +1754,11 @@ static int hyperv_init_vcpu(X86CPU *cpu)return ret; } -if (!hyperv_is_synic_enabled ()) { - ret =hyperv_x86_synic_add (cpu); -if (ret <0 ) { -error_report ("failed to create HyperV SynIC: %s" , -strerror (-ret));
target/i386/kvm/kvm.c static int hyperv_init_vcpu(X86CPU *cpu) · line 1764
Quoted 10 lines
target/i386/kvm/kvm.c +5
-2-return ret; - } + ret =hyperv_enable_synic (cpu); +if (ret <0 ) { +error_report ("failed to create HyperV SynIC: %s" , +strerror (-ret)); +return ret; } }
Why not simply add a hyperv_is_synic_enabled() stub?
Re: [PATCH for-11.0 2/2] i386/hyperv: add stubs for synic enablement
Quoted 77 lines · Philippe Mathieu-Daudé
Hi Ani,
Quoted 70 lines · Ani Sinha
Add a new call
hyperv_enable_synic()that can be called whether or notCONFIG_HYPERVis enabled. This way genetic code ini396/kvm.ccan call this function to enable synic for hyperv. For non-hyperv cases, the stub will be a noop.Reported-by Michale Tokarev <[email protected]>Signed-off-by Ani Sinha <[email protected]>--- target/i386/kvm/hyperv-stub.c | 5 +++++ target/i386/kvm/hyperv.c | 9 +++++++++ target/i386/kvm/hyperv.h | 1 + target/i386/kvm/kvm.c | 12 +++++------- 4 files changed, 20 insertions(+), 7 deletions(-)target/i386/kvm/hyperv-stub.c +5
-0@@ -61,3 +61,8 @@ uint64_t hyperv_syndbg_query_options(void) {return 0 ; } + +int hyperv_enable_synic (X86CPU *cpu) +{ +return 0 ; +}target/i386/kvm/hyperv.c +8
-0@@ -24,6 +24,15 @@ int hyperv_x86_synic_add(X86CPU *cpu)return 0 ; } +int hyperv_enable_synic(X86CPU *cpu) +{ +int ret =0 ; +if (!hyperv_is_synic_enabled ()) { + ret =hyperv_x86_synic_add (cpu); + } +return ret; +} +/* * All devices possibly using SynIC have to be reset before calling this to let * them remove their SINT routes first. target/i386/kvm/hyperv.h +1
-0@@ -23,6 +23,7 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit);#endif int hyperv_x86_synic_add (X86CPU *cpu); +int hyperv_enable_synic (X86CPU *cpu);void hyperv_x86_synic_reset (X86CPU *cpu);void hyperv_x86_synic_update (X86CPU *cpu); diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.cindex
a29f757c16..9e352882c8100644target/i386/kvm/kvm.c +2
-6@@ -1754,13 +1754,11 @@ static int hyperv_init_vcpu(X86CPU *cpu)return ret; } - if (!hyperv_is_synic_enabled()) { - ret =hyperv_x86_synic_add (cpu); -if (ret <0 ) { -error_report ("failed to create HyperV SynIC: %s" , -strerror (-ret)); -return ret; - } + ret =hyperv_enable_synic (cpu); +if (ret <0 ) {
Quoted 8 lines
target/i386/kvm/kvm.c static int hyperv_init_vcpu(X86CPU *cpu) · line 1764
Quoted 6 lines
target/i386/kvm/kvm.c +3
-0+error_report ("failed to create HyperV SynIC: %s" , +strerror (-ret)); +return ret; } }Why not simply add a
hyperv_is_synic_enabled()stub?
That would be wrong unless I assert in hyperv_is_synic_enabled() stub function which would break minimal microvms?
The other reason is I do not like hyperv_x86_synic_add() returning -ENOSYS. If hyperv is not enabled we do not need to call those functions at all.