Commit Graph
85 Commits
Author SHA1 Message Date
kfraser@localhost.localdomain db6dca73cd [BLTAP] Use getpagesize() for portability.
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
2006-12-20 10:11:45 +00:00
Julian Chesterfield 9b27068f37 Qcow driver code cleanup:
- Remove global QCOW flags
- rename sparseness flag to -r fore 'reserve'
- Add ROUNDUP macro
- Check for qtruncate failures

Signed-off-by: Julian Chesterfield <julian@xensource.com>
2006-12-19 20:42:56 +00:00
Ewan Mellor f455c4c7bd Fix 64-bit build with a PRIu64.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
2006-12-15 01:42:31 +00:00
Julian Chesterfield a451e41cb7 Add sparseness flag to qcow-create.
For environments where space must be guaranteed in advance
use the -p flag to remove sparseness from the qcow file.

Signed-off-by: Julian Chesterfield <julian@xensource.com>
2006-12-14 20:23:07 +00:00
Ewan Mellor 62184014df Set FD_CLOEXEC on the pidfile fd, so that tapdisk does not get it.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
2006-12-14 10:31:31 +00:00
Ewan Mellor 0a85a374e0 Steal the write_pidfile function from xenstored_core, and use it to ensure
that blktapctrl only starts once.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
2006-12-13 11:23:01 +00:00
Andrew Warfield ed6af790ae Fix a number of flaws in the blktap userspace daemon when dealing
with I/O errors.

