All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: xen-devel@lists.xensource.com
Subject: PATCH: improve robustness of xenconsoled logfile handling
Date: Tue, 26 Jun 2007 20:48:58 +0100	[thread overview]
Message-ID: <20070626194858.GE6220@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]

Attached is an small patch to xenconsoled to make the persistent logging
code I previously added a little more robust. First change is to check 
the 'log_reload' on every iteration of the select() loop, not just when
select() returns EINTR. This is because the log reload signal may have
iterrupted a syscall other than select & thus without this change  we
might miss the reload signal.  The second change makes us process the
hypervisor logs on every iteration of the loop, not just upon timeouts.
This is because if a guest VM were consistently sending some log message
and < 1 second period, the select() would never hit the 1 second timeout
and thus never process the HV logs. 

Thanks to Markus Armbruster for pointing out both these edge cases

   Signed-off-by: Daniel P. Berrange <berrange@redhat.com>


 io.c |   30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)


Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

[-- Attachment #2: xen-console-log-paranoia.patch --]
[-- Type: text/plain, Size: 1336 bytes --]

diff -r 9261686d840c tools/console/daemon/io.c
--- a/tools/console/daemon/io.c	Tue Jun 26 12:40:37 2007 +0100
+++ b/tools/console/daemon/io.c	Tue Jun 26 15:36:36 2007 -0400
@@ -766,23 +766,27 @@ void handle_io(void)
 		 * for new HV log data as we can with guest */
 		ret = select(max_fd + 1, &readfds, &writefds, 0, log_hv_fd != -1 ? &timeout : NULL);
 
+		if (log_reload) {
+			handle_log_reload();
+			log_reload = 0;
+		}
+
+		/* Abort if select failed, except for EINTR cases
+		   which indicate a possible log reload */
 		if (ret == -1) {
-			if (errno == EINTR) {
-				if (log_reload) {
-					handle_log_reload();
-					log_reload = 0;
-				}
+			if (errno == EINTR)
 				continue;
-			}
 			dolog(LOG_ERR, "Failure in select: %d (%s)",
 			      errno, strerror(errno));
 			break;
 		}
 
-		/* Check for timeout */
+		/* Always process HV logs even if not a timeout */
+		if (log_hv_fd != -1)
+			handle_hv_logs();
+
+		/* Must not check returned FDSET if it was a timeout */
 		if (ret == 0) {
-			if (log_hv_fd != -1)
-				handle_hv_logs();
 			continue;
 		}
 
@@ -806,10 +810,14 @@ void handle_io(void)
 		}
 	}
 
-	if (log_hv_fd != -1)
+	if (log_hv_fd != -1) {
 		close(log_hv_fd);
-	if (xc_handle != -1)
+		log_hv_fd = -1;
+	}
+	if (xc_handle != -1) {
 		xc_interface_close(xc_handle);
+		xc_handle = -1;
+	}
 }
 
 /*

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2007-06-26 19:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20070626194858.GE6220@redhat.com \
    --to=berrange@redhat.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.