Skip to content

Commit 77bad46

Browse files
author
Thanos Makatos
committed
initial commit
Based on trunk/sm.hg, tip 3a0cc7b053e3. Only the files required to build the sm RPM package are imported.
0 parents  commit 77bad46

File tree

135 files changed

+44953
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+44953
-0
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.pc
2+
*~
3+
*.orig
4+
*.o
5+
*.swp
6+
*.pyc
7+
tests/faultinjection/pfilter
8+
tests/faultinjection/libipq.c
9+
tests/faultinjection/libipq/libipq.h
10+
*SR
11+
unittests/unittest.log

LICENSE

Lines changed: 502 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
2+
SM_DRIVERS := File
3+
SM_DRIVERS += NFS
4+
SM_DRIVERS += EXT
5+
SM_DRIVERS += ISCSI
6+
SM_DRIVERS += Dummy
7+
SM_DRIVERS += udev
8+
SM_DRIVERS += ISO
9+
SM_DRIVERS += HBA
10+
SM_DRIVERS += RawHBA
11+
SM_DRIVERS += LVHD
12+
SM_DRIVERS += LVHDoISCSI
13+
SM_DRIVERS += LVHDoHBA
14+
SM_DRIVERS += SHM
15+
16+
SM_LIBS := SR
17+
SM_LIBS += SRCommand
18+
SM_LIBS += VDI
19+
SM_LIBS += cleanup
20+
SM_LIBS += lvutil
21+
SM_LIBS += lvmcache
22+
SM_LIBS += util
23+
SM_LIBS += verifyVHDsOnSR
24+
SM_LIBS += scsiutil
25+
SM_LIBS += scsi_host_rescan
26+
SM_LIBS += vhdutil
27+
SM_LIBS += lvhdutil
28+
SM_LIBS += xs_errors
29+
SM_LIBS += nfs
30+
SM_LIBS += devscan
31+
SM_LIBS += sysdevice
32+
SM_LIBS += iscsilib
33+
SM_LIBS += mpath_dmp
34+
SM_LIBS += mpath_null
35+
SM_LIBS += mpath_cli
36+
SM_LIBS += mpathutil
37+
SM_LIBS += LUNperVDI
38+
SM_LIBS += mpathcount
39+
SM_LIBS += refcounter
40+
SM_LIBS += journaler
41+
SM_LIBS += fjournaler
42+
SM_LIBS += lock
43+
SM_LIBS += flock
44+
SM_LIBS += ipc
45+
SM_LIBS += srmetadata
46+
SM_LIBS += metadata
47+
SM_LIBS += lvmanager
48+
SM_LIBS += blktap2
49+
SM_LIBS += mpp_mpathutil
50+
SM_LIBS += mpp_luncheck
51+
SM_LIBS += updatempppathd
52+
SM_LIBS += lcache
53+
SM_LIBS += resetvdis
54+
SM_LIBS += B_util
55+
56+
CRON_JOBS += ringwatch
57+
58+
SM_XML := XE_SR_ERRORCODES
59+
60+
SM_DEST := /opt/xensource/sm/
61+
DEBUG_DEST := /opt/xensource/debug/
62+
BIN_DEST := /opt/xensource/bin/
63+
MASTER_SCRIPT_DEST := /etc/xensource/master.d/
64+
PLUGIN_SCRIPT_DEST := /etc/xapi.d/plugins/
65+
LIBEXEC := /opt/xensource/libexec/
66+
CRON_DEST := /etc/cron.d/
67+
68+
SM_STAGING := $(DESTDIR)
69+
SM_STAMP := $(MY_OBJ_DIR)/.staging_stamp
70+
71+
.PHONY: build
72+
make -C dcopy
73+
make -C snapwatchd
74+
make -C mpathroot
75+
make -C diskdatatest
76+
77+
.PHONY: install
78+
install:
79+
mkdir -p $(SM_STAGING)
80+
$(call mkdir_clean,$(SM_STAGING))
81+
mkdir -p $(SM_STAGING)$(SM_DEST)
82+
mkdir -p $(SM_STAGING)$(DEBUG_DEST)
83+
mkdir -p $(SM_STAGING)$(BIN_DEST)
84+
mkdir -p $(SM_STAGING)$(MASTER_SCRIPT_DEST)
85+
mkdir -p $(SM_STAGING)$(PLUGIN_SCRIPT_DEST)
86+
mkdir -p $(SM_STAGING)/sbin
87+
for i in $(SM_LIBS); do \
88+
install -m 755 drivers/$$i.py \
89+
$(SM_STAGING)$(SM_DEST); done
90+
install -m 755 drivers/mpathHBA \
91+
$(SM_STAGING)$(SM_DEST)
92+
for i in $(SM_DRIVERS); do \
93+
install -m 755 drivers/$${i}SR.py \
94+
$(SM_STAGING)$(SM_DEST); done
95+
for i in $(SM_XML); do \
96+
install -m 755 drivers/$$i.xml \
97+
$(SM_STAGING)$(SM_DEST); done
98+
cd $(SM_STAGING)$(SM_DEST) && for i in $(SM_DRIVERS); do \
99+
ln -sf $$i"SR.py" $$i"SR"; \
100+
done
101+
rm $(SM_STAGING)$(SM_DEST)/SHMSR
102+
cd $(SM_STAGING)$(SM_DEST) && rm -f LVHDSR && ln -sf LVHDSR.py LVMSR
103+
cd $(SM_STAGING)$(SM_DEST) && rm -f LVHDoISCSISR && ln -sf LVHDoISCSISR.py LVMoISCSISR
104+
cd $(SM_STAGING)$(SM_DEST) && rm -f LVHDoHBASR && ln -sf LVHDoHBASR.py LVMoHBASR
105+
ln -sf $(SM_DEST)mpathutil.py $(SM_STAGING)/sbin/mpathutil
106+
install -m 755 drivers/02-vhdcleanup $(SM_STAGING)$(MASTER_SCRIPT_DEST)
107+
install -m 755 drivers/lvhd-thin $(SM_STAGING)$(PLUGIN_SCRIPT_DEST)
108+
install -m 755 drivers/on-slave $(SM_STAGING)$(PLUGIN_SCRIPT_DEST)
109+
install -m 755 drivers/testing-hooks $(SM_STAGING)$(PLUGIN_SCRIPT_DEST)
110+
install -m 755 drivers/coalesce-leaf $(SM_STAGING)$(PLUGIN_SCRIPT_DEST)
111+
install -m 755 drivers/nfs-on-slave $(SM_STAGING)$(PLUGIN_SCRIPT_DEST)
112+
install -m 755 drivers/tapdisk-pause $(SM_STAGING)$(PLUGIN_SCRIPT_DEST)
113+
install -m 755 drivers/vss_control $(SM_STAGING)$(PLUGIN_SCRIPT_DEST)
114+
install -m 755 drivers/intellicache-clean $(SM_STAGING)$(PLUGIN_SCRIPT_DEST)
115+
ln -sf $(PLUGIN_SCRIPT_DEST)vss_control $(SM_STAGING)$(SM_DEST)
116+
install -m 755 drivers/iscsilib.py $(SM_STAGING)$(SM_DEST)
117+
mkdir -p $(SM_STAGING)$(LIBEXEC)
118+
install -m 755 scripts/local-device-change $(SM_STAGING)$(LIBEXEC)
119+
install -m 755 scripts/check-device-sharing $(SM_STAGING)$(LIBEXEC)
120+
$(MAKE) -C dcopy install DESTDIR=$(SM_STAGING)
121+
$(MAKE) -C snapwatchd install DESTDIR=$(SM_STAGING)
122+
$(MAKE) -C mpathroot install DESTDIR=$(SM_STAGING)
123+
$(MAKE) -C diskdatatest
124+
ln -sf $(SM_DEST)blktap2.py $(SM_STAGING)$(BIN_DEST)/blktap2
125+
install -m 755 -d $(SM_STAGING)$(CRON_DEST)
126+
install -m 644 $(CRON_JOBS:%=etc/cron.d/%) -t $(SM_STAGING)$(CRON_DEST)
127+
ln -sf $(SM_DEST)lcache.py $(SM_STAGING)$(BIN_DEST)tapdisk-cache-stats
128+
cp -rf XenCert $(SM_STAGING)$(DEBUG_DEST)
129+
cp -rf diskdatatest/diskdatatest $(SM_STAGING)$(DEBUG_DEST)/XenCert/diskdatatest
130+
131+
.PHONY: clean
132+
clean:
133+
rm -rf $(SM_STAGING)
134+

