[Kimchi-devel] [PATCH] Detach group of PCI Devices from host before attaching to guest

Daniel Henrique Barboza danielhb at linux.vnet.ibm.com
Thu Jul 16 18:55:17 UTC 2015


Reviewed-by: Daniel Barboza <dhbarboza82 at gmail.com>

On 07/16/2015 01:42 PM, Jose Ricardo Ziviani wrote:
>   - A PCI device can have more than one function. In this case each
>     function must be detached from host before attaching to the vm.
>
> Signed-off-by: Jose Ricardo Ziviani <joserz at linux.vnet.ibm.com>
> ---
>   src/kimchi/model/vmhostdevs.py | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
>
> diff --git a/src/kimchi/model/vmhostdevs.py b/src/kimchi/model/vmhostdevs.py
> index ea75fce..76033f0 100644
> --- a/src/kimchi/model/vmhostdevs.py
> +++ b/src/kimchi/model/vmhostdevs.py
> @@ -196,6 +196,22 @@ class VMHostDevsModel(object):
>           pci_infos = [dev_model.lookup(dev_name) for dev_name in group_names]
>           pci_infos.append(dev_info)
>
> +        # all devices in the group that is going to be attached to the vm
> +        # must be detached from the host first
> +        with RollbackContext() as rollback:
> +            for pci_info in pci_infos:
> +                try:
> +                    dev = self.conn.get().nodeDeviceLookupByName(
> +                        pci_info['name'])
> +                    dev.dettach()
> +                except Exception:
> +                    raise OperationFailed('KCHVMHDEV0005E',
> +                                          {'name': pci_info['name']})
> +                else:
> +                    rollback.prependDefer(dev.reAttach)
> +
> +            rollback.commitAll()
> +
>           device_flags = get_vm_config_flag(dom, mode='all')
>
>           with RollbackContext() as rollback:




More information about the Kimchi-devel mailing list