Hello community,

here is the log from the commit of package katacontainers-image-initrd for 
openSUSE:Factory checked in at 2020-01-28 10:57:32
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/katacontainers-image-initrd (Old)
 and      /work/SRC/openSUSE:Factory/.katacontainers-image-initrd.new.26092 
(New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "katacontainers-image-initrd"

Tue Jan 28 10:57:32 2020 rev:14 rq:767918 version:1.10.0

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/katacontainers-image-initrd/katacontainers-image-initrd.changes
  2020-01-21 21:01:59.848894602 +0100
+++ 
/work/SRC/openSUSE:Factory/.katacontainers-image-initrd.new.26092/katacontainers-image-initrd.changes
       2020-01-28 10:57:40.233142445 +0100
@@ -1,0 +2,7 @@
+Mon Jan 27 17:44:14 UTC 2020 - Ralf Haferkamp <rha...@suse.com>
+
+- kata-agent: add patch agent_memory-hotplug-probe.patch to address
+  memory hotplug issue when running with SUSE kernel 
+  (https://github.com/kata-containers/agent/issues/712)
+
+-------------------------------------------------------------------

New:
----
  agent_memory-hotplug-probe.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ katacontainers-image-initrd.spec ++++++
--- /var/tmp/diff_new_pack.ensfvK/_old  2020-01-28 10:57:41.601143455 +0100
+++ /var/tmp/diff_new_pack.ensfvK/_new  2020-01-28 10:57:41.601143455 +0100
@@ -52,6 +52,8 @@
 URL:            https://github.com/kata-containers/osbuilder
 Source0:        osbuilder-%{version}.tar.xz
 Source1:        agent-%{version}.tar.xz
+# PATCH-FIX-UPSTREAM agent_memory-hotplug-probe.patch 
https://github.com/kata-containers/agent/issues/712
+Patch0:         agent_memory-hotplug-probe.patch
 ExclusiveArch:  x86_64 aarch64 ppc64le s390x
 BuildRequires:  dracut
 BuildRequires:  fdupes
@@ -65,6 +67,9 @@
 
 %prep
 %setup -q -n osbuilder-%{version} -b1
+pushd ../agent-%{version}
+%patch0 -p1
+popd
 
 %build
 export GOPATH=$HOME/go

++++++ agent_memory-hotplug-probe.patch ++++++
commit 2f4911566e9701c4f207864ebc564471812439e2
Author: Ralf Haferkamp <rha...@suse.com>
Date:   Wed Jan 15 12:01:28 2020 +0100

    agent: Fix mem-hotplug on x86 when ARCH_MEMORY_PROBE is set
    
    Don't use the /sys/devices/system/memory/probe interface on architectures
    where the firmware (ACPI) is notifying the system of hotplugged memory.
    This fixes an issue with the agent erroring out when the guest-kernel is
    compiled with CONFIG_ARCH_MEMORY_PROBE=y.
    
    Fixes: #712
    Signed-off-by: Ralf Haferkamp <rha...@suse.com>

diff --git a/grpc.go b/grpc.go
index ea0d7af..4c0dea3 100644
--- a/grpc.go
+++ b/grpc.go
@@ -54,6 +54,7 @@ var (
        sysfsMemOnlinePath          = "/sys/devices/system/memory"
        sysfsMemoryBlockSizePath    = 
"/sys/devices/system/memory/block_size_bytes"
        sysfsMemoryHotplugProbePath = "/sys/devices/system/memory/probe"
+       sysfsAcpiMemoryHotplugPath  = 
"/sys/firmware/acpi/hotplug/memory/enabled"
        sysfsConnectedCPUsPath      = filepath.Join(sysfsCPUOnlinePath, 
"online")
        containersRootfsPath        = "/run"
 
@@ -1576,6 +1577,16 @@ func (a *agentGRPC) ReseedRandomDev(ctx context.Context, 
req *pb.ReseedRandomDev
        return emptyResp, reseedRNG(req.Data)
 }
 
+func (a *agentGRPC) haveAcpiMemoryHotplug() bool {
+       enabled, err := ioutil.ReadFile(sysfsAcpiMemoryHotplugPath)
+       if err != nil {
+               return false
+       } else if strings.TrimSpace(string(enabled)) == "1" {
+               return true
+       }
+       return false
+}
+
 func (a *agentGRPC) GetGuestDetails(ctx context.Context, req 
*pb.GuestDetailsRequest) (*pb.GuestDetailsResponse, error) {
        var details pb.GuestDetailsResponse
        if req.MemBlockSize {
@@ -1603,7 +1614,13 @@ func (a *agentGRPC) GetGuestDetails(ctx context.Context, 
req *pb.GuestDetailsReq
                } else if err != nil {
                        return nil, err
                } else {
-                       details.SupportMemHotplugProbe = true
+                       // Avoid triggering memory hotplugging notifications 
when ACPI
+                       // hotplugging is enabled
+                       if a.haveAcpiMemoryHotplug() {
+                               details.SupportMemHotplugProbe = false
+                       } else {
+                               details.SupportMemHotplugProbe = true
+                       }
                }
        }
 
diff --git a/grpc_test.go b/grpc_test.go
index 768cd19..4bddb05 100644
--- a/grpc_test.go
+++ b/grpc_test.go
@@ -843,12 +843,38 @@ func TestGetGuestDetails(t *testing.T) {
        probeFile, err := ioutil.TempFile("", "probe")
        assert.NoError(err)
 
+       // sysfsAcpiMemoryHotplugPath exist and is 1
+       hotplugEnabledFile, err := ioutil.TempFile("", "enabled")
+       assert.NoError(err)
+       _, err = hotplugEnabledFile.WriteString("1")
+       assert.NoError(err)
+       hotplugEnabledFile.Sync()
+
        oldSysfsMemoryHotplugProbePath := sysfsMemoryHotplugProbePath
+       oldSysfsAcpiMemoryHotplugPath := sysfsAcpiMemoryHotplugPath
        defer func() {
                sysfsMemoryHotplugProbePath = oldSysfsMemoryHotplugProbePath
+               sysfsAcpiMemoryHotplugPath = oldSysfsAcpiMemoryHotplugPath
        }()
 
        sysfsMemoryHotplugProbePath = probeFile.Name()
+       sysfsAcpiMemoryHotplugPath = hotplugEnabledFile.Name()
+       resp, err = a.GetGuestDetails(context.TODO(), req)
+       assert.NoError(err)
+       assert.Equal(resp.SupportMemHotplugProbe, false)
+
+       // sysfsAcpiMemoryHotplugPath exist and is 0
+       _, err = hotplugEnabledFile.Seek(0, 0)
+       assert.NoError(err)
+       _, err = hotplugEnabledFile.WriteString("0")
+       assert.NoError(err)
+       hotplugEnabledFile.Sync()
+       resp, err = a.GetGuestDetails(context.TODO(), req)
+       assert.NoError(err)
+       assert.Equal(resp.SupportMemHotplugProbe, true)
+
+       // sysfsAcpiMemoryHotplugPath does not exist
+       os.Remove(sysfsAcpiMemoryHotplugPath)
        resp, err = a.GetGuestDetails(context.TODO(), req)
        assert.NoError(err)
        assert.Equal(resp.SupportMemHotplugProbe, true)

Reply via email to