]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Update structure & XML definitions to support <hostdev caps=net>
authorBogdan Purcareata <bogdan.purcareata@freescale.com>
Fri, 5 Apr 2013 12:26:39 +0000 (08:26 -0400)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 8 Apr 2013 16:40:08 +0000 (17:40 +0100)
This updates the definitions and supporting structures in the XML
schema and domain configuration files.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h

index 7edeca8a614bd8a9a79324de8bc52511c655fd83..6a6bdbc4f219185d158b651c0a8db2bc94f6fa28 100644 (file)
     &lt;char&gt;/dev/input/event3&lt;/char&gt;
   &lt;/source&gt;
 &lt;/hostdev&gt;
+...
+    </pre>
+
+...
+&lt;hostdev mode='capabilities' type='net'&gt;
+  &lt;source&gt;
+    &lt;interface&gt;eth0&lt;/interface&gt;
+  &lt;/source&gt;
+&lt;/hostdev&gt;
 ...
     </pre>
 
       <dd>The <code>hostdev</code> element is the main container for describing
         host devices. For block/character device passthrough <code>mode</code> is
         always "capabilities" and <code>type</code> is "block" for a block
-        device and "char" for a character device.
+        device, "char" for a character device and "net" for a host network
+        interface.
       </dd>
       <dt><code>source</code></dt>
       <dd>The source element describes the device as seen from the host.
         For block devices, the path to the block device in the host
         OS is provided in the nested "block" element, while for character
-        devices the "char" element is used
+        devices the "char" element is used. For network interfaces, the
+        name of the interface is provided in the "interface" element.
       </dd>
     </dl>
 
index 32abd4f90fe83e37b99983e3290ee81ec5c453df..7b3d6376afceedd1d45273244c47b4744f93fb91 100644 (file)
       <group>
         <ref name="hostdevcapsmisc"/>
       </group>
+      <group>
+        <ref name="hostdevcapsnet"/>
+      </group>
     </choice>
   </define>
 
     </element>
   </define>
 
+  <define name="hostdevcapsnet">
+    <attribute name="type">
+      <value>net</value>
+    </attribute>
+    <element name="source">
+      <element name="interface">
+        <ref name="deviceName"/>
+      </element>
+    </element>
+  </define>
+
   <define name="usbproduct">
     <element name="vendor">
       <attribute name="id">
index 79e3b2ef64c68966c2aded5dd5a9a36a570d542e..03e574093587f8a819475ec82382b0bf796c2515 100644 (file)
@@ -582,7 +582,8 @@ VIR_ENUM_IMPL(virDomainHostdevSubsys, VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST,
 
 VIR_ENUM_IMPL(virDomainHostdevCaps, VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST,
               "storage",
-              "misc")
+              "misc",
+              "net")
 
 VIR_ENUM_IMPL(virDomainPciRombarMode,
               VIR_DOMAIN_PCI_ROMBAR_LAST,
@@ -1611,6 +1612,9 @@ void virDomainHostdevDefClear(virDomainHostdevDefPtr def)
         case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
             VIR_FREE(def->source.caps.u.misc.chardev);
             break;
+        case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+            VIR_FREE(def->source.caps.u.net.iface);
+            break;
         }
     }
 }
@@ -3675,6 +3679,14 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATTRIBUTE_UNUSED,
             goto error;
         }
         break;
+    case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+        if (!(def->source.caps.u.net.iface =
+              virXPathString("string(./source/interface[1])", ctxt))) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("Missing <interface> element in hostdev net device"));
+            goto error;
+        }
+        break;
     default:
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("address type='%s' not supported in hostdev interfaces"),
@@ -8881,6 +8893,14 @@ virDomainHostdevMatchCapsMisc(virDomainHostdevDefPtr a,
                           b->source.caps.u.misc.chardev);
 }
 
+static int
+virDomainHostdevMatchCapsNet(virDomainHostdevDefPtr a,
+                              virDomainHostdevDefPtr b)
+{
+    return STREQ_NULLABLE(a->source.caps.u.net.iface,
+                          b->source.caps.u.net.iface);
+}
+
 
 static int
 virDomainHostdevMatchCaps(virDomainHostdevDefPtr a,
@@ -8894,6 +8914,8 @@ virDomainHostdevMatchCaps(virDomainHostdevDefPtr a,
         return virDomainHostdevMatchCapsStorage(a, b);
     case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
         return virDomainHostdevMatchCapsMisc(a, b);
+    case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+        return virDomainHostdevMatchCapsNet(a, b);
     }
     return 0;
 }
@@ -13530,6 +13552,10 @@ virDomainHostdevDefFormatCaps(virBufferPtr buf,
         virBufferEscapeString(buf, "<char>%s</char>\n",
                               def->source.caps.u.misc.chardev);
         break;
+    case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+        virBufferEscapeString(buf, "<interface>%s</interface>\n",
+                              def->source.caps.u.net.iface);
+        break;
     default:
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unexpected hostdev type %d"),
index a24ebc70960b15c35a6d309ab5ccb020996899f5..ec823e2d7263518e5d30c4ff178e719c3ae8c60f 100644 (file)
@@ -407,6 +407,7 @@ struct _virDomainHostdevSubsys {
 enum virDomainHostdevCapsType {
     VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE,
     VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC,
+    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET,
 
     VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST
 };
@@ -422,6 +423,9 @@ struct _virDomainHostdevCaps {
         struct {
             char *chardev;
         } misc;
+        struct {
+            char *iface;
+        } net;
     } u;
 };