]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_agent: Create file system freeze and thaw functions
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 24 Jan 2012 20:13:40 +0000 (21:13 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 25 Jan 2012 09:59:41 +0000 (10:59 +0100)
These functions simply issue command to guest agent which
should freeze or unfreeze all file systems within guest.

src/qemu/qemu_agent.c
src/qemu/qemu_agent.h

index 6a7c7b34ad20df1cbb1feba6ba97211ba50dc7cd..9df5546d54fa008228b32ef32f2ba34a50586712 100644 (file)
@@ -1110,3 +1110,77 @@ int qemuAgentShutdown(qemuAgentPtr mon,
     virJSONValueFree(reply);
     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;
+}
index 93c2ae7e2f0c7afae8ddd9ca76a2ac16c3d1c6be..df59ef7fe8f53d5901f0df2b536ae4db9f62658c 100644 (file)
@@ -66,4 +66,7 @@ typedef enum {
 int qemuAgentShutdown(qemuAgentPtr mon,
                       qemuAgentShutdownMode mode);
 
+int qemuAgentFSFreeze(qemuAgentPtr mon);
+int qemuAgentFSThaw(qemuAgentPtr mon);
+
 #endif /* __QEMU_AGENT_H__ */