domain_capabilities: Introduce netdev capabilities

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>
This commit is contained in:
Michal Privoznik 2024-06-27 09:42:38 +02:00
parent 73fc20e262
commit 2d3a42cb7c
4 changed files with 56 additions and 0 deletions

View 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
~~~~~~~~

View 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");

View 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;

View File

@ -212,6 +212,9 @@
<optional>
<ref name="crypto"/>
</optional>
<optional>
<ref name="interface"/>
</optional>
</element>
</define>
@ -285,6 +288,13 @@
</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"/>