mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
qemu_driver.c: Coverity fix in qemuNodeDeviceDetachFlags()
Commit 76f47889326c4 made qemuNodeDeviceDetachFlags() unusable due to an 'if then else if' chain that will always results in a 'return -1', regardless of 'driverName' input. Found by Coverity. Fixes: 76f47889326c45d2732711bc6dd5751aaf6e5194 Reported-by: John Ferlan <jferlan@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
e2ee16dcd3
commit
d9977cc0f1
@ -11998,7 +11998,6 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
||||
unsigned int flags)
|
||||
{
|
||||
virQEMUDriverPtr driver = dev->conn->privateData;
|
||||
bool vfio = qemuHostdevHostSupportsPassthroughVFIO();
|
||||
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
@ -12006,22 +12005,27 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
||||
if (!driverName)
|
||||
driverName = "vfio";
|
||||
|
||||
if (STREQ(driverName, "vfio") && !vfio) {
|
||||
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||
_("VFIO device assignment is currently not "
|
||||
"supported on this system"));
|
||||
return -1;
|
||||
} else if (STREQ(driverName, "kvm")) {
|
||||
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||
_("KVM device assignment is no longer "
|
||||
"supported on this system"));
|
||||
return -1;
|
||||
} else {
|
||||
/* Only the 'vfio' driver is supported and a special error message for
|
||||
* the previously supported 'kvm' driver is provided below. */
|
||||
if (STRNEQ(driverName, "vfio") && STRNEQ(driverName, "kvm")) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("unknown driver name '%s'"), driverName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (STREQ(driverName, "kvm")) {
|
||||
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||
_("KVM device assignment is no longer "
|
||||
"supported on this system"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!qemuHostdevHostSupportsPassthroughVFIO()) {
|
||||
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||
_("VFIO device assignment is currently not "
|
||||
"supported on this system"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* virNodeDeviceDetachFlagsEnsureACL() is being called by
|
||||
* virDomainDriverNodeDeviceDetachFlags() */
|
||||
|
Loading…
x
Reference in New Issue
Block a user