def _correct_listen_addr(self, old_xml_str, listen_addrs):
    xml_doc = etree.fromstring(old_xml_str)
    for dev in xml_doc.findall('./devices/graphics'):
        gr_type = dev.get('type')
        listen_tag = dev.find('listen')
        if (gr_type in ('vnc', 'spice')):
            if (listen_tag is not None):
                listen_tag.set('address', listen_addrs[gr_type])
            if (dev.get('listen') is not None):
                dev.set('listen', listen_addrs[gr_type])
    return etree.tostring(xml_doc)
def _correct_listen_addr(self, old_xml_str, listen_addrs):
    xml_doc = etree.fromstring(old_xml_str)
    for dev in xml_doc.findall('./devices/graphics'):
        gr_type = dev.get('type')
        listen_tag = dev.find('listen')
        if (gr_type in ('vnc', 'spice')):
            if (listen_tag is not None):
                listen_tag.set('address', listen_addrs[gr_type])
            if (dev.get('listen') is not None):
                dev.set('listen', listen_addrs[gr_type])
    return etree.tostring(xml_doc)