Make tools/utils scripts generic

We've had some utility scripts slightly out of sync between `virt-test` and `autotest`. This is an attempt to unify them.