Browse Source

Remove wrs-server-group SDK Module from StarlingX

With the StarlingX move to supporting pure upstream OpenStack, the
majority of the SDK Modules are related to functionality no longer
supported. The remaining SDK Modules will be moved to StarlingX
documentation.

Story: 2005275
Task: 30205

Change-Id: Ic0365f07297f0094b46c59d0fc6a62130c681f1e
Signed-off-by: Kristine Bujold <kristine.bujold@windriver.com>
changes/38/648138/2
Kristine Bujold 3 years ago
parent
commit
1ec6ba402b
  1. 2
      centos_guest_image.inc
  2. 2
      centos_guest_image_rt.inc
  3. 3
      centos_iso_image.inc
  4. 1
      centos_pkg_dirs
  5. 5
      devstack/lib/stx-nfv
  6. 6
      devstack/settings
  7. 12
      guest-comm/PKG-INFO
  8. 2
      guest-comm/centos/build_srpm.data
  9. 174
      guest-comm/centos/host-guest-comm.spec
  10. 202
      guest-comm/host-guest-comm-2.0/LICENSE
  11. 175
      guest-comm/host-guest-comm-2.0/Makefile
  12. 118
      guest-comm/host-guest-comm-2.0/Makefile.sdk
  13. 4
      guest-comm/host-guest-comm-2.0/bin/.gitignore
  14. 257
      guest-comm/host-guest-comm-2.0/docs/README.txt
  15. BIN
      guest-comm/host-guest-comm-2.0/docs/TiS-Guest-Server-Group-Messaging.doc
  16. BIN
      guest-comm/host-guest-comm-2.0/docs/TiS-Guest-Server-Group-Messaging.pdf
  17. 503
      guest-comm/host-guest-comm-2.0/guest_agent.c
  18. 95
      guest-comm/host-guest-comm-2.0/guest_host_msg.h
  19. 461
      guest-comm/host-guest-comm-2.0/host_agent.c
  20. 124
      guest-comm/host-guest-comm-2.0/host_guest_msg.c
  21. 96
      guest-comm/host-guest-comm-2.0/host_guest_msg.h
  22. 75
      guest-comm/host-guest-comm-2.0/host_guest_msg_type.h
  23. 629
      guest-comm/host-guest-comm-2.0/host_instance_mgmt.c
  24. 65
      guest-comm/host-guest-comm-2.0/host_instance_mgmt.h
  25. 4
      guest-comm/host-guest-comm-2.0/lib/.gitignore
  26. 239
      guest-comm/host-guest-comm-2.0/lib_guest_host_msg.c
  27. 250
      guest-comm/host-guest-comm-2.0/lib_host_guest_msg.c
  28. 42
      guest-comm/host-guest-comm-2.0/misc.h
  29. 4
      guest-comm/host-guest-comm-2.0/obj/.gitignore
  30. 12
      guest-comm/host-guest-comm-2.0/scripts/guest-agent.service
  31. 78
      guest-comm/host-guest-comm-2.0/scripts/host_agent
  32. 24
      guest-comm/host-guest-comm-2.0/scripts/host_agent.conf
  33. 13
      guest-comm/host-guest-comm-2.0/scripts/host_agent.service
  34. 497
      guest-comm/host-guest-comm-2.0/server_group.c
  35. 119
      guest-comm/host-guest-comm-2.0/server_group.h
  36. 107
      guest-comm/host-guest-comm-2.0/server_group_app.c
  37. 175
      guest-comm/host-guest-comm-2.0/test/guest_app.c
  38. 187
      guest-comm/host-guest-comm-2.0/test/host_app.c
  39. 374
      guest-comm/host-guest-comm-2.0/test/test_host_guest_msg.c

2
centos_guest_image.inc

@ -9,5 +9,3 @@
# guest-client
guest-client
# host-guest-comm
guest-host-comm

2
centos_guest_image_rt.inc

@ -9,5 +9,3 @@
# guest-client
guest-client
# host-guest-comm
guest-host-comm

3
centos_iso_image.inc

@ -2,9 +2,6 @@
# If these have dependencies, they will be pulled in automatically
#
# host-guest-comm
host-guest-comm
# nfv
nfv
nfv-common

1
centos_pkg_dirs

@ -1,6 +1,5 @@
nova-api-proxy
guest-client
guest-agent
guest-comm
nfv
mtce-guest

5
devstack/lib/stx-nfv

@ -35,11 +35,6 @@ MTCE_GUEST_DIR=$STXNFV_DIR/mtce-guest
MTCE_GUEST_CONF=$STXNFV_SYSCONFDIR/mtc
MTCE_GUEST_OCF_DIR=$STXNFV_OCF_ROOT/resource.d/platform
# guest-comm
GUEST_COMM_DIR=$STXNFV_DIR/guest-comm
HOST_AGENT_COMM_VER="2.0"
HOST_AGENT_COMM_DIR=$GUEST_COMM_DIR/host-guest-comm-$HOST_AGENT_COMM_VER
# guest-client
GUEST_CLIENT_VERSION="3.0.1"

6
devstack/settings

@ -49,11 +49,5 @@ if is_service_enabled guest-agent || is_service_enabled guest-server; then
done
fi
if is_service_enabled guest-scale-helper; then
# guest-scale-helper needs header files and libraries built from the folder
# guest-comm
enable_service host-agent
fi
# Initial source of lib script
source $DEST/stx-nfv/devstack/lib/stx-nfv

12
guest-comm/PKG-INFO

@ -1,12 +0,0 @@
Metadata-Version: 1.1
Name: host-guest-comm
Version: 2.0
Summary: Titanium Cloud host guest messaging agents, lib, apps
Home-page:
Author: Windriver
Author-email: info@windriver.com
License: Apache-2.0
Description: Titanium Cloud host guest messaging agents, lib, apps
Platform: UNKNOWN

2
guest-comm/centos/build_srpm.data

@ -1,2 +0,0 @@
SRC_DIR="host-guest-comm-2.0"
TIS_PATCH_VER=6

174
guest-comm/centos/host-guest-comm.spec

