[libvirt] [PATCH 2/3] qemu: SCSI hostdev hot-plug: Fix automatic creation of SCSI controllers

Peter Krempa pkrempa at redhat.com
Thu Jun 30 10:35:22 UTC 2016


On Mon, Jun 27, 2016 at 16:43:47 +0200, Marc Hartmayer wrote:
> Ensure that the given controller and all controllers with a smaller
> index exist; there must not be any missing index in between.
> 
> Reviewed-by: Boris Fiuczynski <fiuczy at linux.vnet.ibm.com>
> Reviewed-by: Bjoern Walk <bwalk at linux.vnet.ibm.com>
> Signed-off-by: Marc Hartmayer <mhartmay at linux.vnet.ibm.com>
> ---
>  src/qemu/qemu_hotplug.c | 21 ++++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 5e6a8cb..037e601 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -1873,6 +1873,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
>                                 virDomainObjPtr vm,
>                                 virDomainHostdevDefPtr hostdev)
>  {
> +    size_t i;
>      int ret = -1;
>      qemuDomainObjPrivatePtr priv = vm->privateData;
>      virErrorPtr orig_err;
> @@ -1888,9 +1889,23 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
>          return -1;
>      }
>  
> -    cont = qemuDomainFindOrCreateSCSIDiskController(driver, vm, hostdev->info->addr.drive.controller);
> -    if (!cont)
> -        return -1;
> +    /* Let's make sure the disk has a controller defined and loaded before
> +     * trying to add it. The controller used by the disk must exist before a
> +     * qemu command line string is generated.
> +     *
> +     * Ensure that the given controller and all controllers with a smaller index
> +     * exist; there must not be any missing index in between.
> +     */
> +    for (i = 0; i <= hostdev->info->addr.drive.controller; i++) {
> +        cont = qemuDomainFindOrCreateSCSIDiskController(driver, vm, i);
> +        if (!cont)
> +            return -1;
> +    }
> +
> +    /* Tell clang that "cont" is non-NULL.
> +       This is because disk->info.addr.driver.controller is unsigned,
> +       and hence the above loop must iterate at least once. */
> +    sa_assert(cont);

Same as in the previous patch I'll tweak it to remove the hunk above and
the unnecessary variable.

Peter




More information about the libvir-list mailing list