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

qapi: Reject blank 'if' conditions in addition to empty ones

"'if': 'COND'" generates "#if COND". We reject empty COND because it
won't compile. Blank COND won't compile any better, so reject that,
too.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-12-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>

+5 -4
+3 -2
scripts/qapi/common.py
··· 742 742 if not isinstance(ifcond, str): 743 743 raise QAPISemError( 744 744 info, "'if' condition must be a string or a list of strings") 745 - if ifcond == '': 746 - raise QAPISemError(info, "'if' condition '' makes no sense") 745 + if ifcond.strip() == '': 746 + raise QAPISemError(info, "'if' condition '%s' makes no sense" 747 + % ifcond) 747 748 748 749 ifcond = expr.get('if') 749 750 if ifcond is None:
+1 -1
tests/qapi-schema/bad-if-list.err
··· 1 - tests/qapi-schema/bad-if-list.json:2: 'if' condition '' makes no sense 1 + tests/qapi-schema/bad-if-list.json:2: 'if' condition ' ' makes no sense
+1 -1
tests/qapi-schema/bad-if-list.json
··· 1 1 # check invalid 'if' content 2 2 { 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, 3 - 'if': ['foo', ''] } 3 + 'if': ['foo', ' '] }