Add state check to virt_query