@ -1,174 +0,0 @@
Summary: Titanium Cloud host guest messaging agents, lib, apps
Name: host-guest-comm
Version: 2.0
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: base
Packager: Wind River <info@windriver.com>
URL: unknown
Source0: %{name}-%{version}.tar.gz
%define cgcs_sdk_deploy_dir /opt/deploy/cgcs_sdk
BuildRequires: json-c
BuildRequires: json-c-devel
BuildRequires: systemd-devel
Requires: rtld(GNU_HASH)
Requires: /bin/sh
Requires: /usr/bin/systemctl
%description
Titanium Cloud host/guest messaging agents, guest app library, guest app
%package -n guest-host-comm
Summary: Titanium Cloud host guest messaging agents, lib, apps
Group: base
Requires: rtld(GNU_HASH)
Requires(post): rtld(GNU_HASH)
Requires: systemd
Requires(post): systemd
Requires(preun): systemd
%description -n guest-host-comm
Titanium Cloud host/guest messaging agents, guest app library, guest app
%package -n guest-host-comm-dev
Summary: Titanium Cloud host guest messaging agents, lib, apps
Group: base
Requires: guest-host-comm
%description -n guest-host-comm-dev
Titanium Cloud host/guest messaging agents, guest app library, guest app
%package -n %{name}-cgts-sdk
Summary: Titanium Cloud host guest messaging SDK files
Group: devel
%description -n %{name}-cgts-sdk
Titanium Cloud host guest messaging SDK files
%package -n host-guest-comm-dbg
Summary: Titanium Cloud host guest messaging agents, lib, apps - Debugging files
Group: devel
%description -n host-guest-comm-dbg
Titanium Cloud host/guest messaging agents, guest app library, guest app. This
package contains ELF symbols and related sources for debugging purposes.
%package -n host-guest-comm-dev
Summary: Titanium Cloud host guest messaging agents, lib, apps - Development files
Group: devel
Requires: host-guest-comm = %{version}-%{release}
%description -n host-guest-comm-dev
Titanium Cloud host/guest messaging agents, guest app library, guest app This
package contains symbolic links, header files, and related items necessary
for software development.
%prep
%setup
%build
VER=%{version}
MAJOR=`echo $VER | awk -F . '{print $1}'`
MINOR=`echo $VER | awk -F . '{print $2}'`
PATCH=%{tis_patch_ver}
make all VER=${VER} MAJOR=${MAJOR} MINOR=${MINOR} PATCH=${PATCH}
%install
VER=%{version}
MAJOR=`echo $VER | awk -F . '{print $1}'`
MINOR=`echo $VER | awk -F . '{print $2}'`
PATCH=%{tis_patch_ver}
make install \
DESTDIR=%{buildroot} \
SYSCONFDIR=%{buildroot}%{_sysconfdir} \
UNITDIR=%{buildroot}%{_unitdir} \
LIBDIR=%{buildroot}%{_libdir} \
SDK_DEPLOY_DIR=%{buildroot}%{cgcs_sdk_deploy_dir} \
MAJOR=${MAJOR} MINOR=${MINOR} PATCH=${PATCH}
%post
/usr/bin/systemctl enable host_agent.service
%postun
/usr/bin/systemctl disable host_agent.service
%files
%defattr(-,root,root,-)
/usr/lib64/libhostguestmsg.so.2.0.%{tis_patch_ver}
/usr/lib64/libhostguestmsg.so.2.0
/usr/lib64/libhostguestmsg.so.2
/usr/sbin/host_agent
/etc/pmon.d/host_agent.conf
/etc/init.d/host_agent
%{_unitdir}/host_agent.service
%files -n guest-host-comm
%defattr(-,root,root,-)
/usr/lib64/libguesthostmsg.so.2.0.%{tis_patch_ver}
/usr/lib64/libguesthostmsg.so.2.0
/usr/lib64/libguesthostmsg.so.2
/usr/lib64/libservergroup.so.2.0.%{tis_patch_ver}
/usr/lib64/libservergroup.so.2.0
/usr/lib64/libservergroup.so.2
/usr/sbin/server_group_app
/usr/sbin/guest_agent
%{_unitdir}/guest-agent.service
%preun -n guest-host-comm
%systemd_preun guest-agent.service
%post -n guest-host-comm
%systemd_post guest-agent.service
/usr/bin/systemctl enable guest-agent.service >/dev/null 2>&1
%files -n guest-host-comm-dev
%defattr(-,root,root,-)
/usr/include/cgcs/guest_host_msg.h
/usr/lib64/libguesthostmsg.so.2.0.%{tis_patch_ver}
/usr/lib64/libguesthostmsg.so.2.0
/usr/lib64/libguesthostmsg.so.2
/usr/lib64/libguesthostmsg.so
/usr/lib64/libservergroup.so.2.0.%{tis_patch_ver}
/usr/lib64/libservergroup.so.2.0
/usr/lib64/libservergroup.so.2
/usr/lib64/libservergroup.so
%files -n host-guest-comm-dbg
%defattr(-,root,root,-)
/usr/src/debug/host-guest-comm-2.0/server_group_app.c
/usr/src/debug/host-guest-comm-2.0/server_group.c
/usr/src/debug/host-guest-comm-2.0/guest_agent.c
/usr/src/debug/host-guest-comm-2.0/lib_host_guest_msg.c
/usr/src/debug/host-guest-comm-2.0/host_guest_msg.c
/usr/src/debug/host-guest-comm-2.0/lib_guest_host_msg.c
/usr/src/debug/host-guest-comm-2.0/host_guest_msg_type.h
/usr/src/debug/host-guest-comm-2.0/host_instance_mgmt.h
/usr/src/debug/host-guest-comm-2.0/host_instance_mgmt.c
/usr/src/debug/host-guest-comm-2.0/guest_host_msg.h
/usr/src/debug/host-guest-comm-2.0/host_guest_msg.h
/usr/src/debug/host-guest-comm-2.0/host_agent.c
/usr/src/debug/host-guest-comm-2.0/server_group.h
%files -n host-guest-comm-dev
%defattr(-,root,root,-)
/usr/include/cgcs/host_guest_msg.h
/usr/lib64/libhostguestmsg.so.2.0.%{tis_patch_ver}
/usr/lib64/libhostguestmsg.so.2.0
/usr/lib64/libhostguestmsg.so.2
/usr/lib64/libhostguestmsg.so
%files -n %{name}-cgts-sdk
%{cgcs_sdk_deploy_dir}/wrs-server-group-%{version}.%{tis_patch_ver}.tgz

