diff mbox series

[5/7] conf: domcaps: Add virDomainCapsDeviceDefValidate

Message ID f6fcd26435ede7c8136f8b8c9dbd4dc94ded3926.1554419814.git.crobinso@redhat.com
State Accepted
Commit d3c7536ce34dcf1df8117f592758a5ecf0227502
Headers show
Series qemu: use domCaps for validation | expand

Commit Message

Cole Robinson April 4, 2019, 11:37 p.m. UTC
This is an entrypoint to validate a virDomainDeviceDef against
values filled into virDomainCaps.

Currently it's just a stub

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 src/conf/domain_capabilities.c | 40 ++++++++++++++++++++++++++++++++++
 src/conf/domain_capabilities.h |  4 ++++
 src/libvirt_private.syms       |  1 +
 3 files changed, 45 insertions(+)

-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 03757ba8cd..aef5703df6 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -20,6 +20,7 @@ 
 
 #include <config.h>
 
+#include "device_conf.h"
 #include "domain_capabilities.h"
 #include "domain_conf.h"
 #include "viralloc.h"
@@ -656,3 +657,42 @@  virDomainCapsFormat(virDomainCapsPtr const caps)
     virBufferCheckError(&buf);
     return virBufferContentAndReset(&buf);
 }
+
+
+int
+virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps ATTRIBUTE_UNUSED,
+                               const virDomainDeviceDef *dev,
+                               const virDomainDef *def ATTRIBUTE_UNUSED)
+{
+    switch ((virDomainDeviceType) dev->type) {
+    case VIR_DOMAIN_DEVICE_DISK:
+    case VIR_DOMAIN_DEVICE_REDIRDEV:
+    case VIR_DOMAIN_DEVICE_NET:
+    case VIR_DOMAIN_DEVICE_CONTROLLER:
+    case VIR_DOMAIN_DEVICE_CHR:
+    case VIR_DOMAIN_DEVICE_SMARTCARD:
+    case VIR_DOMAIN_DEVICE_RNG:
+    case VIR_DOMAIN_DEVICE_HOSTDEV:
+    case VIR_DOMAIN_DEVICE_VIDEO:
+    case VIR_DOMAIN_DEVICE_MEMORY:
+    case VIR_DOMAIN_DEVICE_VSOCK:
+    case VIR_DOMAIN_DEVICE_INPUT:
+    case VIR_DOMAIN_DEVICE_SHMEM:
+    case VIR_DOMAIN_DEVICE_LEASE:
+    case VIR_DOMAIN_DEVICE_FS:
+    case VIR_DOMAIN_DEVICE_SOUND:
+    case VIR_DOMAIN_DEVICE_WATCHDOG:
+    case VIR_DOMAIN_DEVICE_GRAPHICS:
+    case VIR_DOMAIN_DEVICE_HUB:
+    case VIR_DOMAIN_DEVICE_MEMBALLOON:
+    case VIR_DOMAIN_DEVICE_NVRAM:
+    case VIR_DOMAIN_DEVICE_TPM:
+    case VIR_DOMAIN_DEVICE_PANIC:
+    case VIR_DOMAIN_DEVICE_IOMMU:
+    case VIR_DOMAIN_DEVICE_NONE:
+    case VIR_DOMAIN_DEVICE_LAST:
+        break;
+    }
+
+    return 0;
+}
diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
index 052191d284..ffce2c2964 100644
--- a/src/conf/domain_capabilities.h
+++ b/src/conf/domain_capabilities.h
@@ -223,6 +223,10 @@  void virDomainCapsEnumClear(virDomainCapsEnumPtr capsEnum);
 
 char * virDomainCapsFormat(virDomainCapsPtr const caps);
 
+int virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps,
+                                   const virDomainDeviceDef *dev,
+                                   const virDomainDef *def);
+
 void
 virSEVCapabilitiesFree(virSEVCapability *capabilities);
 
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 212adf53c1..231b487ab0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -185,6 +185,7 @@  virDomainCapsCPUModelsGet;
 virDomainCapsCPUModelsNew;
 virDomainCapsCPUUsableTypeFromString;
 virDomainCapsCPUUsableTypeToString;
+virDomainCapsDeviceDefValidate;
 virDomainCapsEnumClear;
 virDomainCapsEnumSet;
 virDomainCapsFormat;