The API is supposed to fetch virEmulatorCapabilities once implemented
in the hypervisor drivers.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
include/libvirt/libvirt.h.in | 6 +++++
src/driver.h | 7 ++++++
src/libvirt.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 2 ++
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 19 +++++++++++++++-
src/remote_protocol-structs | 10 +++++++++
7 files changed, 96 insertions(+), 1 deletion(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index c83b20d..f71f732 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1585,6 +1585,12 @@ int virNodeGetInfo (virConnectPtr
conn,
virNodeInfoPtr info);
char * virConnectGetCapabilities (virConnectPtr conn);
+char * virConnectGetEmulatorCapabilities(virConnectPtr conn,
+ const char *emulatorbin,
+ const char *machine,
+ const char *virttype,
+ unsigned int flags);
+
int virNodeGetCPUStats (virConnectPtr conn,
int cpuNum,
virNodeCPUStatsPtr params,
diff --git a/src/driver.h b/src/driver.h
index a0b258a..919cc44 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -126,6 +126,12 @@ typedef int
typedef char *
(*virDrvConnectGetCapabilities)(virConnectPtr conn);
+typedef char *
+(*virDrvConnectGetEmulatorCapabilities)(virConnectPtr conn,
+ const char *emulatorbin,
+ const char *machine,
+ const char *virttype,
+ unsigned int flags);
typedef int
(*virDrvConnectListDomains)(virConnectPtr conn,
int *ids,
@@ -1211,6 +1217,7 @@ struct _virDriver {
virDrvConnectGetMaxVcpus connectGetMaxVcpus;
virDrvNodeGetInfo nodeGetInfo;
virDrvConnectGetCapabilities connectGetCapabilities;
+ virDrvConnectGetEmulatorCapabilities connectGetEmulatorCapabilities;
virDrvConnectListDomains connectListDomains;
virDrvConnectNumOfDomains connectNumOfDomains;
virDrvConnectListAllDomains connectListAllDomains;
diff --git a/src/libvirt.c b/src/libvirt.c
index 83b7437..512630f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -7178,6 +7178,58 @@ virConnectGetCapabilities(virConnectPtr conn)
/**
+ * virConnectGetEmulatorCapabilities:
+ * @conn: pointer to the hypervisor connection
+ * @emulatorbin: path to emulator
+ * @machine: machine type
+ * @virttype: virtualization type
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Prior creating a domain (for instance via virDomainCreateXML
+ * or virDomainDefineXML) it may be suitable to know what the
+ * underlying emulator and/or libvirt is capable of. For
+ * instance, if host, libvirt and qemu is capable of VFIO
+ * passthrough and so on.
+ *
+ * Returns NULL in case of error, or an XML string
+ * defining the capabilities.
+ * The client must free the returned string after use.
+ */
+char *
+virConnectGetEmulatorCapabilities(virConnectPtr conn,
+ const char *emulatorbin,
+ const char *machine,
+ const char *virttype,
+ unsigned int flags)
+{
+ VIR_DEBUG("conn=%p emulatorbin=%s machine=%s virttype=%s flags=%x",
+ conn, emulatorbin, machine, virttype, flags);
+
+ virResetLastError();
+
+ virCheckConnectReturn(conn, NULL);
+
+ if (conn->driver->connectGetEmulatorCapabilities) {
+ char *ret;
+ ret = conn->driver->connectGetEmulatorCapabilities(conn, emulatorbin,
+ machine, virttype,
+ flags);
+ if (!ret)
+ goto error;
+ VIR_DEBUG("conn=%p emulatorbin=%s machine=%s virttype=%s flags=%x
ret=%s",
+ conn, emulatorbin, machine, virttype, flags, ret);
+ return ret;
+ }
+
+ virReportUnsupportedError();
+
+ error:
+ virDispatchError(conn);
+ return NULL;
+}
+
+
+/**
* virNodeGetCPUStats:
* @conn: pointer to the hypervisor connection.
* @cpuNum: number of node cpu. (VIR_NODE_CPU_STATS_ALL_CPUS means total cpu
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 40d2c1a..e9987ad 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -661,6 +661,8 @@ LIBVIRT_1.2.5 {
LIBVIRT_1.2.6 {
global:
virNodeGetFreePages;
+ virConnectGetEmulatorCapabilities;
} LIBVIRT_1.2.5;
+
# .... define new API here using predicted next version number ....
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index bef9fd7..5838352 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -7886,6 +7886,7 @@ static virDriver remote_driver = {
.domainGetTime = remoteDomainGetTime, /* 1.2.5 */
.domainSetTime = remoteDomainSetTime, /* 1.2.5 */
.nodeGetFreePages = remoteNodeGetFreePages, /* 1.2.6 */
+ .connectGetEmulatorCapabilities = remoteConnectGetEmulatorCapabilities, /* 1.2.6 */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 50b1888..c76e5c4 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -475,6 +475,17 @@ struct remote_connect_get_capabilities_ret {
remote_nonnull_string capabilities;
};
+struct remote_connect_get_emulator_capabilities_args {
+ remote_string emulatorbin;
+ remote_string machine;
+ remote_string virttype;
+ unsigned int flags;
+};
+
+struct remote_connect_get_emulator_capabilities_ret {
+ remote_nonnull_string capabilities;
+};
+
struct remote_node_get_cpu_stats_args {
int cpuNum;
int nparams;
@@ -5370,5 +5381,11 @@ enum remote_procedure {
* @priority: high
* @acl: connect:read
*/
- REMOTE_PROC_NODE_GET_FREE_PAGES = 340
+ REMOTE_PROC_NODE_GET_FREE_PAGES = 340,
+
+ /**
+ * @generate: both
+ * @acl: connect:read
+ */
+ REMOTE_PROC_CONNECT_GET_EMULATOR_CAPABILITIES = 341
};
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 03268f5..f0e30b3 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -148,6 +148,15 @@ struct remote_node_get_info_ret {
struct remote_connect_get_capabilities_ret {
remote_nonnull_string capabilities;
};
+struct remote_connect_get_emulator_capabilities_args {
+ remote_string emulatorbin;
+ remote_string machine;
+ remote_string virttype;
+ u_int flags;
+};
+struct remote_connect_get_emulator_capabilities_ret {
+ remote_nonnull_string capabilities;
+};
struct remote_node_get_cpu_stats_args {
int cpuNum;
int nparams;
@@ -2826,4 +2835,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_SET_TIME = 338,
REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB_2 = 339,
REMOTE_PROC_NODE_GET_FREE_PAGES = 340,
+ REMOTE_PROC_CONNECT_GET_EMULATOR_CAPABILITIES = 341,
};
--
1.8.5.5