202
guest-comm/host-guest-comm-2.0/LICENSE

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

175
guest-comm/host-guest-comm-2.0/Makefile

@ -1,175 +0,0 @@
#
# Copyright(c) 2013-2016, Wind River Systems, Inc. All rights reserved.
# 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 Wind River Systems 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.
#
# Note: if you change either Makefile or Makefile.sdk you need to manually
# do a "make clean" and then "make".
# Import the Makefile that we give to the customer so we eat our own dogfood
include Makefile.sdk
DESTDIR ?= /
SYSCONFDIR ?= /etc
UNITDIR ?= /usr/lib/systemd/system
LIBDIR ?= /usr/lib64
SDK_DEPLOY_DIR ?= /opt/deploy/cgcs_sdk
MAJOR ?= 2
MINOR ?= 0
VERSION ?= $(MAJOR).$(MINOR)
PATCH ?= 0
# This needs to be extended from what the customer will build.
EXECS += host_agent
BINEXECS=$(addprefix $(BINDIR)/, $(EXECS))
HOST_AGENT_SRCS = host_guest_msg.c host_agent.c host_instance_mgmt.c
HOST_AGENT_OBJ := $(patsubst %,$(ODIR)/%,$(HOST_AGENT_SRCS:.c=.o))
LIBHOSTGUESTMSG_SRCS := lib_host_guest_msg.c
LIBHOSTGUESTMSG_OBJ := $(patsubst %,$(ODIR)/%,$(LIBHOSTGUESTMSG_SRCS:.c=.o))
LIBHOSTGUESTMSG := hostguestmsg
LIBHOSTGUESTMSG_SO := $(patsubst %,lib%.so,$(LIBHOSTGUESTMSG))
LIBHOSTGUESTMSG_DEP := $(patsubst %,$(LIBDIR)/%,$(LIBHOSTGUESTMSG_SO))
LIBS= $(LIBHOSTGUESTMSG)
LIBDEPS:=$(patsubst %,$(LIBDIR)/lib%.so,$(LIBS))
EXPORT_SDK := wrs-server-group-$(MAJOR).$(MINOR).$(PATCH)
# Add the host build as a dependency to the SDK build
all: host_all
host_all: $(BINEXECS) $(LIBDEPS) sdk/$(EXPORT_SDK).tgz
OBJS = $(HOST_AGENT_OBJ)
DEPS = $(OBJS:.o=.d) sdk/sdk.d
-include $(DEPS)
# The dependency tracking for the SDK tarball is rather crude. If any
# file changes they're all copied over again. This is quick, so it's
# not worth getting fancy.
sdk/$(EXPORT_SDK).tgz:
@echo "Making SDK"
@mkdir -p sdk/$(EXPORT_SDK)
@mkdir -p sdk/$(EXPORT_SDK)/lib
@mkdir -p sdk/$(EXPORT_SDK)/bin
@mkdir -p sdk/$(EXPORT_SDK)/obj
@mkdir -p sdk/$(EXPORT_SDK)/scripts
@cp scripts/guest-agent.service sdk/$(EXPORT_SDK)/scripts
@echo "MAJOR=$(MAJOR)" > sdk/$(EXPORT_SDK)/Makefile
@echo "MINOR=$(MINOR)" >> sdk/$(EXPORT_SDK)/Makefile
@echo "PATCH=$(PATCH)" >> sdk/$(EXPORT_SDK)/Makefile
@cat Makefile.sdk >> sdk/$(EXPORT_SDK)/Makefile
@cp LICENSE sdk/$(EXPORT_SDK)
@cp docs/README.txt sdk/$(EXPORT_SDK)
@cp docs/TiS-Guest-Server-Group-Messaging.pdf sdk/$(EXPORT_SDK)
@cp $(GUEST_CLIENT_APP_SRCS) sdk/$(EXPORT_SDK)
@cp $(LIBSERVERGROUP_SRCS) sdk/$(EXPORT_SDK)
@cp $(LIBGUESTHOSTMSG_SRCS) sdk/$(EXPORT_SDK)
@cp $(GUEST_AGENT_SRCS) sdk/$(EXPORT_SDK)
@cp host_guest_msg_type.h server_group.h misc.h guest_host_msg.h sdk/$(EXPORT_SDK)
@cd sdk && tar czf $(EXPORT_SDK).tgz $(EXPORT_SDK)
@echo -n "sdk/$(EXPORT_SDK).tgz: Makefile.sdk docs/README.txt docs/TiS-Guest-Server-Group-Messaging.pdf " > sdk/sdk.d
@echo -n "scripts/guest-agent.service " >> sdk/sdk.d
@echo -n "$(GUEST_CLIENT_APP_SRCS) $(LIBSERVERGROUP_SRCS) $(GUEST_AGENT_SRCS) $(LIBGUESTHOSTMSG_SRCS)" >> sdk/sdk.d
@echo " host_guest_msg.h server_group.h misc.h" >> sdk/sdk.d
@echo '*' > sdk/.gitignore
$(LIBHOSTGUESTMSG_DEP): CFLAGS2 = -fPIC
$(LIBHOSTGUESTMSG_DEP): $(LIBHOSTGUESTMSG_OBJ)
$(CC) -shared -Wl,-soname,$(LIBHOSTGUESTMSG_SO).$(MAJOR) $^ -o $(LIBHOSTGUESTMSG_DEP).$(MAJOR).$(MINOR).$(PATCH)
ln -sf $(LIBHOSTGUESTMSG_SO).$(MAJOR).$(MINOR).$(PATCH) $(LIBHOSTGUESTMSG_DEP).$(MAJOR)
ln -sf $(LIBHOSTGUESTMSG_SO).$(MAJOR) $(LIBHOSTGUESTMSG_DEP)
$(BINDIR)/host_agent: $(HOST_AGENT_OBJ)
$(CC) -o $@ $^ $(LDFLAGS) -lrt -ljson-c
install:
install -m 750 -d $(DESTDIR)/usr/sbin
install -m 755 -d $(DESTDIR)/usr/lib64
install -m 755 -d $(DESTDIR)/usr/include
install -m 755 -d $(DESTDIR)/usr/include/cgcs
install -m 750 -d $(SYSCONFDIR)/init.d
install -m 750 -d $(SYSCONFDIR)/pmon.d
install -m 750 -d $(UNITDIR)
install -m 750 -d $(DESTDIR)/usr
install -m 750 -d $(DESTDIR)/usr/src
install -m 750 -d $(DESTDIR)/usr/src/debug
install -m 750 -d $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)
install -m 644 host_guest_msg_type.h $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/host_guest_msg_type.h
install -m 644 server_group_app.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/server_group_app.c
install -m 644 server_group.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/server_group.c
install -m 644 guest_agent.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/guest_agent.c
install -m 644 lib_host_guest_msg.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/lib_host_guest_msg.c
install -m 644 host_guest_msg.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/host_guest_msg.c
install -m 644 lib_guest_host_msg.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/lib_guest_host_msg.c
install -m 644 host_instance_mgmt.h $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/host_instance_mgmt.h
install -m 644 host_instance_mgmt.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/host_instance_mgmt.c
install -m 644 guest_host_msg.h $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/guest_host_msg.h
install -m 644 host_guest_msg.h $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/host_guest_msg.h
install -m 644 host_agent.c $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/host_agent.c
install -m 644 server_group.h $(DESTDIR)/usr/src/debug/host-guest-comm-$(VERSION)/server_group.h
install -m 750 scripts/host_agent $(SYSCONFDIR)/init.d/host_agent
install -m 644 scripts/host_agent.service $(UNITDIR)/host_agent.service
install -m 644 scripts/guest-agent.service $(UNITDIR)/guest-agent.service
install -m 640 scripts/host_agent.conf $(SYSCONFDIR)/pmon.d/host_agent.conf
install -m 750 bin/host_agent $(DESTDIR)/usr/sbin/host_agent
install -m 750 bin/guest_agent $(DESTDIR)/usr/sbin/guest_agent
install -m 750 bin/server_group_app $(DESTDIR)/usr/sbin/server_group_app
install -m 644 guest_host_msg.h $(DESTDIR)/usr/include/cgcs/guest_host_msg.h
install -m 644 host_guest_msg.h $(DESTDIR)/usr/include/cgcs/host_guest_msg.h
# Deploy to the SDK deployment directory
install -d $(SDK_DEPLOY_DIR)
install -m 644 sdk/wrs-server-group-$(VERSION).$(PATCH).tgz $(SDK_DEPLOY_DIR)/wrs-server-group-$(VERSION).$(PATCH).tgz
install -m 755 -p -D lib/libguesthostmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libguesthostmsg.so.$(MAJOR).$(MINOR).$(PATCH)
ln -s libguesthostmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libguesthostmsg.so.$(MAJOR).$(MINOR)
ln -s libguesthostmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libguesthostmsg.so.$(MAJOR)
ln -s libguesthostmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libguesthostmsg.so
install -m 755 -p -D lib/libhostguestmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libhostguestmsg.so.$(MAJOR).$(MINOR).$(PATCH)
ln -s libhostguestmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libhostguestmsg.so.$(MAJOR).$(MINOR)
ln -s libhostguestmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libhostguestmsg.so.$(MAJOR)
ln -s libhostguestmsg.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libhostguestmsg.so
install -m 755 -p -D lib/libservergroup.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libservergroup.so.$(MAJOR).$(MINOR).$(PATCH)
ln -s libservergroup.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libservergroup.so.$(MAJOR).$(MINOR)
ln -s libservergroup.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libservergroup.so.$(MAJOR)
ln -s libservergroup.so.$(MAJOR).$(MINOR).$(PATCH) $(LIBDIR)/libservergroup.so
# Add the host clean as a dependency to the SDK stuff
clean: host_clean
host_clean:
rm -rf sdk

