Skip to content

Commit

Permalink
commit fixed
Browse files Browse the repository at this point in the history
Signed-off-by: victoryang00 <[email protected]>
  • Loading branch information
victoryang00 committed Jan 14, 2024
1 parent 16d3b52 commit 4af2f2a
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 38 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,26 @@ jobs:

- name: build
working-directory: ${{runner.workspace}}/build
run: cmake --build . --config ${{matrix.build}}
run: cmake --build . --config ${{matrix.build}} && cp ${{runner.workspace}}/build/MVVM_checkpoint ${{runner.workspace}}/build/MVVM_checkpoint-macos && cp ${{runner.workspace}}/build/MVVM_restore ${{runner.workspace}}/build/MVVM_restore-macos

- uses: actions/upload-artifact@v2
if: ${{matrix.build}} == "Release"
if: startsWith(github.ref, 'refs/tags/') && ${{matrix.build}} == "Release"
with:
name: MVVM_checkpoint-macos
path: ${{runner.workspace}}/build/MVVM_checkpoint
path: ${{runner.workspace}}/build/MVVM_checkpoint-macos

- uses: actions/upload-artifact@v2
if: ${{matrix.build}} == "Release"
if: startsWith(github.ref, 'refs/tags/') && ${{matrix.build}} == "Release"
with:
name: MVVM_restore-macos
path: ${{runner.workspace}}/build/MVVM_restore
path: ${{runner.workspace}}/build/MVVM_restore-macos

- name: Publish
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && ${{matrix.build}} == "Release"
with:
files: |
${{runner.workspace}}/build/MVVM_checkpoint
${{runner.workspace}}/build/MVVM_restore
${{runner.workspace}}/build/MVVM_checkpoint-macos
${{runner.workspace}}/build/MVVM_restore-macos
generate_release_notes: true
draft: true
20 changes: 10 additions & 10 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,33 @@ jobs:

- name: build
working-directory: ${{runner.workspace}}/build
run: cmake --build . --config ${{matrix.build}}
run: cmake --build . --config ${{matrix.build}} && cp ${{runner.workspace}}/build/MVVM_checkpoint ${{runner.workspace}}/build/MVVM_checkpoint-ubuntu && cp ${{runner.workspace}}/build/MVVM_restore ${{runner.workspace}}/build/MVVM_restore-ubuntu

- uses: actions/upload-artifact@v2
if: ${{matrix.build}} == "Release"
if: startsWith(github.ref, 'refs/tags/') && ${{matrix.build}} == "Release"
with:
name: MVVM_checkpoint-ubuntu
path: ${{runner.workspace}}/build/MVVM_checkpoint
path: ${{runner.workspace}}/build/MVVM_checkpoint-ubuntu

- uses: actions/upload-artifact@v2
if: ${{matrix.build}} == "Release"
if: startsWith(github.ref, 'refs/tags/') && ${{matrix.build}} == "Release"
with:
name: MVVM_restore-ubuntu
path: ${{runner.workspace}}/build/MVVM_restore
path: ${{runner.workspace}}/build/MVVM_restore-ubuntu

- uses: actions/upload-artifact@v2
if: ${{matrix.build}} == "Release"
if: startsWith(github.ref, 'refs/tags/') && ${{matrix.build}} == "Release"
with:
name: gateway
path: ${{runner.workspace}}/build/gateway
path: ${{runner.workspace}}/build/gateway/gateway

- name: Publish
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && ${{matrix.build}} == "Release"
with:
files: |
${{runner.workspace}}/build/MVVM_checkpoint
${{runner.workspace}}/build/MVVM_restore
${{runner.workspace}}/build/gateway
${{runner.workspace}}/build/MVVM_checkpoint-ubuntu
${{runner.workspace}}/build/MVVM_restore-ubuntu
${{runner.workspace}}/build/gateway/gateway
generate_release_notes: true
draft: true
14 changes: 7 additions & 7 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,26 @@ jobs:
- name: build
working-directory: ${{runner.workspace}}/build
run: |
cmake --build . --config ${{matrix.build}}
cmake --build . --config ${{matrix.build}} && cp ${{runner.workspace}}/build/MVVM_checkpoint.exe ${{runner.workspace}}/build/MVVM_checkpoint-windows.exe && cp ${{runner.workspace}}/build/MVVM_restore.exe ${{runner.workspace}}/build/MVVM_restore-windows.exe
- uses: actions/upload-artifact@v2
if: ${{matrix.build}} == "Release"
if: startsWith(github.ref, 'refs/tags/') && ${{matrix.build}} == "Release"
with:
name: MVVM_checkpoint-windows
path: ${{runner.workspace}}/build/MVVM_checkpoint.exe
path: ${{runner.workspace}}/build/MVVM_checkpoint-windows.exe

