Re: [PATCH V5] libxl: support creating domain with VF assignment from a pool

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

 



On 04/07/2016 04:09 AM, Chunyan Liu wrote:
> Add codes to support creating domain with network defition of assigning
> SRIOV VF from a pool.
>
> Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx>
> Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
> ---
> Rebase and send a new version.

ACK. Thanks for the patience. I've pushed this now.

Regards,
Jim

>
>  src/libxl/libxl_domain.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/Makefile.am        |  3 +++
>  2 files changed, 51 insertions(+)
>
> diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
> index 04962a0..bd5deaa 100644
> --- a/src/libxl/libxl_domain.c
> +++ b/src/libxl/libxl_domain.c
> @@ -36,6 +36,7 @@
>  #include "virtime.h"
>  #include "locking/domain_lock.h"
>  #include "xen_common.h"
> +#include "network/bridge_driver.h"
>  
>  #define VIR_FROM_THIS VIR_FROM_LIBXL
>  
> @@ -764,6 +765,10 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
>              if (net->ifname &&
>                  STRPREFIX(net->ifname, LIBXL_GENERATED_PREFIX_XEN))
>                  VIR_FREE(net->ifname);
> +
> +            /* cleanup actual device */
> +            virDomainNetRemoveHostdev(vm->def, net);
> +            networkReleaseActualDevice(vm->def, net);
>          }
>      }
>  
> @@ -900,6 +905,46 @@ libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config)
>      return -1;
>  }
>  
> +static int
> +libxlNetworkPrepareDevices(virDomainDefPtr def)
> +{
> +    size_t i;
> +
> +    for (i = 0; i < def->nnets; i++) {
> +        virDomainNetDefPtr net = def->nets[i];
> +        int actualType;
> +
> +        /* If appropriate, grab a physical device from the configured
> +         * network's pool of devices, or resolve bridge device name
> +         * to the one defined in the network definition.
> +         */
> +        if (networkAllocateActualDevice(def, net) < 0)
> +            return -1;
> +
> +        actualType = virDomainNetGetActualType(net);
> +        if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
> +            net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
> +            /* Each type='hostdev' network device must also have a
> +             * corresponding entry in the hostdevs array. For netdevs
> +             * that are hardcoded as type='hostdev', this is already
> +             * done by the parser, but for those allocated from a
> +             * network / determined at runtime, we need to do it
> +             * separately.
> +             */
> +            virDomainHostdevDefPtr hostdev = virDomainNetGetActualHostdev(net);
> +            virDomainHostdevSubsysPCIPtr pcisrc = &hostdev->source.subsys.u.pci;
> +
> +            if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
> +                hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
> +                pcisrc->backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN;
> +
> +            if (virDomainHostdevInsert(def, hostdev) < 0)
> +                return -1;
> +        }
> +    }
> +    return 0;
> +}
> +
>  static void
>  libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev, void *for_callback)
>  {
> @@ -1050,6 +1095,9 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
>          goto cleanup;
>      VIR_FREE(priv->lockState);
>  
> +    if (libxlNetworkPrepareDevices(vm->def) < 0)
> +        goto cleanup_dom;
> +
>      if (libxlBuildDomainConfig(driver->reservedGraphicsPorts, vm->def,
>                                 cfg->ctx, &d_config) < 0)
>          goto cleanup_dom;
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index b3f1144..db4f88b 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -534,6 +534,9 @@ endif ! WITH_XEN
>  
>  if WITH_LIBXL
>  libxl_LDADDS = ../src/libvirt_driver_libxl_impl.la
> +if WITH_NETWORK
> +libxl_LDADDS += ../src/libvirt_driver_network_impl.la
> +endif WITH_NETWORK
>  libxl_LDADDS += $(LDADDS)
>  
>  xlconfigtest_SOURCES = \

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