[tip:tools/kvm] kvm tools: carefully send and handle balloon stat ipc

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

 



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

kvm tools: carefully send and handle balloon stat ipc

Remove struct stat_cmd and use kvm_ipc__send().

Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/builtin-stat.c   |    8 +-------
 tools/kvm/virtio/balloon.c |    3 +++
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/tools/kvm/builtin-stat.c b/tools/kvm/builtin-stat.c
index 855cc89..ffd72e8 100644
--- a/tools/kvm/builtin-stat.c
+++ b/tools/kvm/builtin-stat.c
@@ -12,11 +12,6 @@
 
 #include <linux/virtio_balloon.h>
 
-struct stat_cmd {
-	u32 type;
-	u32 len;
-};
-
 static bool mem;
 static bool all;
 static const char *instance_name;
@@ -52,7 +47,6 @@ void kvm_stat_help(void)
 
 static int do_memstat(const char *name, int sock)
 {
-	struct stat_cmd cmd = {KVM_IPC_STAT, 0};
 	struct virtio_balloon_stat stats[VIRTIO_BALLOON_S_NR];
 	fd_set fdset;
 	struct timeval t = { .tv_sec = 1 };
@@ -61,7 +55,7 @@ static int do_memstat(const char *name, int sock)
 
 	FD_ZERO(&fdset);
 	FD_SET(sock, &fdset);
-	r = write(sock, &cmd, sizeof(cmd));
+	r = kvm_ipc__send(sock, KVM_IPC_STAT);
 	if (r < 0)
 		return r;
 
diff --git a/tools/kvm/virtio/balloon.c b/tools/kvm/virtio/balloon.c
index bd984b7..09044d0 100644
--- a/tools/kvm/virtio/balloon.c
+++ b/tools/kvm/virtio/balloon.c
@@ -144,6 +144,9 @@ static void virtio_bln__print_stats(int fd, u32 type, u32 len, u8 *msg)
 {
 	int r;
 
+	if (WARN_ON(type != KVM_IPC_STAT || len))
+		return;
+
 	if (virtio_bln__collect_stats() < 0)
 		return;
 
--
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