提交 e0127260 编写于 作者: J Jiri Denemark

qemu: Don't use NULL path from qemuDomainGetHostdevPath

Commit v5.10.0-290-g3a4787a3 refactored qemuDomainGetHostdevPath to
return a single path rather than an array of paths. When the function is
called on a missing device, it will now return NULL in @path rather than
a NULL array with zero items and the callers need to be adapted
properly.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 143b71a8
...@@ -426,13 +426,15 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm, ...@@ -426,13 +426,15 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm,
if (qemuDomainGetHostdevPath(dev, &path, &perms) < 0) if (qemuDomainGetHostdevPath(dev, &path, &perms) < 0)
return -1; return -1;
VIR_DEBUG("Cgroup allow %s perms=%d", path, perms); if (path) {
rv = virCgroupAllowDevicePath(priv->cgroup, path, perms, false); VIR_DEBUG("Cgroup allow %s perms=%d", path, perms);
virDomainAuditCgroupPath(vm, priv->cgroup, "allow", path, rv = virCgroupAllowDevicePath(priv->cgroup, path, perms, false);
virCgroupGetDevicePermsString(perms), virDomainAuditCgroupPath(vm, priv->cgroup, "allow", path,
rv); virCgroupGetDevicePermsString(perms),
if (rv < 0) rv);
return -1; if (rv < 0)
return -1;
}
if (qemuHostdevNeedsVFIO(dev)) { if (qemuHostdevNeedsVFIO(dev)) {
VIR_DEBUG("Cgroup allow %s perms=%d", QEMU_DEV_VFIO, VIR_CGROUP_DEVICE_RW); VIR_DEBUG("Cgroup allow %s perms=%d", QEMU_DEV_VFIO, VIR_CGROUP_DEVICE_RW);
...@@ -473,13 +475,15 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm, ...@@ -473,13 +475,15 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm,
if (qemuDomainGetHostdevPath(dev, &path, NULL) < 0) if (qemuDomainGetHostdevPath(dev, &path, NULL) < 0)
return -1; return -1;
VIR_DEBUG("Cgroup deny %s", path); if (path) {
rv = virCgroupDenyDevicePath(priv->cgroup, path, VIR_DEBUG("Cgroup deny %s", path);
VIR_CGROUP_DEVICE_RWM, false); rv = virCgroupDenyDevicePath(priv->cgroup, path,
virDomainAuditCgroupPath(vm, priv->cgroup, VIR_CGROUP_DEVICE_RWM, false);
"deny", path, "rwm", rv); virDomainAuditCgroupPath(vm, priv->cgroup,
if (rv < 0) "deny", path, "rwm", rv);
return -1; if (rv < 0)
return -1;
}
if (qemuHostdevNeedsVFIO(dev) && if (qemuHostdevNeedsVFIO(dev) &&
!qemuDomainNeedsVFIO(vm->def)) { !qemuDomainNeedsVFIO(vm->def)) {
......
...@@ -14001,7 +14001,8 @@ qemuDomainNeedsVFIO(const virDomainDef *def) ...@@ -14001,7 +14001,8 @@ qemuDomainNeedsVFIO(const virDomainDef *def)
* *
* For given device @dev fetch its host path and store it at * For given device @dev fetch its host path and store it at
* @path. Optionally, caller can get @perms on the path (e.g. * @path. Optionally, caller can get @perms on the path (e.g.
* rw/ro). * rw/ro). When called on a missing device, the function will return success
* and store NULL at @path.
* *
* The caller is responsible for freeing the @path when no longer * The caller is responsible for freeing the @path when no longer
* needed. * needed.
...@@ -14625,7 +14626,7 @@ qemuDomainSetupHostdev(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED, ...@@ -14625,7 +14626,7 @@ qemuDomainSetupHostdev(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
if (qemuDomainGetHostdevPath(dev, &path, NULL) < 0) if (qemuDomainGetHostdevPath(dev, &path, NULL) < 0)
return -1; return -1;
if (qemuDomainCreateDevice(path, data, false) < 0) if (path && qemuDomainCreateDevice(path, data, false) < 0)
return -1; return -1;
if (qemuHostdevNeedsVFIO(dev) && if (qemuHostdevNeedsVFIO(dev) &&
...@@ -15688,7 +15689,7 @@ qemuDomainNamespaceSetupHostdev(virDomainObjPtr vm, ...@@ -15688,7 +15689,7 @@ qemuDomainNamespaceSetupHostdev(virDomainObjPtr vm,
if (qemuDomainGetHostdevPath(hostdev, &path, NULL) < 0) if (qemuDomainGetHostdevPath(hostdev, &path, NULL) < 0)
return -1; return -1;
if (qemuDomainNamespaceMknodPath(vm, path) < 0) if (path && qemuDomainNamespaceMknodPath(vm, path) < 0)
return -1; return -1;
if (qemuHostdevNeedsVFIO(hostdev) && if (qemuHostdevNeedsVFIO(hostdev) &&
...@@ -15720,7 +15721,7 @@ qemuDomainNamespaceTeardownHostdev(virDomainObjPtr vm, ...@@ -15720,7 +15721,7 @@ qemuDomainNamespaceTeardownHostdev(virDomainObjPtr vm,
if (qemuDomainGetHostdevPath(hostdev, &path, NULL) < 0) if (qemuDomainGetHostdevPath(hostdev, &path, NULL) < 0)
return -1; return -1;
if (qemuDomainNamespaceUnlinkPath(vm, path) < 0) if (path && qemuDomainNamespaceUnlinkPath(vm, path) < 0)
return -1; return -1;
if (qemuHostdevNeedsVFIO(hostdev) && if (qemuHostdevNeedsVFIO(hostdev) &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册