While trying to test this tiny script on rawhide,
http://hg.et.redhat.com/virt/websites/ovirt-web--devel?f=e4f3ee8de5a1;fil...
I was surprised to see I couldn't provoke this failure:
echo 1>&2 "$0: you seem to have already run this script"; exit 1; }
The idea is to dump xml, insert 4 lines describing a bridge,
and use virsh "define" to apply the new definition.
However, that last step doesn't seem to work, even though
virsh exits successfully.
If the new XML is somehow insufficient, the least it could
do is give a diagnostic. Otherwise it has to honor the request.
# cat $tmpfile
<domain type='kvm' id='1'>
<name>developer</name>
<uuid>f2af0696-77ea-dd8f-3f6c-cf3f38d5216e</uuid>
<memory>524288</memory>
<currentMemory>524288</currentMemory>
<vcpu>1</vcpu>
<os>
<type>hvm</type>
<boot dev='cdrom'/>
</os>
<features>
<acpi/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<disk type='file' device='disk'>
<source file='/var/lib/libvirt/images/developer.img'/>
<target dev='hda'/>
</disk>
<disk type='file' device='cdrom'>
<source file='/var/lib/libvirt/images/Fedora-8-x86_64-rescuecd.iso'/>
<target dev='hdc'/>
<readonly/>
</disk>
<interface type='network'>
<mac address='00:16:3e:46:e2:8a'/>
<source network='default'/>
<target dev='vnet0'/>
</interface>
<interface type="bridge">
<mac address="00:16:3e:12:34:56"/>
<source bridge="dummybridge"/>
</interface>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='5900' listen='127.0.0.1'/>
</devices>
</domain>
# virsh -c qemu:///system define "$tmpfile"
Domain developer defined from /t/jt2884.FGSiY6/tmp.JVPZ4LBMVf
# virsh -c qemu:///system dumpxml developer
<domain type='kvm' id='1'>
<name>developer</name>
<uuid>f2af0696-77ea-dd8f-3f6c-cf3f38d5216e</uuid>
<memory>524288</memory>
<currentMemory>524288</currentMemory>
<vcpu>1</vcpu>
<os>
<type>hvm</type>
<boot dev='cdrom'/>
</os>
<features>
<acpi/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<disk type='file' device='disk'>
<source file='/var/lib/libvirt/images/developer.img'/>
<target dev='hda'/>
</disk>
<disk type='file' device='cdrom'>
<source file='/var/lib/libvirt/images/Fedora-8-x86_64-rescuecd.iso'/>
<target dev='hdc'/>
<readonly/>
</disk>
<interface type='network'>
<mac address='00:16:3e:46:e2:8a'/>
<source network='default'/>
<target dev='vnet0'/>
</interface>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='5900' listen='127.0.0.1'/>
</devices>
</domain>