refactor code to split off libvirt functions; add more metrics