mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
Introduce virConnectGetDomainCapabilities
The API should expose the information contained in virDomainCapsPtr. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
614581f32b
commit
f409df4de1
@ -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,
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 ....
|
||||
|
@ -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 = {
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -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,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user