[tip:tools/kvm] kvm tools: carefully send and handle pause/ resume ipc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  a286377ac7a44c9f24f1cfb42b356045e92e20f5
Gitweb:     http://git.kernel.org/tip/a286377ac7a44c9f24f1cfb42b356045e92e20f5
Author:     Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
AuthorDate: Tue, 20 Dec 2011 17:08:56 +0800
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Wed, 21 Dec 2011 22:28:09 +0200

kvm tools: carefully send and handle pause/resume ipc

Remove struct pause_cmd/resume_cmd and use kvm_ipc__send().

Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/builtin-pause.c  |   14 +-------------
 tools/kvm/builtin-resume.c |   14 +-------------
 tools/kvm/builtin-run.c    |    7 ++++++-
 3 files changed, 8 insertions(+), 27 deletions(-)

diff --git a/tools/kvm/builtin-pause.c b/tools/kvm/builtin-pause.c
index eb89ff7..ee5a5b8 100644
--- a/tools/kvm/builtin-pause.c
+++ b/tools/kvm/builtin-pause.c
@@ -9,11 +9,6 @@
 #include <string.h>
 #include <signal.h>
 
-struct pause_cmd {
-	u32 type;
-	u32 len;
-};
-
 static bool all;
 static const char *instance_name;
 
@@ -46,14 +41,7 @@ void kvm_pause_help(void)
 
 static int do_pause(const char *name, int sock)
 {
-	struct pause_cmd cmd = {KVM_IPC_PAUSE, 0};
-	int r;
-
-	r = write(sock, &cmd, sizeof(cmd));
-	if (r < 0)
-		return r;
-
-	return 0;
+	return kvm_ipc__send(sock, KVM_IPC_PAUSE);
 }
 
 int kvm_cmd_pause(int argc, const char **argv, const char *prefix)
diff --git a/tools/kvm/builtin-resume.c b/tools/kvm/builtin-resume.c
index 33ccc2b..9c47183 100644
--- a/tools/kvm/builtin-resume.c
+++ b/tools/kvm/builtin-resume.c
@@ -9,11 +9,6 @@
 #include <string.h>
 #include <signal.h>
 
-struct resume_cmd {
-	u32 type;
-	u32 len;
-};
-
 static bool all;
 static const char *instance_name;
 
@@ -46,14 +41,7 @@ void kvm_resume_help(void)
 
 static int do_resume(const char *name, int sock)
 {
-	struct resume_cmd cmd = {KVM_IPC_RESUME, 0};
-	int r;
-
-	r = write(sock, &cmd, sizeof(cmd));
-	if (r < 0)
-		return r;
-
-	return 0;
+	return kvm_ipc__send(sock, KVM_IPC_RESUME);
 }
 
 int kvm_cmd_resume(int argc, const char **argv, const char *prefix)
diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 3e28770..a94fdbc 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -507,12 +507,17 @@ static int is_paused;
 
 static void handle_pause(int fd, u32 type, u32 len, u8 *msg)
 {
+	if (WARN_ON(len))
+		return;
+
 	if (type == KVM_IPC_RESUME && is_paused)
 		kvm__continue();
 	else if (type == KVM_IPC_PAUSE && !is_paused)
 		kvm__pause();
-	else
+	else {
+		WARN_ON(1);
 		return;
+	}
 
 	is_paused = !is_paused;
 	pr_info("Guest %s\n", is_paused ? "paused" : "resumed");
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux