This extends graphics element for spice XML composing, and support sub-elements settings for audio, images, streaming and so on: <graphics type='spice' autoport='yes'> <image compression='auto_glz'/> <jpeg compression='auto'/> <zlib compression='auto'/> <playback compression='on'/> <streaming mode='filter'/> <clipboard copypaste='no'/> </graphics> --- utils/Python/xmlbuilder.py | 9 ++++++- utils/Python/xmlgenerator.py | 51 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/utils/Python/xmlbuilder.py b/utils/Python/xmlbuilder.py index 5a0f8c8..3dbe576 100644 --- a/utils/Python/xmlbuilder.py +++ b/utils/Python/xmlbuilder.py @@ -297,6 +297,13 @@ if __name__ == "__main__": params['memory'] = '1048576' params['vcpu'] = '2' params['inputbus'] = 'usb' + params['graphtype'] = 'spice' + params['image'] = 'auto_glz' + params['jpeg'] = 'auto' + params['zlib'] = 'auto' + params['playback'] = 'on' + params['streaming'] = 'filter' + params['clipboard'] = 'no' params['sound'] = 'ac97' params['bootcd'] = '/iso/rhel5.iso' @@ -367,7 +374,7 @@ if __name__ == "__main__": #---------------------------------------- # get domain snapshot xml string #---------------------------------------- - params['name'] = 'hello' + params['snapshotname'] = 'hello' params['description'] = 'hello snapshot' snapshot_xml = xmlobj.build_domain_snapshot(params) diff --git a/utils/Python/xmlgenerator.py b/utils/Python/xmlgenerator.py index d57dd33..b61ceb1 100644 --- a/utils/Python/xmlgenerator.py +++ b/utils/Python/xmlgenerator.py @@ -235,9 +235,54 @@ def domain_xml(params, install = False): # <graphics> graphics_element = domain.createElement('graphics') - graphics_element.setAttribute('type', 'vnc') - graphics_element.setAttribute('port', '-1') - graphics_element.setAttribute('keymap', 'en-us') + if not params.has_key('graphtype'): + params['graphtype'] == 'vnc' + + graphics_element.setAttribute('type', params['graphtype']) + if params['graphtype'] == 'vnc': + graphics_element.setAttribute('port', '-1') + graphics_element.setAttribute('keymap', 'en-us') + elif params['graphtype'] == 'spice': + graphics_element.setAttribute('autoport', 'yes') + if params.has_key('image'): + image_element = domain.createElement('image') + # image to set image compression (accepts + # auto_glz, auto_lz, quic, glz, lz, off) + image_element.setAttribute('compression', params['image']) + graphics_element.appendChild(image_element) + if params.has_key('jpeg'): + jpeg_element = domain.createElement('jpeg') + # jpeg for JPEG compression for images over wan (accepts + # auto, never, always) + jpeg_element.setAttribute('compression', params['jpeg']) + graphics_element.appendChild(jpeg_element) + if params.has_key('zlib'): + zlib_element = domain.createElement('zlib') + # zlib for configuring wan image compression (accepts + # auto, never, always) + zlib_element.setAttribute('compression', params['zlib']) + graphics_element.appendChild(zlib_element) + if params.has_key('playback'): + playback_element = domain.createElement('playback') + # playback for enabling audio stream compression (accepts on or off) + playback_element.setAttribute('compression', params['playback']) + graphics_element.appendChild(playback_element) + if params.has_key('streaming'): + streaming_element = domain.createElement('streaming') + # streamming for settings it's mode attribute to one of + # filter, all or off + streaming_element.setAttribute('mode', params['streaming']) + graphics_element.appendChild(streaming_element) + if params.has_key('clipboard'): + clipboard_element = domain.createElement('clipboard') + # Copy & Paste functionality is enabled by default, and can + # be disabled by setting the copypaste property to no + clipboard_element.setAttribute('copypaste', params['clipboard']) + graphics_element.appendChild(clipboard_element) + else: + print 'Wrong graphics type was specified.' + sys.exit(1) + devices_element.appendChild(graphics_element) domain_element.appendChild(devices_element) -- 1.7.4.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list