[libvirt] [PATCHv2 7/7] qemu: monitor: Refactor and fix monitor checking