tools/arm: Fix nr_spis handling v2
PATCH 1/1 tools/arm: Fix nr_spis handling v2
We are missing a way to detect whether a user provided a value for nr_spis equal to 0 or did not provide any value (default is also 0) which can cause issues when calculated nr_spis is > 0 and the value from domain config is 0. Fix it by setting default value for nr_spis to UINT32_MAX (max supported nr of SPIs is 960 anyway).
--- tools/libs/light/libxl_arm.c | 7 ++++--- tools/libs/light/libxl_types.idl | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)
tools/libs/light/libxl_arm.c +4 -3
@@ -84,7 +84,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,libxl_domain_config *d_config, struct xen_domctl_createdomain *config) { - uint32_t nr_spis = 0; + uint32_t nr_spis = 0, cfg_nr_spis = d_config->b_info.arch_arm.nr_spis;unsigned int i;uint32_t vuart_irq, virtio_irq =0 ;bool vuart_enabled = false, virtio_enabled = false;
@@ -181,13 +181,14 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,LOG (DEBUG ,"Configure the domain" ); -if (nr_spis > d_config->b_info.arch_arm.nr_spis) { +/* We use UINT32_MAX to denote if a user provided a value or not */ +if ((cfg_nr_spis !=UINT32_MAX ) && (nr_spis > cfg_nr_spis)) {LOG (ERROR ,"Provided nr_spis value is too small (minimum required %u)\n" , nr_spis);return ERROR_FAIL ; } - config->arch.nr_spis =max (nr_spis, d_config->b_info.arch_arm.nr_spis); + config->arch.nr_spis = (cfg_nr_spis !=UINT32_MAX ) ? cfg_nr_spis : nr_spis;LOG (DEBUG ," - Allocate %u SPIs" , config->arch.nr_spis);switch (d_config->b_info.arch_arm.gic_version) {
tools/libs/light/libxl_types.idl +1 -1
@@ -723,7 +723,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), ("vuart", libxl_vuart_type), ("sve_vl", libxl_sve_type), - ("nr_spis", uint32), + ("nr_spis", uint32, {'init_val': 'UINT32_MAX'}), ])), ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool), ])),
Signature · 1 line
2.25.1
Hi Michal,
Quoted 8 lines · Michal Orzel
We are missing a way to detect whether a user provided a value for
nr_spisequal to 0 or did not provide any value (default is also 0) which can cause issues when calculatednr_spisis > 0 and the value from domain config is 0. Fix it by setting default value fornr_spistoUINT32_MAX(max supported nr of SPIs is 960 anyway).
Quoted 4 lines
Fixes 55d62b8d4636 ("tools/arm: Reject configuration with incorrect nr_spis value")Reported-by Luca Fancellu <[email protected]>Signed-off-by Michal Orzel <[email protected]>---
I’ve tested this fix using our test that mounts a virtio mmio disk on the domain, everything works fine.
Quoted 49 lines · Michal Orzel
We are missing a way to detect whether a user provided a value for
nr_spisequal to 0 or did not provide any value (default is also 0) which can cause issues when calculatednr_spisis > 0 and the value from domain config is 0. Fix it by setting default value fornr_spistoUINT32_MAX(max supported nr of SPIs is 960 anyway).Fixes 55d62b8d4636 ("tools/arm: Reject configuration with incorrect nr_spis value")Reported-by Luca Fancellu <[email protected]>Signed-off-by Michal Orzel <[email protected]>--- tools/libs/light/libxl_arm.c | 7 ++++--- tools/libs/light/libxl_types.idl | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)tools/libs/light/libxl_arm.c +4
-3@@ -84,7 +84,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,libxl_domain_config *d_config, struct xen_domctl_createdomain *config) { - uint32_t nr_spis = 0; + uint32_t nr_spis = 0, cfg_nr_spis = d_config->b_info.arch_arm.nr_spis;unsigned int i;uint32_t vuart_irq, virtio_irq =0 ;bool vuart_enabled = false, virtio_enabled = false;@@ -181,13 +181,14 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,LOG (DEBUG ,"Configure the domain" ); -if (nr_spis > d_config->b_info.arch_arm.nr_spis) { +/* We use UINT32_MAX to denote if a user provided a value or not */ +if ((cfg_nr_spis !=UINT32_MAX ) && (nr_spis > cfg_nr_spis)) {LOG (ERROR ,"Provided nr_spis value is too small (minimum required %u)\n" , nr_spis);return ERROR_FAIL ; } - config->arch.nr_spis =max (nr_spis, d_config->b_info.arch_arm.nr_spis); + config->arch.nr_spis = (cfg_nr_spis !=UINT32_MAX ) ? cfg_nr_spis : nr_spis;LOG (DEBUG ," - Allocate %u SPIs" , config->arch.nr_spis);switch (d_config->b_info.arch_arm.gic_version) {tools/libs/light/libxl_types.idl +0
-0
tools/libs/light/libxl_types.idl libxl_domain_build_info = Struct("domain_build_info",[ · line 729
Quoted 8 lines
tools/libs/light/libxl_types.idl +1
-1@@ -723,7 +723,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), ("vuart", libxl_vuart_type), ("sve_vl", libxl_sve_type), - ("nr_spis", uint32), + ("nr_spis", uint32, {'init_val': 'UINT32_MAX'}), ])), ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool), ])),
Doesn't this regenerate the golang bindings?
Cheers,
Alejandro
Quoted 44 lines · Alejandro Vallejo
Quoted 43 lines · Michal Orzel
We are missing a way to detect whether a user provided a value for
nr_spisequal to 0 or did not provide any value (default is also 0) which can cause issues when calculatednr_spisis > 0 and the value from domain config is 0. Fix it by setting default value fornr_spistoUINT32_MAX(max supported nr of SPIs is 960 anyway).Fixes 55d62b8d4636 ("tools/arm: Reject configuration with incorrect nr_spis value")Reported-by Luca Fancellu <[email protected]>Signed-off-by Michal Orzel <[email protected]>--- tools/libs/light/libxl_arm.c | 7 ++++--- tools/libs/light/libxl_types.idl | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)tools/libs/light/libxl_arm.c +4
-3@@ -84,7 +84,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,libxl_domain_config *d_config, struct xen_domctl_createdomain *config) { - uint32_t nr_spis = 0; + uint32_t nr_spis = 0, cfg_nr_spis = d_config->b_info.arch_arm.nr_spis;unsigned int i;uint32_t vuart_irq, virtio_irq =0 ;bool vuart_enabled = false, virtio_enabled = false;@@ -181,13 +181,14 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,LOG (DEBUG ,"Configure the domain" ); -if (nr_spis > d_config->b_info.arch_arm.nr_spis) { +/* We use UINT32_MAX to denote if a user provided a value or not */ +if ((cfg_nr_spis !=UINT32_MAX ) && (nr_spis > cfg_nr_spis)) {LOG (ERROR ,"Provided nr_spis value is too small (minimum required %u)\n" , nr_spis);return ERROR_FAIL ; } - config->arch.nr_spis =max (nr_spis, d_config->b_info.arch_arm.nr_spis); + config->arch.nr_spis = (cfg_nr_spis !=UINT32_MAX ) ? cfg_nr_spis : nr_spis;LOG (DEBUG ," - Allocate %u SPIs" , config->arch.nr_spis);
Quoted 15 lines
Quoted 6 lines
tools/libs/light/libxl_arm.c +0
-0switch (d_config->b_info.arch_arm.gic_version) {tools/libs/light/libxl_types.idl +0
-0tools/libs/light/libxl_types.idl libxl_domain_build_info = Struct("domain_build_info",[ · line 729
Quoted 8 lines
tools/libs/light/libxl_types.idl +1
-1@@ -723,7 +723,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), ("vuart", libxl_vuart_type), ("sve_vl", libxl_sve_type), - ("nr_spis", uint32), + ("nr_spis", uint32, {'init_val': 'UINT32_MAX'}), ])), ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool), ])),Doesn't this regenerate the golang bindings?
You need a build environment with golang for that to happen. It's easy to miss.
In this case, best to ask the committer to regen.
~Andrew
Quoted 63 lines · Andrew Cooper
Quoted 44 lines · Alejandro Vallejo
Quoted 43 lines · Michal Orzel
We are missing a way to detect whether a user provided a value for
nr_spisequal to 0 or did not provide any value (default is also 0) which can cause issues when calculatednr_spisis > 0 and the value from domain config is 0. Fix it by setting default value fornr_spistoUINT32_MAX(max supported nr of SPIs is 960 anyway).Fixes 55d62b8d4636 ("tools/arm: Reject configuration with incorrect nr_spis value")Reported-by Luca Fancellu <[email protected]>Signed-off-by Michal Orzel <[email protected]>--- tools/libs/light/libxl_arm.c | 7 ++++--- tools/libs/light/libxl_types.idl | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)tools/libs/light/libxl_arm.c +4
-3@@ -84,7 +84,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,libxl_domain_config *d_config, struct xen_domctl_createdomain *config) { - uint32_t nr_spis = 0; + uint32_t nr_spis = 0, cfg_nr_spis = d_config->b_info.arch_arm.nr_spis;unsigned int i;uint32_t vuart_irq, virtio_irq =0 ;bool vuart_enabled = false, virtio_enabled = false;@@ -181,13 +181,14 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,LOG (DEBUG ,"Configure the domain" ); -if (nr_spis > d_config->b_info.arch_arm.nr_spis) { +/* We use UINT32_MAX to denote if a user provided a value or not */ +if ((cfg_nr_spis !=UINT32_MAX ) && (nr_spis > cfg_nr_spis)) {LOG (ERROR ,"Provided nr_spis value is too small (minimum required %u)\n" , nr_spis);return ERROR_FAIL ; } - config->arch.nr_spis =max (nr_spis, d_config->b_info.arch_arm.nr_spis); + config->arch.nr_spis = (cfg_nr_spis !=UINT32_MAX ) ? cfg_nr_spis : nr_spis;LOG (DEBUG ," - Allocate %u SPIs" , config->arch.nr_spis);Quoted 15 lines
Quoted 6 lines
tools/libs/light/libxl_arm.c +0
-0switch (d_config->b_info.arch_arm.gic_version) {tools/libs/light/libxl_types.idl +0
-0tools/libs/light/libxl_types.idl libxl_domain_build_info = Struct("domain_build_info",[ · line 729
Quoted 8 lines
tools/libs/light/libxl_types.idl +1
-1@@ -723,7 +723,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), ("vuart", libxl_vuart_type), ("sve_vl", libxl_sve_type), - ("nr_spis", uint32), + ("nr_spis", uint32, {'init_val': 'UINT32_MAX'}), ])), ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool), ])),Doesn't this regenerate the golang bindings?
Quoted 4 lines
You need a build environment with golang for that to happen. It's easy to miss.
In this case, best to ask the committer to regen.
This patch is already waiting for tools Ab, so maybe @Anthony could do that on commit?
~Michal
Quoted 61 lines · Andrew Cooper
Quoted 44 lines · Alejandro Vallejo
Quoted 43 lines · Michal Orzel
We are missing a way to detect whether a user provided a value for
nr_spisequal to 0 or did not provide any value (default is also 0) which can cause issues when calculatednr_spisis > 0 and the value from domain config is 0. Fix it by setting default value fornr_spistoUINT32_MAX(max supported nr of SPIs is 960 anyway).Fixes 55d62b8d4636 ("tools/arm: Reject configuration with incorrect nr_spis value")Reported-by Luca Fancellu <[email protected]>Signed-off-by Michal Orzel <[email protected]>--- tools/libs/light/libxl_arm.c | 7 ++++--- tools/libs/light/libxl_types.idl | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)tools/libs/light/libxl_arm.c +4
-3@@ -84,7 +84,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,libxl_domain_config *d_config, struct xen_domctl_createdomain *config) { - uint32_t nr_spis = 0; + uint32_t nr_spis = 0, cfg_nr_spis = d_config->b_info.arch_arm.nr_spis;unsigned int i;uint32_t vuart_irq, virtio_irq =0 ;bool vuart_enabled = false, virtio_enabled = false;@@ -181,13 +181,14 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,LOG (DEBUG ,"Configure the domain" ); -if (nr_spis > d_config->b_info.arch_arm.nr_spis) { +/* We use UINT32_MAX to denote if a user provided a value or not */ +if ((cfg_nr_spis !=UINT32_MAX ) && (nr_spis > cfg_nr_spis)) {LOG (ERROR ,"Provided nr_spis value is too small (minimum required %u)\n" , nr_spis);return ERROR_FAIL ; } - config->arch.nr_spis =max (nr_spis, d_config->b_info.arch_arm.nr_spis); + config->arch.nr_spis = (cfg_nr_spis !=UINT32_MAX ) ? cfg_nr_spis : nr_spis;LOG (DEBUG ," - Allocate %u SPIs" , config->arch.nr_spis);Quoted 15 lines
Quoted 6 lines
tools/libs/light/libxl_arm.c +0
-0switch (d_config->b_info.arch_arm.gic_version) {tools/libs/light/libxl_types.idl +0
-0tools/libs/light/libxl_types.idl libxl_domain_build_info = Struct("domain_build_info",[ · line 729
Quoted 8 lines
tools/libs/light/libxl_types.idl +1
-1@@ -723,7 +723,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), ("vuart", libxl_vuart_type), ("sve_vl", libxl_sve_type), - ("nr_spis", uint32), + ("nr_spis", uint32, {'init_val': 'UINT32_MAX'}), ])), ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool), ])),Doesn't this regenerate the golang bindings?
Quoted 6 lines
You need a build environment with golang for that to happen. It's easy to miss.
In this case, best to ask the committer to regen.
~Andrew
One more thing for the list of stuff I'd like to add to CI at some point.
Cheers,
Alejandro
Quoted 46 lines · Alejandro Vallejo
Quoted 43 lines · Michal Orzel
We are missing a way to detect whether a user provided a value for
nr_spisequal to 0 or did not provide any value (default is also 0) which can cause issues when calculatednr_spisis > 0 and the value from domain config is 0. Fix it by setting default value fornr_spistoUINT32_MAX(max supported nr of SPIs is 960 anyway).Fixes 55d62b8d4636 ("tools/arm: Reject configuration with incorrect nr_spis value")Reported-by Luca Fancellu <[email protected]>Signed-off-by Michal Orzel <[email protected]>--- tools/libs/light/libxl_arm.c | 7 ++++--- tools/libs/light/libxl_types.idl | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)tools/libs/light/libxl_arm.c +4
-3@@ -84,7 +84,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,libxl_domain_config *d_config, struct xen_domctl_createdomain *config) { - uint32_t nr_spis = 0; + uint32_t nr_spis = 0, cfg_nr_spis = d_config->b_info.arch_arm.nr_spis;unsigned int i;uint32_t vuart_irq, virtio_irq =0 ;bool vuart_enabled = false, virtio_enabled = false;@@ -181,13 +181,14 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,LOG (DEBUG ,"Configure the domain" ); -if (nr_spis > d_config->b_info.arch_arm.nr_spis) { +/* We use UINT32_MAX to denote if a user provided a value or not */ +if ((cfg_nr_spis !=UINT32_MAX ) && (nr_spis > cfg_nr_spis)) {LOG (ERROR ,"Provided nr_spis value is too small (minimum required %u)\n" , nr_spis);return ERROR_FAIL ; } - config->arch.nr_spis =max (nr_spis, d_config->b_info.arch_arm.nr_spis); + config->arch.nr_spis = (cfg_nr_spis !=UINT32_MAX ) ? cfg_nr_spis : nr_spis;LOG (DEBUG ," - Allocate %u SPIs" , config->arch.nr_spis);
Quoted 16 lines
Quoted 6 lines
tools/libs/light/libxl_arm.c +0
-0switch (d_config->b_info.arch_arm.gic_version) {tools/libs/light/libxl_types.idl +0
-0tools/libs/light/libxl_types.idl libxl_domain_build_info = Struct("domain_build_info",[ · line 729
Quoted 8 lines
tools/libs/light/libxl_types.idl +1
-1@@ -723,7 +723,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), ("vuart", libxl_vuart_type), ("sve_vl", libxl_sve_type), - ("nr_spis", uint32), + ("nr_spis", uint32, {'init_val': 'UINT32_MAX'}), ])), ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool), ])),Doesn't this regenerate the golang bindings?
FYI, it does not. The bindings are already there for NrSpis and default value is does not result in a change (for verification I checked max_grant_frames that uses LIBXL_MAX_GRANT_DEFAULT).
~Michal
Quoted 10 lines · Michal Orzel
Quoted 2 lines · Alejandro Vallejo
Doesn't this regenerate the golang bindings?
FYI, it does not. The bindings are already there for NrSpis and default value is does not result in a change (for verification I checked
max_grant_framesthat usesLIBXL_MAX_GRANT_DEFAULT).~Michal
Oh, good then. Though it does raise the (completely separate) question of how correct those bindings might be if they ignore the IDL's default values... :/
Cheers,
Alejandro
Quoted 8 lines · Alejandro Vallejo
Quoted 5 lines · Michal Orzel
Quoted 2 lines · Alejandro Vallejo
Doesn't this regenerate the golang bindings?
Quoted 8 lines
Quoted 5 lines
FYI, it does not. The bindings are already there for NrSpis and default value is does not result in a change (for verification I checked
max_grant_framesthat usesLIBXL_MAX_GRANT_DEFAULT).~Michal
Oh, good then. Though it does raise the (completely separate) question of how correct those bindings might be if they ignore the IDL's default values... :/
Why ignore. AFAICS libxl_domain_build_info_init is called there to grab default values.
~Michal
Quoted 15 lines · Michal Orzel
Quoted 12 lines · Alejandro Vallejo
Quoted 9 lines · Michal Orzel
Quoted 2 lines · Alejandro Vallejo
Doesn't this regenerate the golang bindings?
FYI, it does not. The bindings are already there for NrSpis and default value is does not result in a change (for verification I checked
max_grant_framesthat usesLIBXL_MAX_GRANT_DEFAULT).
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
~Michal
Oh, good then. Though it does raise the (completely separate) question of how correct those bindings might be if they ignore the IDL's default values... :/
Why ignore. AFAICS
libxl_domain_build_info_initis called there to grab default values.~Michal
Oh, so the default populator is itself autogenerated C with a golang binding rather than native golang. Fair enough. The more you learn.
Cheers,
Alejandro
Quoted 31 lines · Michal Orzel
We are missing a way to detect whether a user provided a value for
nr_spisequal to 0 or did not provide any value (default is also 0) which can cause issues when calculatednr_spisis > 0 and the value from domain config is 0. Fix it by setting default value fornr_spistoUINT32_MAX(max supported nr of SPIs is 960 anyway).Fixes 55d62b8d4636 ("tools/arm: Reject configuration with incorrect nr_spis value")Reported-by Luca Fancellu <[email protected]>Signed-off-by Michal Orzel <[email protected]>--- tools/libs/light/libxl_arm.c | 7 ++++--- tools/libs/light/libxl_types.idl | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)tools/libs/light/libxl_arm.c +1
-1@@ -84,7 +84,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,libxl_domain_config *d_config, struct xen_domctl_createdomain *config) { - uint32_t nr_spis = 0; + uint32_t nr_spis = 0, cfg_nr_spis = d_config->b_info.arch_arm.nr_spis;unsigned int i;uint32_t vuart_irq, virtio_irq =0 ;bool vuart_enabled = false, virtio_enabled = false;@@ -181,13 +181,14 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,LOG (DEBUG ,"Configure the domain" );
tools/libs/light/libxl_arm.c int libxl__arch_domain_prepare_config(libxl__gc *gc, · line 191
Quoted 10 lines
tools/libs/light/libxl_arm.c +3
-2-if (nr_spis > d_config->b_info.arch_arm.nr_spis) { +/* We use UINT32_MAX to denote if a user provided a value or not */ +if ((cfg_nr_spis !=UINT32_MAX ) && (nr_spis > cfg_nr_spis)) {LOG (ERROR ,"Provided nr_spis value is too small (minimum required %u)\n" , nr_spis);return ERROR_FAIL ; } - config->arch.nr_spis =max (nr_spis, d_config->b_info.arch_arm.nr_spis); + config->arch.nr_spis = (cfg_nr_spis !=UINT32_MAX ) ? cfg_nr_spis : nr_spis;
Could you try to check only once if there is a user provided value for nr_spis?
tools/libs/light/libxl_types.idl libxl_domain_build_info = Struct("domain_build_info",[ · line 726
Quoted 13 lines
tools/libs/light/libxl_arm.c +0
-0LOG (DEBUG ," - Allocate %u SPIs" , config->arch.nr_spis);switch (d_config->b_info.arch_arm.gic_version) {tools/libs/light/libxl_types.idl +1
-1@@ -723,7 +723,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), ("vuart", libxl_vuart_type), ("sve_vl", libxl_sve_type), - ("nr_spis", uint32), + ("nr_spis", uint32, {'init_val': 'UINT32_MAX'}),
Could you introduce something like LIBXL_NR_SPIS_DEFAULT in libxl.h instead? (Like we have LIBXL_MAX_GRANT_DEFAULT or LIBXL_MEMKB_DEFAULT)
Thanks,
Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
Quoted 42 lines · Anthony PERARD
Quoted 39 lines · Michal Orzel
We are missing a way to detect whether a user provided a value for
nr_spisequal to 0 or did not provide any value (default is also 0) which can cause issues when calculatednr_spisis > 0 and the value from domain config is 0. Fix it by setting default value fornr_spistoUINT32_MAX(max supported nr of SPIs is 960 anyway).Fixes 55d62b8d4636 ("tools/arm: Reject configuration with incorrect nr_spis value")Reported-by Luca Fancellu <[email protected]>Signed-off-by Michal Orzel <[email protected]>--- tools/libs/light/libxl_arm.c | 7 ++++--- tools/libs/light/libxl_types.idl | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)tools/libs/light/libxl_arm.c +3
-2@@ -84,7 +84,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,libxl_domain_config *d_config, struct xen_domctl_createdomain *config) { - uint32_t nr_spis = 0; + uint32_t nr_spis = 0, cfg_nr_spis = d_config->b_info.arch_arm.nr_spis;unsigned int i;uint32_t vuart_irq, virtio_irq =0 ;bool vuart_enabled = false, virtio_enabled = false;@@ -181,13 +181,14 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,LOG (DEBUG ,"Configure the domain" ); -if (nr_spis > d_config->b_info.arch_arm.nr_spis) { +/* We use UINT32_MAX to denote if a user provided a value or not */ +if ((cfg_nr_spis !=UINT32_MAX ) && (nr_spis > cfg_nr_spis)) {LOG (ERROR ,"Provided nr_spis value is too small (minimum required %u)\n" , nr_spis);return ERROR_FAIL ; }
Quoted 5 lines
tools/libs/light/libxl_arm.c int libxl__arch_domain_prepare_config(libxl__gc *gc, · line 191
Quoted 2 lines
tools/libs/light/libxl_arm.c +1
-1- config->arch.nr_spis =max (nr_spis, d_config->b_info.arch_arm.nr_spis); + config->arch.nr_spis = (cfg_nr_spis !=UINT32_MAX ) ? cfg_nr_spis : nr_spis;Could you try to check only once if there is a user provided value for
nr_spis?
Sure, but that's one extra variable or more if/else blocks.
Quoted 17 lines
Quoted 9 lines
tools/libs/light/libxl_arm.c +0
-0LOG (DEBUG ," - Allocate %u SPIs" , config->arch.nr_spis);switch (d_config->b_info.arch_arm.gic_version) {tools/libs/light/libxl_types.idl +0
-0tools/libs/light/libxl_types.idl libxl_domain_build_info = Struct("domain_build_info",[ · line 726
Quoted 5 lines
tools/libs/light/libxl_types.idl +1
-1@@ -723,7 +723,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), ("vuart", libxl_vuart_type), ("sve_vl", libxl_sve_type), - ("nr_spis", uint32), + ("nr_spis", uint32, {'init_val': 'UINT32_MAX'}),Could you introduce something like
LIBXL_NR_SPIS_DEFAULTinlibxl.hinstead? (Like we haveLIBXL_MAX_GRANT_DEFAULTorLIBXL_MEMKB_DEFAULT)
Sure, no problem.
~Michal