Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 71aaf5a

Browse files
committed
VirtualGraphics: Parse pending vnc socket attribute
Not upstream yet, but if the attribute name changes it will be simple to handle.
1 parent 8298f27 commit 71aaf5a

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

tests/xmlparse-xml/change-graphics-in.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<graphics type="vnc" passwd="foobar" port="100" listen="0.0.0.0"/>
2727
<graphics type="sdl" xauth="/tmp/.Xauthority" display="1:2"/>
2828
<graphics type="rdp"/>
29-
<graphics type="vnc" port="-1"/>
29+
<graphics type="vnc" port="-1" socket="/tmp/foobar"/>
3030
<graphics type="spice" passwd="foobar" port="100" tlsPort="101" listen="0.0.0.0" passwdValidTo="2010-04-09T15:51:00">
3131
<channel name='inputs' mode='insecure'/>
3232
<channel name='main' mode='secure'/>

tests/xmlparse-xml/change-graphics-out.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<graphics type="vnc" passwd="newpass" port="6000" listen="1.2.3.4"/>
2727
<graphics type="sdl" xauth="fooauth" display="6:1"/>
2828
<graphics type="rdp"/>
29-
<graphics type="vnc" port="-1"/>
29+
<graphics type="vnc" port="-1" socket="/var/lib/libvirt/socket/foo"/>
3030
<graphics type="spice" passwd="newpass" port="6000" tlsPort="6001" listen="1.2.3.4" passwdValidTo="2011-01-07T19:08:00">
3131
<channel name="inputs" mode="secure"/>
3232
<channel name="main" mode="any"/>

tests/xmlparse.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ def testAlterGraphics(self):
434434
check = self._make_checker(dev4)
435435
check("type", "vnc")
436436
check("port", -1)
437+
check("socket", "/tmp/foobar", "/var/lib/libvirt/socket/foo")
437438

438439
check = self._make_checker(dev5)
439440
check("type", "spice")

virtinst/VirtualGraphics.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def __init__(self, type=TYPE_VNC, port=-1, listen=None, passwd=None,
9898
self._keymap = None
9999
self._xauth = None
100100
self._display = None
101+
self._socket = None
101102
self._channels = {}
102103

103104
if self._is_parse():
@@ -217,6 +218,13 @@ def set_passwdValidTo(self, val):
217218
passwdValidTo = _xml_property(get_passwdValidTo, set_passwdValidTo,
218219
xpath="./@passwdValidTo")
219220

221+
def _get_socket(self):
222+
return self._socket
223+
def _set_socket(self, val):
224+
self._socket = val
225+
socket = _xml_property(_get_socket, _set_socket,
226+
xpath="./@socket")
227+
220228
def get_tlsPort(self):
221229
return self._tlsPort
222230
def set_tlsPort(self, val):
@@ -246,7 +254,7 @@ def set_tlsPort(self, val):
246254

247255
def _build_xml(self, port=None, listen=None, keymap=None, passwd=None,
248256
display=None, xauth=None, tlsPort=None, autoport=False,
249-
passwdValidTo=None):
257+
passwdValidTo=None, socket=None):
250258

251259
doautoport = (autoport and (port == -1 or tlsPort == -1))
252260
portxml = (port != None and (" port='%d'" % port) or "")
@@ -262,7 +270,7 @@ def _build_xml(self, port=None, listen=None, keymap=None, passwd=None,
262270
xauthxml = (xauth and (" xauth='%s'" % xauth) or "")
263271
displayxml = (display and (" display='%s'" % display) or "")
264272

265-
#socketxml = (socket and (" socket='%s'" % socket) or "")
273+
socketxml = (socket and (" socket='%s'" % socket) or "")
266274

267275
xml = (" " +
268276
"<graphics type='%s'" % self.type +
@@ -273,7 +281,7 @@ def _build_xml(self, port=None, listen=None, keymap=None, passwd=None,
273281
listenxml +
274282
passwdxml +
275283
passwdValidToxml +
276-
#socketxml +
284+
socketxml +
277285
displayxml +
278286
xauthxml +
279287
"/>")
@@ -297,7 +305,8 @@ def _spice_config(self):
297305
def _vnc_config(self):
298306
return self._build_xml(port=self.port, keymap=self.keymap,
299307
passwd=self.passwd, listen=self.listen,
300-
passwdValidTo=self.passwdValidTo)
308+
passwdValidTo=self.passwdValidTo,
309+
socket=self.socket)
301310

302311
def _get_xml_config(self):
303312
if self._type == self.TYPE_SDL:

0 commit comments

Comments
 (0)