def find_device_guest_address(dev): """ Find the guest-visible address of a device. With respect to vmxml.device_address(), this function will always and only look for the guest address; on the other hand, vmxml.device_address() will always report the first address it finds. Consider this case: <dev> <source> <address>SRC_ADDR</address> </source> </dev> vmxml.device_address() returns SRC_ADDR this function will return None Consider this case: <dev> <address>GST_ADDR</address> <source> <address>SRC_ADDR</address> </source> </dev> vmxml.device_address() returns GST_ADDR this function will return GST_ADDR as well. """ addr = dev.find('./address') if addr is None: return None return vmxml.parse_address_element(addr)