From 27ff86f2517ac519dcb43a7ce87647eaf76d5669 Mon Sep 17 00:00:00 2001 From: Krzysztof Dynowski Date: Wed, 13 May 2015 15:32:25 +0200 Subject: [PATCH 01/16] Vasum wrapper #5, fix exported function list [Bug/Feature] exported funcs not visible [Cause] missing API keyword in declaration [Solution] #5 add API keyword [Verification] Build, build old clients, install on target Change-Id: Idd408bb59f9421d43b153117aa3d825610722283 --- wrapper/wrapper-compatibility.cpp | 78 +++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/wrapper/wrapper-compatibility.cpp b/wrapper/wrapper-compatibility.cpp index d0bd082..adb1edd 100644 --- a/wrapper/wrapper-compatibility.cpp +++ b/wrapper/wrapper-compatibility.cpp @@ -47,11 +47,11 @@ extern "C" { // find_container_by_pid -char *find_container_by_pid(pid_t /*pid*/) { +API char *find_container_by_pid(pid_t /*pid*/) { return NULL; } // get_domain_pid -pid_t get_domain_pid(const char * /*name*/, const char * /*target*/) { +API pid_t get_domain_pid(const char * /*name*/, const char * /*target*/) { return -1; } @@ -179,27 +179,27 @@ int sock_close_socket(int /*fd*/) { return 0; } // sock_connect -int sock_connect(const char * /*path*/) { +API int sock_connect(const char * /*path*/) { return 0; } // sock_create_socket -int sock_create_socket(const char * /*path*/, int /*type*/, int /*flags*/) { +API int sock_create_socket(const char * /*path*/, int /*type*/, int /*flags*/) { return 0; } // sock_monitor_address -int sock_monitor_address(char * /*buffer*/, int /*len*/, const char * /*lxcpath*/) { +API int sock_monitor_address(char * /*buffer*/, int /*len*/, const char * /*lxcpath*/) { return 0; } // sock_recv_fd (intern) -int sock_recv_fd(int /*fd*/, int * /*recvfd*/, void * /*data*/, size_t /*size*/) { +API int sock_recv_fd(int /*fd*/, int * /*recvfd*/, void * /*data*/, size_t /*size*/) { return 0; } // sock_send_fd -int sock_send_fd(int /*fd*/, int /*sendfd*/, void * /*data*/, size_t /*size*/) { +API int sock_send_fd(int /*fd*/, int /*sendfd*/, void * /*data*/, size_t /*size*/) { return 0; } // vasum_log -void vasum_log(int /*type*/, const char * /*tag*/, const char * /*fmt*/ , ...) { +API void vasum_log(int /*type*/, const char * /*tag*/, const char * /*fmt*/ , ...) { } #define MAX_ERROR_MSG 0x1000 @@ -220,7 +220,7 @@ const char *const fso_type_strtab[] = { "Device node" }; -const char *fso_type_to_string(vsm_fso_type_t fso) +API const char *fso_type_to_string(vsm_fso_type_t fso) { if (fso < 0 || fso > VSM_FSO_MAX_TYPE) { return NULL; @@ -229,7 +229,7 @@ const char *fso_type_to_string(vsm_fso_type_t fso) return fso_type_strtab[fso]; } -int wait_for_pid_status(pid_t pid) +API int wait_for_pid_status(pid_t pid) { int status, ret; @@ -249,7 +249,7 @@ int wait_for_pid_status(pid_t pid) return status; } -vsm_fso_type_t fso_string_to_type(char *str) +API vsm_fso_type_t fso_string_to_type(char *str) { int len; int i; @@ -262,7 +262,7 @@ vsm_fso_type_t fso_string_to_type(char *str) return static_cast(-1); } -int mkdir_p(const char *dir, mode_t mode) +API int mkdir_p(const char *dir, mode_t mode) { const char *tmp = dir; const char *orig = dir; @@ -284,7 +284,7 @@ int mkdir_p(const char *dir, mode_t mode) return 0; } -int lock_fd(int fd, int wait) +API int lock_fd(int fd, int wait) { int ret; struct flock f; @@ -307,7 +307,7 @@ int lock_fd(int fd, int wait) } } -int unlock_fd(int fd) +API int unlock_fd(int fd) { struct flock f; f.l_type = F_UNLCK; @@ -317,12 +317,12 @@ int unlock_fd(int fd) return fcntl(fd, F_SETLKW, &f); } -int copy_smacklabel(const char * /*source*/, const char * /*dest*/) +API int copy_smacklabel(const char * /*source*/, const char * /*dest*/) { return 0; } -int remove_file(char *path) +API int remove_file(char *path) { struct stat path_stat; DIR *dp; @@ -374,7 +374,7 @@ int remove_file(char *path) return status; } -int copy_file(const char *source, const char *dest, int /*flags*/) +API int copy_file(const char *source, const char *dest, int /*flags*/) { int ret; FILE *sfp, *dfp; @@ -424,7 +424,7 @@ int copy_file(const char *source, const char *dest, int /*flags*/) return 0; } -int regex_compile(regex_t * r, const char *regex_text) +API int regex_compile(regex_t * r, const char *regex_text) { int status = regcomp(r, regex_text, REG_EXTENDED | REG_NEWLINE); @@ -440,7 +440,7 @@ int regex_compile(regex_t * r, const char *regex_text) return 0; } -int regex_match(regex_t * r, const char *to_match) +API int regex_match(regex_t * r, const char *to_match) { const char *p = to_match; const int n_matches = 10; @@ -483,7 +483,7 @@ int regex_match(regex_t * r, const char *to_match) return 0; } -int get_peer_pid(int fd) +API int get_peer_pid(int fd) { struct ucred cred; socklen_t cr_len = sizeof(cred); @@ -493,12 +493,12 @@ int get_peer_pid(int fd) return cred.pid; } -pid_t gettid(void) +API pid_t gettid(void) { return syscall(__NR_gettid); } -int set_smacklabel_fd(int fd, const char *xattr_name, const char *label) +API int set_smacklabel_fd(int fd, const char *xattr_name, const char *label) { size_t len; int ret; @@ -517,7 +517,7 @@ int set_smacklabel_fd(int fd, const char *xattr_name, const char *label) return ret; } -int set_smacklabel(const char *path, const char *xattr_name, const char *label) +API int set_smacklabel(const char *path, const char *xattr_name, const char *label) { size_t len; int ret; @@ -535,7 +535,7 @@ int set_smacklabel(const char *path, const char *xattr_name, const char *label) } return ret; } -char *get_self_smacklabel(void) +API char *get_self_smacklabel(void) { int ret; int fd; @@ -563,7 +563,7 @@ char *get_self_smacklabel(void) return strdup(buffer); } -int get_self_cpuset(char *name, int buf_sz) +API int get_self_cpuset(char *name, int buf_sz) { int fd; int lxc_len, ret; @@ -607,7 +607,7 @@ int get_self_cpuset(char *name, int buf_sz) } -char * get_pid_cpuset(int pid) +API char * get_pid_cpuset(int pid) { int fd; int ret; @@ -639,7 +639,7 @@ char * get_pid_cpuset(int pid) return strdup(current_name); } -char * read_namespace_link(const char *ns, int pid) +API char * read_namespace_link(const char *ns, int pid) { char ns_path[PATH_MAX]; char buf[NAME_MAX]; @@ -666,7 +666,7 @@ char * read_namespace_link(const char *ns, int pid) // libs/device.c #define DEV_ITERATE_CONTINUE 0 -int dev_enumerate_nodes(const char *cname, dev_enumerator enumerator, +API int dev_enumerate_nodes(const char *cname, dev_enumerator enumerator, void *data) { int ret; @@ -704,7 +704,7 @@ int dev_enumerate_nodes(const char *cname, dev_enumerator enumerator, return ret; } -int dev_terminal_enumerator(int type, int major, int minor, void *data) +API int dev_terminal_enumerator(int type, int major, int minor, void *data) { int *dev = (int*)data; @@ -718,7 +718,7 @@ int dev_terminal_enumerator(int type, int major, int minor, void *data) } // libs/namespace.c -pid_t get_init_pid(const char *name) +API pid_t get_init_pid(const char *name) { char filename[PATH_MAX]; FILE *fp; @@ -744,7 +744,7 @@ pid_t get_init_pid(const char *name) } -pid_t get_zone_pid(const char *name, const char *target) +API pid_t get_zone_pid(const char *name, const char *target) { char path[PATH_MAX]; char cmd[PATH_MAX]; @@ -821,7 +821,7 @@ pid_t get_zone_pid(const char *name, const char *target) return ret; } -int open_ns(pid_t pid, const char *name) +API int open_ns(pid_t pid, const char *name) { int fd, ret; char path[PATH_MAX]; @@ -871,7 +871,7 @@ static int open_console(const char *path) return fd; } -int get_console_fd(const char *path) +API int get_console_fd(const char *path) { int fd; @@ -903,7 +903,7 @@ int get_console_fd(const char *path) return -1; } -int vt_switch_terminal(int id) +API int vt_switch_terminal(int id) { int fd, ret = -1; @@ -926,7 +926,7 @@ int vt_switch_terminal(int id) return ret; } -int vt_find_unused_terminal(void) +API int vt_find_unused_terminal(void) { int fd, nr = -1; @@ -947,7 +947,7 @@ int vt_find_unused_terminal(void) return nr; } -int vt_query_active_terminal(void) +API int vt_query_active_terminal(void) { int fd, ret = -1; struct vt_stat vtstat; @@ -977,7 +977,7 @@ struct unit_parser { struct unit_keyword_callback *kw; }; -int parse_stream(const char *name, struct unit_parser *parser); +API int parse_stream(const char *name, struct unit_parser *parser); // libs/parser.c #define PARSER_MAXARGS 32 @@ -1187,7 +1187,7 @@ static int parse_statement(struct parser_context *ctx, int argc, char **argv, return ret; } -int parse_stream_core(struct parser_context *ctx, char *s) +API int parse_stream_core(struct parser_context *ctx, char *s) { struct unit_keyword_callback *kw; struct parser_state state; @@ -1268,7 +1268,7 @@ static char *open_stream(const char *name, unsigned int *_sz) return NULL; } -int parse_stream(const char *name, struct unit_parser *parser) +API int parse_stream(const char *name, struct unit_parser *parser) { char *stream; struct parser_context *ctx; -- 2.7.4 From ef63fea3b86d66beecdf06e4cd314b0e92df0dd0 Mon Sep 17 00:00:00 2001 From: Mateusz Malicki Date: Thu, 14 May 2015 12:31:27 +0200 Subject: [PATCH 02/16] libIpc separated from vasum #1 (code refactor) [Feature] Code refactor a) moved vasum::utils namspace to utils namespace b) moved vasum::ipc namespace to ipc namespace c) moved vasum::epoll namespace to ipc::epoll namespace d) moved common/epoll source dir to common/ipc/epoll e) moved UtilsException to utils namespace f) moved getSystemErrorMessage to utils/exception.hpp [Cause] N/A [Solution] N/A [Verification] Build, install Change-Id: I2cda58decfdb30ec9a27f7cb65940ae8dbc7edf3 --- client/CMakeLists.txt | 2 +- client/host-ipc-connection.cpp | 2 +- client/host-ipc-connection.hpp | 6 +-- client/vasum-client-impl.cpp | 4 +- client/vasum-client-impl.hpp | 2 +- common/base-exception.hpp | 7 --- common/ipc/client.cpp | 2 - common/ipc/client.hpp | 2 - common/{ => ipc}/epoll/event-poll.cpp | 9 ++-- common/{ => ipc}/epoll/event-poll.hpp | 6 +-- common/{ => ipc}/epoll/events.cpp | 6 +-- common/{ => ipc}/epoll/events.hpp | 4 +- common/{ => ipc}/epoll/glib-dispatcher.cpp | 6 +-- common/{ => ipc}/epoll/glib-dispatcher.hpp | 6 +-- common/{ => ipc}/epoll/thread-dispatcher.cpp | 6 +-- common/{ => ipc}/epoll/thread-dispatcher.hpp | 6 +-- common/ipc/exception.hpp | 4 +- common/ipc/internals/acceptor.cpp | 2 - common/ipc/internals/acceptor.hpp | 2 - common/ipc/internals/add-peer-request.hpp | 2 - common/ipc/internals/event-queue.hpp | 2 - common/ipc/internals/finish-request.hpp | 2 - common/ipc/internals/method-request.hpp | 2 - common/ipc/internals/processor.cpp | 4 +- common/ipc/internals/processor.hpp | 2 - common/ipc/internals/remove-peer-request.hpp | 2 - common/ipc/internals/request-queue.hpp | 2 - common/ipc/internals/result-builder.hpp | 2 - common/ipc/internals/send-result-request.hpp | 2 - common/ipc/internals/signal-request.hpp | 2 - common/ipc/internals/socket.cpp | 4 +- common/ipc/internals/socket.hpp | 2 - common/ipc/ipc-gsource.cpp | 2 - common/ipc/ipc-gsource.hpp | 2 - common/ipc/method-result.cpp | 2 - common/ipc/method-result.hpp | 2 - common/ipc/result.hpp | 2 - common/ipc/service.cpp | 2 - common/ipc/service.hpp | 2 - common/ipc/types.cpp | 2 - common/ipc/types.hpp | 2 - common/netlink/netlink.cpp | 3 +- common/utils/c-array.hpp | 2 - common/utils/callback-guard.cpp | 2 - common/utils/callback-guard.hpp | 2 - common/utils/callback-wrapper.hpp | 2 - common/utils/counting-map.hpp | 2 - common/utils/environment.cpp | 7 ++- common/utils/environment.hpp | 2 - common/utils/eventfd.cpp | 4 +- common/utils/eventfd.hpp | 2 - common/{base-exception.cpp => utils/exception.cpp} | 8 +-- common/utils/exception.hpp | 14 ++++-- common/utils/execute.cpp | 6 +-- common/utils/execute.hpp | 2 - common/utils/fd-utils.cpp | 4 +- common/utils/fd-utils.hpp | 2 - common/utils/file-wait.cpp | 3 +- common/utils/file-wait.hpp | 2 - common/utils/fs.cpp | 4 +- common/utils/fs.hpp | 2 - common/utils/glib-loop.cpp | 2 - common/utils/glib-loop.hpp | 2 - common/utils/glib-utils.cpp | 2 - common/utils/glib-utils.hpp | 2 - common/utils/img.cpp | 4 +- common/utils/img.hpp | 2 - common/utils/initctl.cpp | 2 - common/utils/initctl.hpp | 2 - common/utils/latch.cpp | 2 - common/utils/latch.hpp | 2 - common/utils/make-clean.hpp | 2 - common/utils/paths.hpp | 2 - common/utils/same-thread-guard.cpp | 2 - common/utils/same-thread-guard.hpp | 2 - common/utils/scoped-gerror.cpp | 2 - common/utils/scoped-gerror.hpp | 2 - common/utils/signal.cpp | 2 - common/utils/signal.hpp | 2 - common/utils/typeinfo.cpp | 2 - common/utils/typeinfo.hpp | 2 - common/utils/value-latch.hpp | 2 - common/utils/vt.cpp | 4 +- common/utils/vt.hpp | 2 - common/utils/worker.cpp | 2 - common/utils/worker.hpp | 2 - libs/dbus/connection.cpp | 2 +- libs/dbus/connection.hpp | 2 +- server/host-ipc-connection.hpp | 4 +- server/host-ipc-definitions.hpp | 58 +++++++++++----------- server/input-monitor.cpp | 2 +- server/netdev.cpp | 3 +- server/server.cpp | 3 ++ server/zone-provision.cpp | 2 + tests/unit_tests/client/ut-client.cpp | 2 +- tests/unit_tests/config/ut-configuration.cpp | 3 +- tests/unit_tests/config/ut-dynvisit.cpp | 3 +- tests/unit_tests/config/ut-kvstore.cpp | 4 +- tests/unit_tests/dbus/ut-connection.cpp | 2 +- tests/unit_tests/epoll/ut-event-poll.cpp | 12 ++--- tests/unit_tests/ipc/ut-ipc.cpp | 10 ++-- tests/unit_tests/ipc/ut-socket.cpp | 2 +- tests/unit_tests/server/ut-input-monitor.cpp | 2 +- tests/unit_tests/server/ut-server.cpp | 14 +++--- tests/unit_tests/server/ut-zone-provision.cpp | 1 + tests/unit_tests/server/ut-zone.cpp | 7 +-- tests/unit_tests/server/ut-zones-manager.cpp | 12 ++--- .../unit_tests/socket_test_service/socket-test.cpp | 2 +- tests/unit_tests/utils/scoped-daemon.cpp | 2 - tests/unit_tests/utils/scoped-daemon.hpp | 2 - tests/unit_tests/utils/scoped-dir.cpp | 2 - tests/unit_tests/utils/scoped-dir.hpp | 2 - tests/unit_tests/utils/ut-callback-guard.cpp | 3 +- tests/unit_tests/utils/ut-counting-map.cpp | 2 +- tests/unit_tests/utils/ut-fs.cpp | 3 +- tests/unit_tests/utils/ut-glib-loop.cpp | 3 +- tests/unit_tests/utils/ut-paths.cpp | 2 +- tests/unit_tests/utils/ut-same-thread-guard.cpp | 2 +- tests/unit_tests/utils/ut-value-latch.cpp | 8 +-- tests/unit_tests/utils/ut-worker.cpp | 4 +- 120 files changed, 164 insertions(+), 284 deletions(-) rename common/{ => ipc}/epoll/event-poll.cpp (97%) rename common/{ => ipc}/epoll/event-poll.hpp (96%) rename common/{ => ipc}/epoll/events.cpp (96%) rename common/{ => ipc}/epoll/events.hpp (96%) rename common/{ => ipc}/epoll/glib-dispatcher.cpp (96%) rename common/{ => ipc}/epoll/glib-dispatcher.hpp (94%) rename common/{ => ipc}/epoll/thread-dispatcher.cpp (95%) rename common/{ => ipc}/epoll/thread-dispatcher.hpp (95%) rename common/{base-exception.cpp => utils/exception.cpp} (89%) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 9b1d890..e08c79b 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -22,7 +22,7 @@ MESSAGE(STATUS "") MESSAGE(STATUS "Generating makefile for the Client...") FILE(GLOB project_SRCS *.cpp *.hpp *.h) -FILE(GLOB common_SRCS ${COMMON_FOLDER}/epoll/*.hpp ${COMMON_FOLDER}/epoll/*.cpp +FILE(GLOB common_SRCS ${COMMON_FOLDER}/ipc/epoll/*.hpp ${COMMON_FOLDER}/ipc/epoll/*.cpp ${COMMON_FOLDER}/ipc/*.hpp ${COMMON_FOLDER}/ipc/*.cpp ${COMMON_FOLDER}/ipc/internals/*.hpp ${COMMON_FOLDER}/ipc/internals/*.cpp ${COMMON_FOLDER}/utils/*.hpp ${COMMON_FOLDER}/utils/*.cpp diff --git a/client/host-ipc-connection.cpp b/client/host-ipc-connection.cpp index b17c6cf..7444f19 100644 --- a/client/host-ipc-connection.cpp +++ b/client/host-ipc-connection.cpp @@ -40,7 +40,7 @@ void HostIPCConnection::createSystem() mClient.reset(new ipc::Client(mDispatcher.getPoll(), HOST_IPC_SOCKET)); mClient->start(); } -epoll::ThreadDispatcher& HostIPCConnection::getDispatcher() +ipc::epoll::ThreadDispatcher& HostIPCConnection::getDispatcher() { return mDispatcher; } diff --git a/client/host-ipc-connection.hpp b/client/host-ipc-connection.hpp index 1497390..52b90b7 100644 --- a/client/host-ipc-connection.hpp +++ b/client/host-ipc-connection.hpp @@ -27,7 +27,7 @@ #define VASUM_CLIENT_HOST_IPC_CONNECTION_HPP #include -#include +#include #include #include @@ -44,7 +44,7 @@ public: typedef std::function NotificationCallback; void createSystem(); void create(const std::string& address); - epoll::ThreadDispatcher& getDispatcher(); + ipc::epoll::ThreadDispatcher& getDispatcher(); void callGetZoneIds(vasum::api::ZoneIds& argOut); void callGetActiveZoneId(vasum::api::ZoneId& argOut); @@ -80,7 +80,7 @@ public: void unsubscribe(const SubscriptionId& id); private: - epoll::ThreadDispatcher mDispatcher; + ipc::epoll::ThreadDispatcher mDispatcher; std::unique_ptr mClient; }; diff --git a/client/vasum-client-impl.cpp b/client/vasum-client-impl.cpp index bbc7e9e..b9af36f 100644 --- a/client/vasum-client-impl.cpp +++ b/client/vasum-client-impl.cpp @@ -27,6 +27,7 @@ #include "vasum-client-impl.hpp" #include "utils.hpp" #include "exception.hpp" +#include "utils/exception.hpp" #include "host-ipc-connection.hpp" #include "logger/logger.hpp" @@ -42,6 +43,7 @@ #include using namespace std; +using namespace utils; using namespace vasum; namespace { @@ -194,7 +196,7 @@ VsmStatus Client::create(const string& address) noexcept }); } -epoll::EventPoll& Client::getEventPoll() noexcept +ipc::epoll::EventPoll& Client::getEventPoll() noexcept { return mHostClient.getDispatcher().getPoll(); } diff --git a/client/vasum-client-impl.hpp b/client/vasum-client-impl.hpp index da6dc8f..0b96149 100644 --- a/client/vasum-client-impl.hpp +++ b/client/vasum-client-impl.hpp @@ -69,7 +69,7 @@ public: */ VsmStatus createSystem() noexcept; - vasum::epoll::EventPoll& getEventPoll() noexcept; + ipc::epoll::EventPoll& getEventPoll() noexcept; /** * Create client. diff --git a/common/base-exception.hpp b/common/base-exception.hpp index 89b79bc..645fa41 100644 --- a/common/base-exception.hpp +++ b/common/base-exception.hpp @@ -41,13 +41,6 @@ struct VasumException: public std::runtime_error { VasumException(const std::string& error) : std::runtime_error(error) {} }; -/** - * Return string describing error number - * it is wrapper for strerror_r - */ -std::string getSystemErrorMessage(); -std::string getSystemErrorMessage(int err); - } // namespace vasum diff --git a/common/ipc/client.cpp b/common/ipc/client.cpp index 75a62ad..3fff662 100644 --- a/common/ipc/client.cpp +++ b/common/ipc/client.cpp @@ -28,7 +28,6 @@ #include "ipc/internals/socket.hpp" #include "ipc/exception.hpp" -namespace vasum { namespace ipc { Client::Client(epoll::EventPoll& eventPoll, const std::string& socketPath) @@ -139,4 +138,3 @@ void Client::removeMethod(const MethodID methodID) } } // namespace ipc -} // namespace vasum diff --git a/common/ipc/client.hpp b/common/ipc/client.hpp index db15a4a..c76a817 100644 --- a/common/ipc/client.hpp +++ b/common/ipc/client.hpp @@ -33,7 +33,6 @@ #include -namespace vasum { namespace ipc { /** @@ -212,6 +211,5 @@ void Client::signal(const MethodID methodID, } } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_CLIENT_HPP diff --git a/common/epoll/event-poll.cpp b/common/ipc/epoll/event-poll.cpp similarity index 97% rename from common/epoll/event-poll.cpp rename to common/ipc/epoll/event-poll.cpp index adca814..d43c97d 100644 --- a/common/epoll/event-poll.cpp +++ b/common/ipc/epoll/event-poll.cpp @@ -23,7 +23,7 @@ */ #include "config.hpp" -#include "epoll/event-poll.hpp" +#include "ipc/epoll/event-poll.hpp" #include "utils/fd-utils.hpp" #include "utils/exception.hpp" #include "logger/logger.hpp" @@ -33,7 +33,10 @@ #include #include -namespace vasum { +using namespace vasum; +using namespace utils; + +namespace ipc { namespace epoll { EventPoll::EventPoll() @@ -176,4 +179,4 @@ void EventPoll::removeFDInternal(const int fd) } } // namespace epoll -} // namespace vasum +} // namespace ipc diff --git a/common/epoll/event-poll.hpp b/common/ipc/epoll/event-poll.hpp similarity index 96% rename from common/epoll/event-poll.hpp rename to common/ipc/epoll/event-poll.hpp index 67614ab..5e84ee3 100644 --- a/common/epoll/event-poll.hpp +++ b/common/ipc/epoll/event-poll.hpp @@ -25,14 +25,14 @@ #ifndef COMMON_EPOLL_EVENT_POLL_HPP #define COMMON_EPOLL_EVENT_POLL_HPP -#include "epoll/events.hpp" +#include "ipc/epoll/events.hpp" #include #include #include #include -namespace vasum { +namespace ipc { namespace epoll { class EventPoll { @@ -70,6 +70,6 @@ private: } // namespace epoll -} // namespace vasum +} // namespace ipc #endif // COMMON_EPOLL_EVENT_POLL_HPP diff --git a/common/epoll/events.cpp b/common/ipc/epoll/events.cpp similarity index 96% rename from common/epoll/events.cpp rename to common/ipc/epoll/events.cpp index 1ee27e0..35952fd 100644 --- a/common/epoll/events.cpp +++ b/common/ipc/epoll/events.cpp @@ -23,11 +23,11 @@ */ #include "config.hpp" -#include "epoll/events.hpp" +#include "ipc/epoll/events.hpp" #include -namespace vasum { +namespace ipc { namespace epoll { namespace { @@ -68,4 +68,4 @@ std::string eventsToString(Events events) } } // namespace epoll -} // namespace vasum +} // namespace ipc diff --git a/common/epoll/events.hpp b/common/ipc/epoll/events.hpp similarity index 96% rename from common/epoll/events.hpp rename to common/ipc/epoll/events.hpp index 62eb00a..093542b 100644 --- a/common/epoll/events.hpp +++ b/common/ipc/epoll/events.hpp @@ -28,7 +28,7 @@ #include #include // for EPOLL* constatnts -namespace vasum { +namespace ipc { namespace epoll { typedef unsigned int Events; ///< bitmask of EPOLL* constants @@ -36,6 +36,6 @@ typedef unsigned int Events; ///< bitmask of EPOLL* constants std::string eventsToString(Events events); } // namespace epoll -} // namespace vasum +} // namespace ipc #endif // COMMON_EPOLL_EVENTS_HPP diff --git a/common/epoll/glib-dispatcher.cpp b/common/ipc/epoll/glib-dispatcher.cpp similarity index 96% rename from common/epoll/glib-dispatcher.cpp rename to common/ipc/epoll/glib-dispatcher.cpp index 9567abb..d17ea54 100644 --- a/common/epoll/glib-dispatcher.cpp +++ b/common/ipc/epoll/glib-dispatcher.cpp @@ -23,10 +23,10 @@ */ #include "config.hpp" -#include "epoll/glib-dispatcher.hpp" +#include "ipc/epoll/glib-dispatcher.hpp" #include "utils/callback-wrapper.hpp" -namespace vasum { +namespace ipc { namespace epoll { GlibDispatcher::GlibDispatcher() @@ -63,4 +63,4 @@ EventPoll& GlibDispatcher::getPoll() } } // namespace epoll -} // namespace vasum +} // namespace ipc diff --git a/common/epoll/glib-dispatcher.hpp b/common/ipc/epoll/glib-dispatcher.hpp similarity index 94% rename from common/epoll/glib-dispatcher.hpp rename to common/ipc/epoll/glib-dispatcher.hpp index 0fa7b3a..2eb58b1 100644 --- a/common/epoll/glib-dispatcher.hpp +++ b/common/ipc/epoll/glib-dispatcher.hpp @@ -25,12 +25,12 @@ #ifndef COMMON_EPOLL_GLIB_DISPATCHER_HPP #define COMMON_EPOLL_GLIB_DISPATCHER_HPP -#include "epoll/event-poll.hpp" +#include "ipc/epoll/event-poll.hpp" #include "utils/callback-guard.hpp" #include -namespace vasum { +namespace ipc { namespace epoll { /** @@ -51,6 +51,6 @@ private: } // namespace epoll -} // namespace vasum +} // namespace ipc #endif // COMMON_UTILS_GLIB_DISPATCHER_HPP diff --git a/common/epoll/thread-dispatcher.cpp b/common/ipc/epoll/thread-dispatcher.cpp similarity index 95% rename from common/epoll/thread-dispatcher.cpp rename to common/ipc/epoll/thread-dispatcher.cpp index d286c19..fcc3d17 100644 --- a/common/epoll/thread-dispatcher.cpp +++ b/common/ipc/epoll/thread-dispatcher.cpp @@ -23,9 +23,9 @@ */ #include "config.hpp" -#include "epoll/thread-dispatcher.hpp" +#include "ipc/epoll/thread-dispatcher.hpp" -namespace vasum { +namespace ipc { namespace epoll { ThreadDispatcher::ThreadDispatcher() @@ -57,4 +57,4 @@ EventPoll& ThreadDispatcher::getPoll() } } // namespace epoll -} // namespace vasum +} // namespace ipc diff --git a/common/epoll/thread-dispatcher.hpp b/common/ipc/epoll/thread-dispatcher.hpp similarity index 95% rename from common/epoll/thread-dispatcher.hpp rename to common/ipc/epoll/thread-dispatcher.hpp index 5c6c145..033967f 100644 --- a/common/epoll/thread-dispatcher.hpp +++ b/common/ipc/epoll/thread-dispatcher.hpp @@ -25,13 +25,13 @@ #ifndef COMMON_EPOLL_THREAD_DISPATCHER_HPP #define COMMON_EPOLL_THREAD_DISPATCHER_HPP -#include "epoll/event-poll.hpp" +#include "ipc/epoll/event-poll.hpp" #include "utils/eventfd.hpp" #include #include -namespace vasum { +namespace ipc { namespace epoll { /** @@ -51,6 +51,6 @@ private: }; } // namespace epoll -} // namespace vasum +} // namespace ipc #endif // COMMON_EPOLL_THREAD_DISPATCHER_HPP diff --git a/common/ipc/exception.hpp b/common/ipc/exception.hpp index 8e9a7df..3d89d3b 100644 --- a/common/ipc/exception.hpp +++ b/common/ipc/exception.hpp @@ -28,13 +28,12 @@ #include "base-exception.hpp" -namespace vasum { namespace ipc { /** * Base class for exceptions in IPC */ -struct IPCException: public VasumException { +struct IPCException: public vasum::VasumException { IPCException(const std::string& message) : VasumException(message) {} }; @@ -90,6 +89,5 @@ private: }; } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_EXCEPTION_HPP diff --git a/common/ipc/internals/acceptor.cpp b/common/ipc/internals/acceptor.cpp index 15b9ad8..604c65a 100644 --- a/common/ipc/internals/acceptor.cpp +++ b/common/ipc/internals/acceptor.cpp @@ -27,7 +27,6 @@ #include "ipc/internals/acceptor.hpp" #include "logger/logger.hpp" -namespace vasum { namespace ipc { Acceptor::Acceptor(const std::string& socketPath, const NewConnectionCallback& newConnectionCallback) @@ -54,4 +53,3 @@ FileDescriptor Acceptor::getConnectionFD() } } // namespace ipc -} // namespace vasum diff --git a/common/ipc/internals/acceptor.hpp b/common/ipc/internals/acceptor.hpp index a6e9ec8..9725e70 100644 --- a/common/ipc/internals/acceptor.hpp +++ b/common/ipc/internals/acceptor.hpp @@ -32,7 +32,6 @@ #include -namespace vasum { namespace ipc { /** @@ -73,6 +72,5 @@ private: }; } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_INTERNALS_ACCEPTOR_HPP diff --git a/common/ipc/internals/add-peer-request.hpp b/common/ipc/internals/add-peer-request.hpp index 57ec06c..bb8a81f 100644 --- a/common/ipc/internals/add-peer-request.hpp +++ b/common/ipc/internals/add-peer-request.hpp @@ -28,7 +28,6 @@ #include "ipc/types.hpp" #include "ipc/internals/socket.hpp" -namespace vasum { namespace ipc { class AddPeerRequest { @@ -47,6 +46,5 @@ public: }; } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_INTERNALS_ADD_PEER_REQUEST_HPP diff --git a/common/ipc/internals/event-queue.hpp b/common/ipc/internals/event-queue.hpp index b4532fd..1b13449 100644 --- a/common/ipc/internals/event-queue.hpp +++ b/common/ipc/internals/event-queue.hpp @@ -33,7 +33,6 @@ #include #include -namespace vasum { namespace ipc { @@ -119,6 +118,5 @@ bool EventQueue::isEmpty() } } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_INTERNALS_EVENT_QUEUE_HPP diff --git a/common/ipc/internals/finish-request.hpp b/common/ipc/internals/finish-request.hpp index d09a14e..934c135 100644 --- a/common/ipc/internals/finish-request.hpp +++ b/common/ipc/internals/finish-request.hpp @@ -27,7 +27,6 @@ #include -namespace vasum { namespace ipc { class FinishRequest { @@ -43,6 +42,5 @@ public: }; } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_INTERNALS_FINISH_REQUEST_HPP diff --git a/common/ipc/internals/method-request.hpp b/common/ipc/internals/method-request.hpp index 8ec1223..663cbde 100644 --- a/common/ipc/internals/method-request.hpp +++ b/common/ipc/internals/method-request.hpp @@ -32,7 +32,6 @@ #include "config/manager.hpp" #include -namespace vasum { namespace ipc { class MethodRequest { @@ -94,6 +93,5 @@ std::shared_ptr MethodRequest::create(const MethodID methodID, } } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_INTERNALS_METHOD_REQUEST_HPP diff --git a/common/ipc/internals/processor.cpp b/common/ipc/internals/processor.cpp index 587723c..9cb86c0 100644 --- a/common/ipc/internals/processor.cpp +++ b/common/ipc/internals/processor.cpp @@ -36,7 +36,8 @@ #include #include -namespace vasum { +using namespace utils; + namespace ipc { #define IGNORE_EXCEPTIONS(expr) \ @@ -728,4 +729,3 @@ std::ostream& operator<<(std::ostream& os, const Processor::Event& event) } } // namespace ipc -} // namespace vasum diff --git a/common/ipc/internals/processor.hpp b/common/ipc/internals/processor.hpp index 84aaa5c..ecc3a1d 100644 --- a/common/ipc/internals/processor.hpp +++ b/common/ipc/internals/processor.hpp @@ -54,7 +54,6 @@ #include #include -namespace vasum { namespace ipc { const unsigned int DEFAULT_MAX_NUMBER_OF_PEERS = 500; @@ -684,6 +683,5 @@ void Processor::signal(const MethodID methodID, } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_INTERNALS_PROCESSOR_HPP diff --git a/common/ipc/internals/remove-peer-request.hpp b/common/ipc/internals/remove-peer-request.hpp index 6ef8eca..c9f7ec7 100644 --- a/common/ipc/internals/remove-peer-request.hpp +++ b/common/ipc/internals/remove-peer-request.hpp @@ -30,7 +30,6 @@ #include -namespace vasum { namespace ipc { class RemovePeerRequest { @@ -50,6 +49,5 @@ public: }; } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_INTERNALS_REMOVE_PEER_REQUEST_HPP diff --git a/common/ipc/internals/request-queue.hpp b/common/ipc/internals/request-queue.hpp index 44306ee..810175f 100644 --- a/common/ipc/internals/request-queue.hpp +++ b/common/ipc/internals/request-queue.hpp @@ -34,7 +34,6 @@ #include #include -namespace vasum { namespace ipc { /** @@ -184,6 +183,5 @@ bool RequestQueue::removeIf(Predicate predicate) return true; } } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_INTERNALS_MESSAGE_QUEUE_HPP diff --git a/common/ipc/internals/result-builder.hpp b/common/ipc/internals/result-builder.hpp index 3fe3c49..97134e3 100644 --- a/common/ipc/internals/result-builder.hpp +++ b/common/ipc/internals/result-builder.hpp @@ -30,7 +30,6 @@ #include #include -namespace vasum { namespace ipc { class ResultBuilder { @@ -67,7 +66,6 @@ typedef std::function ResultBuilderHandler; } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_RESULT_BUILDER_HPP diff --git a/common/ipc/internals/send-result-request.hpp b/common/ipc/internals/send-result-request.hpp index bc1db6c..a6ed2b4 100644 --- a/common/ipc/internals/send-result-request.hpp +++ b/common/ipc/internals/send-result-request.hpp @@ -28,7 +28,6 @@ #include "ipc/types.hpp" #include "logger/logger-scope.hpp" -namespace vasum { namespace ipc { class SendResultRequest { @@ -53,6 +52,5 @@ public: }; } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_INTERNALS_SEND_RESULT_REQUEST_HPP diff --git a/common/ipc/internals/signal-request.hpp b/common/ipc/internals/signal-request.hpp index dac9c4d..904d3f3 100644 --- a/common/ipc/internals/signal-request.hpp +++ b/common/ipc/internals/signal-request.hpp @@ -29,7 +29,6 @@ #include "config/manager.hpp" #include "logger/logger-scope.hpp" -namespace vasum { namespace ipc { class SignalRequest { @@ -75,6 +74,5 @@ std::shared_ptr SignalRequest::create(const MethodID methodID, } } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_INTERNALS_SIGNAL_REQUEST_HPP diff --git a/common/ipc/internals/socket.cpp b/common/ipc/internals/socket.cpp index 26e1c27..0654a4e 100644 --- a/common/ipc/internals/socket.cpp +++ b/common/ipc/internals/socket.cpp @@ -27,6 +27,7 @@ #include "ipc/exception.hpp" #include "ipc/internals/socket.hpp" #include "utils/fd-utils.hpp" +#include "utils/exception.hpp" #include "logger/logger.hpp" #include @@ -38,8 +39,8 @@ #include #include +using namespace utils; -namespace vasum { namespace ipc { namespace { @@ -225,4 +226,3 @@ Socket Socket::connectSocket(const std::string& path) } } // namespace ipc -} // namespace vasum diff --git a/common/ipc/internals/socket.hpp b/common/ipc/internals/socket.hpp index 839afe4..65f574d 100644 --- a/common/ipc/internals/socket.hpp +++ b/common/ipc/internals/socket.hpp @@ -29,7 +29,6 @@ #include #include -namespace vasum { namespace ipc { /** @@ -114,6 +113,5 @@ private: }; } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_INTERNALS_SOCKET_HPP diff --git a/common/ipc/ipc-gsource.cpp b/common/ipc/ipc-gsource.cpp index 1769414..d339d50 100644 --- a/common/ipc/ipc-gsource.cpp +++ b/common/ipc/ipc-gsource.cpp @@ -31,7 +31,6 @@ #include -namespace vasum { namespace ipc { namespace { @@ -205,4 +204,3 @@ void IPCGSource::finalize(GSource* gSource) } } // namespace ipc -} // namespace vasum diff --git a/common/ipc/ipc-gsource.hpp b/common/ipc/ipc-gsource.hpp index 87057db..ed01989 100644 --- a/common/ipc/ipc-gsource.hpp +++ b/common/ipc/ipc-gsource.hpp @@ -34,7 +34,6 @@ #include -namespace vasum { namespace ipc { /** @@ -143,6 +142,5 @@ private: }; } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_IPC_GSOURCE_HPP diff --git a/common/ipc/method-result.cpp b/common/ipc/method-result.cpp index 826354c..ffb97a8 100644 --- a/common/ipc/method-result.cpp +++ b/common/ipc/method-result.cpp @@ -27,7 +27,6 @@ #include "ipc/method-result.hpp" #include "ipc/internals/processor.hpp" -namespace vasum { namespace ipc { MethodResult::MethodResult(Processor& processor, @@ -56,4 +55,3 @@ void MethodResult::setError(const int code, const std::string& message) } } // namespace ipc -} // namespace vasum diff --git a/common/ipc/method-result.hpp b/common/ipc/method-result.hpp index ebe9697..bd9d10f 100644 --- a/common/ipc/method-result.hpp +++ b/common/ipc/method-result.hpp @@ -29,7 +29,6 @@ #include "logger/logger.hpp" #include -namespace vasum { namespace ipc { class Processor; @@ -70,6 +69,5 @@ struct MethodHandler { }; } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_METHOD_RESULT_HPP diff --git a/common/ipc/result.hpp b/common/ipc/result.hpp index 0edf172..9069fd5 100644 --- a/common/ipc/result.hpp +++ b/common/ipc/result.hpp @@ -29,7 +29,6 @@ #include #include -namespace vasum { namespace ipc { template @@ -69,6 +68,5 @@ struct ResultHandler { }; } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_RESULT_HPP diff --git a/common/ipc/service.cpp b/common/ipc/service.cpp index d4e1b88..48d8c96 100644 --- a/common/ipc/service.cpp +++ b/common/ipc/service.cpp @@ -30,7 +30,6 @@ using namespace std::placeholders; -namespace vasum { namespace ipc { Service::Service(epoll::EventPoll& eventPoll, @@ -149,4 +148,3 @@ void Service::removeMethod(const MethodID methodID) } // namespace ipc -} // namespace vasum diff --git a/common/ipc/service.hpp b/common/ipc/service.hpp index 32b604f..8f6f62b 100644 --- a/common/ipc/service.hpp +++ b/common/ipc/service.hpp @@ -34,7 +34,6 @@ #include -namespace vasum { namespace ipc { @@ -220,6 +219,5 @@ void Service::signal(const MethodID methodID, } } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_SERVICE_HPP diff --git a/common/ipc/types.cpp b/common/ipc/types.cpp index 9854e0e..0961b35 100644 --- a/common/ipc/types.cpp +++ b/common/ipc/types.cpp @@ -29,7 +29,6 @@ #include -namespace vasum { namespace ipc { namespace { @@ -49,4 +48,3 @@ PeerID getNextPeerID() } // namespace ipc -} // namespace vasum diff --git a/common/ipc/types.hpp b/common/ipc/types.hpp index 3fec337..ab4ed00 100644 --- a/common/ipc/types.hpp +++ b/common/ipc/types.hpp @@ -29,7 +29,6 @@ #include #include -namespace vasum { namespace ipc { typedef int FileDescriptor; @@ -52,6 +51,5 @@ struct SignalHandler { }; } // namespace ipc -} // namespace vasum #endif // COMMON_IPC_TYPES_HPP diff --git a/common/netlink/netlink.cpp b/common/netlink/netlink.cpp index e5cf8a7..633276a 100644 --- a/common/netlink/netlink.cpp +++ b/common/netlink/netlink.cpp @@ -25,7 +25,7 @@ #include "config.hpp" #include "netlink.hpp" #include "utils.hpp" -#include "base-exception.hpp" +#include "utils/exception.hpp" #include "utils/make-clean.hpp" #include "utils/environment.hpp" @@ -40,6 +40,7 @@ #define PAGE_SIZE 4096 #endif +using namespace utils; using namespace vasum; namespace { diff --git a/common/utils/c-array.hpp b/common/utils/c-array.hpp index 68fa816..d238e4a 100644 --- a/common/utils/c-array.hpp +++ b/common/utils/c-array.hpp @@ -27,7 +27,6 @@ #include -namespace vasum { namespace utils { template @@ -67,7 +66,6 @@ private: typedef CArrayBuilder CStringArrayBuilder; } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_C_ARRAY_HPP diff --git a/common/utils/callback-guard.cpp b/common/utils/callback-guard.cpp index b0ce7dd..c3deca1 100644 --- a/common/utils/callback-guard.cpp +++ b/common/utils/callback-guard.cpp @@ -31,7 +31,6 @@ #include -namespace vasum { namespace utils { // Reference counting class like shared_ptr but with the ability to wait for it. @@ -127,4 +126,3 @@ bool CallbackGuard::waitForTrackers(const unsigned int timeoutMs) } } // namespace utils -} // namespace vasum diff --git a/common/utils/callback-guard.hpp b/common/utils/callback-guard.hpp index d28e707..7cb299b 100644 --- a/common/utils/callback-guard.hpp +++ b/common/utils/callback-guard.hpp @@ -29,7 +29,6 @@ #include -namespace vasum { namespace utils { /** @@ -73,7 +72,6 @@ private: }; } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_CALLBACK_GUARD_HPP diff --git a/common/utils/callback-wrapper.hpp b/common/utils/callback-wrapper.hpp index fd5a4c0..fbf8455 100644 --- a/common/utils/callback-wrapper.hpp +++ b/common/utils/callback-wrapper.hpp @@ -28,7 +28,6 @@ #include "callback-guard.hpp" -namespace vasum { namespace utils { @@ -86,7 +85,6 @@ const Callback& getCallbackFromPointer(const void* pointer) } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_CALLBACK_WRAPPER_HPP diff --git a/common/utils/counting-map.hpp b/common/utils/counting-map.hpp index da5f4c7..a05f76a 100644 --- a/common/utils/counting-map.hpp +++ b/common/utils/counting-map.hpp @@ -27,7 +27,6 @@ #include -namespace vasum { namespace utils { @@ -82,7 +81,6 @@ private: } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_COUNTING_MAP_HPP diff --git a/common/utils/environment.cpp b/common/utils/environment.cpp index 209f9ba..7bd7d07 100644 --- a/common/utils/environment.cpp +++ b/common/utils/environment.cpp @@ -26,6 +26,7 @@ #include "utils/environment.hpp" #include "utils/execute.hpp" +#include "utils/exception.hpp" #include "utils/make-clean.hpp" #include "base-exception.hpp" #include "logger/logger.hpp" @@ -60,7 +61,7 @@ static inline int setns(int fd, int nstype) #endif -using namespace vasum::utils; +using namespace utils; namespace { @@ -126,7 +127,6 @@ bool fdSend(int socket, int fd) } // namespace -namespace vasum { namespace utils { @@ -223,7 +223,7 @@ int passNemaspacedFd(int nsPid, int ns, const std::function& fdFactory) int fds[2]; int ret = socketpair(PF_LOCAL, SOCK_RAW, 0, fds); if (ret == -1) { - LOGE("Can't create socket pair: " << vasum::getSystemErrorMessage()); + LOGE("Can't create socket pair: " << getSystemErrorMessage()); return -1; } bool success = executeAndWait([&, fds, nsPid, ns]() { @@ -254,4 +254,3 @@ int passNemaspacedFd(int nsPid, int ns, const std::function& fdFactory) } } // namespace utils -} // namespace vasum diff --git a/common/utils/environment.hpp b/common/utils/environment.hpp index d63ac16..b4e3194 100644 --- a/common/utils/environment.hpp +++ b/common/utils/environment.hpp @@ -31,7 +31,6 @@ #include -namespace vasum { namespace utils { @@ -63,7 +62,6 @@ bool joinToNs(int nsPid, int ns); int passNemaspacedFd(int nsPid, int ns, const std::function& fdFactory); } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_ENVIRONMENT_HPP diff --git a/common/utils/eventfd.cpp b/common/utils/eventfd.cpp index d69d572..a1b45e9 100644 --- a/common/utils/eventfd.cpp +++ b/common/utils/eventfd.cpp @@ -34,7 +34,8 @@ #include #include -namespace vasum { +using namespace vasum; + namespace utils { EventFD::EventFD() @@ -71,4 +72,3 @@ void EventFD::receive() } // namespace utils -} // namespace vasum diff --git a/common/utils/eventfd.hpp b/common/utils/eventfd.hpp index b3d5027..f49bbff 100644 --- a/common/utils/eventfd.hpp +++ b/common/utils/eventfd.hpp @@ -25,7 +25,6 @@ #ifndef COMMON_UTILS_EVENTFD_HPP #define COMMON_UTILS_EVENTFD_HPP -namespace vasum { namespace utils { class EventFD { @@ -58,6 +57,5 @@ private: }; } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_EVENTFD_HPP diff --git a/common/base-exception.cpp b/common/utils/exception.cpp similarity index 89% rename from common/base-exception.cpp rename to common/utils/exception.cpp index 628296d..ae69618 100644 --- a/common/base-exception.cpp +++ b/common/utils/exception.cpp @@ -19,16 +19,16 @@ /** * @file * @author Mateusz Malicki (m.malicki2@samsung.com) - * @brief Vasum base exception implementation + * @brief Utils base exception helper implementation */ -#include "base-exception.hpp" +#include "utils/exception.hpp" #include #include #include -namespace vasum { +namespace utils { const int ERROR_MESSAGE_BUFFER_CAPACITY = 256; @@ -43,4 +43,4 @@ std::string getSystemErrorMessage(int err) return strerror_r(err, buf, sizeof(buf)); } -} // namespace vasum +} // namespace utils diff --git a/common/utils/exception.hpp b/common/utils/exception.hpp index 32f416c..49aceb8 100644 --- a/common/utils/exception.hpp +++ b/common/utils/exception.hpp @@ -29,18 +29,24 @@ #include "base-exception.hpp" -namespace vasum { +namespace utils { /** * Base class for exceptions in utils */ -struct UtilsException: public VasumException { +struct UtilsException: public vasum::VasumException { - UtilsException(const std::string& error) : VasumException(error) {} + UtilsException(const std::string& error) : vasum::VasumException(error) {} }; +/** + * Return string describing error number + * it is wrapper for strerror_r + */ +std::string getSystemErrorMessage(); +std::string getSystemErrorMessage(int err); -} // namespace vasum +} // namespace utils #endif // COMMON_UTILS_EXCEPTION_HPP diff --git a/common/utils/execute.cpp b/common/utils/execute.cpp index 4e8eebf..d030177 100644 --- a/common/utils/execute.cpp +++ b/common/utils/execute.cpp @@ -23,7 +23,7 @@ */ #include "config.hpp" -#include "base-exception.hpp" +#include "utils/exception.hpp" #include "utils/execute.hpp" #include "logger/logger.hpp" @@ -31,7 +31,6 @@ #include #include -namespace vasum { namespace utils { namespace { @@ -74,7 +73,7 @@ bool executeAndWait(const std::function& func, int& status) pid_t pid = fork(); if (pid == -1) { - LOGE("Fork failed: " << vasum::getSystemErrorMessage()); + LOGE("Fork failed: " << getSystemErrorMessage()); return false; } if (pid == 0) { @@ -128,4 +127,3 @@ bool waitPid(pid_t pid, int& status) } } // namespace utils -} // namespace vasum diff --git a/common/utils/execute.hpp b/common/utils/execute.hpp index 8f7fd56..bc5cf9d 100644 --- a/common/utils/execute.hpp +++ b/common/utils/execute.hpp @@ -28,7 +28,6 @@ #include #include -namespace vasum { namespace utils { /** @@ -55,7 +54,6 @@ bool executeAndWait(const std::function& func); bool waitPid(pid_t pid, int& status); } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_EXECUTE_HPP diff --git a/common/utils/fd-utils.cpp b/common/utils/fd-utils.cpp index 17448b5..95080ff 100644 --- a/common/utils/fd-utils.cpp +++ b/common/utils/fd-utils.cpp @@ -39,7 +39,8 @@ namespace fs = boost::filesystem; namespace chr = std::chrono; -namespace vasum { +using namespace vasum; + namespace utils { namespace { @@ -202,5 +203,4 @@ unsigned int getFDNumber() } } // namespace utils -} // namespace vasum diff --git a/common/utils/fd-utils.hpp b/common/utils/fd-utils.hpp index ac32b0a..151eb1c 100644 --- a/common/utils/fd-utils.hpp +++ b/common/utils/fd-utils.hpp @@ -27,7 +27,6 @@ #include -namespace vasum { namespace utils { /** @@ -73,6 +72,5 @@ void setMaxFDNumber(unsigned int limit); unsigned int getFDNumber(); } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_FD_HPP diff --git a/common/utils/file-wait.cpp b/common/utils/file-wait.cpp index f89ada6..4949314 100644 --- a/common/utils/file-wait.cpp +++ b/common/utils/file-wait.cpp @@ -30,8 +30,8 @@ #include #include +using namespace vasum; -namespace vasum { namespace utils { @@ -56,4 +56,3 @@ void waitForFile(const std::string& filename, const unsigned int timeoutMs) } // namespace utils -} // namespace vasum diff --git a/common/utils/file-wait.hpp b/common/utils/file-wait.hpp index 9029c6e..02b361e 100644 --- a/common/utils/file-wait.hpp +++ b/common/utils/file-wait.hpp @@ -28,7 +28,6 @@ #include -namespace vasum { namespace utils { @@ -38,7 +37,6 @@ void waitForFile(const std::string& filename, const unsigned int timeoutMs); } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_FILE_WAIT_HPP diff --git a/common/utils/fs.cpp b/common/utils/fs.cpp index e4dcd7f..5581a29 100644 --- a/common/utils/fs.cpp +++ b/common/utils/fs.cpp @@ -45,7 +45,8 @@ namespace fs = boost::filesystem; -namespace vasum { +using namespace vasum; + namespace utils { @@ -527,4 +528,3 @@ bool createLink(const std::string& src, const std::string& dest) } } // namespace utils -} // namespace vasum diff --git a/common/utils/fs.hpp b/common/utils/fs.hpp index b2e05b6..bff2e70 100644 --- a/common/utils/fs.hpp +++ b/common/utils/fs.hpp @@ -31,7 +31,6 @@ #include -namespace vasum { namespace utils { /** @@ -149,7 +148,6 @@ bool copyFile(const std::string& src, const std::string& dest); bool createLink(const std::string& src, const std::string& dest); } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_FS_HPP diff --git a/common/utils/glib-loop.cpp b/common/utils/glib-loop.cpp index dd82204..0ce15d9 100644 --- a/common/utils/glib-loop.cpp +++ b/common/utils/glib-loop.cpp @@ -30,7 +30,6 @@ #include #include -namespace vasum { namespace utils { namespace { @@ -85,4 +84,3 @@ gboolean Glib::onTimerEvent(gpointer data) } // namespace utils -} // namespace vasum diff --git a/common/utils/glib-loop.hpp b/common/utils/glib-loop.hpp index 8db43b6..0c5a459 100644 --- a/common/utils/glib-loop.hpp +++ b/common/utils/glib-loop.hpp @@ -32,7 +32,6 @@ #include -namespace vasum { namespace utils { @@ -81,7 +80,6 @@ private: }; } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_GLIB_LOOP_HPP diff --git a/common/utils/glib-utils.cpp b/common/utils/glib-utils.cpp index 93cbff9..fcd2f35 100644 --- a/common/utils/glib-utils.cpp +++ b/common/utils/glib-utils.cpp @@ -28,7 +28,6 @@ #include -namespace vasum { namespace utils { namespace { @@ -56,4 +55,3 @@ void executeInGlibThread(const VoidCallback& callback, const CallbackGuard& guar } // namespace utils -} // namespace vasum diff --git a/common/utils/glib-utils.hpp b/common/utils/glib-utils.hpp index eaeeee8..a818230 100644 --- a/common/utils/glib-utils.hpp +++ b/common/utils/glib-utils.hpp @@ -27,7 +27,6 @@ #include "utils/callback-guard.hpp" -namespace vasum { namespace utils { typedef std::function VoidCallback; @@ -39,6 +38,5 @@ void executeInGlibThread(const VoidCallback& callback, const CallbackGuard& guar } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_GLIB_UTILS_HPP diff --git a/common/utils/img.cpp b/common/utils/img.cpp index 785291c..20f6daf 100644 --- a/common/utils/img.cpp +++ b/common/utils/img.cpp @@ -27,13 +27,12 @@ #include "utils/img.hpp" #include "utils/fs.hpp" #include "utils/paths.hpp" -#include "base-exception.hpp" +#include "utils/exception.hpp" #include #include #include -namespace vasum { namespace utils { namespace { @@ -238,4 +237,3 @@ bool copyImageContents(const std::string& img, const std::string& dst) } } // namespace utils -} // namespace vasum diff --git a/common/utils/img.hpp b/common/utils/img.hpp index 8782ae2..de04fdc 100644 --- a/common/utils/img.hpp +++ b/common/utils/img.hpp @@ -25,7 +25,6 @@ #ifndef COMMON_UTILS_IMG_HPP #define COMMON_UTILS_IMG_HPP -namespace vasum { namespace utils { /** @@ -50,6 +49,5 @@ bool umountImage(const std::string& path, const std::string& loopdev); bool copyImageContents(const std::string& img, const std::string& dst); } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_IMG_HPP diff --git a/common/utils/initctl.cpp b/common/utils/initctl.cpp index 5986799..55e8cfd 100644 --- a/common/utils/initctl.cpp +++ b/common/utils/initctl.cpp @@ -30,7 +30,6 @@ #include #include -namespace vasum { namespace utils { namespace { @@ -87,4 +86,3 @@ bool setRunLevel(RunLevel runLevel) } // namespace utils -} // namespace vasum diff --git a/common/utils/initctl.hpp b/common/utils/initctl.hpp index 97f4ca4..d81c7bc 100644 --- a/common/utils/initctl.hpp +++ b/common/utils/initctl.hpp @@ -26,7 +26,6 @@ #define COMMON_UTILS_INITCTL_HPP -namespace vasum { namespace utils { enum RunLevel : int { @@ -38,7 +37,6 @@ bool setRunLevel(RunLevel runLevel); } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_INITCTL_HPP diff --git a/common/utils/latch.cpp b/common/utils/latch.cpp index e4b3649..4889946 100644 --- a/common/utils/latch.cpp +++ b/common/utils/latch.cpp @@ -28,7 +28,6 @@ #include -namespace vasum { namespace utils { @@ -81,4 +80,3 @@ bool Latch::empty() } // namespace utils -} // namespace vasum diff --git a/common/utils/latch.hpp b/common/utils/latch.hpp index 7ef1dd7..ad48475 100644 --- a/common/utils/latch.hpp +++ b/common/utils/latch.hpp @@ -29,7 +29,6 @@ #include -namespace vasum { namespace utils { @@ -89,7 +88,6 @@ private: } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_LATCH_HPP diff --git a/common/utils/make-clean.hpp b/common/utils/make-clean.hpp index 1d551ef..18fe6d7 100644 --- a/common/utils/make-clean.hpp +++ b/common/utils/make-clean.hpp @@ -28,7 +28,6 @@ #include #include -namespace vasum { namespace utils { template @@ -47,7 +46,6 @@ T make_clean() } } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_MAKE_CLEAN_HPP diff --git a/common/utils/paths.hpp b/common/utils/paths.hpp index b86333f..26ebde6 100644 --- a/common/utils/paths.hpp +++ b/common/utils/paths.hpp @@ -30,7 +30,6 @@ #include -namespace vasum { namespace utils { @@ -121,7 +120,6 @@ inline std::string getAbsolutePath(const std::string& path, const std::string& b } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_PATHS_HPP diff --git a/common/utils/same-thread-guard.cpp b/common/utils/same-thread-guard.cpp index 5b54c73..65621d4 100644 --- a/common/utils/same-thread-guard.cpp +++ b/common/utils/same-thread-guard.cpp @@ -30,7 +30,6 @@ #include "logger/logger.hpp" #include "logger/formatter.hpp" -namespace vasum { namespace utils { namespace { @@ -70,6 +69,5 @@ void SameThreadGuard::reset() } } // namespace utils -} // namespace vasum #endif // ENABLE_SAME_THREAD_GUARD diff --git a/common/utils/same-thread-guard.hpp b/common/utils/same-thread-guard.hpp index fd697fd..3a173b5 100644 --- a/common/utils/same-thread-guard.hpp +++ b/common/utils/same-thread-guard.hpp @@ -34,7 +34,6 @@ #include #endif -namespace vasum { namespace utils { /** @@ -74,7 +73,6 @@ private: }; } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_SAME_THREAD_GUARD_HPP diff --git a/common/utils/scoped-gerror.cpp b/common/utils/scoped-gerror.cpp index 0e4de47..92e0dd2 100644 --- a/common/utils/scoped-gerror.cpp +++ b/common/utils/scoped-gerror.cpp @@ -26,7 +26,6 @@ #include "scoped-gerror.hpp" -namespace vasum { namespace utils { ScopedGError::ScopedGError() @@ -74,4 +73,3 @@ std::ostream& operator<<(std::ostream& os, const ScopedGError& e) } } // namespace utils -} // namespace vasum diff --git a/common/utils/scoped-gerror.hpp b/common/utils/scoped-gerror.hpp index 0ee4c64..5d3bcc7 100644 --- a/common/utils/scoped-gerror.hpp +++ b/common/utils/scoped-gerror.hpp @@ -28,7 +28,6 @@ #include #include -namespace vasum{ namespace utils { class ScopedGError { @@ -73,6 +72,5 @@ private: }; } // namespace utils -} // namespace vasum #endif // COMMON_SCOPED_GERROR_HPP diff --git a/common/utils/signal.cpp b/common/utils/signal.cpp index 11ea8f2..2daa766 100644 --- a/common/utils/signal.cpp +++ b/common/utils/signal.cpp @@ -31,7 +31,6 @@ #include #include -namespace vasum { namespace utils { void signalBlock(const int signalToBlock) @@ -57,7 +56,6 @@ void signalBlock(const int signalToBlock) } } // namespace utils -} // namespace vasum diff --git a/common/utils/signal.hpp b/common/utils/signal.hpp index f26e365..c466688 100644 --- a/common/utils/signal.hpp +++ b/common/utils/signal.hpp @@ -25,13 +25,11 @@ #ifndef COMMON_UTILS_SIGNAL_HPP #define COMMON_UTILS_SIGNAL_HPP -namespace vasum { namespace utils { void signalBlock(const int signalsToBlock); } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_SIGNAL_HPP diff --git a/common/utils/typeinfo.cpp b/common/utils/typeinfo.cpp index 0f7e574..e97aa35 100644 --- a/common/utils/typeinfo.cpp +++ b/common/utils/typeinfo.cpp @@ -29,7 +29,6 @@ #include #include -namespace vasum { namespace utils { std::string getTypeName(const std::type_info& ti) @@ -47,4 +46,3 @@ std::string getTypeName(const std::type_info& ti) } } // namespace utils -} // namespace vasum diff --git a/common/utils/typeinfo.hpp b/common/utils/typeinfo.hpp index 9faf0cb..f1c83a0 100644 --- a/common/utils/typeinfo.hpp +++ b/common/utils/typeinfo.hpp @@ -28,7 +28,6 @@ #include #include -namespace vasum { namespace utils { std::string getTypeName(const std::type_info& ti); @@ -39,7 +38,6 @@ template std::string getTypeName(const T& t) } } // namespace utils -} // namespace vasum #endif // COMMON_TYPE_INFO_HPP diff --git a/common/utils/value-latch.hpp b/common/utils/value-latch.hpp index 0e06f6f..74fc738 100644 --- a/common/utils/value-latch.hpp +++ b/common/utils/value-latch.hpp @@ -31,7 +31,6 @@ #include #include -namespace vasum { namespace utils { template @@ -121,6 +120,5 @@ T ValueLatch::get(const unsigned int timeoutMs) } } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_VALUE_LATCH_H diff --git a/common/utils/vt.cpp b/common/utils/vt.cpp index 44461e4..373a949 100644 --- a/common/utils/vt.cpp +++ b/common/utils/vt.cpp @@ -25,7 +25,7 @@ #include "config.hpp" #include "utils/vt.hpp" #include "logger/logger.hpp" -#include "base-exception.hpp" +#include "utils/exception.hpp" #include #include @@ -40,7 +40,6 @@ const std::string TTY_DEV = "/dev/tty0"; } // namespace -namespace vasum { namespace utils { bool activateVT(const int& vt) @@ -84,4 +83,3 @@ bool activateVT(const int& vt) } } // namespace utils -} // namespace vasum diff --git a/common/utils/vt.hpp b/common/utils/vt.hpp index 16f4030..a28261c 100644 --- a/common/utils/vt.hpp +++ b/common/utils/vt.hpp @@ -25,12 +25,10 @@ #ifndef COMMON_UTILS_VT_HPP #define COMMON_UTILS_VT_HPP -namespace vasum { namespace utils { bool activateVT(const int& vt); } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_VT_HPP diff --git a/common/utils/worker.cpp b/common/utils/worker.cpp index 2cb3284..7e87d33 100644 --- a/common/utils/worker.cpp +++ b/common/utils/worker.cpp @@ -35,7 +35,6 @@ #include -namespace vasum { namespace utils { @@ -183,4 +182,3 @@ void Worker::addTask(const Task& task) } // namespace utils -} // namespace vasum diff --git a/common/utils/worker.hpp b/common/utils/worker.hpp index 0d951fb..677f218 100644 --- a/common/utils/worker.hpp +++ b/common/utils/worker.hpp @@ -28,7 +28,6 @@ #include #include -namespace vasum { namespace utils { /** @@ -68,7 +67,6 @@ private: }; } // namespace utils -} // namespace vasum #endif // COMMON_UTILS_WORKER_HPP diff --git a/libs/dbus/connection.cpp b/libs/dbus/connection.cpp index 3485ea5..60b3225 100644 --- a/libs/dbus/connection.cpp +++ b/libs/dbus/connection.cpp @@ -30,7 +30,7 @@ #include "utils/glib-utils.hpp" #include "logger/logger.hpp" -using namespace vasum::utils; +using namespace utils; namespace dbus { diff --git a/libs/dbus/connection.hpp b/libs/dbus/connection.hpp index faf737c..5248d2e 100644 --- a/libs/dbus/connection.hpp +++ b/libs/dbus/connection.hpp @@ -181,7 +181,7 @@ private: : nameAcquired(acquired), nameLost(lost) {} }; - vasum::utils::CallbackGuard mGuard; + utils::CallbackGuard mGuard; GDBusConnection* mConnection; guint mNameId; diff --git a/server/host-ipc-connection.hpp b/server/host-ipc-connection.hpp index d5144fd..b5d671e 100644 --- a/server/host-ipc-connection.hpp +++ b/server/host-ipc-connection.hpp @@ -27,7 +27,7 @@ #define SERVER_HOST_IPC_CONNECTION_HPP #include "api/messages.hpp" -#include "epoll/thread-dispatcher.hpp" +#include "ipc/epoll/thread-dispatcher.hpp" #include "ipc/service.hpp" #include "ipc-callback-wrapper.hpp" @@ -84,7 +84,7 @@ public: void sendNotification(const api::Notification& notification); private: - epoll::ThreadDispatcher mDispatcher; + ipc::epoll::ThreadDispatcher mDispatcher; std::unique_ptr mService; }; diff --git a/server/host-ipc-definitions.hpp b/server/host-ipc-definitions.hpp index a54b679..0053efa 100644 --- a/server/host-ipc-definitions.hpp +++ b/server/host-ipc-definitions.hpp @@ -31,36 +31,36 @@ namespace vasum { namespace api { namespace ipc { -const vasum::ipc::MethodID METHOD_GET_ZONE_ID_LIST = 2; -const vasum::ipc::MethodID METHOD_GET_ACTIVE_ZONE_ID = 3; -const vasum::ipc::MethodID METHOD_GET_ZONE_INFO = 4; -const vasum::ipc::MethodID METHOD_SET_NETDEV_ATTRS = 5; -const vasum::ipc::MethodID METHOD_GET_NETDEV_ATTRS = 6; -const vasum::ipc::MethodID METHOD_GET_NETDEV_LIST = 7; -const vasum::ipc::MethodID METHOD_CREATE_NETDEV_VETH = 8; -const vasum::ipc::MethodID METHOD_CREATE_NETDEV_MACVLAN = 9; -const vasum::ipc::MethodID METHOD_CREATE_NETDEV_PHYS = 10; -const vasum::ipc::MethodID METHOD_DELETE_NETDEV_IP_ADDRESS = 11; -const vasum::ipc::MethodID METHOD_DESTROY_NETDEV = 12; -const vasum::ipc::MethodID METHOD_DECLARE_FILE = 13; -const vasum::ipc::MethodID METHOD_DECLARE_MOUNT = 14; -const vasum::ipc::MethodID METHOD_DECLARE_LINK = 15; -const vasum::ipc::MethodID METHOD_GET_DECLARATIONS = 16; -const vasum::ipc::MethodID METHOD_REMOVE_DECLARATION = 17; -const vasum::ipc::MethodID METHOD_SET_ACTIVE_ZONE = 18; -const vasum::ipc::MethodID METHOD_CREATE_ZONE = 19; -const vasum::ipc::MethodID METHOD_DESTROY_ZONE = 20; -const vasum::ipc::MethodID METHOD_SHUTDOWN_ZONE = 21; -const vasum::ipc::MethodID METHOD_START_ZONE = 22; -const vasum::ipc::MethodID METHOD_LOCK_ZONE = 23; -const vasum::ipc::MethodID METHOD_UNLOCK_ZONE = 24; -const vasum::ipc::MethodID METHOD_GRANT_DEVICE = 25; -const vasum::ipc::MethodID METHOD_REVOKE_DEVICE = 26; +const ::ipc::MethodID METHOD_GET_ZONE_ID_LIST = 2; +const ::ipc::MethodID METHOD_GET_ACTIVE_ZONE_ID = 3; +const ::ipc::MethodID METHOD_GET_ZONE_INFO = 4; +const ::ipc::MethodID METHOD_SET_NETDEV_ATTRS = 5; +const ::ipc::MethodID METHOD_GET_NETDEV_ATTRS = 6; +const ::ipc::MethodID METHOD_GET_NETDEV_LIST = 7; +const ::ipc::MethodID METHOD_CREATE_NETDEV_VETH = 8; +const ::ipc::MethodID METHOD_CREATE_NETDEV_MACVLAN = 9; +const ::ipc::MethodID METHOD_CREATE_NETDEV_PHYS = 10; +const ::ipc::MethodID METHOD_DELETE_NETDEV_IP_ADDRESS = 11; +const ::ipc::MethodID METHOD_DESTROY_NETDEV = 12; +const ::ipc::MethodID METHOD_DECLARE_FILE = 13; +const ::ipc::MethodID METHOD_DECLARE_MOUNT = 14; +const ::ipc::MethodID METHOD_DECLARE_LINK = 15; +const ::ipc::MethodID METHOD_GET_DECLARATIONS = 16; +const ::ipc::MethodID METHOD_REMOVE_DECLARATION = 17; +const ::ipc::MethodID METHOD_SET_ACTIVE_ZONE = 18; +const ::ipc::MethodID METHOD_CREATE_ZONE = 19; +const ::ipc::MethodID METHOD_DESTROY_ZONE = 20; +const ::ipc::MethodID METHOD_SHUTDOWN_ZONE = 21; +const ::ipc::MethodID METHOD_START_ZONE = 22; +const ::ipc::MethodID METHOD_LOCK_ZONE = 23; +const ::ipc::MethodID METHOD_UNLOCK_ZONE = 24; +const ::ipc::MethodID METHOD_GRANT_DEVICE = 25; +const ::ipc::MethodID METHOD_REVOKE_DEVICE = 26; -const vasum::ipc::MethodID METHOD_NOTIFY_ACTIVE_ZONE = 100; -const vasum::ipc::MethodID METHOD_FILE_MOVE_REQUEST = 101; -const vasum::ipc::MethodID SIGNAL_NOTIFICATION = 102; -const vasum::ipc::MethodID SIGNAL_SWITCH_TO_DEFAULT = 103; +const ::ipc::MethodID METHOD_NOTIFY_ACTIVE_ZONE = 100; +const ::ipc::MethodID METHOD_FILE_MOVE_REQUEST = 101; +const ::ipc::MethodID SIGNAL_NOTIFICATION = 102; +const ::ipc::MethodID SIGNAL_SWITCH_TO_DEFAULT = 103; const std::string FILE_MOVE_DESTINATION_NOT_FOUND = "FILE_MOVE_DESTINATION_NOT_FOUND"; const std::string FILE_MOVE_WRONG_DESTINATION = "FILE_MOVE_WRONG_DESTINATION"; diff --git a/server/input-monitor.cpp b/server/input-monitor.cpp index 68e63c0..e99906f 100644 --- a/server/input-monitor.cpp +++ b/server/input-monitor.cpp @@ -49,7 +49,7 @@ #include #include -using namespace vasum::utils; +using namespace utils; namespace fs = boost::filesystem; namespace vasum { diff --git a/server/netdev.cpp b/server/netdev.cpp index 38ccb88..b9a1389 100644 --- a/server/netdev.cpp +++ b/server/netdev.cpp @@ -26,6 +26,7 @@ #include "netdev.hpp" #include "netlink/netlink-message.hpp" #include "utils/make-clean.hpp" +#include "utils/exception.hpp" #include "utils.hpp" #include "exception.hpp" @@ -64,7 +65,7 @@ #endif using namespace std; -using namespace vasum; +using namespace utils; using namespace vasum::netlink; namespace vasum { diff --git a/server/server.cpp b/server/server.cpp index ab8cba3..95f22a0 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -34,6 +34,7 @@ #include "utils/environment.hpp" #include "utils/fs.hpp" #include "utils/signal.hpp" +#include "utils/exception.hpp" #include #include @@ -65,6 +66,8 @@ extern char** environ; +using namespace utils; + namespace vasum { diff --git a/server/zone-provision.cpp b/server/zone-provision.cpp index 1c542f7..70c3711 100644 --- a/server/zone-provision.cpp +++ b/server/zone-provision.cpp @@ -41,6 +41,8 @@ namespace fs = boost::filesystem; +using namespace utils; + namespace vasum { ZoneProvision::ZoneProvision(const std::string& rootPath, diff --git a/tests/unit_tests/client/ut-client.cpp b/tests/unit_tests/client/ut-client.cpp index adc325e..a43319c 100644 --- a/tests/unit_tests/client/ut-client.cpp +++ b/tests/unit_tests/client/ut-client.cpp @@ -46,7 +46,7 @@ #include using namespace vasum; -using namespace vasum::utils; +using namespace utils; namespace { diff --git a/tests/unit_tests/config/ut-configuration.cpp b/tests/unit_tests/config/ut-configuration.cpp index 1334966..88b6a4e 100644 --- a/tests/unit_tests/config/ut-configuration.cpp +++ b/tests/unit_tests/config/ut-configuration.cpp @@ -34,6 +34,7 @@ namespace { +using namespace utils; using namespace config; const std::string UT_PATH = "/tmp/ut-config/"; @@ -44,7 +45,7 @@ const std::string DB_PREFIX = "ut"; const int TOLERANCE = 1; struct Fixture { - vasum::utils::ScopedDir mUTDirGuard; + ScopedDir mUTDirGuard; Fixture() : mUTDirGuard(UT_PATH) {} }; diff --git a/tests/unit_tests/config/ut-dynvisit.cpp b/tests/unit_tests/config/ut-dynvisit.cpp index 2050def..bbe45e0 100644 --- a/tests/unit_tests/config/ut-dynvisit.cpp +++ b/tests/unit_tests/config/ut-dynvisit.cpp @@ -33,12 +33,13 @@ namespace { +using namespace utils; using namespace config; const std::string UT_PATH = "/tmp/ut-config/"; struct Fixture { - vasum::utils::ScopedDir mUTDirGuard; + ScopedDir mUTDirGuard; std::string dbPath; std::string dbPrefix; diff --git a/tests/unit_tests/config/ut-kvstore.cpp b/tests/unit_tests/config/ut-kvstore.cpp index 239f568..13691c7 100644 --- a/tests/unit_tests/config/ut-kvstore.cpp +++ b/tests/unit_tests/config/ut-kvstore.cpp @@ -37,7 +37,7 @@ #include using namespace config; -using namespace vasum::utils; +using namespace utils; namespace fs = boost::filesystem; namespace { @@ -45,7 +45,7 @@ namespace { const std::string UT_PATH = "/tmp/ut-config/"; struct Fixture { - vasum::utils::ScopedDir mUTDirGuard; + ScopedDir mUTDirGuard; std::string dbPath; KVStore c; diff --git a/tests/unit_tests/dbus/ut-connection.cpp b/tests/unit_tests/dbus/ut-connection.cpp index 84ea626..b427355 100644 --- a/tests/unit_tests/dbus/ut-connection.cpp +++ b/tests/unit_tests/dbus/ut-connection.cpp @@ -46,8 +46,8 @@ BOOST_AUTO_TEST_SUITE(DbusSuite) +using namespace utils; using namespace vasum; -using namespace vasum::utils; using namespace dbus; namespace { diff --git a/tests/unit_tests/epoll/ut-event-poll.cpp b/tests/unit_tests/epoll/ut-event-poll.cpp index 3a26b5e..819e959 100644 --- a/tests/unit_tests/epoll/ut-event-poll.cpp +++ b/tests/unit_tests/epoll/ut-event-poll.cpp @@ -26,18 +26,18 @@ #include "config.hpp" #include "ut.hpp" -#include "epoll/event-poll.hpp" +#include "ipc/epoll/event-poll.hpp" #include "logger/logger.hpp" #include "ipc/internals/socket.hpp" #include "utils/value-latch.hpp" #include "utils/glib-loop.hpp" -#include "epoll/glib-dispatcher.hpp" -#include "epoll/thread-dispatcher.hpp" +#include "ipc/epoll/glib-dispatcher.hpp" +#include "ipc/epoll/thread-dispatcher.hpp" using namespace vasum; -using namespace vasum::utils; -using namespace vasum::epoll; -using namespace vasum::ipc; +using namespace utils; +using namespace ipc; +using namespace ipc::epoll; namespace { diff --git a/tests/unit_tests/ipc/ut-ipc.cpp b/tests/unit_tests/ipc/ut-ipc.cpp index 6f2765b..b5edbf7 100644 --- a/tests/unit_tests/ipc/ut-ipc.cpp +++ b/tests/unit_tests/ipc/ut-ipc.cpp @@ -34,8 +34,8 @@ #include "ipc/client.hpp" #include "ipc/types.hpp" #include "ipc/result.hpp" -#include "epoll/thread-dispatcher.hpp" -#include "epoll/glib-dispatcher.hpp" +#include "ipc/epoll/thread-dispatcher.hpp" +#include "ipc/epoll/glib-dispatcher.hpp" #include "utils/glib-loop.hpp" #include "utils/latch.hpp" #include "utils/value-latch.hpp" @@ -52,9 +52,9 @@ #include using namespace vasum; -using namespace vasum::ipc; -using namespace vasum::epoll; -using namespace vasum::utils; +using namespace ipc; +using namespace epoll; +using namespace utils; using namespace std::placeholders; // Timeout for sending one message diff --git a/tests/unit_tests/ipc/ut-socket.cpp b/tests/unit_tests/ipc/ut-socket.cpp index 6f78f90..c2577ee 100644 --- a/tests/unit_tests/ipc/ut-socket.cpp +++ b/tests/unit_tests/ipc/ut-socket.cpp @@ -29,7 +29,7 @@ #include -using namespace vasum::ipc; +using namespace ipc; BOOST_AUTO_TEST_SUITE(SocketSuite) diff --git a/tests/unit_tests/server/ut-input-monitor.cpp b/tests/unit_tests/server/ut-input-monitor.cpp index 454a307..22fba47 100644 --- a/tests/unit_tests/server/ut-input-monitor.cpp +++ b/tests/unit_tests/server/ut-input-monitor.cpp @@ -46,7 +46,7 @@ using namespace vasum; -using namespace vasum::utils; +using namespace utils; namespace { diff --git a/tests/unit_tests/server/ut-server.cpp b/tests/unit_tests/server/ut-server.cpp index 8466f19..600b271 100644 --- a/tests/unit_tests/server/ut-server.cpp +++ b/tests/unit_tests/server/ut-server.cpp @@ -37,6 +37,11 @@ #include #include +using namespace utils; +using namespace vasum; +using namespace config; + + namespace { const std::string CONFIG_DIR = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-server"; @@ -48,7 +53,7 @@ const std::string ZONES_PATH = "/tmp/ut-zones"; // the same as in daemon.conf const bool AS_ROOT = true; struct Fixture { - vasum::utils::ScopedDir mZonesPathGuard; + utils::ScopedDir mZonesPathGuard; Fixture() : mZonesPathGuard(ZONES_PATH) @@ -59,8 +64,8 @@ struct Fixture { void prepare() { - vasum::utils::ScopedGlibLoop loop; - vasum::ZonesManager manager(TEST_CONFIG_PATH); + ScopedGlibLoop loop; + ZonesManager manager(TEST_CONFIG_PATH); manager.createZone("zone1", TEMPLATE_NAME); manager.createZone("zone2", TEMPLATE_NAME); manager.restoreAll(); @@ -70,9 +75,6 @@ struct Fixture { BOOST_FIXTURE_TEST_SUITE(ServerSuite, Fixture) -using namespace vasum; -using namespace config; - BOOST_AUTO_TEST_CASE(ConstructorDestructor) { std::unique_ptr s; diff --git a/tests/unit_tests/server/ut-zone-provision.cpp b/tests/unit_tests/server/ut-zone-provision.cpp index d6a5955..65a5b91 100644 --- a/tests/unit_tests/server/ut-zone-provision.cpp +++ b/tests/unit_tests/server/ut-zone-provision.cpp @@ -42,6 +42,7 @@ #include using namespace vasum; +using namespace utils; using namespace config; namespace fs = boost::filesystem; diff --git a/tests/unit_tests/server/ut-zone.cpp b/tests/unit_tests/server/ut-zone.cpp index 2aed285..755aa52 100644 --- a/tests/unit_tests/server/ut-zone.cpp +++ b/tests/unit_tests/server/ut-zone.cpp @@ -45,6 +45,7 @@ #include #include +using namespace utils; using namespace vasum; using namespace vasum::netdev; using namespace config; @@ -63,9 +64,9 @@ const std::string BRIDGE_NAME = "brtest01"; const std::string ZONE_NETDEV = "netdevtest01"; struct Fixture { - utils::ScopedGlibLoop mLoop; - utils::ScopedDir mZonesPathGuard; - utils::ScopedDir mRunGuard; + ScopedGlibLoop mLoop; + ScopedDir mZonesPathGuard; + ScopedDir mRunGuard; std::string mBridgeName; Fixture() diff --git a/tests/unit_tests/server/ut-zones-manager.cpp b/tests/unit_tests/server/ut-zones-manager.cpp index e052117..f7a4351 100644 --- a/tests/unit_tests/server/ut-zones-manager.cpp +++ b/tests/unit_tests/server/ut-zones-manager.cpp @@ -37,7 +37,7 @@ #endif //DBUS_CONNECTION #include "host-ipc-definitions.hpp" #include -#include +#include #include #include "exception.hpp" @@ -61,7 +61,7 @@ using namespace vasum; using namespace config; -using namespace vasum::utils; +using namespace utils; #ifdef DBUS_CONNECTION using namespace dbus; #endif //DBUS_CONNECTION @@ -599,7 +599,7 @@ public: } private: - epoll::ThreadDispatcher mDispatcher; + ipc::epoll::ThreadDispatcher mDispatcher; ipc::Client mClient; }; @@ -619,10 +619,10 @@ bool spinWaitFor(int timeoutMs, Predicate pred) } // namespace struct Fixture { - vasum::utils::ScopedGlibLoop mLoop; + ScopedGlibLoop mLoop; - utils::ScopedDir mZonesPathGuard; - utils::ScopedDir mRunGuard; + ScopedDir mZonesPathGuard; + ScopedDir mRunGuard; Fixture() : mZonesPathGuard(ZONES_PATH) diff --git a/tests/unit_tests/socket_test_service/socket-test.cpp b/tests/unit_tests/socket_test_service/socket-test.cpp index 2f163af..1ffc09e 100644 --- a/tests/unit_tests/socket_test_service/socket-test.cpp +++ b/tests/unit_tests/socket_test_service/socket-test.cpp @@ -36,7 +36,7 @@ #include using namespace vasum::socket_test; -using namespace vasum::ipc; +using namespace ipc; using namespace logger; // NOTE this is a single-usage program, only meant to test vasum::ipc::Socket module. diff --git a/tests/unit_tests/utils/scoped-daemon.cpp b/tests/unit_tests/utils/scoped-daemon.cpp index 19f252c..6dbe93f 100644 --- a/tests/unit_tests/utils/scoped-daemon.cpp +++ b/tests/unit_tests/utils/scoped-daemon.cpp @@ -35,7 +35,6 @@ #include -namespace vasum { namespace utils { @@ -179,4 +178,3 @@ void ScopedDaemon::stop() } // namespace utils -} // namespace vasum diff --git a/tests/unit_tests/utils/scoped-daemon.hpp b/tests/unit_tests/utils/scoped-daemon.hpp index 7d67c00..d263b4d 100644 --- a/tests/unit_tests/utils/scoped-daemon.hpp +++ b/tests/unit_tests/utils/scoped-daemon.hpp @@ -28,7 +28,6 @@ #include -namespace vasum { namespace utils { @@ -62,7 +61,6 @@ private: } // namespace utils -} // namespace vasum #endif // UNIT_TESTS_UTILS_SCOPED_DAEMON_HPP diff --git a/tests/unit_tests/utils/scoped-dir.cpp b/tests/unit_tests/utils/scoped-dir.cpp index 48b354b..ddec9b6 100644 --- a/tests/unit_tests/utils/scoped-dir.cpp +++ b/tests/unit_tests/utils/scoped-dir.cpp @@ -29,7 +29,6 @@ #include -namespace vasum { namespace utils { namespace fs = boost::filesystem; @@ -67,4 +66,3 @@ void ScopedDir::remove() } } // namespace utils -} // namespace vasum diff --git a/tests/unit_tests/utils/scoped-dir.hpp b/tests/unit_tests/utils/scoped-dir.hpp index c42dbe7..625954e 100644 --- a/tests/unit_tests/utils/scoped-dir.hpp +++ b/tests/unit_tests/utils/scoped-dir.hpp @@ -28,7 +28,6 @@ #include -namespace vasum { namespace utils { @@ -58,7 +57,6 @@ private: } // namespace utils -} // namespace vasum #endif // UNIT_TESTS_UTILS_SCOPED_DIR_HPP diff --git a/tests/unit_tests/utils/ut-callback-guard.cpp b/tests/unit_tests/utils/ut-callback-guard.cpp index 524c7d5..557d8f0 100644 --- a/tests/unit_tests/utils/ut-callback-guard.cpp +++ b/tests/unit_tests/utils/ut-callback-guard.cpp @@ -32,10 +32,9 @@ #include #include - BOOST_AUTO_TEST_SUITE(CallbackGuardSuite) -using namespace vasum::utils; +using namespace utils; const int unsigned TIMEOUT = 1000; diff --git a/tests/unit_tests/utils/ut-counting-map.cpp b/tests/unit_tests/utils/ut-counting-map.cpp index 04832db..55a0a55 100644 --- a/tests/unit_tests/utils/ut-counting-map.cpp +++ b/tests/unit_tests/utils/ut-counting-map.cpp @@ -30,7 +30,7 @@ BOOST_AUTO_TEST_SUITE(CountingMapSuite) -using namespace vasum::utils; +using namespace utils; BOOST_AUTO_TEST_CASE(Counting) { diff --git a/tests/unit_tests/utils/ut-fs.cpp b/tests/unit_tests/utils/ut-fs.cpp index cbbe14b..2cc32d0 100644 --- a/tests/unit_tests/utils/ut-fs.cpp +++ b/tests/unit_tests/utils/ut-fs.cpp @@ -34,8 +34,7 @@ #include #include -using namespace vasum; -using namespace vasum::utils; +using namespace utils; namespace { diff --git a/tests/unit_tests/utils/ut-glib-loop.cpp b/tests/unit_tests/utils/ut-glib-loop.cpp index 467fbfb..fb0292e 100644 --- a/tests/unit_tests/utils/ut-glib-loop.cpp +++ b/tests/unit_tests/utils/ut-glib-loop.cpp @@ -32,8 +32,7 @@ BOOST_AUTO_TEST_SUITE(GlibLoopSuite) -using namespace vasum; -using namespace vasum::utils; +using namespace utils; namespace { diff --git a/tests/unit_tests/utils/ut-paths.cpp b/tests/unit_tests/utils/ut-paths.cpp index e14da13..00120e8 100644 --- a/tests/unit_tests/utils/ut-paths.cpp +++ b/tests/unit_tests/utils/ut-paths.cpp @@ -32,7 +32,7 @@ BOOST_AUTO_TEST_SUITE(UtilsPathsSuite) -using namespace vasum::utils; +using namespace utils; BOOST_AUTO_TEST_CASE(CreateFilePath) { diff --git a/tests/unit_tests/utils/ut-same-thread-guard.cpp b/tests/unit_tests/utils/ut-same-thread-guard.cpp index 463c07d..f2ec471 100644 --- a/tests/unit_tests/utils/ut-same-thread-guard.cpp +++ b/tests/unit_tests/utils/ut-same-thread-guard.cpp @@ -33,7 +33,7 @@ BOOST_AUTO_TEST_SUITE(SameThreadGuardSuite) -using namespace vasum::utils; +using namespace utils; BOOST_AUTO_TEST_CASE(Simple) { diff --git a/tests/unit_tests/utils/ut-value-latch.cpp b/tests/unit_tests/utils/ut-value-latch.cpp index 2b09967..aa5b3a0 100644 --- a/tests/unit_tests/utils/ut-value-latch.cpp +++ b/tests/unit_tests/utils/ut-value-latch.cpp @@ -33,7 +33,7 @@ BOOST_AUTO_TEST_SUITE(ValueLatchSuite) -using namespace vasum::utils; +using namespace utils; namespace { @@ -106,7 +106,7 @@ BOOST_AUTO_TEST_CASE(Timeout) ValueLatch testLatch; BOOST_REQUIRE_EXCEPTION(testLatch.get(EXPECTED_TIMEOUT), - vasum::UtilsException, + UtilsException, WhatEquals("Timeout occured")); } @@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE(MultipleSet) testLatch.set(3); BOOST_REQUIRE_EXCEPTION(testLatch.set(2), - vasum::UtilsException, + UtilsException, WhatEquals("Cannot set value multiple times")); } @@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(MultipleGet) testLatch.set(3); testLatch.get(TIMEOUT); BOOST_REQUIRE_EXCEPTION(testLatch.get(EXPECTED_TIMEOUT), - vasum::UtilsException, + UtilsException, WhatEquals("Timeout occured")); } diff --git a/tests/unit_tests/utils/ut-worker.cpp b/tests/unit_tests/utils/ut-worker.cpp index da2a96d..52c14fd 100644 --- a/tests/unit_tests/utils/ut-worker.cpp +++ b/tests/unit_tests/utils/ut-worker.cpp @@ -33,9 +33,9 @@ #include #include -BOOST_AUTO_TEST_SUITE(WorkerSuite) +using namespace utils; -using namespace vasum::utils; +BOOST_AUTO_TEST_SUITE(WorkerSuite) const int unsigned TIMEOUT = 1000; -- 2.7.4 From fbdc75348bf89310c30e862db8aec803b8309cc5 Mon Sep 17 00:00:00 2001 From: Mateusz Malicki Date: Thu, 14 May 2015 14:32:52 +0200 Subject: [PATCH 03/16] libIpc separated from vasum #2/2 [Feature] libIpc separated from vasum; [Cause] N/A [Solution] Some header files from utils are copied to libIpc-devel rpm package (they can conflict with libSimpleDbus-devel header files) [Verification] Build, install, run tests Change-Id: Ic89a6e1d2a7a4cbb48112eef226b11cd10eb7987 --- CMakeLists.txt | 2 + cli/CMakeLists.txt | 2 +- client/CMakeLists.txt | 8 +-- common/netlink/netlink.cpp | 1 + common/utils/eventfd.cpp | 2 - common/utils/exception.hpp | 7 +- common/utils/fd-utils.cpp | 2 - common/utils/file-wait.cpp | 2 - common/utils/fs.cpp | 2 - libs/ipc/CMakeLists.txt | 78 ++++++++++++++++++++++ {common => libs}/ipc/client.cpp | 0 {common => libs}/ipc/client.hpp | 0 {common => libs}/ipc/epoll/event-poll.cpp | 1 - {common => libs}/ipc/epoll/event-poll.hpp | 0 {common => libs}/ipc/epoll/events.cpp | 0 {common => libs}/ipc/epoll/events.hpp | 0 {common => libs}/ipc/epoll/glib-dispatcher.cpp | 0 {common => libs}/ipc/epoll/glib-dispatcher.hpp | 0 {common => libs}/ipc/epoll/thread-dispatcher.cpp | 0 {common => libs}/ipc/epoll/thread-dispatcher.hpp | 0 {common => libs}/ipc/exception.hpp | 6 +- {common => libs}/ipc/internals/acceptor.cpp | 0 {common => libs}/ipc/internals/acceptor.hpp | 0 .../ipc/internals/add-peer-request.hpp | 0 {common => libs}/ipc/internals/event-queue.hpp | 0 {common => libs}/ipc/internals/finish-request.hpp | 0 {common => libs}/ipc/internals/method-request.hpp | 0 {common => libs}/ipc/internals/processor.cpp | 0 {common => libs}/ipc/internals/processor.hpp | 0 .../ipc/internals/remove-peer-request.hpp | 0 {common => libs}/ipc/internals/request-queue.hpp | 0 {common => libs}/ipc/internals/result-builder.hpp | 0 .../ipc/internals/send-result-request.hpp | 0 {common => libs}/ipc/internals/signal-request.hpp | 0 {common => libs}/ipc/internals/socket.cpp | 0 {common => libs}/ipc/internals/socket.hpp | 0 {common => libs}/ipc/ipc-gsource.cpp | 0 {common => libs}/ipc/ipc-gsource.hpp | 0 libs/ipc/libIpc.pc.in | 13 ++++ {common => libs}/ipc/method-result.cpp | 0 {common => libs}/ipc/method-result.hpp | 0 {common => libs}/ipc/result.hpp | 0 {common => libs}/ipc/service.cpp | 0 {common => libs}/ipc/service.hpp | 0 {common => libs}/ipc/types.cpp | 0 {common => libs}/ipc/types.hpp | 0 packaging/vasum.spec | 34 ++++++++++ server/CMakeLists.txt | 2 +- server/zones-manager.cpp | 30 ++++----- tests/unit_tests/CMakeLists.txt | 4 +- tests/unit_tests/epoll/ut-event-poll.cpp | 1 - tests/unit_tests/ipc/ut-ipc.cpp | 1 - 52 files changed, 156 insertions(+), 42 deletions(-) create mode 100644 libs/ipc/CMakeLists.txt rename {common => libs}/ipc/client.cpp (100%) rename {common => libs}/ipc/client.hpp (100%) rename {common => libs}/ipc/epoll/event-poll.cpp (99%) rename {common => libs}/ipc/epoll/event-poll.hpp (100%) rename {common => libs}/ipc/epoll/events.cpp (100%) rename {common => libs}/ipc/epoll/events.hpp (100%) rename {common => libs}/ipc/epoll/glib-dispatcher.cpp (100%) rename {common => libs}/ipc/epoll/glib-dispatcher.hpp (100%) rename {common => libs}/ipc/epoll/thread-dispatcher.cpp (100%) rename {common => libs}/ipc/epoll/thread-dispatcher.hpp (100%) rename {common => libs}/ipc/exception.hpp (95%) rename {common => libs}/ipc/internals/acceptor.cpp (100%) rename {common => libs}/ipc/internals/acceptor.hpp (100%) rename {common => libs}/ipc/internals/add-peer-request.hpp (100%) rename {common => libs}/ipc/internals/event-queue.hpp (100%) rename {common => libs}/ipc/internals/finish-request.hpp (100%) rename {common => libs}/ipc/internals/method-request.hpp (100%) rename {common => libs}/ipc/internals/processor.cpp (100%) rename {common => libs}/ipc/internals/processor.hpp (100%) rename {common => libs}/ipc/internals/remove-peer-request.hpp (100%) rename {common => libs}/ipc/internals/request-queue.hpp (100%) rename {common => libs}/ipc/internals/result-builder.hpp (100%) rename {common => libs}/ipc/internals/send-result-request.hpp (100%) rename {common => libs}/ipc/internals/signal-request.hpp (100%) rename {common => libs}/ipc/internals/socket.cpp (100%) rename {common => libs}/ipc/internals/socket.hpp (100%) rename {common => libs}/ipc/ipc-gsource.cpp (100%) rename {common => libs}/ipc/ipc-gsource.hpp (100%) create mode 100644 libs/ipc/libIpc.pc.in rename {common => libs}/ipc/method-result.cpp (100%) rename {common => libs}/ipc/method-result.hpp (100%) rename {common => libs}/ipc/result.hpp (100%) rename {common => libs}/ipc/service.cpp (100%) rename {common => libs}/ipc/service.hpp (100%) rename {common => libs}/ipc/types.cpp (100%) rename {common => libs}/ipc/types.hpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0b6b1b..d42f496 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,6 +142,7 @@ SET(LIBS_FOLDER ${PROJECT_SOURCE_DIR}/libs) SET(LOGGER_FOLDER ${PROJECT_SOURCE_DIR}/libs/logger) SET(DBUS_FOLDER ${PROJECT_SOURCE_DIR}/libs/dbus) SET(CONFIG_FOLDER ${PROJECT_SOURCE_DIR}/libs/config) +SET(IPC_FOLDER ${PROJECT_SOURCE_DIR}/libs/ipc) SET(CLIENT_FOLDER ${PROJECT_SOURCE_DIR}/client) SET(SERVER_FOLDER ${PROJECT_SOURCE_DIR}/server) SET(ZONE_SUPPORT_FOLDER ${PROJECT_SOURCE_DIR}/zone-support) @@ -185,6 +186,7 @@ SET(VSM_UNIT_TESTS_IPC_SOCKET_PATH /var/run/vasum-ipc-unit-tests.socket) ADD_SUBDIRECTORY(${LOGGER_FOLDER}) ADD_SUBDIRECTORY(${DBUS_FOLDER}) ADD_SUBDIRECTORY(${CONFIG_FOLDER}) +ADD_SUBDIRECTORY(${IPC_FOLDER}) ADD_SUBDIRECTORY(${CLIENT_FOLDER}) ADD_SUBDIRECTORY(${SERVER_FOLDER}) ADD_SUBDIRECTORY(${ZONE_SUPPORT_FOLDER}) diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 957faff..f8ad183 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -31,7 +31,7 @@ PKG_CHECK_MODULES(LIB_DEPS REQUIRED vasum) INCLUDE_DIRECTORIES(${CLIENT_FOLDER}) INCLUDE_DIRECTORIES(${COMMON_FOLDER}) -TARGET_LINK_LIBRARIES(${CLI_CODENAME} ${PROJECT_NAME}-client ${LIB_DEPS_LIBRARIES}) +TARGET_LINK_LIBRARIES(${CLI_CODENAME} ${PROJECT_NAME}-client ${LIB_DEPS_LIBRARIES} Ipc) CONFIGURE_FILE(support/vasum-cli-completion.sh.in ${CMAKE_BINARY_DIR}/vasum-cli-completion.sh diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index e08c79b..56ed2e7 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -22,10 +22,7 @@ MESSAGE(STATUS "") MESSAGE(STATUS "Generating makefile for the Client...") FILE(GLOB project_SRCS *.cpp *.hpp *.h) -FILE(GLOB common_SRCS ${COMMON_FOLDER}/ipc/epoll/*.hpp ${COMMON_FOLDER}/ipc/epoll/*.cpp - ${COMMON_FOLDER}/ipc/*.hpp ${COMMON_FOLDER}/ipc/*.cpp - ${COMMON_FOLDER}/ipc/internals/*.hpp ${COMMON_FOLDER}/ipc/internals/*.cpp - ${COMMON_FOLDER}/utils/*.hpp ${COMMON_FOLDER}/utils/*.cpp +FILE(GLOB common_SRCS ${COMMON_FOLDER}/utils/*.hpp ${COMMON_FOLDER}/utils/*.cpp ${COMMON_FOLDER}/*.hpp ${COMMON_FOLDER}/*.cpp) SET(_LIB_VERSION_ "${VERSION}") @@ -51,9 +48,10 @@ PKG_CHECK_MODULES(LIB_DEPS REQUIRED gio-2.0 libsystemd-daemon libcap-ng) INCLUDE_DIRECTORIES(SYSTEM ${LIB_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${COMMON_FOLDER}) INCLUDE_DIRECTORIES(${LIBS_FOLDER}) +INCLUDE_DIRECTORIES(${IPC_FOLDER}) INCLUDE_DIRECTORIES(${SERVER_FOLDER}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_DEPS_LIBRARIES} ${Boost_LIBRARIES} - Config SimpleDbus) + Config SimpleDbus Ipc) ## Generate the pc file ######################################################## CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_BINARY_DIR}/${PC_FILE} @ONLY) diff --git a/common/netlink/netlink.cpp b/common/netlink/netlink.cpp index 633276a..6dd0ae5 100644 --- a/common/netlink/netlink.cpp +++ b/common/netlink/netlink.cpp @@ -28,6 +28,7 @@ #include "utils/exception.hpp" #include "utils/make-clean.hpp" #include "utils/environment.hpp" +#include "base-exception.hpp" #include #include diff --git a/common/utils/eventfd.cpp b/common/utils/eventfd.cpp index a1b45e9..9af1114 100644 --- a/common/utils/eventfd.cpp +++ b/common/utils/eventfd.cpp @@ -34,8 +34,6 @@ #include #include -using namespace vasum; - namespace utils { EventFD::EventFD() diff --git a/common/utils/exception.hpp b/common/utils/exception.hpp index 49aceb8..ca5564a 100644 --- a/common/utils/exception.hpp +++ b/common/utils/exception.hpp @@ -26,8 +26,7 @@ #ifndef COMMON_UTILS_EXCEPTION_HPP #define COMMON_UTILS_EXCEPTION_HPP -#include "base-exception.hpp" - +#include namespace utils { @@ -35,9 +34,9 @@ namespace utils { /** * Base class for exceptions in utils */ -struct UtilsException: public vasum::VasumException { +struct UtilsException: public std::runtime_error { - UtilsException(const std::string& error) : vasum::VasumException(error) {} + UtilsException(const std::string& error) : std::runtime_error(error) {} }; /** diff --git a/common/utils/fd-utils.cpp b/common/utils/fd-utils.cpp index 95080ff..d5179b1 100644 --- a/common/utils/fd-utils.cpp +++ b/common/utils/fd-utils.cpp @@ -39,8 +39,6 @@ namespace fs = boost::filesystem; namespace chr = std::chrono; -using namespace vasum; - namespace utils { namespace { diff --git a/common/utils/file-wait.cpp b/common/utils/file-wait.cpp index 4949314..b1d9a4f 100644 --- a/common/utils/file-wait.cpp +++ b/common/utils/file-wait.cpp @@ -30,8 +30,6 @@ #include #include -using namespace vasum; - namespace utils { diff --git a/common/utils/fs.cpp b/common/utils/fs.cpp index 5581a29..a093c9e 100644 --- a/common/utils/fs.cpp +++ b/common/utils/fs.cpp @@ -45,8 +45,6 @@ namespace fs = boost::filesystem; -using namespace vasum; - namespace utils { diff --git a/libs/ipc/CMakeLists.txt b/libs/ipc/CMakeLists.txt new file mode 100644 index 0000000..d760883 --- /dev/null +++ b/libs/ipc/CMakeLists.txt @@ -0,0 +1,78 @@ +# Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved +# +# 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. +# +# +# @file CMakeLists.txt +# @author Mateusz Malicki (m.malicki2@samsung.com) +# + +PROJECT(Ipc) + +MESSAGE(STATUS "") +MESSAGE(STATUS "Generating makefile for the libIpc...") + +FILE(GLOB HEADERS *.hpp) +FILE(GLOB HEADERS_INTERNALS internals/*.hpp) +FILE(GLOB HEADERS_EPOLL epoll/*.hpp) +FILE(GLOB HEADERS_UTILS ${COMMON_FOLDER}/utils/fd-utils.hpp + ${COMMON_FOLDER}/utils/eventfd.hpp + ${COMMON_FOLDER}/utils/exception.hpp + ${COMMON_FOLDER}/utils/callback-guard.hpp) +FILE(GLOB SRCS *.cpp) +FILE(GLOB SRCS_INTERNALS internals/*.cpp) +FILE(GLOB SRCS_EPOLL epoll/*.cpp) +FILE(GLOB SRCS_UTILS ${COMMON_FOLDER}/utils/fd-utils.cpp + ${COMMON_FOLDER}/utils/eventfd.cpp + ${COMMON_FOLDER}/utils/exception.cpp + ${COMMON_FOLDER}/utils/callback-guard.cpp) + +SET(_LIB_VERSION_ "${VERSION}") +SET(_LIB_SOVERSION_ "0") +SET(PC_FILE "lib${PROJECT_NAME}.pc") + +## Setup target ################################################################ +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS} ${SRCS_INTERNALS} ${SRCS_UTILS} ${SRCS_EPOLL}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES + SOVERSION ${_LIB_SOVERSION_} + VERSION ${_LIB_VERSION_} + ) + +## Link libraries ############################################################## +INCLUDE_DIRECTORIES(${LIBS_FOLDER}) +INCLUDE_DIRECTORIES(${COMMON_FOLDER}) +INCLUDE_DIRECTORIES(SYSTEM ${DBUS_DEPS_INCLUDE_DIRS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} Logger Config) + +## Generate the pc file ######################################################## +CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_CURRENT_BINARY_DIR}/${PC_FILE} @ONLY) + +## Install ##################################################################### +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PC_FILE} + DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) + +INSTALL(TARGETS ${PROJECT_NAME} + DESTINATION ${LIB_INSTALL_DIR} + COMPONENT RuntimeLibraries) + +INSTALL(FILES ${HEADERS} + DESTINATION ${INCLUDE_INSTALL_DIR}/vasum-tools/ipc) + +INSTALL(FILES ${HEADERS_INTERNALS} + DESTINATION ${INCLUDE_INSTALL_DIR}/vasum-tools/ipc/internals) + +INSTALL(FILES ${HEADERS_EPOLL} + DESTINATION ${INCLUDE_INSTALL_DIR}/vasum-tools/ipc/epoll) + +INSTALL(FILES ${HEADERS_UTILS} + DESTINATION ${INCLUDE_INSTALL_DIR}/vasum-tools/ipc/utils) diff --git a/common/ipc/client.cpp b/libs/ipc/client.cpp similarity index 100% rename from common/ipc/client.cpp rename to libs/ipc/client.cpp diff --git a/common/ipc/client.hpp b/libs/ipc/client.hpp similarity index 100% rename from common/ipc/client.hpp rename to libs/ipc/client.hpp diff --git a/common/ipc/epoll/event-poll.cpp b/libs/ipc/epoll/event-poll.cpp similarity index 99% rename from common/ipc/epoll/event-poll.cpp rename to libs/ipc/epoll/event-poll.cpp index d43c97d..fb8470e 100644 --- a/common/ipc/epoll/event-poll.cpp +++ b/libs/ipc/epoll/event-poll.cpp @@ -33,7 +33,6 @@ #include #include -using namespace vasum; using namespace utils; namespace ipc { diff --git a/common/ipc/epoll/event-poll.hpp b/libs/ipc/epoll/event-poll.hpp similarity index 100% rename from common/ipc/epoll/event-poll.hpp rename to libs/ipc/epoll/event-poll.hpp diff --git a/common/ipc/epoll/events.cpp b/libs/ipc/epoll/events.cpp similarity index 100% rename from common/ipc/epoll/events.cpp rename to libs/ipc/epoll/events.cpp diff --git a/common/ipc/epoll/events.hpp b/libs/ipc/epoll/events.hpp similarity index 100% rename from common/ipc/epoll/events.hpp rename to libs/ipc/epoll/events.hpp diff --git a/common/ipc/epoll/glib-dispatcher.cpp b/libs/ipc/epoll/glib-dispatcher.cpp similarity index 100% rename from common/ipc/epoll/glib-dispatcher.cpp rename to libs/ipc/epoll/glib-dispatcher.cpp diff --git a/common/ipc/epoll/glib-dispatcher.hpp b/libs/ipc/epoll/glib-dispatcher.hpp similarity index 100% rename from common/ipc/epoll/glib-dispatcher.hpp rename to libs/ipc/epoll/glib-dispatcher.hpp diff --git a/common/ipc/epoll/thread-dispatcher.cpp b/libs/ipc/epoll/thread-dispatcher.cpp similarity index 100% rename from common/ipc/epoll/thread-dispatcher.cpp rename to libs/ipc/epoll/thread-dispatcher.cpp diff --git a/common/ipc/epoll/thread-dispatcher.hpp b/libs/ipc/epoll/thread-dispatcher.hpp similarity index 100% rename from common/ipc/epoll/thread-dispatcher.hpp rename to libs/ipc/epoll/thread-dispatcher.hpp diff --git a/common/ipc/exception.hpp b/libs/ipc/exception.hpp similarity index 95% rename from common/ipc/exception.hpp rename to libs/ipc/exception.hpp index 3d89d3b..271cf9a 100644 --- a/common/ipc/exception.hpp +++ b/libs/ipc/exception.hpp @@ -26,16 +26,16 @@ #ifndef COMMON_IPC_EXCEPTION_HPP #define COMMON_IPC_EXCEPTION_HPP -#include "base-exception.hpp" +#include namespace ipc { /** * Base class for exceptions in IPC */ -struct IPCException: public vasum::VasumException { +struct IPCException: public std::runtime_error { IPCException(const std::string& message) - : VasumException(message) {} + : std::runtime_error(message) {} }; struct IPCParsingException: public IPCException { diff --git a/common/ipc/internals/acceptor.cpp b/libs/ipc/internals/acceptor.cpp similarity index 100% rename from common/ipc/internals/acceptor.cpp rename to libs/ipc/internals/acceptor.cpp diff --git a/common/ipc/internals/acceptor.hpp b/libs/ipc/internals/acceptor.hpp similarity index 100% rename from common/ipc/internals/acceptor.hpp rename to libs/ipc/internals/acceptor.hpp diff --git a/common/ipc/internals/add-peer-request.hpp b/libs/ipc/internals/add-peer-request.hpp similarity index 100% rename from common/ipc/internals/add-peer-request.hpp rename to libs/ipc/internals/add-peer-request.hpp diff --git a/common/ipc/internals/event-queue.hpp b/libs/ipc/internals/event-queue.hpp similarity index 100% rename from common/ipc/internals/event-queue.hpp rename to libs/ipc/internals/event-queue.hpp diff --git a/common/ipc/internals/finish-request.hpp b/libs/ipc/internals/finish-request.hpp similarity index 100% rename from common/ipc/internals/finish-request.hpp rename to libs/ipc/internals/finish-request.hpp diff --git a/common/ipc/internals/method-request.hpp b/libs/ipc/internals/method-request.hpp similarity index 100% rename from common/ipc/internals/method-request.hpp rename to libs/ipc/internals/method-request.hpp diff --git a/common/ipc/internals/processor.cpp b/libs/ipc/internals/processor.cpp similarity index 100% rename from common/ipc/internals/processor.cpp rename to libs/ipc/internals/processor.cpp diff --git a/common/ipc/internals/processor.hpp b/libs/ipc/internals/processor.hpp similarity index 100% rename from common/ipc/internals/processor.hpp rename to libs/ipc/internals/processor.hpp diff --git a/common/ipc/internals/remove-peer-request.hpp b/libs/ipc/internals/remove-peer-request.hpp similarity index 100% rename from common/ipc/internals/remove-peer-request.hpp rename to libs/ipc/internals/remove-peer-request.hpp diff --git a/common/ipc/internals/request-queue.hpp b/libs/ipc/internals/request-queue.hpp similarity index 100% rename from common/ipc/internals/request-queue.hpp rename to libs/ipc/internals/request-queue.hpp diff --git a/common/ipc/internals/result-builder.hpp b/libs/ipc/internals/result-builder.hpp similarity index 100% rename from common/ipc/internals/result-builder.hpp rename to libs/ipc/internals/result-builder.hpp diff --git a/common/ipc/internals/send-result-request.hpp b/libs/ipc/internals/send-result-request.hpp similarity index 100% rename from common/ipc/internals/send-result-request.hpp rename to libs/ipc/internals/send-result-request.hpp diff --git a/common/ipc/internals/signal-request.hpp b/libs/ipc/internals/signal-request.hpp similarity index 100% rename from common/ipc/internals/signal-request.hpp rename to libs/ipc/internals/signal-request.hpp diff --git a/common/ipc/internals/socket.cpp b/libs/ipc/internals/socket.cpp similarity index 100% rename from common/ipc/internals/socket.cpp rename to libs/ipc/internals/socket.cpp diff --git a/common/ipc/internals/socket.hpp b/libs/ipc/internals/socket.hpp similarity index 100% rename from common/ipc/internals/socket.hpp rename to libs/ipc/internals/socket.hpp diff --git a/common/ipc/ipc-gsource.cpp b/libs/ipc/ipc-gsource.cpp similarity index 100% rename from common/ipc/ipc-gsource.cpp rename to libs/ipc/ipc-gsource.cpp diff --git a/common/ipc/ipc-gsource.hpp b/libs/ipc/ipc-gsource.hpp similarity index 100% rename from common/ipc/ipc-gsource.hpp rename to libs/ipc/ipc-gsource.hpp diff --git a/libs/ipc/libIpc.pc.in b/libs/ipc/libIpc.pc.in new file mode 100644 index 0000000..dbed433 --- /dev/null +++ b/libs/ipc/libIpc.pc.in @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@LIB_INSTALL_DIR@ +includedir=@INCLUDE_INSTALL_DIR@ + +Name: libIpc +Description: IPC library +Version: @_LIB_VERSION_@ +Libs: -L${libdir} -lIpc +Cflags: -I${includedir}/vasum-tools -I${includedir}/vasum-tools/ipc + diff --git a/common/ipc/method-result.cpp b/libs/ipc/method-result.cpp similarity index 100% rename from common/ipc/method-result.cpp rename to libs/ipc/method-result.cpp diff --git a/common/ipc/method-result.hpp b/libs/ipc/method-result.hpp similarity index 100% rename from common/ipc/method-result.hpp rename to libs/ipc/method-result.hpp diff --git a/common/ipc/result.hpp b/libs/ipc/result.hpp similarity index 100% rename from common/ipc/result.hpp rename to libs/ipc/result.hpp diff --git a/common/ipc/service.cpp b/libs/ipc/service.cpp similarity index 100% rename from common/ipc/service.cpp rename to libs/ipc/service.cpp diff --git a/common/ipc/service.hpp b/libs/ipc/service.hpp similarity index 100% rename from common/ipc/service.hpp rename to libs/ipc/service.hpp diff --git a/common/ipc/types.cpp b/libs/ipc/types.cpp similarity index 100% rename from common/ipc/types.cpp rename to libs/ipc/types.cpp diff --git a/common/ipc/types.hpp b/libs/ipc/types.hpp similarity index 100% rename from common/ipc/types.hpp rename to libs/ipc/types.hpp diff --git a/packaging/vasum.spec b/packaging/vasum.spec index 0636c53..0f99f07 100644 --- a/packaging/vasum.spec +++ b/packaging/vasum.spec @@ -356,4 +356,38 @@ The package provides libConfig development tools and libs. %{_includedir}/vasum-tools/config %{_libdir}/pkgconfig/libConfig.pc +## libIpc Package ####################################################### +%package -n libIpc +Summary: IPC library +Group: Security/Other +Requires: libConfig +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description -n libIpc +The package provides libIpc library. +%post -n libIpc -p /sbin/ldconfig + +%postun -n libIpc -p /sbin/ldconfig + +%files -n libIpc +%defattr(644,root,root,755) +%{_libdir}/libIpc.so.0 +%attr(755,root,root) %{_libdir}/libIpc.so.%{version} + +%package -n libIpc-devel +Summary: Development IPC library +Group: Development/Libraries +Requires: libIpc = %{epoch}:%{version}-%{release} +Requires: pkgconfig(libLogger) +Requires: pkgconfig(libConfig) + +%description -n libIpc-devel +The package provides libIpc development tools and libs. + +%files -n libIpc-devel +%defattr(644,root,root,755) +%{_libdir}/libIpc.so +%{_includedir}/vasum-tools/ipc +%{_libdir}/pkgconfig/libIpc.pc diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index c4e0d8f..6181e15 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -44,7 +44,7 @@ SET_TARGET_PROPERTIES(${SERVER_CODENAME} PROPERTIES ) TARGET_LINK_LIBRARIES(${SERVER_CODENAME} ${SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES} - Logger Config SimpleDbus) + Logger Config SimpleDbus Ipc) ## Subdirectories ############################################################## ADD_SUBDIRECTORY(configs) diff --git a/server/zones-manager.cpp b/server/zones-manager.cpp index c05b1be..3869a39 100644 --- a/server/zones-manager.cpp +++ b/server/zones-manager.cpp @@ -587,7 +587,7 @@ void ZonesManager::handleNotifyActiveZoneCall(const std::string& caller, //XXX:get(iter).sendNotification(caller, application, message); } result->setVoid(); - } catch (const VasumException&) { + } catch (const std::runtime_error&) { LOGE("Notification from " << caller << " hasn't been sent"); result->setError(api::ERROR_INTERNAL, "Notification hasn't been sent"); } @@ -820,7 +820,7 @@ void ZonesManager::handleSetNetdevAttrsCall(const api::SetNetDevAttrsIn& data, } catch (const InvalidZoneIdException&) { LOGE("No zone with id=" << data.id); result->setError(api::ERROR_INVALID_ID, "No such zone id"); - } catch (const VasumException& ex) { + } catch (const std::runtime_error& ex) { LOGE("Can't set attributes: " << ex.what()); result->setError(api::ERROR_INTERNAL, ex.what()); } @@ -842,7 +842,7 @@ void ZonesManager::handleGetNetdevAttrsCall(const api::GetNetDevAttrsIn& data, } catch (const InvalidZoneIdException&) { LOGE("No zone with id=" << data.first); result->setError(api::ERROR_INVALID_ID, "No such zone id"); - } catch (const VasumException& ex) { + } catch (const std::runtime_error& ex) { LOGE("Can't set attributes: " << ex.what()); result->setError(api::ERROR_INTERNAL, ex.what()); } @@ -860,7 +860,7 @@ void ZonesManager::handleGetNetdevListCall(const api::ZoneId& zoneId, } catch (const InvalidZoneIdException&) { LOGE("No zone with id=" << zoneId.value); result->setError(api::ERROR_INVALID_ID, "No such zone id"); - } catch (const VasumException& ex) { + } catch (const std::runtime_error& ex) { LOGE("Can't set attributes: " << ex.what()); result->setError(api::ERROR_INTERNAL, ex.what()); } @@ -878,7 +878,7 @@ void ZonesManager::handleCreateNetdevVethCall(const api::CreateNetDevVethIn& dat } catch (const InvalidZoneIdException&) { LOGE("No zone with id=" << data.id); result->setError(api::ERROR_INVALID_ID, "No such zone id"); - } catch (const VasumException& ex) { + } catch (const std::runtime_error& ex) { LOGE("Can't create veth: " << ex.what()); result->setError(api::ERROR_INTERNAL, ex.what()); } @@ -895,7 +895,7 @@ void ZonesManager::handleCreateNetdevMacvlanCall(const api::CreateNetDevMacvlanI } catch (const InvalidZoneIdException&) { LOGE("No zone with id=" << data.id); result->setError(api::ERROR_INVALID_ID, "No such zone id"); - } catch (const VasumException& ex) { + } catch (const std::runtime_error& ex) { LOGE("Can't create macvlan: " << ex.what()); result->setError(api::ERROR_INTERNAL, ex.what()); } @@ -913,7 +913,7 @@ void ZonesManager::handleCreateNetdevPhysCall(const api::CreateNetDevPhysIn& dat } catch (const InvalidZoneIdException&) { LOGE("No zone with id=" << data.first); result->setError(api::ERROR_INVALID_ID, "No such zone id"); - } catch (const VasumException& ex) { + } catch (const std::runtime_error& ex) { LOGE("Can't create netdev: " << ex.what()); result->setError(api::ERROR_INTERNAL, ex.what()); } @@ -931,7 +931,7 @@ void ZonesManager::handleDestroyNetdevCall(const api::DestroyNetDevIn& data, } catch (const InvalidZoneIdException&) { LOGE("No zone with id=" << data.first); result->setError(api::ERROR_INVALID_ID, "No such zone id"); - } catch (const VasumException& ex) { + } catch (const std::runtime_error& ex) { LOGE("Can't create netdev: " << ex.what()); result->setError(api::ERROR_INTERNAL, ex.what()); } @@ -948,7 +948,7 @@ void ZonesManager::handleDeleteNetdevIpAddressCall(const api::DeleteNetdevIpAddr } catch (const InvalidZoneIdException&) { LOGE("No zone with id=" << data.zone); result->setError(api::ERROR_INVALID_ID, "No such zone id"); - } catch (const VasumException& ex) { + } catch (const std::runtime_error& ex) { LOGE("Can't delete address: " << ex.what()); result->setError(api::ERROR_INTERNAL, ex.what()); } @@ -1022,7 +1022,7 @@ void ZonesManager::handleGetDeclarationsCall(const api::ZoneId& zoneId, } catch (const InvalidZoneIdException&) { LOGE("No zone with id=" << zoneId.value); result->setError(api::ERROR_INVALID_ID, "No such zone id"); - } catch (const VasumException& ex) { + } catch (const std::runtime_error& ex) { LOGE(ex.what()); result->setError(api::ERROR_INTERNAL, ex.what()); } @@ -1039,7 +1039,7 @@ void ZonesManager::handleRemoveDeclarationCall(const api::RemoveDeclarationIn& d } catch (const InvalidZoneIdException&) { LOGE("No zone with id=" << data.first); result->setError(api::ERROR_INVALID_ID, "No such zone id"); - } catch (const VasumException& ex) { + } catch (const std::runtime_error& ex) { LOGE(ex.what()); result->setError(api::ERROR_INTERNAL, ex.what()); } @@ -1179,7 +1179,7 @@ void ZonesManager::createZone(const std::string& id, try { LOGI("Generating config from " << zoneTemplatePath); generateNewConfig(id, zoneTemplatePath); - } catch (VasumException& e) { + } catch (std::runtime_error& e) { LOGE("Generate config failed: " << e.what()); utils::launchAsRoot(std::bind(removeAllWrapper, zonePathStr)); throw e; @@ -1188,7 +1188,7 @@ void ZonesManager::createZone(const std::string& id, LOGT("Creating new zone"); try { insertZone(id, zoneTemplatePath); - } catch (VasumException& e) { + } catch (std::runtime_error& e) { LOGE("Creating new zone failed: " << e.what()); utils::launchAsRoot(std::bind(removeAllWrapper, zonePathStr)); throw e; @@ -1207,7 +1207,7 @@ void ZonesManager::handleCreateZoneCall(const api::CreateZoneIn& data, result->setVoid(); } catch (const InvalidZoneIdException& e) { result->setError(api::ERROR_INVALID_ID, "Existing or invalid zone id"); - } catch (const VasumException& e) { + } catch (const std::runtime_error& e) { result->setError(api::ERROR_INTERNAL, "Failed to create zone"); } } @@ -1222,7 +1222,7 @@ void ZonesManager::handleDestroyZoneCall(const api::ZoneId& zoneId, } catch (const InvalidZoneIdException&) { LOGE("Failed to destroy zone - no such zone id: " << zoneId.value); result->setError(api::ERROR_INVALID_ID, "No such zone id"); - } catch (const VasumException& e) { + } catch (const std::runtime_error& e) { LOGE("Error during zone destruction: " << e.what()); result->setError(api::ERROR_INTERNAL, "Failed to destroy zone"); return; diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt index 500e7af..a4e6cfd 100644 --- a/tests/unit_tests/CMakeLists.txt +++ b/tests/unit_tests/CMakeLists.txt @@ -66,9 +66,9 @@ SET_TARGET_PROPERTIES(${SOCKET_TEST_CODENAME} PROPERTIES ) TARGET_LINK_LIBRARIES(${UT_SERVER_CODENAME} ${UT_SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES} - Logger Config SimpleDbus) + Logger Config SimpleDbus Ipc) TARGET_LINK_LIBRARIES(${SOCKET_TEST_CODENAME} ${UT_SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES} - Logger Config SimpleDbus) + Logger Config SimpleDbus Ipc) ## Subdirectories ############################################################## SET(VSM_TEST_CONFIG_INSTALL_DIR ${VSM_CONFIG_INSTALL_DIR}/tests) diff --git a/tests/unit_tests/epoll/ut-event-poll.cpp b/tests/unit_tests/epoll/ut-event-poll.cpp index 819e959..9bf28f0 100644 --- a/tests/unit_tests/epoll/ut-event-poll.cpp +++ b/tests/unit_tests/epoll/ut-event-poll.cpp @@ -34,7 +34,6 @@ #include "ipc/epoll/glib-dispatcher.hpp" #include "ipc/epoll/thread-dispatcher.hpp" -using namespace vasum; using namespace utils; using namespace ipc; using namespace ipc::epoll; diff --git a/tests/unit_tests/ipc/ut-ipc.cpp b/tests/unit_tests/ipc/ut-ipc.cpp index b5edbf7..e71a160 100644 --- a/tests/unit_tests/ipc/ut-ipc.cpp +++ b/tests/unit_tests/ipc/ut-ipc.cpp @@ -51,7 +51,6 @@ #include #include -using namespace vasum; using namespace ipc; using namespace epoll; using namespace utils; -- 2.7.4 From f9dc55e105e8046563e1f2d0471de2d8238319fc Mon Sep 17 00:00:00 2001 From: Dariusz Michaluk Date: Wed, 13 May 2015 16:19:26 +0200 Subject: [PATCH 04/16] Cleanup daemon and zones configuration [Feature] Move unit tests configs to one directory. Remove unnecessary unit tests configs. Remove zoneTemplatePrefix from daemon config (zoneTemplateDir is used instead). Rename some configs. [Cause] N/A [Solution] N/A [Verification] Build, install, run tests, run server. Change-Id: Iabed6b7bfc1999296bcea89269195867d804c9ac --- packaging/vasum.spec | 8 ++- server/configs/daemon.conf.in | 1 - server/zone-admin.cpp | 4 +- server/zone-admin.hpp | 4 +- server/zone-config.hpp | 2 +- server/zone.cpp | 4 +- server/zone.hpp | 4 +- server/zones-manager-config.hpp | 6 -- server/zones-manager.cpp | 2 +- tests/unit_tests/CMakeLists.txt | 8 +-- tests/unit_tests/client/configs/CMakeLists.txt | 37 ---------- tests/unit_tests/client/ut-client.cpp | 2 +- tests/unit_tests/configs/CMakeLists.txt | 63 ++++++++++++++++ .../dbus-1/system.d/org.tizen.vasum.tests.conf | 0 .../dbus/ut-dbus-system.conf} | 0 .../ut-connection => configs/dbus}/ut-dbus.conf | 0 .../provision/test-provision.conf} | 0 .../configs/systemd/vasum-socket-test.service | 0 .../configs/systemd/vasum-socket-test.socket | 0 .../templates/buggy-init.conf} | 0 .../templates/buggy-template.conf} | 0 .../templates/console-dbus.conf.in | 4 +- .../templates/console-ipc.conf.in | 2 +- .../test.conf => configs/templates/default.conf} | 2 +- .../templates/minimal.sh} | 4 +- .../templates/missing.conf | 0 .../templates/test-no-shutdown.conf | 0 .../ut-client => configs}/test-daemon.conf.in | 7 +- .../configs/ut-fs => configs/utils}/file.txt | 0 tests/unit_tests/dbus/configs/CMakeLists.txt | 26 ------- tests/unit_tests/dbus/ut-connection.cpp | 2 +- tests/unit_tests/lxc/templates/CMakeLists.txt | 23 ------ tests/unit_tests/lxc/templates/minimal.sh | 76 -------------------- tests/unit_tests/server/configs/CMakeLists.txt | 83 ---------------------- .../configs/ut-server/templates/default.conf | 18 ----- .../server/configs/ut-server/test-daemon.conf.in | 17 ----- .../configs/ut-zone-admin/templates/test.conf | 18 ----- .../configs/ut-zone/templates/test-dbus.conf.in | 18 ----- .../unit_tests/server/configs/ut-zone/ut-dbus.conf | 18 ----- .../ut-zones-manager/templates/console.conf | 18 ----- .../configs/ut-zones-manager/test-daemon.conf.in | 22 ------ tests/unit_tests/server/ut-server.cpp | 2 +- tests/unit_tests/server/ut-zone-admin.cpp | 9 ++- tests/unit_tests/server/ut-zone-provision.cpp | 3 +- tests/unit_tests/server/ut-zone.cpp | 13 ++-- tests/unit_tests/server/ut-zones-manager.cpp | 4 +- .../socket_test_service/configs/CMakeLists.txt | 26 ------- tests/unit_tests/utils/configs/CMakeLists.txt | 26 ------- tests/unit_tests/utils/ut-fs.cpp | 2 +- 49 files changed, 106 insertions(+), 482 deletions(-) delete mode 100644 tests/unit_tests/client/configs/CMakeLists.txt create mode 100644 tests/unit_tests/configs/CMakeLists.txt rename tests/unit_tests/{server => }/configs/dbus-1/system.d/org.tizen.vasum.tests.conf (100%) rename tests/unit_tests/{server/configs/ut-zones-manager/ut-dbus.conf => configs/dbus/ut-dbus-system.conf} (100%) rename tests/unit_tests/{dbus/configs/ut-connection => configs/dbus}/ut-dbus.conf (100%) rename tests/unit_tests/{server/configs/ut-zone-provision/test.conf => configs/provision/test-provision.conf} (100%) rename tests/unit_tests/{socket_test_service => }/configs/systemd/vasum-socket-test.service (100%) rename tests/unit_tests/{socket_test_service => }/configs/systemd/vasum-socket-test.socket (100%) rename tests/unit_tests/{server/configs/ut-zone-admin/templates/buggy.conf => configs/templates/buggy-init.conf} (100%) rename tests/unit_tests/{server/configs/ut-zone/templates/buggy.conf => configs/templates/buggy-template.conf} (100%) rename tests/unit_tests/{client/configs/ut-client => configs}/templates/console-dbus.conf.in (76%) rename tests/unit_tests/{client/configs/ut-client => configs}/templates/console-ipc.conf.in (92%) rename tests/unit_tests/{server/configs/ut-zone/templates/test.conf => configs/templates/default.conf} (95%) rename tests/unit_tests/{lxc/templates/minimal-dbus.sh => configs/templates/minimal.sh} (96%) rename tests/unit_tests/{server/configs/ut-zone-admin => configs}/templates/missing.conf (100%) rename tests/unit_tests/{server/configs/ut-zone-admin => configs}/templates/test-no-shutdown.conf (100%) rename tests/unit_tests/{client/configs/ut-client => configs}/test-daemon.conf.in (76%) rename tests/unit_tests/{utils/configs/ut-fs => configs/utils}/file.txt (100%) delete mode 100644 tests/unit_tests/dbus/configs/CMakeLists.txt delete mode 100644 tests/unit_tests/lxc/templates/CMakeLists.txt delete mode 100755 tests/unit_tests/lxc/templates/minimal.sh delete mode 100644 tests/unit_tests/server/configs/CMakeLists.txt delete mode 100644 tests/unit_tests/server/configs/ut-server/templates/default.conf delete mode 100644 tests/unit_tests/server/configs/ut-server/test-daemon.conf.in delete mode 100644 tests/unit_tests/server/configs/ut-zone-admin/templates/test.conf delete mode 100644 tests/unit_tests/server/configs/ut-zone/templates/test-dbus.conf.in delete mode 100644 tests/unit_tests/server/configs/ut-zone/ut-dbus.conf delete mode 100644 tests/unit_tests/server/configs/ut-zones-manager/templates/console.conf delete mode 100644 tests/unit_tests/server/configs/ut-zones-manager/test-daemon.conf.in delete mode 100644 tests/unit_tests/socket_test_service/configs/CMakeLists.txt delete mode 100644 tests/unit_tests/utils/configs/CMakeLists.txt diff --git a/packaging/vasum.spec b/packaging/vasum.spec index 0f99f07..22a6363 100644 --- a/packaging/vasum.spec +++ b/packaging/vasum.spec @@ -246,8 +246,12 @@ systemctl daemon-reload %attr(755,root,root) %{script_dir}/vsm_int_tests.py %attr(755,root,root) %{script_dir}/vsm_launch_test.py %{script_dir}/vsm_test_parser.py -%config /etc/vasum/tests -%attr(755,root,root) /etc/vasum/tests/templates +%config /etc/vasum/tests/*.conf +%config /etc/vasum/tests/dbus/*.conf +%config /etc/vasum/tests/provision/*.conf +%config /etc/vasum/tests/templates/*.conf +%attr(755,root,root) /etc/vasum/tests/templates/*.sh +%config /etc/vasum/tests/utils/*.txt %{python_sitelib}/vsm_integration_tests %config /etc/dbus-1/system.d/org.tizen.vasum.tests.conf %{_unitdir}/vasum-socket-test.socket diff --git a/server/configs/daemon.conf.in b/server/configs/daemon.conf.in index 0800124..b94eb29 100644 --- a/server/configs/daemon.conf.in +++ b/server/configs/daemon.conf.in @@ -6,7 +6,6 @@ "zoneTemplateDir" : "/etc/vasum/templates/", "runMountPointPrefix" : "/var/run/zones", "defaultId" : "", - "zoneTemplatePrefix" : "/etc/vasum/templates", "availableVTs" : [3, 4, 5, 6], "inputConfig" : {"enabled" : true, "device" : "gpio_keys.6", diff --git a/server/zone-admin.cpp b/server/zone-admin.cpp index 473a11c..05d9c7d 100644 --- a/server/zone-admin.cpp +++ b/server/zone-admin.cpp @@ -46,7 +46,7 @@ const std::uint64_t DEFAULT_VCPU_PERIOD_MS = 100000; ZoneAdmin::ZoneAdmin(const std::string& zoneId, const std::string& zonesPath, - const std::string& zoneTemplatePrefix, + const std::string& zoneTemplateDir, const ZoneConfig& config, const ZoneDynamicConfig& dynamicConfig) : mConfig(config), @@ -61,7 +61,7 @@ ZoneAdmin::ZoneAdmin(const std::string& zoneId, if (!mZone.isDefined()) { const std::string zoneTemplate = utils::getAbsolutePath(config.zoneTemplate, - zoneTemplatePrefix); + zoneTemplateDir); LOGI(mId << ": Creating zone from template: " << zoneTemplate); utils::CStringArrayBuilder args; if (!dynamicConfig.ipv4Gateway.empty()) { diff --git a/server/zone-admin.hpp b/server/zone-admin.hpp index d154beb..ec4c7cd 100644 --- a/server/zone-admin.hpp +++ b/server/zone-admin.hpp @@ -47,13 +47,13 @@ public: * ZoneAdmin constructor * @param zoneId zone id * @param zonesPath directory where zones are defined (configs, rootfs etc) - * @param zoneTemplatePrefix directory where templates are stored + * @param zoneTemplateDir directory where templates are stored * @param config zones config * @param dynamicConfig zones dynamic config */ ZoneAdmin(const std::string& zoneId, const std::string& zonesPath, - const std::string& zoneTemplatePrefix, + const std::string& zoneTemplateDir, const ZoneConfig& config, const ZoneDynamicConfig& dynamicConfig); virtual ~ZoneAdmin(); diff --git a/server/zone-config.hpp b/server/zone-config.hpp index aad9159..01fc728 100644 --- a/server/zone-config.hpp +++ b/server/zone-config.hpp @@ -38,7 +38,7 @@ namespace vasum { struct ZoneConfig { /** - * Zone template name (relative to zoneTemplatePrefix) + * Zone template name (relative to zoneTemplateDir) */ std::string zoneTemplate; diff --git a/server/zone.cpp b/server/zone.cpp index a19fc6a..3fe0b12 100644 --- a/server/zone.cpp +++ b/server/zone.cpp @@ -56,7 +56,7 @@ Zone::Zone(const std::string& zoneId, const std::string& zonesPath, const std::string& zoneTemplatePath, const std::string& dbPath, - const std::string& zoneTemplatePrefix, + const std::string& zoneTemplateDir, const std::string& baseRunMountPointPath) : mDbPath(dbPath) { @@ -75,7 +75,7 @@ Zone::Zone(const std::string& zoneId, mRunMountPoint = fs::absolute(mDynamicConfig.runMountPoint, baseRunMountPointPath).string(); } - mAdmin.reset(new ZoneAdmin(zoneId, zonesPath, zoneTemplatePrefix, mConfig, mDynamicConfig)); + mAdmin.reset(new ZoneAdmin(zoneId, zonesPath, zoneTemplateDir, mConfig, mDynamicConfig)); const fs::path zonePath = fs::path(zonesPath) / zoneId; mRootPath = (zonePath / fs::path("rootfs")).string(); diff --git a/server/zone.hpp b/server/zone.hpp index ee1bf43..fb9f0c7 100644 --- a/server/zone.hpp +++ b/server/zone.hpp @@ -49,14 +49,14 @@ public: * @param zonesPath directory where zones are defined (configs, rootfs etc) * @param zoneTemplatePath path for zones config template * @param dbPath path to dynamic config db file - * @param zoneTemplatePrefix directory where templates are stored + * @param zoneTemplateDir directory where templates are stored * @param baseRunMountPointPath base directory for run mount point */ Zone(const std::string& zoneId, const std::string& zonesPath, const std::string& zoneTemplatePath, const std::string& dbPath, - const std::string& zoneTemplatePrefix, + const std::string& zoneTemplateDir, const std::string& baseRunMountPointPath); Zone(const Zone&) = delete; Zone& operator=(const Zone&) = delete; diff --git a/server/zones-manager-config.hpp b/server/zones-manager-config.hpp index b59cfc2..6e4625f 100644 --- a/server/zones-manager-config.hpp +++ b/server/zones-manager-config.hpp @@ -60,11 +60,6 @@ struct ZonesManagerConfig { std::string zoneTemplateDir; /** - * Path prefix for zone templates - */ - std::string zoneTemplatePrefix; - - /** * VTs available for zones */ std::vector availableVTs; @@ -90,7 +85,6 @@ struct ZonesManagerConfig { zonesPath, zoneImagePath, zoneTemplateDir, - zoneTemplatePrefix, availableVTs, inputConfig, runMountPointPrefix, diff --git a/server/zones-manager.cpp b/server/zones-manager.cpp index 3869a39..0762294 100644 --- a/server/zones-manager.cpp +++ b/server/zones-manager.cpp @@ -323,7 +323,7 @@ void ZonesManager::insertZone(const std::string& zoneId, const std::string& zone mConfig.zonesPath, zoneTemplatePath, mConfig.dbPath, - mConfig.zoneTemplatePrefix, + mConfig.zoneTemplateDir, mConfig.runMountPointPrefix)); mZones.push_back(std::move(zone)); diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt index a4e6cfd..452a54a 100644 --- a/tests/unit_tests/CMakeLists.txt +++ b/tests/unit_tests/CMakeLists.txt @@ -76,13 +76,7 @@ SET(VSM_TEST_TEMPLATES_INSTALL_DIR ${VSM_CONFIG_INSTALL_DIR}/tests/templates) ADD_DEFINITIONS(-DVSM_TEST_CONFIG_INSTALL_DIR="${VSM_TEST_CONFIG_INSTALL_DIR}") ADD_DEFINITIONS(-DVSM_TEST_TEMPLATES_INSTALL_DIR="${VSM_TEST_TEMPLATES_INSTALL_DIR}") -ADD_SUBDIRECTORY(dbus/configs) -ADD_SUBDIRECTORY(server/configs) -ADD_SUBDIRECTORY(utils/configs) -ADD_SUBDIRECTORY(client/configs) -ADD_SUBDIRECTORY(lxc/templates) -ADD_SUBDIRECTORY(socket_test_service/configs) - +ADD_SUBDIRECTORY(configs) ## Install ##################################################################### INSTALL(TARGETS ${UT_SERVER_CODENAME} DESTINATION bin) diff --git a/tests/unit_tests/client/configs/CMakeLists.txt b/tests/unit_tests/client/configs/CMakeLists.txt deleted file mode 100644 index 64618ed..0000000 --- a/tests/unit_tests/client/configs/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved -# -# 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. -# -# -# @file CMakeLists.txt -# @author Mateusz Malicki (m.malicki2@samsung.com) -# - -MESSAGE(STATUS "Installing configs for the Client Unit Tests to " ${VSM_TEST_CONFIG_INSTALL_DIR}) - -## Generate #################################################################### -CONFIGURE_FILE(ut-client/test-daemon.conf.in - ${CMAKE_BINARY_DIR}/ut-client/test-daemon.conf @ONLY) -FILE(GLOB client_manager_CONF_GEN ${CMAKE_BINARY_DIR}/ut-client/*.conf) - -CONFIGURE_FILE(ut-client/templates/console-dbus.conf.in - ${CMAKE_BINARY_DIR}/ut-client/templates/console-dbus.conf @ONLY) -CONFIGURE_FILE(ut-client/templates/console-ipc.conf.in - ${CMAKE_BINARY_DIR}/ut-client/templates/console-ipc.conf @ONLY) -FILE(GLOB client_templates_CONF_GEN ${CMAKE_BINARY_DIR}/ut-client/templates/*.conf) - -## Install ##################################################################### -INSTALL(FILES ${client_manager_CONF_GEN} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/client/ut-client) -INSTALL(FILES ${client_templates_CONF_GEN} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/client/ut-client/templates) diff --git a/tests/unit_tests/client/ut-client.cpp b/tests/unit_tests/client/ut-client.cpp index a43319c..328a5bd 100644 --- a/tests/unit_tests/client/ut-client.cpp +++ b/tests/unit_tests/client/ut-client.cpp @@ -51,7 +51,7 @@ using namespace utils; namespace { const std::string TEST_CONFIG_PATH = - VSM_TEST_CONFIG_INSTALL_DIR "/client/ut-client/test-daemon.conf"; + VSM_TEST_CONFIG_INSTALL_DIR "/test-daemon.conf"; const std::string ZONES_PATH = "/tmp/ut-zones"; // the same as in daemon.conf const std::string TEMPLATE_NAME = "console-ipc"; diff --git a/tests/unit_tests/configs/CMakeLists.txt b/tests/unit_tests/configs/CMakeLists.txt new file mode 100644 index 0000000..04aabda --- /dev/null +++ b/tests/unit_tests/configs/CMakeLists.txt @@ -0,0 +1,63 @@ +# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved +# +# 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. +# +# +# @file CMakeLists.txt +# @author Dariusz Michaluk (d.michaluk@samsung.com) +# + +MESSAGE(STATUS "Installing configs for the Unit Tests to " ${VSM_TEST_CONFIG_INSTALL_DIR}) + +FILE(GLOB ut_zone_CONF *.conf) +FILE(GLOB ut_zone_templates_CONF templates/*.conf + templates/*.sh) + +## Generate #################################################################### +CONFIGURE_FILE(test-daemon.conf.in + ${CMAKE_BINARY_DIR}/test-daemon.conf @ONLY) +FILE(GLOB ut_zone_CONF_GEN ${CMAKE_BINARY_DIR}/*.conf) + +CONFIGURE_FILE(templates/console-dbus.conf.in + ${CMAKE_BINARY_DIR}/templates/console-dbus.conf @ONLY) +CONFIGURE_FILE(templates/console-ipc.conf.in + ${CMAKE_BINARY_DIR}/templates/console-ipc.conf @ONLY) +FILE(GLOB ut_zone_templates_CONF_GEN ${CMAKE_BINARY_DIR}/templates/*.conf) + + +## Install ##################################################################### +INSTALL(FILES ${ut_zone_CONF} + ${ut_zone_CONF_GEN} + DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}) + +INSTALL(FILES ${ut_zone_templates_CONF} + ${ut_zone_templates_CONF_GEN} + DESTINATION ${VSM_TEST_TEMPLATES_INSTALL_DIR}) + +INSTALL(FILES dbus/ut-dbus.conf + dbus/ut-dbus-system.conf + DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/dbus) + +INSTALL(FILES provision/test-provision.conf + DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/provision) + +INSTALL(FILES utils/file.txt + DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/utils) + +INSTALL(FILES systemd/vasum-socket-test.socket + systemd/vasum-socket-test.service + DESTINATION ${SYSTEMD_UNIT_DIR}) + +INSTALL(FILES dbus-1/system.d/org.tizen.vasum.tests.conf + DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d/) + diff --git a/tests/unit_tests/server/configs/dbus-1/system.d/org.tizen.vasum.tests.conf b/tests/unit_tests/configs/dbus-1/system.d/org.tizen.vasum.tests.conf similarity index 100% rename from tests/unit_tests/server/configs/dbus-1/system.d/org.tizen.vasum.tests.conf rename to tests/unit_tests/configs/dbus-1/system.d/org.tizen.vasum.tests.conf diff --git a/tests/unit_tests/server/configs/ut-zones-manager/ut-dbus.conf b/tests/unit_tests/configs/dbus/ut-dbus-system.conf similarity index 100% rename from tests/unit_tests/server/configs/ut-zones-manager/ut-dbus.conf rename to tests/unit_tests/configs/dbus/ut-dbus-system.conf diff --git a/tests/unit_tests/dbus/configs/ut-connection/ut-dbus.conf b/tests/unit_tests/configs/dbus/ut-dbus.conf similarity index 100% rename from tests/unit_tests/dbus/configs/ut-connection/ut-dbus.conf rename to tests/unit_tests/configs/dbus/ut-dbus.conf diff --git a/tests/unit_tests/server/configs/ut-zone-provision/test.conf b/tests/unit_tests/configs/provision/test-provision.conf similarity index 100% rename from tests/unit_tests/server/configs/ut-zone-provision/test.conf rename to tests/unit_tests/configs/provision/test-provision.conf diff --git a/tests/unit_tests/socket_test_service/configs/systemd/vasum-socket-test.service b/tests/unit_tests/configs/systemd/vasum-socket-test.service similarity index 100% rename from tests/unit_tests/socket_test_service/configs/systemd/vasum-socket-test.service rename to tests/unit_tests/configs/systemd/vasum-socket-test.service diff --git a/tests/unit_tests/socket_test_service/configs/systemd/vasum-socket-test.socket b/tests/unit_tests/configs/systemd/vasum-socket-test.socket similarity index 100% rename from tests/unit_tests/socket_test_service/configs/systemd/vasum-socket-test.socket rename to tests/unit_tests/configs/systemd/vasum-socket-test.socket diff --git a/tests/unit_tests/server/configs/ut-zone-admin/templates/buggy.conf b/tests/unit_tests/configs/templates/buggy-init.conf similarity index 100% rename from tests/unit_tests/server/configs/ut-zone-admin/templates/buggy.conf rename to tests/unit_tests/configs/templates/buggy-init.conf diff --git a/tests/unit_tests/server/configs/ut-zone/templates/buggy.conf b/tests/unit_tests/configs/templates/buggy-template.conf similarity index 100% rename from tests/unit_tests/server/configs/ut-zone/templates/buggy.conf rename to tests/unit_tests/configs/templates/buggy-template.conf diff --git a/tests/unit_tests/client/configs/ut-client/templates/console-dbus.conf.in b/tests/unit_tests/configs/templates/console-dbus.conf.in similarity index 76% rename from tests/unit_tests/client/configs/ut-client/templates/console-dbus.conf.in rename to tests/unit_tests/configs/templates/console-dbus.conf.in index c47dfaa..ef8a63e 100644 --- a/tests/unit_tests/client/configs/ut-client/templates/console-dbus.conf.in +++ b/tests/unit_tests/configs/templates/console-dbus.conf.in @@ -1,6 +1,6 @@ { - "zoneTemplate" : "minimal-dbus.sh", - "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"], + "zoneTemplate" : "minimal.sh", + "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/dbus/ut-dbus-system.conf --fork; read"], "requestedState" : "running", "ipv4Gateway" : "", "ipv4" : "", diff --git a/tests/unit_tests/client/configs/ut-client/templates/console-ipc.conf.in b/tests/unit_tests/configs/templates/console-ipc.conf.in similarity index 92% rename from tests/unit_tests/client/configs/ut-client/templates/console-ipc.conf.in rename to tests/unit_tests/configs/templates/console-ipc.conf.in index 7b48420..a4d43b0 100644 --- a/tests/unit_tests/client/configs/ut-client/templates/console-ipc.conf.in +++ b/tests/unit_tests/configs/templates/console-ipc.conf.in @@ -1,5 +1,5 @@ { - "zoneTemplate" : "minimal-dbus.sh", + "zoneTemplate" : "minimal.sh", "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], "requestedState" : "running", "ipv4Gateway" : "", diff --git a/tests/unit_tests/server/configs/ut-zone/templates/test.conf b/tests/unit_tests/configs/templates/default.conf similarity index 95% rename from tests/unit_tests/server/configs/ut-zone/templates/test.conf rename to tests/unit_tests/configs/templates/default.conf index 115307d..6b0eaa7 100644 --- a/tests/unit_tests/server/configs/ut-zone/templates/test.conf +++ b/tests/unit_tests/configs/templates/default.conf @@ -4,7 +4,7 @@ "requestedState" : "running", "ipv4Gateway" : "", "ipv4" : "", - "privilege" : 10, + "privilege" : 20, "vt" : -1, "switchToDefaultAfterTimeout" : true, "cpuQuotaForeground" : -1, diff --git a/tests/unit_tests/lxc/templates/minimal-dbus.sh b/tests/unit_tests/configs/templates/minimal.sh similarity index 96% rename from tests/unit_tests/lxc/templates/minimal-dbus.sh rename to tests/unit_tests/configs/templates/minimal.sh index a33ccac..948cf01 100755 --- a/tests/unit_tests/lxc/templates/minimal-dbus.sh +++ b/tests/unit_tests/configs/templates/minimal.sh @@ -48,8 +48,8 @@ lxc.utsname = ${name} lxc.rootfs = ${rootfs} # userns 1-to-1 mapping -lxc.id_map = u 0 0 65536 -lxc.id_map = g 0 0 65536 +#lxc.id_map = u 0 0 65536 +#lxc.id_map = g 0 0 65536 lxc.haltsignal = SIGTERM diff --git a/tests/unit_tests/server/configs/ut-zone-admin/templates/missing.conf b/tests/unit_tests/configs/templates/missing.conf similarity index 100% rename from tests/unit_tests/server/configs/ut-zone-admin/templates/missing.conf rename to tests/unit_tests/configs/templates/missing.conf diff --git a/tests/unit_tests/server/configs/ut-zone-admin/templates/test-no-shutdown.conf b/tests/unit_tests/configs/templates/test-no-shutdown.conf similarity index 100% rename from tests/unit_tests/server/configs/ut-zone-admin/templates/test-no-shutdown.conf rename to tests/unit_tests/configs/templates/test-no-shutdown.conf diff --git a/tests/unit_tests/client/configs/ut-client/test-daemon.conf.in b/tests/unit_tests/configs/test-daemon.conf.in similarity index 76% rename from tests/unit_tests/client/configs/ut-client/test-daemon.conf.in rename to tests/unit_tests/configs/test-daemon.conf.in index 848366a..5151fbe 100644 --- a/tests/unit_tests/client/configs/ut-client/test-daemon.conf.in +++ b/tests/unit_tests/configs/test-daemon.conf.in @@ -1,15 +1,14 @@ { "dbPath" : "/tmp/ut-zones/vasum.db", "zoneIds" : [], - "defaultId" : "", "zonesPath" : "/tmp/ut-zones", "zoneImagePath" : "", - "zoneTemplateDir" : "@VSM_TEST_CONFIG_INSTALL_DIR@/client/ut-client/templates/", + "zoneTemplateDir" : "@VSM_TEST_CONFIG_INSTALL_DIR@/templates/", "runMountPointPrefix" : "", - "zoneTemplatePrefix" : "@VSM_TEST_TEMPLATES_INSTALL_DIR@", + "defaultId" : "", "availableVTs" : [], "inputConfig" : {"enabled" : false, - "device" : "/dev/doesnotexist", + "device" : "gpio-keys.4", "code" : 139, "numberOfEvents" : 2, "timeWindowMs" : 500}, diff --git a/tests/unit_tests/utils/configs/ut-fs/file.txt b/tests/unit_tests/configs/utils/file.txt similarity index 100% rename from tests/unit_tests/utils/configs/ut-fs/file.txt rename to tests/unit_tests/configs/utils/file.txt diff --git a/tests/unit_tests/dbus/configs/CMakeLists.txt b/tests/unit_tests/dbus/configs/CMakeLists.txt deleted file mode 100644 index 69c2910..0000000 --- a/tests/unit_tests/dbus/configs/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved -# -# 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. -# -# -# @file CMakeLists.txt -# @author Lukasz Pawelczyk (l.pawelczyk@partner.samsung.com) -# - -MESSAGE(STATUS "Installing configs for the DBus Unit Tests to " ${VSM_TEST_CONFIG_INSTALL_DIR}) -FILE(GLOB dbus_CONF ut-connection/*.conf) - - -## Install ##################################################################### -INSTALL(FILES ${dbus_CONF} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/dbus/ut-connection) diff --git a/tests/unit_tests/dbus/ut-connection.cpp b/tests/unit_tests/dbus/ut-connection.cpp index b427355..98154df 100644 --- a/tests/unit_tests/dbus/ut-connection.cpp +++ b/tests/unit_tests/dbus/ut-connection.cpp @@ -55,7 +55,7 @@ namespace { const char* DBUS_DAEMON_PROC = "/usr/bin/dbus-daemon"; const char* const DBUS_DAEMON_ARGS[] = { DBUS_DAEMON_PROC, - "--config-file=" VSM_TEST_CONFIG_INSTALL_DIR "/dbus/ut-connection/ut-dbus.conf", + "--config-file=" VSM_TEST_CONFIG_INSTALL_DIR "/dbus/ut-dbus.conf", "--nofork", NULL }; diff --git a/tests/unit_tests/lxc/templates/CMakeLists.txt b/tests/unit_tests/lxc/templates/CMakeLists.txt deleted file mode 100644 index c7b98c5..0000000 --- a/tests/unit_tests/lxc/templates/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved -# -# 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. -# -# -# @file -# @author Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com) -# - -FILE(GLOB ZONE_TEMPLATES *.sh) - -INSTALL(PROGRAMS ${ZONE_TEMPLATES} - DESTINATION ${VSM_TEST_TEMPLATES_INSTALL_DIR}) diff --git a/tests/unit_tests/lxc/templates/minimal.sh b/tests/unit_tests/lxc/templates/minimal.sh deleted file mode 100755 index 0450d1a..0000000 --- a/tests/unit_tests/lxc/templates/minimal.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash - -echo UnitTest LXC template, args: $@ - -options=$(getopt -o p:n: -l rootfs:,path:,name: -- "$@") -if [ $? -ne 0 ]; then - exit 1 -fi -eval set -- "$options" - -while true -do - case "$1" in - -p|--path) path=$2; shift 2;; - --rootfs) rootfs=$2; shift 2;; - -n|--name) name=$2; shift 2;; - --) shift 1; break ;; - *) break ;; - esac -done - -# Prepare zone rootfs -ROOTFS_DIRS="\ -${rootfs}/bin \ -${rootfs}/dev \ -${rootfs}/dev/pts \ -${rootfs}/etc \ -${rootfs}/home \ -${rootfs}/lib \ -${rootfs}/lib64 \ -${rootfs}/proc \ -${rootfs}/root \ -${rootfs}/run \ -${rootfs}/sbin \ -${rootfs}/sys \ -${rootfs}/tmp \ -${rootfs}/usr \ -${rootfs}/opt -" -/bin/mkdir ${ROOTFS_DIRS} - -# Prepare zone configuration file -> ${path}/config -cat <> ${path}/config -lxc.utsname = ${name} -lxc.rootfs = ${rootfs} - -# userns 1-to-1 mapping -lxc.id_map = u 0 0 65536 -lxc.id_map = g 0 0 65536 - -lxc.haltsignal = SIGTERM - -lxc.pts = 256 -lxc.tty = 0 - -#lxc.loglevel = TRACE -#lxc.logfile = /tmp/${name}.log - -lxc.cgroup.devices.deny = a - -lxc.mount.auto = proc sys cgroup -lxc.mount.entry = /bin bin none ro,bind 0 0 -lxc.mount.entry = /etc etc none ro,bind 0 0 -lxc.mount.entry = /lib lib none ro,bind 0 0 -lxc.mount.entry = /sbin sbin none ro,bind 0 0 -lxc.mount.entry = /usr usr none ro,rbind 0 0 -lxc.mount.entry = /opt opt none ro,rbind 0 0 -EOF - -if [ "$(uname -m)" = "x86_64" ]; then -cat <> $path/config -lxc.mount.entry = /lib64 lib64 none ro,bind 0 0 -EOF -fi - diff --git a/tests/unit_tests/server/configs/CMakeLists.txt b/tests/unit_tests/server/configs/CMakeLists.txt deleted file mode 100644 index a91d5d8..0000000 --- a/tests/unit_tests/server/configs/CMakeLists.txt +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved -# -# 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. -# -# -# @file CMakeLists.txt -# @author Jan Olszak (j.olszak@samsung.com) -# - -MESSAGE(STATUS "Installing configs for the Server Unit Tests to " ${VSM_TEST_CONFIG_INSTALL_DIR}) - -FILE(GLOB server_manager_CONF ut-server/*.conf) -FILE(GLOB server_templates_CONF ut-server/templates/*.conf) - -FILE(GLOB manager_manager_CONF ut-zones-manager/*.conf) -FILE(GLOB manager_templates_CONF ut-zones-manager/templates/*.conf) - -FILE(GLOB zone_CONF ut-zone/*.conf) -FILE(GLOB zone_templates_CONF ut-zone/templates/*.conf) - -FILE(GLOB zone_provision_CONF ut-zone-provision/*.conf) - -FILE(GLOB admin_templates_CONF ut-zone-admin/templates/*.conf) - - -## Generate #################################################################### -CONFIGURE_FILE(ut-server/test-daemon.conf.in - ${CMAKE_BINARY_DIR}/ut-server/test-daemon.conf @ONLY) -FILE(GLOB server_manager_CONF_GEN ${CMAKE_BINARY_DIR}/ut-server/*.conf) - -CONFIGURE_FILE(ut-zone/templates/test-dbus.conf.in - ${CMAKE_BINARY_DIR}/ut-zone/templates/test-dbus.conf @ONLY) -FILE(GLOB zone_templates_CONF_GEN ${CMAKE_BINARY_DIR}/ut-zone/templates/*.conf) - -CONFIGURE_FILE(ut-zones-manager/test-daemon.conf.in - ${CMAKE_BINARY_DIR}/ut-zones-manager/test-daemon.conf @ONLY) -FILE(GLOB manager_manager_CONF_GEN ${CMAKE_BINARY_DIR}/ut-zones-manager/*.conf) - -FILE(GLOB manager_templates_CONF_GEN ${CMAKE_BINARY_DIR}/ut-zones-manager/templates/*.conf) - - -## Install ##################################################################### -INSTALL(FILES ${server_manager_CONF} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-server) -INSTALL(FILES ${server_manager_CONF_GEN} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-server) -INSTALL(FILES ${server_templates_CONF} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-server/templates) - -INSTALL(FILES ${manager_manager_CONF} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager) -INSTALL(FILES ${manager_manager_CONF_GEN} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager) -INSTALL(FILES ${manager_templates_CONF} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager/templates) -INSTALL(FILES ${manager_templates_CONF_GEN} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager/templates) - -INSTALL(FILES ${zone_CONF} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone) -INSTALL(FILES ${zone_templates_CONF} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone/templates) -INSTALL(FILES ${zone_templates_CONF_GEN} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone/templates) - -INSTALL(FILES ${zone_provision_CONF} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone-provision) - -INSTALL(FILES ${admin_templates_CONF} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone-admin/templates) - -INSTALL(FILES dbus-1/system.d/org.tizen.vasum.tests.conf - DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d/) diff --git a/tests/unit_tests/server/configs/ut-server/templates/default.conf b/tests/unit_tests/server/configs/ut-server/templates/default.conf deleted file mode 100644 index 646fcb1..0000000 --- a/tests/unit_tests/server/configs/ut-server/templates/default.conf +++ /dev/null @@ -1,18 +0,0 @@ -{ - "zoneTemplate" : "minimal.sh", - "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], - "requestedState" : "running", - "ipv4Gateway" : "", - "ipv4" : "", - "privilege" : 20, - "vt" : -1, - "switchToDefaultAfterTimeout" : true, - "cpuQuotaForeground" : -1, - "cpuQuotaBackground" : 1000, - "shutdownTimeout" : 10, - "runMountPoint" : "", - "provisions" : [], - "permittedToSend" : [], - "permittedToRecv" : [], - "validLinkPrefixes" : [] -} diff --git a/tests/unit_tests/server/configs/ut-server/test-daemon.conf.in b/tests/unit_tests/server/configs/ut-server/test-daemon.conf.in deleted file mode 100644 index 1d59bdc..0000000 --- a/tests/unit_tests/server/configs/ut-server/test-daemon.conf.in +++ /dev/null @@ -1,17 +0,0 @@ -{ - "dbPath" : "/tmp/ut-zones/vasum.db", - "zoneIds" : [], - "zonesPath" : "/tmp/ut-zones", - "zoneImagePath" : "", - "zoneTemplateDir" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-server/templates/", - "runMountPointPrefix" : "", - "defaultId" : "", - "zoneTemplatePrefix" : "@VSM_TEST_TEMPLATES_INSTALL_DIR@", - "availableVTs" : [], - "inputConfig" : {"enabled" : false, - "device" : "gpio-keys.4", - "code" : 139, - "numberOfEvents" : 2, - "timeWindowMs" : 500}, - "proxyCallRules" : [] -} diff --git a/tests/unit_tests/server/configs/ut-zone-admin/templates/test.conf b/tests/unit_tests/server/configs/ut-zone-admin/templates/test.conf deleted file mode 100644 index fea418d..0000000 --- a/tests/unit_tests/server/configs/ut-zone-admin/templates/test.conf +++ /dev/null @@ -1,18 +0,0 @@ -{ - "zoneTemplate" : "minimal.sh", - "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], - "requestedState" : "running", - "ipv4Gateway" : "", - "ipv4" : "", - "privilege" : 10, - "vt" : -1, - "switchToDefaultAfterTimeout" : true, - "cpuQuotaForeground" : -1, - "cpuQuotaBackground" : 1000, - "shutdownTimeout" : 10, - "runMountPoint" : "", - "provisions" : [], - "permittedToSend" : [], - "permittedToRecv" : [], - "validLinkPrefixes" : [] -} diff --git a/tests/unit_tests/server/configs/ut-zone/templates/test-dbus.conf.in b/tests/unit_tests/server/configs/ut-zone/templates/test-dbus.conf.in deleted file mode 100644 index 0dd101a..0000000 --- a/tests/unit_tests/server/configs/ut-zone/templates/test-dbus.conf.in +++ /dev/null @@ -1,18 +0,0 @@ -{ - "zoneTemplate" : "minimal-dbus.sh", - "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zone/ut-dbus.conf --fork; read"], - "requestedState" : "running", - "ipv4Gateway" : "", - "ipv4" : "", - "privilege" : 10, - "vt" : -1, - "switchToDefaultAfterTimeout" : true, - "cpuQuotaForeground" : -1, - "cpuQuotaBackground" : 1000, - "shutdownTimeout" : 10, - "runMountPoint" : "/tmp/ut-run/zoneId", - "provisions" : [], - "permittedToSend" : [], - "permittedToRecv" : [], - "validLinkPrefixes" : [] -} diff --git a/tests/unit_tests/server/configs/ut-zone/ut-dbus.conf b/tests/unit_tests/server/configs/ut-zone/ut-dbus.conf deleted file mode 100644 index 2e0488d..0000000 --- a/tests/unit_tests/server/configs/ut-zone/ut-dbus.conf +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - custom - unix:path=/var/run/dbus/system_bus_socket - - - - - - - - - - diff --git a/tests/unit_tests/server/configs/ut-zones-manager/templates/console.conf b/tests/unit_tests/server/configs/ut-zones-manager/templates/console.conf deleted file mode 100644 index 2537e16..0000000 --- a/tests/unit_tests/server/configs/ut-zones-manager/templates/console.conf +++ /dev/null @@ -1,18 +0,0 @@ -{ - "zoneTemplate" : "minimal.sh", - "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], - "requestedState" : "running", - "ipv4Gateway" : "", - "ipv4" : "", - "privilege" : 20, - "vt" : -1, - "switchToDefaultAfterTimeout" : true, - "cpuQuotaForeground" : -1, - "cpuQuotaBackground" : 1000, - "shutdownTimeout" : 10, - "runMountPoint" : "", - "provisions" : [], - "permittedToSend" : [ "/tmp/.*" ], - "permittedToRecv" : [ "/tmp/.*" ], - "validLinkPrefixes" : [] -} diff --git a/tests/unit_tests/server/configs/ut-zones-manager/test-daemon.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/test-daemon.conf.in deleted file mode 100644 index a388e6d..0000000 --- a/tests/unit_tests/server/configs/ut-zones-manager/test-daemon.conf.in +++ /dev/null @@ -1,22 +0,0 @@ -{ - "dbPath" : "/tmp/ut-zones/vasum.db", - "zoneIds" : [], - "defaultId" : "", - "zonesPath" : "/tmp/ut-zones", - "zoneImagePath" : "", - "zoneTemplateDir" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/templates/", - "runMountPointPrefix" : "", - "zoneTemplatePrefix" : "@VSM_TEST_TEMPLATES_INSTALL_DIR@", - "availableVTs" : [], - "inputConfig" : {"enabled" : false, - "device" : "/dev/doesnotexist", - "code" : 139, - "numberOfEvents" : 2, - "timeWindowMs" : 500}, - "proxyCallRules" : [{"caller" : "*", - "target" : "*", - "targetBusName" : "org.tizen.vasum.tests", - "targetObjectPath" : "*", - "targetInterface" : "*", - "targetMethod" : "*"}] -} diff --git a/tests/unit_tests/server/ut-server.cpp b/tests/unit_tests/server/ut-server.cpp index 600b271..af6d5ca 100644 --- a/tests/unit_tests/server/ut-server.cpp +++ b/tests/unit_tests/server/ut-server.cpp @@ -44,7 +44,7 @@ using namespace config; namespace { -const std::string CONFIG_DIR = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-server"; +const std::string CONFIG_DIR = VSM_TEST_CONFIG_INSTALL_DIR; const std::string TEST_CONFIG_PATH = CONFIG_DIR + "/test-daemon.conf"; const std::string MISSING_CONFIG_PATH = CONFIG_DIR + "/missing-daemon.conf"; const std::string TEMPLATE_NAME = "default"; diff --git a/tests/unit_tests/server/ut-zone-admin.cpp b/tests/unit_tests/server/ut-zone-admin.cpp index 72bc2e6..faee59a 100644 --- a/tests/unit_tests/server/ut-zone-admin.cpp +++ b/tests/unit_tests/server/ut-zone-admin.cpp @@ -37,13 +37,12 @@ using namespace vasum; namespace { -const std::string TEMPLATES_DIR = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone-admin/templates"; -const std::string TEST_CONFIG_PATH = TEMPLATES_DIR + "/test.conf"; +const std::string TEMPLATES_DIR = VSM_TEST_TEMPLATES_INSTALL_DIR; +const std::string TEST_CONFIG_PATH = TEMPLATES_DIR + "/default.conf"; const std::string TEST_NO_SHUTDOWN_CONFIG_PATH = TEMPLATES_DIR + "/test-no-shutdown.conf"; -const std::string BUGGY_CONFIG_PATH = TEMPLATES_DIR + "/buggy.conf"; +const std::string BUGGY_CONFIG_PATH = TEMPLATES_DIR + "/buggy-init.conf"; const std::string MISSING_CONFIG_PATH = TEMPLATES_DIR + "/missing.conf"; const std::string ZONES_PATH = "/tmp/ut-zones"; -const std::string TEMPLATES_PATH = VSM_TEST_TEMPLATES_INSTALL_DIR; struct Fixture { utils::ScopedGlibLoop mLoop; @@ -62,7 +61,7 @@ struct Fixture { config::loadFromJsonFile(configPath, mDynamicConfig); return std::unique_ptr(new ZoneAdmin("zoneId", ZONES_PATH, - TEMPLATES_PATH, + TEMPLATES_DIR, mConfig, mDynamicConfig)); } diff --git a/tests/unit_tests/server/ut-zone-provision.cpp b/tests/unit_tests/server/ut-zone-provision.cpp index 65a5b91..45a74d7 100644 --- a/tests/unit_tests/server/ut-zone-provision.cpp +++ b/tests/unit_tests/server/ut-zone-provision.cpp @@ -49,10 +49,9 @@ namespace fs = boost::filesystem; namespace { -const std::string TEST_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone-provision/test.conf"; +const std::string TEST_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/provision/test-provision.conf"; const std::string ZONE = "ut-zone-provision-test"; const fs::path ZONES_PATH = "/tmp/ut-zones"; -const fs::path TEMPLATES_PATH = VSM_TEST_TEMPLATES_INSTALL_DIR; const fs::path ZONE_PATH = ZONES_PATH / fs::path(ZONE); const fs::path SOME_FILE_PATH = ZONE_PATH / "file.txt"; const fs::path ROOTFS_PATH = ZONE_PATH / "rootfs"; diff --git a/tests/unit_tests/server/ut-zone.cpp b/tests/unit_tests/server/ut-zone.cpp index 755aa52..abc10dc 100644 --- a/tests/unit_tests/server/ut-zone.cpp +++ b/tests/unit_tests/server/ut-zone.cpp @@ -52,13 +52,12 @@ using namespace config; namespace { -const std::string TEMPLATES_DIR = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone/templates"; -const std::string TEST_CONFIG_PATH = TEMPLATES_DIR + "/test.conf"; -const std::string TEST_DBUS_CONFIG_PATH = TEMPLATES_DIR + "/test-dbus.conf"; -const std::string BUGGY_CONFIG_PATH = TEMPLATES_DIR + "/buggy.conf"; -const std::string MISSING_CONFIG_PATH = TEMPLATES_DIR + "/missing.conf"; +const std::string TEMPLATES_DIR = VSM_TEST_TEMPLATES_INSTALL_DIR; +const std::string TEST_CONFIG_PATH = TEMPLATES_DIR + "/default.conf"; +const std::string TEST_DBUS_CONFIG_PATH = TEMPLATES_DIR + "/console-dbus.conf"; +const std::string BUGGY_CONFIG_PATH = TEMPLATES_DIR + "/buggy-template.conf"; +const std::string MISSING_CONFIG_PATH = TEMPLATES_DIR + "/missing-config.conf"; const std::string ZONES_PATH = "/tmp/ut-zones"; -const std::string TEMPLATES_PATH = VSM_TEST_TEMPLATES_INSTALL_DIR; const std::string DB_PATH = ZONES_PATH + "/vasum.db"; const std::string BRIDGE_NAME = "brtest01"; const std::string ZONE_NETDEV = "netdevtest01"; @@ -89,7 +88,7 @@ struct Fixture { ZONES_PATH, configPath, DB_PATH, - TEMPLATES_PATH, + TEMPLATES_DIR, "")); } diff --git a/tests/unit_tests/server/ut-zones-manager.cpp b/tests/unit_tests/server/ut-zones-manager.cpp index f7a4351..f73e164 100644 --- a/tests/unit_tests/server/ut-zones-manager.cpp +++ b/tests/unit_tests/server/ut-zones-manager.cpp @@ -69,7 +69,7 @@ using namespace dbus; namespace { -const std::string CONFIG_DIR = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zones-manager"; +const std::string CONFIG_DIR = VSM_TEST_CONFIG_INSTALL_DIR; const std::string TEST_CONFIG_PATH = CONFIG_DIR + "/test-daemon.conf"; const std::string MISSING_CONFIG_PATH = CONFIG_DIR + "/missing-daemon.conf"; const int EVENT_TIMEOUT = 5000; @@ -81,7 +81,7 @@ const std::string FILE_CONTENT = "File content\n" "Line 2\n"; const std::string NON_EXISTANT_ZONE_ID = "NON_EXISTANT_ZONE_ID"; const std::string ZONES_PATH = "/tmp/ut-zones"; // the same as in daemon.conf -const std::string SIMPLE_TEMPLATE = "console"; +const std::string SIMPLE_TEMPLATE = "console-ipc"; #ifdef DBUS_CONNECTION /** diff --git a/tests/unit_tests/socket_test_service/configs/CMakeLists.txt b/tests/unit_tests/socket_test_service/configs/CMakeLists.txt deleted file mode 100644 index 17e79b9..0000000 --- a/tests/unit_tests/socket_test_service/configs/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved -# -# 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. -# -# -# @file CMakeLists.txt -# @author Lukasz Kostyra (l.kostyra@samsung.com) -# - -MESSAGE(STATUS "Installing configs for Vasum sycket test service to " ${VSM_TEST_CONFIG_INSTALL_DIR}) - -## Install ##################################################################### -INSTALL(FILES systemd/vasum-socket-test.socket - DESTINATION ${SYSTEMD_UNIT_DIR}) -INSTALL(FILES systemd/vasum-socket-test.service - DESTINATION ${SYSTEMD_UNIT_DIR}) diff --git a/tests/unit_tests/utils/configs/CMakeLists.txt b/tests/unit_tests/utils/configs/CMakeLists.txt deleted file mode 100644 index d408df0..0000000 --- a/tests/unit_tests/utils/configs/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved -# -# 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. -# -# -# @file CMakeLists.txt -# @author Lukasz Pawelczyk (l.pawelczyk@partner.samsung.com) -# - -MESSAGE(STATUS "Installing configs for the Utils Unit Tests to " ${VSM_TEST_CONFIG_INSTALL_DIR}) -FILE(GLOB fs_CONF ut-fs/*.txt) - - -## Install ##################################################################### -INSTALL(FILES ${fs_CONF} - DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/utils/ut-fs) diff --git a/tests/unit_tests/utils/ut-fs.cpp b/tests/unit_tests/utils/ut-fs.cpp index 2cc32d0..5881193 100644 --- a/tests/unit_tests/utils/ut-fs.cpp +++ b/tests/unit_tests/utils/ut-fs.cpp @@ -39,7 +39,7 @@ using namespace utils; namespace { const std::string TEST_PATH = "/tmp/ut-fsutils"; -const std::string REFERENCE_FILE_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/utils/ut-fs/file.txt"; +const std::string REFERENCE_FILE_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/utils/file.txt"; const std::string REFERENCE_FILE_CONTENT = "File content\n" "Line 1\n" "Line 2\n"; -- 2.7.4 From 2b62c2b2881eb5c654bd2c311a0a0a7af5daa355 Mon Sep 17 00:00:00 2001 From: Dariusz Michaluk Date: Mon, 18 May 2015 16:05:25 +0200 Subject: [PATCH 05/16] Replace brctl with ip (remove bridge-utils dependency) [Feature] N/A [Cause] N/A [Solution] N/A [Verification] Build, install, run server. Change-Id: I8acbaff403d611df82bbebaef5d6281defb2acf8 --- packaging/vasum.spec | 2 +- server/configs/templates/template.sh | 5 ++--- server/configs/templates/tizen-common-wayland.sh | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packaging/vasum.spec b/packaging/vasum.spec index 22a6363..11c1599 100644 --- a/packaging/vasum.spec +++ b/packaging/vasum.spec @@ -27,7 +27,7 @@ BuildRequires: pkgconfig(libsystemd-journal) BuildRequires: pkgconfig(libsystemd-daemon) BuildRequires: pkgconfig(sqlite3) Requires(post): libcap-tools -Requires: bridge-utils +Requires: iproute2 Requires: libjson >= 0.10 %description diff --git a/server/configs/templates/template.sh b/server/configs/templates/template.sh index 82cd0f9..945c434 100755 --- a/server/configs/templates/template.sh +++ b/server/configs/templates/template.sh @@ -61,10 +61,9 @@ EOF # prepare pre start hook > ${path}/pre-start.sh cat <> ${path}/pre-start.sh -if [ -z "\$(/usr/sbin/brctl show | /bin/grep -P "${br_name}\t")" ] +if [ -z "\$(/usr/sbin/ip show | /bin/grep -P "${br_name}\t")" ] then - /usr/sbin/brctl addbr ${br_name} - /usr/sbin/brctl setfd ${br_name} 0 + /usr/sbin/ip link add name ${br_name} type bridge /sbin/ifconfig ${br_name} ${ipv4_gateway} netmask 255.255.255.0 up fi if [ -z "\$(/usr/sbin/iptables -t nat -S | /bin/grep MASQUERADE)" ] diff --git a/server/configs/templates/tizen-common-wayland.sh b/server/configs/templates/tizen-common-wayland.sh index 48a2ff9..40e401c 100755 --- a/server/configs/templates/tizen-common-wayland.sh +++ b/server/configs/templates/tizen-common-wayland.sh @@ -277,10 +277,9 @@ EOF # Prepare zone hook files cat <>${path}/hooks/pre-start.sh -if [ -z "\$(/usr/sbin/brctl show | /bin/grep -P "${br_name}\t")" ] +if [ -z "\$(/usr/sbin/ip show | /bin/grep -P "${br_name}\t")" ] then - /usr/sbin/brctl addbr ${br_name} - /usr/sbin/brctl setfd ${br_name} 0 + /usr/sbin/ip link add name ${br_name} type bridge /sbin/ifconfig ${br_name} ${ipv4_gateway} netmask 255.255.255.0 up fi if [ -z "\$(/usr/sbin/iptables -t nat -S | /bin/grep MASQUERADE)" ] -- 2.7.4 From 800d16092d93c736d99dc067ebe5eaccb9fae084 Mon Sep 17 00:00:00 2001 From: Dariusz Michaluk Date: Tue, 19 May 2015 14:33:35 +0200 Subject: [PATCH 06/16] Fix ip command [Feature] N/A [Cause] N/A [Solution] N/A [Verification] Build, install, run server. Change-Id: Ic28e6ea45c80fc48934ee911f7f5cee68cfcbb87 --- server/configs/templates/template.sh | 2 +- server/configs/templates/tizen-common-wayland.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/configs/templates/template.sh b/server/configs/templates/template.sh index 945c434..3bcf528 100755 --- a/server/configs/templates/template.sh +++ b/server/configs/templates/template.sh @@ -61,7 +61,7 @@ EOF # prepare pre start hook > ${path}/pre-start.sh cat <> ${path}/pre-start.sh -if [ -z "\$(/usr/sbin/ip show | /bin/grep -P "${br_name}\t")" ] +if [ -z "\$(/usr/sbin/ip link show | /bin/grep -P "${br_name}:")" ] then /usr/sbin/ip link add name ${br_name} type bridge /sbin/ifconfig ${br_name} ${ipv4_gateway} netmask 255.255.255.0 up diff --git a/server/configs/templates/tizen-common-wayland.sh b/server/configs/templates/tizen-common-wayland.sh index 40e401c..5c57aff 100755 --- a/server/configs/templates/tizen-common-wayland.sh +++ b/server/configs/templates/tizen-common-wayland.sh @@ -277,7 +277,7 @@ EOF # Prepare zone hook files cat <>${path}/hooks/pre-start.sh -if [ -z "\$(/usr/sbin/ip show | /bin/grep -P "${br_name}\t")" ] +if [ -z "\$(/usr/sbin/ip link show | /bin/grep -P "${br_name}:")" ] then /usr/sbin/ip link add name ${br_name} type bridge /sbin/ifconfig ${br_name} ${ipv4_gateway} netmask 255.255.255.0 up -- 2.7.4 From 655ec72492d6a5aca52da056e1eb27484c720d16 Mon Sep 17 00:00:00 2001 From: Krzysztof Dynowski Date: Mon, 18 May 2015 15:05:57 +0200 Subject: [PATCH 07/16] Vasum wrapper #6, implement vsm_declare_*, add logs, missing functions [Bug/Feature] dummy implementation of vsm_declare_link,vsm_declare_file,vsm_declare_mount [Cause] N/A [Solution] #6 implement vsm_declare_link,vsm_declare_file,vsm_declare_mount [Verification] Build, install on target Change-Id: I522233d4b02a9af8d2c282e6a04cd96be85920df --- wrapper/wrapper.cpp | 289 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 207 insertions(+), 82 deletions(-) diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index c5eadbc..72eece3 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -55,7 +55,12 @@ static struct { int done; int glib_stop; -}wrap; +} wrap; + +extern "C" { +API void vsm_string_free(VsmString string); +API void vsm_array_string_free(VsmArrayString astring); +} #ifndef offsetof #define offsetof(type, memb) ((size_t)&((type *)0)->memb) @@ -70,7 +75,6 @@ static struct #define UNUSED(x) ((void)(x)) -#define vsm_error_t vsm_error_s #define vsm_attach_command_t vsm_attach_command_s #define vsm_attach_options_t vsm_attach_options_s #define vsm_zone_state_cb vsm_zone_state_changed_cb @@ -85,6 +89,7 @@ void wrapper_load(void) { Logger::setLogLevel(LogLevel::TRACE); Logger::setLogBackend(new SystemdJournalBackend()); + LOGI("wrapper_load"); init_wrapper(); } @@ -92,6 +97,7 @@ void wrapper_unload(void) { if (wrap.glib_stop) Client::vsm_stop_glib_loop(); wrap.glib_stop = 0; + LOGI("wrapper_unload"); } static void callcheck() @@ -104,7 +110,7 @@ void init_wrapper() if (wrap.done) return ; memset(&wrap,0,sizeof(wrap)); wrap.done = 1; - LOGS(""); + LOGS("WRAP:"); } static struct vsm_zone* wrap_vsm_zone(WrappedContext *w, VsmZone zone, bool create = false) @@ -197,7 +203,8 @@ static void init_context_wrap(WrappedContext *w) API vsm_context_h vsm_create_context(void) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); WrappedContext *w = new WrappedContext(); init_context_wrap(w); @@ -207,7 +214,8 @@ API vsm_context_h vsm_create_context(void) API int vsm_cleanup_context(vsm_context_h ctx) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); if (w->client != NULL) { delete w->client; @@ -250,18 +258,10 @@ API vsm_error_e vsm_last_error(struct vsm_context *ctx) return static_cast(-1); } -API const char *vsm_error_string(vsm_error_e error) -{ - LOGS(""); callcheck(); - if (error < 0 || error > VSM_MAX_ERROR) { - return NULL; - } - return vsm_error_strtab[error]; -} - API int vsm_get_poll_fd(struct vsm_context *ctx) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); UNUSED(w); //FIXME Client should create Dispatcher and pass to IPCConnection @@ -271,7 +271,8 @@ API int vsm_get_poll_fd(struct vsm_context *ctx) } API int vsm_enter_eventloop(struct vsm_context *ctx, int flags, int timeout) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); UNUSED(flags); UNUSED(timeout); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); @@ -284,7 +285,8 @@ API int vsm_enter_eventloop(struct vsm_context *ctx, int flags, int timeout) API int vsm_create_zone(struct vsm_context *ctx, const char *zone_name, const char *template_name, int flag) { - LOGS("create_zone " << zone_name); callcheck(); + LOGS("WRAP:create_zone " << zone_name); + callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); UNUSED(flag); //template_name = NULL; //template name not supported by libvasum-client @@ -298,7 +300,8 @@ API int vsm_create_zone(struct vsm_context *ctx, const char *zone_name, const ch API int vsm_destroy_zone(struct vsm_context *ctx, const char *zone_name, int force) { - LOGS("zone=" << zone_name); callcheck(); + LOGS("WRAP:zone=" << zone_name); + callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); UNUSED(force); if (!w->client) return VSM_ERROR_GENERIC; @@ -313,7 +316,8 @@ API int vsm_destroy_zone(struct vsm_context *ctx, const char *zone_name, int for API int vsm_start_zone(struct vsm_context *ctx, const char *zone_name) { - LOGS("zone=" << zone_name); callcheck(); + LOGS("WRAP:zone=" << zone_name); + callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); if (!w->client) return VSM_ERROR_GENERIC; VsmStatus st = w->client->vsm_start_zone(zone_name); @@ -322,7 +326,8 @@ API int vsm_start_zone(struct vsm_context *ctx, const char *zone_name) API int vsm_shutdown_zone(struct vsm_context *ctx, const char *zone_name, int force) { - LOGS("zone=" << zone_name); callcheck(); + LOGS("WRAP:zone=" << zone_name); + callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); UNUSED(force); if (!w->client) return VSM_ERROR_GENERIC; @@ -332,7 +337,8 @@ API int vsm_shutdown_zone(struct vsm_context *ctx, const char *zone_name, int fo API int vsm_lock_zone(struct vsm_context *ctx, const char *zone_name, int shutdown) { - LOGS("zone=" << zone_name); callcheck(); + LOGS("WRAP:zone=" << zone_name); + callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); UNUSED(shutdown); if (!w->client) return VSM_ERROR_GENERIC; @@ -342,7 +348,8 @@ API int vsm_lock_zone(struct vsm_context *ctx, const char *zone_name, int shutdo API int vsm_unlock_zone(struct vsm_context *ctx, const char *zone_name) { - LOGS("zone=" << zone_name); callcheck(); + LOGS("WRAP:zone=" << zone_name); + callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); if (!w->client) return VSM_ERROR_GENERIC; VsmStatus st = w->client->vsm_lock_zone(zone_name); @@ -351,7 +358,8 @@ API int vsm_unlock_zone(struct vsm_context *ctx, const char *zone_name) API int vsm_set_foreground(struct vsm_zone *zone) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); WrappedZone *w = container_of(zone, WrappedZone, vz); if (!w->client) return VSM_ERROR_GENERIC; VsmStatus st = w->client->vsm_set_active_zone(zone->name); @@ -380,7 +388,8 @@ API int vsm_attach_zone_wait(struct vsm_context *ctx, API int vsm_iterate_zone(struct vsm_context *ctx, void (*callback)(struct vsm_zone *zone, void *user_data), void *user_data) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); if (!w->client) return -VSM_ERROR_GENERIC; callback(ctx->root_zone, user_data); @@ -392,7 +401,8 @@ API int vsm_iterate_zone(struct vsm_context *ctx, void (*callback)(struct vsm_zo API struct vsm_zone *vsm_lookup_zone_by_name(struct vsm_context *ctx, const char *path) { - LOGS("name=" << path); callcheck(); + LOGS("WRAP:name=" << path); + callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); VsmZone zone; if (!w->client) return NULL; @@ -402,9 +412,11 @@ API struct vsm_zone *vsm_lookup_zone_by_name(struct vsm_context *ctx, const char return wrap_vsm_zone(w, zone, true); } +//supposed return ref to internal struct API struct vsm_zone *vsm_lookup_zone_by_pid(struct vsm_context *ctx, pid_t pid) { - LOGS("pid=" << pid); callcheck(); + LOGS("WRAP: pid=" << pid); + callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); VsmZone zone; VsmString id; @@ -420,22 +432,10 @@ API struct vsm_zone *vsm_lookup_zone_by_pid(struct vsm_context *ctx, pid_t pid) return wrap_vsm_zone(w, zone); } -API struct vsm_zone *vsm_lookup_zone_by_terminal_id(struct vsm_context *ctx, int terminal) -{ - LOGS("terminal=" << terminal); callcheck(); - WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); - VsmZone zone; - VsmString id; - if (!w->client) return NULL; - if (w->client->vsm_lookup_zone_by_terminal_id(terminal, &id) != VSMCLIENT_SUCCESS) - return NULL; - w->client->vsm_lookup_zone_by_id(id, &zone); - return wrap_vsm_zone(w, zone); -} -#if 0 API int vsm_add_state_changed_callback(struct vsm_context *ctx, vsm_zone_state_cb callback, void *user_data) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); VsmSubscriptionId subscriptionId; @@ -443,9 +443,10 @@ API int vsm_add_state_changed_callback(struct vsm_context *ctx, vsm_zone_state_c void { VsmZone zone; //TODO what are valid state, event + vsm_zone_state_t t=VSM_ZONE_STATE_RUNNING; UNUSED(dbusAddress); w->client->vsm_lookup_zone_by_id(id, &zone); - callback(wrap_vsm_zone(w, zone), data); + callback(wrap_vsm_zone(w, zone), t, data); }; w->client->vsm_add_state_callback(dbus_cb, user_data, &subscriptionId); return (int)subscriptionId; @@ -453,16 +454,18 @@ API int vsm_add_state_changed_callback(struct vsm_context *ctx, vsm_zone_state_c API int vsm_del_state_changed_callback(struct vsm_context *ctx, int handle) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); VsmSubscriptionId subscriptionId = (VsmSubscriptionId)handle; VsmStatus st = w->client->vsm_del_state_callback(subscriptionId); return wrap_error(st, w->client); } -#endif + API int vsm_grant_device(struct vsm_zone *dom, const char *name, uint32_t flags) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); WrappedZone *w = container_of(dom, WrappedZone, vz); const char *id = dom->name; VsmZone zone; @@ -473,7 +476,8 @@ API int vsm_grant_device(struct vsm_zone *dom, const char *name, uint32_t flags) API int vsm_revoke_device(struct vsm_zone *dom, const char *name) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); WrappedZone *w = container_of(dom, WrappedZone, vz); const char *id = dom->name; VsmStatus st = w->client->vsm_revoke_device(id, name); @@ -482,7 +486,8 @@ API int vsm_revoke_device(struct vsm_zone *dom, const char *name) API struct vsm_netdev *vsm_create_netdev(struct vsm_zone *zone, vsm_netdev_type_t type, const char *target, const char *netdev) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); UNUSED(zone); UNUSED(type); UNUSED(target); @@ -518,7 +523,8 @@ API struct vsm_netdev *vsm_create_netdev(struct vsm_zone *zone, vsm_netdev_type_ API int vsm_destroy_netdev(struct vsm_zone *zone, struct vsm_netdev *netdev) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); WrappedZone *w = container_of(zone, WrappedZone, vz); VsmStatus st = w->client->vsm_destroy_netdev(zone->name, netdev->name); @@ -534,7 +540,8 @@ API int vsm_destroy_netdev(struct vsm_zone *zone, struct vsm_netdev *netdev) API int vsm_iterate_netdev(struct vsm_zone *zone, void (*callback)(struct vsm_netdev *, void *user_data), void *user_data) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); WrappedZone *w = container_of(zone, WrappedZone, vz); for (auto nd : w->netdevs) { callback(&nd, user_data); @@ -544,7 +551,8 @@ API int vsm_iterate_netdev(struct vsm_zone *zone, void (*callback)(struct vsm_ne API struct vsm_netdev *vsm_lookup_netdev_by_name(struct vsm_zone *zone, const char *name) { - LOGS(""); callcheck(); + LOGS("WRAP:"); + callcheck(); WrappedZone *w = container_of(zone, WrappedZone, vz); VsmNetdev nd; VsmStatus st = w->client->vsm_lookup_netdev_by_name(zone->name, name, &nd); @@ -560,13 +568,65 @@ API struct vsm_netdev *vsm_lookup_netdev_by_name(struct vsm_zone *zone, const ch API int vsm_declare_file(struct vsm_context *ctx, vsm_fso_type_t ftype, const char *path, int flags, vsm_mode_t mode) { - LOGS(""); callcheck(); - UNUSED(ctx); - UNUSED(ftype); - UNUSED(path); - UNUSED(flags); - UNUSED(mode); - //TODO apply declare link for existing zones (and those created in the future, so must store paits source, target) + LOGS("WRAP:"); + callcheck(); +/* Old implementation is following: (but implemented in server) + args.oldpath = oldpath; + args.newpath = newpath; + ret = iterate_running_zone("/sys/fs/cgroup/cpuset/lxc", file_resource, &args); +*/ + WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); + VsmArrayString ids = NULL; + VsmFileType type; + switch (ftype) { + case VSM_FSO_TYPE_DIR: /**< Directoy type */ + type = VSMFILE_DIRECTORY; + break; + case VSM_FSO_TYPE_REG: /**< Regular file type */ + type = VSMFILE_REGULAR; + break; + case VSM_FSO_TYPE_FIFO: /**< Fifo file type */ + type = VSMFILE_FIFO; + break; + case VSM_FSO_TYPE_SOCK: /**< Socket file type */ + return VSM_ERROR_NONE; + case VSM_FSO_TYPE_DEV: /**< Device node type */ + return VSM_ERROR_NONE; + default: + return VSM_ERROR_NONE; + } + w->client->vsm_get_zone_ids(&ids); + if (ids != NULL) { + for (VsmString* id = ids; *id; ++id) { + VsmStatus st = w->client->vsm_declare_file(*id, type, path, (int32_t)flags, (mode_t)mode, NULL); + if (st != VSMCLIENT_SUCCESS) { + wrap_error(st, w->client); + } + } + } + vsm_array_string_free(ids); + return VSM_ERROR_NONE; +} + +API int vsm_declare_link(struct vsm_context *ctx, const char *source, const char *target) +{ + LOGS("WRAP:src=" << source << ", dst=" << target); + callcheck(); +/* Old implementation is following: (but implemented in server) + args.oldpath = oldpath; + args.newpath = newpath; + ret = iterate_running_zone("/sys/fs/cgroup/cpuset/lxc", link_resource, &args); +*/ + WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); + VsmArrayString ids = NULL; + w->client->vsm_get_zone_ids(&ids); + if (ids != NULL) + for (VsmString* id = ids; *id; ++id) { + VsmStatus st = w->client->vsm_declare_link(source, *id, target, NULL); + if (st != VSMCLIENT_SUCCESS) + wrap_error(st, w->client); + } + vsm_array_string_free(ids); return VSM_ERROR_NONE; } @@ -577,54 +637,119 @@ API int vsm_declare_mount(struct vsm_context *ctx, unsigned long flags, const void *data) { - LOGS(""); callcheck(); - UNUSED(ctx); - UNUSED(source); - UNUSED(target); - UNUSED(fstype); - UNUSED(flags); - UNUSED(data); - //TODO apply declare link for existing zones (and those created in the future, so must store paits source, target) - return VSM_ERROR_NONE; -} - -API int vsm_declare_link(struct vsm_context *ctx, const char *source, const char *target) -{ - LOGS("src=" << source << "dst=" << target); callcheck(); - UNUSED(ctx); - UNUSED(source); - UNUSED(target); - //TODO apply declare link for existing zones (and those created in the future, so must store paits source, target) + LOGS("WRAP:"); + callcheck(); +/* Old implementation is following: (but implemented in server) + args.oldpath = oldpath; + args.newpath = newpath; + ret = iterate_running_zone("/sys/fs/cgroup/cpuset/lxc", mount_resource, &args); +*/ + WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); + VsmArrayString ids = NULL; + w->client->vsm_get_zone_ids(&ids); + if (ids != NULL) { + for (VsmString* id = ids; *id; ++id) { + VsmStatus st = w->client->vsm_declare_mount(source, *id, target, fstype, flags, (const char *)data, NULL); + if (st != VSMCLIENT_SUCCESS) { + wrap_error(st, w->client); + } + } + } + vsm_array_string_free(ids); return VSM_ERROR_NONE; } -API int vsm_add_state_changed_callback(vsm_context_h /*ctx*/, vsm_zone_state_changed_cb /*callback*/, void * /*user_data*/) -{ - return VSM_ERROR_NONE; -} -API int vsm_del_state_changed_callback(vsm_context_h /*ctx*/, int /*id*/) -{ - return VSM_ERROR_NONE; -} API const char * vsm_get_zone_rootpath(vsm_zone_h /*zone*/) { + LOGS("WRAP:"); return NULL; } API const char * vsm_get_zone_name(vsm_zone_h /*zone*/) { + LOGS("WRAP:"); return NULL; } API int vsm_is_host_zone(vsm_zone_h /*zone*/) { + LOGS("WRAP:"); return VSM_ERROR_NONE; } API vsm_zone_h vsm_join_zone(vsm_zone_h /*zone*/) { + LOGS("WRAP:"); return NULL; } API int vsm_canonicalize_path(const char * /*input_path*/, char ** /*output_path*/) { + LOGS("WRAP:"); return VSM_ERROR_NONE; } +static int is_valid_context(void * /*v*/) +{ + return 1; +} +static const char *vsm_error_string_v0_34(struct vsm_context *ctx) +{ + vsm_error_e error = ctx->error; + if (error < 0 || error > VSM_MAX_ERROR) { + return NULL; + } + return vsm_error_strtab[error]; +} +static const char *vsm_error_string_v0_3_1(vsm_error_e error) +{ + if (error < 0 || error > VSM_MAX_ERROR) { + return NULL; + } + return vsm_error_strtab[error]; +} + +extern "C" { +// Note: incomaptible API, try support both +// API(v0.34) const char *vsm_error_string(struct vsm_context *ctx) +// API(v0.3.1) const char *vsm_error_string(vsm_error_e error) +API const char *vsm_error_string(vsm_error_e e) +{ + LOGS("WRAP:"); + callcheck(); + struct vsm_context *ctx=(struct vsm_context *)e; + if (is_valid_context(ctx)) { + return vsm_error_string_v0_34((struct vsm_context *)ctx); + } + else { + return vsm_error_string_v0_3_1(static_cast((int)ctx)); + } +} + +API struct vsm_zone *vsm_lookup_zone_by_terminal_id(struct vsm_context *ctx, int terminal) +{ + LOGS("WRAP:terminal=" << terminal); + callcheck(); + WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); + VsmZone zone; + VsmString id; + if (!w->client) return NULL; + if (w->client->vsm_lookup_zone_by_terminal_id(terminal, &id) != VSMCLIENT_SUCCESS) + return NULL; + w->client->vsm_lookup_zone_by_id(id, &zone); + return wrap_vsm_zone(w, zone); +} + +API void vsm_array_string_free(VsmArrayString astring) +{ + if (!astring) { + return; + } + for (char** ptr = astring; *ptr; ++ptr) { + vsm_string_free(*ptr); + } + free(astring); +} + +API void vsm_string_free(VsmString string) +{ + free(string); +} +} // extern "C" -- 2.7.4 From 27932ad509b7dda08344e62ba7fb5b1c1d71cc3d Mon Sep 17 00:00:00 2001 From: Lukasz Kostyra Date: Wed, 20 May 2015 11:30:54 +0200 Subject: [PATCH 08/16] Fix critical bug in environment.cpp [Bug] "Namespaced" word was misspelled in "passNamespacedFd" function declaration, definition and usage. Assuming someone does not use syntax recognition, it could case critical errors during compilation and a lot of confusion. [Cause] Author of passNamespacedFd function made a typo. [Solution] Replace "Nemaspaced" with correct version - "Namespaced". [Verification] Build, install, run tests. Change-Id: I3df106ee8e275210af43de572a9c69ba0a220a56 --- common/netlink/netlink.cpp | 2 +- common/utils/environment.cpp | 2 +- common/utils/environment.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/netlink/netlink.cpp b/common/netlink/netlink.cpp index 6dd0ae5..6d7be95 100644 --- a/common/netlink/netlink.cpp +++ b/common/netlink/netlink.cpp @@ -106,7 +106,7 @@ void Netlink::open(int netNsPid) LOGE("Can't open socket: " << getSystemErrorMessage()); } } else { - mFd = utils::passNemaspacedFd(netNsPid, CLONE_NEWNET, fdFactory); + mFd = utils::passNamespacedFd(netNsPid, CLONE_NEWNET, fdFactory); } if (mFd == -1) { throw VasumException("Can't open netlink connection"); diff --git a/common/utils/environment.cpp b/common/utils/environment.cpp index 7bd7d07..57b6e2a 100644 --- a/common/utils/environment.cpp +++ b/common/utils/environment.cpp @@ -218,7 +218,7 @@ bool joinToNs(int nsPid, int ns) return true; } -int passNemaspacedFd(int nsPid, int ns, const std::function& fdFactory) +int passNamespacedFd(int nsPid, int ns, const std::function& fdFactory) { int fds[2]; int ret = socketpair(PF_LOCAL, SOCK_RAW, 0, fds); diff --git a/common/utils/environment.hpp b/common/utils/environment.hpp index b4e3194..9039239 100644 --- a/common/utils/environment.hpp +++ b/common/utils/environment.hpp @@ -59,7 +59,7 @@ bool joinToNs(int nsPid, int ns); /** * Pass file descriptor from namespace of some process */ -int passNemaspacedFd(int nsPid, int ns, const std::function& fdFactory); +int passNamespacedFd(int nsPid, int ns, const std::function& fdFactory); } // namespace utils -- 2.7.4 From 88fa8ab69b1079df9eeabd8c1fa120c85db17978 Mon Sep 17 00:00:00 2001 From: Mateusz Malicki Date: Wed, 20 May 2015 10:58:50 +0200 Subject: [PATCH 09/16] Add libsystemd-daemon build dependencies [Bug] LibIpc need libsystemd-daemon [Cause] N/A [Solution] N/A [Verification] Build, install on target Change-Id: I6da84631ed75e80d8e0f417dd4aacdc51f797a11 --- client/CMakeLists.txt | 2 +- libs/ipc/CMakeLists.txt | 6 ++++-- packaging/vasum.spec | 4 ++-- server/CMakeLists.txt | 2 +- tests/unit_tests/CMakeLists.txt | 3 +-- wrapper/CMakeLists.txt | 2 +- zone-daemon/CMakeLists.txt | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 56ed2e7..c1fdd19 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -44,7 +44,7 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES ## Link libraries ############################################################## FIND_PACKAGE(Boost COMPONENTS system filesystem) -PKG_CHECK_MODULES(LIB_DEPS REQUIRED gio-2.0 libsystemd-daemon libcap-ng) +PKG_CHECK_MODULES(LIB_DEPS REQUIRED gio-2.0 libcap-ng) INCLUDE_DIRECTORIES(SYSTEM ${LIB_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${COMMON_FOLDER}) INCLUDE_DIRECTORIES(${LIBS_FOLDER}) diff --git a/libs/ipc/CMakeLists.txt b/libs/ipc/CMakeLists.txt index d760883..84bb812 100644 --- a/libs/ipc/CMakeLists.txt +++ b/libs/ipc/CMakeLists.txt @@ -49,10 +49,12 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES ) ## Link libraries ############################################################## +PKG_CHECK_MODULES(IPC_DEPS REQUIRED libsystemd-daemon) + INCLUDE_DIRECTORIES(${LIBS_FOLDER}) INCLUDE_DIRECTORIES(${COMMON_FOLDER}) -INCLUDE_DIRECTORIES(SYSTEM ${DBUS_DEPS_INCLUDE_DIRS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} Logger Config) +INCLUDE_DIRECTORIES(SYSTEM ${DBUS_DEPS_INCLUDE_DIRS} ${IPC_DEPS_INCLUDE_DIRS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${IPC_DEPS_LIBRARIES} Logger Config) ## Generate the pc file ######################################################## CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_CURRENT_BINARY_DIR}/${PC_FILE} @ONLY) diff --git a/packaging/vasum.spec b/packaging/vasum.spec index 11c1599..3b241df 100644 --- a/packaging/vasum.spec +++ b/packaging/vasum.spec @@ -23,8 +23,6 @@ BuildRequires: libjson-devel >= 0.10 BuildRequires: libcap-ng-devel BuildRequires: lxc-devel BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(libsystemd-journal) -BuildRequires: pkgconfig(libsystemd-daemon) BuildRequires: pkgconfig(sqlite3) Requires(post): libcap-tools Requires: iproute2 @@ -261,6 +259,7 @@ systemctl daemon-reload %package -n libLogger Summary: Logger library Group: Security/Other +BuildRequires: pkgconfig(libsystemd-journal) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -364,6 +363,7 @@ The package provides libConfig development tools and libs. %package -n libIpc Summary: IPC library Group: Security/Other +BuildRequires: pkgconfig(libsystemd-daemon) Requires: libConfig Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 6181e15..f9ce867 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -30,7 +30,7 @@ ADD_EXECUTABLE(${SERVER_CODENAME} ${project_SRCS} ${common_SRCS}) ## Link libraries ############################################################## FIND_PACKAGE(Boost COMPONENTS program_options system filesystem regex) -PKG_CHECK_MODULES(SERVER_DEPS REQUIRED lxc json gio-2.0 libsystemd-journal libsystemd-daemon libcap-ng) +PKG_CHECK_MODULES(SERVER_DEPS REQUIRED lxc json gio-2.0 libcap-ng) INCLUDE_DIRECTORIES(${COMMON_FOLDER}) INCLUDE_DIRECTORIES(${LIBS_FOLDER}) diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt index 452a54a..2b5a09e 100644 --- a/tests/unit_tests/CMakeLists.txt +++ b/tests/unit_tests/CMakeLists.txt @@ -47,8 +47,7 @@ ADD_EXECUTABLE(${SOCKET_TEST_CODENAME} ${socket_test_SRCS} ${common_SRCS} ${clie ## Link libraries ############################################################## FIND_PACKAGE (Boost COMPONENTS unit_test_framework system filesystem regex) -PKG_CHECK_MODULES(UT_SERVER_DEPS REQUIRED lxc json gio-2.0 libsystemd-daemon - libsystemd-journal libcap-ng) +PKG_CHECK_MODULES(UT_SERVER_DEPS REQUIRED lxc json gio-2.0 libcap-ng) INCLUDE_DIRECTORIES(${COMMON_FOLDER} ${SERVER_FOLDER} ${UNIT_TESTS_FOLDER} ${CLIENT_FOLDER} ${LIBS_FOLDER} ${SOCKET_TEST_FOLDER}) INCLUDE_DIRECTORIES(SYSTEM ${UT_SERVER_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) diff --git a/wrapper/CMakeLists.txt b/wrapper/CMakeLists.txt index 532e693..7f5ea46 100644 --- a/wrapper/CMakeLists.txt +++ b/wrapper/CMakeLists.txt @@ -51,7 +51,7 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES ## Link libraries ############################################################## FIND_PACKAGE(Boost COMPONENTS system filesystem) -PKG_CHECK_MODULES(LIB_DEPS REQUIRED gio-2.0 libsystemd-daemon libcap-ng) +PKG_CHECK_MODULES(LIB_DEPS REQUIRED gio-2.0 libcap-ng) INCLUDE_DIRECTORIES(SYSTEM ${LIB_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${COMMON_FOLDER}) INCLUDE_DIRECTORIES(${LIBS_FOLDER}) diff --git a/zone-daemon/CMakeLists.txt b/zone-daemon/CMakeLists.txt index e721dbf..4d48141 100644 --- a/zone-daemon/CMakeLists.txt +++ b/zone-daemon/CMakeLists.txt @@ -31,7 +31,7 @@ ADD_EXECUTABLE(${ZONE_DAEMON_CODENAME} ${project_SRCS} ${common_SRCS}) ## Link libraries ############################################################## FIND_PACKAGE (Boost COMPONENTS program_options system filesystem) -PKG_CHECK_MODULES(ZONE_DAEMON_DEPS REQUIRED gio-2.0 libsystemd-journal libcap-ng) +PKG_CHECK_MODULES(ZONE_DAEMON_DEPS REQUIRED gio-2.0 libcap-ng) INCLUDE_DIRECTORIES(${COMMON_FOLDER}) INCLUDE_DIRECTORIES(${LIBS_FOLDER}) -- 2.7.4 From 3d3322780ebd21cd989e3a8ef7b03e4b66e475bc Mon Sep 17 00:00:00 2001 From: Mateusz Malicki Date: Wed, 20 May 2015 11:03:39 +0200 Subject: [PATCH 10/16] Fix building on x86_64 [Bug] Removed unneeded cast [Cause] Lose precision cast [Solution] N/A [Verification] Build on x86_64 Change-Id: I2302eaefed4f0c94f29ad94468ff9d83fa15166e --- wrapper/wrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index 72eece3..9483a87 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -718,7 +718,7 @@ API const char *vsm_error_string(vsm_error_e e) return vsm_error_string_v0_34((struct vsm_context *)ctx); } else { - return vsm_error_string_v0_3_1(static_cast((int)ctx)); + return vsm_error_string_v0_3_1(e); } } -- 2.7.4 From c49644b6bebb9f8889abe8dc01f9b068b0ccd2fd Mon Sep 17 00:00:00 2001 From: Dariusz Michaluk Date: Wed, 20 May 2015 11:46:33 +0200 Subject: [PATCH 11/16] Add vsm_get_zone_rootpath API function [Bug/Feature] Introduce new API function: vsm_get_zone_rootpath [Cause] N/A [Solution] N/A [Verification] Build, install, run tests Change-Id: Ia4f9f6701f20d6a32878bf13c59a8ad9ade9a9bb --- client/vasum-client-impl.cpp | 12 ++++++++++++ client/vasum-client-impl.hpp | 5 +++++ client/vasum-client.cpp | 5 +++++ client/vasum-client.h | 11 +++++++++++ tests/unit_tests/client/ut-client.cpp | 17 +++++++++++++++++ 5 files changed, 50 insertions(+) diff --git a/client/vasum-client-impl.cpp b/client/vasum-client-impl.cpp index b9af36f..38e4c5a 100644 --- a/client/vasum-client-impl.cpp +++ b/client/vasum-client-impl.cpp @@ -241,6 +241,18 @@ VsmStatus Client::vsm_get_active_zone_id(VsmString* id) noexcept }); } +VsmStatus Client::vsm_get_zone_rootpath(const char* id, VsmString* rootpath) noexcept +{ + assert(id); + assert(rootpath); + + return coverException([&] { + api::ZoneInfoOut info; + mHostClient.callGetZoneInfo({ id }, info); + *rootpath = ::strdup(info.rootPath.c_str()); + }); +} + VsmStatus Client::vsm_lookup_zone_by_pid(int pid, VsmString* id) noexcept { assert(id); diff --git a/client/vasum-client-impl.hpp b/client/vasum-client-impl.hpp index 0b96149..86f7a5e 100644 --- a/client/vasum-client-impl.hpp +++ b/client/vasum-client-impl.hpp @@ -105,6 +105,11 @@ public: VsmStatus vsm_get_active_zone_id(VsmString* id) noexcept; /** + * @see ::vsm_get_zone_rootpath + */ + VsmStatus vsm_get_zone_rootpath(const char* id, VsmString* rootpath) noexcept; + + /** * @see ::vsm_lookup_zone_by_pid */ VsmStatus vsm_lookup_zone_by_pid(int pid, VsmString* id) noexcept; diff --git a/client/vasum-client.cpp b/client/vasum-client.cpp index c12e8c6..b1028e2 100644 --- a/client/vasum-client.cpp +++ b/client/vasum-client.cpp @@ -133,6 +133,11 @@ API VsmStatus vsm_get_active_zone_id(VsmClient client, VsmString* id) return getClient(client).vsm_get_active_zone_id(id); } +API VsmStatus vsm_get_zone_rootpath(VsmClient client, const char* id, VsmString* rootpath) +{ + return getClient(client).vsm_get_zone_rootpath(id, rootpath); +} + API VsmStatus vsm_lookup_zone_by_pid(VsmClient client, int pid, VsmString* id) { return getClient(client).vsm_lookup_zone_by_pid(pid, id); diff --git a/client/vasum-client.h b/client/vasum-client.h index 1d43094..6c68fe2 100644 --- a/client/vasum-client.h +++ b/client/vasum-client.h @@ -334,6 +334,17 @@ VsmStatus vsm_get_zone_ids(VsmClient client, VsmArrayString* array); VsmStatus vsm_get_active_zone_id(VsmClient client, VsmString* id); /** + * Get zone rootfs path. + * + * @param[in] client vasum-server's client + * @param[in] id zone name + * @param[out] rootpath zone rootfs path + * @return status of this function call + * @remark Use @p vsm_string_free() to free memory occupied by @p rootpath. + */ +VsmStatus vsm_get_zone_rootpath(VsmClient client, const char* id, VsmString* rootpath); + +/** * Get zone name of process with given pid. * * @param[in] client vasum-server's client diff --git a/tests/unit_tests/client/ut-client.cpp b/tests/unit_tests/client/ut-client.cpp index 328a5bd..3e83884 100644 --- a/tests/unit_tests/client/ut-client.cpp +++ b/tests/unit_tests/client/ut-client.cpp @@ -167,6 +167,23 @@ BOOST_AUTO_TEST_CASE(GetActiveZoneId) vsm_client_free(client); } +BOOST_AUTO_TEST_CASE(GetZoneRootPath) +{ + const std::string zoneId = "zone1"; + + VsmClient client = vsm_client_create(); + VsmStatus status = vsm_connect(client); + BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status); + VsmString rootpath; + status = vsm_get_zone_rootpath(client, zoneId.c_str(), &rootpath); + BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status); + + BOOST_CHECK_EQUAL(rootpath, "/tmp/ut-zones/" + zoneId + "/rootfs"); + + vsm_string_free(rootpath); + vsm_client_free(client); +} + BOOST_AUTO_TEST_CASE(LookupZoneById) { const std::string activeZoneId = "zone1"; -- 2.7.4 From 13d3aa32753860aa97f66d5641c81b0d00c83ae5 Mon Sep 17 00:00:00 2001 From: Mateusz Malicki Date: Thu, 21 May 2015 16:12:53 +0200 Subject: [PATCH 12/16] Fix IPCSuite/WriteTimeout [Bug] IPCSuite/WriteTimeout some time fails [Cause] To large write timeout and too small response time - checking timeout when response has already been callSync only sometimes takes into account the serialization time [Solution] Increase response time. Wait for sending till timeout countdown start [Verification] Build, install on emulator, run IPCSuite/WriteTimeout test (multiple times) Change-Id: Ic9e814a0ae5cb85a769f0398d5126b0b67f5c626 --- libs/ipc/internals/processor.hpp | 27 ++++++++++++++++++++++----- tests/unit_tests/ipc/ut-ipc.cpp | 11 ++++++++++- tests/unit_tests/ut.cpp | 2 ++ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/libs/ipc/internals/processor.hpp b/libs/ipc/internals/processor.hpp index ecc3a1d..b1b0a5f 100644 --- a/libs/ipc/internals/processor.hpp +++ b/libs/ipc/internals/processor.hpp @@ -442,6 +442,12 @@ private: unsigned int mMaxNumberOfPeers; template + MessageID callAsyncInternal(const MethodID methodID, + const PeerID peerID, + const std::shared_ptr& data, + const typename ResultHandler::type& process); + + template void setMethodHandlerInternal(const MethodID methodID, const typename MethodHandler::type& process); @@ -597,6 +603,15 @@ MessageID Processor::callAsync(const MethodID methodID, const typename ResultHandler::type& process) { Lock lock(mStateMutex); + return callAsyncInternal(methodID, peerID, data, process); +} + +template +MessageID Processor::callAsyncInternal(const MethodID methodID, + const PeerID peerID, + const std::shared_ptr& data, + const typename ResultHandler::type& process) +{ auto request = MethodRequest::create(methodID, peerID, data, process); mRequestQueue.pushBack(Event::METHOD, request); return request->messageID; @@ -618,17 +633,19 @@ std::shared_ptr Processor::callSync(const MethodID methodID, cv.notify_all(); }; - MessageID messageID = callAsync(methodID, - peerID, - data, - process); + Lock lock(mStateMutex); + MessageID messageID = callAsyncInternal(methodID, + peerID, + data, + process); auto isResultInitialized = [&result]() { return result.isValid(); }; - Lock lock(mStateMutex); LOGT(mLogPrefix + "Waiting for the response..."); + //In the case of too large sending time response can be received far after timeoutMS but + //before this thread wakes up and before predicate check (there will by no timeout exception) if (!cv.wait_for(lock, std::chrono::milliseconds(timeoutMS), isResultInitialized)) { LOGW(mLogPrefix + "Probably a timeout in callSync. Checking..."); diff --git a/tests/unit_tests/ipc/ut-ipc.cpp b/tests/unit_tests/ipc/ut-ipc.cpp index e71a160..958f1f2 100644 --- a/tests/unit_tests/ipc/ut-ipc.cpp +++ b/tests/unit_tests/ipc/ut-ipc.cpp @@ -180,6 +180,15 @@ void longEchoCallback(const PeerID, methodResult->set(returnData); } +void shortEchoCallback(const PeerID, + std::shared_ptr& data, + MethodResult::Pointer methodResult) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(SHORT_OPERATION_TIME)); + auto returnData = std::make_shared(data->intVal); + methodResult->set(returnData); +} + PeerID connect(Service& s, Client& c) { // Connects the Client to the Service and returns Clients PeerID @@ -497,7 +506,7 @@ MULTI_FIXTURE_TEST_CASE(ReadTimeout, F, ThreadedFixture, GlibFixture) MULTI_FIXTURE_TEST_CASE(WriteTimeout, F, ThreadedFixture, GlibFixture) { Service s(F::getPoll(), SOCKET_PATH); - s.setMethodHandler(1, echoCallback); + s.setMethodHandler(1, shortEchoCallback); s.start(); Client c(F::getPoll(), SOCKET_PATH); diff --git a/tests/unit_tests/ut.cpp b/tests/unit_tests/ut.cpp index bb45e84..718bd2c 100644 --- a/tests/unit_tests/ut.cpp +++ b/tests/unit_tests/ut.cpp @@ -30,6 +30,7 @@ #include +#include "utils/signal.hpp" using namespace boost::unit_test; using namespace logger; @@ -39,5 +40,6 @@ test_suite* init_unit_test_suite(int /*argc*/, char** /*argv*/) Logger::setLogLevel(LogLevel::TRACE); Logger::setLogBackend(new StderrBackend()); + utils::signalBlock(SIGPIPE); return NULL; } -- 2.7.4 From d4d3a18185664a406b86719d541becd5e1d439ee Mon Sep 17 00:00:00 2001 From: Mateusz Malicki Date: Thu, 21 May 2015 17:05:16 +0200 Subject: [PATCH 13/16] Fix SwitchToDefault and AllowSwitchToDefault [Bug] SwitchToDefault and AllowSwitchToDefault some times fails [Cause] Signal handler are not set [Solution] Ensure signal handler propagate (wait) [Verification] Build, install on emulator, run ZonesManagerSuite/SwitchToDefault and ZonesManagerSuite/AllowSwitchToDefault tests (multiple times) Change-Id: I3c9c2549903cebcc30496af3ccb427c1186d1b23 --- tests/unit_tests/server/ut-zones-manager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit_tests/server/ut-zones-manager.cpp b/tests/unit_tests/server/ut-zones-manager.cpp index f73e164..0283fd9 100644 --- a/tests/unit_tests/server/ut-zones-manager.cpp +++ b/tests/unit_tests/server/ut-zones-manager.cpp @@ -73,6 +73,7 @@ const std::string CONFIG_DIR = VSM_TEST_CONFIG_INSTALL_DIR; const std::string TEST_CONFIG_PATH = CONFIG_DIR + "/test-daemon.conf"; const std::string MISSING_CONFIG_PATH = CONFIG_DIR + "/missing-daemon.conf"; const int EVENT_TIMEOUT = 5000; +const int SIGNAL_PROPAGATE_TIME = 500; // ms //const int UNEXPECTED_EVENT_TIMEOUT = EVENT_TIMEOUT / 5; const std::string TEST_APP_NAME = "testapp"; const std::string TEST_MESSAGE = "testmessage"; @@ -870,6 +871,7 @@ MULTI_FIXTURE_TEST_CASE(SwitchToDefault, F, ACCESSORS) cm.restoreAll(); typename F::HostAccessory host; + std::this_thread::sleep_for(std::chrono::milliseconds(SIGNAL_PROPAGATE_TIME)); auto isDefaultFocused = [&cm]() -> bool { return cm.getRunningForegroundZoneId() == "zone1"; @@ -892,6 +894,7 @@ MULTI_FIXTURE_TEST_CASE(AllowSwitchToDefault, F, ACCESSORS) cm.restoreAll(); typename F::HostAccessory host; + std::this_thread::sleep_for(std::chrono::milliseconds(SIGNAL_PROPAGATE_TIME)); auto isDefaultFocused = [&cm]() -> bool { return cm.getRunningForegroundZoneId() == "zone1"; -- 2.7.4 From 8118a30e23585d04c92e30aa67b8b716a51400f5 Mon Sep 17 00:00:00 2001 From: Krzysztof Dynowski Date: Wed, 20 May 2015 17:41:52 +0200 Subject: [PATCH 14/16] Vasum wrapper #7, add functions introduced in last vasum old API, link to Ipc [Bug/Feature] latest image not works with wrapper [Cause] last vasum old API introduced new functions [Solution] #7 implement those new functions [Verification] Build, install on target, check journal Change-Id: I95d46157d419e0886beb00574bc94a1bfe316677 --- wrapper/CMakeLists.txt | 2 +- wrapper/wrapper-compatibility.cpp | 235 +++++++++++++--------------------- wrapper/wrapper.cpp | 257 ++++++++++++++++++++++++-------------- 3 files changed, 249 insertions(+), 245 deletions(-) diff --git a/wrapper/CMakeLists.txt b/wrapper/CMakeLists.txt index 7f5ea46..a75bfa9 100644 --- a/wrapper/CMakeLists.txt +++ b/wrapper/CMakeLists.txt @@ -58,7 +58,7 @@ INCLUDE_DIRECTORIES(${LIBS_FOLDER}) INCLUDE_DIRECTORIES(${SERVER_FOLDER}) INCLUDE_DIRECTORIES(${CLIENT_FOLDER}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_DEPS_LIBRARIES} ${Boost_LIBRARIES} - Config SimpleDbus) + Config SimpleDbus Ipc) ## Generate the pc file ######################################################## CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_BINARY_DIR}/${PC_FILE} @ONLY) diff --git a/wrapper/wrapper-compatibility.cpp b/wrapper/wrapper-compatibility.cpp index adb1edd..303fcfe 100644 --- a/wrapper/wrapper-compatibility.cpp +++ b/wrapper/wrapper-compatibility.cpp @@ -39,167 +39,66 @@ #include #include #include +#include #include #include +#include "logger/logger.hpp" +#include "logger/logger-scope.hpp" + #define UNUSED(x) ((void)(x)) extern "C" { // find_container_by_pid API char *find_container_by_pid(pid_t /*pid*/) { + LOGS(""); return NULL; } // get_domain_pid API pid_t get_domain_pid(const char * /*name*/, const char * /*target*/) { + LOGS(""); return -1; } -// mainloop_add_watch -int mainloop_add_watch(struct mainloop * /*mainloop*/, int /*fd*/, mainloop_event /*event*/, mainloop_callback /*callback*/, void * /*data*/) { - return 0; -} -// mainloop_cleanup -int mainloop_cleanup(struct mainloop * /*mainloop*/) { - return 0; -} -// mainloop_create -struct mainloop *mainloop_create(void) { - struct mainloop *mainloop = (struct mainloop *)malloc(sizeof(struct mainloop)); - mainloop->epfd = -1; // epoll_create(2); - pthread_mutex_init(&mainloop->ml_mutex, NULL); - pthread_rwlock_init(&mainloop->lock, NULL); - adt_init_list(&mainloop->watches); - return mainloop; -} -// mainloop_dispatch -int mainloop_dispatch(struct mainloop * /*mainloop*/, int /*timeout*/) { - return 0; -} -// mainloop_remove_watch -int mainloop_remove_watch(struct mainloop * /*mainloop*/, int /*fd*/) { - return 0; -} -// mainloop_run -int mainloop_run(struct mainloop * /*mainloop*/, int /*timeout*/) { - return 0; -} -// mxe_alloc_endpoint -struct mxe_endpoint *mxe_alloc_endpoint(struct mxe_engine * /*engine*/, int /*fd*/, mainloop_callback /*callback*/, int /*type*/) { - return NULL; -} -// mxe_broadcast -int mxe_broadcast(struct mxe_engine * /*engine*/, struct mxe_emple * /*emple*/, ...) { - return 0; -} -// mxe_create_client -struct mxe_endpoint *mxe_create_client(struct mxe_engine *engine, const char * /*addr*/) { - struct mxe_endpoint *ep = (struct mxe_endpoint *)malloc(sizeof(struct mxe_endpoint)); - ep->type = 1; //MXE_EPT_SLAVE - ep->fd = -1; //sock_connect(addr); - ep->engine = engine; - pthread_rwlock_init(&ep->queue_lock, NULL); - pthread_mutex_init(&ep->rd_mutex, NULL); - pthread_mutex_init(&ep->wr_mutex, NULL); - adt_init_list(&ep->queue); - adt_init_list(&ep->list); - return ep; -} -// mxe_create_server -struct mxe_endpoint *mxe_create_server(struct mxe_engine * /*engine*/, const char * /*addr*/) { - return NULL; -} -// mxe_emple_factory -struct mxe_emple *mxe_emple_factory(struct mxe_proxy * /*proxy*/) { - return NULL; -} -// mxe_finalize_engine -int mxe_finalize_engine(struct mxe_engine * /*engine*/) { - return 0; -} -// mxe_free_endpoint -int mxe_free_endpoint(struct mxe_endpoint * /*ep*/) { - return 0; -} -// mxe_invoke -int mxe_invoke(struct mxe_endpoint * /*ep*/, struct mxe_emple * /*emple*/, ...) { - return 0; -} -// mxe_lookup_emple -struct mxe_emple *mxe_lookup_emple(struct mxe_endpoint * /*ep*/, int /*signature*/) { - return NULL; -} -// mxe_lookup_proxy -struct mxe_proxy *mxe_lookup_proxy(struct mxe_engine * /*engine*/, int /*id*/) { - return NULL; -} -// mxe_pop_integer -int mxe_pop_integer(struct mxe_message * /*msg*/) { - return 0; -} -// mxe_pop_string -char *mxe_pop_string(struct mxe_message * /*msg*/) { - return NULL; -} -// mxe_prepare_engine -struct mxe_engine *mxe_prepare_engine(struct mainloop *mainloop, void *data) { - struct mxe_engine *engine = (struct mxe_engine *)malloc(sizeof(struct mxe_engine)); - engine->data = data; - engine->mainloop = mainloop; - pthread_rwlock_init(&engine->endpoint_lock, NULL); - adt_init_list(&engine->endpoints); - - return engine; -} -// mxe_push_integer -int mxe_push_integer(struct mxe_message * /*msg*/, int /*value*/) { - return 0; -} -// mxe_push_string -int mxe_push_string(struct mxe_message * /*msg*/, const char * /*str*/) { - return 0; -} -// mxe_register_proxy -int mxe_register_proxy(struct mxe_engine * /*engine*/, struct mxe_proxy * /*proxy*/) { - return 0; -} -// mxe_reply_message (intenal) -int mxe_reply_message(struct mxe_endpoint * /*ep*/, struct mxe_message * /*origin*/, ...) { - return 0; -} -// mxe_reset_payload -void mxe_reset_payload(struct mxe_message * /*msg*/) { -} -// mxe_wait_for_event -int mxe_wait_for_event(struct mxe_endpoint * /*ep*/, struct mxe_emple * /*emple*/) { - return 0; -} -// sock_close_socket (intern) -int sock_close_socket(int /*fd*/) { +// sock_close_socket +API int sock_close_socket(int /*fd*/) { + LOGS(""); return 0; } // sock_connect API int sock_connect(const char * /*path*/) { - return 0; + LOGS(""); + return -1; } // sock_create_socket API int sock_create_socket(const char * /*path*/, int /*type*/, int /*flags*/) { - return 0; + LOGS(""); + return -1; } // sock_monitor_address API int sock_monitor_address(char * /*buffer*/, int /*len*/, const char * /*lxcpath*/) { + LOGS(""); return 0; } // sock_recv_fd (intern) API int sock_recv_fd(int /*fd*/, int * /*recvfd*/, void * /*data*/, size_t /*size*/) { + LOGS(""); return 0; } // sock_send_fd API int sock_send_fd(int /*fd*/, int /*sendfd*/, void * /*data*/, size_t /*size*/) { + LOGS(""); return 0; } // vasum_log -API void vasum_log(int /*type*/, const char * /*tag*/, const char * /*fmt*/ , ...) { +API void vasum_log(int type, const char *tag, const char *fmt, ...) { + va_list arg_ptr; + char buf[100]; + va_start(arg_ptr, fmt); + vsnprintf(buf, sizeof(buf), fmt, arg_ptr); + va_end(arg_ptr); + LOGS("type=" << type << " tag=" << tag << " msg=" << buf); } #define MAX_ERROR_MSG 0x1000 @@ -222,6 +121,7 @@ const char *const fso_type_strtab[] = { API const char *fso_type_to_string(vsm_fso_type_t fso) { + LOGS(""); if (fso < 0 || fso > VSM_FSO_MAX_TYPE) { return NULL; } @@ -231,6 +131,7 @@ API const char *fso_type_to_string(vsm_fso_type_t fso) API int wait_for_pid_status(pid_t pid) { + LOGS(""); int status, ret; again: @@ -239,8 +140,7 @@ API int wait_for_pid_status(pid_t pid) if (errno == EINTR) { goto again; } else { - ERROR("waitpid- pid : %d error : %s", pid, - strerror(errno)); + ERROR("waitpid pid : %d error : %s", pid, strerror(errno)); return -1; } } @@ -251,6 +151,7 @@ API int wait_for_pid_status(pid_t pid) API vsm_fso_type_t fso_string_to_type(char *str) { + LOGS(""); int len; int i; for (i = 0; i <= VSM_FSO_MAX_TYPE; i++) { @@ -264,6 +165,7 @@ API vsm_fso_type_t fso_string_to_type(char *str) API int mkdir_p(const char *dir, mode_t mode) { + LOGS(""); const char *tmp = dir; const char *orig = dir; char *makeme; @@ -286,6 +188,7 @@ API int mkdir_p(const char *dir, mode_t mode) API int lock_fd(int fd, int wait) { + LOGS(""); int ret; struct flock f; @@ -309,6 +212,7 @@ API int lock_fd(int fd, int wait) API int unlock_fd(int fd) { + LOGS(""); struct flock f; f.l_type = F_UNLCK; f.l_whence = SEEK_SET; @@ -319,11 +223,13 @@ API int unlock_fd(int fd) API int copy_smacklabel(const char * /*source*/, const char * /*dest*/) { + LOGS(""); return 0; } API int remove_file(char *path) { + LOGS(""); struct stat path_stat; DIR *dp; struct dirent *d; @@ -376,6 +282,7 @@ API int remove_file(char *path) API int copy_file(const char *source, const char *dest, int /*flags*/) { + LOGS(""); int ret; FILE *sfp, *dfp; size_t nread, nwritten, size = BUF_SIZE; @@ -426,6 +333,7 @@ API int copy_file(const char *source, const char *dest, int /*flags*/) API int regex_compile(regex_t * r, const char *regex_text) { + LOGS(""); int status = regcomp(r, regex_text, REG_EXTENDED | REG_NEWLINE); if (status != 0) { @@ -442,6 +350,7 @@ API int regex_compile(regex_t * r, const char *regex_text) API int regex_match(regex_t * r, const char *to_match) { + LOGS(""); const char *p = to_match; const int n_matches = 10; regmatch_t m[n_matches]; @@ -485,6 +394,7 @@ API int regex_match(regex_t * r, const char *to_match) API int get_peer_pid(int fd) { + LOGS(""); struct ucred cred; socklen_t cr_len = sizeof(cred); if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &cr_len) < 0) { @@ -495,23 +405,25 @@ API int get_peer_pid(int fd) API pid_t gettid(void) { + LOGS(""); return syscall(__NR_gettid); } API int set_smacklabel_fd(int fd, const char *xattr_name, const char *label) { + LOGS(""); size_t len; int ret; - if(fd < 0) + if (fd < 0) return -1; len = strnlen(label, SMACK_LABEL_LEN + 1); if (len > SMACK_LABEL_LEN) return -1; - ret = fsetxattr(fd, xattr_name, label, len+1, 0); - if(ret != 0) { + ret = fsetxattr(fd, xattr_name, label, len + 1, 0); + if (ret != 0) { ERROR("Set Smack lable error : %s", strerror(errno)); } return ret; @@ -519,52 +431,55 @@ API int set_smacklabel_fd(int fd, const char *xattr_name, const char *label) API int set_smacklabel(const char *path, const char *xattr_name, const char *label) { + LOGS(""); size_t len; int ret; - if(path == NULL) + if (path == NULL) return -1; len = strnlen(label, SMACK_LABEL_LEN + 1); if (len > SMACK_LABEL_LEN) return -1; - ret = lsetxattr(path, xattr_name, label, len+1, 0); - if(ret != 0) { + ret = lsetxattr(path, xattr_name, label, len + 1, 0); + if (ret != 0) { ERROR("Set Smack lable error : %s", strerror(errno)); } return ret; } API char *get_self_smacklabel(void) { + LOGS(""); int ret; int fd; const char *attr_path = "/proc/self/attr/current"; - char buffer[SMACK_LABEL_LEN+1]; + char buffer[SMACK_LABEL_LEN + 1]; - bzero(buffer, SMACK_LABEL_LEN+1); + bzero(buffer, SMACK_LABEL_LEN + 1); fd = open(attr_path, O_RDONLY); - if( fd < 0) { + if (fd < 0) { return NULL; } - ret = read(fd, buffer, SMACK_LABEL_LEN+1); + ret = read(fd, buffer, SMACK_LABEL_LEN + 1); close(fd); if (ret < 0) { return NULL; } - if( ret > SMACK_LABEL_LEN) { + if (ret > SMACK_LABEL_LEN) { //return NULL; } - buffer[SMACK_LABEL_LEN]=0; + buffer[SMACK_LABEL_LEN] = 0; return strdup(buffer); } API int get_self_cpuset(char *name, int buf_sz) { + LOGS(""); int fd; int lxc_len, ret; char cpuset_path[] = "/proc/self/cpuset"; @@ -585,7 +500,7 @@ API int get_self_cpuset(char *name, int buf_sz) close(fd); lxc_len = sizeof("/lxc"); - if( ret < lxc_len) { + if (ret < lxc_len) { name[0] = '/'; name[1] = 0; return 1; @@ -593,14 +508,14 @@ API int get_self_cpuset(char *name, int buf_sz) char *p; p = current_name + lxc_len; - while(*p != '\0') { - if(*p == '/') { + while (*p != '\0') { + if (*p == '/') { *p = '\0'; break; } p++; } - snprintf(name, buf_sz, "%s", current_name+lxc_len); + snprintf(name, buf_sz, "%s", current_name + lxc_len); } return ret - lxc_len; @@ -609,6 +524,7 @@ API int get_self_cpuset(char *name, int buf_sz) API char * get_pid_cpuset(int pid) { + LOGS(""); int fd; int ret; char cpuset_path[PATH_MAX]; @@ -617,7 +533,7 @@ API char * get_pid_cpuset(int pid) snprintf(cpuset_path, PATH_MAX, "/proc/%d/cpuset", pid); ret = access(cpuset_path, F_OK | R_OK); - if( ret != 0 ) + if (ret != 0) return NULL; fd = open(cpuset_path, O_RDONLY); @@ -641,6 +557,7 @@ API char * get_pid_cpuset(int pid) API char * read_namespace_link(const char *ns, int pid) { + LOGS(""); char ns_path[PATH_MAX]; char buf[NAME_MAX]; int ret; @@ -648,11 +565,11 @@ API char * read_namespace_link(const char *ns, int pid) snprintf(ns_path, PATH_MAX, "/proc/%d/ns/%s", pid, ns); ret = access(ns_path, F_OK); - if(ret != 0) + if (ret != 0) return NULL; ret = readlink(ns_path, buf, NAME_MAX); - if( ret == -1 ) { + if (ret == -1) { ERROR("Failed to readlink ns file - [%s]", ns_path); return NULL; } @@ -669,6 +586,7 @@ API char * read_namespace_link(const char *ns, int pid) API int dev_enumerate_nodes(const char *cname, dev_enumerator enumerator, void *data) { + LOGS(""); int ret; FILE *fp;; char path[PATH_MAX], entry[64]; @@ -706,6 +624,7 @@ API int dev_enumerate_nodes(const char *cname, dev_enumerator enumerator, API int dev_terminal_enumerator(int type, int major, int minor, void *data) { + LOGS(""); int *dev = (int*)data; *dev = minor; @@ -720,6 +639,7 @@ API int dev_terminal_enumerator(int type, int major, int minor, void *data) // libs/namespace.c API pid_t get_init_pid(const char *name) { + LOGS(""); char filename[PATH_MAX]; FILE *fp; pid_t ret = -1; @@ -746,6 +666,7 @@ API pid_t get_init_pid(const char *name) API pid_t get_zone_pid(const char *name, const char *target) { + LOGS(""); char path[PATH_MAX]; char cmd[PATH_MAX]; int res = 0, len; @@ -823,6 +744,7 @@ API pid_t get_zone_pid(const char *name, const char *target) API int open_ns(pid_t pid, const char *name) { + LOGS(""); int fd, ret; char path[PATH_MAX]; @@ -846,6 +768,7 @@ API int open_ns(pid_t pid, const char *name) #include static int is_console(int fd) { + LOGS(""); char arg; return (isatty(fd) && @@ -873,6 +796,7 @@ static int open_console(const char *path) API int get_console_fd(const char *path) { + LOGS(""); int fd; if (path) { @@ -905,6 +829,7 @@ API int get_console_fd(const char *path) API int vt_switch_terminal(int id) { + LOGS(""); int fd, ret = -1; fd = get_console_fd(NULL); @@ -928,6 +853,7 @@ API int vt_switch_terminal(int id) API int vt_find_unused_terminal(void) { + LOGS(""); int fd, nr = -1; fd = get_console_fd(NULL); @@ -949,6 +875,7 @@ API int vt_find_unused_terminal(void) API int vt_query_active_terminal(void) { + LOGS(""); int fd, ret = -1; struct vt_stat vtstat; @@ -1189,6 +1116,7 @@ static int parse_statement(struct parser_context *ctx, int argc, char **argv, API int parse_stream_core(struct parser_context *ctx, char *s) { + LOGS(""); struct unit_keyword_callback *kw; struct parser_state state; char *args[PARSER_MAXARGS]; @@ -1270,6 +1198,7 @@ static char *open_stream(const char *name, unsigned int *_sz) API int parse_stream(const char *name, struct unit_parser *parser) { + LOGS(""); char *stream; struct parser_context *ctx; @@ -1294,6 +1223,13 @@ API int parse_stream(const char *name, struct unit_parser *parser) return 0; } +API struct vsm_netdev *alloc_netdev(struct vsm_zone * /*zone*/, vsm_netdev_type_t /*type*/, const char * /*netdev_name*/) { + LOGS(""); + return NULL; +} +API void enter_to_ns(pid_t /*pid*/, char * /*name*/) { + LOGS(""); +} // dummy-ops static int dummy_create_zone(vsm_context_h /*ctx*/, const char * /*zone_name*/, @@ -1350,7 +1286,7 @@ static vsm_zone_h dummy_get_foreground(vsm_context_h ctx) static int dummy_iterate_zone(vsm_context_h ctx, vsm_zone_iter_cb callback, void *user_data) { - if( callback) { + if (callback) { callback(ctx->root_zone, user_data); } return VSM_ERROR_NONE; @@ -1440,7 +1376,7 @@ static int dummy_attach_zone_wait(vsm_context_h ctx, const char *zone_name, vsm_attach_command_s * command, vsm_attach_options_s * opts) { - pid_t pid=0; + pid_t pid = 0; int ret, status; ret = dummy_attach_zone(ctx, zone_name, command, opts, &pid); @@ -1482,7 +1418,7 @@ static int dummy_is_equivalent_zone(vsm_context_h /*ctx*/, pid_t /*pid*/) static int dummy_get_host_pid(vsm_zone_h zone, pid_t pid) { - if(zone == zone->parent) + if (zone == zone->parent) return pid; return -VSM_ERROR_NO_OBJECT; @@ -1517,7 +1453,7 @@ static int dummy_declare_link(vsm_context_h /*ctx*/, const char *source, } struct vasum_ops dummy_ops; -static int dummy_ops_init(){ +static int dummy_ops_init() { dummy_ops.create_zone = dummy_create_zone; dummy_ops.destroy_zone = dummy_destroy_zone; dummy_ops.start_zone = dummy_start_zone; @@ -1542,4 +1478,5 @@ static int dummy_ops_init(){ } int dummy_ops_init_i = dummy_ops_init(); + } //extern "C" diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index 9483a87..4fc0c60 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -57,10 +57,6 @@ static struct int glib_stop; } wrap; -extern "C" { -API void vsm_string_free(VsmString string); -API void vsm_array_string_free(VsmArrayString astring); -} #ifndef offsetof #define offsetof(type, memb) ((size_t)&((type *)0)->memb) @@ -77,7 +73,6 @@ API void vsm_array_string_free(VsmArrayString astring); #define vsm_attach_command_t vsm_attach_command_s #define vsm_attach_options_t vsm_attach_options_s -#define vsm_zone_state_cb vsm_zone_state_changed_cb void __attribute__ ((constructor)) wrapper_load(void); void __attribute__ ((destructor)) wrapper_unload(void); @@ -108,9 +103,9 @@ static void callcheck() void init_wrapper() { if (wrap.done) return ; - memset(&wrap,0,sizeof(wrap)); + memset(&wrap, 0, sizeof(wrap)); wrap.done = 1; - LOGS("WRAP:"); + LOGS(""); } static struct vsm_zone* wrap_vsm_zone(WrappedContext *w, VsmZone zone, bool create = false) @@ -129,6 +124,7 @@ static struct vsm_zone* wrap_vsm_zone(WrappedContext *w, VsmZone zone, bool crea zw.client = w->client; zw.zone = zone; zw.vz.name = zone->id; + zw.vz.id = 0; zw.vz.type = NULL; zw.vz.user_data = NULL; zw.vz.rootfs_path = zone->rootfs_path; @@ -143,7 +139,7 @@ static struct vsm_zone* wrap_vsm_zone(WrappedContext *w, VsmZone zone, bool crea static int wrap_error(VsmStatus st, const Client *c) { if (st == VSMCLIENT_SUCCESS) LOGI("return success " << st); - else LOGE("return error " << st << "m=" << (c ? c->vsm_get_status_message() : "n/a")); + else LOGE("return error=" << st << ", msg=" << (c ? c->vsm_get_status_message() : "n/a")); switch (st) { case VSMCLIENT_SUCCESS: return VSM_ERROR_NONE; case VSMCLIENT_CUSTOM_ERROR: return -VSM_ERROR_GENERIC; @@ -171,7 +167,7 @@ static void init_context_wrap(WrappedContext *w) //init root_zone ctx->root_zone = &w->hq_root; ctx->root_zone->name = (char*)""; - ctx->root_zone->id=0; + ctx->root_zone->id = 0; ctx->root_zone->rootfs_path = (char*)"/"; ctx->root_zone->terminal = -1; @@ -201,9 +197,13 @@ static void init_context_wrap(WrappedContext *w) //ctx->data = ep; } +extern "C" { +API void vsm_string_free(VsmString string); +API void vsm_array_string_free(VsmArrayString astring); + API vsm_context_h vsm_create_context(void) { - LOGS("WRAP:"); + LOGS(""); callcheck(); WrappedContext *w = new WrappedContext(); init_context_wrap(w); @@ -214,7 +214,7 @@ API vsm_context_h vsm_create_context(void) API int vsm_cleanup_context(vsm_context_h ctx) { - LOGS("WRAP:"); + LOGS(""); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); if (w->client != NULL) { @@ -225,6 +225,7 @@ API int vsm_cleanup_context(vsm_context_h ctx) zw.netdevs.clear(); } w->zones.clear(); + pthread_rwlock_destroy(&ctx->lock); delete w; return VSM_ERROR_NONE; } @@ -260,7 +261,7 @@ API vsm_error_e vsm_last_error(struct vsm_context *ctx) API int vsm_get_poll_fd(struct vsm_context *ctx) { - LOGS("WRAP:"); + LOGS(""); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); UNUSED(w); @@ -271,7 +272,7 @@ API int vsm_get_poll_fd(struct vsm_context *ctx) } API int vsm_enter_eventloop(struct vsm_context *ctx, int flags, int timeout) { - LOGS("WRAP:"); + LOGS(""); callcheck(); UNUSED(flags); UNUSED(timeout); @@ -285,7 +286,7 @@ API int vsm_enter_eventloop(struct vsm_context *ctx, int flags, int timeout) API int vsm_create_zone(struct vsm_context *ctx, const char *zone_name, const char *template_name, int flag) { - LOGS("WRAP:create_zone " << zone_name); + LOGS("create_zone " << zone_name); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); UNUSED(flag); @@ -300,7 +301,7 @@ API int vsm_create_zone(struct vsm_context *ctx, const char *zone_name, const ch API int vsm_destroy_zone(struct vsm_context *ctx, const char *zone_name, int force) { - LOGS("WRAP:zone=" << zone_name); + LOGS("zone=" << zone_name); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); UNUSED(force); @@ -316,7 +317,7 @@ API int vsm_destroy_zone(struct vsm_context *ctx, const char *zone_name, int for API int vsm_start_zone(struct vsm_context *ctx, const char *zone_name) { - LOGS("WRAP:zone=" << zone_name); + LOGS("zone=" << zone_name); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); if (!w->client) return VSM_ERROR_GENERIC; @@ -326,7 +327,7 @@ API int vsm_start_zone(struct vsm_context *ctx, const char *zone_name) API int vsm_shutdown_zone(struct vsm_context *ctx, const char *zone_name, int force) { - LOGS("WRAP:zone=" << zone_name); + LOGS("zone=" << zone_name); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); UNUSED(force); @@ -337,7 +338,7 @@ API int vsm_shutdown_zone(struct vsm_context *ctx, const char *zone_name, int fo API int vsm_lock_zone(struct vsm_context *ctx, const char *zone_name, int shutdown) { - LOGS("WRAP:zone=" << zone_name); + LOGS("zone=" << zone_name); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); UNUSED(shutdown); @@ -348,7 +349,7 @@ API int vsm_lock_zone(struct vsm_context *ctx, const char *zone_name, int shutdo API int vsm_unlock_zone(struct vsm_context *ctx, const char *zone_name) { - LOGS("WRAP:zone=" << zone_name); + LOGS("zone=" << zone_name); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); if (!w->client) return VSM_ERROR_GENERIC; @@ -358,7 +359,7 @@ API int vsm_unlock_zone(struct vsm_context *ctx, const char *zone_name) API int vsm_set_foreground(struct vsm_zone *zone) { - LOGS("WRAP:"); + LOGS(""); callcheck(); WrappedZone *w = container_of(zone, WrappedZone, vz); if (!w->client) return VSM_ERROR_GENERIC; @@ -388,12 +389,13 @@ API int vsm_attach_zone_wait(struct vsm_context *ctx, API int vsm_iterate_zone(struct vsm_context *ctx, void (*callback)(struct vsm_zone *zone, void *user_data), void *user_data) { - LOGS("WRAP:"); + LOGS(""); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); if (!w->client) return -VSM_ERROR_GENERIC; callback(ctx->root_zone, user_data); for (auto& z : w->zones) { + LOGI("iterate callback zone: " << z.zone->id); callback(&z.vz, user_data); } return 0; @@ -401,7 +403,7 @@ API int vsm_iterate_zone(struct vsm_context *ctx, void (*callback)(struct vsm_zo API struct vsm_zone *vsm_lookup_zone_by_name(struct vsm_context *ctx, const char *path) { - LOGS("WRAP:name=" << path); + LOGS("name=" << path); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); VsmZone zone; @@ -415,16 +417,18 @@ API struct vsm_zone *vsm_lookup_zone_by_name(struct vsm_context *ctx, const char //supposed return ref to internal struct API struct vsm_zone *vsm_lookup_zone_by_pid(struct vsm_context *ctx, pid_t pid) { - LOGS("WRAP: pid=" << pid); + LOGS("pid=" << pid); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); VsmZone zone; VsmString id; + VsmStatus st; if (!w->client) return NULL; - if (w->client->vsm_lookup_zone_by_pid(pid, &id) != VSMCLIENT_SUCCESS) { - LOGE("vsm_lookup_zone_by_pid(" << pid << ") error"); + if ((st = w->client->vsm_lookup_zone_by_pid(pid, &id)) != VSMCLIENT_SUCCESS) { + wrap_error(st, w->client); return NULL; } + LOGI("found zone(pid=" << pid << ")='" << id << "'"); if (::strcmp(id, "host") == 0) { return w->hq_ctx.root_zone; } @@ -432,9 +436,9 @@ API struct vsm_zone *vsm_lookup_zone_by_pid(struct vsm_context *ctx, pid_t pid) return wrap_vsm_zone(w, zone); } -API int vsm_add_state_changed_callback(struct vsm_context *ctx, vsm_zone_state_cb callback, void *user_data) +API int vsm_add_state_changed_callback(struct vsm_context *ctx, vsm_zone_state_changed_cb callback, void *user_data) { - LOGS("WRAP:"); + LOGS(""); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); VsmSubscriptionId subscriptionId; @@ -443,7 +447,7 @@ API int vsm_add_state_changed_callback(struct vsm_context *ctx, vsm_zone_state_c void { VsmZone zone; //TODO what are valid state, event - vsm_zone_state_t t=VSM_ZONE_STATE_RUNNING; + vsm_zone_state_t t = VSM_ZONE_STATE_RUNNING; UNUSED(dbusAddress); w->client->vsm_lookup_zone_by_id(id, &zone); callback(wrap_vsm_zone(w, zone), t, data); @@ -454,7 +458,7 @@ API int vsm_add_state_changed_callback(struct vsm_context *ctx, vsm_zone_state_c API int vsm_del_state_changed_callback(struct vsm_context *ctx, int handle) { - LOGS("WRAP:"); + LOGS(""); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); VsmSubscriptionId subscriptionId = (VsmSubscriptionId)handle; @@ -464,7 +468,7 @@ API int vsm_del_state_changed_callback(struct vsm_context *ctx, int handle) API int vsm_grant_device(struct vsm_zone *dom, const char *name, uint32_t flags) { - LOGS("WRAP:"); + LOGS(""); callcheck(); WrappedZone *w = container_of(dom, WrappedZone, vz); const char *id = dom->name; @@ -476,7 +480,7 @@ API int vsm_grant_device(struct vsm_zone *dom, const char *name, uint32_t flags) API int vsm_revoke_device(struct vsm_zone *dom, const char *name) { - LOGS("WRAP:"); + LOGS(""); callcheck(); WrappedZone *w = container_of(dom, WrappedZone, vz); const char *id = dom->name; @@ -486,7 +490,7 @@ API int vsm_revoke_device(struct vsm_zone *dom, const char *name) API struct vsm_netdev *vsm_create_netdev(struct vsm_zone *zone, vsm_netdev_type_t type, const char *target, const char *netdev) { - LOGS("WRAP:"); + LOGS(""); callcheck(); UNUSED(zone); UNUSED(type); @@ -521,26 +525,15 @@ API struct vsm_netdev *vsm_create_netdev(struct vsm_zone *zone, vsm_netdev_type_ return &w->netdevs.back(); //pointer to struct on vector } -API int vsm_destroy_netdev(struct vsm_zone *zone, struct vsm_netdev *netdev) +API int vsm_destroy_netdev(vsm_netdev_h) { - LOGS("WRAP:"); - callcheck(); - WrappedZone *w = container_of(zone, WrappedZone, vz); - - VsmStatus st = w->client->vsm_destroy_netdev(zone->name, netdev->name); - if (st == VSMCLIENT_SUCCESS) { - auto devbyname = [netdev](const vsm_netdev& v) {return ::strcmp(v.name, netdev->name) == 0;}; - auto devlist = std::find_if(w->netdevs.begin(), w->netdevs.end(), devbyname); - if (devlist != w->netdevs.end()) { - w->netdevs.erase(devlist); - } - } - return wrap_error(st, w->client); + LOGS(""); + return 0; } API int vsm_iterate_netdev(struct vsm_zone *zone, void (*callback)(struct vsm_netdev *, void *user_data), void *user_data) { - LOGS("WRAP:"); + LOGS(""); callcheck(); WrappedZone *w = container_of(zone, WrappedZone, vz); for (auto nd : w->netdevs) { @@ -551,7 +544,7 @@ API int vsm_iterate_netdev(struct vsm_zone *zone, void (*callback)(struct vsm_ne API struct vsm_netdev *vsm_lookup_netdev_by_name(struct vsm_zone *zone, const char *name) { - LOGS("WRAP:"); + LOGS(""); callcheck(); WrappedZone *w = container_of(zone, WrappedZone, vz); VsmNetdev nd; @@ -568,7 +561,7 @@ API struct vsm_netdev *vsm_lookup_netdev_by_name(struct vsm_zone *zone, const ch API int vsm_declare_file(struct vsm_context *ctx, vsm_fso_type_t ftype, const char *path, int flags, vsm_mode_t mode) { - LOGS("WRAP:"); + LOGS(""); callcheck(); /* Old implementation is following: (but implemented in server) args.oldpath = oldpath; @@ -610,7 +603,7 @@ API int vsm_declare_file(struct vsm_context *ctx, vsm_fso_type_t ftype, const ch API int vsm_declare_link(struct vsm_context *ctx, const char *source, const char *target) { - LOGS("WRAP:src=" << source << ", dst=" << target); + LOGS("src=" << source << ", dst=" << target); callcheck(); /* Old implementation is following: (but implemented in server) args.oldpath = oldpath; @@ -637,7 +630,7 @@ API int vsm_declare_mount(struct vsm_context *ctx, unsigned long flags, const void *data) { - LOGS("WRAP:"); + LOGS(""); callcheck(); /* Old implementation is following: (but implemented in server) args.oldpath = oldpath; @@ -659,72 +652,53 @@ API int vsm_declare_mount(struct vsm_context *ctx, return VSM_ERROR_NONE; } -API const char * vsm_get_zone_rootpath(vsm_zone_h /*zone*/) +API const char * vsm_get_zone_rootpath(vsm_zone_h zone) { - LOGS("WRAP:"); - return NULL; + LOGS(""); + return zone == NULL ? NULL : zone->rootfs_path; } -API const char * vsm_get_zone_name(vsm_zone_h /*zone*/) +API const char * vsm_get_zone_name(vsm_zone_h zone) { - LOGS("WRAP:"); - return NULL; + LOGS(""); + return zone == NULL ? NULL : zone->name; } -API int vsm_is_host_zone(vsm_zone_h /*zone*/) +API int vsm_is_host_zone(vsm_zone_h zone) { - LOGS("WRAP:"); - return VSM_ERROR_NONE; + LOGS(""); + if (zone == NULL) + return -VSM_ERROR_INVALID; + + return zone->parent == zone ? 1 : 0; } API vsm_zone_h vsm_join_zone(vsm_zone_h /*zone*/) { - LOGS("WRAP:"); + LOGS(""); return NULL; } -API int vsm_canonicalize_path(const char * /*input_path*/, char ** /*output_path*/) -{ - LOGS("WRAP:"); - return VSM_ERROR_NONE; -} - -static int is_valid_context(void * /*v*/) -{ - return 1; -} -static const char *vsm_error_string_v0_34(struct vsm_context *ctx) -{ - vsm_error_e error = ctx->error; - if (error < 0 || error > VSM_MAX_ERROR) { - return NULL; - } - return vsm_error_strtab[error]; -} -static const char *vsm_error_string_v0_3_1(vsm_error_e error) +API int vsm_canonicalize_path(const char *input_path, char **output_path) { - if (error < 0 || error > VSM_MAX_ERROR) { - return NULL; - } - return vsm_error_strtab[error]; + LOGS(""< VSM_MAX_ERROR) { + return NULL; } + return vsm_error_strtab[error]; } API struct vsm_zone *vsm_lookup_zone_by_terminal_id(struct vsm_context *ctx, int terminal) { - LOGS("WRAP:terminal=" << terminal); + LOGS("terminal=" << terminal); callcheck(); WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx); VsmZone zone; @@ -752,4 +726,97 @@ API void vsm_string_free(VsmString string) free(string); } +API int vsm_add_event_callback(vsm_context_h, vsm_zone_event_cb, void*) { + LOGS(""); + return 0; +} +API int vsm_del_event_callback(vsm_context_h, int) { + LOGS(""); + return 0; +} +API int vsm_add_state_callback(vsm_context_h , vsm_zone_state_cb , void *) { + LOGS(""); + return 0; +} +API int vsm_del_state_callback(vsm_context_h , int ) { + LOGS(""); + return 0; +} +API int vsm_down_netdev(vsm_netdev_h) { + LOGS(""); + return 0; +} +API vsm_zone* vsm_get_foreground(vsm_context_h ctx) { + LOGS(""); + //return ((struct vasum_ops *)(ctx->vsm_ops))->get_foreground(ctx); + return dummy_ops.get_foreground(ctx); +} +API int vsm_get_host_pid(vsm_zone_h, pid_t) { + LOGS(""); + return 0; +} +API int vsm_get_ip_addr_netdev(vsm_netdev_h, vsm_netdev_addr_t, char*, int) { + LOGS(""); + return 0; +} +API void* vsm_get_userdata(vsm_zone_h) { + LOGS(""); + return NULL; +} +API int vsm_get_zone_id(vsm_zone_h zone) { + LOGS(""); + if (zone == NULL) + return -VSM_ERROR_INVALID; + return zone->id; +} +API vsm_zone_state_t vsm_get_zone_state(vsm_zone_h zone) { + LOGS(""); + if (zone == NULL) + return static_cast(-VSM_ERROR_INVALID); + return zone->state; +} +API int vsm_get_zone_terminal(vsm_zone_h) { + LOGS(""); + return -VSM_ERROR_NOT_SUPPORTED; +} +API const char *vsm_get_zone_type(vsm_zone_h zone) { + LOGS(""); + return zone == NULL ? NULL : zone->type; +} +API int vsm_is_equivalent_zone(vsm_context_h, pid_t) { + LOGS(""); + return 0; +} +API int vsm_is_virtualized() { + LOGS(""); + return 0; /* Running in Host */ +} +// libs/network.c +API int vsm_set_ip_addr_netdev(vsm_netdev_h, vsm_netdev_addr_t, const char*, int) { + LOGS(""); + return 0; +} +API int vsm_up_netdev(vsm_netdev_h) { + LOGS(""); + return 0; +} +// libs/zone.c +API int vsm_set_userdata(vsm_zone_h, void*) { + LOGS(""); + return 0; +} +API int vsm_state_change_watch_callback(struct vsm_context * /*ctx*/, char * /*name*/, + int /*state*/, int /*event*/) { + LOGS(""); + return 0; +} +// libs/vsm_signal.c +API int vsm_signal_state_broadcast(struct mxe_engine * /*engine*/, const char * /*zone_name*/, int /*state*/) { + LOGS(""); + return 0; +} +API int vsm_signal_event_broadcast(struct mxe_engine * /*engine*/, const char * /*zone_name*/, int /*event*/) { + LOGS(""); + return 0; +} } // extern "C" -- 2.7.4 From a8e270d21722cb019cb6ccdf46926921c3e2e53d Mon Sep 17 00:00:00 2001 From: Mateusz Malicki Date: Thu, 21 May 2015 17:25:22 +0200 Subject: [PATCH 15/16] Fix SocketSuite/SystemdSocket [Bug] Prevent from run vasum-socket-test.service in qemu [Cause] N/A [Solution] Remove ConditionVirtualization=no [Verification] Build, install on emulator, run SocketSuite/SystemdSocket test Change-Id: I4fc0c9da2a4ca55878acec6203caab3674d94d02 --- tests/unit_tests/configs/systemd/vasum-socket-test.service | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit_tests/configs/systemd/vasum-socket-test.service b/tests/unit_tests/configs/systemd/vasum-socket-test.service index 1d43529..23c6d3a 100644 --- a/tests/unit_tests/configs/systemd/vasum-socket-test.service +++ b/tests/unit_tests/configs/systemd/vasum-socket-test.service @@ -1,6 +1,5 @@ [Unit] Description=Vasum Socket tests mini-service -ConditionVirtualization=no [Service] Type=simple -- 2.7.4 From aa1f5f7317a73b7063b7ca4cc4872cc6271c79d2 Mon Sep 17 00:00:00 2001 From: Mateusz Malicki Date: Tue, 19 May 2015 18:38:11 +0200 Subject: [PATCH 16/16] Fix GetZoneIdByPidTestMultiple, GrantRevoke [Feature] GetZoneIdByPidTestMultiple, GrantRevoke some times fails [Cause] Timeout was too small [Solution] Increase timeout [Verification] Build, install, run tests Change-Id: Id191c1a6443e19f729dfc90c9a3c8c34dc4166e3 --- common/utils/fd-utils.hpp | 4 ++-- libs/config/fdstore.hpp | 4 ++-- libs/ipc/client.hpp | 2 +- libs/ipc/internals/processor.hpp | 2 +- libs/ipc/service.hpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/utils/fd-utils.hpp b/common/utils/fd-utils.hpp index 151eb1c..209de2c 100644 --- a/common/utils/fd-utils.hpp +++ b/common/utils/fd-utils.hpp @@ -42,7 +42,7 @@ void close(int fd); * @param size size of data to write * @param timeoutMS timeout in milliseconds */ -void write(int fd, const void* bufferPtr, const size_t size, int timeoutMS = 500); +void write(int fd, const void* bufferPtr, const size_t size, int timeoutMS = 5000); /** * Read from a file descriptor, throw on error. @@ -52,7 +52,7 @@ void write(int fd, const void* bufferPtr, const size_t size, int timeoutMS = 500 * @param size size of the data to read * @param timeoutMS timeout in milliseconds */ -void read(int fd, void* bufferPtr, const size_t size, int timeoutMS = 500); +void read(int fd, void* bufferPtr, const size_t size, int timeoutMS = 5000); /** * @return the max number of file descriptors for this process. diff --git a/libs/config/fdstore.hpp b/libs/config/fdstore.hpp index d34ea14..d76fc5f 100644 --- a/libs/config/fdstore.hpp +++ b/libs/config/fdstore.hpp @@ -50,7 +50,7 @@ public: * @param size size of the buffer * @param timeoutMS timeout in milliseconds */ - void write(const void* bufferPtr, const size_t size, const unsigned int timeoutMS = 500); + void write(const void* bufferPtr, const size_t size, const unsigned int timeoutMS = 5000); /** * Reads a value of the given type. @@ -59,7 +59,7 @@ public: * @param size size of the buffer * @param timeoutMS timeout in milliseconds */ - void read(void* bufferPtr, const size_t size, const unsigned int timeoutMS = 500); + void read(void* bufferPtr, const size_t size, const unsigned int timeoutMS = 5000); private: int mFD; diff --git a/libs/ipc/client.hpp b/libs/ipc/client.hpp index c76a817..fe3345a 100644 --- a/libs/ipc/client.hpp +++ b/libs/ipc/client.hpp @@ -125,7 +125,7 @@ public: template std::shared_ptr callSync(const MethodID methodID, const std::shared_ptr& data, - unsigned int timeoutMS = 500); + unsigned int timeoutMS = 5000); /** * Asynchronous method call. The return callback will be called on diff --git a/libs/ipc/internals/processor.hpp b/libs/ipc/internals/processor.hpp index b1b0a5f..121978c 100644 --- a/libs/ipc/internals/processor.hpp +++ b/libs/ipc/internals/processor.hpp @@ -262,7 +262,7 @@ public: std::shared_ptr callSync(const MethodID methodID, const PeerID peerID, const std::shared_ptr& data, - unsigned int timeoutMS = 500); + unsigned int timeoutMS = 5000); /** * Asynchronous method call diff --git a/libs/ipc/service.hpp b/libs/ipc/service.hpp index 8f6f62b..5b6297c 100644 --- a/libs/ipc/service.hpp +++ b/libs/ipc/service.hpp @@ -130,7 +130,7 @@ public: std::shared_ptr callSync(const MethodID methodID, const PeerID peerID, const std::shared_ptr& data, - unsigned int timeoutMS = 500); + unsigned int timeoutMS = 5000); /** * Asynchronous method call. The return callback will be called on -- 2.7.4