[libvirt] [PATCH 3/5] Introduce forward mode='hostdev' for network XML in order to use the functionality of interface pools.

Laine Stump laine at laine.org
Mon Jun 11 17:22:39 UTC 2012


On 06/08/2012 11:29 AM, Shradha Shah wrote:
> This new forward mode sets up a PCI network device to be assigned to the guest with PCI passthrough.
> The PCI network device is chosen from an interface pool.
> Currently there is no support for USB devices when using this forward mode.
>
> Example XML:
> Network XML:
> <network>
>   <name>direct-network</name>
>   <uuid>81ff0d90-c91e-6742-64da-4a736edb9a8f</uuid>
>   <forward mode="hostdev">
>     <pf dev="eth2"/>
>   </forward>
> </network>

See my comment on PATCH 1/5 for my suggestion on changing the XML format.

>
> The above xml leads to the creation of an implicit interface pool and a free network device
> is chosen from the pool. This patch would also work if an interface pool is given explicitly.
> The interface dev value can be an interface name or a PCI device address.
>
> Example XML:
> Network XML:
> <network>
>   <name>direct-network</name>
>   <uuid>81ff0d90-c91e-6742-64da-4a736edb9a8f</uuid>
>   <forward mode="hostdev">
>     <interface dev="0000:04:00.1"/>
>     <interface dev="0000:04:00.2"/>
>     <interface dev="0000:04:00.3"/>
>   </forward>
> </network>
>
> The MAC address would be provided in the domain xml.
>
> Signed-off-by: Shradha Shah <sshah at solarflare.com>
> ---
>  docs/schemas/network.rng    |    1 +
>  src/conf/network_conf.c     |    3 ++-
>  src/conf/network_conf.h     |    1 +
>  src/network/bridge_driver.c |    6 ++++--
>  4 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
> index 2ae879e..a0046f1 100644
> --- a/docs/schemas/network.rng
> +++ b/docs/schemas/network.rng
> @@ -82,6 +82,7 @@
>                    <value>passthrough</value>
>                    <value>private</value>
>                    <value>vepa</value>
> +                  <value>hostdev</value>
>                  </choice>
>                </attribute>
>              </optional>
> diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
> index 8fcba16..6b346c3 100644
> --- a/src/conf/network_conf.c
> +++ b/src/conf/network_conf.c
> @@ -51,7 +51,7 @@ VIR_ENUM_DECL(virNetworkForward)
>  
>  VIR_ENUM_IMPL(virNetworkForward,
>                VIR_NETWORK_FORWARD_LAST,
> -              "none", "nat", "route", "bridge", "private", "vepa", "passthrough" )
> +              "none", "nat", "route", "bridge", "private", "vepa", "passthrough", "hostdev")
>  
>  #define virNetworkReportError(code, ...)                                \
>      virReportErrorHelper(VIR_FROM_NETWORK, code, __FILE__,              \
> @@ -1251,6 +1251,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
>          case VIR_NETWORK_FORWARD_PRIVATE:
>          case VIR_NETWORK_FORWARD_VEPA:
>          case VIR_NETWORK_FORWARD_PASSTHROUGH:
> +        case VIR_NETWORK_FORWARD_HOSTDEV:
>              if (def->bridge) {
>                  virNetworkReportError(VIR_ERR_XML_ERROR,
>                                        _("bridge name not allowed in %s mode (network '%s'"),
> diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
> index b205cb0..d473c71 100644
> --- a/src/conf/network_conf.h
> +++ b/src/conf/network_conf.h
> @@ -45,6 +45,7 @@ enum virNetworkForwardType {
>      VIR_NETWORK_FORWARD_PRIVATE,
>      VIR_NETWORK_FORWARD_VEPA,
>      VIR_NETWORK_FORWARD_PASSTHROUGH,
> +    VIR_NETWORK_FORWARD_HOSTDEV,
>  
>      VIR_NETWORK_FORWARD_LAST,
>  };
> diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
> index 8540003..cc53551 100644
> --- a/src/network/bridge_driver.c
> +++ b/src/network/bridge_driver.c
> @@ -1974,7 +1974,7 @@ networkStartNetworkExternal(struct network_driver *driver ATTRIBUTE_UNUSED,
>                              virNetworkObjPtr network ATTRIBUTE_UNUSED)
>  {
>      /* put anything here that needs to be done each time a network of
> -     * type BRIDGE, PRIVATE, VEPA, or PASSTHROUGH is started. On
> +     * type BRIDGE, PRIVATE, VEPA, HOSTDEV or PASSTHROUGH is started. On
>       * failure, undo anything you've done, and return -1. On success
>       * return 0.
>       */
> @@ -1985,7 +1985,7 @@ static int networkShutdownNetworkExternal(struct network_driver *driver ATTRIBUT
>                                          virNetworkObjPtr network ATTRIBUTE_UNUSED)
>  {
>      /* put anything here that needs to be done each time a network of
> -     * type BRIDGE, PRIVATE, VEPA, or PASSTHROUGH is shutdown. On
> +     * type BRIDGE, PRIVATE, VEPA, HOSTDEV or PASSTHROUGH is shutdown. On
>       * failure, undo anything you've done, and return -1. On success
>       * return 0.
>       */
> @@ -2016,6 +2016,7 @@ networkStartNetwork(struct network_driver *driver,
>      case VIR_NETWORK_FORWARD_PRIVATE:
>      case VIR_NETWORK_FORWARD_VEPA:
>      case VIR_NETWORK_FORWARD_PASSTHROUGH:
> +    case VIR_NETWORK_FORWARD_HOSTDEV:
>          ret = networkStartNetworkExternal(driver, network);
>          break;
>      }
> @@ -2075,6 +2076,7 @@ static int networkShutdownNetwork(struct network_driver *driver,
>      case VIR_NETWORK_FORWARD_PRIVATE:
>      case VIR_NETWORK_FORWARD_VEPA:
>      case VIR_NETWORK_FORWARD_PASSTHROUGH:
> +    case VIR_NETWORK_FORWARD_HOSTDEV:
>          ret = networkShutdownNetworkExternal(driver, network);
>          break;
>      }




More information about the libvir-list mailing list