Internal driver API for sVirt support (James Morris & Dan Walsh)

This commit is contained in:
Daniel P. Berrange 2009-03-03 09:14:28 +00:00
parent 0b7860ecdd
commit 8d13558ae6
9 changed files with 98 additions and 0 deletions

View File

@ -1,3 +1,16 @@
Tue Mar 3 09:12:13 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
Internal driver API for sVirt support (James Morris & Dan Walsh)
* src/driver.h: Internal typedefs for virNodeGetSecurityModel()
and virDomainGetSecurityLabel() driver entry points
* src/libvirt.c: Implement entry point for new public APIs
virNodeGetSecurityModel() and virDomainGetSecurityLabel()
* src/lxc_driver.c, src/openvz_driver.c, src/qemu_driver.c,
src/test.c, src/uml_driver.c: Update for new driver entry
points
* python/generator.py: temporarily blacklist non-generated
virNodeGetSecurityModel() and virDomainGetSecurityLabel()
Tue Mar 3 09:10:13 GMT 2009 Daniel P. Berrange <berrange@redhat.com> Tue Mar 3 09:10:13 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
Public API for sVirt support (James Morris & Dan Walsh) Public API for sVirt support (James Morris & Dan Walsh)

View File

@ -342,6 +342,8 @@ skip_function = (
'virCopyLastError', # Python API is called virGetLastError instead 'virCopyLastError', # Python API is called virGetLastError instead
'virConnectOpenAuth', # Python C code is manually written 'virConnectOpenAuth', # Python C code is manually written
'virDefaultErrorFunc', # Python virErrorFuncHandler impl calls this from C 'virDefaultErrorFunc', # Python virErrorFuncHandler impl calls this from C
'virDomainGetSecurityLabel', # Needs investigation...
'virNodeGetSecurityModel', # Needs investigation...
'virConnectDomainEventRegister', # overridden in virConnect.py 'virConnectDomainEventRegister', # overridden in virConnect.py
'virConnectDomainEventDeregister', # overridden in virConnect.py 'virConnectDomainEventDeregister', # overridden in virConnect.py
'virSaveLastError', # We have our own python error wrapper 'virSaveLastError', # We have our own python error wrapper

View File

@ -180,6 +180,13 @@ typedef int
int maplen); int maplen);
typedef int typedef int
(*virDrvDomainGetMaxVcpus) (virDomainPtr domain); (*virDrvDomainGetMaxVcpus) (virDomainPtr domain);
typedef int
(*virDrvDomainGetSecurityLabel) (virDomainPtr domain,
virSecurityLabelPtr seclabel);
typedef int
(*virDrvNodeGetSecurityModel) (virConnectPtr conn,
virSecurityModelPtr secmodel);
typedef int typedef int
(*virDrvDomainAttachDevice) (virDomainPtr domain, (*virDrvDomainAttachDevice) (virDomainPtr domain,
const char *xml); const char *xml);
@ -371,6 +378,8 @@ struct _virDriver {
virDrvDomainPinVcpu domainPinVcpu; virDrvDomainPinVcpu domainPinVcpu;
virDrvDomainGetVcpus domainGetVcpus; virDrvDomainGetVcpus domainGetVcpus;
virDrvDomainGetMaxVcpus domainGetMaxVcpus; virDrvDomainGetMaxVcpus domainGetMaxVcpus;
virDrvDomainGetSecurityLabel domainGetSecurityLabel;
virDrvNodeGetSecurityModel nodeGetSecurityModel;
virDrvDomainDumpXML domainDumpXML; virDrvDomainDumpXML domainDumpXML;
virDrvListDefinedDomains listDefinedDomains; virDrvListDefinedDomains listDefinedDomains;
virDrvNumOfDefinedDomains numOfDefinedDomains; virDrvNumOfDefinedDomains numOfDefinedDomains;

View File

@ -4174,6 +4174,70 @@ error:
return -1; return -1;
} }
/**
* virDomainGetSecurityLabel:
* @domain: a domain object
* @seclabel: pointer to a virSecurityLabel structure
*
* Extract security label of an active domain.
*
* Returns 0 in case of success, -1 in case of failure, and -2
* if the operation is not supported (caller decides if that's
* an error).
*/
int
virDomainGetSecurityLabel(virDomainPtr domain, virSecurityLabelPtr seclabel)
{
virConnectPtr conn;
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
return -1;
}
if (seclabel == NULL) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
return -1;
}
conn = domain->conn;
if (conn->driver->domainGetSecurityLabel)
return conn->driver->domainGetSecurityLabel(domain, seclabel);
virLibConnWarning(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
return -2;
}
/**
* virNodeGetSecurityModel:
* @conn: a connection object
* @secmodel: pointer to a virSecurityModel structure
*
* Extract the security model of a hypervisor.
*
* Returns 0 in case of success, -1 in case of failure, and -2 if the
* operation is not supported (caller decides if that's an error).
*/
int
virNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel)
{
if (!VIR_IS_CONNECT(conn)) {
virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
return -1;
}
if (secmodel == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return -1;
}
if (conn->driver->nodeGetSecurityModel)
return conn->driver->nodeGetSecurityModel(conn, secmodel);
virLibConnWarning(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
return -2;
}
/** /**
* virDomainAttachDevice: * virDomainAttachDevice:

View File

@ -1429,6 +1429,8 @@ static virDriver lxcDriver = {
NULL, /* domainPinVcpu */ NULL, /* domainPinVcpu */
NULL, /* domainGetVcpus */ NULL, /* domainGetVcpus */
NULL, /* domainGetMaxVcpus */ NULL, /* domainGetMaxVcpus */
NULL, /* domainGetSecurityLabel */
NULL, /* nodeGetSecurityModel */
lxcDomainDumpXML, /* domainDumpXML */ lxcDomainDumpXML, /* domainDumpXML */
lxcListDefinedDomains, /* listDefinedDomains */ lxcListDefinedDomains, /* listDefinedDomains */
lxcNumDefinedDomains, /* numOfDefinedDomains */ lxcNumDefinedDomains, /* numOfDefinedDomains */

View File

@ -1299,6 +1299,8 @@ static virDriver openvzDriver = {
NULL, /* domainPinVcpu */ NULL, /* domainPinVcpu */
NULL, /* domainGetVcpus */ NULL, /* domainGetVcpus */
openvzDomainGetMaxVcpus, /* domainGetMaxVcpus */ openvzDomainGetMaxVcpus, /* domainGetMaxVcpus */
NULL, /* domainGetSecurityLabel */
NULL, /* nodeGetSecurityModel */
openvzDomainDumpXML, /* domainDumpXML */ openvzDomainDumpXML, /* domainDumpXML */
openvzListDefinedDomains, /* listDomains */ openvzListDefinedDomains, /* listDomains */
openvzNumDefinedDomains, /* numOfDomains */ openvzNumDefinedDomains, /* numOfDomains */

View File

@ -4743,6 +4743,8 @@ static virDriver qemuDriver = {
NULL, /* domainGetVcpus */ NULL, /* domainGetVcpus */
#endif #endif
qemudDomainGetMaxVcpus, /* domainGetMaxVcpus */ qemudDomainGetMaxVcpus, /* domainGetMaxVcpus */
NULL, /* domainGetSecurityLabel */
NULL, /* nodeGetSecurityModel */
qemudDomainDumpXML, /* domainDumpXML */ qemudDomainDumpXML, /* domainDumpXML */
qemudListDefinedDomains, /* listDomains */ qemudListDefinedDomains, /* listDomains */
qemudNumDefinedDomains, /* numOfDomains */ qemudNumDefinedDomains, /* numOfDomains */

View File

@ -3501,6 +3501,8 @@ static virDriver testDriver = {
NULL, /* domainPinVcpu */ NULL, /* domainPinVcpu */
NULL, /* domainGetVcpus */ NULL, /* domainGetVcpus */
NULL, /* domainGetMaxVcpus */ NULL, /* domainGetMaxVcpus */
NULL, /* domainGetSecurityLabel */
NULL, /* nodeGetSecurityModel */
testDomainDumpXML, /* domainDumpXML */ testDomainDumpXML, /* domainDumpXML */
testListDefinedDomains, /* listDefinedDomains */ testListDefinedDomains, /* listDefinedDomains */
testNumOfDefinedDomains, /* numOfDefinedDomains */ testNumOfDefinedDomains, /* numOfDefinedDomains */

View File

@ -1854,6 +1854,8 @@ static virDriver umlDriver = {
NULL, /* domainPinVcpu */ NULL, /* domainPinVcpu */
NULL, /* domainGetVcpus */ NULL, /* domainGetVcpus */
NULL, /* domainGetMaxVcpus */ NULL, /* domainGetMaxVcpus */
NULL, /* domainGetSecurityLabel */
NULL, /* nodeGetSecurityModel */
umlDomainDumpXML, /* domainDumpXML */ umlDomainDumpXML, /* domainDumpXML */
umlListDefinedDomains, /* listDomains */ umlListDefinedDomains, /* listDomains */
umlNumDefinedDomains, /* numOfDomains */ umlNumDefinedDomains, /* numOfDomains */