[libvirt] [PATCHv3] qemu: monitor: Refactor and fix monitor checking