- uses: actions/upload-artifact@v2
if: ${{matrix.build}} == "Release"
if: startsWith(github.ref, 'refs/tags/') && ${{matrix.build}} == "Release"
with:
name: MVVM_restore-windows
path: ${{runner.workspace}}/build/MVVM_restore.exe
path: ${{runner.workspace}}/build/MVVM_restore-windows.exe

- name: Publish
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && ${{matrix.build}} == "Release"
with:
files: |
${{runner.workspace}}/build/MVVM_checkpoint.exe
${{runner.workspace}}/build/MVVM_restore.exe
${{runner.workspace}}/build/MVVM_checkpoint-windows.exe
${{runner.workspace}}/build/MVVM_restore-windows.exe
generate_release_notes: true
draft: true
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ else ()
set(CMAKE_GENERATOR_PLATFORM "")
set(CMAKE_CXX_FLAGS "/MD")
set(LLVM_LLDB_LIB "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/lib/x64/cudart.lib" uvwasi_a uv ws2_32 "C:/Program Files/LLVM/lib/liblldb.lib")
if(MVVM_BUILD_TEST)
set(BLAS_LIBRARIES "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/lib/x64/cublas.lib")
set(BLAS_INCLUDE_DIRS "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/include/")
endif()
endif ()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
Expand Down
2 changes: 2 additions & 0 deletions include/wamr_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
#define MVVM_WAMR_NATIVE_H
#pragma once

#if defined (MVVM_BUILD_TEST)
#if defined(_WIN32)
#include <cublas_v2.h>
#include <cublas_api.h>
#include <cuda_runtime_api.h>
#else
#include <cblas.h>
#endif
#endif
#include <cstddef>
#include <cstdint>
#include <lib_export.h>
Expand Down
10 changes: 3 additions & 7 deletions src/checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include "wasm_runtime.h"
#if !defined(_WIN32)
#include "thread_manager.h"
#endif

#include <sys/socket.h>
#include <arpa/inet.h>
#endif
#include <condition_variable>
#include <cstdio>
#include <cxxopts.hpp>
Expand All @@ -20,7 +20,6 @@
#include <mutex>
#include <sstream>
#include <string>
#include <sys/socket.h>
#include <thread>
#include <tuple>

