Re: [PATCH v3 11/13] Move the detach of PCI device to the beginnging of live hotplug

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

 



Shivaprasad G Bhat <shivaprasadbhat@xxxxxxxxx> writes:

> The hostdevices are the only devices which have dependencies
> outside of themselves such that, other functions of the PCI
> card should also have been detached from host driver before
> attempting the hotplug.
>
> This patch moves the detach to the beginning of the hotplug
> so that the following patch can detach all funtions first before
> attempting to hotplug any.
>
> We need not move the detach for net devices using SRIOV as
> all SRIOV devices are single function devices and can be independently
> detached as usual.
>
> Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx>
> ---
>  src/qemu/qemu_hotplug.c |   43 ++++++++++++++++++++++++++++++++++---------
>  1 file changed, 34 insertions(+), 9 deletions(-)
>
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 9a546e2..6821ed5 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -899,6 +899,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
>      actualType = virDomainNetGetActualType(net);
>
>      if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
> +        virDomainHostdevDefPtr hostdev = virDomainNetGetActualHostdev(net);
>          /* This is really a "smart hostdev", so it should be attached
>           * as a hostdev (the hostdev code will reach over into the
>           * netdev-specific code as appropriate), then also added to
> @@ -907,8 +908,14 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
>           * qemuDomainAttachHostDevice uses a connection to resolve
>           * a SCSI hostdev secret, which is not this case, so pass NULL.
>           */
> -        ret = qemuDomainAttachHostDevice(NULL, driver, vm,
> -                                         virDomainNetGetActualHostdev(net));
> +        if (qemuDomainAttachPCIHostDevicePrepare(driver, vm->def,
> +                                                 hostdev, priv->qemuCaps) < 0)
> +            goto cleanup;
> +
> +        ret = qemuDomainAttachHostDevice(NULL, driver, vm, hostdev);
> +        if (!ret)
> +            qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1);
> +
>          goto cleanup;
>      }
>
> @@ -1248,10 +1255,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
>      if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
>          return -1;
>
> -    if (qemuDomainAttachPCIHostDevicePrepare(driver, vm->def,
> -                                             hostdev, priv->qemuCaps) < 0)
> -        return -1;
> -
>      backend = hostdev->source.subsys.u.pci.backend;
>
>      /* Temporarily add the hostdev to the domain definition. This is needed
> @@ -1330,8 +1333,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
>      if (releaseaddr)
>          qemuDomainReleaseDeviceAddress(vm, hostdev->info, NULL);
>
> -    qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1);
> -
>      VIR_FREE(devstr);
>      VIR_FREE(configfd_name);
>      VIR_FORCE_CLOSE(configfd);
> @@ -4386,11 +4387,35 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
>                             virDomainDeviceDefPtr dev,
>                             virDomainPtr dom)
>  {
> +    virQEMUDriverPtr driver = dom->conn->privateData;
> +    virQEMUCapsPtr qemuCaps = NULL;
> +    qemuDomainObjPrivatePtr priv = vm->privateData;
> +
> +    if (priv->qemuCaps)
> +        qemuCaps = virObjectRef(priv->qemuCaps);

Unref / free the qemuCaps

> +    else if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, vm->def->emulator)))
> +        return -1;
> +
>      if (virDomainDefCompatibleDevice(vm->def, dev,
>                                       VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0)
>          return -1;
>
> -    return qemuDomainAttachDeviceLiveInternal(vm, dev, dom);
> +    if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
> +        dev->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
> +        qemuDomainAttachPCIHostDevicePrepare(driver, vm->def, dev->data.hostdev, qemuCaps) < 0)
> +        return -1;
> +
> +    if (qemuDomainAttachDeviceLiveInternal(vm, dev, dom) < 0)
> +        goto undoprepare;
> +
> +    return 0;
> +
> + undoprepare:
> +    if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
> +        dev->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
> +        qemuHostdevReAttachPCIDevices(driver, vm->def->name, &dev->data.hostdev, 1);
> +
> +    return -1;
>  }
>
>  static int
>
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

--
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]