Commit Graph
96 Commits
Author SHA1 Message Date
Keir Fraser 4b48ffd60a blktap: fix empty QCOW images (bug 1430 part 2)
Empty QCOW images consist of only the L1 table, this results in a
file size which is not sector-aligned. Since blktap uses O_DIRECT, the
block aligned read of the L1 table will go beyond the end of file and
thus returns the actual file size and not the expected length.
This patch checks whether at least the L1 table has been read.

This should fix bug 1430.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
2009-06-03 11:11:50 +01:00
Keir Fraser 2f78e9cccf blktap: fix and use ROUNDUP macro (bug 1430 part 1)
As pointed out in Xen Bugzilla 1430 in the blktap QCOW driver the
rounding function is wrong in line 824 of block-qcow.c.
This patch replaces this (and other roundings) with the already
existing ROUNDUP macro (and fixes the usual macro pitfall).

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
2009-06-03 11:11:04 +01:00
Keir Fraser 630ec346ad blktap: Revert parts of c/s 19349.
Caused blktapctrl pipes to be created with uninitialised variable in name.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-06-01 14:02:26 +01:00
Keir Fraser cde518aa71 blktap: Move error signaling to blktapctrl
Until now the udev script for blktap devices needs to decide if to
signal success or failure to xend. As this script runs completely
independent of blktapctrl and tapdisk/ioemu which do the real work,
the udev script can't even theoretically know if tapdisk is happy.

This patch removes the udev script and replaces its checks by new
ones in libblktap.

Signed-off-by: Kevin Wolf <kwolf@suse.de>
2009-03-12 18:48:09 +00:00
Keir Fraser 3dc413c7bd blktapctrl: Fix too early close of pipes
Connections to ioemu have single_handler set, so they are closed as
soon as all images of a certain type are closed. This is wrong with
ioemu: All images that belong to the same domain are handled by the
same backend process (usually qemu-dm, but also tapdisk-ioemu for
domains without device model), regardless of the image type.

This patch checks for the same-domain condition for ioemu connections.

Signed-off-by: Kevin Wolf <kwolf@suse.de>
2009-03-12 18:46:26 +00:00
Keir Fraser 57871f919d blktap: Export disk type constants for ioemu
Currently all disk types that are supported are defined in a header
file private to blktapctrl and tapdisk. When restoring ioemu as a
backend for blktap these constants are needed by ioemu, so move them
to a more public header file.

Signed-off-by: Kevin Wolf <kwolf@suse.de>
2009-03-12 18:42:59 +00:00
Keir Fraser 8b173f5236 blktapctrl: Select backend by prefix
This patch adds support for specifying the backend (tapdisk or ioemu)
to blktapctrl. Images can be specified e.g. as tap:tapdisk:aio,
tap:ioemu:qcow2 or tap:vmdk. When omitting the backend, a default is
chosen based on the image type (currently always tapdisk because ioemu
as a backend is broken until a follow-up patch series against qemu-xen
is applied)

Signed-off-by: Kevin Wolf <kwolf@suse.de>
2009-03-12 18:42:31 +00:00
Keir Fraser 19801a52bf blktap: Fix compile warnings in block-qcow2.c
Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
2009-03-09 09:48:45 +00:00
Keir Fraser 86d2a1cec5 blktap: Allow creation of qcow2 files.
Signed-off-by: Yang Zhang <yang.zhang@intel.com>
2009-03-03 13:22:28 +00:00
Keir Fraser 77de1e2709 blktap: Fix check_gcrypt
Signed-off-by: KUWAMURA Shin'ya <kuwa@jp.fujitsu.com>
2009-02-11 10:44:42 +00:00
Keir Fraser bef2c17dbc Do not print `***' when compiling unless we fall over
This has finally bugged me enough to do something about it:

make prints `***' when it stops due to an error.  With make -j, and/or
with automated build systems, this error marker can be in the middle
of a large logfile.  It is useful to be able to search for it.

