mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 20:45:18 +00:00
qemu: Fix improper union member access on hostdevs
Add missing checks if a hostdev is a subsystem/SCSI device before access the union member 'subsys'/'scsi'. Also fix indentation and simplify qemuDomainObjCheckHostdevTaint(). Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
This commit is contained in:
parent
ae381879f3
commit
505bc9b025
@ -4037,12 +4037,12 @@ void qemuDomainObjCheckHostdevTaint(virQEMUDriverPtr driver,
|
||||
virDomainHostdevDefPtr hostdev,
|
||||
qemuDomainLogContextPtr logCtxt)
|
||||
{
|
||||
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
|
||||
if (!(hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI))
|
||||
return;
|
||||
|
||||
if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
|
||||
scsisrc->rawio == VIR_TRISTATE_BOOL_YES)
|
||||
qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_HIGH_PRIVILEGES,
|
||||
logCtxt);
|
||||
if (hostdev->source.subsys.u.scsi.rawio == VIR_TRISTATE_BOOL_YES)
|
||||
qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_HIGH_PRIVILEGES, logCtxt);
|
||||
}
|
||||
|
||||
|
||||
|
@ -4312,6 +4312,10 @@ qemuProcessSetupRawIO(virQEMUDriverPtr driver,
|
||||
/* If rawio not already set, check hostdevs as well */
|
||||
if (!rawio) {
|
||||
for (i = 0; i < vm->def->nhostdevs; i++) {
|
||||
if (!(vm->def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||
vm->def->hostdevs[i]->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI))
|
||||
continue;
|
||||
|
||||
virDomainHostdevSubsysSCSIPtr scsisrc =
|
||||
&vm->def->hostdevs[i]->source.subsys.u.scsi;
|
||||
if (scsisrc->rawio == VIR_TRISTATE_BOOL_YES) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user