1 Star 0 Fork 131

xiaoyuliang/qemu

forked from src-openEuler/qemu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
hw-vfio-hct-qemu-startup-terminate-once-error-happen.patch 2.44 KB
一键复制 编辑 原始数据 按行查看 历史
Jiabo Feng 提交于 2024-11-30 08:43 +08:00 . QEMU update to version 8.2.0-25:
From 32855e315c3050f09388f1335c0869bba065fbae Mon Sep 17 00:00:00 2001
From: yangdepei <yangdepei@hygon.cn>
Date: Fri, 27 Sep 2024 17:08:08 +0800
Subject: [PATCH] hw/vfio/hct: qemu startup terminate once error happened in
hct
Signed-off-by: yangdepei <yangdepei@hygon.cn>
---
hw/vfio/hct.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/hw/vfio/hct.c b/hw/vfio/hct.c
index 9374e95e85..7fd3977182 100644
--- a/hw/vfio/hct.c
+++ b/hw/vfio/hct.c
@@ -136,7 +136,9 @@ static const MemoryRegionOps hct_mmio_ops = {
static void vfio_hct_detach_device(HCTDevState *state)
{
vfio_detach_device(&state->vdev);
- g_free(state->vdev.name);
+
+ if (state->vdev.name)
+ g_free(state->vdev.name);
}
static void vfio_hct_exit(PCIDevice *dev)
@@ -413,7 +415,6 @@ static int hct_data_init(HCTDevState *state)
int ret;
if (hct_data.init == 0) {
-
hct_data.hct_fd = qemu_open_old(HCT_SHARE_DEV, O_RDWR);
if (hct_data.hct_fd < 0) {
error_report("fail to open %s, errno %d.", HCT_SHARE_DEV, errno);
@@ -465,7 +466,6 @@ static void vfio_hct_realize(PCIDevice *pci_dev, Error **errp)
{
int ret;
char *mdevid;
- Error *err = NULL;
HCTDevState *state = PCI_HCT_DEV(pci_dev);
/* parsing mdev device name from startup scripts */
@@ -475,14 +475,18 @@ static void vfio_hct_realize(PCIDevice *pci_dev, Error **errp)
ret = hct_data_init(state);
if (ret < 0) {
g_free(state->vdev.name);
+ state->vdev.name = NULL;
+ error_setg(errp, "hct data init failed");
goto out;
}
ret = vfio_attach_device(state->vdev.name, &state->vdev,
- pci_device_iommu_address_space(pci_dev), &err);
+ pci_device_iommu_address_space(pci_dev), errp);
if (ret) {
- error_report("attach device failed, name = %s", state->vdev.name);
+ g_free(state->vdev.name);
+ state->vdev.name = NULL;
+ error_setg(errp, "attach device failed, name = %s", state->vdev.name);
goto data_uninit_out;
}
@@ -491,7 +495,12 @@ static void vfio_hct_realize(PCIDevice *pci_dev, Error **errp)
ret = vfio_hct_region_mmap(state);
if (ret < 0)
+ {
+ g_free(state->vdev.name);
+ state->vdev.name = NULL;
+ error_setg(errp, "region mmap failed, name = %s", state->vdev.name);
goto detach_device_out;
+ }
return;
--
2.41.0.windows.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xiao-yuliang/qemu.git
git@gitee.com:xiao-yuliang/qemu.git
xiao-yuliang
qemu
qemu
master

搜索帮助