From 72445d01b4fd75b642680aca33b5d0194b91afcf Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Fri, 13 May 2022 10:59:12 +0800 Subject: [PATCH] config_tools: add placeholders in input widgets The configurator today shows "Please Input" as the placeholder of input widgets, which is far from informative. This patch specifies element or type specific placeholders in the XML schema by reusing the `acrn:widget-options` annotation mechanism. For manually-designed widgets such as ivshmem or vUART the placeholders are added in the corresponding vue directly. Tracked-On: #6691 Signed-off-by: Junjie Mao --- doc/scripts/configdoc.xsl | 7 +++- .../CustomWidget/IVSHMEM_REGION.vue | 4 +-- .../Config/ConfigForm/CustomWidget/VUART.vue | 8 ++--- .../scenario_config/jsonschema/converter.py | 16 +++++---- misc/config_tools/schema/VMtypes.xsd | 36 ++++++++++--------- misc/config_tools/schema/config.xsd | 25 ++++++------- misc/config_tools/schema/types.xsd | 6 ++-- 7 files changed, 53 insertions(+), 49 deletions(-) diff --git a/doc/scripts/configdoc.xsl b/doc/scripts/configdoc.xsl index 5f393f911..2e1fbdf3d 100644 --- a/doc/scripts/configdoc.xsl +++ b/doc/scripts/configdoc.xsl @@ -5,7 +5,7 @@ - + @@ -204,6 +204,11 @@ + + + + + No type annotation found 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 938acc481..2103269c4 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 @@ -9,7 +9,7 @@ - + @@ -48,7 +48,7 @@ - +
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 18b4e3cf1..2cad1dc95 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 @@ -50,15 +50,15 @@ Connection_{{ index + 1 }}-{{ VUARTConn.endpoint[0].vm_name }} - - + + Connection_{{ index + 1 }}-{{ VUARTConn.endpoint[1].vm_name }} - - + +
diff --git a/misc/config_tools/scenario_config/jsonschema/converter.py b/misc/config_tools/scenario_config/jsonschema/converter.py index fe7377a1b..086aed148 100644 --- a/misc/config_tools/scenario_config/jsonschema/converter.py +++ b/misc/config_tools/scenario_config/jsonschema/converter.py @@ -148,8 +148,8 @@ class XS2JS: def convert_widget_config(self, annotation, js_ele): if '@acrn:widget' in annotation: js_ele['ui:widget'] = annotation['@acrn:widget'] - if '@acrn:widget-options' in annotation: - js_ele['ui:options'] = {eval(k): eval(v) for k, v in [kv.split('=') for kv in annotation['@acrn:widget-options'].split(',')]} + if '@acrn:widget-options' in annotation: + js_ele['ui:options'] = eval(f"{{{annotation['@acrn:widget-options']}}}") def xst2jst(self, type_name) -> str: """convert xml schema type name to json schema type name""" @@ -195,9 +195,9 @@ class XS2JS: enum_names.append(enum_name) js_st["enumNames"] = enum_names - # widget and its options - if 'xs:annotation' in obj: - self.convert_widget_config(obj['xs:annotation'], js_st) + # widget and its options + if 'xs:annotation' in obj: + self.convert_widget_config(obj['xs:annotation'], js_st) js_st.update(self.xsa2jsa(restriction)) return js_st @@ -297,12 +297,14 @@ class XS2JS: required.append(name) if '@maxOccurs' in element: - possible_keys = ['type', '$ref', 'oneOf'] + # ui:options seen at this moment are copied from the annotation of the type. + possible_keys = ['type', '$ref', 'oneOf', 'ui:options'] convert_to_items_success = False + js_ele['items'] = {} for possible_key in possible_keys: if possible_key not in js_ele: continue - js_ele['items'] = {possible_key: js_ele[possible_key]} + js_ele['items'][possible_key] = js_ele[possible_key] del js_ele[possible_key] convert_to_items_success = True diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd index 0701f00db..a61237bc0 100644 --- a/misc/config_tools/schema/VMtypes.xsd +++ b/misc/config_tools/schema/VMtypes.xsd @@ -147,17 +147,20 @@ The size is a subset of the VM's total memory size specified on the Basic tab. - + Specify the tag for the kernel image that is used as a multiboot module. The tag's spelling must exactly match the module tag in the GRUB multiboot cmdline. - + Specify the tag for the RAMdisk image that is used as a multiboot module. The tag's spelling must exactly match the module tag in the GRUB multiboot cmdline. - + Specify the command-line parameters that will be used to boot the kernel for this VM. See `Linux documentation <https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html>`__ for a list of parameters. @@ -276,8 +279,7 @@ The size is a subset of the VM's total memory size specified on the Basic tab. - + Select the PCI devices you want to assign to this virtual machine. @@ -314,13 +316,13 @@ The size is a subset of the VM's total memory size specified on the Basic tab. - + Specify the network interface name that will appear in the Service VM. Use the `ip a` command in the Service VM to display the network interface names. - - A string of letters, digits, ``_``, or ``-``. - + + A string of letters, digits, ``_``, or ``-``. + @@ -372,18 +374,18 @@ device file when user config it as virtio serial port, which can be read and wri Specify backend device type in service VM. - - + + The output file path for the file backend type. - - + + The sock file path for the sock server or client backend type. - - + + The device path for the tty backend type. @@ -393,12 +395,12 @@ device file when user config it as virtio serial port, which can be read and wri - + Specifying backend device in service vm with device description. - + Specifying unique identifier to distinguish same devices in guest. diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd index 9c5917b61..a65114d9a 100644 --- a/misc/config_tools/schema/config.xsd +++ b/misc/config_tools/schema/config.xsd @@ -286,7 +286,7 @@ These settings can only be changed at build time. Refer to :ref:`vuart_config` for detailed vUART settings. - + Specify the cache setting. @@ -306,20 +306,10 @@ Refer to :ref:`vuart_config` for detailed vUART settings. Select the VM type. A standard VM (``STANDARD_VM``) is for general-purpose applications, such as human-machine interface (HMI). A real-time VM (``RTVM``) offers special features for time-sensitive applications. - + Specify the name used to identify this VM. The VM name will be shown in the hypervisor console vm_list command. - - - A string from 1 to 32 characters long (with no spaces). - - - - - - - @@ -404,7 +394,7 @@ argument and memory. - + MMIO resources to passthrough. @@ -470,13 +460,18 @@ is the virtio network driver, simulating the virtual NIC. The backend could be: mouse, and tablet. It sends Linux input layer events over virtio. - + The virtio-blk device presents a block device to the VM. Each virtio-blk device appears as a disk inside the VM. + + + + - + The virtio GPU device presents a GPU device to the VM. This feature enables you to view the VM's GPU output in the Service VM. diff --git a/misc/config_tools/schema/types.xsd b/misc/config_tools/schema/types.xsd index b48feef6b..b80cfaff1 100644 --- a/misc/config_tools/schema/types.xsd +++ b/misc/config_tools/schema/types.xsd @@ -4,7 +4,7 @@ xmlns:acrn="https://projectacrn.org"> - + A Boolean value, written as ``y`` or ``n``. @@ -24,7 +24,7 @@ - + An Integer value in hexadecimal format (with a leading ``0x``). @@ -184,7 +184,7 @@ Read more about the available scheduling options in :ref:`cpu_sharing`. - + A string of up to 15 letters, digits, ``_``, or ``-``.