Commit a8cef189 authored by Alain Takoudjou's avatar Alain Takoudjou

qemu qmp: wait until drive-backup is finished before exit

qmp drive-backup command should exit when qemu has finished to backup image
else image is copied when qemu is still writing and result to a broken backup

If qemu return error in command, raise instead of silent exit with code 0
parent 186aed86
......@@ -92,7 +92,11 @@ class QemuQMPWrapper(object):
try:
return json.loads(data)
except ValueError:
print 'Wrong data: %s' % data
# if error the raise
if "error" in data:
raise Exception('ERROR: %s' % data)
else:
print 'Wrong data: %s' % data
def _getVMStatus(self):
response = self._send({'execute': 'query-status'})
......@@ -134,6 +138,11 @@ class QemuQMPWrapper(object):
def _getRunningJobList(self, device):
result = self._queryBlockJobs(device)
while result is None:
# If result is None retry to command until if return something.
time.sleep(3)
result = self._queryBlockJobs(device)
if result.get('return'):
return result['return']
else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment