blktap3/misc: Merge from blktap2.5, add fixes/improvements, and build blktap3
PATCH 1/1 blktap3/misc: Merge from blktap2.5, add fixes/improvements, and build blktap3
This patch series imports bug-fix and functionality commits from blkap2.5, introduces some other bug fixes and code improvements, and hooks blktap3 into the Xen build system.
PATCH 1/1 blktap3: Merge from blktap2.5
This patch imports commits from blktap2.5 after blktap3 was forked from it in July 2011 (4212b833df6321fac4ccabb75f7f9a476553d6d0) until February 2013 (ce9f9ce8529ac7fc330371c8ec1efe018da637e0). There are a few more to be merged.
The patch introduces (and builds) the following:
* the part utility
* the lvm utility
* the tap-ctl utility
* vhd-util-XXX utilities
* the mirroring functionality (NBD)
* the pause, unpause, and stats commands
* various block drivers (mostly in unknown state)
* bug fixes
tools/blktap3/Makefile +2 -0
@@ -10,6 +10,8 @@ SUBDIRS-y += vhd SUBDIRS-y += control SUBDIRS-y += tapback SUBDIRS-y += drivers +SUBDIRS-y += part +SUBDIRS-y += lvm tags: ctags -R --language-force=C --c-kinds=+px
tools/blktap3/control/Makefile +14 -6
@@ -5,6 +5,8 @@ MAJOR = 3 MINOR = 0 LIBNAME = libblktapctl +IBIN = tap3-ctl + override CFLAGS += \ -I../include \ -DTAPDISK_BUILDDIR='"../drivers"' \
@@ -16,7 +18,7 @@ override CFLAGS += \ -Wextra \ -Werror -# FIXME cause trouble +# TODO cause trouble override CFLAGS += \ -Wno-type-limits \ -Wno-missing-field-initializers \
@@ -31,6 +33,9 @@ CTL_OBJS += tap-ctl-open.o CTL_OBJS += tap-ctl-close.o CTL_OBJS += tap-ctl-create.o CTL_OBJS += tap-ctl-destroy.o +CTL_OBJS += tap-ctl-pause.o +CTL_OBJS += tap-ctl-unpause.o +CTL_OBJS += tap-ctl-stats.o CTL_PICS = $(patsubst %.o,%.opic,$(CTL_OBJS))
@@ -50,15 +55,18 @@ build: $(IBIN) $(LIB_STATIC) $(LIB_SHARE $(CC) $(LDFLAGS) -fPIC -Wl,$(SONAME_LDFLAG) -Wl,$(LIB_SHARED) \ $(SHLIB_LDFLAGS) -rdynamic $^ -o $@ -install: $(LIB_STATIC) $(LIB_SHARED) - $(INSTALL_DIR) -p $(DESTDIR)$(SBINDIR) - # TODO Why install the static version? - #$(INSTALL_DATA) $(LIB_STATIC) $(DESTDIR)$(LIBDIR) +tap3-ctl: tap-ctl.o $(LIB_SHARED) + $(CC) $(LDFLAGS) -o $@ $^ + +install: $(LIB_SHARED) $(IBIN) + $(INSTALL_DIR) -p $(DESTDIR)$(BINDIR) $(INSTALL_PROG) $(LIB_SHARED) $(DESTDIR)$(LIBDIR) + $(INSTALL_PROG) $(IBIN) $(DESTDIR)$(BINDIR) ldconfig clean: - rm -f $(CTL_OBJS) $(PICS) $(DEPS) $(LIB_STATIC) $(LIB_SHARED) + rm -f $(CTL_OBJS) $(PICS) $(DEPS) $(LIB_STATIC) $(LIB_SHARED) $(IBIN)\ + tap-ctl.o .PHONY: all build clean install
tools/blktap3/control/tap-ctl-destroy.c +23 -9
@@ -1,15 +1,29 @@/* -* Copyright (C) 2012 Citrix Ltd. +* Copyright (c) 2008, XenSource Inc. +* All rights reserved. * -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published -* by the Free Software Foundation; version 2.1 only. with the special -* exception on linking described in file LICENSE. +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of XenSource Inc. nor the names of its contributors +* may be used to endorse or promote products derived from this software +* without specific prior written permission. * -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdio.h>
tools/blktap3/control/tap-ctl-ipc.c +7 -4
@@ -154,7 +154,8 @@ tap_ctl_send_and_receive(const int sfd,return err; } -if (tapdisk_message_is_rsp_paired (msg_type)) { +if (TAPDISK_MESSAGE_ERROR != message->type + &&tapdisk_message_is_rsp_paired (msg_type)) {if (message->type - msg_type !=1 ) { err =EINVAL ; EPRINTF("invalid response '%s' to message '%s'\n",
@@ -190,7 +191,7 @@ tap_ctl_connect(const char *name, int *s fd =socket (AF_UNIX ,SOCK_STREAM ,0 );if (fd ==-1 ) { -EPRINTF ("couldn't create socket for %s: %d\n" , name, errno); +EPRINTF ("couldn't create socket for %s: %s\n" , name,strerror (errno));return -errno; }
@@ -200,9 +201,10 @@ tap_ctl_connect(const char *name, int *s err =connect (fd, (const struct sockaddr *)&saddr,sizeof (saddr));if (err) { -EPRINTF ("couldn't connect to %s: %d\n" , name, errno); + err = errno; +EPRINTF ("couldn't connect to %s: %s\n" , name,strerror (err));close (fd); -return -errno; +return -err; } *sfd = fd;
@@ -229,6 +231,7 @@ tap_ctl_connect_id(int id, int *sfd) } err =tap_ctl_connect (name, sfd); +free (name);return err;
tools/blktap3/control/tap-ctl-open.c +1 -1
@@ -45,7 +45,7 @@ tap_ctl_open(const int pid, const char *memset (&message,0 ,sizeof (message)); message.type =TAPDISK_MESSAGE_OPEN ;if (prt_path) { -if (strnlen (prt_path,TAPDISK_MESSAGE_OPEN ) ==TAPDISK_MESSAGE_OPEN ) +if (strlen (prt_path) >=TAPDISK_MESSAGE_OPEN )return -ENAMETOOLONG ;strcpy (message.u.params.prt_path, prt_path); }
tools/blktap3/control/tap-ctl-pause.c new file +70 -0
70 lines not on this page · raw message
tools/blktap3/control/tap-ctl-stats.c new file +178 -0
178 lines not on this page · raw message
tools/blktap3/control/tap-ctl-unpause.c new file +98 -0
98 lines not on this page · raw message
tools/blktap3/control/tap-ctl.c new file +707 -0
707 lines not on this page · raw message
tools/blktap3/control/tap-ctl.h +9 -2
@@ -214,12 +214,19 @@ int tap_ctl_destroy(const int id, const/** * Pauses the VBD. */ -int tap_ctl_pause (const int id,const char * params,struct timeval +int tap_ctl_pause (const int pid,const char * params,struct timeval *timeout);/** * Unpauses the VBD +* +* @param pid the process ID of the tapdisk +* @param params1 VDI (type:/path/to/file) +* @param params2 new VDI to use (type:/path/to/file), optional +* @param flags TODO +* @param secondary TODO */ -int tap_ctl_unpause (const int id,const char * params); +int tap_ctl_unpause (const int pid,const char * params1,const char *params2, +int flags,char *secondary);ssize_t tap_ctl_stats (pid_t pid,const char * params,char *buf,size_t size);int tap_ctl_stats_fwrite (pid_t pid,const char * params,FILE * out);
tools/blktap3/drivers/Makefile +18 -10
@@ -11,7 +11,6 @@ LIBVHDDIR = $(BLKTAP_ROOT)/vhd/lib # FIXME tapdisk-client tapdisk-stream tapdisk-diff not in blktap2.5 IBIN = tapdisk3 LOCK_UTIL = lock-util -INST_DIR = $(SBINDIR) override CFLAGS += \ -fno-strict-aliasing \
@@ -78,15 +77,16 @@ TAP-OBJS-y += tapdisk-server.o TAP-OBJS-y += tapdisk-queue.o TAP-OBJS-y += tapdisk-filter.o TAP-OBJS-y += tapdisk-utils.o -TAP-OBJS-y += tapdisk-log.o +TAP-OBJS-y += tapdisk-log.o TAP-OBJS-y += io-optimize.o #TAP-OBJS-y += lock.o -#TAP-OBJS-y += tapdisk-blktap.o -TAP-OBJS-y += tapdisk-stats.o -TAP-OBJS-y += tapdisk-storage.o -TAP-OBJS-y += tapdisk-loglimit.o -TAP-OBJS-y += tapdisk-logfile.o -TAP-OBJS-y += tapdisk-syslog.o +TAP-OBJS-y += tapdisk-stats.o +TAP-OBJS-y += tapdisk-storage.o +TAP-OBJS-y += tapdisk-loglimit.o +TAP-OBJS-y += tapdisk-logfile.o +TAP-OBJS-y += tapdisk-syslog.o +TAP-OBJS-y += tapdisk-nbdserver.o +TAP-OBJS-y += tapdisk-fdreceiver.o #TAP-OBJS-y += $(PORTABLE-OBJS-y) LIBSRING := sring/libsring.a
@@ -96,6 +96,14 @@ LIBSRING := sring/libsring.a BLK-OBJS-y := block-aio.o BLK-OBJS-y += block-vhd.o +BLK-OBJS-y += block-ram.o +BLK-OBJS-y += block-cache.o +BLK-OJBS-y += block-vindex.o +BLK-OBJS-y += block-lcache.o +BLK-OBJS-y += block-llcache.o +BLK-OBJS-y += block-valve.o +BLK-OBJS-y += block-nbd.o +BLK-OBJS-y += block-vindex.o # FIXME The following exist in blktap2 but not in blktap2.5. #BLK-OBJS-y += aes.o #BLK-OBJS-y += md5.o
@@ -125,8 +133,8 @@ lock-util: lock.c # FIXME img2qcow, qcow-create, qcow2raw not built so not installed # FIXME lock-util should be installed install: all - $(INSTALL_DIR) -p $(DESTDIR)$(INST_DIR) - $(INSTALL_PROG) $(IBIN) $(DESTDIR)$(INST_DIR) + $(INSTALL_DIR) -p $(DESTDIR)$(BINDIR) + $(INSTALL_PROG) $(IBIN) $(DESTDIR)$(BINDIR) clean: subdirs-clean rm -rf .*.d *.o *~ xen TAGS $(IBIN) $(LIB) $(LOCK_UTIL)
tools/blktap3/drivers/atomicio.c new file +65 -0
65 lines not on this page · raw message
tools/blktap3/drivers/atomicio.h new file +33 -0
@@ -0,0 +1,33 @@ +/* $OpenBSD: atomicio.h,v 1.6 2005/05/24 17:32:43 avsm Exp $ */ + +/* +* Copyright (c) 1995,1999 Theo de Raadt. All rights reserved. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +* Ensure all of data on socket comes through. f==read || f==vwrite +*/ +size_t atomicio (ssize_t (*)(int ,void *,size_t ),int ,void *,size_t ); + +#define vwrite (ssize_t (*)(int, void *, size_t))write
tools/blktap3/drivers/block-aio.c +2 -1
@@ -240,7 +240,8 @@ void tdaio_queue_write(td_driver_t * dritd_complete_request (treq, -EBUSY ); } -int tdaio_close (td_driver_t * driver) +int tdaio_close (td_driver_t * driver, +struct tqh_td_image_handle *head __attribute__((unused))) {struct tdaio_state *prv = (struct tdaio_state *) driver->data;
tools/blktap3/drivers/block-cache.c new file +795 -0
795 lines not on this page · raw message
tools/blktap3/drivers/block-lcache.c new file +380 -0
380 lines not on this page · raw message
tools/blktap3/drivers/block-llcache.c new file +610 -0
452 lines not on this page · raw message
tools/blktap3/drivers/block-log.c new file +692 -0
692 lines not on this page · raw message
tools/blktap3/drivers/block-nbd.c new file +908 -0
908 lines not on this page · raw message
tools/blktap3/drivers/block-ram.c new file +267 -0
267 lines not on this page · raw message
tools/blktap3/drivers/block-valve.c new file +703 -0
703 lines not on this page · raw message
tools/blktap3/drivers/block-valve.h new file +41 -0
41 lines not on this page · raw message
tools/blktap3/drivers/block-vhd.c +2 -1
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/block-vindex.c new file +936 -0
936 lines not on this page · raw message
tools/blktap3/drivers/io-optimize.h +1 -22
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/profile.h +1 -22
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-blktap.h deleted +0 -84
84 lines not on this page · raw message
tools/blktap3/drivers/tapdisk-control.c +132 -74
206 lines not on this page · raw message
tools/blktap3/drivers/tapdisk-diff.c new file +814 -0
814 lines not on this page · raw message
tools/blktap3/drivers/tapdisk-disktype.c +14 -18
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-disktype.h +2 -1
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-driver.c +2 -2
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-fdreceiver.c new file +264 -0
264 lines not on this page · raw message
tools/blktap3/drivers/tapdisk-fdreceiver.h new file +48 -0
48 lines not on this page · raw message
tools/blktap3/drivers/tapdisk-image.c +0 -1
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-interface.c +1 -1
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-log.c +4 -1
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-log.h +1 -0
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-nbd.h new file +89 -0
89 lines not on this page · raw message
tools/blktap3/drivers/tapdisk-nbdserver.c new file +712 -0
712 lines not on this page · raw message
tools/blktap3/drivers/tapdisk-nbdserver.h new file +83 -0
83 lines not on this page · raw message
tools/blktap3/drivers/tapdisk-queue.c +7 -4
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-stats.c +24 -2
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-stats.h +4 -0
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-stream.c new file +510 -0
510 lines not on this page · raw message
tools/blktap3/drivers/tapdisk-syslog.c +1 -1
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-utils.c +19 -0
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-utils.h +2 -0
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk-vbd.c +88 -9
97 lines not on this page · raw message
tools/blktap3/drivers/tapdisk-vbd.h +9 -1
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk.c +11 -0
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/tapdisk.h +3 -4
Lines of this file are not shown. View the raw message.
tools/blktap3/drivers/td-rated.1.txt new file +190 -0
190 lines not on this page · raw message
tools/blktap3/drivers/td-rated.c new file +1722 -0
1,722 lines not on this page · raw message
tools/blktap3/drivers/td.c new file +697 -0
697 lines not on this page · raw message
tools/blktap3/include/libvhd-index.h new file +102 -0
102 lines not on this page · raw message
tools/blktap3/include/libvhd-journal.h new file +70 -0
70 lines not on this page · raw message
tools/blktap3/include/tapdisk-message.h +30 -0
Lines of this file are not shown. View the raw message.
tools/blktap3/include/vhd-util.h new file +48 -0
48 lines not on this page · raw message
tools/blktap3/lvm/Makefile new file +45 -0
45 lines not on this page · raw message
tools/blktap3/lvm/lvm-util.c new file +375 -0
375 lines not on this page · raw message
tools/blktap3/lvm/lvm-util.h new file +71 -0
71 lines not on this page · raw message
tools/blktap3/part/part-util.c new file +369 -0
369 lines not on this page · raw message
tools/blktap3/part/partition.c new file +112 -0
112 lines not on this page · raw message
tools/blktap3/part/vhdpartx new file +109 -0
109 lines not on this page · raw message
tools/blktap3/tapback/Makefile +2 -4
Lines of this file are not shown. View the raw message.
tools/blktap3/vhd/Makefile +32 -3
Lines of this file are not shown. View the raw message.
tools/blktap3/vhd/lib/Makefile +22 -2
Lines of this file are not shown. View the raw message.
tools/blktap3/vhd/lib/atomicio.c +1 -1
Lines of this file are not shown. View the raw message.
tools/blktap3/vhd/lib/libvhd-journal.c new file +1540 -0
1,540 lines not on this page · raw message
tools/blktap3/vhd/lib/libvhd.c +30 -34
64 lines not on this page · raw message
tools/blktap3/vhd/lib/libvhdio.c +11 -3
Lines of this file are not shown. View the raw message.
tools/blktap3/vhd/lib/test/random-copy.c new file +226 -0
226 lines not on this page · raw message
tools/blktap3/vhd/lib/test/test-snapshot.c new file +161 -0
161 lines not on this page · raw message
tools/blktap3/vhd/lib/vhd-util-check.c new file +1272 -0
1,272 lines not on this page · raw message
tools/blktap3/vhd/lib/vhd-util-coalesce.c new file +708 -0
708 lines not on this page · raw message
tools/blktap3/vhd/lib/vhd-util-create.c new file +100 -0
100 lines not on this page · raw message
tools/blktap3/vhd/lib/vhd-util-fill.c new file +114 -0
114 lines not on this page · raw message
tools/blktap3/vhd/lib/vhd-util-modify.c new file +170 -0
170 lines not on this page · raw message
tools/blktap3/vhd/lib/vhd-util-query.c new file +195 -0
195 lines not on this page · raw message
tools/blktap3/vhd/lib/vhd-util-read.c new file +937 -0
937 lines not on this page · raw message
tools/blktap3/vhd/lib/vhd-util-repair.c new file +86 -0
86 lines not on this page · raw message
tools/blktap3/vhd/lib/vhd-util-resize.c new file +1200 -0
1,200 lines not on this page · raw message
tools/blktap3/vhd/lib/vhd-util-revert.c new file +98 -0
98 lines not on this page · raw message
tools/blktap3/vhd/lib/vhd-util-scan.c new file +1372 -0
1,372 lines not on this page · raw message
tools/blktap3/vhd/lib/vhd-util-set-field.c new file +119 -0
119 lines not on this page · raw message
tools/blktap3/vhd/lib/vhd-util-snapshot.c new file +235 -0
235 lines not on this page · raw message
tools/blktap3/vhd/vhd-index.c new file +1012 -0
1,012 lines not on this page · raw message
tools/blktap3/vhd/vhd-update.c new file +273 -0
273 lines not on this page · raw message
tools/blktap3/vhd/vhd-util.c new file +168 -0
168 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
PATCH 1/1 blktap3: Ignore blktap3 binaries
In reply to Thanos MakatosThis patch adds the rest of blktap3 binaries to the Mercurial ignore list.
.hgignore +4 -0
@@ -379,3 +379,7 @@ # blktap3 ^tools/blktap3/tapback/tapback$ ^tools/blktap3/drivers/tapdisk3$ +^tools/blktap3/control/tap3-ctl$ +^tools/blktap3/part/part-util$ +^tools/blktap3/vhd/(vhd-index3|vhd-update3|vhd-util3)$ +
PATCH 1/1 blktap3/build
In reply to Thanos MakatosThis patch hooks blktap3 into the build system.
tools/Makefile +1 -0
@@ -25,6 +25,7 @@ ifeq ($(CONFIG_X86),y) SUBDIRS-$(CONFIG_Linux) += blktap endif SUBDIRS-$(CONFIG_Linux) += blktap2 +SUBDIRS-$(CONFIG_Linux) += blktap3 SUBDIRS-$(CONFIG_NetBSD) += $(SUBDIRS-libaio) SUBDIRS-$(CONFIG_NetBSD) += blktap2 SUBDIRS-$(CONFIG_NetBSD) += xenbackendd