Qemu模拟CXL pmem搭建问题记录

项目场景:

使用 QEMU 仿真测试 CXL2.0 设备

项目地址(网络大佬开源项目):https://github.com/linuslau/CXL-Emulator-QEMU


问题描述

在编译ndctl工具源码时,出现头文件不兼容问题,如下图所示:

[1/80] Compiling C object test/fwctl.p/fwctl.c.o FAILED: test/fwctl.p/fwctl.c.o cc -Itest/fwctl.p -Itest -I../test -I. -I.. -Indctl -I../ndctl -I/usr/include/uuid -fdiagnostics-coloc In file included from ../test/fwctl.c:17: ../cxl/fwctl/features.h:108:9: error: expected specifier-qualifier-list before ‘__struct_group’ 108 | __struct_group(cxl_mbox_get_sup_feats_out_hdr, hdr, /* no attrs */, | ^~~~~~~~~~~~~~ ../cxl/fwctl/features.h:162:9: error: expected specifier-qualifier-list before ‘__struct_group’ 162 | __struct_group(cxl_mbox_set_feat_hdr, hdr, /* no attrs */, | ^~~~~~~~~~~~~~ In file included from ../test/fwctl.c:19: ../cxl/fwctl/cxl.h:25:9: error: expected specifier-qualifier-list before ‘__struct_group’ 25 | __struct_group(fwctl_rpc_cxl_hdr, hdr, /* no attrs */, | ^~~~~~~~~~~~~~ ../cxl/fwctl/cxl.h:46:9: error: expected specifier-qualifier-list before ‘__struct_group’


原因分析:

查看我的宿主机Ubuntu为24.04,内核版本为6.14.0,客户机安装的Ubuntu为22.04,默认内核版本为5.15.0。虽然升级到6.8.0运行内核为6.8.0,但apt仓库内核还为5.15.0。导致内核头文件里找不到对应的__struct_group结构体,编译报错。


解决方案:

升级内核头文件:

1、首先检查仓库源列表是否完整:

vim /etc/apt/sources.list

        确保至少包含这些行(以 Ubuntu 22.04 为例):

deb http://archive.ubuntu.com/ubuntu jammy main universe restricted multiverse
deb http://archive.ubuntu.com/ubuntu jammy-updates main universe restricted multiverse
deb http://archive.ubuntu.com/ubuntu jammy-security main universe restricted multiverse

2、安装与 6.8.x 匹配的 HWE 头文件包

apt update
apt install linux-headers-generic-hwe-22.04

        这个包会拉取 linux-headers-6.8.x 系列

3、检查是否成功:

dpkg -l | grep linux-headers

        有输出表示,升级成功了。

最后,再编译ndctl工具便可以完成编译。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值