2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 01:51:51 +00:00

criu/plugin: Implement dummy amdgpu plugin hooks

This is just a placeholder dummy plugin and will be replaced by a proper
plugin that implements support for AMD GPU devices. This just
facilitates the initial pull request and CI build test trigger for early
code review of CRIU specific changes. Future PRs will bring in more
support for amdgpu_plugin to enable CRIU with AMD ROCm.

Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
This commit is contained in:
Rajneesh Bhardwaj 2021-07-15 01:34:08 -04:00 committed by Andrei Vagin
parent 17e2a8c709
commit 7b6239b6dd
4 changed files with 66 additions and 3 deletions

View File

@ -284,15 +284,19 @@ clean mrproper:
$(Q) $(MAKE) $(build)=crit $@
.PHONY: clean mrproper
clean-dummy_amdgpu_plugin:
$(Q) $(MAKE) -C plugins/amdgpu clean
.PHONY: clean dummy_amdgpu_plugin
clean-top:
$(Q) $(MAKE) -C Documentation clean
$(Q) $(MAKE) $(build)=test/compel clean
$(Q) $(RM) .gitid
.PHONY: clean-top
clean: clean-top
clean: clean-top clean-dummy_amdgpu_plugin
mrproper-top: clean-top
mrproper-top: clean-top clean-dummy_amdgpu_plugin
$(Q) $(RM) $(CONFIG_HEADER)
$(Q) $(RM) $(VERSION_HEADER)
$(Q) $(RM) $(COMPEL_VERSION_HEADER)
@ -320,6 +324,10 @@ test: zdtm
$(Q) $(MAKE) -C test
.PHONY: test
dummy_amdgpu_plugin:
$(Q) $(MAKE) -C plugins/amdgpu all
.PHONY: dummy_amdgpu_plugin
#
# Generating tar requires tag matched CRIU_VERSION.
# If not found then simply use GIT's describe with

View File

@ -7,6 +7,7 @@ MANDIR ?= $(PREFIX)/share/man
INCLUDEDIR ?= $(PREFIX)/include
LIBEXECDIR ?= $(PREFIX)/libexec
RUNDIR ?= /run
PLUGINDIR ?= /var/lib/criu
#
# For recent Debian/Ubuntu with multiarch support.
@ -26,7 +27,7 @@ endif
LIBDIR ?= $(PREFIX)/lib
export PREFIX BINDIR SBINDIR MANDIR RUNDIR
export LIBDIR INCLUDEDIR LIBEXECDIR
export LIBDIR INCLUDEDIR LIBEXECDIR PLUGINDIR
install-man:
$(Q) $(MAKE) -C Documentation install
@ -40,6 +41,10 @@ install-criu: criu
$(Q) $(MAKE) $(build)=criu install
.PHONY: install-criu
install-dummy_amdgpu_plugin: dummy_amdgpu_plugin
$(Q) $(MAKE) -C plugins/amdgpu install
.PHONY: install-dummy_amdgpu_plugin
install-compel: $(compel-install-targets)
$(Q) $(MAKE) $(build)=compel install
$(Q) $(MAKE) $(build)=compel/plugins install
@ -54,4 +59,5 @@ uninstall:
$(Q) $(MAKE) $(build)=criu $@
$(Q) $(MAKE) $(build)=compel $@
$(Q) $(MAKE) $(build)=compel/plugins $@
$(Q) $(MAKE) -C plugins/amdgpu $@
.PHONY: uninstall

13
plugins/amdgpu/Makefile Normal file
View File

@ -0,0 +1,13 @@
all: dummy_plugin.so
dummy_plugin.so: dummy_plugin.c
gcc -g -Werror -D _GNU_SOURCE -Wall -shared -nostartfiles dummy_plugin.c -o dummy_plugin.so -iquote ../../../criu/include -iquote ../../criu/include -fPIC
clean:
$(Q) $(RM) dummy_plugin.so
install:
$(Q) mkdir -p $(PLUGINDIR)
$(Q) install -m 644 dummy_plugin.so $(PLUGINDIR)
uninstall:
$(Q) $(RM) $(PLUGINDIR)/dummy_plugin.so

View File

@ -0,0 +1,36 @@
#include <sys/stat.h>
#include "criu-log.h"
#include "criu-plugin.h"
int dummy_plugin_handle_device_vma(int fd, const struct stat *stat)
{
pr_info("dummy_plugin: Inside %s for fd = %d\n", __func__, fd);
/* let criu report failure for the unsupported mapping */
return -ENOTSUP;
}
CR_PLUGIN_REGISTER_HOOK(CR_PLUGIN_HOOK__HANDLE_DEVICE_VMA, dummy_plugin_handle_device_vma)
int dummy_plugin_resume_devices_late(int target_pid)
{
pr_info("dummy_plugin: Inside %s for target pid = %d\n", __func__, target_pid);
return -ENOTSUP;
}
CR_PLUGIN_REGISTER_HOOK(CR_PLUGIN_HOOK__RESUME_DEVICES_LATE, dummy_plugin_resume_devices_late)
/*
* return 0 if no match found
* return -1 for error or -ENOTSUP.
* return 1 if vmap map must be adjusted.
*/
int dummy_plugin_update_vmamap(const char *old_path, char *new_path, const uint64_t addr, const uint64_t old_offset,
uint64_t *new_offset)
{
uint64_t temp = 100;
*new_offset = temp;
pr_info("dummy_plugin: old_pgoff= 0x%lu new_pgoff = 0x%lx old_path = %s new_path = %s addr = 0x%lu\n",
old_offset, *new_offset, old_path, new_path, addr);
return -ENOTSUP;
}
CR_PLUGIN_REGISTER_HOOK(CR_PLUGIN_HOOK__UPDATE_VMA_MAP, dummy_plugin_update_vmamap)