From: Asias He <asias.hejun@gmail.com>
To: Pekka Enberg <penberg@kernel.org>
Cc: Sasha Levin <levinsasha928@gmail.com>,
Cyrill Gorcunov <gorcunov@gmail.com>, Ingo Molnar <mingo@elte.hu>,
kvm@vger.kernel.org, Asias He <asias.hejun@gmail.com>
Subject: [PATCH 1/6] kvm tools: Handle multiple IPC cmd at a time
Date: Thu, 22 Dec 2011 10:10:42 +0800 [thread overview]
Message-ID: <1324519847-19897-1-git-send-email-asias.hejun@gmail.com> (raw)
This is useful when client submiting multiple IPC cmd in one socket
connection.
Signed-off-by: Asias He <asias.hejun@gmail.com>
---
tools/kvm/kvm-ipc.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/tools/kvm/kvm-ipc.c b/tools/kvm/kvm-ipc.c
index 2036b91..dbe2363 100644
--- a/tools/kvm/kvm-ipc.c
+++ b/tools/kvm/kvm-ipc.c
@@ -102,7 +102,7 @@ static void kvm_ipc__close_conn(int fd)
close(fd);
}
-static void kvm_ipc__receive(int fd)
+static int kvm_ipc__receive(int fd)
{
struct kvm_ipc_head head;
u8 *msg = NULL;
@@ -122,8 +122,11 @@ static void kvm_ipc__receive(int fd)
kvm_ipc__handle(fd, head.type, head.len, msg);
+ return 0;
+
done:
free(msg);
+ return -1;
}
static void *kvm_ipc__thread(void *param)
@@ -140,10 +143,16 @@ static void *kvm_ipc__thread(void *param)
if (fd == stop_fd && event.events & EPOLLIN) {
break;
} else if (fd == server_fd) {
- int client;
+ int client, r;
client = kvm_ipc__new_conn(fd);
- kvm_ipc__receive(client);
+ /*
+ * Handle multiple IPC cmd at a time
+ */
+ do {
+ r = kvm_ipc__receive(client);
+ } while (r == 0);
+
} else if (event.events && (EPOLLERR | EPOLLRDHUP | EPOLLHUP)) {
kvm_ipc__close_conn(fd);
} else {
--
1.7.7.3
next reply other threads:[~2011-12-22 2:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-22 2:10 Asias He [this message]
2011-12-22 2:10 ` [PATCH 2/6] kvm tools: Introduce KVM_IPC_VMSTATE IPC cmd Asias He
2011-12-22 2:10 ` [PATCH 3/6] kvm tools: Respect paused status in ./lkvm list Asias He
2011-12-22 2:10 ` [PATCH 4/6] kvm tools: Improve 'lkvm {pause,resume}'s output Asias He
2011-12-22 2:10 ` [PATCH 5/6] kvm tools: Remove resume pause noise Asias He
2011-12-22 2:10 ` [PATCH 6/6] kvm tools: Use kvm_ipc__send to send IPC msg Asias He
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1324519847-19897-1-git-send-email-asias.hejun@gmail.com \
--to=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=mingo@elte.hu \
--cc=penberg@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).