From: Daniel Stodden Date: Tue, 18 Jan 2011 19:53:23 +0000 (-0800) Subject: EA-1001: Nuke tapdisk1. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=bc5992fd784ba81215a8ae09b0a55b3a4d9654d5;p=people%2Fdstodden%2Fblktap.git EA-1001: Nuke tapdisk1. Including tapdisk-ipc. Signed-off-by: Daniel Stodden --- diff --git a/drivers/Makefile b/drivers/Makefile index 1fec139..e6ab094 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -3,7 +3,7 @@ include $(BLKTAP_ROOT)/Rules.mk LIBVHDDIR = $(BLKTAP_ROOT)/vhd/lib -IBIN = tapdisk tapdisk2 td-util tapdisk-client tapdisk-stream tapdisk-diff +IBIN = tapdisk2 td-util tapdisk-client tapdisk-stream tapdisk-diff LOCK_UTIL = lock-util INST_DIR = /usr/sbin @@ -21,15 +21,15 @@ LIBS += -lrt CFLAGS += -Wp,-MD,.$(@F).d DEPS = .*.d -tapdisk tapdisk2 td-util tapdisk-stream tapdisk-diff: LIBS += -L$(LIBVHDDIR) -lvhd -luuid +tapdisk2 td-util tapdisk-stream tapdisk-diff: LIBS += -L$(LIBVHDDIR) -lvhd -luuid ifneq ($(USE_SYSTEM_LIBRARIES),y) LIBAIO_DIR = $(XEN_ROOT)/tools/libaio/src -tapdisk tapdisk2 tapdisk-stream tapdisk-diff: AIOLIBS := $(LIBAIO_DIR)/libaio.a -tapdisk tapdisk2 tapdisk-client tapdisk-stream tapdisk-diff: CFLAGS += -I$(LIBAIO_DIR) -I$(XEN_LIBXC) -tapdisk tapdisk2 tapdisk-client tapdisk-stream tapdisk-diff block-log: CFLAGS += -I$(XEN_ROOT)/tools/include +tapdisk2 tapdisk-stream tapdisk-diff: AIOLIBS := $(LIBAIO_DIR)/libaio.a +tapdisk2 tapdisk-client tapdisk-stream tapdisk-diff: CFLAGS += -I$(LIBAIO_DIR) -I$(XEN_LIBXC) +tapdisk2 tapdisk-client tapdisk-stream tapdisk-diff block-log: CFLAGS += -I$(XEN_ROOT)/tools/include else -tapdisk tapdisk2 tapdisk-stream tapdisk-diff: AIOLIBS := -laio +tapdisk2 tapdisk-stream tapdisk-diff: AIOLIBS := -laio endif ifeq ($(VHD_STATIC),y) @@ -38,7 +38,6 @@ endif TAP-OBJS := scheduler.o TAP-OBJS += tapdisk-control.o -TAP-OBJS += tapdisk-ipc.o TAP-OBJS += tapdisk-vbd.o TAP-OBJS += tapdisk-image.o TAP-OBJS += tapdisk-driver.o @@ -69,9 +68,6 @@ BLK-OBJS += block-lcache.o all: $(IBIN) lock-util -tapdisk: $(TAP-OBJS) $(BLK-OBJS) $(MISC-OBJS) tapdisk.c - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(AIOLIBS) - tapdisk2: $(TAP-OBJS) $(BLK-OBJS) $(MISC-OBJS) tapdisk2.c $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(AIOLIBS) diff --git a/drivers/tapdisk-ipc.c b/drivers/tapdisk-ipc.c deleted file mode 100644 index 8998dc6..0000000 --- a/drivers/tapdisk-ipc.c +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright (c) 2008, XenSource Inc. - * All rights reserved. - * - * 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 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 -#include -#include -#include -#include -#include - -#include "tapdisk.h" -#include "tapdisk-ipc.h" -#include "tapdisk-vbd.h" -#include "tapdisk-server.h" -#include "tapdisk-disktype.h" - -static void -tapdisk_ipc_read_event(event_id_t id, char mode, void *private) -{ - td_ipc_t *ipc = private; - tapdisk_ipc_read(ipc); -} - -static void -__tapdisk_ipc_init(td_ipc_t *ipc) -{ - ipc->rfd = -1; - ipc->wfd = -1; - ipc->rfd_event = -1; -} - -int -tapdisk_ipc_open(td_ipc_t *ipc, const char *read, const char *write) -{ - int err; - - memset(ipc, 0, sizeof(td_ipc_t)); - __tapdisk_ipc_init(ipc); - - if (read) { - ipc->rfd = open(read, O_RDWR | O_NONBLOCK); - if (ipc->rfd < 0) { - err = -errno; - EPRINTF("FD open failed %s: %d\n", read, err); - goto fail; - } - - ipc->rfd_event = - tapdisk_server_register_event(SCHEDULER_POLL_READ_FD, - ipc->rfd, 0, - tapdisk_ipc_read_event, - ipc); - if (ipc->rfd_event < 0) { - err = ipc->rfd_event; - goto fail; - } - } - - if (write) { - ipc->wfd = open(write, O_RDWR | O_NONBLOCK); - if (ipc->wfd < 0) { - err = -errno; - EPRINTF("FD open failed %s, %d\n", write, err); - goto fail; - } - } - - return 0; - -fail: - tapdisk_ipc_close(ipc); - return err; -} - -void -tapdisk_ipc_close(td_ipc_t *ipc) -{ - if (ipc->rfd > 0) - close(ipc->rfd); - - if (ipc->wfd > 0) - close(ipc->wfd); - - if (ipc->rfd_event >= 0) - tapdisk_server_unregister_event(ipc->rfd_event); - - __tapdisk_ipc_init(ipc); -} - -static int -tapdisk_ipc_write_message(int fd, tapdisk_message_t *message, int timeout) -{ - fd_set writefds; - int ret, len, offset; - struct timeval tv, *t; - - t = NULL; - offset = 0; - len = sizeof(tapdisk_message_t); - - if (timeout) { - tv.tv_sec = timeout; - tv.tv_usec = 0; - t = &tv; - } - - DPRINTF("sending '%s' message (uuid = %u)\n", - tapdisk_message_name(message->type), message->cookie); - - while (offset < len) { - FD_ZERO(&writefds); - FD_SET(fd, &writefds); - - /* we don't bother reinitializing tv. at worst, it will wait a - * bit more time than expected. */ - - ret = select(fd + 1, NULL, &writefds, NULL, t); - if (ret == -1) - break; - else if (FD_ISSET(fd, &writefds)) { - ret = write(fd, message + offset, len - offset); - if (ret <= 0) - break; - offset += ret; - } else - break; - } - - if (offset != len) { - EPRINTF("failure writing message\n"); - return -EIO; - } - - return 0; -} - -int -tapdisk_ipc_write(td_ipc_t *ipc, int type) -{ - tapdisk_message_t message; - - if (ipc->wfd == -1) - return 0; - - memset(&message, 0, sizeof(tapdisk_message_t)); - message.type = type; - message.cookie = ipc->uuid; - - return tapdisk_ipc_write_message(ipc->wfd, &message, 2); -} - -int -tapdisk_ipc_write_error(td_ipc_t *ipc, const char *text) -{ - tapdisk_message_t message; - - memset(&message, 0, sizeof(message)); - message.type = TAPDISK_MESSAGE_RUNTIME_ERROR; - message.cookie = ipc->uuid; - snprintf(message.u.string.text, - sizeof(message.u.string.text), "%s", text); - - return tapdisk_ipc_write_message(ipc->wfd, &message, 2); -} - -static int -tapdisk_ipc_read_message(int fd, tapdisk_message_t *message, int timeout) -{ - fd_set readfds; - int ret, len, offset; - struct timeval tv, *t; - - t = NULL; - offset = 0; - len = sizeof(tapdisk_message_t); - - if (timeout) { - tv.tv_sec = timeout; - tv.tv_usec = 0; - t = &tv; - } - - memset(message, 0, sizeof(tapdisk_message_t)); - - while (offset < len) { - FD_ZERO(&readfds); - FD_SET(fd, &readfds); - - /* we don't bother reinitializing tv. at worst, it will wait a - * bit more time than expected. */ - - ret = select(fd + 1, &readfds, NULL, NULL, t); - if (ret == -1) - break; - else if (FD_ISSET(fd, &readfds)) { - ret = read(fd, message + offset, len - offset); - if (ret <= 0) - break; - offset += ret; - } else - break; - } - - if (offset != len) { - EPRINTF("failure reading message\n"); - return -EIO; - } - - DPRINTF("received '%s' message (uuid = %u)\n", - tapdisk_message_name(message->type), message->cookie); - - return 0; -} - -int -tapdisk_ipc_read(td_ipc_t *ipc) -{ - int err; - td_vbd_t *vbd; - td_uuid_t uuid; - tapdisk_message_t message; - - err = tapdisk_ipc_read_message(ipc->rfd, &message, 2); - if (err) { - tapdisk_server_check_state(); - return err; - } - - uuid = message.cookie; - vbd = tapdisk_server_get_vbd(uuid); - - if (!vbd && message.type != TAPDISK_MESSAGE_PID) { - EPRINTF("received message for non-existing vbd: %u\n", uuid); - err = -EINVAL; - goto fail; - } - - switch (message.type) { - case TAPDISK_MESSAGE_PID: - err = tapdisk_vbd_initialize(ipc->rfd, ipc->wfd, uuid); - - memset(&message, 0, sizeof(tapdisk_message_t)); - message.cookie = uuid; - - if (!err) { - message.type = TAPDISK_MESSAGE_PID_RSP; - message.u.tapdisk_pid = getpid(); - } else - message.type = TAPDISK_MESSAGE_ERROR; - - return tapdisk_ipc_write_message(ipc->wfd, &message, 0); - - case TAPDISK_MESSAGE_OPEN: - { - image_t image; - char *devname; - td_flag_t flags; - int type; - const char *path; - - flags = 0; - - if (message.u.params.flags & TAPDISK_MESSAGE_FLAG_RDONLY) - flags |= TD_OPEN_RDONLY; - if (message.u.params.flags & TAPDISK_MESSAGE_FLAG_SHARED) - flags |= TD_OPEN_SHAREABLE; - if (message.u.params.flags & TAPDISK_MESSAGE_FLAG_ADD_CACHE) - flags |= TD_OPEN_ADD_CACHE; - if (message.u.params.flags & TAPDISK_MESSAGE_FLAG_VHD_INDEX) - flags |= TD_OPEN_VHD_INDEX; - if (message.u.params.flags & TAPDISK_MESSAGE_FLAG_LOG_DIRTY) - flags |= TD_OPEN_LOG_DIRTY; - - err = asprintf(&devname, "%s/%s%d", - BLKTAP_DEV_DIR, BLKTAP_DEV_NAME, - message.u.params.devnum); - if (err == -1) - goto fail; - - type = tapdisk_disktype_parse_params(message.u.params.path, &path); - if (type < 0) { - err = type; - goto fail; - } - - err = tapdisk_vbd_open(vbd, - type, path, - message.u.params.devnum, - devname, flags); - free(devname); - if (err) - goto fail; - - err = tapdisk_vbd_get_image_info(vbd, &image); - if (err) - goto fail; - - memset(&message, 0, sizeof(tapdisk_message_t)); - message.cookie = uuid; - message.u.image.sectors = image.size; - message.u.image.sector_size = image.secsize; - message.u.image.info = image.info; - message.type = TAPDISK_MESSAGE_OPEN_RSP; - - return tapdisk_ipc_write_message(ipc->wfd, &message, 0); - } - - case TAPDISK_MESSAGE_PAUSE: - tapdisk_vbd_pause(vbd); - return 0; /* response written asynchronously */ - - case TAPDISK_MESSAGE_RESUME: { - int type; - const char *path; - - type = tapdisk_disktype_parse_params(message.u.params.path, &path); - if (type < 0) - return type; - - tapdisk_vbd_resume(vbd, type, path); - return 0; /* response written asynchronously */ - } - case TAPDISK_MESSAGE_CLOSE: - tapdisk_vbd_close(vbd); - return 0; /* response written asynchronously */ - - case TAPDISK_MESSAGE_FORCE_SHUTDOWN: - err = tapdisk_vbd_close(vbd); - if (err) - tapdisk_vbd_kill_queue(vbd); - return 0; /* response written asynchronously */ - - case TAPDISK_MESSAGE_EXIT: - return 0; - } - - err = -EINVAL; - EPRINTF("received unrecognized message %s, uuid = %d\n", - tapdisk_message_name(message.type), uuid); - -fail: - memset(&message, 0, sizeof(tapdisk_message_t)); - message.cookie = uuid; - message.type = TAPDISK_MESSAGE_ERROR; - tapdisk_ipc_write_message(ipc->wfd, &message, 2); - tapdisk_server_check_state(); - - return -err; -} diff --git a/drivers/tapdisk-ipc.h b/drivers/tapdisk-ipc.h deleted file mode 100644 index c213d17..0000000 --- a/drivers/tapdisk-ipc.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2008, XenSource Inc. - * All rights reserved. - * - * 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 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. - */ -#ifndef _TAPDISK_IPC_H_ -#define _TAPDISK_IPC_H_ - -#include "tapdisk-message.h" -#include "scheduler.h" - -typedef struct td_ipc_handle { - int rfd; - int wfd; - event_id_t rfd_event; - td_uuid_t uuid; -} td_ipc_t; - -int tapdisk_ipc_open(td_ipc_t *ipc, const char *read, const char *write); -void tapdisk_ipc_close(td_ipc_t *ipc); -int tapdisk_ipc_read(td_ipc_t *ipc); -int tapdisk_ipc_write(td_ipc_t *ipc, int type); -int tapdisk_ipc_write_error(td_ipc_t *ipc, const char *message); - -#endif diff --git a/drivers/tapdisk-server.c b/drivers/tapdisk-server.c index e64789e..3291160 100644 --- a/drivers/tapdisk-server.c +++ b/drivers/tapdisk-server.c @@ -45,7 +45,6 @@ typedef struct tapdisk_server { int run; - td_ipc_t ipc; struct list_head vbds; scheduler_t scheduler; struct tqueue aio_queue; @@ -226,27 +225,6 @@ tapdisk_server_stop_vbds(void) tapdisk_vbd_kill_queue(vbd); } -static void -tapdisk_server_send_error(const char *message) -{ - td_vbd_t *vbd, *tmp; - - tapdisk_server_for_each_vbd(vbd, tmp) - tapdisk_ipc_write_error(&vbd->ipc, message); -} - -static int -tapdisk_server_init_ipc(const char *read, const char *write) -{ - return tapdisk_ipc_open(&server.ipc, read, write); -} - -static void -tapdisk_server_close_ipc(void) -{ - tapdisk_ipc_close(&server.ipc); -} - static int tapdisk_server_init_aio(void) { @@ -309,7 +287,6 @@ tapdisk_server_close(void) { tapdisk_server_close_tlog(); tapdisk_server_close_aio(); - tapdisk_server_close_ipc(); } void @@ -407,10 +384,6 @@ tapdisk_server_initialize(const char *read, const char *write) tapdisk_server_init(); - err = tapdisk_server_init_ipc(read, write); - if (err) - goto fail; - err = tapdisk_server_complete(); if (err) goto fail; diff --git a/drivers/tapdisk-vbd.c b/drivers/tapdisk-vbd.c index ae52f0c..4319999 100644 --- a/drivers/tapdisk-vbd.c +++ b/drivers/tapdisk-vbd.c @@ -108,9 +108,6 @@ tapdisk_vbd_create(uint16_t uuid) vbd->uuid = uuid; vbd->minor = -1; - vbd->ipc.rfd = -1; - vbd->ipc.wfd = -1; - vbd->ipc.uuid = uuid; vbd->ring.fd = -1; /* default blktap ring completion */ @@ -144,9 +141,6 @@ tapdisk_vbd_initialize(int rfd, int wfd, uint16_t uuid) vbd = tapdisk_vbd_create(uuid); - vbd->ipc.rfd = rfd; - vbd->ipc.wfd = wfd; - tapdisk_server_add_vbd(vbd); return 0; @@ -853,7 +847,6 @@ tapdisk_vbd_shutdown(td_vbd_t *vbd) vbd->kicked, vbd->kicks_in, vbd->kicks_out); tapdisk_vbd_close_vdi(vbd); - tapdisk_ipc_write(&vbd->ipc, TAPDISK_MESSAGE_CLOSE_RSP); tapdisk_vbd_detach(vbd); tapdisk_server_remove_vbd(vbd); free(vbd->name); @@ -1057,7 +1050,6 @@ tapdisk_vbd_pause(td_vbd_t *vbd) td_flag_clear(vbd->state, TD_VBD_PAUSE_REQUESTED); td_flag_set(vbd->state, TD_VBD_PAUSED); - tapdisk_ipc_write(&vbd->ipc, TAPDISK_MESSAGE_PAUSE_RSP); return 0; } @@ -1071,7 +1063,6 @@ tapdisk_vbd_resume(td_vbd_t *vbd, int type, const char *path) if (!td_flag_test(vbd->state, TD_VBD_PAUSED)) { EPRINTF("resume request for unpaused vbd %s\n", vbd->name); - tapdisk_ipc_write(&vbd->ipc, TAPDISK_MESSAGE_ERROR); return -EINVAL; } @@ -1080,7 +1071,6 @@ tapdisk_vbd_resume(td_vbd_t *vbd, int type, const char *path) vbd->name = strdup(path); if (!vbd->name) { EPRINTF("copying new vbd %s name failed\n", path); - tapdisk_ipc_write(&vbd->ipc, TAPDISK_MESSAGE_ERROR); return -EINVAL; } vbd->type = type; @@ -1094,17 +1084,14 @@ tapdisk_vbd_resume(td_vbd_t *vbd, int type, const char *path) sleep(TD_VBD_EIO_SLEEP); } - if (err) { - tapdisk_ipc_write(&vbd->ipc, TAPDISK_MESSAGE_ERROR); + if (err) return err; - } DBG(TLOG_DBG, "resume completed\n"); tapdisk_vbd_start_queue(vbd); td_flag_clear(vbd->state, TD_VBD_PAUSED); td_flag_clear(vbd->state, TD_VBD_PAUSE_REQUESTED); - tapdisk_ipc_write(&vbd->ipc, TAPDISK_MESSAGE_RESUME_RSP); tapdisk_vbd_check_state(vbd); DBG(TLOG_DBG, "state checked\n"); diff --git a/drivers/tapdisk-vbd.h b/drivers/tapdisk-vbd.h index 00bd966..8851dc9 100644 --- a/drivers/tapdisk-vbd.h +++ b/drivers/tapdisk-vbd.h @@ -34,7 +34,6 @@ #include "tapdisk.h" #include "scheduler.h" -#include "tapdisk-ipc.h" #include "tapdisk-image.h" #define TD_VBD_REQUEST_TIMEOUT 120 @@ -93,8 +92,6 @@ struct td_vbd_handle { td_flag_t flags; td_flag_t state; - td_ipc_t ipc; - struct list_head images; int parent_devnum; diff --git a/drivers/tapdisk.c b/drivers/tapdisk.c deleted file mode 100644 index 032799a..0000000 --- a/drivers/tapdisk.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2008, XenSource Inc. - * All rights reserved. - * - * 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 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 -#include -#include -#include -#include -#include - -#include "tapdisk-utils.h" -#include "tapdisk-server.h" - -static const char *program; - -static void -usage(FILE *stream) -{ - fprintf(stream, "blktap-utils: v2.0.0\n"); - fprintf(stream, "Usage: %s [-h ] [-D] \n", program); -} - -int -main(int argc, char *argv[]) -{ - const struct option longopts[] = { - { "help", 0, 0, 'h' }, - { "detach", 0, 0, 'D' } - }; - int err, detach = 0; - const char *facility; - const char *ipc_read, *ipc_write; - - program = basename(argv[0]); - facility = "daemon"; - - do { - int c; - - c = getopt_long(argc, argv, "hDl:", longopts, NULL); - if (c == -1) - break; - - switch (c) { - case 'l': - facility = optarg; - break; - case 'h': - usage(stdout); - return 0; - case 'D': - detach = 1; - break; - default: - goto usage; - } - } while (1); - - if (argc - optind < 2) - goto usage; - - ipc_read = argv[optind++]; - ipc_write = argv[optind++]; - - if (argc - optind) - goto usage; - - if (detach) { - /* NB. This is expected to rarely, if ever, be - used. Blktapctrl is already detached, and breaking - affiliation will be exactly not desirable. */ - err = daemon(0, 0); - if (err) { - PERROR("daemon"); - return -errno; - } - } - - tapdisk_start_logging("TAPDISK", facility); - - err = tapdisk_server_initialize(ipc_read, ipc_write); - if (err) { - EPRINTF("failed to initialize tapdisk server: %d\n", err); - goto out; - } - - err = tapdisk_server_run(); - -out: - tapdisk_stop_logging(); - - return err ? 1 : 0; - -usage: - usage(stderr); - return 1; -} diff --git a/mk/blktap.spec.in b/mk/blktap.spec.in index b80ac5e..21a8ace 100644 --- a/mk/blktap.spec.in +++ b/mk/blktap.spec.in @@ -42,7 +42,6 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libvhd.so* %{_libdir}/libvhdio.so* %{_libdir}/libblktapctl.so* -%{_sbindir}/tapdisk %{_sbindir}/tapdisk2 %{_sbindir}/tap-ctl %{_sbindir}/td-util