提交 29bce12a 编写于 作者: M Michal Privoznik

qemu_agent: Create file system freeze and thaw functions

These functions simply issue command to guest agent which
should freeze or unfreeze all file systems within guest.
上级 24a00149
...@@ -1110,3 +1110,77 @@ int qemuAgentShutdown(qemuAgentPtr mon, ...@@ -1110,3 +1110,77 @@ int qemuAgentShutdown(qemuAgentPtr mon,
virJSONValueFree(reply); virJSONValueFree(reply);
return ret; return ret;
} }
/*
* qemuAgentFSFreeze:
* @mon: Agent
*
* Issue guest-fsfreeze-freeze command to guest agent,
* which freezes all mounted file systems and returns
* number of frozen file systems on success.
*
* Returns: number of file system frozen on success,
* -1 on error.
*/
int qemuAgentFSFreeze(qemuAgentPtr mon)
{
int ret = -1;
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
cmd = qemuAgentMakeCommand("guest-fsfreeze-freeze", NULL);
if (!cmd)
return -1;
if (qemuAgentCommand(mon, cmd, &reply) < 0 ||
qemuAgentCheckError(cmd, reply) < 0)
goto cleanup;
if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed return value"));
}
cleanup:
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
}
/*
* qemuAgentFSThaw:
* @mon: Agent
*
* Issue guest-fsfreeze-thaw command to guest agent,
* which unfreezes all mounted file systems and returns
* number of thawed file systems on success.
*
* Returns: number of file system thawed on success,
* -1 on error.
*/
int qemuAgentFSThaw(qemuAgentPtr mon)
{
int ret = -1;
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
cmd = qemuAgentMakeCommand("guest-fsfreeze-thaw", NULL);
if (!cmd)
return -1;
if (qemuAgentCommand(mon, cmd, &reply) < 0 ||
qemuAgentCheckError(cmd, reply) < 0)
goto cleanup;
if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed return value"));
}
cleanup:
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
}
...@@ -66,4 +66,7 @@ typedef enum { ...@@ -66,4 +66,7 @@ typedef enum {
int qemuAgentShutdown(qemuAgentPtr mon, int qemuAgentShutdown(qemuAgentPtr mon,
qemuAgentShutdownMode mode); qemuAgentShutdownMode mode);
int qemuAgentFSFreeze(qemuAgentPtr mon);
int qemuAgentFSThaw(qemuAgentPtr mon);
#endif /* __QEMU_AGENT_H__ */ #endif /* __QEMU_AGENT_H__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册