summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libvirt/libvirt.h.in7
-rw-r--r--src/driver.h9
-rw-r--r--src/libvirt.c53
-rw-r--r--src/libvirt_public.syms5
-rw-r--r--src/remote/remote_driver.c1
-rw-r--r--src/remote/remote_protocol.x19
-rw-r--r--src/remote_protocol-structs11
7 files changed, 104 insertions, 1 deletions
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 032d6e6309..aedd49ad57 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1585,6 +1585,13 @@ int virNodeGetInfo (virConnectPtr conn,
virNodeInfoPtr info);
char * virConnectGetCapabilities (virConnectPtr conn);
+char * virConnectGetDomainCapabilities(virConnectPtr conn,
+ const char *emulatorbin,
+ const char *arch,
+ 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 5018068f33..c769675b04 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -126,6 +126,14 @@ typedef int
typedef char *
(*virDrvConnectGetCapabilities)(virConnectPtr conn);
+typedef char *
+(*virDrvConnectGetDomainCapabilities)(virConnectPtr conn,
+ const char *emulatorbin,
+ const char *arch,
+ const char *machine,
+ const char *virttype,
+ unsigned int flags);
+
typedef int
(*virDrvConnectListDomains)(virConnectPtr conn,
int *ids,
@@ -1407,6 +1415,7 @@ struct _virDriver {
virDrvDomainGetTime domainGetTime;
virDrvDomainSetTime domainSetTime;
virDrvNodeGetFreePages nodeGetFreePages;
+ virDrvConnectGetDomainCapabilities connectGetDomainCapabilities;
};
diff --git a/src/libvirt.c b/src/libvirt.c
index 88c1f49fad..b80b484cf1 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -21137,3 +21137,56 @@ virNetworkDHCPLeaseFree(virNetworkDHCPLeasePtr lease)
VIR_FREE(lease->clientid);
VIR_FREE(lease);
}
+
+/**
+ * virConnectGetDomainCapabilities:
+ * @conn: pointer to the hypervisor connection
+ * @emulatorbin: path to emulator
+ * @arch: domain architecture
+ * @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.
+ */
+char *
+virConnectGetDomainCapabilities(virConnectPtr conn,
+ const char *emulatorbin,
+ const char *arch,
+ const char *machine,
+ const char *virttype,
+ unsigned int flags)
+{
+ VIR_DEBUG("conn=%p, emulatorbin=%s, arch=%s, "
+ "machine=%s, virttype=%s, flags=%x",
+ conn, NULLSTR(emulatorbin), NULLSTR(arch),
+ NULLSTR(machine), NULLSTR(virttype), flags);
+
+ virResetLastError();
+
+ virCheckConnectReturn(conn, NULL);
+
+ if (conn->driver->connectGetDomainCapabilities) {
+ char *ret;
+ ret = conn->driver->connectGetDomainCapabilities(conn, emulatorbin,
+ arch, machine,
+ virttype, flags);
+ if (!ret)
+ goto error;
+ VIR_DEBUG("conn=%p, ret=%s", conn, ret);
+ return ret;
+ }
+
+ virReportUnsupportedError();
+
+ error:
+ virDispatchError(conn);
+ return NULL;
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 65a5b43acc..9f4016a85f 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -665,4 +665,9 @@ LIBVIRT_1.2.6 {
virNetworkGetDHCPLeases;
} LIBVIRT_1.2.5;
+LIBVIRT_1.2.7 {
+ global:
+ virConnectGetDomainCapabilities;
+} LIBVIRT_1.2.6;
+
# .... define new API here using predicted next version number ....
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 3c10d5ce63..88fc9777d2 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8004,6 +8004,7 @@ static virDriver remote_driver = {
.domainGetTime = remoteDomainGetTime, /* 1.2.5 */
.domainSetTime = remoteDomainSetTime, /* 1.2.5 */
.nodeGetFreePages = remoteNodeGetFreePages, /* 1.2.6 */
+ .connectGetDomainCapabilities = remoteConnectGetDomainCapabilities, /* 1.2.7 */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index bff2c47209..5c316fb576 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -478,6 +478,18 @@ struct remote_connect_get_capabilities_ret {
remote_nonnull_string capabilities;
};
+struct remote_connect_get_domain_capabilities_args {
+ remote_string emulatorbin;
+ remote_string arch;
+ remote_string machine;
+ remote_string virttype;
+ unsigned int flags;
+};
+
+struct remote_connect_get_domain_capabilities_ret {
+ remote_nonnull_string capabilities;
+};
+
struct remote_node_get_cpu_stats_args {
int cpuNum;
int nparams;
@@ -5402,6 +5414,11 @@ enum remote_procedure {
* @generate: none
* @acl: network:read
*/
- REMOTE_PROC_NETWORK_GET_DHCP_LEASES = 341
+ REMOTE_PROC_NETWORK_GET_DHCP_LEASES = 341,
+ /**
+ * @generate: both
+ * @acl: connect:write
+ */
+ REMOTE_PROC_CONNECT_GET_DOMAIN_CAPABILITIES = 342
};
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index a14e1fd670..9bf09b8417 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -148,6 +148,16 @@ struct remote_node_get_info_ret {
struct remote_connect_get_capabilities_ret {
remote_nonnull_string capabilities;
};
+struct remote_connect_get_domain_capabilities_args {
+ remote_string emulatorbin;
+ remote_string arch;
+ remote_string machine;
+ remote_string virttype;
+ u_int flags;
+};
+struct remote_connect_get_domain_capabilities_ret {
+ remote_nonnull_string capabilities;
+};
struct remote_node_get_cpu_stats_args {
int cpuNum;
int nparams;
@@ -2851,4 +2861,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB_2 = 339,
REMOTE_PROC_NODE_GET_FREE_PAGES = 340,
REMOTE_PROC_NETWORK_GET_DHCP_LEASES = 341,
+ REMOTE_PROC_CONNECT_GET_DOMAIN_CAPABILITIES = 342,
};