Skip to content

Commit d3b8b3d

Browse files
committed
Update compute.json and KVM API
1 parent db75f51 commit d3b8b3d

File tree

6 files changed

+30
-17
lines changed

6 files changed

+30
-17
lines changed

c/streaming.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on_get(const char *url, const char *arg)
2727

2828
int main(int argc, char **argv)
2929
{
30-
if (strcmp(argv[0], "vmod_kvm"))
30+
if (IS_LINUX_MAIN())
3131
{
3232
puts("Hello Linux World!");
3333
return 0;

compute.json

+15-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"max_boot_time": 8.0,
55
"max_request_time": 6.0,
66
"max_memory": 64,
7-
"max_request_memory": 48,
8-
"req_mem_limit_after_reset": 16 /* Mbytes */
7+
"max_request_memory": 48
98
},
109
"avif": {
1110
"group": "compute",
@@ -47,7 +46,7 @@
4746
"uri": "https://filebin.varnish-software.com/tinykvm_programs/deflate.tar.xz",
4847
"filename": "/tmp/compute_deflate",
4948
"max_memory": 64,
50-
"max_request_memory": 16,
49+
"max_request_memory": 32,
5150
"ephemeral": false,
5251
"split_hugepages": false,
5352
"hugepage_arena_size": 64,
@@ -72,6 +71,7 @@
7271
"group": "compute",
7372
"uri": "https://filebin.varnish-software.com/tinykvm_programs/gbcemu.tar.xz",
7473
"filename": "/tmp/compute_gbcemu",
74+
"key": "123",
7575
"max_memory": 128,
7676
"max_request_memory": 64,
7777
"concurrency": 4,
@@ -91,7 +91,11 @@
9191
"uri": "https://filebin.varnish-software.com/tinykvm_programs/hello_world.tar.xz",
9292
"filename": "/tmp/compute_hello_world",
9393
"concurrency": 2,
94-
"storage": true
94+
"storage": true,
95+
"server": {
96+
"port": 8081,
97+
"systems": 64
98+
}
9599
},
96100
"jsapp": {
97101
"group": "compute",
@@ -144,8 +148,7 @@
144148
},
145149
"payload": {
146150
"group": "compute",
147-
//"uri": "https://filebin.varnish-software.com/tinykvm_programs/payload.tar.xz",
148-
"uri": "file:///home/gonzo/github/kvm_demo/cpp/.build/payload",
151+
"uri": "https://filebin.varnish-software.com/tinykvm_programs/payload.tar.xz",
149152
"filename": "/tmp/compute_payload",
150153
"max_memory": 128,
151154
"max_request_memory": 80,
@@ -217,10 +220,13 @@
217220
"webp": {
218221
"group": "compute",
219222
"uri": "https://filebin.varnish-software.com/tinykvm_programs/webpencoder.tar.xz",
223+
"key": "123",
220224
"filename": "/tmp/compute_webp",
221225
"max_memory": 128,
222226
"max_request_memory": 64,
223-
"concurrency": 2
227+
"concurrency": 2,
228+
"ephemeral": false,
229+
"hugepage_arena_size": 16
224230
},
225231
"xml": {
226232
"group": "compute",
@@ -232,7 +238,8 @@
232238
"zlibng": {
233239
"group": "compute",
234240
"uri": "https://filebin.varnish-software.com/tinykvm_programs/zlibng.tar.xz",
235-
"filename": "/tmp/compute_zlibng"
241+
"filename": "/tmp/compute_zlibng",
242+
"ephemeral": false
236243
},
237244
"zstd": {
238245
"group": "compute",

cpp/gbc/build_and_upload.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ ninja
77
popd
88

99
file=".build/gbcemu"
10-
tenant="gameboy.com"
11-
key="12daf155b8508edc4a4b8002264d7494"
12-
host="https://sandbox.varnish-software.com"
10+
tenant="gbc"
11+
key="123"
12+
host="http://127.0.0.1:8080/update"
1313

14-
curl -H "X-PostKey: $key" -H "Host: $tenant" --data-binary "@$file" -X POST $host
14+
set -x
15+
curl -D - -H "X-LiveUpdate: $key" -H "Host: $tenant" --data-binary "@$file" -X POST $host

cpp/src/hello_world.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ on_socket_prepare(int thread)
7676

7777
int main(int argc, char **argv)
7878
{
79-
Print("Hello Compute %s World!\n", argv[2]);
79+
Print("Hello Compute %s World!\n", getenv("KVM_TYPE"));
8080

8181
set_backend_get(on_get);
8282

kvm_api.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ extern "C" {
4646
extern void register_func(int, ...);
4747

4848
/**
49-
* Detecting KVM from main(). Note that we could check CPUID, but we prefer
50-
* a simple check for / in argv[0].
49+
* Detecting KVM from main(). Presence of environment variables,
50+
* like KVM_NAME and KVM_TYPE, are used to determine if the
51+
* program is running in a sandboxed environment.
5152
**/
5253
#define IS_SANDBOXED_MAIN() (getenv("KVM_NAME") != (void*)0)
5354
#define IS_LINUX_MAIN() !IS_SANDBOXED_MAIN()
54-
#define IS_STORAGE() (strcmp(getenv("KVM_TYPE"), "storage") == 0)
55+
#define IS_STORAGE() (strcmp(getenv("KVM_TYPE"), "storage") == 0)
56+
#define IS_REQUEST() (strcmp(getenv("KVM_TYPE"), "request") == 0)
57+
#define IS_DEBUG() (strcmp(getenv("KVM_DEBUG"), "1") == 0)
58+
5559
/**
5660
* During the start of the program, one should register callback functions
5761
* that will handle different types of requests, like GET, POST etc.

upload_programs.sh

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ upload_program cpp/.build/espeak
4545
upload_program cpp/.build/hello_world
4646
upload_program cpp/.build/fetch
4747
upload_program cpp/.build/minify
48+
upload_program cpp/.build/payload
4849
upload_program cpp/.build/to_string
4950
upload_program cpp/base64/.build/base64pp
5051
upload_program cpp/thumbnail/.build/thumbnails

0 commit comments

Comments
 (0)