On 09/19/2011 04:32 PM, Lon Hohberger wrote:
> On 09/13/2011 04:44 AM, Kazunori INOUE wrote:
>
>> I attached the patch for this problem.
>>
>> * Modified to send a SIGHUP to the primary thread from the secondary
>> thread detects the start of the VM, and
>> the primary thread is modified so as to select() the requests from
>> the VM which started.
>
> That's certainly one way of doing it. I might have used
> 'pthread_cond_singal'.
I am sorry for the delay.
I have a fix based on yours that uses a pipe to wake up select() rather
than pthread_kill; I'll attach it here. This ends up being a bit lower
impact, as well; it doesn't require changing the main program - only the
serial/vmchannel plugin.
Apart from that, the patch here is largely the same.
Let me know what you think at your convenience.
-- Lon
From 5a9431e16e23ea24f5d86a17a83e4edc3f112afd Mon Sep 17 00:00:00 2001
From: Lon Hohberger <lon@users.sourceforge.net>
Date: Tue, 25 Oct 2011 19:29:24 -0400
Subject: [PATCH] Fix serial domain handling
+ /*
+ * See if the goal was just to be woken up in order to refill our
+ * file descriptor set. For example, if multiple domains were
+ * created simultaneously, we would have to refill our fd_set
+ */
+ if (FD_ISSET(info->wake_fd, &rfds)) {
+ tv.tv_sec = 0;
+ tv.tv_usec = 10000;
+ _read_retry(info->wake_fd, &c, 1, &tv);
+ return 0;
+ }
+
/*
* If no requests, we're done
*/
@@ -392,7 +409,7 @@ serial_init(listener_context_t *c, const fence_callbacks_t *cb,
info->magic = SERIAL_PLUG_MAGIC;
info->history = history_init(check_history, 10, sizeof(fence_req_t));
*c = (listener_context_t)info;
- start_event_listener(info->uri, info->path, info->mode);
+ start_event_listener(info->uri, info->path, info->mode, &info->wake_fd);
sleep(1);
return 0;
diff --git a/server/serial.h b/server/serial.h
index 0b3e480..fb8e575 100644
--- a/server/serial.h
+++ b/server/serial.h
@@ -13,7 +13,7 @@ int domain_sock_name(int fd, char *outbuf, size_t buflen);
int domain_sock_cleanup(void);
/* virt-serial.c - event thread control functions */
-int start_event_listener(const char *uri, const char *path, int mode);
+int start_event_listener(const char *uri, const char *path, int mode, int *wake_fd);
int stop_event_listener(void);
/* Add 2 callbacks to prove this works with more than just one */
- memset(&dinfo, 0, sizeof (dinfo));
- dinfo.event = VIR_DOMAIN_EVENT_UNDEFINED;
callback1ret =
virConnectDomainEventRegister(dconn, myDomainEventCallback1,
- &dinfo, NULL);
+ arg, NULL);
if ((callback1ret == 0)) {
while (run) {
@@ -469,18 +471,6 @@ event_thread(void *arg)
t_cb(t_timeout, t_opaque);
}