[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 10 of 16 RFC] blktap3: Introduce the blktap header file



On Wed, 2012-10-24 at 18:02 +0100, Thanos Makatos wrote:
> In this file various file-system paths are specified, similar to the XEN
> blktap2. These defines need to be documented. Unused defines (i.e. IOCTLs) 
> have
> been removed.
> 
> diff -r efb6b2844256 -r a17c7217bef2 tools/blktap3/include/blktap.h
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/tools/blktap3/include/blktap.h  Wed Oct 24 17:26:14 2012 +0100
> @@ -0,0 +1,85 @@
> +/*
> + * 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 __BLKTAP_3_H__
> +#define __BLKTAP_3_H__
> +
> +#include <xen-external/bsd-sys-queue.h>
> +#include <errno.h>
> +#include <sys/types.h>
> +#include <stdio.h>
> +
> +/*
> + * TODO Document what each define is.
> + */
> +#define BLKTAP3_SYSFS_DIR                   "/sys/class/blktap3"

I thought there was no kernel side to blktap3?

> +#define BLKTAP3_CONTROL_NAME                "blktap-control"
> +#define BLKTAP3_CONTROL_DIR                 "/var/run/"BLKTAP3_CONTROL_NAME
> +#define BLKTAP3_CONTROL_SOCKET              "ctl"

> +#define BLKTAP3_DIRECTORY                   "/dev/xen/blktap-3"
> +#define BLKTAP3_RING_DEVICE                 BLKTAP3_DIRECTORY"/blktap"

Likewise these two.

> +#define BLKTAP3_IO_DEVICEBLKTAP3_DIRECTORY  "/tapdev"
> +#define BLKTAP3_ENOSPC_SIGNAL_FILE          "/var/run/tapdisk3-enospc"
> +
> +/*
> + * TODO Can these be supplied from somewhere else?
> + */
> +#define likely(_cond)   __builtin_expect(!!(_cond), 1)
> +#define unlikely(_cond) __builtin_expect(!!(_cond), 0)
> +
> +/*
> + * FIXME taken from list.h
> + */
> +#define containerof(_ptr, _type, _memb) \
> +    ((_type*)((void*)(_ptr) - offsetof(_type, _memb)))
> +
> +/*
> + * FIXME shouldn't these be supplied from somewhere?
> + */
> +#define __printf(a, b) __attribute__((format(printf, a, b)))
> +#define __scanf(_f, _a) __attribute__((format (scanf, _f, _a)))

These are all abstractions of gcc-isms (presumably to ease ports to
other compilers). We generally don't bother with this sort of thing in
the tools, although you can if you like. You might want to put into a
compiler.h and add suitable #if like those in
xen/include/xen/compiler.h.

> +
> +#define TAILQ_MOVE_HEAD(node, src, dst, entry)  \
> +    TAILQ_REMOVE(src, node, entry);             \
> +    TAILQ_INSERT_HEAD(dst, node, entry);
> +
> +#define TAILQ_MOVE_TAIL(node, src, dst, entry)  \
> +    TAILQ_REMOVE(src, node, entry);             \
> +    TAILQ_INSERT_TAIL(dst, node, entry);
> +
> +/*
> + * TODO This is defined in xen/lib.h, use that instead of redefining it
> + * here.

xen/lib.h is a hypervisor internal header so isn't available to you
here. I think it is fine to define your own (although it should be in a
private header, not part of the libblktap API)

> + */
> +#ifndef ARRAY_SIZE
> +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> +#endif /* ARRAY_SIZE */
> +
> +#endif /* __BLKTAP_3_H__ */
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx
> http://lists.xen.org/xen-devel



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.