From 2d3a42cb7ce578913ee98fb957c1cb4df6050d3e Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 27 Jun 2024 09:42:38 +0200 Subject: [PATCH] domain_capabilities: Introduce netdev capabilities If mgmt apps on top of libvirt want to make a decision on the backend type for (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 Reviewed-by: Peter Krempa --- docs/formatdomaincaps.rst | 25 +++++++++++++++++++++++++ src/conf/domain_capabilities.c | 13 +++++++++++++ src/conf/domain_capabilities.h | 8 ++++++++ src/conf/schemas/domaincaps.rng | 10 ++++++++++ 4 files changed, 56 insertions(+) diff --git a/docs/formatdomaincaps.rst b/docs/formatdomaincaps.rst index a2ad0acc3d..be45de8996 100644 --- a/docs/formatdomaincaps.rst +++ b/docs/formatdomaincaps.rst @@ -629,6 +629,31 @@ Crypto device capabilities are exposed under the ``crypto`` element. For instanc ``backendModel`` Options for the ``backendModel`` attribute of the ```` element. +Interface device +^^^^^^^^^^^^^^^^ + +Interface device corresponds to `network interface +`__ (````) in domain XML. + +:: + + + ... + + + + default + passt + + + ... + + + +``backendType`` + Options for the ``type`` attribute of the ```` element + + Features ~~~~~~~~ diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 3f2d231d1c..199bac006b 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -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, "\n"); diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 986f3cb394..3fe62ce211 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -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; diff --git a/src/conf/schemas/domaincaps.rng b/src/conf/schemas/domaincaps.rng index b8115fe028..f17a4e681d 100644 --- a/src/conf/schemas/domaincaps.rng +++ b/src/conf/schemas/domaincaps.rng @@ -212,6 +212,9 @@ + + + @@ -285,6 +288,13 @@ + + + + + + + -- 2.39.5