[libvirt PATCH 6/9] libvirt: introduce virConnectGetHypervisorCPUModelDefinition public API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 include/libvirt/libvirt-host.h |  7 +++++
 src/driver-hypervisor.h        |  9 ++++++
 src/libvirt-host.c             | 54 ++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms        |  1 +
 4 files changed, 71 insertions(+)

diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h
index 5aaa001adb..ad11c1172d 100644
--- a/include/libvirt/libvirt-host.h
+++ b/include/libvirt/libvirt-host.h
@@ -968,6 +968,13 @@ int virConnectGetHypervisorCPUModelNames(virConnectPtr conn,
                                          char ***aliases,
                                          unsigned int flags);
 
+int virConnectGetHypervisorCPUModelDefinition(virConnectPtr conn,
+                                              const char *arch,
+                                              const char *machine,
+                                              const char *name,
+                                              char **xmlCPU,
+                                              unsigned int flags);
+
 /**
  * virConnectBaselineCPUFlags:
  *
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index c81e5d4c75..b016ec7775 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -739,6 +739,14 @@ typedef int
                                            char ***aliases,
                                            unsigned int flags);
 
+typedef int
+(*virDrvConnectGetHypervisorCPUModelDefinition)(virConnectPtr conn,
+                                                const char *arch,
+                                                const char *machine,
+                                                const char *name,
+                                                char **xmlCPU,
+                                                unsigned int flags);
+
 typedef int
 (*virDrvDomainGetJobInfo)(virDomainPtr domain,
                           virDomainJobInfoPtr info);
@@ -1720,4 +1728,5 @@ struct _virHypervisorDriver {
     virDrvDomainGetMessages domainGetMessages;
     virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc;
     virDrvConnectGetHypervisorCPUModelNames connectGetHypervisorCPUModelNames;
+    virDrvConnectGetHypervisorCPUModelDefinition connectGetHypervisorCPUModelDefinition;
 };
diff --git a/src/libvirt-host.c b/src/libvirt-host.c
index 6e734628c1..8875f67a7b 100644
--- a/src/libvirt-host.c
+++ b/src/libvirt-host.c
@@ -1288,6 +1288,60 @@ virConnectGetHypervisorCPUModelNames(virConnectPtr conn,
     return -1;
 }
 
+/**
+ * virConnectGetHypervisorCPUModelDefinition:
+ *
+ * @conn: virConnect connection
+ * @arch: Architecture
+ * @machine: Machine type
+ * @name: CPU model name
+ * @xmlCPU: XML description of the CPUs
+ * @flags: extra flags; not used yet, so callers should always pass 0.
+ *
+ * Get the description of a specific hypervisor cpu model for a given machine
+ * type and architecture.
+ *
+ * Returns 0 on success, -1 otherwise.
+ *
+ * Since: 8.5.0
+ */
+int
+virConnectGetHypervisorCPUModelDefinition(virConnectPtr conn,
+                                          const char *arch,
+                                          const char *machine,
+                                          const char *name,
+                                          char **xmlCPU,
+                                          unsigned int flags)
+{
+    VIR_DEBUG("conn=%p, arch=%s, machine=%s, model=%s, flags=0x%x", conn,
+              NULLSTR(arch), NULLSTR(machine), NULLSTR(name), flags);
+    virResetLastError();
+
+    virCheckConnectReturn(conn, -1);
+    virCheckNonNullArgGoto(arch, error);
+    virCheckNonNullArgGoto(machine, error);
+    virCheckNonNullArgGoto(name, error);
+
+    if (conn->driver->connectGetHypervisorCPUModelDefinition) {
+        int ret;
+
+        ret = conn->driver->connectGetHypervisorCPUModelDefinition(conn, arch,
+                                                                   machine,
+                                                                   name,
+                                                                   xmlCPU,
+                                                                   flags);
+        if (ret < 0)
+            goto error;
+
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(conn);
+    return -1;
+}
 
 /**
  * virConnectBaselineCPU:
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index c6a8e898ae..15ef29d07d 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -924,6 +924,7 @@ LIBVIRT_8.4.0 {
 
 LIBVIRT_8.5.0 {
     global:
+        virConnectGetHypervisorCPUModelDefinition;
         virConnectGetHypervisorCPUModelNames;
         virDomainAbortJobFlags;
 } LIBVIRT_8.4.0;
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux