cofig_tools: apply vBDF pattern check to vUART and ivshmem

apply vBDF pattern check to vUART and ivshmem.

Tracked-On: #7925
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Kunhui-Li 2022-07-27 13:12:29 +08:00 committed by acrnsi-robot
parent 9a5f42e187
commit fa8c149a38
3 changed files with 21 additions and 5 deletions

View File

@ -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
{{ this.VBDFType["err:pattern"] }}
</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);
},

View File

@ -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>
{{ this.VBDFType["err:pattern"] }}
</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>
{{ this.VBDFType["err:pattern"] }}
</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);
},

View File

@ -178,7 +178,7 @@ Read more about the available scheduling options in :ref:`cpu_sharing`.</xs:docu
</xs:simpleType>
<xs:simpleType name="VBDFType">
<xs:annotation>
<xs:annotation acrn:errormsg="'pattern': 'A string with up to two hex digits, a ``:``, two hex digits, a ``.``, and one digit between 0-7.'">
<xs:documentation>A string with up to two hex digits, a ``:``, two hex digits, a ``.``, and one digit between 0-7.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">