代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/libvirt 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 399548b72ba5630981db3ac434c9d2c7a46fa5e7 Mon Sep 17 00:00:00 2001
From: AlexChen <alex.chen@huawei.com>
Date: Fri, 29 Mar 2024 16:16:09 +0800
Subject: [PATCH] vdpa: support vdpa device hot plug/unplug
support vdpa device hot plug/unplug
Signed-off-by: AlexChen <alex.chen@huawei.com>
---
src/qemu/qemu_hotplug.c | 84 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 29c0856f62..87353d2149 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2761,6 +2761,82 @@ qemuDomainAttachMediatedDevice(virQEMUDriver *driver,
return ret;
}
+static int
+qemuDomainAttachVDPADevice(virQEMUDriver *driver,
+ virDomainObj *vm,
+ virDomainHostdevDef *hostdev)
+{
+ int ret = -1;
+ g_autoptr(virJSONValue) devprops = NULL;
+ bool teardowncgroup = false;
+ bool teardownlabel = false;
+ bool teardowndevice = false;
+ bool teardownmemlock = false;
+ bool releaseaddr = false;
+ qemuDomainObjPrivate *priv = vm->privateData;
+ virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_HOSTDEV,
+ { .hostdev = hostdev } };
+
+ if (qemuDomainNamespaceSetupHostdev(vm, hostdev, &teardowndevice) < 0)
+ goto cleanup;
+
+ if (qemuSetupHostdevCgroup(vm, hostdev) < 0)
+ goto cleanup;
+ teardowncgroup = true;
+
+ if (qemuSecuritySetHostdevLabel(driver, vm, hostdev) < 0)
+ goto cleanup;
+ teardownlabel = true;
+
+ if (qemuDomainEnsurePCIAddress(vm, &dev) < 0)
+ goto cleanup;
+ releaseaddr = true;
+
+ qemuAssignDeviceHostdevAlias(vm->def, &hostdev->info->alias, -1);
+
+ if (!virDomainObjIsActive(vm)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("guest unexpectedly quit during hotplug"));
+ goto cleanup;
+ }
+
+ if (!(devprops = qemuBuildHostdevVDPADevProps(hostdev)))
+ goto cleanup;
+
+ VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
+
+ if (qemuDomainAdjustMaxMemLockHostdev(vm, hostdev) < 0)
+ goto cleanup;
+ teardownmemlock = true;
+
+ qemuDomainObjEnterMonitor(vm);
+ ret = qemuMonitorAddDeviceProps(priv->mon, &devprops);
+ qemuDomainObjExitMonitor(vm);
+
+ virDomainAuditHostdev(vm, hostdev, "attach", ret == 0);
+ if (ret < 0)
+ goto cleanup;
+
+ vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
+
+ return 0;
+
+ cleanup:
+ if (teardowncgroup && qemuTeardownHostdevCgroup(vm, hostdev) < 0)
+ VIR_WARN("Unable to remove host device cgroup ACL on hotplug fail");
+ if (teardownlabel &&
+ qemuSecurityRestoreHostdevLabel(driver, vm, hostdev) < 0)
+ VIR_WARN("Unable to restore host device labelling on hotplug fail");
+ if (teardowndevice &&
+ qemuDomainNamespaceTeardownHostdev(vm, hostdev) < 0)
+ VIR_WARN("Unable to remove host device from /dev");
+ if (teardownmemlock && qemuDomainAdjustMaxMemLock(vm) < 0)
+ VIR_WARN("Unable to reset maximum locked memory on hotplug fail");
+ if (releaseaddr)
+ qemuDomainReleaseDeviceAddress(vm, hostdev->info);
+
+ return -1;
+}
static int
qemuDomainAttachHostDevice(virQEMUDriver *driver,
@@ -2806,6 +2882,9 @@ qemuDomainAttachHostDevice(virQEMUDriver *driver,
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_VDPA:
+ if (qemuDomainAttachVDPADevice(driver, vm, hostdev) < 0)
+ return -1;
+ break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -5689,6 +5768,7 @@ qemuDomainDetachPrepHostdev(virDomainObj *vm,
virDomainHostdevSubsysPCI *pcisrc = &subsys->u.pci;
virDomainHostdevSubsysSCSI *scsisrc = &subsys->u.scsi;
virDomainHostdevSubsysMediatedDev *mdevsrc = &subsys->u.mdev;
+ virDomainHostdevSubsysVDPA *vdpasrc = &subsys->u.vdpa;
virDomainHostdevDef *hostdev = NULL;
int idx;
@@ -5746,6 +5826,10 @@ qemuDomainDetachPrepHostdev(virDomainObj *vm,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_VDPA:
+ virReportError(VIR_ERR_DEVICE_MISSING,
+ _("vdpa device '%s' not found"),
+ vdpasrc->devpath);
+ break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。