aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/blkfront.c
Commit message (Collapse)AuthorAgeFilesLines
* mini-os: fix various memory leaks in blkfrontMatthew Daley2013-09-211-4/+7
| | | | | | | Coverity-ID: 1055814 Coverity-ID: 1055815 Signed-off-by: Matthew Daley <mattjd@gmail.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* minios: fix xenbus_rm() calls in frontend driversBen Cressey2013-09-101-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The commit "minios: refactor xenbus state machine" caused "/state" to be appended to the local value of nodename. Previously the nodename variable pointed to dev->nodename. The xenbus_rm() calls were not updated to reflect this change, and refer to paths that do not exist. For example, shutdown_blkfront() for vbd 2049 would issue these calls: xenbus_rm(XBT_NIL, "device/vbd/2049/state/ring-ref"); xenbus_rm(XBT_NIL, "device/vbd/2049/state/event-channel"); This patch restores the previous behavior, issuing these calls instead: xenbus_rm(XBT_NIL, "device/vbd/2049/ring-ref"); xenbus_rm(XBT_NIL, "device/vbd/2049/event-channel"); This causes frontend drivers to not be properly reset when PV-GRUB exists. Some PV Linux drivers fail to re-initialize frontend devices if PV-GRUB leaves them in this state. Signed-off-by: Ben Cressey <bcressey@amazon.com> Reviewed-by: Matt Wilson <msw@amazon.com> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org> [msw: adjusted commit message to include consequences, split out changes into separate patches] Signed-off-by: Matt Wilson <msw@amazon.com>
* minios: clean up unneeded "err = NULL" in frontend driversBen Cressey2013-09-101-1/+0
| | | | | | | | | | | | | | | This patch removes cases where the error message pointer is already NULL and is then set to NULL. These are harmless, but suggest incorrect practice: the pointer should be passed to free() to deallocate memory prior to reassignment. There are no functional changes in this patch. Signed-off-by: Ben Cressey <bcressey@amazon.com> Reviewed-by: Matt Wilson <msw@amazon.com> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org> [msw: split a larger patch from Ben into this cleanup patch] Signed-off-by: Matt Wilson <msw@amazon.com>
* minios: clean up allocation of char arrays used for xenbus pathsMatt Wilson2013-09-101-3/+3
| | | | | | | | | | This patch cleans up instances of char array allocation where string lengths were manually counted to use strlen() instead. There are no functional changes in this patch. Signed-off-by: Matt Wilson <msw@amazon.com> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-By: Samuel Thibault <samuel.thibault@ens-lyon.org>
* minios: correct char array allocation for xenbus pathsMatt Wilson2013-09-101-1/+1
| | | | | | | | | | | | | | | | | | | The char arrays used to hold xenbus paths have historically been allocated by manually counting the length longest string constants included in constructing the path. This has led to improperly sized buffers, both too large (with little consequence) and too small (which obviously causes problems). This patch corrects the instances where the length was incorrectly calculated by using strlen() on the longest string constant used in building a xenbus path. A follow-on clean-up patch will change all instances to use strlen(). Signed-off-by: Ben Cressey <bcressey@amazon.com> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-By: Samuel Thibault <samuel.thibault@ens-lyon.org> [msw: split this patch from a larger patch from Ben, reworked to use strlen()] Signed-off-by: Matt Wilson <msw@amazon.com>
* minios: add posix io for blkfrontMatthew Fioravante2012-10-091-0/+169
| | | | | | | | | This patch adds posix io support (read,write,lseek) to block devices using blkfront. Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu> Acked-by: Samuel Thibault <samuel.thibault@ens-lyons.org> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* mini-os: stop compiler complaint about unused variablesJohn McDermott2012-02-091-0/+1
| | | | | | | | | gcc (GCC) 4.6.2 20111027 (Red Hat 4.6.2-1) complains about unused variables in mini-os drivers Signed-off-by: John McDermott <john.mcdermott@nrl.navy.mil> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* mini-os: use BSD sys/queue.h instead of Linux list.hIan Campbell2012-01-311-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The latter is GPL which makes the whole of mini-os GPL rather than BSD as intended. In tree users are all GPL or GPL-compatible but we should fix this so that mini-os is BSD. Do so by using the same BSD sys/queue.h as we use in libxl. Tested with the builtin mini-os test app and qemu stubdomain, both of which appear to still function as expected. Move tools/libxl/external and the associated sed script to tools/include/xen-external to allow more sensible access from mini-os. Also add s/NULL/0/ in the sed script due to NULL not always being defined in stubdom code when mini-os/wait.h is included. As well as the obvious ABI changes there are a few API updates associated with the change: - struct rw_semaphore.wait_list is unused - remove_waiter needs to take the wait_queue_head The latter requires a qemu update, so there is also a QEMU_TAG update in this changeset. I sprinkled some extra-emacs local variables around the files I edited which didn't have them. I think this should be backported to the stable branches since external users of mini-os may have been mislead into thinking they could safely link mini-os against GPL-incompatible code. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* mini-os: Revert 21106:b20f897d6010 "Fix xenbus initialisation"Keir Fraser2010-05-041-14/+3
| | | | | | Jeremy Fitzhardinge (jeremy@goop.org) reports that this fixes HVM+stubdom. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* mini-os: Fix crash on frontend shutdown failuresKeir Fraser2010-04-071-1/+2
| | | | | | | Do not free frontend resources if some error happened, since the backend may not have finished properly restarting in such case. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* mini-os: Fix frontend shutdown wait loopKeir Fraser2010-04-071-1/+1
| | | | | | | minios frontends must wait for backends to be shut down and reinitialized before freeing resources. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* mini-os: Fix xenbus initialisationKeir Fraser2010-04-061-3/+14
| | | | | | | | | This fixes xenbus initialization of blkfront, netfront and pcifront by uniformizing with fbfront: after writing parameters, set state to initialised, then wait for backend to switch to connect state, and then only read its parameter and switch to the connect state. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* mini-os: Fix memory leaks in blkfront, netfront, pcifront, etc.Keir Fraser2009-12-141-4/+13
| | | | | | | | | The return value of Xenbus routines xenbus_transaction_start(), xenbus_printf(), xenbus_transaction_end(), etc. is a pointer of error message. This pointer should be passed to free() to release the allocated memory when it is no longer needed. Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
* minios: Fix xenbus_unwatch_path callsKeir Fraser2009-11-231-2/+2
| | | | | | | | | | In a lot of places in MiniOS frontends, xenbus_watch_path_token is used instead of xenbus_watch_path to get more precise wake ups. To free those, xenbus_unwatch_path_token has to be used instead of xenbus_unwatch_path, else the unwatch operation will fail. This fixes spurious watch events left by pv-grub. Signed-Off-By: Samuel Thibault <samuel.thibault@ens-lyon.org>
* stubdom/minios: re-structure headersKeir Fraser2009-10-011-7/+8
| | | | | | | | | As part of making stubdom usable on NetBSD, it is necessary to restructure the minios headers to avoid conflicts with NetBSD's crossbuild toolchain. Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* minios: refactor xenbus state machineKeir Fraser2009-06-031-13/+49
| | | | | | | | Implement xenbus_wait_for_state_change and xenbus_switch_state and change the various frontends to use the two functions and do proper error checking. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
* pvgrub: few lines in shutdown_blkfront were removed by mistake.Keir Fraser2009-05-261-0/+4
| | | | Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
* minios: Fix blkfront driver when sector_size != 512Keir Fraser2009-05-261-4/+4
| | | | | | | | The first and last sector as well as the sector number of the request is expressed in 512 bytes units, independently from the real sector size. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
* stubdoms: generate stubdom config fileKeir Fraser2009-04-231-4/+0
| | | | | | | | | | | | | | | | | | This patch removes the need for a second configuration file for stubdoms: it is going to be automatically generated by the script stubdom-dm using command line options and xenstore to find any needed information. The configuration script will be placed under /etc/xen/stubdoms and automatically removed when the domain is destroyed. The only change needed in xend is not to write on xenstore sdl, opengl and serial command line options for qemu, because stubdoms do not support them. It is safe to remove those two options from xenstore because qemu does not use xenstore to read commans line options. Finally this patch fixes blkfront disconnections from backends and display and xauthority variables for pv guests. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
* minios: fix a memory corruption in blkfrontKeir Fraser2009-04-141-5/+7
| | | | | | | | | The corruption happens every time we pass a sector aligned buffer (instead of a page aligned buffer) to blkfront_aio. To trigger the COW we have to write at least a byte to each page of the buffer, but we must be careful not to overwrite useful content. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
* minios: blkfront should set protocol nodeKeir Fraser2008-09-241-0/+7
| | | | | From: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* stubdom: use host's gccKeir Fraser2008-07-041-9/+12
| | | | | | | | This makes stubdom use the host's gcc instead of downloading/compiling binutils+gcc. That requires a bunch of changes and even uncovered a few bugs, but saves a lot of time. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: proper frees are now handled, so drop the FIXME commentKeir Fraser2008-07-011-1/+0
| | | | Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* Add PV-GRUBKeir Fraser2008-06-181-1/+7
| | | | | | | | | | | This fetches GRUB1 sources, applies the {graphical, print function, save default, and ext3_256byte} patches from debian, and applies a patch to make it work on x86_64 and port it to Mini-OS. By using libxc, PV-GRUB can then "kexec" the loaded kernel from inside the domain itself, hence permitting to avoid the security-concerned pygrub. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* stubdom: fix using minios frontends directly when libc is activedKeir Fraser2008-06-181-3/+9
| | | | Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: add proper shutdown facilitiesKeir Fraser2008-06-091-0/+2
| | | | Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: add a blkfront synchronous interfaceKeir Fraser2008-06-051-4/+23
| | | | Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: free blkfront resources on error/shutdownKeir Fraser2008-05-121-8/+24
| | | | Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: fix thread safety of xenbus watches by requiring callers toKeir Fraser2008-05-061-6/+10
| | | | | | | provide their own queue of events, because else we can not dispatch to watchers running in parallel. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* stubdom: add asynchronous disk flush supportKeir Fraser2008-04-051-86/+92
| | | | Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: blkfront_aio_poll may reenterKeir Fraser2008-03-261-9/+12
| | | | | | | | | | if the callback calls blkfront_sync for instance. In such a case, we would see responses and hence release grants several times. We need to be more synchronous and stop when we detect that we have re-entered. This fixes HVM restore with stubdomains. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: get VBD CD/removable/RO infoKeir Fraser2008-03-201-1/+4
| | | | Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: Fix lost eventsKeir Fraser2008-03-181-9/+5
| | | | | | | | | | | | | | | evtchn_bind_interdomain used to clear any already pending event before binding a handler, because else the handler may be called before it is ready. That however leads to missed events, which I had to workaround for the HVM case. This changes the semantics of bind_evtchn, and thus of all the event channel binding functions (bind_virq, evtchn_alloc_unbound, evtchn_bind_interdomain) into not unmasking the event itself, hence letting the caller initialize properly before unmasking the port (e.g. record the port number in an appropriate place). Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: drop unused xenblk_rxidx functionKeir Fraser2008-02-141-5/+0
| | | | Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* stubdom: optimize block io completion polling by not polling all theKeir Fraser2008-02-141-0/+5
| | | | | | time; only when some requests have completed. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* Add stubdomain support. See stubdom/README for usage details.Keir Fraser2008-02-121-5/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Move PAGE_SIZE and STACK_SIZE into __PAGE_SIZE and __STACK_SIZE in arch_limits.h so as to permit getting them from there without pulling all the internal Mini-OS defines. - Setup a xen-elf cross-compilation environment in stubdom/cross-root - Add a POSIX layer on top of Mini-OS by linking against the newlib C library and lwIP, and implementing the Unixish part in mini-os/lib/sys.c - Cross-compile zlib and libpci too. - Add an xs.h-compatible layer on top of Mini-OS' xenbus. - Cross-compile libxc with an additional xc_minios.c and a few things disabled. - Cross-compile ioemu with an additional block-vbd, but without sound, tpm and other details. A few hacks are needed: - Align ide and scsi buffers at least on sector size to permit direct transmission to the block backend. While we are at it, just page-align it to possibly save a segment. Also, limit the scsi buffer size because of limitations of the block paravirtualization protocol. - Allocate big tables dynamically rather that letting them go to bss: when Mini-OS gets installed in memory, bss is not lazily allocated, and doing so during Mini-OS is unnecessarily trick while we can simply use malloc. - Had to change the Mini-OS compilation somehow, so as to export Mini-OS compilation flags to the Makefiles of libxc and ioemu. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: Fix blkfront grant map leakKeir Fraser2008-02-071-3/+3
| | | | Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: Support net/block backend in domUKeir Fraser2008-02-071-11/+13
| | | | Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: Fix bug when blkfront reading into zero-mapped bufferKeir Fraser2008-01-291-1/+6
| | | | | | | by just poking the page. No need to use virtual_to_mfn() for the ring since that is a real page. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: permit blkfront to write from mapped memoryKeir Fraser2008-01-231-1/+1
| | | | | | Missing call to virtual_to_mfn Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: permit blkfront to write from mapped memoryKeir Fraser2008-01-221-1/+1
| | | | | | by adding a virtual_to_mfn macro Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios, blkfront: set default block path.Keir Fraser2008-01-221-2/+2
| | | | | | remove unnecessary path head stripping. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* minios: add blkfrontKeir Fraser2008-01-171-0/+392
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>