dcopy/Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
PREFIX ?= /opt/xensource/libexec
2+
DESTDIR ?=
3+
DEBUGDIR ?= /opt/xensource/debug
4+
5+
6+
OPTS := -D _GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -Wall
7+
8+
SRC := dcopy.c
9+
SRC += atomicio.c
10+
11+
BIN := dcopy
12+
13+
all: dcopy tp
14+
15+
dcopy: dcopy.c
16+
$(CC) $(OPTS) $(SRC) -o $(BIN)
17+
18+
tp: tp.c
19+
$(CC) $(OPTS) tp.c -o tp
20+
21+
test: tp
22+
./test.sh
23+
24+
install: install_dcopy install_tp
25+
26+
install_dcopy: dcopy
27+
mkdir -p $(DESTDIR)$(PREFIX)
28+
install -m 755 $^ $(DESTDIR)$(PREFIX)
29+
30+
install_tp: tp
31+
mkdir -p $(DESTDIR)$(DEBUGDIR)
32+
install -m 755 $^ $(DESTDIR)$(DEBUGDIR)
33+
34+
clean:
35+
rm -f dcopy tp *.o source_img dest_img

dcopy/atomicio.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2005 Anil Madhavapeddy. All rights reserved.
3+
* Copyright (c) 1995,1999 Theo de Raadt. All rights reserved.
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions
8+
* are met:
9+
* 1. Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
*/
26+
27+
#include <stdlib.h>
28+
#include <errno.h>
29+
#include "atomicio.h"
30+
31+
/*
32+
* ensure all of data on socket comes through. f==read || f==vwrite
33+
*/
34+
size_t
35+
atomicio(f, fd, _s, n)
36+
ssize_t (*f) (int, void *, size_t);
37+
int fd;
38+
void *_s;
39+
size_t n;
40+
{
41+
char *s = _s;
42+
size_t pos = 0;
43+
ssize_t res;
44+
45+
while (n > pos) {
46+
res = (f) (fd, s + pos, n - pos);
47+
switch (res) {
48+
case -1:
49+
if (errno == EINTR || errno == EAGAIN)
50+
continue;
51+
return 0;
52+
case 0:
53+
errno = EPIPE;
54+
return pos;
55+
default:
56+
pos += (size_t)res;
57+
}
58+
}
59+
return (pos);
60+
}
61+

dcopy/atomicio.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* $OpenBSD: atomicio.h,v 1.6 2005/05/24 17:32:43 avsm Exp $ */
2+
3+
/*
4+
* Copyright (c) 1995,1999 Theo de Raadt. All rights reserved.
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
* 1. Redistributions of source code must retain the above copyright
11+
* notice, this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
/*
29+
* Ensure all of data on socket comes through. f==read || f==vwrite
30+
*/
31+
size_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t);
32+
33+
#define vwrite (ssize_t (*)(int, void *, size_t))write

0 commit comments

Comments
 (0)