]> xenbits.xensource.com Git - libvirt.git/commitdiff
domain_capabilities: Introduce netdev capabilities
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 27 Jun 2024 07:42:38 +0000 (09:42 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 1 Jul 2024 10:36:28 +0000 (12:36 +0200)
If mgmt apps on top of libvirt want to make a decision on the
backend type for <interface type='user'/> (e.g. whether past is
supported) we currently offer them no way to learn this fact.
Domain capabilities were invented exactly for this reason. Report
supported net backend types there.

Now, because of backwards compatibility, specifying no backend
type (which translates to VIR_DOMAIN_NET_BACKEND_DEFAULT) means
"use hyperviosr's builtin SLIRP". That behaviour can not be
changed. But it may happen that the hypervisor has no support for
SLIRP. So we have to report it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
docs/formatdomaincaps.rst
src/conf/domain_capabilities.c
src/conf/domain_capabilities.h
src/conf/schemas/domaincaps.rng

index a2ad0acc3d8d3c33d3e0c1df03cd769f979ffcd1..be45de89969b17e1503b8d5e919f8bad8fee3a67 100644 (file)
@@ -629,6 +629,31 @@ Crypto device capabilities are exposed under the ``crypto`` element. For instanc
 ``backendModel``
    Options for the ``backendModel`` attribute of the ``<crypto><backend/>`` element.
 
+Interface device
+^^^^^^^^^^^^^^^^
+
+Interface device corresponds to `network interface
+<formatdomain.html#network-interfaces>`__ (``<interface/>``) in domain XML.
+
+::
+
+  <domainCapabilities>
+    ...
+    <devices>
+      <interface supported='yes'>
+        <enum name='backendType'>
+          <value>default</value>
+          <value>passt</value>
+        </enum>
+      </interface>
+      ...
+    </devices>
+  </domainCapabilities>
+
+``backendType``
+   Options for the ``type`` attribute of the ``<backend/>`` element
+
+
 Features
 ~~~~~~~~
 
index 3f2d231d1c40632225eb46a341c6f8f5754ec3d6..199bac006bd9f43b31e76114e8a1bb4fad56fa69 100644 (file)
@@ -607,6 +607,18 @@ virDomainCapsDeviceCryptoFormat(virBuffer *buf,
 }
 
 
+static void
+virDomainCapsDeviceNetFormat(virBuffer *buf,
+                             const virDomainCapsDeviceNet *interface)
+{
+    FORMAT_PROLOGUE(interface);
+
+    ENUM_PROCESS(interface, backendType, virDomainNetBackendTypeToString);
+
+    FORMAT_EPILOGUE(interface);
+}
+
+
 /**
  * virDomainCapsFeatureGICFormat:
  * @buf: target buffer
@@ -787,6 +799,7 @@ virDomainCapsFormat(const virDomainCaps *caps)
     virDomainCapsDeviceRedirdevFormat(&buf, &caps->redirdev);
     virDomainCapsDeviceChannelFormat(&buf, &caps->channel);
     virDomainCapsDeviceCryptoFormat(&buf, &caps->crypto);
+    virDomainCapsDeviceNetFormat(&buf, &caps->net);
 
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</devices>\n");
index 986f3cb3944ef18a7a22cc0deb7d7aa5e27f8387..3fe62ce211efead4671e7ade6a8e25f9fc3458d7 100644 (file)
@@ -250,6 +250,13 @@ struct _virDomainCapsDeviceCrypto {
     virDomainCapsEnum backendModel;   /* virDomainCryptoBackend */
 };
 
+STATIC_ASSERT_ENUM(VIR_DOMAIN_NET_BACKEND_LAST);
+typedef struct _virDomainCapsDeviceNet virDomainCapsDeviceNet;
+struct _virDomainCapsDeviceNet {
+    virTristateBool supported;
+    virDomainCapsEnum backendType; /* virDomainNetBackendType */
+};
+
 typedef enum {
     VIR_DOMAIN_CAPS_FEATURE_IOTHREADS = 0,
     VIR_DOMAIN_CAPS_FEATURE_VMCOREINFO,
@@ -286,6 +293,7 @@ struct _virDomainCaps {
     virDomainCapsDeviceRedirdev redirdev;
     virDomainCapsDeviceChannel channel;
     virDomainCapsDeviceCrypto crypto;
+    virDomainCapsDeviceNet net;
     /* add new domain devices here */
 
     virDomainCapsFeatureGIC gic;
index b8115fe0289f890a28440fa2cf0fdba15acaf66c..f17a4e681d9b0f01fab1b6951ff6c72f428dd996 100644 (file)
       <optional>
         <ref name="crypto"/>
       </optional>
+      <optional>
+        <ref name="interface"/>
+      </optional>
     </element>
   </define>
 
     </element>
   </define>
 
+  <define name="interface">
+    <element name="interface">
+      <ref name="supported"/>
+      <ref name="enum"/>
+    </element>
+  </define>
+
   <define name="launchSecurity">
     <element name="launchSecurity">
       <ref name="supported"/>