Skip to content

Commit e1a4a11

Browse files
committed
Initial commit
0 parents  commit e1a4a11

32 files changed

+4679
-0
lines changed

CLA

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
The libnvidia-container
2+
Software Grant and Corporate Contributor License Agreement ("Agreement")
3+
4+
Thank you for your interest in the libnvidia-container Project (the
5+
"Project"). In order to clarify the intellectual property license
6+
granted with Contributions from any person or entity, NVIDIA
7+
Corporation (the “Copyright Holders") must have a Contributor License
8+
Agreement (CLA) on file that has been signed by each Contributor,
9+
indicating agreement to the license terms below. This license is
10+
for your protection as a Contributor as well as the protection of the
11+
Project and its users; it does not change your rights to use your own
12+
Contributions for any other purpose.
13+
14+
This version of the Agreement allows an entity (the "Corporation") to
15+
submit Contributions to the Project, to authorize Contributions
16+
submitted by its designated employees to the Project, and to grant
17+
copyright and patent licenses thereto to the Copyright Holders.
18+
19+
If you have not already done so, please complete and sign, then scan and
20+
email a pdf file of this Agreement to [email protected].
21+
Please read this document carefully before signing and keep a copy for
22+
your records.
23+
24+
Corporation name: ________________________________________________
25+
26+
Corporation address: ________________________________________________
27+
28+
________________________________________________
29+
30+
________________________________________________
31+
32+
Point of Contact: ________________________________________________
33+
34+
E-Mail: ________________________________________________
35+
36+
Telephone: _____________________ Fax: _____________________
37+
38+
39+
You accept and agree to the following terms and conditions for Your
40+
present and future Contributions submitted to the Project. In
41+
return, the Copyright Holders shall not use Your Contributions in a way
42+
that is contrary to the public benefit or inconsistent with its nonprofit
43+
status and bylaws in effect at the time of the Contribution. Except
44+
for the license granted herein to the Copyright Holders and recipients of
45+
software distributed by the Copyright Holders, You reserve all right, title,
46+
and interest in and to Your Contributions.
47+
48+
1. Definitions.
49+
50+
"You" (or "Your") shall mean the copyright owner or legal entity
51+
authorized by the copyright owner that is making this Agreement
52+
with the Copyright Holders. For legal entities, the entity making a
53+
Contribution and all other entities that control, are controlled by,
54+
or are under common control with that entity are considered to be a
55+
single Contributor. For the purposes of this definition, "control"
56+
means (i) the power, direct or indirect, to cause the direction or
57+
management of such entity, whether by contract or otherwise, or
58+
(ii) ownership of fifty percent (50%) or more of the outstanding
59+
shares, or (iii) beneficial ownership of such entity.
60+
61+
"Contribution" shall mean the code, documentation or other original
62+
works of authorship expressly identified in Schedule B, as well as
63+
any original work of authorship, including
64+
any modifications or additions to an existing work, that is intentionally
65+
submitted by You to the Copyright Holders for inclusion in, or
66+
documentation of, any of the products owned or managed by the
67+
Copyright Holders (the "Work"). For the purposes of this definition,
68+
"submitted" means any form of electronic, verbal, or written
69+
communication sent to the Copyright Holders or its representatives,
70+
including but not limited to communication on electronic mailing
71+
lists, source code control systems, and issue tracking systems
72+
that are managed by, or on behalf of, the Copyright Holders for the
73+
purpose of discussing and improving the Work, but excluding
74+
communication that is conspicuously marked or otherwise designated
75+
in writing by You as "Not a Contribution."
76+
77+
2. Grant of Copyright License. Subject to the terms and conditions
78+
of this Agreement, You hereby grant to the Copyright Holders and to
79+
recipients of software distributed by the Copyright Holders a
80+
perpetual, worldwide, non-exclusive, no-charge, royalty-free,
81+
irrevocable copyright license to reproduce, prepare derivative works
82+
of, publicly display, publicly perform, sublicense, and distribute
83+
Your Contributions and such derivative works.
84+
85+
3. Grant of Patent License. Subject to the terms and conditions of
86+
this Agreement, You hereby grant to the Copyright Holders and to
87+
recipients of software distributed by the Copyright Holders
88+
a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
89+
irrevocable (except as stated in this section) patent license
90+
to make, have made, use, offer to sell, sell, import, and otherwise
91+
transfer the Work, where such license applies only to those
92+
patent claims licensable by You that are necessarily infringed
93+
by Your Contribution(s) alone or by combination of Your Contribution(s)
94+
with the Work to which such Contribution(s) were submitted.
95+
If any entity institutes patent litigation against You or any
96+
other entity (including a cross-claim or counterclaim in a lawsuit)
97+
alleging that your Contribution, or the Work to which you have
98+
contributed, constitutes direct or contributory patent infringement,
99+
then any patent licenses granted to that entity under this Agreement
100+
for that Contribution or Work shall terminate as of the date such
101+
litigation is filed.
102+
103+
4. You represent that You are legally entitled to grant the above
104+
license. You represent further that each employee of the
105+
Corporation designated on Schedule A below (or in a subsequent
106+
written modification to that Schedule) is authorized to submit
107+
Contributions on behalf of the Corporation.
108+
109+
5. You represent that each of Your Contributions is Your original
110+
creation (see section 7 for submissions on behalf of others).
111+
112+
6. You are not expected to provide support for Your Contributions,
113+
except to the extent You desire to provide support. You may provide
114+
support for free, for a fee, or not at all. Unless required by
115+
applicable law or agreed to in writing, You provide Your
116+
Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
117+
OF ANY KIND, either express or implied, including, without
118+
limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
119+
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
120+
121+
7. Should You wish to submit work that is not Your original creation,
122+
You may submit it to the Copyright Holders separately from any
123+
Contribution, identifying the complete details of its source and
124+
of any license or other restriction (including, but not limited
125+
to, related patents, trademarks, and license agreements) of which
126+
you are personally aware, and conspicuously marking the work as
127+
"Submitted on behalf of a third-party: [named here]".
128+
129+
8. It is your responsibility to notify the Copyright Holders when any change
130+
is required to the list of designated employees authorized to submit
131+
Contributions on behalf of the Corporation, or to the Corporation's
132+
Point of Contact with the Copyright Holders.
133+
134+
135+
136+
Please sign: __________________________________ Date: _______________
137+
138+
Title: __________________________________
139+
140+
Corporation: __________________________________
141+
142+
143+
144+
145+
Schedule A
146+
147+
[Initial list of designated employees. NB: authorization is not
148+
tied to particular Contributions.]
149+
150+
151+
152+
153+
154+
155+
Schedule B
156+
157+
[Identification of optional concurrent software grant. Would be
158+
left blank or omitted if there is no concurrent software grant.]
159+
160+

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions
5+
are met:
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above copyright
9+
notice, this list of conditions and the following disclaimer in the
10+
documentation and/or other materials provided with the distribution.
11+
* Neither the name of NVIDIA CORPORATION nor the names of its
12+
contributors may be used to endorse or promote products derived
13+
from this software without specific prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Makefile

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
#
2+
# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3+
#
4+
5+
.DEFAULT_GOAL := all
6+
7+
##### Global variables #####
8+
9+
WITH_TIRPC ?= 0
10+
WITH_SECCOMP ?= 1
11+
12+
##### Global definitions #####
13+
14+
export CUDA_DIR ?= /usr/local/cuda
15+
export DEPS_DIR ?= $(CURDIR)/deps
16+
export DIST_DIR ?= $(CURDIR)/dist
17+
export MAKE_DIR ?= $(CURDIR)/mk
18+
export DEBUG_DIR ?= $(CURDIR)/.debug
19+
20+
include $(MAKE_DIR)/common.mk
21+
22+
##### Source definitions #####
23+
24+
TARGET := libnvidia-container
25+
ARCH := x86_64
26+
MAJOR := $(call getdef,NVC_MAJOR,nvc.h)
27+
MINOR := $(call getdef,NVC_MINOR,nvc.h)
28+
REVISION := $(call getdef,NVC_REVISION,nvc.h)
29+
VERSION := $(MAJOR).$(MINOR).$(REVISION)
30+
31+
STATIC_LIB := $(TARGET).a
32+
SHARED_LIB := $(TARGET).so.$(VERSION)
33+
SONAME := $(TARGET).so.$(MAJOR)
34+
35+
VERSION_SCRIPT := nvc.sym
36+
BUILD_INFO := build.info
37+
DRIVER_RPC := driver_rpc.x
38+
39+
SRCS := driver.c \
40+
elftool.c \
41+
error.c \
42+
ldcache.c \
43+
nvc.c \
44+
nvc_entry.c \
45+
nvc_exec.c \
46+
nvc_info.c \
47+
nvc_mount.c \
48+
nvc_container.c \
49+
options.c \
50+
utils.c
51+
52+
RPCS := driver_rpc.h \
53+
driver_xdr.c \
54+
driver_svc.c \
55+
driver_clt.c
56+
57+
##### Flags definitions #####
58+
59+
ARFLAGS := -rU
60+
CPPFLAGS += -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -DNV_LINUX -MMD -MF .$*.d
61+
CFLAGS += -std=gnu11 -O2 -g -Wall -Wextra -Wcast-align -Wpointer-arith -Wmissing-prototypes -Wnonnull \
62+
-Wwrite-strings -Wlogical-op -Wformat=2 -Wmissing-format-attribute -Winit-self -Wshadow \
63+
-Wstrict-prototypes -Wunreachable-code -Wconversion -Wsign-conversion \
64+
-Wno-unknown-warning-option -Wno-format-extra-args -Wno-gnu \
65+
-fdata-sections -ffunction-sections -fstack-protector -fstrict-aliasing -fvisibility=hidden -fPIC
66+
LDFLAGS += -shared -Wl,-zrelro -Wl,-znow -Wl,-zdefs -Wl,--gc-sections -Wl,-soname=$(SONAME) -Wl,--version-script=$(VERSION_SCRIPT)
67+
68+
CPPFLAGS += -isystem $(CUDA_DIR)/include -isystem $(DEPS_DIR)/usr/local/include
69+
LDFLAGS += -Wl,--entry=nvc_entry -Wl,--undefined=nvc_interp -L$(DEPS_DIR)/usr/local/lib
70+
STATIC_LDLIBS += -l:libelf.a -l:libnvidia-modprobe-utils.a
71+
SHARED_LDLIBS += -ldl -lcap
72+
ifeq ($(WITH_TIRPC), 1)
73+
CPPFLAGS += -isystem $(DEPS_DIR)/usr/local/include/tirpc -DWITH_TIRPC
74+
STATIC_LDLIBS += -l:libtirpc.a
75+
SHARED_LDLIBS += -lpthread
76+
endif
77+
ifeq ($(WITH_SECCOMP), 1)
78+
CPPFLAGS += -DWITH_SECCOMP
79+
SHARED_LDLIBS += -lseccomp
80+
endif
81+
LDLIBS += $(STATIC_LDLIBS) $(SHARED_LDLIBS)
82+
83+
$(word 1,$(RPCS)): RPCGENFLAGS=-h
84+
$(word 2,$(RPCS)): RPCGENFLAGS=-c
85+
$(word 3,$(RPCS)): RPCGENFLAGS=-m
86+
$(word 4,$(RPCS)): RPCGENFLAGS=-l
87+
88+
##### Private targets #####
89+
90+
OBJS := $(SRCS:.c=.o) $(patsubst %.c,%.o,$(filter %.c,$(RPCS)))
91+
STATIC_LIB_OBJ := $(STATIC_LIB:.a=.o)
92+
93+
nvc.o nvc_entry.o: info
94+
nvc.o nvc_entry.o: CPPFLAGS += -include $(BUILD_INFO)
95+
96+
$(RPCS): $(DRIVER_RPC)
97+
$(RM) $@
98+
$(RPCGEN) $(RPCGENFLAGS) -C -M -N -o $@ $(DRIVER_RPC)
99+
100+
$(OBJS): %.o: %.c | deps
101+
$(COMPILE.c) $(OUTPUT_OPTION) $<
102+
103+
-include $(OBJS:%.o=.%.d)
104+
105+
$(SHARED_LIB): $(OBJS)
106+
$(MKDIR) -p $(DEBUG_DIR)
107+
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
108+
$(OBJCPY) --only-keep-debug $@ $(SONAME)
109+
$(OBJCPY) --add-gnu-debuglink=$(SONAME) $@
110+
$(MV) $(SONAME) $(DEBUG_DIR)
111+
$(STRIP) --strip-unneeded $@
112+
113+
$(STATIC_LIB_OBJ): $(OBJS)
114+
$(LD) -d -r --exclude-libs ALL -L$(DEPS_DIR)/usr/local/lib -o $@ $^ $(STATIC_LDLIBS)
115+
$(OBJCPY) --localize-hidden $@
116+
$(STRIP) --strip-unneeded $@
117+
118+
##### Public targets #####
119+
120+
.PHONY: all shared static deps info install uninstall dist depsclean mostlyclean clean distclean
121+
122+
all: release
123+
124+
debug: shared static
125+
126+
release: CPPFLAGS += -DNDEBUG
127+
release: shared static
128+
129+
shared: $(SHARED_LIB)
130+
131+
static: $(STATIC_LIB)($(STATIC_LIB_OBJ))
132+
133+
deps: export DESTDIR=$(DEPS_DIR)
134+
deps: $(RPCS)
135+
$(MKDIR) -p $(DEPS_DIR)
136+
$(MAKE) -f $(MAKE_DIR)/elftoolchain.mk install
137+
$(MAKE) -f $(MAKE_DIR)/nvidia-modprobe.mk install
138+
ifeq ($(WITH_TIRPC), 1)
139+
$(MAKE) -f $(MAKE_DIR)/libtirpc.mk install
140+
endif
141+
142+
info:
143+
@printf '#define BUILD_DATE "%s"\n' '$(shell date -u --iso-8601=minutes)' >$(BUILD_INFO)
144+
@printf '#define SCM_REVISION "%s"\n' '$(shell git rev-parse HEAD)' >>$(BUILD_INFO)
145+
@printf '#define COMPILE_OPTS "%s"\n' '$(CFLAGS)' >>$(BUILD_INFO)
146+
147+
install: all
148+
$(INSTALL) -D -m 644 nvc.h $(DESTDIR)$(includedir)/nvc.h
149+
$(INSTALL) -D -m 644 $(STATIC_LIB) $(DESTDIR)$(libdir)/$(STATIC_LIB)
150+
$(INSTALL) -D -m 755 $(SHARED_LIB) $(DESTDIR)$(libdir)/$(SHARED_LIB)
151+
$(INSTALL) -D -m 755 $(DEBUG_DIR)/$(SONAME) $(DESTDIR)$(libdbgdir)/$(DEBUG_DIR)/$(SONAME)
152+
$(INSTALL) -d -m 755 $(DESTDIR)$(pkgconfdir)
153+
$(LDCONFIG) -n $(DESTDIR)$(libdir)
154+
$(LN) -sf $(SONAME) $(DESTDIR)$(libdir)/$(TARGET).so
155+
$(M4) -D'$$VERSION=$(VERSION)' -D'$$PRIVATE_LIBS=$(SHARED_LDLIBS)' $(MAKE_DIR)/$(TARGET).pc.m4 > $(DESTDIR)$(pkgconfdir)/$(TARGET).pc
156+
157+
uninstall:
158+
$(RM) $(addprefix $(DESTDIR)$(includedir)/,nvc.h)
159+
$(RM) $(addprefix $(DESTDIR)$(libdir)/,$(SHARED_LIB) $(STATIC_LIB) $(SONAME) $(TARGET).so)
160+
$(RM) $(DESTDIR)$(pkgconfdir)/$(TARGET).pc
161+
162+
dist: DESTDIR=$(DIST_DIR)/$(TARGET)_$(VERSION)
163+
dist: install
164+
$(TAR) -C $(dir $(DESTDIR)) -caf $(DESTDIR)_$(ARCH).tar.xz $(notdir $(DESTDIR))
165+
$(RM) -r $(DESTDIR)
166+
167+
depsclean:
168+
-$(MAKE) -f $(MAKE_DIR)/elftoolchain.mk clean
169+
-$(MAKE) -f $(MAKE_DIR)/nvidia-modprobe.mk clean
170+
ifeq ($(WITH_TIRPC), 1)
171+
-$(MAKE) -f $(MAKE_DIR)/libtirpc.mk clean
172+
endif
173+
174+
mostlyclean:
175+
$(RM) -r $(DEBUG_DIR)
176+
$(RM) $(OBJS) $(STATIC_LIB_OBJ) $(OBJS:%.o=.%.d)
177+
178+
clean: mostlyclean depsclean
179+
180+
distclean: clean
181+
$(RM) -r $(DEPS_DIR) $(DIST_DIR) $(DEBUG_DIR)
182+
$(RM) $(RPCS) $(BUILD_INFO) $(STATIC_LIB) $(SHARED_LIB)

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# libnvidia-container
2+
3+
**Warning: This project is an alpha release, it is not intended to be used in production systems.**
4+
5+
This repository provides a library to automatically configure GNU/Linux containers leveraging NVIDIA hardware.\
6+
The implementation relies on low-level kernel primitives and is designed to be agnostic of the container runtime.
7+
8+
## Copyright and License
9+
10+
This project is released under the [BSD 3-clause license](https://github.com/NVIDIA/libnvidia-container/blob/master/LICENSE).
11+
12+
## Issues and Contributing
13+
14+
A signed copy of the [Contributor License Agreement](https://raw.githubusercontent.com/NVIDIA/libnvidia-container/master/CLA) needs to be provided to <a href="mailto:[email protected]">[email protected]</a> before any change can be accepted.
15+
16+
* Please let us know by [filing a new issue](https://github.com/NVIDIA/libnvidia-container/issues/new)
17+
* You can contribute by opening a [pull request](https://help.github.com/articles/using-pull-requests/)

0 commit comments

Comments
 (0)