提交 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,6 +426,7 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm, ...@@ -426,6 +426,7 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm,
if (qemuDomainGetHostdevPath(dev, &path, &perms) < 0) if (qemuDomainGetHostdevPath(dev, &path, &perms) < 0)
return -1; return -1;
if (path) {
VIR_DEBUG("Cgroup allow %s perms=%d", path, perms); VIR_DEBUG("Cgroup allow %s perms=%d", path, perms);
rv = virCgroupAllowDevicePath(priv->cgroup, path, perms, false); rv = virCgroupAllowDevicePath(priv->cgroup, path, perms, false);
virDomainAuditCgroupPath(vm, priv->cgroup, "allow", path, virDomainAuditCgroupPath(vm, priv->cgroup, "allow", path,
...@@ -433,6 +434,7 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm, ...@@ -433,6 +434,7 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm,
rv); rv);
if (rv < 0) if (rv < 0)
return -1; 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,6 +475,7 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm, ...@@ -473,6 +475,7 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm,
if (qemuDomainGetHostdevPath(dev, &path, NULL) < 0) if (qemuDomainGetHostdevPath(dev, &path, NULL) < 0)
return -1; return -1;
if (path) {
VIR_DEBUG("Cgroup deny %s", path); VIR_DEBUG("Cgroup deny %s", path);
rv = virCgroupDenyDevicePath(priv->cgroup, path, rv = virCgroupDenyDevicePath(priv->cgroup, path,
VIR_CGROUP_DEVICE_RWM, false); VIR_CGROUP_DEVICE_RWM, false);
...@@ -480,6 +483,7 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm, ...@@ -480,6 +483,7 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm,
"deny", path, "rwm", rv); "deny", path, "rwm", rv);
if (rv < 0) if (rv < 0)
return -1; 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.
先完成此消息的编辑!
想要评论请 注册