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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>
> Reviewed-by: Bjoern Walk <bwalk@xxxxxxxxxxxxxxxxxx>
> Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxxxxxxx>
> ---
>  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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]