Commit Graph
100 Commits
Author SHA1 Message Date
Keir Fraser dd6832985c xenconsoled: replace gettimeofday with clock_gettime
Currently if someone changes the date on the host, xenconsoled may
behave incorrectly due to the use of gettimeofday for the rate control
algorithm. For example I was able to hang the console connected to a
guest just setting the date forward 20 years. To solve the problem we
need to use a time source that doesn't change start point, that is
clock_gettime with CLOCK_MONOTONIC. The only bad side effect is that
it introduces a dependency to librt, but I think is well worth it.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2008-07-30 09:18:35 +01:00
Keir Fraser 7eb8d34c18 tools: Declare functions static where they should be, and provide
proper prototypes for others as required.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2008-07-15 13:19:26 +01:00
Keir Fraser 461990971f tools: replace sprintf with snprintf where applicable
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2008-06-12 15:41:15 +01:00
Keir Fraser fd6c8de67e console: Provide option to stall the inter-domain console ring rather
than discard characters in the console daemon buffers.

New option: -o, --overflow-data=discard|keep

This option changes the behaviour when dealing with data that overflow
the max capacity of the buffer. If overflow-data is set to discard
(the default), the current behaviour is used: we discard some data in
the middle of the buffer.

If overflow-data is set to keep, we stop listening to the ring until
we free some space in the buffer. This can cause the ring to fill up
and the guest kernel internal buffer to fill up as well. When this
happens the guest kernel stops reading characters from the console
device so the application generating data hangs. When xenconsoled
resumes reading from the ring, the guest kernel will be able to resume
reading from the console device as well. At that point the guest
application will be allowed to continue.

The risk of making this behaviour the default is that existing kernel
drivers may assume they can rely on timely ring updates by the console
daemon and thus themselves block on the ring being emptied.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2008-04-22 10:34:55 +01:00
Keir Fraser 7b1566db12 xenconsoled: don't force newline with timestamps
Previously a newline was forced after every call to
write_with_timestamp. This could result in some ugly logs when a
single console line stretched over multiple calls. This change carries
some extra state to determine if we ended the last call to
write_with_timestamp on a newline, and prints the timestamp as
appropriate.

This also fixes a bug where logging hv messages was dependent on the
guest timestamp flag.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2008-02-20 18:00:28 +00:00
Keir Fraser 22cd908398 xenconsoled: Use ISO8601 date stamp format.
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
2008-02-15 09:51:34 +00:00
Keir Fraser 67bfbd67d1 libxenctrl headers should not pollute macro namespace with
mb/rmb/wmb. Instead add a xen_ prefix. Modify Xen's public headers to
expect the prefixed names instead of bare mb/rmb/wmb, but gate this
expectation on a bump of __XEN_INTERFACE_VERSION__.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2008-02-12 11:37:45 +00:00
Keir Fraser 2bba474f8f Add timestamp option to xenconsoled
Similar to the --log option, --timestamp or -t takes:
- none : No timestamping
- hv   : Timestamp hypervisor logs
- guest: Timestamp guest logs
- all  : Timestamp guest and hypervisor logs

From: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2008-02-12 10:16:20 +00:00
Keir Fraser 3faece79e4 Define CFLAGS and LDFLAGS for libxenstore.
Signed-off-by: Bastian Blank <waldi@debian.org>
2008-01-27 12:58:15 +00:00
Keir Fraser ad44c013ec Define CFLAGS and LDFLAGS for libxenctrl.
Signed-off-by: Bastian Blank <waldi@debian.org>
2008-01-27 12:57:14 +00:00
Keir Fraser 73de243b92 Add PRIVATE_BINDIR. Use it.
Signed-off-by: Bastian Blank <waldi@debian.org>
2008-01-26 14:42:03 +00:00
Keir Fraser be5fbf9a7f Move generation of public header hierarchy into the tools.
This patch merges the two versions of public header generation
currently used in the build into one.

