提交 4301b95a 编写于 作者: J Jim Fehlig

[v2] qemu: Retry JSON monitor cont cmd on MigrationExpected error

When restoring a saved qemu instance via JSON monitor, the vm is
left in a paused state.  Turns out the 'cont' cmd was failing with
"MigrationExpected" error class and "An incoming migration is
expected before this command can be executed" error description
due to migration (restore) not yet complete.

Detect if 'cont' cmd fails with "MigrationExpecte" error class and
retry 'cont' cmd.

V2: Fix potential double-free noted by Laine Stump
上级 af268f2a
...@@ -702,13 +702,29 @@ qemuMonitorJSONStartCPUs(qemuMonitorPtr mon, ...@@ -702,13 +702,29 @@ qemuMonitorJSONStartCPUs(qemuMonitorPtr mon,
int ret; int ret;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("cont", NULL); virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("cont", NULL);
virJSONValuePtr reply = NULL; virJSONValuePtr reply = NULL;
int i = 0, timeout = 3;
if (!cmd) if (!cmd)
return -1; return -1;
ret = qemuMonitorJSONCommand(mon, cmd, &reply); do {
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
if (ret == 0) if (ret != 0)
ret = qemuMonitorJSONCheckError(cmd, reply); break;
/* If no error, we're done */
if ((ret = qemuMonitorJSONCheckError(cmd, reply)) == 0)
break;
/* If error class is not MigrationExpected, we're done.
* Otherwise try 'cont' cmd again */
if (!qemuMonitorJSONHasError(reply, "MigrationExpected"))
break;
virJSONValueFree(reply);
reply = NULL;
usleep(250000);
} while (++i <= timeout);
virJSONValueFree(cmd); virJSONValueFree(cmd);
virJSONValueFree(reply); virJSONValueFree(reply);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册