]> git.proxmox.com Git - mirror_qemu.git/blame - nbd.h
omap: Wire up the DMA request line to the GPMC
[mirror_qemu.git] / nbd.h
CommitLineData
75818250 1/*
7a5ca864
FB
2 * Copyright (C) 2005 Anthony Liguori <anthony@codemonkey.ws>
3 *
4 * Network Block Device
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; under version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
8167ee88 16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
75818250 17 */
7a5ca864
FB
18
19#ifndef NBD_H
20#define NBD_H
21
22#include <sys/types.h>
7a5ca864
FB
23
24#include <qemu-common.h>
c12504ce 25
7a5ca864
FB
26#include "block_int.h"
27
75818250 28struct nbd_request {
c12504ce 29 uint32_t magic;
75818250
TS
30 uint32_t type;
31 uint64_t handle;
32 uint64_t from;
33 uint32_t len;
c12504ce 34} __attribute__ ((__packed__));
75818250
TS
35
36struct nbd_reply {
c12504ce 37 uint32_t magic;
75818250
TS
38 uint32_t error;
39 uint64_t handle;
c12504ce 40} __attribute__ ((__packed__));
75818250
TS
41
42enum {
43 NBD_CMD_READ = 0,
44 NBD_CMD_WRITE = 1,
45 NBD_CMD_DISC = 2
46};
47
1d45f8b5
LV
48#define NBD_DEFAULT_PORT 10809
49
75818250
TS
50size_t nbd_wr_sync(int fd, void *buffer, size_t size, bool do_read);
51int tcp_socket_outgoing(const char *address, uint16_t port);
7a5ca864 52int tcp_socket_incoming(const char *address, uint16_t port);
c12504ce
NT
53int tcp_socket_outgoing_spec(const char *address_and_port);
54int tcp_socket_incoming_spec(const char *address_and_port);
cd831bd7
TS
55int unix_socket_outgoing(const char *path);
56int unix_socket_incoming(const char *path);
7a5ca864 57
27982661 58int nbd_negotiate(int csock, off_t size);
1d45f8b5
LV
59int nbd_receive_negotiate(int csock, const char *name, uint32_t *flags,
60 off_t *size, size_t *blocksize);
cd831bd7 61int nbd_init(int fd, int csock, off_t size, size_t blocksize);
75818250
TS
62int nbd_send_request(int csock, struct nbd_request *request);
63int nbd_receive_reply(int csock, struct nbd_reply *reply);
2f726488
TS
64int nbd_trip(BlockDriverState *bs, int csock, off_t size, uint64_t dev_offset,
65 off_t *offset, bool readonly, uint8_t *data, int data_size);
0a4eb864 66int nbd_client(int fd);
7a5ca864
FB
67int nbd_disconnect(int fd);
68
69#endif