Signed-off-by: Bastian Blank <waldi@debian.org>
2008-01-26 10:38:44 +00:00
Keir Fraser 93e3de7b94 Add SBINDIR. Use it always.
Signed-off-by: Bastian Blank <waldi@debian.org>
2008-01-22 14:35:02 +00:00
Keir Fraser c8107e1564 Apply PREFIX directly to LIBDIR.
Signed-off-by: Bastian Blank <waldi@debian.org>
2008-01-22 14:29:11 +00:00
Keir Fraser d2477385df tools: LDFLAGS in link lines
LDFLAGS is not honoured by a couple of link lines in tools/*, but
should be.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2008-01-17 15:17:22 +00:00
Keir Fraser 889be060b8 xenconsoled: Make slave pty raw during initialization.
(This avoids echo).

Signed-off-by: Tristan Gingold <tgingold@free.fr>
2008-01-16 13:44:18 +00:00
Keir Fraser 25d73306ec Fix master/slave handling in xenconsoled and qemu
Fix a number of problems with the pty handling:

- make openpty() implementation work on Solaris
- set raw on the slave fd, not the master, as the master doesn't
  have a line discipline pushed on Solaris
- make sure we don't leak the slave fd returned from openpty()
- don't use the 'name' argument of openpty() as it's a security risk
- note behaviour of a zero read of the master on Solaris
- remove pointless tcget/setattr

Signed-off-by: John Levon <john.levon@sun.com>
Signed-off-by: Samuel Thibault <samuel.thibault@citrix.com>
2007-12-19 14:45:45 +00:00
Keir Fraser ed8c66a1f6 Fix use-after-free in xenconsoled.
shutdown_domain() MUST NOT call cleanup_domain(), just flagging them
as dead is enough.  cleanup_domains() for dead domains is called by
the main loop in handle_io() in a safe way already.

shutdown_domain() calling cleanup_domain() too leads struct domain
being accessed after freeing and to a double-free.

Fixed by simply dropping the cleanup_domain() call and by making the
functions called by the main loop in handle_io() ignore dead domains.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2007-11-01 16:34:43 +00:00
Keir Fraser 14012a15e8 xenconsoled: Rate-limit activity caused by each domU.
Allow each domU to fire its event channel at most 30 times every 200ms.
Signed-off by: Daniel P. Berrange <berrange@redhat.com>
2007-10-29 14:43:19 +00:00
Keir Fraser ee41f1c835 Allow incremental access to hypervisor console log.
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-10-29 12:56:27 +00:00
Keir Fraser f8e2c1f126 pv-qemu 10/10: Make xenconsoled ignore doms with qemu-dm
This patch writes a field /local/vm/DOMID/console/type taking the
value 'ioemu' or 'xenconsoled'. If xenconsoled sees a type that is
not its own, then it skips handling of that guest. The qemu-dm
process doesn't need to read this field since it will only attach
to the console if given the -serial pty arg which XenD already
ensures matches this xenstore field.

The overall behaviour is that if a paravirt guest has a qemu-dm
process running then that handles the console, otherwise the
xenconsoled handles it. The former is more functional, with the
exception of not currently supporting persistent logging to a
file at the same time as exposing a PTY.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2007-10-25 14:45:47 +01:00
Keir Fraser b2ac1c4e50 xenconsoled: portability fixes:
- Use openpty(), which does the same as the sequence
   of open(), grantpt(), unlockpt(), ptsname(), tcgetattr()
   simplifies code
 - Check return code from tcsetattr()
 - sprintf() -> snprintf()
 - OpenBSD lacks POSIX grantpt() and unlockpt()
   requires use of openpty()
 - Solaris lacks POSIX openpty() via feedback from SUN (John Levon)
   implement openpty() for Solaris, tested and ok'd by SUN (John
   Levon)

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2007-10-08 10:55:50 +01:00
Keir Fraser c11a94127d Fix tools/console to build on NetBSD.
- include headers needed to build on NetBSD
 - Remove unused pty.h
 - Initialize spty terminal before actually using it

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2007-09-20 16:02:22 +01:00
Keir Fraser 3f96f21796 xenconsoled: improve robustness of logfile handling
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>
2007-06-27 21:05:54 +01:00
kfraser@localhost.localdomain ff2fc71eda tools: warn_unused_result build fixes.
Note that some of the existing error checking for asprintf was wrong
for Linux.  asprintf in glibc returns -1 on error, but leaves the
pointer uninitialized.  Only the BSDs zero out the pointer on error.

Also, while fixing these warnings I saw several error paths that were
incorrect.  This patch minimally fixes the warn_unused_result; more
complete error path cleanup will be a later patch.

Signed-off-by:  Charles Coffing <ccoffing@novell.com>
2007-06-12 11:38:31 +01:00
kfraser@localhost.localdomain c3a5cde516 tools: Fix some type issues GCC 4.1.0 warnings.
FC5's gcc 4.1.0 can't make some files in tools/ due to its stronger
type checking.

From: Dexuan Cui <dexuan.cui@intel.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-06-07 11:02:23 +01:00
kfraser@localhost.localdomain 5238d5a2f0 console daemon: Fix realloc() usage.
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-06-05 10:00:15 +01:00
kfraser@localhost.localdomain 96763f7c9a Add persistent guest & hv logging in xenconsoled.
* The  --log  command line argument takes one of 4 values

      - none   - no logging   (the default)
      - hv     - log all hypervisor messages
      - guest  - log all guest messages
      - both   - log all guest & hypervisor messages

  * The --log-dir command line argument takes a path to specify where
    to store logfiles. If omitted it defaults to /var/log/xen/console

  * The hypervisor logfile is $LOGDIR/hypervisor.log

  * The guest logfile is  $LOGDIR/guest-[NAME].log

  * If receiving a SIGHUP it will close & re-open all log files to
    enable logrotate to do its magic

  * Fixes the permissions of /var/run/xenconsoled.pid

  * Adds a --pid-file command line argument to override the default
    location of pid file (this is not really related to logging, but
    since I was in that code...)

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2007-06-04 14:49:12 +01:00
kfraser@localhost.localdomain ff3ee91914 Console daemon - remove duplicate include.
Signed-off-by: Mats Petersson <mats.petersson@amd.com>
2007-05-24 13:58:01 +01:00
Christian Limpach 596f933f56 [pv console] Move console information in xenstore to serial/0/.
Support information in console/ in a backwards compatible fashion.
This puts the serial port information for pv domains at the same
location where it is for hvm domains.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
2007-05-01 14:17:01 +01:00
kfraser@localhost.localdomain 9de4f0c67d tools: Clean up use of 'install' command.
- convert raw "install" command to use $(INSTALL)
- convert some $(INSTALL) to $(INSTALL_DATA) as appropriate
- modify the specific $(INSTALL) definitions to use -p.

Original patch by Ben Thomas <ben@virtualiron.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-03-07 10:49:20 +00:00
john.levon@sun.com 90a79f7c6f Xenconsoled should ignore spurious watch event. Otherwise, it can rebind to the same evtchn of a dying domU during suspending and cause below error message:
(XEN) event_channel.c:177:d0 EVTCHNOP failure: domain 0, error -22, line 177
2007-02-19 20:44:42 -08:00
Tim Deegan 7f39243d68 [PYGRUB] Plumb bootloader I/O through xenconsole.
- xend forwards console traffic between the running bootloader and a pty
   which it writes to the store so the xenconsole client can see it.
 - the xenconsole client handles the domain's console pty changing.
 - xm create no longer runs the bootloader.
 - pygrub gets '-i' option to explicitly request an interactive session.
 - xend unlocks the domain list during bootloading so that "xm console"
   can see the domain and attach to its console pty.

Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
2007-01-22 11:49:14 +00:00
kfraser@localhost.localdomain 2004d63d13 Stop enforcing -g for some of the tools.
Signed-off-by: John Levon <john.levon@sun.com>
2006-10-31 18:24:57 +00:00
kfraser@localhost.localdomain 2d0b60a90f [SOLARIS] A couple of simple compile fixes for tools/ on Solaris.
Signed-off-by: John Levon <john.levon@sun.com>
2006-10-17 18:15:59 +01:00
kfraser@localhost.localdomain d61113c5c7 [SOLARIS] On Solaris, GCC is configured to use Sun's LD. Fix the build to use
the correct flags, and link against libsocket where necessary.

Signed-off-by: John Levon <john.levon@sun.com>
2006-10-17 17:17:57 +01:00
kfraser@localhost.localdomain 6311dc03da Clean up duplication of 'install' macros in the Makefiles.
Signed-off-by: John Levon <john.levon@sun.com>
2006-10-17 15:57:05 +01:00
kaf24@firebug.cl.cam.ac.uk 80f2588d2b [CONSOLED] Shouldn't call domain_create_ring() for a domU which is shutting down.
There is a race condition between domain_create_ring() and the removal
of the domU entry from xenstore. If the removal of the domU entry from xenstore
comes later than the first xs_gather() call in domain_create_ring(), it will go
on and bind the evtchn port to the dying domU, which will cause below error
message: (XEN) (file=event_channel.c, line=144) EVTCHNOP failure: domain 0, error -22, line 144

Signed-off-by: Max Zhen <max.zhen@sun.com>
2006-09-13 14:01:23 +01:00
Ewan Mellor 8037b37752 This patch improves error message of xm console command.
# xm console Domain-0
Can't specify Domain-0

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
2006-09-05 17:06:01 +01:00
kaf24@localhost.localdomain 2b1e704734 The following patch fixes a bug where xenconsoled will can SEGV
because it uses FD_ISSET(-1,xxx).  Since the code is written that any
ring/tty handler can set d->tty_fd to -1 it has to be checked
_every_time_.

Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
2006-08-28 12:50:55 +01:00
kaf24@firebug.cl.cam.ac.uk 76f880fe7d [TOOLS] Introduce xc_evtchn_*() interface for interacting with /dev/xen/evtchn.
No longer open the device as non-blocking: all reads immediately follow
a select() on the device indicating it's ready to read.

Signed-off-by: John Levon <john.levon@sun.com>
2006-06-15 13:11:31 +01:00
kaf24@firebug.cl.cam.ac.uk b5fa90ac8e build: Clean up use of .PHONY
* Move .PHONY directives next to targets,
  this makes them a lot harder to miss
* Add missing .PHONY directives
* Remove nonexistent .PHONY directives
* Hopefully I didn'T miss anything...

Signed-Off-By: Horms <horms@verge.net.au>
2006-04-10 17:02:49 +01:00
kaf24@firebug.cl.cam.ac.uk 6daae768eb Remove some dead code from the consoled client.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2006-04-03 17:48:39 +01:00
kaf24@firebug.cl.cam.ac.uk 5707afc46f Fix xenconsoled when sending lots of console data to a domU.
Fixes bug #477.

Signed-off-by: Keir Fraser <keir@xensource.com>
2006-03-30 11:38:56 +01:00
emellor@leeni.uk.xensource.com ef1189d806 Increase timeout while waiting for console/tty node to appear in the store:
the intention appears to have been 500msec, but struct timeval when used with
a select() is in usec, not msec.  The timeout has been set to 250msec (500msec
seems a little long, in any case).

Signed-off-by: Ewan Mellor <ewan@xensource.com>
2006-03-21 11:56:11 +01:00
kaf24@firebug.cl.cam.ac.uk d27fbb0061 Move 'debug' build option into the outermost Config.mk file.
Signed-off-by: Keir Fraser <keir@xensource.com>
2006-03-09 22:31:45 +01:00
kaf24@firebug.cl.cam.ac.uk 326450f67e Clean up the usage of CFLAGS. This is nice for packagers, who would
like to control the base compilation flags from a central place.

Signed-off-by: Charles Coffing <ccoffing@novell.com>
2006-03-09 21:17:45 +01:00
vhanquez@kneesa.uk.xensource.com e92fb45b06 Replace NULL xenbus transaction by a specific XBT_NULL value.
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
2006-01-10 15:05:05 +00:00
Anthony Liguori d4895766cb Make sure to fork again after setsid() so that child cannot regain CTTY.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2005-12-12 15:11:13 +00:00
emellor@leeni.uk.xensource.com 497ff155b3 Remove timeout on select -- there is no need for it, since we don't do anything
in the main loop except service I/O.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
2005-12-07 11:47:46 +00:00