Really this should be a <code>@staticmethod</code> since it's not manupulating <code>self</code> but another instance.  Though I wonder why do the indirect manipulation anyway, these operations can all be done on the vmxml object directly.

 How about wrapping this all up inside a <code>command_channel</code> property which takes a <code>source, target</code> tuple:  Setting it adds or changes a command-channel device.  Delete removes any existing command-channel device.  Reading from it returns a <code>(source, target)</code> tuple or None if no command-channel device exists.

If think you will find this is a more intuitive way to use the vmxml class.  It lets your test code do:

    vmxml = VMXML.new_from_dumpxml(some_name)
    ...
    if vmxml.command_channel is None:
        vmxml.command_channel = ('/var/lib/libvirt/qemu/guest.agent', 'org.qemu.guest_agent.0')
    ...
    test some things
    ...
    # Remove channel from guest XML
    del vmxml.command_channel