[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2 of 3] blktap3/libxl: Check whether blktap3 is available
This patch implements function libxl__blktap3_enabled, the equivalent of the existing libxl__blktap_enabled for blktap2. The checks performed are rather simple and should be extended. diff -r dd920505264c -r dd63f2992e71 tools/libxl/Makefile --- a/tools/libxl/Makefile Fri Feb 08 17:23:23 2013 +0000 +++ b/tools/libxl/Makefile Fri Feb 08 17:23:25 2013 +0000 @@ -37,8 +37,10 @@ LIBXLU_LIBS = LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o flexarray.o ifeq ($(LIBXL_BLKTAP),y) LIBXL_OBJS-y += libxl_blktap2.o +LIBXL_OBJS-y += libxl_blktap3.o else LIBXL_OBJS-y += libxl_noblktap2.o +LIBXL_OBJS-y += libxl_noblktap3.o endif LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o libxl_noarch.o diff -r dd920505264c -r dd63f2992e71 tools/libxl/libxl_blktap3.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxl/libxl_blktap3.c Fri Feb 08 17:23:25 2013 +0000 @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2012 Citrix Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#include "libxl_osdeps.h" /* must come before any other headers */ +#include "libxl_internal.h" + +/* FIXME get the tapback name from blktap3 instead of hard-coding */ +#define TAPBACK_NAME "tapback" +#define CMD "pidof " TAPBACK_NAME + +/* + * Simple sanity checks. Most of these checks are not race-free (e.g. checking + * wether the tapdisk binary exists), but at least we get some protection + * against spectacularly silly mistakes. + * + * We don't check whether the tapdisk binary exists as this is done by the + * tapback daemon. + */ +int libxl__blktap3_enabled(libxl__gc *gc) +{ + libxl_ctx *ctx = libxl__gc_owner(gc); + int err; + + /* + * Check whether the tapback daemon is running. + */ + err = system(CMD); + if (err == -1) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, + "failed to check whether the tapback daemon is running\n"); + return 0; + } + err = WEXITSTATUS(err); + if (err != 0) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "tapback daemon not running\n"); + return 0; + } + + /* + * TODO Check for evtchn, gntdev. How do we do that!? + */ + + return 1; +} diff -r dd920505264c -r dd63f2992e71 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Fri Feb 08 17:23:23 2013 +0000 +++ b/tools/libxl/libxl_internal.h Fri Feb 08 17:23:25 2013 +0000 @@ -1337,6 +1337,14 @@ struct libxl__cpuid_policy { }; /* + * blktap3 support + */ +/* libxl__blktap_enabled: + * return true if blktap3 support is available. + */ +_hidden int libxl__blktap3_enabled(libxl__gc *gc); + +/* * blktap2 support */ diff -r dd920505264c -r dd63f2992e71 tools/libxl/libxl_noblktap3.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxl/libxl_noblktap3.c Fri Feb 08 17:23:25 2013 +0000 @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2012 Citrix Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#include "libxl_osdeps.h" /* must come before any other headers */ +#include "libxl_internal.h" + +int libxl__blktap3_enabled(libxl__gc *gc) +{ + return 0; +} _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |