Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BFB0342C8E for ; Fri, 20 Feb 2026 12:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771589140; cv=none; b=gWagTuyxtSMyRY+W9velHrpzwiosZeqDiVCvioSknSwgL9BWbvAsQJkEt9Be0dBwd6huG/BsKCAsDL7uJgQOZGSx4POqaeGs3xLqAKME8g9/U3+otNm7k7u1cmx0HwcUrU/Twx7E8PPmH8Irz8htuleCnHB6tkm0BUiTRNabSXs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771589140; c=relaxed/simple; bh=yDwcVtF7ItCZs9yU+sdCFfbPhLcMPopGhSMV+poTLMo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g1fk9vVw+RT4p3QxoLi3sESocRZVbpl/RT0fLRcXS1gly8xjWRwm/KeYauUqs8UGigrYC7Qti+cGjLbtZnEVh2qEvv3QJzcbAAhnZwO3Apbmjiex8SI4gEDM7YMCb34iYjLwCuz/jCN/IgjR22yz/IYao6nN//lgC0pYWqbESiM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=Hjn3kl5c; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="Hjn3kl5c" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=TuXuIUqlCYQ9EqO4OmDfAOnUJcDV35rNdPRo8bEBNx4=; b=Hjn3kl5cPwWxBGw+ZqjZrPMHjs PjjNMjlWMj/INWjsqJOqP4XCjrZ6Ix9iLmFfqNOwQFPAvz1sdV+aWOmgSyYxg3lMpE9JmAi2qwgCf ixb4GT9zMTizZ+S3w0e8WsdlbTouKLEKW7d5C3UtmgQVrQwatsHqFJWelFg9F85HxlRfUpFuCcsXP hzKx1zs+WvcA06xNdSNkXnaG0awV6Ws6Yl7cq3Kl/+O67IBtMp4dfF3/qE6R4kkdONs0kJ1zH7jkt h1hr67rbWwnPp/u0k8g4uCpQmTa8C+QDQigLaxAw5yPRR8rtt9LQoShvVjyyD8D4J8vDtlqCmSKUa hE11h12g==; Received: from [90.240.106.137] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vtPGL-002v0Y-Aa; Fri, 20 Feb 2026 13:05:37 +0100 From: Tvrtko Ursulin To: criu@lists.linux.dev Cc: David Francis , Tvrtko Ursulin Subject: [RFC 17/26] plugins/amdgpu: Use the load_img helper in drm file restore Date: Fri, 20 Feb 2026 12:05:05 +0000 Message-ID: <20260220120514.4540-18-tvrtko.ursulin@igalia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260220120514.4540-1-tvrtko.ursulin@igalia.com> References: <20260220120514.4540-1-tvrtko.ursulin@igalia.com> Precedence: bulk X-Mailing-List: criu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use the recently added image load helper in one more function which contains the exactly same flow of open-alloc-read. Signed-off-by: Tvrtko Ursulin --- plugins/amdgpu/amdgpu_plugin.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/plugins/amdgpu/amdgpu_plugin.c b/plugins/amdgpu/amdgpu_plugin.c index 9ba12bd3a466..a653ba1aa2d9 100644 --- a/plugins/amdgpu/amdgpu_plugin.c +++ b/plugins/amdgpu/amdgpu_plugin.c @@ -1859,7 +1859,6 @@ static int amdgpu_plugin_restore_drm_file(int id, bool *retry_needed) CriuRenderNode *rd; unsigned char *buf; size_t img_size; - FILE *img_fp; int fd, ret; /* This is restorer plugin for renderD nodes. Criu doesn't guarantee that they will @@ -1868,9 +1867,8 @@ static int amdgpu_plugin_restore_drm_file(int id, bool *retry_needed) * first as we assume restore_maps is already filled. Need to fix this later. */ snprintf(img_path, sizeof(img_path), IMG_DRM_FILE, id); - - img_fp = open_img_file(img_path, false, &img_size); - if (!img_fp) { + ret = load_img(img_path, &buf, &img_size); + if (ret < 0) { ret = amdgpu_plugin_dmabuf_restore(id); if (ret == 1) { /* This is a dmabuf fd, but the corresponding buffer object that was @@ -1882,29 +1880,16 @@ static int amdgpu_plugin_restore_drm_file(int id, bool *retry_needed) } return ret; } - pr_info("Restoring RenderD %s\n", img_path); - pr_debug("RenderD Image file size:%ld\n", img_size); - buf = xmalloc(img_size); - if (!buf) { - pr_perror("Failed to allocate memory"); - return -ENOMEM; - } - ret = read_fp(img_fp, buf, img_size); - if (ret) { - pr_perror("Unable to read from %s", img_path); - xfree(buf); - return -1; - } + pr_info("Restoring RenderD %s image of %lu bytes\n", + img_path, img_size); rd = criu_render_node__unpack(NULL, img_size, buf); if (rd == NULL) { - pr_perror("Unable to parse the RenderD message %d", id); + pr_perror("Unable to parse the RenderD image %d", id); xfree(buf); - fclose(img_fp); return -1; } - fclose(img_fp); pr_info("render node gpu_id = 0x%04x\n", rd->gpu_id); -- 2.52.0