!20 合入0.2版本的必要patch
From: @anatas Reviewed-by: @snoweay Signed-off-by: @snoweay
This commit is contained in:
commit
416f649640
71
0002-kexec-do-kexec-load-before-criu-dump.patch
Normal file
71
0002-kexec-do-kexec-load-before-criu-dump.patch
Normal file
@ -0,0 +1,71 @@
|
||||
From 6a262bdec754c90ab9cbb3504588648599c4a8b5 Mon Sep 17 00:00:00 2001
|
||||
From: anatasluo <luolongjuna@gmail.com>
|
||||
Date: Thu, 25 Mar 2021 11:22:43 +0800
|
||||
Subject: [PATCH 08/20] kexec: do kexec load before criu dump
|
||||
|
||||
Signed-off-by: anatasluo <luolongjuna@gmail.com>
|
||||
---
|
||||
src/server.go | 40 ++++++++++++++++++++--------------------
|
||||
1 file changed, 20 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/src/server.go b/src/server.go
|
||||
index 79a94b9..c6eead7 100644
|
||||
--- a/src/server.go
|
||||
+++ b/src/server.go
|
||||
@@ -252,7 +252,26 @@ func UpdateImage(ver string) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
- err := findPids(criuPids)
|
||||
+ kexecLoad := "-l"
|
||||
+ if enableQK {
|
||||
+ kexecLoad = "-q"
|
||||
+ }
|
||||
+
|
||||
+ cmdline, err := loadCmdline()
|
||||
+ if err != nil {
|
||||
+ log.Error(err)
|
||||
+ return -1
|
||||
+ }
|
||||
+
|
||||
+ err, _ = runCmd(kexecExe, []string{kexecLoad, "/boot/vmlinuz-" + ver,
|
||||
+ "--initrd", "/boot/initramfs-" + ver + ".img", "--append=" +
|
||||
+ cmdline}, os.Stdin, os.Stdout, os.Stderr)
|
||||
+ if err != nil {
|
||||
+ log.Errorf("Unable to load kernel image, err is %s \n", err)
|
||||
+ return -1
|
||||
+ }
|
||||
+
|
||||
+ err = findPids(criuPids)
|
||||
if err != nil {
|
||||
return -1
|
||||
}
|
||||
@@ -305,25 +324,6 @@ func UpdateImage(ver string) int {
|
||||
|
||||
DumpAllNet(configDir)
|
||||
|
||||
- cmdline, err := loadCmdline()
|
||||
- if err != nil {
|
||||
- log.Error(err)
|
||||
- return -1
|
||||
- }
|
||||
-
|
||||
- kexecLoad := "-l"
|
||||
- if enableQK {
|
||||
- kexecLoad = "-q"
|
||||
- }
|
||||
-
|
||||
- err, _ = runCmd(kexecExe, []string{kexecLoad, "/boot/vmlinuz-" + ver,
|
||||
- "--initrd", "/boot/initramfs-" + ver + ".img", "--append=" +
|
||||
- cmdline}, os.Stdin, os.Stdout, os.Stderr)
|
||||
- if err != nil {
|
||||
- log.Errorf("Unable to load kernel image, err is %s \n", err)
|
||||
- return -1
|
||||
- }
|
||||
-
|
||||
err, _ = runCmd(kexecExe, []string{"-e"}, os.Stdin, os.Stdout, os.Stderr)
|
||||
if err != nil {
|
||||
log.Errorf("Unable to run kexec -e with err %s \n", err)
|
||||
--
|
||||
2.31.1
|
||||
|
||||
26
0003-nvwa-move-socket-from-tmp-to-run.patch
Normal file
26
0003-nvwa-move-socket-from-tmp-to-run.patch
Normal file
@ -0,0 +1,26 @@
|
||||
From 08ece5f9af894e245d274fff55d75730504db069 Mon Sep 17 00:00:00 2001
|
||||
From: anatasluo <luolongjuna@gmail.com>
|
||||
Date: Thu, 25 Mar 2021 16:55:50 +0800
|
||||
Subject: [PATCH 09/20] nvwa: move socket from /tmp to /run
|
||||
|
||||
Signed-off-by: anatasluo <luolongjuna@gmail.com>
|
||||
---
|
||||
src/main.go | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/main.go b/src/main.go
|
||||
index 3845a63..d139f78 100644
|
||||
--- a/src/main.go
|
||||
+++ b/src/main.go
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"flag"
|
||||
)
|
||||
|
||||
-var socketPath = "/tmp/nvwa.socket"
|
||||
+var socketPath = "/run/nvwa.socket"
|
||||
|
||||
func main() {
|
||||
server := flag.Int("server", 0,
|
||||
--
|
||||
2.31.1
|
||||
|
||||
26
0004-kexec-add-x.patch
Normal file
26
0004-kexec-add-x.patch
Normal file
@ -0,0 +1,26 @@
|
||||
From a7d47d33d2694b76f7d69c1c4c0beebc15fd5931 Mon Sep 17 00:00:00 2001
|
||||
From: anatasluo <luolongjuna@gmail.com>
|
||||
Date: Tue, 30 Mar 2021 14:33:31 +0800
|
||||
Subject: [PATCH 10/20] kexec: add -x
|
||||
|
||||
Signed-off-by: anatasluo <luolongjuna@gmail.com>
|
||||
---
|
||||
src/server.go | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/server.go b/src/server.go
|
||||
index c6eead7..1185789 100644
|
||||
--- a/src/server.go
|
||||
+++ b/src/server.go
|
||||
@@ -324,7 +324,7 @@ func UpdateImage(ver string) int {
|
||||
|
||||
DumpAllNet(configDir)
|
||||
|
||||
- err, _ = runCmd(kexecExe, []string{"-e"}, os.Stdin, os.Stdout, os.Stderr)
|
||||
+ err, _ = runCmd(kexecExe, []string{"-e", "-x"}, os.Stdin, os.Stdout, os.Stderr)
|
||||
if err != nil {
|
||||
log.Errorf("Unable to run kexec -e with err %s \n", err)
|
||||
return -1
|
||||
--
|
||||
2.31.1
|
||||
|
||||
63
0005-nvwa-move-unix-socket-from-run-to-run-nvwa.patch
Normal file
63
0005-nvwa-move-unix-socket-from-run-to-run-nvwa.patch
Normal file
@ -0,0 +1,63 @@
|
||||
From ae05433278739b1faafef7e18debccefc920c046 Mon Sep 17 00:00:00 2001
|
||||
From: anatasluo <luolongjuna@gmail.com>
|
||||
Date: Wed, 31 Mar 2021 15:37:52 +0800
|
||||
Subject: [PATCH 11/20] nvwa: move unix socket from /run to /run/nvwa
|
||||
|
||||
Signed-off-by: anatasluo <luolongjuna@gmail.com>
|
||||
---
|
||||
src/main.go | 2 +-
|
||||
src/server.go | 12 ++++++++++++
|
||||
2 files changed, 13 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/main.go b/src/main.go
|
||||
index d139f78..bcb5bb4 100644
|
||||
--- a/src/main.go
|
||||
+++ b/src/main.go
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"flag"
|
||||
)
|
||||
|
||||
-var socketPath = "/run/nvwa.socket"
|
||||
+var socketPath = "/run/nvwa/nvwa.socket"
|
||||
|
||||
func main() {
|
||||
server := flag.Int("server", 0,
|
||||
diff --git a/src/server.go b/src/server.go
|
||||
index 1185789..3de06a5 100644
|
||||
--- a/src/server.go
|
||||
+++ b/src/server.go
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
+ "path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@@ -431,12 +432,23 @@ func ExitServer(msg string) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
+func may_init_socket(path string) error {
|
||||
+ socketDir := filepath.Dir(path)
|
||||
+ log.Debugf("Socket directory %s \n", socketDir)
|
||||
+ return os.Mkdir(socketDir, 0700)
|
||||
+}
|
||||
+
|
||||
func runServer(path string) {
|
||||
registerRPC("update", UpdateImage)
|
||||
registerRPC("restore", RestoreService)
|
||||
registerRPC("init", InitEnv)
|
||||
registerRPC("exit", ExitServer)
|
||||
|
||||
+ err := may_init_socket(path)
|
||||
+ if err != nil {
|
||||
+ log.Fatal(err)
|
||||
+ }
|
||||
+
|
||||
addr, err := net.ResolveUnixAddr("unix", path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
--
|
||||
2.31.1
|
||||
|
||||
32
0006-pin-move-pin-from-tools-to-tools-pin.patch
Normal file
32
0006-pin-move-pin-from-tools-to-tools-pin.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From a433f4516b4d32988cea19ca9be35423d430b725 Mon Sep 17 00:00:00 2001
|
||||
From: anatasluo <luolongjuna@gmail.com>
|
||||
Date: Wed, 31 Mar 2021 15:44:28 +0800
|
||||
Subject: [PATCH 12/20] pin: move pin from tools to tools/pin
|
||||
|
||||
Signed-off-by: anatasluo <luolongjuna@gmail.com>
|
||||
---
|
||||
nvwa.spec | 2 +-
|
||||
tools/{ => pin}/nvwa-pin.c | 0
|
||||
2 files changed, 1 insertion(+), 1 deletion(-)
|
||||
rename tools/{ => pin}/nvwa-pin.c (100%)
|
||||
|
||||
diff --git a/nvwa.spec b/nvwa.spec
|
||||
index f1d6cbb..8eba081 100644
|
||||
--- a/nvwa.spec
|
||||
+++ b/nvwa.spec
|
||||
@@ -28,7 +28,7 @@ go build -mod=vendor
|
||||
cd -
|
||||
|
||||
cd tools
|
||||
-gcc %{name}-pin.c -o %{name}-pin
|
||||
+gcc ./pin/%{name}-pin.c -o %{name}-pin
|
||||
cd -
|
||||
|
||||
%install
|
||||
diff --git a/tools/nvwa-pin.c b/tools/pin/nvwa-pin.c
|
||||
similarity index 100%
|
||||
rename from tools/nvwa-pin.c
|
||||
rename to tools/pin/nvwa-pin.c
|
||||
--
|
||||
2.31.1
|
||||
|
||||
18
nvwa.spec
18
nvwa.spec
@ -1,6 +1,6 @@
|
||||
Name: nvwa
|
||||
Version: 0.1
|
||||
Release: 4
|
||||
Release: 5
|
||||
Summary: a tool used for openEuler kernel update
|
||||
|
||||
License: MulanPSL-2.0 and Apache-2.0 and MIT and MPL-2.0
|
||||
@ -8,6 +8,11 @@ URL: https://gitee.com/openeuler/nvwa
|
||||
Source: %{name}-v%{version}.tar.gz
|
||||
|
||||
Patch1: 0001-add-use-fork-pid-support-for-kernel-4.19.patch
|
||||
Patch2: 0002-kexec-do-kexec-load-before-criu-dump.patch
|
||||
Patch3: 0003-nvwa-move-socket-from-tmp-to-run.patch
|
||||
Patch4: 0004-kexec-add-x.patch
|
||||
Patch5: 0005-nvwa-move-unix-socket-from-run-to-run-nvwa.patch
|
||||
Patch6: 0006-pin-move-pin-from-tools-to-tools-pin.patch
|
||||
|
||||
BuildRequires: golang >= 1.13
|
||||
Requires: kexec-tools criu
|
||||
@ -28,7 +33,7 @@ cd src
|
||||
go build -mod=vendor -buildmode=pie
|
||||
cd -
|
||||
|
||||
cd tools
|
||||
cd tools/pin
|
||||
gcc %{name}-pin.c -o %{name}-pin -fstack-protector-all -fPIE -pie -Wl,-z,noexecstack,-z,relro,-z,now
|
||||
cd -
|
||||
|
||||
@ -42,7 +47,7 @@ mkdir -p %{buildroot}/var/%{name}
|
||||
mkdir -p %{buildroot}/var/%{name}/running
|
||||
|
||||
install -m 0750 %{_builddir}/%{name}-v%{version}/src/%{name} %{buildroot}/%{_bindir}/
|
||||
install -m 0750 %{_builddir}/%{name}-v%{version}/tools/%{name}-pin %{buildroot}/%{_bindir}/
|
||||
install -m 0750 %{_builddir}/%{name}-v%{version}/tools/pin/%{name}-pin %{buildroot}/%{_bindir}/
|
||||
install -m 0640 %{_builddir}/%{name}-v%{version}/config/%{name}-restore.yaml %{buildroot}/etc/%{name}/
|
||||
install -m 0640 %{_builddir}/%{name}-v%{version}/config/%{name}-server.yaml %{buildroot}/etc/%{name}/
|
||||
|
||||
@ -75,6 +80,13 @@ install -m 0644 %{_builddir}/%{name}-v%{version}/misc/%{name}-pre.service %{buil
|
||||
%{_bindir}/%{name}-pre.sh
|
||||
|
||||
%changelog
|
||||
* Sat 31 Jul 2021 anatasluo <luolongjuna@gmail.com> - 0.1-5
|
||||
- Add necessary patches from version 0.2
|
||||
- Do kexec before criu dump
|
||||
- Change nvwa socket location
|
||||
- Add x for kexec
|
||||
- Change pin location
|
||||
|
||||
* Mon 26 Jul 2021 anatasluo <luolongjuna@gmail.com> - 0.1-4
|
||||
- Add use fork pid support for kernel 4.19
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user