aboutsummaryrefslogtreecommitdiffstats
path: root/tools/console/daemon
Commit message (Collapse)AuthorAgeFilesLines
* xenconsoled: use array index to keep track of pollfdWei Liu2013-03-251-31/+35
| | | | | | | | | | | | | If we use pointers to reference elements inside array, it is possible that we get wild pointer after realloc(3) copies array and returns a new pointer. Keep track of element indexes inside the array can solve this problem. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Cc: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Marcus Granado <marcus.granado@citrix.com> Tested-by: Marcus Granado <marcus.granado@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* tools/xenconsoled: Initialise pointers before trying to use themAndrew Cooper2013-03-071-11/+1
| | | | | | | | | | | | | | | | This is a regression introduced by "Switch from select() to poll() in xenconsoled's IO loop." hg c/s 26405:7359c3122c5d git cc5434c933153c4b8812d1df901f8915c22830a8 which results in reliable segfaults during VM power operations. Switch to calloc(3) in an effort to avoid similar problems with changes in the future. Signed-off-by: Marcus Granado <marcus.granado@citrix.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
* xenconsoled: use grant references instead of map_foreign_rangeDaniel De Graaf2013-01-173-10/+42
| | | | | | | | | | | | | | | Grant references for the xenstore and xenconsole shared pages exist, but currently only xenstore uses these references. Change the xenconsole daemon to prefer using the grant reference over map_foreign_range when mapping the shared console ring. This allows xenconsoled to be run in a domain other than dom0 if set up correctly - for libxl, the xenstore path /tool/xenconsoled/domid specifies the domain containing xenconsoled. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* Switch from select() to poll() in xenconsoled's IO loopWei Liu2013-01-171-72/+140
| | | | | | | | | | | | | | | | | | | In Linux select() typically supports up to 1024 file descriptors. This can be a problem when user tries to boot up many guests. Switching to poll() has minimum impact on existing code and has better scalibility. pollfd array is dynamically allocated / reallocated. If the array fails to expand, we just ignore the incoming fd. Updated: reset *_pollfd after use. This fixes regression 14869. Also remove unused slave_pollfd in strcut domain. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* Revert 0b9dfd067b42: Switch from select() to poll() in xenconsoled's IO loopIan Campbell2013-01-131-136/+73
| | | | | | Causes issues with migration etc in test flight 14869 onwards. Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
* Switch from select() to poll() in xenconsoled's IO loopWei Liu2013-01-111-73/+136
| | | | | | | | | | | | | In Linux select() typically supports up to 1024 file descriptors. This can be a problem when user tries to boot up many guests. Switching to poll() has minimum impact on existing code and has better scalibility. pollfd array is dynamically allocated / reallocated. If the array fails to expand, we just ignore the incoming fd. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* xenconsoled: clean-up after all dead domainsDavid Vrabel2012-08-311-1/+11
| | | | | | | | | | | | | | | | | | | | | | | xenconsoled expected domains that are being shutdown to end up in the the DYING state and would only clean-up such domains. HVM domains either didn't enter the DYING state or weren't in long enough for xenconsoled to notice. For every shutdown HVM domain, xenconsoled would leak memory, grow its list of domains and (if guest console logging was enabled) leak the log file descriptor. If the file descriptors were leaked and enough HVM domains were shutdown, no more console connections would work as the evtchn device could not be opened. Guests would then block waiting to send console output. Fix this by tagging domains that exist in enum_domains(). Afterwards, all untagged domains are assumed to be dead and are shutdown and cleaned up. Signed-off-by: David Vrabel <david.vrabel@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* nstore: rename public xenstore headersIan Campbell2012-05-142-2/+2
| | | | | | | | | | | | | | | | | | | | | | The xenstore header xs.h is producing conflicts with other software[1]. xs is a too short identifier and does not matche the library. Renaming the headers to xenstore.h and xenstore_lib.h is the easiest way to make them easy recognizable and prevent furthe problems. [1]: http://bugs.debian.org/668550 [ Also update QEMU_TAG, to bring in corresponding change to qemu-xen-traditional. -iwj ] Signed-off-by: Bastian Blank <waldi@debian.org> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com> --HG-- rename : tools/xenstore/xs.h => tools/xenstore/xenstore.h rename : tools/xenstore/xs_lib.h => tools/xenstore/xenstore_lib.h
* libxc: convert evtchn interfaces to use an opaque handle typeIan Campbell2010-12-231-16/+16
| | | | | | | | | | | | This makes the interface consistent with the changes made to the main interface in 21483:779c0ef9682c. Also fix some references to "struct xc_interface" which should have been simply "xc_interface" in tools/xenpaging, and update QEMU_TAG to pull in the corresponding qemu change. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxc: remove unnecessary double indirection from xc_readconsoleringIan Campbell2010-10-181-1/+1
| | | | | | | | The double indirection has been unnecessary since 9867:ec61a8c25429, there is no possibility of the buffer being reallocated now. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* tools: xenconsole[d] and libxl: multiple console supportStefano Stabellini2010-08-161-62/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements the new protocol for handling pv consoles and emulated serials as described in the document docs/misc/console.txt. The changes are: - xenconsoled: do not write the pty under serial in xenstore if xenconsoled is handling a consolepath; - xenconsole: implement support for an explicit console type parameter; the parameter can be "pv", to specify that the user wants to connect to a pv console, or "serial", to specify that the user wants to connect to an emulated serial. If the type parameter hasn't been specified be the user, xenconsole tries to guess which type of console it has to connect to, defaulting to pv console for pv guests and emulated serial for hvm guests. - xenconsole: use the new xenstore paths; - libxl: rename libxl_console_constype to libxl_console_consback: constype is used to to specify whether qemu or xenconsoled provides the backend, so I renamed it to libxl_console_consback to make it more obvious that we are talking about backends; - libxl: add a new libxl_console_constype to specify if the console is an emulated serial or a pv console; - libxl: support the new xenconsole "type" command line parameter; - libxl: use the "output" node under console in xenstore to tell qemu where do we want the output of this pv console to go; - remove the legacy "serialpath" from xenconsoled altogether Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Also: update the QEMU_TAG to pull in the qemu part of these changes. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxc: disable xc_ptrace on x86 LinuxIan Campbell2010-08-131-1/+1
| | | | | | | | | | | It has been unused since 21732:eb34666befcc. Removing the include of sys/ptrace.h and threaddb.h exposed a few places which were using time(2) or gettimeofday(2) without including time.h or sys/time.h respectively and were relying on an include. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* Without this we leak an fd on each domain shutdown and eventually runStefano Stabellini2010-07-191-0/+5
| | | | | | | | | out of file descriptors meaning new the console of new domains are not logged. Seems to have been accidentally removed in 16638:28921e83000b. Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
* Before this patch only log messages with precisely priorityStefano Stabellini2010-07-161-2/+4
| | | | | | | | | | | | | | LOG_WARNING (or precisely LOG_DEBUG if -v) would be logged. xenconsoled only actually logs using LOG_ERR and LOG_DEBUG so for the most part we would have been logging absolutely nothing up until now. Linux provides a LOG_UPTO macro but I'm not sure how portable that is so I have opencoded the list of levels. Do I get some sort of prize for fixing a bug introduced in 2005? Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
* libxc: eliminate static variables, use xentoollog; API changeKeir Fraser2010-05-283-13/+13
| | | | | | | | | | | | | | | | | | | | This patch eliminate the global variables in libxenctrl (used for logging and error reporting). Instead the information which was in the global variables is now in a new xc_interface* opaque structure, which xc_interface open returns instead of the raw file descriptor; furthermore, logging is done via xentoollog. There are three new parameters to xc_interface_open to control the logging, but existing callers can just pass "0" for all three to get the old behaviour. All libxc callers have been adjusted accordingly. Also update QEMU_TAG for corresponding qemu change. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xenconsoled: Discard guest console data in bigger chunksKeir Fraser2010-05-271-11/+18
| | | | | | | | | | Discard guest console data in bigger chunks so that there are fewer discontinuities in the console data. Also avoid discarding data if space is available at the front of the buffer by reclaiming that space. Patch from: Christian Limpach <Christian.Limpach@citrix.com> Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
* tools: Always check for __linux__ not __Linux__Keir Fraser2009-07-021-3/+2
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* xenconsoled: fix timestamp logKeir Fraser2009-06-231-1/+1
| | | | | | | timestamp log is broken. Also, xenconsoled might die with segfault. Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
* xenconsoled: Fix rate-limit calculation overflow leading to console freezes.Keir Fraser2009-06-231-2/+2
| | | | | From: Eric Tessler <eric@3tera.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* xenconsoled: Fixes to domain management.Keir Fraser2009-04-201-4/+12
| | | | | | | | | | | | | Event-channel setup: Re-bind if the connection becomes unbound (e.g., due to 'slow' domain suspend cancellation), even if the remote port identifier has not changed. Domain logging: Only open log file once (don't leak fds) and fix a small memory leak. Evtchn changes based on a patch by Jiri Denemark <jdenemar@redhat.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* xenconsole: Compile fixes for console code on SolarisKeir Fraser2009-03-111-0/+2
| | | | Signed-off-by: John Levon <john.levon@sun.com>
* xenconsole: Fix pty handlingKeir Fraser2009-02-201-11/+17
| | | | | | | | | | | | | | I printed the terminal attributes after openpty() and they were garbage on the first console, valid on the second etc. openpty() gets garbage in (uninitialized attributes MODIFIED by cfmakeraw()). It sets the slave to the attributes requested. Using uninitialized data for cfmakeraw->openpty results in pty attributes that may even have the receiver disabled. Closing the slave just hides the bug as these attributes disappear and hope the slave will be reopened and initialized. From: Juergen Hannken-Illjes <hannken@netbsd.org> Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
* xenconsoled: make guest console visible on NetBSD dom0Keir Fraser2009-02-201-0/+8
| | | | | | | | After openpty(), slave_fd must be closed or guest console output goes to the slave while select() in xen console client listens on the master. Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
* xenconsoled: replace gettimeofday with clock_gettimeKeir Fraser2008-07-301-6/+6
| | | | | | | | | | | | 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>
* tools: Declare functions static where they should be, and provideKeir Fraser2008-07-151-1/+1
| | | | | | proper prototypes for others as required. Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
* tools: replace sprintf with snprintf where applicableKeir Fraser2008-06-121-1/+2
| | | | Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
* console: Provide option to stall the inter-domain console ring ratherKeir Fraser2008-04-222-6/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* xenconsoled: don't force newline with timestampsKeir Fraser2008-02-201-35/+52
| | | | | | | | | | | | | | 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>
* xenconsoled: Use ISO8601 date stamp format.Keir Fraser2008-02-151-1/+1
| | | | Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
* libxenctrl headers should not pollute macro namespace withKeir Fraser2008-02-121-4/+4
| | | | | | | 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>
* Add timestamp option to xenconsoledKeir Fraser2008-02-122-11/+99
| | | | | | | | | | | 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>
* xenconsoled: Make slave pty raw during initialization.Keir Fraser2008-01-161-4/+21
| | | | | | (This avoids echo). Signed-off-by: Tristan Gingold <tgingold@free.fr>
* Fix master/slave handling in xenconsoled and qemuKeir Fraser2007-12-191-64/+76
| | | | | | | | | | | | | | | 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>
* Fix use-after-free in xenconsoled.Keir Fraser2007-11-011-1/+9
| | | | | | | | | | | | | | 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>
* xenconsoled: Rate-limit activity caused by each domU.Keir Fraser2007-10-291-6/+68
| | | | | Allow each domU to fire its event channel at most 30 times every 200ms. Signed-off by: Daniel P. Berrange <berrange@redhat.com>
* Allow incremental access to hypervisor console log.Keir Fraser2007-10-291-17/+46
| | | | Signed-off-by: Keir Fraser <keir@xensource.com>
* pv-qemu 10/10: Make xenconsoled ignore doms with qemu-dmKeir Fraser2007-10-251-0/+9
| | | | | | | | | | | | | | | | | 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>
* xenconsoled: portability fixes:Keir Fraser2007-10-082-47/+97
| | | | | | | | | | | | | | | - 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>
* Fix tools/console to build on NetBSD.Keir Fraser2007-09-201-0/+1
| | | | | | | | - 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>
* xenconsoled: improve robustness of logfile handlingKeir Fraser2007-06-271-14/+22
| | | | | | | | | | | | | | | 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>
* tools: warn_unused_result build fixes.kfraser@localhost.localdomain2007-06-121-1/+4
| | | | | | | | | | | | 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>
* tools: Fix some type issues GCC 4.1.0 warnings.kfraser@localhost.localdomain2007-06-071-1/+2
| | | | | | | | 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>
* console daemon: Fix realloc() usage.kfraser@localhost.localdomain2007-06-051-0/+1
| | | | Signed-off-by: Keir Fraser <keir@xensource.com>
* Add persistent guest & hv logging in xenconsoled.kfraser@localhost.localdomain2007-06-043-6/+204
| | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Console daemon - remove duplicate include.kfraser@localhost.localdomain2007-05-241-1/+0
| | | | Signed-off-by: Mats Petersson <mats.petersson@amd.com>
* [pv console] Move console information in xenstore to serial/0/.Christian Limpach2007-05-011-8/+62
| | | | | | | | 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>
* Xenconsoled should ignore spurious watch event. Otherwise, it can rebind to ↵john.levon@sun.com2007-02-191-0/+8
| | | | | | 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
* [SOLARIS] A couple of simple compile fixes for tools/ on Solaris.kfraser@localhost.localdomain2006-10-172-2/+2
| | | | Signed-off-by: John Levon <john.levon@sun.com>
* [CONSOLED] Shouldn't call domain_create_ring() for a domU which is shutting ↵kaf24@firebug.cl.cam.ac.uk2006-09-131-4/+6
| | | | | | | | | | | | 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>
* The following patch fixes a bug where xenconsoled will can SEGVkaf24@localhost.localdomain2006-08-281-8/+6
| | | | | | | | 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>