graphics: introduce listens.{type|address|network} parameters

Using "listens.*" allows better configuration of listen elements for
graphics devices.  Currently the only way how to configure a listen
type is to abuse "listen" parameter and there is no way how to configure
exact "network".

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2017-09-06 10:17:43 +02:00
parent ccaef8c16a
commit fe6c5067c0
3 changed files with 32 additions and 0 deletions

View File

@ -249,6 +249,14 @@
<image compression="off"/>
<listen type="none"/>
</graphics>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
<listen type="address" address="1.2.3.4"/>
</graphics>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
<listen type="network" network="default"/>
</graphics>
<serial type="tcp">
<source mode="bind" host="127.0.0.1" service="2222"/>
<protocol type="telnet"/>

View File

@ -486,6 +486,8 @@ c.add_compare(""" \
--graphics spice,gl=yes,listen=socket \
--graphics spice,gl=yes,listen=none \
--graphics spice,gl=yes,listen=none,rendernode=/dev/dri/foo \
--graphics spice,listens0.type=address,listens0.address=1.2.3.4 \
--graphics spice,listens0.type=network,listens0.network=default \
\
--controller usb,model=ich9-ehci1,address=0:0:4.7,index=0 \
--controller usb,model=ich9-uhci1,address=0:0:4.0,index=0,master=0 \

View File

@ -2233,6 +2233,22 @@ class ParserGraphics(VirtCLIParser):
else:
inst.listen = val
def listens_find_inst_cb(self, inst, val, virtarg, can_edit):
graphics = inst
num = 0
if re.search("\d+", virtarg.key):
num = int(re.search("\d+", virtarg.key).group())
if can_edit:
while len(graphics.listens) < (num + 1):
graphics.add_listen()
try:
return graphics.listens[num]
except IndexError:
if not can_edit:
return None
raise
def _parse(self, inst):
if self.optstr == "none":
self.guest.skip_default_graphics = True
@ -2261,6 +2277,12 @@ ParserGraphics.add_arg(None, "type", cb=ParserGraphics.set_type_cb)
ParserGraphics.add_arg("port", "port")
ParserGraphics.add_arg("tlsPort", "tlsport")
ParserGraphics.add_arg("listen", "listen", cb=ParserGraphics.set_listen_cb)
ParserGraphics.add_arg("type", "listens[0-9]*.type",
find_inst_cb=ParserGraphics.listens_find_inst_cb)
ParserGraphics.add_arg("address", "listens[0-9]*.address",
find_inst_cb=ParserGraphics.listens_find_inst_cb)
ParserGraphics.add_arg("network", "listens[0-9]*.network",
find_inst_cb=ParserGraphics.listens_find_inst_cb)
ParserGraphics.add_arg(None, "keymap", cb=ParserGraphics.set_keymap_cb)
ParserGraphics.add_arg("passwd", "password")
ParserGraphics.add_arg("passwdValidTo", "passwordvalidto")