From: Thanos Makatos <thanos.makatos@citrix.com>
To: xen-devel@lists.xensource.com
Cc: thanos.makatos@citrix.com
Subject: [PATCH 5 of 9 RFC v2] blktap3/libblktapctl: Introduce functionality used by tapback to instruct tapdisk to connect to the sring
Date: Tue, 4 Dec 2012 18:19:43 +0000 [thread overview]
Message-ID: <59bb0802d11ee95e4a08.1354645183@makatos-desktop> (raw)
In-Reply-To: <patchbomb.1354645178@makatos-desktop>
This patch introduces functions tap_ctl_connect_xenblkif and
tap_ctl_disconnect_xenblkif, that are used by the tapback daemon to instruct a
running tapdisk process to connect to/disconnect from the shared ring.
diff --git a/tools/blktap3/control/tap-ctl-xen.c b/tools/blktap3/control/tap-ctl-xen.c
new file mode 100644
--- /dev/null
+++ b/tools/blktap3/control/tap-ctl-xen.c
@@ -0,0 +1,80 @@
+/*
+ * 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 <stdio.h>
+#include <string.h>
+
+#include "tap-ctl.h"
+#include "tap-ctl-xen.h"
+
+int tap_ctl_connect_xenblkif(pid_t pid, int minor, domid_t domid,
+ int devid, const grant_ref_t * grefs, int order,
+ const evtchn_port_t port, int proto, const char *pool)
+{
+ tapdisk_message_t message;
+ int i, err;
+
+ memset(&message, 0, sizeof(message));
+ message.type = TAPDISK_MESSAGE_XENBLKIF_CONNECT;
+ message.cookie = minor;
+
+ message.u.blkif.domid = domid;
+ message.u.blkif.devid = devid;
+ for (i = 0; i < 1 << order; i++)
+ message.u.blkif.gref[i] = grefs[i];
+ message.u.blkif.order = order;
+ message.u.blkif.port = port;
+ message.u.blkif.proto = proto;
+ if (pool)
+ strncpy(message.u.blkif.pool, pool, sizeof(message.u.blkif.pool));
+ else
+ message.u.blkif.pool[0] = 0;
+
+ err = tap_ctl_connect_send_and_receive(pid, &message, NULL);
+ if (err)
+ return err;
+
+ if (message.type == TAPDISK_MESSAGE_XENBLKIF_CONNECT_RSP)
+ err = -message.u.response.error;
+ else
+ err = -EINVAL;
+
+ return err;
+}
+
+int tap_ctl_disconnect_xenblkif(pid_t pid, int minor, domid_t domid,
+ int devid, struct timeval *timeout)
+{
+ tapdisk_message_t message;
+ int err;
+
+ memset(&message, 0, sizeof(message));
+ message.type = TAPDISK_MESSAGE_XENBLKIF_DISCONNECT;
+ message.cookie = minor;
+ message.u.blkif.domid = domid;
+ message.u.blkif.devid = devid;
+
+ err = tap_ctl_connect_send_and_receive(pid, &message, timeout);
+ if (message.type == TAPDISK_MESSAGE_XENBLKIF_CONNECT_RSP)
+ err = -message.u.response.error;
+ else
+ err = -EINVAL;
+
+ return err;
+}
diff --git a/tools/blktap3/control/tap-ctl-xen.h b/tools/blktap3/control/tap-ctl-xen.h
new file mode 100644
--- /dev/null
+++ b/tools/blktap3/control/tap-ctl-xen.h
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+#ifndef __TAP_CTL_XEN_H__
+#define __TAP_CTL_XEN_H__
+
+#include <xen/xen.h>
+#include <xen/grant_table.h>
+#include <xen/event_channel.h>
+
+/**
+ * Instructs a tapdisk to connect to the shared ring.
+ *
+ * TODO further explain parameters
+ *
+ * @param pid the process ID of the tapdisk that should connect to the shared
+ * ring
+ * @param minor the minor number of the virtual block device
+ * @param domid the domain ID of the guest VM
+ * @param devid the device ID
+ * @param grefs the grant references
+ * @param order number of grant references, expressed as a 2's order
+ * @param port event channel port
+ * @param proto the protocol: native (XENIO_BLKIF_PROTO_NATIVE),
+ * x86 (XENIO_BLKIF_PROTO_X86_32), or x64 (XENIO_BLKIF_PROTO_X86_64)
+ * @param pool TODO page pool?
+ * @returns 0 on success, an error code otherwise
+ */
+int tap_ctl_connect_xenblkif(pid_t pid, int minor, domid_t domid, int devid,
+ const grant_ref_t * grefs, int order, evtchn_port_t port, int proto,
+ const char *pool);
+
+/**
+ * Instructs a tapdisk to disconnect from the shared ring.
+ *
+ * @param pid the process ID of the tapdisk that should disconnect
+ * @param minor the minor number of the virtual block device
+ * @param domid the ID of the guest VM
+ * @param devid the device ID of the virtual block device
+ * @param timeout timeout to wait, if NULL the function will wait indefinitely
+ */
+int tap_ctl_disconnect_xenblkif(pid_t pid, int minor, domid_t domid,
+ int devid, struct timeval *timeout);
+
+#endif /* __TAP_CTL_XEN_H__ */
next prev parent reply other threads:[~2012-12-04 18:19 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-04 18:19 [PATCH 0 of 9 RFC v2] blktap3: Introduce a small subset of blktap3 files Thanos Makatos
2012-12-04 18:19 ` [PATCH 1 of 9 RFC v2] blktap3: Introduce blktap3 headers Thanos Makatos
2013-01-18 13:45 ` Ian Campbell
2013-01-18 17:43 ` Thanos Makatos
2013-01-21 10:37 ` Ian Campbell
2012-12-04 18:19 ` [PATCH 2 of 9 RFC v2] blktap3/libblktapctl: Introduce tapdisk message types and structures Thanos Makatos
2013-01-18 13:49 ` Ian Campbell
2013-01-21 18:16 ` Thanos Makatos
2012-12-04 18:19 ` [PATCH 3 of 9 RFC v2] blktap3/libblktapctl: Introduce the tapdisk control header Thanos Makatos
2012-12-04 18:19 ` [PATCH 4 of 9 RFC v2] blktap3/libblktapctl: Introduce listing running tapdisks functionality Thanos Makatos
2012-12-04 18:19 ` Thanos Makatos [this message]
2013-01-18 13:54 ` [PATCH 5 of 9 RFC v2] blktap3/libblktapctl: Introduce functionality used by tapback to instruct tapdisk to connect to the sring Ian Campbell
2013-01-21 18:16 ` Thanos Makatos
2012-12-04 18:19 ` [PATCH 6 of 9 RFC v2] blktap3/libblktapctl: Introduce block device control information retrieval functionality Thanos Makatos
2013-01-18 13:55 ` Ian Campbell
2013-01-21 18:16 ` Thanos Makatos
2012-12-04 18:19 ` [PATCH 7 of 9 RFC v2] blktap3/libblktapctl: Introduce tapdisk message exchange functionality Thanos Makatos
2012-12-04 18:19 ` [PATCH 8 of 9 RFC v2] blktap3/libblktapctl: Introduce tapdisk spawn functionality Thanos Makatos
2012-12-04 18:19 ` [PATCH 9 of 9 RFC v2] blktap3/libblktapctl: Introduce makefile that builds tapback-required libblktapctl functionality Thanos Makatos
2013-01-18 13:59 ` Ian Campbell
2013-01-21 18:16 ` Thanos Makatos
2013-01-22 9:28 ` Ian Campbell
2013-01-11 15:40 ` [PATCH 0 of 9 RFC v2] blktap3: Introduce a small subset of blktap3 files Thanos Makatos
2013-01-18 13:39 ` Ian Campbell
2013-01-18 16:37 ` Thanos Makatos
2013-01-18 16:46 ` Ian Campbell
2013-01-18 16:58 ` Thanos Makatos
2013-01-18 17:01 ` Ian Campbell
2013-01-18 17:15 ` Thanos Makatos
2013-01-18 17:25 ` Ian Campbell
2013-01-22 17:29 ` 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=59bb0802d11ee95e4a08.1354645183@makatos-desktop \
--to=thanos.makatos@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).