Re: [PATCH 2/2] Implement support for <hostdev caps=net>

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

 



On Fri, Apr 05, 2013 at 03:28:08AM -0400, Bogdan Purcareata wrote:
> This allows a container-type domain to have exclusive access to one of
> the host's NICs.
> 
> Wire <hostdev caps=net> with the lxc_controller - when moving the newly
> created veth devices into a new namespace, also look for any hostdev
> devices that should be moved. Note: once the container domain has been
> destroyed, there is no code that moves the interfaces back to the 
> original namespace. This does happen, though, probably due to default
> cleanup on namespace destruction.
> 
> Signed-off-by: Bogdan Purcareata <bogdan.purcareata@xxxxxxxxxxxxx>
> ---
>  src/lxc/lxc_container.c  |  4 +++-
>  src/lxc/lxc_controller.c | 19 +++++++++++++++++++
>  src/lxc/lxc_hostdev.c    |  1 +
>  3 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index 002ba9e..e59bfdf 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -1551,7 +1551,6 @@ cleanup:
>      return ret;
>  }
>  
> -
>  static int lxcContainerSetupHostdevSubsys(virDomainDefPtr vmDef,
>                                            virDomainHostdevDefPtr def,
>                                            const char *dstprefix,
> @@ -1582,6 +1581,9 @@ static int lxcContainerSetupHostdevCaps(virDomainDefPtr vmDef,
>      case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
>          return lxcContainerSetupHostdevCapsMisc(vmDef, def, dstprefix, securityDriver);
>  
> +    case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
> +        return 0; // case is handled in virLXCControllerMoveInterfaces
> +
>      default:
>          virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>                         _("Unsupported host device mode %s"),
> diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
> index cede445..ab488d8 100644
> --- a/src/lxc/lxc_controller.c
> +++ b/src/lxc/lxc_controller.c
> @@ -1050,12 +1050,31 @@ cleanup2:
>  static int virLXCControllerMoveInterfaces(virLXCControllerPtr ctrl)
>  {
>      size_t i;
> +    virDomainDefPtr def = ctrl->def;
>  
>      for (i = 0 ; i < ctrl->nveths ; i++) {
>          if (virNetDevSetNamespace(ctrl->veths[i], ctrl->initpid) < 0)
>              return -1;
>      }
>  
> +    for (i = 0; i < def->nhostdevs; i ++) {
> +	virDomainHostdevDefPtr hdev = def->hostdevs[i];
> +
> +	if (hdev->mode != VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
> +            continue;
> +        }

No need for {} for a body which is only 1 statement.

> +
> +        virDomainHostdevCaps hdcaps = hdev->source.caps;
> +
> +	if (hdcaps.type != VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET) {
> +           continue;
> +        }

No need for {}

> +
> +        if (virNetDevSetNamespace(hdcaps.u.net.interface, ctrl->initpid) < 0) {
> +            return -1;
> +	}

No need for {}

You've got some tab characters in here which is making the
indentation go funny. Run 'make syntax-check' and it'll
tell you where any problems are.

Functionally it all looks fine.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

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