Therefore change occurrences of `*' to `=' for information and warning
messages.  `***' is reserved for cases where the build stops.

A corresponding change is being applied to qemu-xen-unstable.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2009-01-12 10:17:12 +00:00
Keir Fraser 9f8501582f Use -MMD -MF in tools/* rather than -Wp,-M...
If you use -MMD -MF then the correct .o filename is written to the
.*.d file as the compiler driver arranges everything.  This was done
in 19010:275abe1c5d24 for the hypervisor.

In this patch we do the same elsewhere in the xen-unstable tree,
particularly tools/.  Specifically:
 * Change tools/Rules.mk to add -MMD -MF ... to CFLAGS and set DEPS.
 * Remove -Wp,-MD... from every other Makefile
 * Remove setting of DEPS from every other Makefile
 * Ensure that every Makefile says -include $(DEPS)
 * Ensure that every Makefile's clean target removes $(DEPS)

Some Makefiles were already halfway there, but often for a different
variable name eg PROG_DEP.  The variable name is now standardised in
Rules.mk as DEPS.

I have done a test build with this change, on Debian etch.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2009-01-12 10:16:05 +00:00
Keir Fraser d0292e3adb blktap: re-enable O_DIRECT in block_qcow.c
Turns out that only two reads and writes in block-qcow.c need to be
fixed to work correctly with O_DIRECT.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2008-10-22 11:55:33 +01:00
Keir Fraser 942da08c6c blktap: Handle qcow backing files correctly.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2008-10-20 15:08:24 +01:00
Keir Fraser 121068a2ce blktap: portability cleanup
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2008-07-14 10:03:09 +01:00
Keir Fraser 962649c369 blktap: cleanup
Make functions w/o a prototype static and remove redundant
declaration of xs_fire_next_watch().

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2008-07-11 15:36:40 +01:00
Keir Fraser 1d36727c99 tapdisk: in case O_DIRECT fails, retry again with o_flags but
O_DIRECT, instead of fixed value O_RD_WR | O_LARGEFILE

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
2008-07-11 12:43:33 +01:00
Keir Fraser 5109f87cee Blktapctrl compatibility layer
I originally had just changed the NEWINTF ioctl to send over 48-bits
of information, which works on 64-bit but not on 32-bit (since the arg
is an unsigned long).  Additionally, the previous changes would break
an older userland against a new kernel.  For that reason, introduce a
new ioctl (NEWINTF_EXT) that fixes both of these problems.  This is
the dom0 userland side.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2008-07-09 10:41:49 +01:00
Keir Fraser 04465fbeb9 blktap: Fall back to libcrypto if libgcrypt is not installed.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2008-06-30 11:39:10 +01:00
Keir Fraser 53a29c4ca7 blktap: link against libgcrypt rather than libcrypto
tapdisk, part of blktap, links against libcrypto. tapdisk includes
GPLv2 (tapaio.c) and other licensed code (block-qcow.c). The license
of OpenSSL is considered incompatible with the GPL by many
people. This patch changes them to link against libgcrypt, which is
LGPL.

Signed-off-by: Bastian Blank <waldi@debian.org>
2008-06-30 10:00:53 +01:00
Keir Fraser 4fe815abd1 blktap: Extend userland busid to 32 bits
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2008-06-27 16:08:56 +01:00
Keir Fraser c8af9ce961 tapdisk: Fix qcow2 for images > 2 GB
Signed-off-by: Kevin Wolf <kwolf@suse.de>
2008-06-27 14:03:52 +01:00
Keir Fraser defe5e9a30 blktap: Automatically start tapdisk-ioemu on demand
When a domain wants to use a tap:ioemu disk but has no device model,
start a tapdisk-ioemu instance as provider. Also, move the creation
and removal of communication pipes to xend so that qemu-dm doesn't
need the unwanted SIGHUP handler anymore.

Signed-off-by: Kevin Wolf <kwolf@suse.de>
2008-04-23 16:57:23 +01:00
Keir Fraser 8318d7d63d Revert 17499:451ae3b8e5c8
Breaks HVM guest creation (bugzilla #1221).

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2008-04-23 13:30:24 +01:00
Keir Fraser 3b64ad17ca blktap: Automatically start tapdisk-ioemu on demand
When a domain wants to use a tap:ioemu disk but has no device model,
start a tapdisk-ioemu instance as provider. Also, move the creation
and removal of communication pipes to xend so that qemu-dm doesn't
need the unwanted SIGHUP handler anymore.

Signed-off-by: Kevin Wolf <kwolf@suse.de>
2008-04-22 14:39:33 +01:00
Keir Fraser bd095de691 tools: Use PATH_MAX for pathname char arrays.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2008-04-04 14:49:37 +01:00
Keir Fraser b4f95a5c93 tapdisk: Fix L1 table endianess of qcow images
Fix tapdisk to use big endian L1 tables as used by qemu/ioemu. Old
tapdisk images with native endianess are automagically converted to
big endian when the image file is opened for the first time.

Signed-off-by: Kevin Wolf <kwolf@suse.de>
2008-03-27 17:13:37 +00:00
Keir Fraser 6fef410021 blktap: Fix BSD build failure.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2008-03-19 16:19:10 +00:00
Keir Fraser f9aa19ee3a tapaio build fix
With some combinations of compiler flags (no optimization, -Werror),
the compiler may complain that the function doesn't have a return
statement (even if the function actually just never returns), reported
as bug 1128. This adds a dummy return statement.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
2008-03-19 14:12:12 +00:00
Keir Fraser 45b676a245 Use ioemu block drivers through blktap.
Add support for a tap:ioemu pseudo driver. Devices using this driver
won't use tapdisk (containing the code duplication) any more, but will
connect to the qemu-dm of the domain. In this way no working
configuration should be broken right now as you can still choose to
use the tapdisk drivers.

Signed-off-by: Kevin Wolf <kwolf@suse.de>
2008-03-18 10:58:47 +00:00
Keir Fraser 2dfb6b6e90 Clean up blktap Makefiles.
Signed-off-by: Bastian Blank <waldi@debian.org>
2008-03-17 10:57:59 +00:00
Keir Fraser a226d0f1bb blktapctrl: Fix a potential device minor number leak.
Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
2008-03-03 11:08:10 +00:00
Keir Fraser 912ede3b1a blktap: Fix unused warnings in block-qcow2.c with -D_FORTIFY_SOURCE=2.
Signed-off-by: Kevin Wolf <kwolf@suse.de>
2008-02-28 13:19:38 +00:00
Keir Fraser c3d370d254 blktap: Remove some code duplication
With my qcow2 patch to blktap I contributed a bit to the mess, so here
an attempt to clean up and remove at least some of the code
duplication in the functions dealing with aio operations.

Signed-off-by: Kevin Wolf <kwolf@suse.de>
2008-02-25 09:12:20 +00:00
Keir Fraser 219c37ca95 blktap: qcow2 image format support
This patch adds support for the qcow2 image format to blktap. It
consists mostly of qemu code, adapted to the blktap interfaces.
Snapshots and compressed images are supported.

The qcow2 driver may be used by either specifying tap:qcow2 or by
using tap:qcow which will detect that you have a version 2 image and
will call the qcow2 driver.

Signed-off-by: Kevin Wolf <kwolf@suse.de>
2008-02-21 10:30:57 +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 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 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 bc4a5b7bf5 blktap: Clean up makefile and linked libs.
Signed-off-by: Bastian Blank <waldi@debian.org>
2008-01-26 10:17:33 +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 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 6aef553b66 blktap: factor out linux specific code
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2008-01-15 14:17:22 +00:00
Keir Fraser fa7a56b7fa tapaio check return value from read()
In tools/blktap/drivers/tapaio.c there is a call to read(2) whose
return value is not checked.  The attached patch attempts to do
something vaguely sensible in cases of error.

Fully comprehensive error handling in this area would be quite tough
to introduce now but at least with this change when things go wrong
you stand a chance of getting some information about what happened.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2007-12-27 12:28:58 +00:00
Keir Fraser 363a648846 blktap: cleanups for *BSD.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2007-12-05 09:59:23 +00:00
Keir Fraser 8ddc7e13ab blktap: remove unused headers.
Attached patch removes unused linux specific headers
and makes bswap.h ready for BSD support.

This is first step for BSD support in blktap. More to come.
No functional change.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2007-12-04 10:48:28 +00:00
kfraser@localhost.localdomain c1d183f3dd blktap: Fix double-free in tapdisk cleanup.
Signed-off-by: Ben Guthro <bguthro@virtualiron.com>
Signed-off-by: Josh Nicholas <jnicholas@virtualiron.com>
2007-08-30 16:29:10 +01:00
kfraser@localhost.localdomain 4eb73854d7 Fix file descriptor leak in blktapctrl
The blktapctrl process is responsible for spawning individual tapdisk
processes. It does this using the 'system' method, but unfortunately
none of its file descriptors have the close-on-exec flag set. The
parent blktapctl process opens a couple of unix domain sockets
per-tapdisk it spawns. So the first tapdisk get 2 FDs leaked to it,
the second gets 4 FDs leaked to it, the 3rd gets 6 and so on. The use
of 'system' also unneccessarily invokes the shell.

Replace system with fork/execvp, and explicitly close all file handles
up to _SC_OPEN_MAX.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2007-08-01 09:04:20 +01:00
Keir Fraser 43aa5ed8c0 Specify -fno-strict-aliasing in root build config file.
Fixes correctness issues with xenstored and gcc-4.2.

Original patch by Charles Coffing <ccoffing@novell.com>

Signed-off-by: Keir Fraser <keir@xensource.com>
2007-07-07 10:31:15 +01:00
kfraser@localhost.localdomain bdb957f876 blktap: Add fallback code to blktap for missing poll-on-aio support.
blktap requires a xen specific kernel AIO ABI which has been vetoed by
upstream in favour of another approach. Rather than include this ABI,
Fedora has been carrying a patch which makes tap:aio use a thread to
poll for aio events and notify the main thread via a pipe.

The upstream approach of allowing io_getevents() poll normal file
descriptors via epoll is still progressing:
 http://lkml.org/lkml/2007/1/3/16

but when that does make it upstream, blktap will require significant
re-working to use that approach.

In the meantime, here's a patch which uses the poll-in-a-thread
approach only if AIO poll support isn't available. It also hides the
details behind a simple abstraction and makes both tap:aio and
tap:qcow use it.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2007-06-19 16:32:28 +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