qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

qapi: Have each QAPI schema declare its name rule violations

qapi.py has a hardcoded white-list of type names that may violate the
rule on use of upper and lower case. Add a new pragma directive
'name-case-whitelist', and use it to replace the hard-coded
white-list.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1489582656-31133-7-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>

+34 -14
+6
docs/qapi-code-gen.txt
··· 252 252 "x-" is marked experimental, and may be withdrawn or changed 253 253 incompatibly in a future release. 254 254 255 + Pragma 'name-case-whitelist' lets you violate the rules on use of 256 + upper and lower case. Use for new code is strongly discouraged. 257 + 255 258 In the rest of this document, usage lines are given for each 256 259 expression type, with literal strings written in lower case and 257 260 placeholders written in capitals. If a literal string includes a ··· 320 323 321 324 Pragma 'returns-whitelist' takes a list of command names that may 322 325 violate the rules on permitted return types. Default is none. 326 + 327 + Pragma 'name-case-whitelist' takes a list of names that may violate 328 + rules on use of upper- vs. lower-case letters. Default is none. 323 329 324 330 325 331 === Struct types ===
+10 -1
qapi-schema.json
··· 61 61 'query-migrate-cache-size', 62 62 'query-tpm-models', 63 63 'query-tpm-types', 64 - 'ringbuf-read' ] } } 64 + 'ringbuf-read' ], 65 + 'name-case-whitelist': [ 66 + 'ACPISlotType', # DIMM, visible through query-acpi-ospm-status 67 + 'CpuInfoMIPS', # PC, visible through query-cpu 68 + 'CpuInfoTricore', # PC, visible through query-cpu 69 + 'QapiErrorClass', # all members, visible through errors 70 + 'UuidInfo', # UUID, visible through query-uuid 71 + 'X86CPURegister32', # all members, visible indirectly through qom-get 72 + 'q_obj_CpuInfo-base' # CPU, visible through query-cpu 73 + ] } } 65 74 66 75 # QAPI common definitions 67 76 { 'include': 'qapi/common.json' }
+10 -12
scripts/qapi.py
··· 44 44 returns_whitelist = [] 45 45 46 46 # Whitelist of entities allowed to violate case conventions 47 - case_whitelist = [ 48 - # From QMP: 49 - 'ACPISlotType', # DIMM, visible through query-acpi-ospm-status 50 - 'CpuInfoMIPS', # PC, visible through query-cpu 51 - 'CpuInfoTricore', # PC, visible through query-cpu 52 - 'QapiErrorClass', # all members, visible through errors 53 - 'UuidInfo', # UUID, visible through query-uuid 54 - 'X86CPURegister32', # all members, visible indirectly through qom-get 55 - 'q_obj_CpuInfo-base', # CPU, visible through query-cpu 56 - ] 47 + name_case_whitelist = [] 57 48 58 49 enum_types = [] 59 50 struct_types = [] ··· 302 293 self.docs.extend(exprs_include.docs) 303 294 304 295 def _pragma(self, name, value, info): 305 - global doc_required, returns_whitelist 296 + global doc_required, returns_whitelist, name_case_whitelist 306 297 if name == 'doc-required': 307 298 if not isinstance(value, bool): 308 299 raise QAPISemError(info, ··· 315 306 "Pragma returns-whitelist must be" 316 307 " a list of strings") 317 308 returns_whitelist = value 309 + elif name == 'name-case-whitelist': 310 + if (not isinstance(value, list) 311 + or any([not isinstance(elt, str) for elt in value])): 312 + raise QAPISemError(info, 313 + "Pragma name-case-whitelist must be" 314 + " a list of strings") 315 + name_case_whitelist = value 318 316 else: 319 317 raise QAPISemError(info, "Unknown pragma '%s'" % name) 320 318 ··· 1287 1285 1288 1286 def check_clash(self, info, seen): 1289 1287 cname = c_name(self.name) 1290 - if cname.lower() != cname and self.owner not in case_whitelist: 1288 + if cname.lower() != cname and self.owner not in name_case_whitelist: 1291 1289 raise QAPISemError(info, 1292 1290 "%s should not use uppercase" % self.describe()) 1293 1291 if cname in seen:
+1
tests/Makefile.include
··· 443 443 qapi-schema += non-objects.json 444 444 qapi-schema += pragma-doc-required-crap.json 445 445 qapi-schema += pragma-extra-junk.json 446 + qapi-schema += pragma-name-case-whitelist-crap.json 446 447 qapi-schema += pragma-non-dict.json 447 448 qapi-schema += pragma-returns-whitelist-crap.json 448 449 qapi-schema += qapi-schema-test.json
+1 -1
tests/qapi-schema/enum-member-case.err
··· 1 - tests/qapi-schema/enum-member-case.json:3: 'Value' (member of NoWayThisWillGetWhitelisted) should not use uppercase 1 + tests/qapi-schema/enum-member-case.json:4: 'Value' (member of NoWayThisWillGetWhitelisted) should not use uppercase
+1
tests/qapi-schema/enum-member-case.json
··· 1 1 # Member names should be 'lower-case' unless the enum is whitelisted 2 + { 'pragma': { 'name-case-whitelist': [ 'UuidInfo' ] } } 2 3 { 'enum': 'UuidInfo', 'data': [ 'Value' ] } # UuidInfo is whitelisted 3 4 { 'enum': 'NoWayThisWillGetWhitelisted', 'data': [ 'Value' ] }
+1
tests/qapi-schema/pragma-name-case-whitelist-crap.err
··· 1 + tests/qapi-schema/pragma-name-case-whitelist-crap.json:3: Pragma name-case-whitelist must be a list of strings
+1
tests/qapi-schema/pragma-name-case-whitelist-crap.exit
··· 1 + 1
+3
tests/qapi-schema/pragma-name-case-whitelist-crap.json
··· 1 + # 'name-case-whitelist' must be list of strings 2 + 3 + { 'pragma': { 'name-case-whitelist': null } }
tests/qapi-schema/pragma-name-case-whitelist-crap.out

This is a binary file and will not be displayed.