[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 09 of 16 RFC] blktap3: Introduce the tapdisk control function prototypes
This file is based on the github blktap2, which in turn is based on the XEN blktap2. Most of the changes here are prototype function changes introduced by the the github blktap2. In blktap3, Linux lists are replaced with BSD tail queues. diff -r 23e2537c7257 -r efb6b2844256 tools/blktap3/include/tap-ctl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/blktap3/include/tap-ctl.h Wed Oct 24 17:26:04 2012 +0100 @@ -0,0 +1,184 @@ +/* + * FIXME this is the github blktap2 license + * + * 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 __TAP_CTL_H__ +#define __TAP_CTL_H__ + +#include <syslog.h> +#include <errno.h> +#include <sys/time.h> +#include <tapdisk-message.h> +#include "blktap.h" + +/** + * Contains information about a tapdisk process. + */ +typedef struct tap_list { + + /** + * The process ID. + */ + pid_t pid; + + /** + * TODO? + */ + int minor; + + /** + * State of the VBD, specified in drivers/tapdisk-vbd.h. + */ + int state; + + /** + * TODO type? + */ + char *type; + + /** + * /path/to/file + */ + char *path; + + /** + * for linked lists + */ + TAILQ_ENTRY(tap_list) entry; +} tap_list_t; + +TAILQ_HEAD(tqh_tap_list, tap_list); + +/** + * Iterate over a list of struct tap_list. + */ +#define tap_list_for_each_entry(_pos, _head) \ + TAILQ_FOREACH(_pos, _head, entry) + +/** + * Iterate over a list of struct tap_list allowing deletions without having to + * restart the iteration. + */ +#define tap_list_for_each_entry_safe(_pos, _n, _head) \ + TAILQ_FOREACH_SAFE(_pos, _head, entry, _n) + +/** + * Connects to a tapdisk. + * + * @param /path/to/file of the control socket (e.g. /var/run/blktap-control/ctl/<pid> + * @param socket output parameter that receives the connection + * @returns 0 on success, an error code otherwise + */ +int tap_ctl_connect(const char *path, int *socket); + +/** + * Connects to a tapdisk. + * + * @param id the process ID of the tapdisk to connect to + * @param socket output parameter that receives the connection + * @returns 0 on success, an error code otherwise + */ +int tap_ctl_connect_id(const int id, int *socket); + +/** + * Reads from the tapdisk connection to the buffer. + * + * @param fd the file descriptor of the socket to read from + * @param buf buffer that receives the output + * @param sz size, in bytes, of the buffer + * @param timeout (optional) specifies the maximum time to wait for reading + * @returns 0 on success, an error code otherwise + */ +int tap_ctl_read_raw(const int fd, void *buf, const size_t sz, + struct timeval *timeout); + +int tap_ctl_read_message(int fd, tapdisk_message_t * message, + struct timeval *timeout); +int tap_ctl_write_message(int fd, tapdisk_message_t * message, + struct timeval *timeout); +int tap_ctl_send_and_receive(int fd, tapdisk_message_t * message, + struct timeval *timeout); +int tap_ctl_connect_send_and_receive(int id, tapdisk_message_t * message, + struct timeval *timeout); +char *tap_ctl_socket_name(int id); +int tap_ctl_list_pid(pid_t pid, struct tqh_tap_list *list); + + +/** + * Retrieves a list of all tapdisks. + * + * @param list output parameter that receives the list of tapdisks + * @returns 0 on success, an error code otherwise + */ +int tap_ctl_list(struct tqh_tap_list *list); + +/** + * Deallocates a list of struct tap_list. + * + * @param list the tapdisk information structure to deallocate. + */ +void tap_ctl_list_free(struct tqh_tap_list *list); + +/** + * Creates a tapdisk process. + * + * TODO document parameters + * @param params + * @param flags + * @param prt_minor + * @param secondary + * @returns 0 on success, en error code otherwise + */ +int tap_ctl_create(const char *params, int flags, int prt_minor, + char *secondary); +int tap_ctl_destroy(const int id, const int minor, int force, + struct timeval *timeout); + +/* + * TODO The following functions are not currently used by anything else other + * than the tapdisk itself. Move to a private header? + */ +int tap_ctl_spawn(void); +pid_t tap_ctl_get_pid(const int id); + +int tap_ctl_attach(const int id, const int minor); +int tap_ctl_detach(const int id, const int minor); + +int tap_ctl_open(const int id, const int minor, const char *params, + int flags, const int prt_minor, const char *secondary); +int tap_ctl_close(const int id, const int minor, const int force, + struct timeval *timeout); + +int tap_ctl_pause(const int id, const int minor, struct timeval *timeout); +int tap_ctl_unpause(const int id, const int minor, const char *params); + +ssize_t tap_ctl_stats(pid_t pid, int minor, char *buf, size_t size); +int tap_ctl_stats_fwrite(pid_t pid, int minor, FILE * out); + +#endif /* __TAP_CTL_H__ */ _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |