qemu-iotests: Improve and make use of QMPTestCase.wait_until_completed()

This eliminates code duplication.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>