diff --git a/libvirt.spec.in b/libvirt.spec.in index 37a9ea48cb..c2e2be4a83 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1728,8 +1728,37 @@ fi %if %{with_network} %post daemon-config-network if test $1 -eq 1 && test ! -f %{_sysconfdir}/libvirt/qemu/networks/default.xml ; then + # see if the network used by default network creates a conflict, + # and try to resolve it + # NB: 192.168.122.0/24 is used in the default.xml template file; + # do not modify any of those values here without also modifying + # them in the template. + orig_sub=122 + sub=${orig_sub} + nl=' +' + routes="${nl}$(ip route show | cut -d' ' -f1)" + case ${routes} in + *"${nl}192.168.${orig_sub}.0/24${nl}"*) + # there was a match, so we need to look for an unused subnet + for new_sub in $(seq 124 254); do + case ${routes} in + *"${nl}192.168.${new_sub}.0/24${nl}"*) + ;; + *) + sub=$new_sub + break; + ;; + esac + done + ;; + *) + ;; + esac + UUID=`/usr/bin/uuidgen` - sed -e "s,,\n $UUID," \ + sed -e "s/${orig_sub}/${sub}/g" \ + -e "s,,\n $UUID," \ < %{_datadir}/libvirt/networks/default.xml \ > %{_sysconfdir}/libvirt/qemu/networks/default.xml ln -s ../default.xml %{_sysconfdir}/libvirt/qemu/networks/autostart/default.xml