Expand All @@ -31,6 +30,7 @@ std::vector<std::unique_ptr<WAMRExecEnv>> as;
std::mutex as_mtx;
void serialize_to_file(WASMExecEnv *instance) {
// gateway
#if !defined(_WIN32)
if (!wamr->socket_fd_map_.empty()) {
// tell gateway to keep alive the server
struct sockaddr_in addr {};
Expand All @@ -50,7 +50,6 @@ void serialize_to_file(WASMExecEnv *instance) {
src_addr.is_4 = true;
}
if (src_addr.is_4 && tmp_ip4 == "0.0.0.0" || !src_addr.is_4 && tmp_ip6 == "0:0:0:0:0:0:0:0") {
#if !defined(_WIN32)
struct ifaddrs *ifaddr, *ifa;
int family, s;
char host[NI_MAXHOST];
Expand Down Expand Up @@ -91,7 +90,6 @@ void serialize_to_file(WASMExecEnv *instance) {
}

freeifaddrs(ifaddr);
#endif
}
LOGV(INFO) << "addr: "
<< fmt::format("{}.{}.{}.{}", src_addr.ip4[0], src_addr.ip4[1], src_addr.ip4[2], src_addr.ip4[3])
Expand All @@ -112,7 +110,6 @@ void serialize_to_file(WASMExecEnv *instance) {
<< " dest_port: " << wamr->op_data.addr[idx][1].port;
wamr->op_data.size += 1;
}

// Create a socket
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
LOGV(ERROR) << "socket error";
Expand Down Expand Up @@ -143,7 +140,6 @@ void serialize_to_file(WASMExecEnv *instance) {
// Clean up
close(fd);
}
#if !defined(_WIN32)
auto cluster = wasm_exec_env_get_cluster(instance);
// wasm_cluster_suspend_all_except_self(cluster, instance);
auto all_count = bh_list_length(&cluster->exec_env_list);
Expand Down
9 changes: 6 additions & 3 deletions src/restore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
#include "wamr_export.h"
#include "wamr_read_write.h"
#include "wasm_runtime.h"
#include <arpa/inet.h>
#include <cxxopts.hpp>
#include <iostream>
#include <memory>
#include <string>
#if !defined(_WIN32)
#include <arpa/inet.h>
#endif

FreadStream *reader;
FwriteStream *writer;
Expand Down Expand Up @@ -55,13 +57,13 @@ int main(int argc, char **argv) {
reader = new FreadStream((removeExtension(target) + ".bin").c_str());
wamr = new WAMRInstance(target.c_str(), false);
auto a = struct_pack::deserialize<std::vector<std::unique_ptr<WAMRExecEnv>>>(*reader).value();
#if !defined(_WIN32)
if (!a[0]->module_inst.wasi_ctx.socket_fd_map.empty()) { // new ip, old ip // only if tcp requires keepalive
// tell gateway to stop keep alive the server
struct sockaddr_in addr {};
int fd = 0;

SocketAddrPool src_addr = {.ip4 = {0}, .ip6 = {0}, .is_4 = true, .port = 0}; // get current ip
#if !defined(_WIN32)
struct ifaddrs *ifaddr, *ifa;

if (getifaddrs(&ifaddr) == -1) {
Expand Down Expand Up @@ -100,7 +102,6 @@ int main(int argc, char **argv) {
}

freeifaddrs(ifaddr);
#endif
LOGV(INFO) << "new ip is "
<< fmt::format("{}.{}.{}.{}", src_addr.ip4[0], src_addr.ip4[1], src_addr.ip4[2], src_addr.ip4[3]);
wamr->op_data.op = MVVM_SOCK_RESUME;
Expand Down Expand Up @@ -132,6 +133,8 @@ int main(int argc, char **argv) {
}
close(fd);
}
#endif
// do iptables here
wamr->recover(&a);
return 0;
}
2 changes: 1 addition & 1 deletion src/wamr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ int WAMRInstance::invoke_fopen(std::string &path, uint32 option) {

buffer_for_wasm = wasm_runtime_module_malloc(module_inst, path.size(), (void **)&buffer_);
if (buffer_for_wasm != 0) {
uint32 argv[0];
uint32 argv[2];
argv[0] = buffer_for_wasm; // pass the buffer_ address for WASM space
argv[1] = option; // the size of buffer_
strncpy(buffer_, path.c_str(), path.size()); // use native address for accessing in runtime
Expand Down
8 changes: 5 additions & 3 deletions src/wamr_wasi_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "logging.h"
#include "wamr.h"
#include <string>
#include <sys/socket.h>
extern WAMRInstance *wamr;

#if !defined(_WIN32)
#include <sys/socket.h>
struct sockaddr_in sockaddr_from_ip4(const SocketAddrPool &addr) {
struct sockaddr_in sockaddr4;
memset(&sockaddr4, 0, sizeof(sockaddr4));
Expand All @@ -25,6 +25,7 @@ struct sockaddr_in6 sockaddr_from_ip6(const SocketAddrPool &addr) {
memcpy(&sockaddr6.sin6_addr.s6_addr, addr.ip6, sizeof(addr.ip6));
return sockaddr6;
}
#endif

void WAMRWASIContext::dump_impl(WASIArguments *env) {
uint8 buf[1024];
Expand All @@ -39,7 +40,7 @@ void WAMRWASIContext::dump_impl(WASIArguments *env) {
auto dumped_res = std::make_tuple(path, op);
this->fd_map[fd] = dumped_res;
}

#if !defined(_WIN32)
for (auto [fd, socketMetaData] : wamr->socket_fd_map_) {
SocketMetaData socketMetaDataCopy = socketMetaData;
this->socket_fd_map[fd] = socketMetaDataCopy;
Expand Down Expand Up @@ -81,6 +82,7 @@ void WAMRWASIContext::dump_impl(WASIArguments *env) {
// }
}
}
#endif
}
void WAMRWASIContext::restore_impl(WASIArguments *env) {
int r;
Expand Down

0 comments on commit 4af2f2a

Please sign in to comment.