[libvirt] [PATCH libvirt] qemu: Fix segmentation fault when attaching a non iSCSI host device

John Ferlan jferlan at redhat.com
Wed Jan 17 13:39:45 UTC 2018



On 01/17/2018 07:26 AM, Marc Hartmayer wrote:
> 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 at linux.vnet.ibm.com>
> Reviewed-by: Bjoern Walk <bwalk at linux.vnet.ibm.com>
> Reviewed-by: Boris Fiuczynski <fiuczy at linux.vnet.ibm.com>
> ---
>  src/qemu/qemu_hotplug.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 

Thanks - thought I got this with '6050affb7', but right it must be
protocol iSCSI <sigh>.

Reviewed-by: John Ferlan <jferlan at redhat.com>

(and safe for freeze - I'll push shortly),

John

> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 6dc16a1054af..83d0e1c71a8e 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -2343,8 +2343,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
>      bool secobjAdded = false;
>      virJSONValuePtr secobjProps = NULL;
>      virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
> -    virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
> -    qemuDomainStorageSourcePrivatePtr srcPriv;
> +    qemuDomainStorageSourcePrivatePtr srcPriv = NULL;
>      qemuDomainSecretInfoPtr secinfo = NULL;
>  
>      if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
> @@ -2386,7 +2385,8 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
>      if (qemuDomainSecretHostdevPrepare(conn, priv, hostdev) < 0)
>          goto cleanup;
>  
> -    srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src);
> +    if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
> +        srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(scsisrc->u.iscsi.src);
>      if (srcPriv)
>          secinfo = srcPriv->secinfo;

Probably could combine into one if statement...


>      if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
> 




More information about the libvir-list mailing list