From: Thanos Makatos <thanos.makatos@citrix.com>
To: xen-devel@lists.xensource.com
Cc: andrei.lifchits@citrix.com
Subject: [PATCH 2 of 3] blktap3/libxl: Check whether blktap3 is available
Date: Fri, 8 Feb 2013 17:24:13 +0000 [thread overview]
Message-ID: <dd63f2992e71a1e43abf.1360344253@makatos-desktop> (raw)
In-Reply-To: <patchbomb.1360344251@makatos-desktop>
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;
+}
next prev parent reply other threads:[~2013-02-08 17:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-08 17:24 [PATCH 0 of 3] blktap3/libxl: add support for blktap3 in libxl Thanos Makatos
2013-02-08 17:24 ` [PATCH 1 of 3] blktap3/libxl: add new device kind and disk back-end Thanos Makatos
2013-02-08 17:24 ` Thanos Makatos [this message]
2013-02-12 17:57 ` [PATCH 2 of 3] blktap3/libxl: Check whether blktap3 is available Ian Jackson
2013-02-13 10:44 ` Thanos Makatos
2013-03-05 12:58 ` Thanos Makatos
2013-03-05 13:51 ` Ian Jackson
2013-03-05 14:25 ` Thanos Makatos
2013-03-05 14:28 ` Ian Jackson
2013-03-05 14:42 ` Thanos Makatos
2013-03-05 14:53 ` Ian Jackson
2013-03-05 15:13 ` Thanos Makatos
2013-03-05 15:27 ` Ian Jackson
2013-03-05 15:44 ` Thanos Makatos
2013-02-08 17:24 ` [PATCH 3 of 3] blktap3/libxl: Handles blktap3 device in libxl Thanos Makatos
2013-02-12 18:01 ` Ian Jackson
2013-02-13 11:16 ` Thanos Makatos
-- strict thread matches above, loose matches on Subject: below --
2013-04-19 15:40 [PATCH 0 of 3] blktap3/libxl: add support for blktap3 " Thanos Makatos
2013-04-19 15:40 ` [PATCH 2 of 3] blktap3/libxl: Check whether blktap3 is available Thanos Makatos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dd63f2992e71a1e43abf.1360344253@makatos-desktop \
--to=thanos.makatos@citrix.com \
--cc=andrei.lifchits@citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).