118
guest-comm/host-guest-comm-2.0/Makefile.sdk

@ -1,118 +0,0 @@
#
# Copyright(c) 2013-2016, Wind River Systems, Inc. All rights reserved.
# 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 Wind River Systems 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.
#
.PHONY: all clean
EXECS= guest_agent server_group_app
CFLAGS= -g -Wall -Wformat -Wformat-security
LDFLAGS =
ODIR=obj
BINDIR=bin
LIBDIR=lib
INCDIR=include/cgcs
_DEPS = *.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
GUEST_AGENT_SRCS = host_guest_msg.c guest_agent.c
GUEST_AGENT_OBJ := $(patsubst %,$(ODIR)/%,$(GUEST_AGENT_SRCS:.c=.o))
GUEST_CLIENT_APP_SRCS = server_group_app.c
GUEST_CLIENT_APP_OBJ := $(patsubst %,$(ODIR)/%,$(GUEST_CLIENT_APP_SRCS:.c=.o))
LIBGUESTHOSTMSG_SRCS := lib_guest_host_msg.c
LIBGUESTHOSTMSG_INCLUDES := guest_host_msg.h
LIBGUESTHOSTMSG_OBJ := $(patsubst %,$(ODIR)/%,$(LIBGUESTHOSTMSG_SRCS:.c=.o))
LIBGUESTHOSTMSG := guesthostmsg
LIBGUESTHOSTMSG_SO := $(patsubst %,lib%.so,$(LIBGUESTHOSTMSG))
LIBGUESTHOSTMSG_DEP := $(patsubst %,$(LIBDIR)/%,$(LIBGUESTHOSTMSG_SO))
LIBSERVERGROUP_SRCS := server_group.c
LIBSERVERGROUP_INCLUDES := server_group.h
LIBSERVERGROUP_OBJ := $(patsubst %,$(ODIR)/%,$(LIBSERVERGROUP_SRCS:.c=.o))
LIBSERVERGROUP := servergroup
LIBSERVERGROUP_SO := $(patsubst %,lib%.so,$(LIBSERVERGROUP))
LIBSERVERGROUP_DEP := $(patsubst %,$(LIBDIR)/%,$(LIBSERVERGROUP_SO))
LIBS= $(LIBSERVERGROUP) $(LIBGUESTHOSTMSG)
INCLUDES= $(LIBGUESTHOSTMSG_INCLUDES) $(LIBSERVERGROUP_INCLUDES)
BINEXECS=$(addprefix $(BINDIR)/, $(EXECS))
LIBDEPS:=$(patsubst %,$(LIBDIR)/lib%.so,$(LIBS))
INCDEPS:=$(addprefix $(INCDIR)/, $(INCLUDES))
all: $(BINEXECS) $(LIBDEPS) $(INCDIR) $(INCDEPS)
OBJS = $(GUEST_AGENT_OBJ) $(LIBSERVERGROUP_OBJ) $(GUEST_CLIENT_APP_OBJ)
DEPS = $(OBJS:.o=.d)
-include $(DEPS)
$(ODIR)/%.o: %.c
$(CC) -c $(CFLAGS) $(CFLAGS2) -MMD -o $@ $<
$(INCDIR):
mkdir -p $(INCDIR)
$(INCDIR)/%.h: %.h $(INCDIR)
cp $< $@
vpath %.h .
# the version of make in wrl5 seems to have a problem with target-specific
# variable values. It can't handle just doing "CFLAGS += -fPIC". Same thing
# for LDFLAGS below. This seems to work as a workaround.
$(LIBSERVERGROUP_DEP): CFLAGS2 = -fPIC
$(LIBSERVERGROUP_DEP): $(LIBSERVERGROUP_OBJ)
$(CC) -shared -Wl,-soname,$(LIBSERVERGROUP_SO).$(MAJOR) $^ -o $(LIBSERVERGROUP_DEP).$(MAJOR).$(MINOR).$(PATCH)
ln -sf $(LIBSERVERGROUP_SO).$(MAJOR).$(MINOR).$(PATCH) $(LIBSERVERGROUP_DEP).$(MAJOR)
ln -sf $(LIBSERVERGROUP_SO).$(MAJOR) $(LIBSERVERGROUP_DEP)
$(LIBGUESTHOSTMSG_DEP): CFLAGS2 = -fPIC
$(LIBGUESTHOSTMSG_DEP): $(LIBGUESTHOSTMSG_OBJ)
$(CC) -shared -Wl,-soname,$(LIBGUESTHOSTMSG_SO).$(MAJOR) $^ -o $(LIBGUESTHOSTMSG_DEP).$(MAJOR).$(MINOR).$(PATCH)
ln -sf $(LIBGUESTHOSTMSG_SO).$(MAJOR).$(MINOR).$(PATCH) $(LIBGUESTHOSTMSG_DEP).$(MAJOR)
ln -sf $(LIBGUESTHOSTMSG_SO).$(MAJOR) $(LIBGUESTHOSTMSG_DEP)
$(BINDIR)/guest_agent: LDFLAGS2 = -rdynamic
$(BINDIR)/guest_agent: $(GUEST_AGENT_OBJ)
$(CC) -o $@ $^ $(LDFLAGS) $(LDFLAGS2) -ljson-c
$(BINDIR)/server_group_app: LDFLAGS2 = -l$(LIBSERVERGROUP) -L$(LIBDIR)
$(BINDIR)/server_group_app: $(GUEST_CLIENT_APP_OBJ) $(LIBSERVERGROUP_DEP)
$(CC) -o $@ $^ $(LDFLAGS) $(LDFLAGS2) -ljson-c
clean:
rm -rf $(ODIR)/* *~ core $(BINDIR)/* $(LIBDIR)/*

4
guest-comm/host-guest-comm-2.0/bin/.gitignore vendored

@ -1,4 +0,0 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

257
guest-comm/host-guest-comm-2.0/docs/README.txt

@ -1,257 +0,0 @@
Copyright(c) 2013-2016, Wind River Systems, Inc.
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 Wind River Systems 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.
-----------------------------------------------------------------------
DESCRIPTION
===========
Server Group Messaging is a service to provide simple low-bandwidth datagram
messaging and notifications for servers that are part of the same server group.
This messaging channel is available regardless of whether IP networking is
functional within the server, and it requires no knowledge within the server
about the other members of the group.
The service provides three types of messaging:
1) Broadcast: this allows a server to send a datagram (size of up to 3050 bytes)
to all other servers within the server group.
2) Notification: this provides servers with information about changes to the
state of other servers within the server group.
3) Status: this allows a server to query the current state of all servers within
the server group (including itself).
This service is not intended for high bandwidth or low-latency operations. It
is best-effort, not reliable. Applications should do end-to-end acks and
retries if they care about reliability.
REQUIREMENTS
============
Compilation:
Linux OS, x86_64 architecture
gcc compiler
development libraries and headers for glibc
development libraries and headers for json-c
VM Runtime:
Linux OS, x86_64 architecture
runtime libraries for glibc
runtime libraries for json-c
The code has been tested with glibc 2.15, gcc 4.6 and json-c 0.12.99 but it
should run on other versions without difficulty.
DELIVERABLE
===========
The Server Group Messaging service is delivered as source with the
required makefiles in a compressed tarball called
"wrs-server-group-2.0.0.tgz", such that it can be compiled for the applicable
guest linux distribution.
COMPILE
=======
Install the prerequisites:
On CentOS/RHEL: yum install json-c-devel make gcc glibc-devel
On Ubuntu/Debian: sudo apt-get install build-essential libjson0-dev
Extract the tarball contents:
tar xvf wrs-server-group-#.#.#.tgz
To compile:
cd wrs-server-group-#.#.#
make
export WRS_SERVER_GROUP_DIR=${PWD}
This will produce:
1) An executable "bin/guest_agent". This acts as a relay between the guest and
the host. This executable must be installed into the guest and configured to
run at startup. It should be configured to respawn (via /etc/inittab or some
other process monitor) if it dies for any reason.
Typical manual installation commands:
sudo cp bin/* /usr/sbin
sudo cp scripts/guest-agent.service /lib/systemd/system/
sudo systemctl enable guest-agent.service
sudo systemctl start guest-agent.service
2) A library "lib/libservergroup.so.2.0.*". This encapsulates the details of
talking to the guest agent. This can be used with the header file
"server_group.h" to create custom applications that can make use of the
messaging service. This should be installed within the guest in a suitable
library location such that the linker can find it. It should also be installed
in the build system where custom applications can link against it. The
"libservergroup.so.2" symlink should be created in the build system and the
guest, and the "libservergroup.so" symlink should be created in the build
system, either by ldconfig or some other means.
Typical manual installation commands:
sudo cp -P lib/libservergroup.* /usr/lib/
sudo ldconfig
3) A header file "include/cgcs/server_group.h". This is used along with the library to
create custom applications that can make use of the messaging service. This
should be installed in the build system where custom applications can include
it.
4) A sample program "bin/server_group_app" is created in order to show the use
of the APIs and validate that they are working properly in the guest.
5) A library "lib/libguesthostmsg.so.2.0.*". This library is used by
wrs-guest-scale component packaged separately. This can be used with the
header file "guest_host_msg.h". This should be installed within
the guest in a suitable library location such that the linker can find it.
It should also be installed in the build system where custom applications can
link against it. The "libguesthostmsg.so.2" symlink should be created in the
build system and the guest, and the "libguesthostmsg.so" symlink should be
created in the build system, either by ldconfig or some other means.
Typical manual installation commands:
sudo cp -P lib/libguesthostmsg.* /usr/lib/
sudo ldconfig
6) A header file "include/cgcs/guest_host_msg.h". This is used along with
the library to create custom applications that can make use of the messaging
service. This should be installed in the build system where custom
applications can include it. (Setting the WRS_SERVER_GROUP_DIR environment as above
variable will allow it to be found when building the wrs-guest-scale component.)
Note:
The inclusion of the files into the build system and the guest image and the
configuration of the guest startup scripts is left up to the user to allow for
different build systems and init subsystems in the guest.
INSTALL
=======
Installing in a running VM:
As the root user
1) Copy "bin/guest_agent" and any other desired binaries such as
"bin/server_group_app" to /usr/sbin in the VM.
2) Run "cp -P lib/* /usr/lib" (or /usr/lib64 as appropriate) in the VM
to install the libraries.
3) Run "ldconfig".
4) Copy scripts/guest-agent.service to /lib/systemd/system/ and then run
"systemctl enable guest-agent.service" and "systemctl start guest-agent.service".
This should cause the "guest-agent" binary to start running.
5) Applications can now make use of the service.
6) Run "cp -r include/cgcs /usr/include/" to set up the headers for anyone
wanting to link against libservergroup or libguesthostmsg.
As part of building the VM ISO Image:
1) Ensure "bin/guest_agent" and any other desired binaries get installed
to /usr/sbin in the VM filesystem.
2) Ensure "lib/*" gets installed to /usr/lib64 in the VM filesystem.
3) Ensure that "ldconfig" will run at VM startup.
4) Ensure that "/usr/sbin/guest_agent" is configured to run automatically
at VM startup and to respawn if it dies for any reason. The scripts/
guest_agent.service file is provided for use by systemd.
USAGE
=====
The service is designed to be simple to use. A basic description is given
below, but more details are provided in the header file.
First, the application must call init_sg(). This call takes three function
pointers corresponding to callbacks for the various message types. If an
application doesn't intend to use one or more of the message types then the
appropriate function pointers can be specified as NULL. The function returns a
socket that must be monitored for activity using select/poll/etc.
When the socket becomes readable, the application must call process_sg_msg().
This may result in callbacks being called so be careful about deadlock.
In order to send a broadcast message to every server in the server group, the
application can call sg_msg_broadcast().
In order to request the status of all servers in the group, the application can
call sg_request_status().
The sg_broadcast_msg_handler_t() callback will be called when receiving a server
group broadcast message. It will be passed the message as well as a
null-terminated string containing the instance name of the sender.
The sg_notification_msg_handler_t() callback will be called when receiving a
notification message indicating a status change in one of the members of the
server group. The msg is JSON-formatted, essentially the normal notification
that gets sent out by OpenStack's notification service, but with some
non-relevant information removed to keep the message shorter.
The sg_status_msg_handler_t() callback will be called when receiving the
response to a status query. The message is a JSON-formatted list of
dictionaries, each of which represents a single server.
SAMPLE APPLICATION
==================
The "server_group_app" sample application can be used to test the various types
of messages. It takes one optional argument, consisting of a character string
in quotes. When run, it behaves as follows:
1) It registers for all three callbacks.
2) If the optional argument was specified it sends that string as a server group
broadcast message.
3) It requests the group status.
4) It then goes into a loop waiting for incoming messages. Any incoming message
will be printed out along with information about the type of message.
The service can be validated as follows using the "server_group_app" sample
application:
a) Create a server group with the "affinity" scheduler policy.
b) Start up a server within the server group.
c) Run "server_group_app" in the first server. You should immediately see the
status response message containing information about that server.
d) Start up a second server within the server group. You should see
notification messages being received in the first server.
e) Run 'server_group_app "this is a test"' on the second server. You should see
"this is a test" received as a broadcast message on the first server. The
second server should show a status response with information about both
servers
f) Start up a third server within the server group. You should see
notification messages being received in the other two servers.
g) Run 'server_group_app "final test"' on the second server. You should see
"final test" received as a broadcast message on the other two servers. The
second server should show a status response with information about all three
servers

BIN
guest-comm/host-guest-comm-2.0/docs/TiS-Guest-Server-Group-Messaging.doc

Binary file not shown.

BIN
guest-comm/host-guest-comm-2.0/docs/TiS-Guest-Server-Group-Messaging.pdf

Binary file not shown.

503
guest-comm/host-guest-comm-2.0/guest_agent.c

@ -1,503 +0,0 @@
/*
* Copyright (c) 2013-2016, Wind River Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2) 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.
*
* 3) Neither the name of Wind River Systems 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 HOLDER 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.
*/
/**
*/
#define _GNU_SOURCE /* for memmem() */
#include <stddef.h>
#include <errno.h>
#include <error.h>
#include <fcntl.h>
#include <poll.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/select.h>
#include <sys/un.h>
#include <sys/socket.h>
#include <syslog.h>
#include <limits.h>
#include <signal.h>
#include <execinfo.h>
#include <json-c/json.h>
#include "host_guest_msg_type.h"
/*
Notes on virtio-serial in guest:
1) The fact that POLLHUP is always set in revents when host connection is down
means that the only way to get event-driven notification of connection is to
register for SIGIO. However, then we get a SIGIO every time the device becomes
readable. The solution is to selectively block SIGIO as long as we think the link
is up, then unblock it so we get notified when the link comes back.
2) If the host disconnects we will still process any buffered messages from it.
3) If read() returns 0 or write() returns -1 with errno of EAGAIN that means
the host is disconnected.
*/
// Tokener serves as reassembly buffer for host connection.
struct json_tokener* tok;
int host_fd;
int app_fd;
volatile sig_atomic_t check_host_connection=1;
volatile sig_atomic_t initial_connection=1;
// Currently we only use 2 fds, one for server group messaging and one for the
// connection to the host.
#define MAX_FDS_GUEST 10
// Message has arrived from the host.
// This assumes the message has been validated
void process_msg(json_object *jobj_msg, int fd)
{
int rc;
struct sockaddr_un cliaddr;
int addrlen;
// parse version
struct json_object *jobj_version;
if (!json_object_object_get_ex(jobj_msg, VERSION, &jobj_version)) {
PRINT_ERR("failed to parse version\n");
return;
}
int version = json_object_get_int(jobj_version);
if (version != CUR_VERSION) {
PRINT_ERR("received version %d, expected %d\n", version, CUR_VERSION);
return;
}
// parse source addr
struct json_object *jobj_source_addr;
if (!json_object_object_get_ex(jobj_msg, SOURCE_ADDR, &jobj_source_addr)) {
PRINT_ERR("failed to parse source_addr\n");
return;
}
// parse dest addr
struct json_object *jobj_dest_addr;
if (!json_object_object_get_ex(jobj_msg, DEST_ADDR, &jobj_dest_addr)) {
PRINT_ERR("failed to parse dest_addr\n");
return;
}
const char *dest_addr = json_object_get_string(jobj_dest_addr);
// parse msg data
struct json_object *jobj_data;
if (!json_object_object_get_ex(jobj_msg, DATA, &jobj_data)) {
PRINT_ERR("failed to parse data\n");
return;
}
//create outgoing message
struct json_object *jobj_outmsg = json_object_new_object();
if (jobj_outmsg == NULL) {
PRINT_ERR("failed to allocate json object for jobj_outmsg\n");
return;
}
json_object_object_add(jobj_outmsg, DATA, jobj_data);
json_object_object_add(jobj_outmsg, VERSION, json_object_new_int(CUR_VERSION));
json_object_object_add(jobj_outmsg, SOURCE_ADDR, jobj_source_addr);
const char *outmsg = json_object_to_json_string_ext(jobj_outmsg, JSON_C_TO_STRING_PLAIN);
// Set up destination address
memset(&cliaddr, 0, sizeof(struct sockaddr_un));
cliaddr.sun_family = AF_UNIX;
cliaddr.sun_path[0] = '\0';
strncpy(cliaddr.sun_path+1, dest_addr, strlen(dest_addr));
addrlen = sizeof(sa_family_t) + strlen(dest_addr) + 1;
// Send the message to the client.
// This will get transparently restarted if interrupted by signal.
ssize_t outlen = strlen(outmsg);
rc = sendto(app_fd, outmsg, outlen, 0, (struct sockaddr *) &cliaddr,
addrlen);
if (rc == -1) {
PRINT_ERR("unable to send msg to %.*s: %m\n", UNIX_ADDR_LEN, cliaddr.sun_path+1);
} else if (rc != outlen) {
PRINT_ERR("sendto didn't send the whole message\n");
}
json_object_put(jobj_outmsg);
}
void handle_app_msg(const char *msg, struct sockaddr_un *cliaddr,
socklen_t cliaddrlen)
{
int rc;
char *app_addr;
//parse incoming msg
struct json_object *jobj_msg = json_tokener_parse(msg);
if (jobj_msg == NULL) {
PRINT_ERR("failed to parse msg\n");
return;
}
// parse version
struct json_object *jobj_version;
if (!json_object_object_get_ex(jobj_msg, VERSION, &jobj_version)) {
PRINT_ERR("failed to parse version\n");
goto done;
}
int version = json_object_get_int(jobj_version);
if (version != CUR_VERSION) {
PRINT_ERR("message from app version %d, expected %d, dropping\n",
version, CUR_VERSION);
goto done;
}
// parse dest instance
struct json_object *jobj_dest_addr;
if (!json_object_object_get_ex(jobj_msg, DEST_ADDR, &jobj_dest_addr)) {
PRINT_ERR("failed to parse dest_address\n");
goto done;
}
// parse data
struct json_object *jobj_data;
if (!json_object_object_get_ex(jobj_msg, DATA, &jobj_data)) {
PRINT_ERR("failed to parse data\n");
goto done;
}
if (cliaddr->sun_path[0] == '\0') {
app_addr = cliaddr->sun_path+1;
// get length without family or leading null from abstract namespace
cliaddrlen = cliaddrlen - sizeof(sa_family_t) - 1;
app_addr[cliaddrlen] = '\0';
} else {
PRINT_INFO("client address not in abstract namespace, dropping\n");
goto done;
}
struct json_object *jobj_outmsg = json_object_new_object();
if (jobj_outmsg == NULL) {
PRINT_ERR("failed to allocate json object for outmsg\n");
goto done;
}
json_object_object_add(jobj_outmsg, DATA, jobj_data);
json_object_object_add(jobj_outmsg, VERSION, jobj_version);
json_object_object_add(jobj_outmsg, DEST_ADDR, jobj_dest_addr);
json_object_object_add(jobj_outmsg, SOURCE_ADDR, json_object_new_string(app_addr));
const char *outmsg = json_object_to_json_string_ext(jobj_outmsg, JSON_C_TO_STRING_PLAIN);
// use '\n' to delimit JSON string: mark the beginning
rc = write(host_fd, "\n", 1);
if (rc == -1) {
PRINT_ERR("unable to send \\n \n");
}
// send to host
ssize_t outlen = strlen(outmsg);
rc = write(host_fd, outmsg, outlen);
if (rc == -1) {
PRINT_ERR("unable to send msg from %.*s: %m\n", UNIX_ADDR_LEN, app_addr);
} else if (rc != outlen) {
PRINT_ERR("write didn't write the whole message to host\n");
}
// use '\n' to delimit JSON string: mark the ending
rc = write(host_fd, "\n", 1);
if (rc == -1) {
PRINT_ERR("unable to send \\n \n");
}
json_object_put(jobj_outmsg);
done:
json_object_put(jobj_msg);
}
void unmask_sigio(void)
{
sigset_t mask;
sigemptyset (&mask);
sigaddset (&mask, SIGIO);
sigprocmask(SIG_UNBLOCK, &mask, 0);
}
void mask_sigio(void)
{
sigset_t mask;
sigemptyset (&mask);
sigaddset (&mask, SIGIO);
sigprocmask(SIG_BLOCK, &mask, 0);
}
void handle_host_conn_down()
{
check_host_connection = 0;
unmask_sigio();
}
void scan_host_fd(struct pollfd *pfd)
{
char buf[10000];
ssize_t rc;
if (pfd->revents & POLLIN) {
// Read all messages from the host device
while(1) {
rc = read(pfd->fd, buf, sizeof(buf));
if (rc == 0) {
// Connection to host has gone down
handle_host_conn_down();
return;
} else if (rc < 0) {
if (errno == EAGAIN)
// We've read all the messages
return;
else {
PRINT_ERR("read from host: %m");
return;
}
}
handle_virtio_serial_msg(buf, rc, pfd->fd, tok);
}
}
}
void scan_app_fd(struct pollfd *pfd)
{
char buf[10000];
struct sockaddr_un cliaddr;
ssize_t rc;
// Read all messages from the app socket
if (pfd->revents & POLLIN) {
while(1) {
socklen_t addrlen = sizeof(struct sockaddr_un);
rc = recvfrom(pfd->fd, buf, sizeof(buf), 0,
(struct sockaddr *) &cliaddr, &addrlen);
if (rc < 0) {
if (errno == EAGAIN)
// We've read all the messages
return;
else {
PRINT_ERR("recvfrom from app: %m");
return;
}
}
handle_app_msg(buf, &cliaddr, addrlen);
}
}
}
//we get a SIGIO if the host connection connects/disconnects
static void sigio_handler(int signal)
{
struct pollfd pfd;
pfd.fd = host_fd;
pfd.events = POLLIN;
poll(&pfd, 1, 0);
// if host is not connected, just exit
if (pfd.revents & POLLHUP)
return;
// host is connected so check it in main loop
check_host_connection = 1;
initial_connection = 1;
}
//dump stack trace on segfault
static void segv_handler(int signum)
{
int count;
void *syms[100];
int fd = open("/var/log/guest_agent_backtrace.log", O_RDWR|O_APPEND|O_CREAT, S_IRWXU);
if (fd == -1) {
PRINT_ERR("Unable to open guest agent backtrace file: %m");
goto out;
}
write(fd, "\n", 1);
count = backtrace(syms, 100);
if (count == 0) {
char *log = "Got zero items in backtrace.\n";
write(fd, log, strlen(log));
goto out;
}
backtrace_symbols_fd(syms, count, fd);
out:
fflush(NULL);
exit(-1);
}
int main(int argc, char **argv)
{
int flags;
int rc;
struct sockaddr_un svaddr;
int addrlen;
PRINT_INFO("%s starting up\n", *argv);
// optional arg for log level. Higher number means more logs
if (argc > 1) {
char *endptr, *str;
long val;
str = argv[1];
errno = 0;
val = strtol(str, &endptr, 0);
if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN))
|| (errno != 0 && val == 0)) {
PRINT_ERR("error parsing log level arg: strtol: %m");
exit(-1);
}
if (endptr == str) {
PRINT_ERR("No digits were found\n");
exit(EXIT_FAILURE);
}
if (val > LOG_DEBUG)
val = LOG_DEBUG;
setlogmask(LOG_UPTO(val));
} else
setlogmask(LOG_UPTO(LOG_WARNING));
signal(SIGIO, sigio_handler);
signal(SIGSEGV, segv_handler);
// set up fd for talking to host
host_fd = open("/dev/virtio-ports/cgcs.messaging", O_RDWR|O_NONBLOCK);
if (host_fd == -1) {
PRINT_ERR("problem with open: %m");
exit(-1);
}
flags = fcntl(host_fd, F_GETFL);
rc = fcntl(host_fd, F_SETFL, flags | O_ASYNC);
if (rc == -1) {
PRINT_ERR("problem setting host_fd async: %m");
exit(-1);
}
rc = fcntl(host_fd, F_SETOWN, getpid());
if (rc == -1) {
PRINT_ERR("problem owning host_fd: %m");
exit(-1);
}
// set up socket for talking to apps
app_fd = socket(AF_UNIX, SOCK_DGRAM, 0);
if (app_fd == -1) {
PRINT_ERR("problem with socket: %m");
exit(-1);
}
flags = fcntl(app_fd, F_GETFL, 0);
fcntl(app_fd, F_SETFL, flags | O_NONBLOCK);
memset(&svaddr, 0, sizeof(struct sockaddr_un));
svaddr.sun_family = AF_UNIX;
svaddr.sun_path[0] = '\0';
strncpy(svaddr.sun_path+1, AGENT_ADDR, sizeof(svaddr.sun_path) - 2);
addrlen = sizeof(sa_family_t) + strlen(AGENT_ADDR) + 1;
if (bind(app_fd, (struct sockaddr *) &svaddr, addrlen) == -1) {
PRINT_ERR("problem with bind: %m");
exit(-1);
}
tok = json_tokener_new();
while(1) {
struct pollfd pollfds[MAX_FDS_GUEST];
int i;
int nfds = 0;
if (check_host_connection) {
// we think the host connection is up
if (initial_connection) {
//mask SIGIO if we haven't already
mask_sigio();
initial_connection