diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-06-08 08:05:09 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-06-08 08:05:09 +0100 |
commit | 4b1af8b188ccf532742ed5f2a49f480d9a702333 (patch) | |
tree | a34e14bc4e972f3ec7af5870b6a7ed634cd3282b /tools/blktap2/control/tap-ctl-detach.c | |
parent | c6913b5aaf48107f7bb9fb4e01c7f74c863b3713 (diff) | |
download | xen-4b1af8b188ccf532742ed5f2a49f480d9a702333.tar.gz xen-4b1af8b188ccf532742ed5f2a49f480d9a702333.tar.bz2 xen-4b1af8b188ccf532742ed5f2a49f480d9a702333.zip |
blktap2: The tap-ctl userspace control utility and library.
Tapdisk control in userspace, a replacement for the original blktap2
control stack, which had to pass a kernel space interface based on
sysfs nodes.
All tapdisk processes listen for commands on a unix stream socket. The
control library supports scanning the socket namespace for running
tapdisks, VBD minors allocated, associated images and state inquiry.
Control operations include allocating/releasing devices, spawning
tapdisks, opening/closing images, attaching disk images to
devices. disk pause/resume operations and runtime switching of disk
images.
Signed-off-by: Jake Wires <jake.wires@citrix.com>
Signed-off-by: Daniel Stodden <daniel.stodden@citrix.com>
Diffstat (limited to 'tools/blktap2/control/tap-ctl-detach.c')
-rw-r--r-- | tools/blktap2/control/tap-ctl-detach.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/blktap2/control/tap-ctl-detach.c b/tools/blktap2/control/tap-ctl-detach.c new file mode 100644 index 0000000000..7d7bbf30d3 --- /dev/null +++ b/tools/blktap2/control/tap-ctl-detach.c @@ -0,0 +1,61 @@ +/* + * 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 <stdio.h> +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <getopt.h> + +#include "tap-ctl.h" + +int +tap_ctl_detach(const int id, const int minor) +{ + int err; + tapdisk_message_t message; + + memset(&message, 0, sizeof(message)); + message.type = TAPDISK_MESSAGE_DETACH; + message.cookie = minor; + + err = tap_ctl_connect_send_and_receive(id, &message, 5); + if (err) + return err; + + if (message.type == TAPDISK_MESSAGE_DETACH_RSP) { + err = message.u.response.error; + if (err < 0) + printf("detach failed: %d\n", err); + } else { + printf("got unexpected result '%s' from %d\n", + tapdisk_message_name(message.type), id); + err = EINVAL; + } + + return err; +} |