From 9652547b19135538579751c7004fe268007c7352 Mon Sep 17 00:00:00 2001 From: huyubiao Date: Mon, 24 Nov 2025 09:10:00 +0800 Subject: [PATCH] add debug --- kata-containers.spec | 8 +- ...ilation-options-to-runtime-directory.patch | 2 +- patches/0013-add-debug.patch | 110 ++++++++++++++++++ patches/0014-add-debug.patch | 37 ++++++ series.conf | 4 +- 5 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 patches/0013-add-debug.patch create mode 100644 patches/0014-add-debug.patch diff --git a/kata-containers.spec b/kata-containers.spec index 8189ee8..d9b485b 100644 --- a/kata-containers.spec +++ b/kata-containers.spec @@ -2,7 +2,7 @@ %global debug_package %{nil} %define VERSION 3.2.0 -%define RELEASE 12 +%define RELEASE 13 Name: kata-containers Version: %{VERSION} @@ -139,6 +139,12 @@ strip %{buildroot}/usr/bin/containerd-shim-kata-v2 %doc %changelog +* Mon Nov 24 2025 huyubiao - 3.2.0-13 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:add debug + * Tue Nov 18 2025 dongyuzhen - 3.2.0-12 - Type:bugfix - ID:NA diff --git a/patches/0008-add-compilation-options-to-runtime-directory.patch b/patches/0008-add-compilation-options-to-runtime-directory.patch index 94db5a6..a3ba819 100644 --- a/patches/0008-add-compilation-options-to-runtime-directory.patch +++ b/patches/0008-add-compilation-options-to-runtime-directory.patch @@ -18,7 +18,7 @@ index fb35a2c6..1af1fbe3 100644 +#Define security option compilation function (arguments: $1=directory path, $2=output filename, $3=extra ldflags) +define BUILD_WITH_SECURITY_OPTS + (cd $(1) && \ -+ CGO_CFLAGS="-fstack-protector-strong -fPIE -D_FORTIFY_SOURCE=2 -O2" \ ++ CGO_CFLAGS="-fstack-protector-strong -fno-pie -D_FORTIFY_SOURCE=2 -O2" \ + CGO_LDFLAGS_ALLOW="-Wl,-z,relro,-z,now" \ + CGO_LDFLAGS="-Wl,-z,relro,-z,now -Wl,-z,noexecstack" \ + go build $(KATA_LDFLAGS) $(BUILDFLAGS) -o $(2) -ldflags "$(3)" .) diff --git a/patches/0013-add-debug.patch b/patches/0013-add-debug.patch new file mode 100644 index 0000000..6792a99 --- /dev/null +++ b/patches/0013-add-debug.patch @@ -0,0 +1,110 @@ +From f74f7d80d35166dced75dd1e218b46ae7a24733d Mon Sep 17 00:00:00 2001 +From: huyubiao +Date: Mon, 24 Nov 2025 08:48:51 +0800 +Subject: [PATCH] add debug + +--- + kata-containers-3.2.0/src/runtime/Makefile | 2 +- + src/runtime/Makefile | 2 +- + .../pkg/cloud-hypervisor/client/client.go | 37 ++++++++++++------- + 3 files changed, 26 insertions(+), 15 deletions(-) + +diff --git a/kata-containers-3.2.0/src/runtime/Makefile b/kata-containers-3.2.0/src/runtime/Makefile +index 33fa8f2..700bbfe 100644 +--- a/kata-containers-3.2.0/src/runtime/Makefile ++++ b/kata-containers-3.2.0/src/runtime/Makefile +@@ -624,7 +624,7 @@ QUIET_TEST = $(Q:@=@echo ' TEST '$@;) + BUILDTAGS := + + # go build common flags +-BUILDFLAGS := -buildmode=pie -mod=vendor ${BUILDTAGS} ++BUILDFLAGS := -buildmode=default -mod=vendor ${BUILDTAGS} + + # whether stipping the binary + ifeq ($(STRIP),yes) +diff --git a/src/runtime/Makefile b/src/runtime/Makefile +index db71e8d..aa5af54 100644 +--- a/src/runtime/Makefile ++++ b/src/runtime/Makefile +@@ -673,7 +673,7 @@ QUIET_TEST = $(Q:@=@echo ' TEST '$@;) + BUILDTAGS := + + # go build common flags +-BUILDFLAGS := -buildmode=pie -mod=vendor ${BUILDTAGS} ++BUILDFLAGS := -buildmode=default -mod=vendor ${BUILDTAGS} + + # whether stipping the binary + ifeq ($(STRIP),yes) +diff --git a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/client.go b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/client.go +index 757d7a3..37e1862 100644 +--- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/client.go ++++ b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/client.go +@@ -19,7 +19,7 @@ import ( + "fmt" + "io" + "io/ioutil" +- "log" ++ // "log" + "mime/multipart" + "net/http" + "net/http/httputil" +@@ -33,6 +33,8 @@ import ( + "time" + "unicode/utf8" + ++ "github.com/sirupsen/logrus" ++ + "golang.org/x/oauth2" + ) + +@@ -160,26 +162,35 @@ func parameterToJson(obj interface{}) (string, error) { + + // callAPI do the request. + func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { +- if c.cfg.Debug { +- dump, err := httputil.DumpRequestOut(request, true) +- if err != nil { +- return nil, err +- } +- log.Printf("\n%s\n", string(dump)) ++ ++ // 直接写入文件 ++ file, err := os.OpenFile("/home/hyb/kata-runtime.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644) ++ if err == nil { ++ defer file.Close() ++ } ++ ++ dump, err := httputil.DumpRequestOut(request, true) ++ if err != nil { ++ return nil, err + } ++ // log.Printf("\n%s\n", string(dump)) ++ logrus.Printf("\n%s\n", string(dump)) + + resp, err := c.cfg.HTTPClient.Do(request) + if err != nil { + return resp, err + } + +- if c.cfg.Debug { +- dump, err := httputil.DumpResponse(resp, true) +- if err != nil { +- return resp, err +- } +- log.Printf("\n%s\n", string(dump)) ++ dump, err = httputil.DumpResponse(resp, true) ++ if err != nil { ++ return resp, err + } ++ // log.Printf("\n%s\n", string(dump)) ++ logrus.Printf("\n%s\n", string(dump)) ++ ++ file.WriteString("=== API Resp ===\n") ++ file.Write(dump) ++ file.WriteString("\n") + return resp, err + } + +-- +2.43.0 + diff --git a/patches/0014-add-debug.patch b/patches/0014-add-debug.patch new file mode 100644 index 0000000..07693b8 --- /dev/null +++ b/patches/0014-add-debug.patch @@ -0,0 +1,37 @@ +From 4de3bc27f4dd1c404f88002d26ebf5f4e3a55088 Mon Sep 17 00:00:00 2001 +From: huyubiao +Date: Wed, 26 Nov 2025 08:55:07 +0800 +Subject: [PATCH] add debug + +--- + .../virtcontainers/pkg/cloud-hypervisor/client/client.go | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/client.go b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/client.go +index 37e1862..cf93265 100644 +--- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/client.go ++++ b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/client.go +@@ -174,7 +174,10 @@ func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + return nil, err + } + // log.Printf("\n%s\n", string(dump)) +- logrus.Printf("\n%s\n", string(dump)) ++ logrus.Warnf("\n%s\n", string(dump)) ++ file.WriteString("=== API Req ===\n") ++ file.Write(dump) ++ file.WriteString("\n") + + resp, err := c.cfg.HTTPClient.Do(request) + if err != nil { +@@ -186,7 +189,7 @@ func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + return resp, err + } + // log.Printf("\n%s\n", string(dump)) +- logrus.Printf("\n%s\n", string(dump)) ++ logrus.Warnf("\n%s\n", string(dump)) + + file.WriteString("=== API Resp ===\n") + file.Write(dump) +-- +2.43.0 + diff --git a/series.conf b/series.conf index 21ef96e..9995459 100644 --- a/series.conf +++ b/series.conf @@ -5,6 +5,6 @@ 0005-mount-Reduce-the-mount-points-with-namespace-isolati.patch 0006-Allow-swappiness-to-be-1-as-default.patch 0007-Add-support-for-riscv64-platform.patch -0008-add-compilation-options-to-runtime-directory.patch 0009-kata-runtime-9p-use-cache-none.patch -0012-fix-the-missing-secure-compilation-option.patch +0013-add-debug.patch +0014-add-debug.patch -- Gitee