mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemu: Fix segmentation fault when attaching a non iSCSI host device
Add a check if it's a iSCSI hostdev and if it's not then don't use the union member 'iscsi'. The segmentation fault occured when accessing secinfo->type, but this can vary from case to case. 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
2efd35a307
commit
97202988d9
@ -2343,8 +2343,6 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
|
||||
bool secobjAdded = false;
|
||||
virJSONValuePtr secobjProps = NULL;
|
||||
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
|
||||
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
|
||||
qemuDomainStorageSourcePrivatePtr srcPriv;
|
||||
qemuDomainSecretInfoPtr secinfo = NULL;
|
||||
|
||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
|
||||
@ -2386,9 +2384,12 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
|
||||
if (qemuDomainSecretHostdevPrepare(conn, priv, hostdev) < 0)
|
||||
goto cleanup;
|
||||
|
||||
srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src);
|
||||
if (srcPriv)
|
||||
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
|
||||
qemuDomainStorageSourcePrivatePtr srcPriv =
|
||||
QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(scsisrc->u.iscsi.src);
|
||||
secinfo = srcPriv->secinfo;
|
||||
}
|
||||
|
||||
if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
|
||||
if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0)
|
||||
goto cleanup;
|
||||
|
Loading…
Reference in New Issue
Block a user