There are a number of flaws in the blktap userspace daemon when dealing
with I/O errors.

 - The backends which use AIO check the io_events.res member to determine
  if an I/O error occurred. Which is good. But when calling the callback
  to signal completion of the I/O, they pass the io_events.res2 member

  Now this seems fine at first glance[1]

    "res is the usual result of an I/O operation: the number of bytes
     transfered, or a negative error code. res2 is a second status
     value which will be returned to the user"

  Except that

     "currently (2.6.0-test9), callers of aio_complete() within the
      kernel always set res2 to zero."

  And this hasn't changed anytime since 2.6.0, so by passing through
  the status from 'res2', the callback thinks the I/O operation succeeded
  even when it failed :-(

  The fix is simple instead of passing 'res2', just pass

     ep->res == io->u.c.nbytes ? 0 : 1

  This would solve the error reporting to the guest, except that there
  is a second flaw...

 - The tapdisk I/O completion callback checks the status parameter
  passed in, syslog's it and then returns. It never bothers to send
  the I/O completion response back to the blktap kernel driver when
  a failure occurrs.

  Fortunately the fix for this is also simple. Instead of returning
  from the callback when dealing with an error, we simply toggle the
  status field for the pending response to BLKIF_RSP_ERROR and then
  continue with the normal codepath. So the error eventually gets
  back to the guest.


The scenario I used to discover the problem and test the patch is thus:

 - In dom0  create a filesystem with only 200 MB of free space
 - Create a 1 GB sparse file on this volume.
 - Configure the guest so this sparse file appears as /dev/xvdb
 - In the domU create a single partition on /dev/xvdb and format
  it with ext3.
 - In the DomU, mount /dev/xvdb1 on /mnt and then run

     dd if=/dev/zero of=/mnt/data.bin bs=1GB count=1


Without this patch, the 'dd' command would succeed in writing 1 GB of data
even though the underlying disk in Dom0 was only 200 MB in size. More complex
tests of copying a whole directory heirarchy across resulted in catastrophic
data corruption of the filessytem itself. Manual fsck was needed to fixup
the filesystem & there were many very bad errors needing fixing.


With this patch applied the DomU sees the I/O failures and kernel  logs
messages

Dec  1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 722127
Dec  1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 730327
Dec  1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 738527
Dec  1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 746727
Dec  1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 754927
Dec  1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 763127
Dec  1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 771327
Dec  1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 779527
Dec  1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 792399

It will retry the I/O operation until it runs out of sectors to try, and then
fail the operation. The filesystem is not seriously damaged - ext3 journal
recovery will trivially cleanup if the guest is rebooted after the disk in
Dom0 is enlarged.

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


[1] http://lwn.net/Articles/24366/
2006-12-01 09:01:04 -08:00
kfraser@localhost.localdomain bc79267989 [BLKTAP] Use lartge enough types to express parameters of large block devices.
While the kernel side of blktap drivers is using 64-bit sector numbers
correctly when reporting disk sizing, the userspace parts where this
dat is actually generated is truncating at 32-bit. There are 3 variables
related to disk sizing which are used in the kernel/userspace code
'size', 'sector size' & 'info'. In kernel space these are treated as being
unsigned long long, unsigned long, and unsigned int, respectively. In
the blktap userspace code this were all varyingly long, unsigned long.
This mismatch caused 32-bit wraparound on large disks. The attached
patch updates the blktap userspace to use the same data types as
kernel space for all these params, thus both fixing the 32-bit bug &
giving the code consistency.

This patch has been tested both by comparing /proc/partitions in the
guest, with the image size seen in the host, and by using Stephen
Tweedie's 'verify-data' tool on a variety of multi-TB sized disks.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2006-11-28 13:50:32 +00:00
kfraser@localhost.localdomain 9f941deb84 [TOOLS] Provide common LFS CFLAGS/LDFLAGS additions in Rules.mk.
Signed-off-by: Keir Fraser <keir@xensource.com>
2006-11-17 09:54:48 +00:00
Andrew Warfield 3cfbe70d32 [BLKTAP] Little error handling fix to blktapctrl.c.
Signed-off-by: Andrew Warfield <andy@xensource.com>
2006-11-15 12:50:17 -08:00
kfraser@localhost.localdomain bcc2aed22a [BLKTAP] No need for barrier when updating rsp_prod_pvt.
Signed-off-by: Keir Fraser <keir@xensource.com>
2006-11-07 12:31:17 +00:00
kfraser@localhost.localdomain 720860012a [BLKTAP] Various cleanups necessary for ia64 support.
- remove magic number 8 and 64.
  page size / sector size is 8 on x86, however on ia64 page size is
  16kb.
  blkring size is 64 on x86. however it's 128 on ia64.
- replace 0xFFFF with INVALID_GRANT_HANDLE
- don't map io ring into user space with uncachable.
  kernel access the page with cacable and tapdisk uses memory barrier
  so that it isn't necessary.
- remove printk warning and inserted new line.
- remove unused variable, page.
- add one BUG()

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
2006-11-07 11:01:35 +00:00
kfraser@localhost.localdomain 9f29e9da09 [BLKTAP] Simplify linked-list insertion/deletion.
This should also avoid (bogus) compiler warnings, as reported
on IA64.
Signed-off-by: Keir Fraser <keir@xensource.com>
2006-10-25 10:56:50 +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 1febf1acf7 [BLKTAP] Remove bogus extra public definition of sig_handler().
Also do not build the daemon -fPIC.
Signed-off-by: Keir Fraser <keir@xensource.com>
2006-10-08 18:05:57 +01:00
kfraser@localhost.localdomain 44740083e9 [BLKTAP] Fix trivial indentation snafu in previous changeset.
Signed-off-by: Keir Fraser <keir@xensource.com>
2006-10-06 16:51:10 +01:00
kfraser@localhost.localdomain 382c54558d [BLKTAP] Fix crash at start-of-day in blktapctrld
if /local/domain does not exist.
Signed-off-by: Keir Fraser <keir@xensource.com>
2006-10-06 15:05:30 +01:00
kfraser@localhost.localdomain dc2917720c [BLKTAP] Formatting and style cleanups to blktapctrl.
Signed-off-by: Keir Fraser <keir@xensource.com>
2006-10-06 15:04:42 +01:00
jchesterfield@dhcp92.uk.xensource.com 9bc9168a08 [BLKTAP] Blktapctrl: Add asynchronous watch on dom0 name entry for blktapctrl on startup. This patch cleans up the synchronisation issues between blktapctrl and xend at initialisation if the Dom0 entries have not yet been populated.
Signed-off-by: Julian Chesterfield <julian@xensource.com>
2006-10-05 10:55:13 +01:00
kfraser@localhost.localdomain bb52a4e20a [BLKTAP] Find major number by searching sysfs
instead of reading /proc/devices.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
2006-09-29 14:55:57 +01:00
kfraser@localhost.localdomain 80550dad57 [BLKTAP] Remove unnecessary timeout from tapdisk select() call.
tapdisk was using a 1msec select() timeout in its main event loop.  On
timeout, the loop does nothing except repeat, so the timeout achieves
nothing; worse, on a machine with HZ set to less than 1000, a msec
timeout returns immediately, sending tapdisk into a 100%-CPU-
utilisation loop.

Simply remove the timeout entirely; everything still works fine, and
much more efficiently when idle.

Signed-off-by: Stephen Tweedie <sct@redhat.com>
2006-09-29 11:16:52 +01:00
Andrew Warfield 9dd368070b [BLKTAP] have blktap use a dynamic major
blktap currently uses a hardcoded major of 254 for the device.  This is
not robust in anyway and needs to be dynamic.

Note: it is better not to have the daemon create the node, and have udev
create it instead. But since the daemon currently creates the node
anyway, it is still the way this is done.  That change needs to be made
at another time.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
2006-09-28 12:47:45 -07:00
jchesterfield@dhcp92.uk.xensource.com 30acc78a4b [blktap] Fix block device getsize bug in qcow when backing_filename is a block device. 2006-09-05 15:35:42 +01:00
Andrew Warfield f1da4c1bac Tapdisk cleanup.
Sign-off-by: Jun Koi <junkoi2004@gmail.com>
2006-09-01 13:24:51 -07:00
Andrew Warfield b54a368212 Fix typo.
Signed-off-by: <andy@xensource.com>
2006-08-29 16:31:57 -07:00
akw@devbox.site 34cac35129 Small blktap cleanups.
Signed-off-by: Andrew Warfield <andy@xensource.com>
2006-08-29 15:55:24 -07:00
akw@devbox.site 8c6d286668 Reduce AIO context allocations in blktap.
Signed-off-by: Andrew Warfield <andy@xensource.com>
2006-08-29 14:34:57 -07:00
Steven Hand edd2b90d12 Ensure get_dom_domid() terminates even when /local/domain/<foo>/name is
not present.

Signed-off-by: Steven Hand <steven@xensource.com>
2006-08-24 14:07:01 +01:00
kfraser@localhost.localdomain 75205296f9 This is a small patch that makes a cross compiler successfully compile
the sources under the tools directory.  This patch became necessary
after qemu-dm is updated to a newer version.

Signed-off-by: Hiroya INAKOSHI <inakoshi.hiroya@jp.fujitsu.com>
2006-08-16 11:53:37 +01:00
jchesterfield@wicket.uk.xensource.com acf531c565 Limit blktap static link to just libaio. 2006-08-07 18:11:59 +01:00
chris@kneesaa.uk.xensource.com c421252d5a [blktap] Add dependencies to Makefiles and simplify to avoid needless rebuilds.
Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
2006-08-03 19:45:14 +01:00
jchesterfield@dhcp92.uk.xensource.com 7005c6cd93 Switch blktapctrl.c over to using standard system daemon(3) call. Current patch was not closing all FDs and redirecting output to /dev/null, preventing tapdisk from launching correctly. 2006-08-01 17:59:27 +01:00
kfraser@localhost.localdomain 31c8886dc2 [BLKTAP] Properly daemonise the blktap control daemon. Fixes bug #709.
Signed-off-by: Harry Butterworth <butterwo@uk.ibm.com>
2006-07-31 18:07:25 +01:00
kfraser@localhost.localdomain ab78272006 When installing libblktap, symlinks should be made instead of using
install on the symlinks (install will follow the symlink)

Signed-off-by: Jeremy Katz <katzj@redhat.com>
2006-07-25 11:41:45 +01:00
kaf24@firebug.cl.cam.ac.uk 0f36c05f28 [IA64] The blktap driver hardcodes PAGE_SIZE. Change it to use getpagesize(),
thereby allowing it to build on ia64.

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
2006-07-14 11:46:28 +01:00
jchesterfield@dhcp92.uk.xensource.com 0da81aa1d4 Added blktap support. Includes kernel driver (enabled as CONFIG_XEN_BLKDEV_TAP=y) and userspace tools. The userspace deamon (blktapctrl) is enabled by default when xend is activated. For further information on using and configuring blktap see tools/blktap/README. 2006-07-13 10:13:26 +01:00
akw@localhost.localdomain b85d17117a Remove old blktap tools.
Signed-off-by: Andrew Warfield <andrew.warfield@cl.cam.ac.uk>
2006-06-16 18:45:45 -07: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 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
kaf24@firebug.cl.cam.ac.uk 55f8d24f80 Bump blktap and dom0op version numbers.
Signed-off-by: Keir Fraser <keir@xensource.com>
2005-12-04 12:06:38 +01:00
kaf24@firebug.cl.cam.ac.uk b2de462a06 Public interface cleanups. Widen some fields in public
interface defintions for future extensibility. In particular,
grant references are now 32 bits and this has some knock-on
effects on split-driver interfaces.

Signed-off-by: Keir Fraser <keir@xensource.com>
2005-11-30 16:03:05 +01:00
cl349@firebug.cl.cam.ac.uk 016ef02e87 Move mk-symlinks target into tools/Rules.mk.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
2005-11-28 18:07:22 +01:00
kaf24@firebug.cl.cam.ac.uk f8e8438eef Remove unnecessary NULL checks before freeing memory blocks.
The following functions check for NULL internally:
 free, kfree, xfree, free_xenheap_page[s]

Signed-off-by: Keir Fraser <keir@xensource.com>
2005-11-11 12:55:47 +01:00
kaf24@firebug.cl.cam.ac.uk d8263e8dba Fix Xen public interfaces and the tools to consistently
use stdint-format bitsize types (uint32_t and friends).

Signed-off-by: Keir Fraser <keir@xensource.com>
2005-10-12 11:07:37 +01:00
kaf24@firebug.cl.cam.ac.uk 4657d174ab Refactor xenbus to break up the xenbus_lock and permit watches
to fire concurrently with request/reply pairs. Remove
watch_ack message: no longer needed.

Signed-off-by: Keir Fraser <keir@xensource.com>
2005-10-09 18:52:54 +01:00
kaf24@firebug.cl.cam.ac.uk 76bd51c23d Change xs_read_watch interface to return a sized array (in userspace and in
kernel).

Add index macros (XS_WATCH_*) for accessing the array to allow for future
expansion.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2005-10-07 15:51:53 +01:00
emellor@ewan d934679092 Within the store, split the persistent information regarding a VM from the
transient information regarding a domain.  This allows live localhost migration,
which is important for testing migration, and also allows migration when we
have a distributed store.  The backend paths in the store now refer to the
frontend domain ID, not its UUID, and blktap has changed to match.

To support this split in the information, the cleanup procedure has been split
to match.

Change the save-restore interface between XendDomain, XendDomainInfo, and 
XendCheckpoint, to remove some intermingling, in particular taking XendDomain
out of the loop for the restore procedure.

Improved the recovery procedure to avoid trying to destroy dom0 when recovering.

Added a lock around XendDomain.refresh and one around
XendDomainInfo.refreshShutdown, to improve the behaviour when recreating
domains at startup.  There are still races here, so more thought needs to be
given to the locking.

Live reconfiguration of an existing domain is temporarily broken.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
2005-09-30 13:41:10 +01:00
cl349@firebug.cl.cam.ac.uk 7fd9bccce2 Remove iflag argument to xs_write
xs_write with O_CREAT|O_EXCL causes problems over daemon restarts, since
it's not idempotent.
It turns out noone really needs the flags word at all, so get rid of it.
It's now as if everyone specified "O_CREAT".
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
2005-09-19 14:34:30 +00:00