[PATCH] cofig_tools: apply vBDF pattern check to vUART and ivshmem


Kunhui Li
 

apply vBDF pattern check to vUART and ivshmem.

Tracked-On: #7925
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
.../ConfigForm/CustomWidget/IVSHMEM_REGION.vue | 9 +++++++--
.../Config/ConfigForm/CustomWidget/VUART.vue | 15 +++++++++++++--
2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/IVSHMEM_REGION.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/IVSHMEM_REGION.vue
index 948f414b7..e18d372f2 100644
--- a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/IVSHMEM_REGION.vue
+++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/IVSHMEM_REGION.vue
@@ -87,9 +87,9 @@
</b-form-invalid-feedback>
</b-col>
<b-col sm="3">
- <b-form-input v-model="IVSHMEM_VM.VBDF" placeholder="00:[device].[function], e.g. 00:0c.0. All fields are in hexadecimal."/>
+ <b-form-input :state="validateVBDF(IVSHMEM_VM.VBDF)" v-model="IVSHMEM_VM.VBDF" placeholder="00:[device].[function], e.g. 00:0c.0. All fields are in hexadecimal."/>
<b-form-invalid-feedback>
- must have value
+ A string with up to two hex digits, a ``:``, two hex digits, a ``.``, and one digit between 0-7.
</b-form-invalid-feedback>
</b-col>
<b-col sm="3">
@@ -171,6 +171,7 @@ export default {
IVSHMEMSize: this.rootSchema.definitions['IVSHMEMSize']['enum'],
IVSHMEMRegionType: this.rootSchema.definitions['IVSHMEMRegionType'],
IVSHMEM_VM: this.rootSchema.definitions['IVSHMEMVM'],
+ VBDFType: this.rootSchema.definitions['VBDFType'],
defaultVal: vueUtils.getPathVal(this.rootFormData, this.curNodePath)
};
},
@@ -196,6 +197,10 @@ export default {
var regexp = new RegExp(this.IVSHMEMRegionType.properties.NAME.pattern);
return (value != null) && regexp.test(value);
},
+ validateVBDF(value) {
+ var regexp = new RegExp(this.VBDFType.pattern);
+ return (value != null) && regexp.test(value);
+ },
validation(value) {
return (value != null) && (value.length !== 0);
},
diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/VUART.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/VUART.vue
index f00ccbec1..b9d389791 100644
--- a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/VUART.vue
+++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/VUART.vue
@@ -96,14 +96,20 @@
<b-col sm="4"> Connection_{{ index + 1 }}-{{ VUARTConn.endpoint[0].vm_name }} </b-col>
<b-col sm="4">
<b-form-input v-model="VUARTConn.endpoint[0].io_port" v-if="VUARTConn.type === 'legacy'" :placeholder="vIoPortPlaceholder"/>
- <b-form-input v-model="VUARTConn.endpoint[0].vbdf" v-else-if="VUARTConn.type === 'pci'" :placeholder="vBDFPlaceholder"/>
+ <b-form-input :state="validateVBDF(VUARTConn.endpoint[0].vbdf)" v-model="VUARTConn.endpoint[0].vbdf" v-else-if="VUARTConn.type === 'pci'" :placeholder="vBDFPlaceholder"/>
+ <b-form-invalid-feedback>
+ A string with up to two hex digits, a ``:``, two hex digits, a ``.``, and one digit between 0-7.
+ </b-form-invalid-feedback>
</b-col>
</b-row>
<b-row class="justify-content-sm-start align-items-center">
<b-col sm="4"> Connection_{{ index + 1 }}-{{ VUARTConn.endpoint[1].vm_name }} </b-col>
<b-col sm="4">
<b-form-input v-model="VUARTConn.endpoint[1].io_port" v-if="VUARTConn.type === 'legacy'" :placeholder="vIoPortPlaceholder"/>
- <b-form-input v-model="VUARTConn.endpoint[1].vbdf" v-else-if="VUARTConn.type === 'pci'" :placeholder="vBDFPlaceholder"/>
+ <b-form-input :state="validateVBDF(VUARTConn.endpoint[1].vbdf)" v-model="VUARTConn.endpoint[1].vbdf" v-else-if="VUARTConn.type === 'pci'" :placeholder="vBDFPlaceholder"/>
+ <b-form-invalid-feedback>
+ A string with up to two hex digits, a ``:``, two hex digits, a ``.``, and one digit between 0-7.
+ </b-form-invalid-feedback>
</b-col>
</b-row>
</div>
@@ -186,6 +192,7 @@ export default {
IOPortDefault: this.rootSchema.definitions['VuartEndpointType']['properties']['io_port']['default'],
VMConfigType: this.rootSchema.definitions['VMConfigType'],
VuartConnectionType: this.rootSchema.definitions['VuartConnectionType'],
+ VBDFType: this.rootSchema.definitions['VBDFType'],
defaultVal: vueUtils.getPathVal(this.rootFormData, this.curNodePath)
};
},
@@ -210,6 +217,10 @@ export default {
validation(value) {
return (value != null) && (value.length != 0);
},
+ validateVBDF(value) {
+ var regexp = new RegExp(this.VBDFType.pattern);
+ return (value != null) && regexp.test(value);
+ },
removeVUARTConnection(index) {
this.defaultVal.splice(index, 1);
},
--
2.25.1

Join {acrn-dev@lists.projectacrn.org to automatically receive all group messages.