Introduce virConnectGetDomainCapabilities

The API should expose the information contained in virDomainCapsPtr.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2014-06-25 17:05:20 +02:00
parent 614581f32b
commit f409df4de1
7 changed files with 104 additions and 1 deletions

View File

@ -1585,6 +1585,13 @@ int virNodeGetInfo (virConnectPtr conn,
virNodeInfoPtr info); virNodeInfoPtr info);
char * virConnectGetCapabilities (virConnectPtr conn); 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 virNodeGetCPUStats (virConnectPtr conn,
int cpuNum, int cpuNum,
virNodeCPUStatsPtr params, virNodeCPUStatsPtr params,

View File

@ -126,6 +126,14 @@ typedef int
typedef char * typedef char *
(*virDrvConnectGetCapabilities)(virConnectPtr conn); (*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 typedef int
(*virDrvConnectListDomains)(virConnectPtr conn, (*virDrvConnectListDomains)(virConnectPtr conn,
int *ids, int *ids,
@ -1407,6 +1415,7 @@ struct _virDriver {
virDrvDomainGetTime domainGetTime; virDrvDomainGetTime domainGetTime;
virDrvDomainSetTime domainSetTime; virDrvDomainSetTime domainSetTime;
virDrvNodeGetFreePages nodeGetFreePages; virDrvNodeGetFreePages nodeGetFreePages;
virDrvConnectGetDomainCapabilities connectGetDomainCapabilities;
}; };

View File

@ -21137,3 +21137,56 @@ virNetworkDHCPLeaseFree(virNetworkDHCPLeasePtr lease)
VIR_FREE(lease->clientid); VIR_FREE(lease->clientid);
VIR_FREE(lease); 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;
}

View File

@ -665,4 +665,9 @@ LIBVIRT_1.2.6 {
virNetworkGetDHCPLeases; virNetworkGetDHCPLeases;
} LIBVIRT_1.2.5; } LIBVIRT_1.2.5;
LIBVIRT_1.2.7 {
global:
virConnectGetDomainCapabilities;
} LIBVIRT_1.2.6;
# .... define new API here using predicted next version number .... # .... define new API here using predicted next version number ....

View File

@ -8004,6 +8004,7 @@ static virDriver remote_driver = {
.domainGetTime = remoteDomainGetTime, /* 1.2.5 */ .domainGetTime = remoteDomainGetTime, /* 1.2.5 */
.domainSetTime = remoteDomainSetTime, /* 1.2.5 */ .domainSetTime = remoteDomainSetTime, /* 1.2.5 */
.nodeGetFreePages = remoteNodeGetFreePages, /* 1.2.6 */ .nodeGetFreePages = remoteNodeGetFreePages, /* 1.2.6 */
.connectGetDomainCapabilities = remoteConnectGetDomainCapabilities, /* 1.2.7 */
}; };
static virNetworkDriver network_driver = { static virNetworkDriver network_driver = {

View File

@ -478,6 +478,18 @@ struct remote_connect_get_capabilities_ret {
remote_nonnull_string capabilities; 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 { struct remote_node_get_cpu_stats_args {
int cpuNum; int cpuNum;
int nparams; int nparams;
@ -5402,6 +5414,11 @@ enum remote_procedure {
* @generate: none * @generate: none
* @acl: network:read * @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
}; };

View File

@ -148,6 +148,16 @@ struct remote_node_get_info_ret {
struct remote_connect_get_capabilities_ret { struct remote_connect_get_capabilities_ret {
remote_nonnull_string capabilities; 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 { struct remote_node_get_cpu_stats_args {
int cpuNum; int cpuNum;
int nparams; int nparams;
@ -2851,4 +2861,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB_2 = 339, REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB_2 = 339,
REMOTE_PROC_NODE_GET_FREE_PAGES = 340, REMOTE_PROC_NODE_GET_FREE_PAGES = 340,
REMOTE_PROC_NETWORK_GET_DHCP_LEASES = 341, REMOTE_PROC_NETWORK_GET_DHCP_LEASES = 341,
REMOTE_PROC_CONNECT_GET_DOMAIN_CAPABILITIES = 342,
}; };