mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 23:37:42 +00:00
xen: make direct call when there is only one subdriver
No need to use a for loop if we know there is exactly one client. Found by: for f in $(sed -n 's/.*Drv[^ ]* \([^;]*\);.*/\1/p' src/xen/xen_driver.h) do git grep "\(\.\|->\)$f\b" src/xen done | cat and looking through the resulting list to see which callback struct members are used exactly once. The next patch will ensure that we don't reintroduce uses of these callbacks. * src/xen/xen_driver.c (xenUnifiedClose): Call close unconditionally, to match xenUnifiedOpen. (xenUnifiedNodeGetInfo, xenUnifiedDomainCreateXML) (xenUnifiedDomainSave, xenUnifiedDomainRestore) (xenUnifiedDomainCoreDump, xenUnifiedDomainUpdateDeviceFlags): Make direct call to lone implementation. * src/xen/xend_internal.h (xenDaemonDomainCoreDump) (xenDaemonUpdateDeviceFlags, xenDaemonCreateXML): Add prototypes. * src/xen/xend_internal.c (xenDaemonDomainCoreDump) (xenDaemonUpdateDeviceFlags, xenDaemonCreateXML): Export.
This commit is contained in:
parent
03e5f8bbbf
commit
a1e641a550
@ -414,7 +414,8 @@ fail:
|
|||||||
clean:
|
clean:
|
||||||
VIR_DEBUG("Failed to activate a mandatory sub-driver");
|
VIR_DEBUG("Failed to activate a mandatory sub-driver");
|
||||||
for (i = 0 ; i < XEN_UNIFIED_NR_DRIVERS ; i++)
|
for (i = 0 ; i < XEN_UNIFIED_NR_DRIVERS ; i++)
|
||||||
if (priv->opened[i]) drivers[i]->xenClose(conn);
|
if (priv->opened[i])
|
||||||
|
drivers[i]->xenClose(conn);
|
||||||
virMutexDestroy(&priv->lock);
|
virMutexDestroy(&priv->lock);
|
||||||
VIR_FREE(priv);
|
VIR_FREE(priv);
|
||||||
conn->privateData = NULL;
|
conn->privateData = NULL;
|
||||||
@ -434,8 +435,8 @@ xenUnifiedClose (virConnectPtr conn)
|
|||||||
virDomainEventCallbackListFree(priv->domainEventCallbacks);
|
virDomainEventCallbackListFree(priv->domainEventCallbacks);
|
||||||
|
|
||||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (priv->opened[i] && drivers[i]->xenClose)
|
if (priv->opened[i])
|
||||||
(void) drivers[i]->xenClose (conn);
|
drivers[i]->xenClose(conn);
|
||||||
|
|
||||||
virMutexDestroy(&priv->lock);
|
virMutexDestroy(&priv->lock);
|
||||||
VIR_FREE(conn->privateData);
|
VIR_FREE(conn->privateData);
|
||||||
@ -537,14 +538,9 @@ static int
|
|||||||
xenUnifiedNodeGetInfo (virConnectPtr conn, virNodeInfoPtr info)
|
xenUnifiedNodeGetInfo (virConnectPtr conn, virNodeInfoPtr info)
|
||||||
{
|
{
|
||||||
GET_PRIVATE(conn);
|
GET_PRIVATE(conn);
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
|
||||||
if (priv->opened[i] &&
|
|
||||||
drivers[i]->xenNodeGetInfo &&
|
|
||||||
drivers[i]->xenNodeGetInfo (conn, info) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
||||||
|
return xenDaemonNodeGetInfo(conn, info);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,15 +617,9 @@ xenUnifiedDomainCreateXML (virConnectPtr conn,
|
|||||||
const char *xmlDesc, unsigned int flags)
|
const char *xmlDesc, unsigned int flags)
|
||||||
{
|
{
|
||||||
GET_PRIVATE(conn);
|
GET_PRIVATE(conn);
|
||||||
int i;
|
|
||||||
virDomainPtr ret;
|
|
||||||
|
|
||||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
|
||||||
if (priv->opened[i] && drivers[i]->xenDomainCreateXML) {
|
|
||||||
ret = drivers[i]->xenDomainCreateXML (conn, xmlDesc, flags);
|
|
||||||
if (ret) return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
||||||
|
return xenDaemonCreateXML(conn, xmlDesc, flags);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1056,7 +1046,6 @@ xenUnifiedDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
GET_PRIVATE(dom->conn);
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
if (dxml) {
|
if (dxml) {
|
||||||
@ -1065,12 +1054,8 @@ xenUnifiedDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
||||||
if (priv->opened[i] &&
|
return xenDaemonDomainSave(dom, to);
|
||||||
drivers[i]->xenDomainSave &&
|
|
||||||
drivers[i]->xenDomainSave (dom, to) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1085,7 +1070,6 @@ xenUnifiedDomainRestoreFlags(virConnectPtr conn, const char *from,
|
|||||||
const char *dxml, unsigned int flags)
|
const char *dxml, unsigned int flags)
|
||||||
{
|
{
|
||||||
GET_PRIVATE(conn);
|
GET_PRIVATE(conn);
|
||||||
int i;
|
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
if (dxml) {
|
if (dxml) {
|
||||||
@ -1094,12 +1078,8 @@ xenUnifiedDomainRestoreFlags(virConnectPtr conn, const char *from,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
||||||
if (priv->opened[i] &&
|
return xenDaemonDomainRestore(conn, from);
|
||||||
drivers[i]->xenDomainRestore &&
|
|
||||||
drivers[i]->xenDomainRestore (conn, from) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1113,14 +1093,9 @@ static int
|
|||||||
xenUnifiedDomainCoreDump (virDomainPtr dom, const char *to, unsigned int flags)
|
xenUnifiedDomainCoreDump (virDomainPtr dom, const char *to, unsigned int flags)
|
||||||
{
|
{
|
||||||
GET_PRIVATE(dom->conn);
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
|
||||||
if (priv->opened[i] &&
|
|
||||||
drivers[i]->xenDomainCoreDump &&
|
|
||||||
drivers[i]->xenDomainCoreDump (dom, to, flags) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
||||||
|
return xenDaemonDomainCoreDump(dom, to, flags);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1651,13 +1626,9 @@ xenUnifiedDomainUpdateDeviceFlags (virDomainPtr dom, const char *xml,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
GET_PRIVATE(dom->conn);
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
|
||||||
if (priv->opened[i] && drivers[i]->xenDomainUpdateDeviceFlags &&
|
|
||||||
drivers[i]->xenDomainUpdateDeviceFlags(dom, xml, flags) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
||||||
|
return xenDaemonUpdateDeviceFlags(dom, xml, flags);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,8 +81,8 @@ extern int xenRegister (void);
|
|||||||
* structure with direct calls in xen_unified.c.
|
* structure with direct calls in xen_unified.c.
|
||||||
*/
|
*/
|
||||||
struct xenUnifiedDriver {
|
struct xenUnifiedDriver {
|
||||||
virDrvOpen xenOpen;
|
virDrvOpen xenOpen; /* Must not be NULL */
|
||||||
virDrvClose xenClose;
|
virDrvClose xenClose; /* Must not be NULL */
|
||||||
virDrvGetVersion xenVersion;
|
virDrvGetVersion xenVersion;
|
||||||
virDrvGetHostname xenGetHostname;
|
virDrvGetHostname xenGetHostname;
|
||||||
virDrvNodeGetInfo xenNodeGetInfo;
|
virDrvNodeGetInfo xenNodeGetInfo;
|
||||||
|
@ -1638,7 +1638,7 @@ xenDaemonDomainSave(virDomainPtr domain, const char *filename)
|
|||||||
*
|
*
|
||||||
* Returns 0 in case of success, -1 in case of error.
|
* Returns 0 in case of success, -1 in case of error.
|
||||||
*/
|
*/
|
||||||
static int
|
int
|
||||||
xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
|
xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
@ -2608,7 +2608,7 @@ xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
|
|||||||
*
|
*
|
||||||
* Returns a new domain object or NULL in case of failure
|
* Returns a new domain object or NULL in case of failure
|
||||||
*/
|
*/
|
||||||
static virDomainPtr
|
virDomainPtr
|
||||||
xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc,
|
xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
@ -2841,7 +2841,7 @@ cleanup:
|
|||||||
*
|
*
|
||||||
* Returns 0 in case of success, -1 in case of failure.
|
* Returns 0 in case of success, -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
static int
|
int
|
||||||
xenDaemonUpdateDeviceFlags(virDomainPtr domain, const char *xml,
|
xenDaemonUpdateDeviceFlags(virDomainPtr domain, const char *xml,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
|
@ -107,6 +107,8 @@ int xenDaemonDomainShutdown(virDomainPtr domain);
|
|||||||
int xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags);
|
int xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags);
|
||||||
int xenDaemonDomainDestroyFlags(virDomainPtr domain, unsigned int flags);
|
int xenDaemonDomainDestroyFlags(virDomainPtr domain, unsigned int flags);
|
||||||
int xenDaemonDomainSave(virDomainPtr domain, const char *filename);
|
int xenDaemonDomainSave(virDomainPtr domain, const char *filename);
|
||||||
|
int xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
|
||||||
|
unsigned int flags);
|
||||||
int xenDaemonDomainRestore(virConnectPtr conn, const char *filename);
|
int xenDaemonDomainRestore(virConnectPtr conn, const char *filename);
|
||||||
int xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory);
|
int xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory);
|
||||||
int xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory);
|
int xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory);
|
||||||
@ -140,6 +142,8 @@ int xenDaemonDomainGetVcpus (virDomainPtr domain,
|
|||||||
int maxinfo,
|
int maxinfo,
|
||||||
unsigned char *cpumaps,
|
unsigned char *cpumaps,
|
||||||
int maplen);
|
int maplen);
|
||||||
|
int xenDaemonUpdateDeviceFlags(virDomainPtr domain, const char *xml,
|
||||||
|
unsigned int flags);
|
||||||
int xenDaemonDomainGetAutostart (virDomainPtr dom,
|
int xenDaemonDomainGetAutostart (virDomainPtr dom,
|
||||||
int *autostart);
|
int *autostart);
|
||||||
int xenDaemonDomainSetAutostart (virDomainPtr domain,
|
int xenDaemonDomainSetAutostart (virDomainPtr domain,
|
||||||
@ -149,6 +153,8 @@ int xenDaemonDomainSetAutostart (virDomainPtr domain,
|
|||||||
extern struct xenUnifiedDriver xenDaemonDriver;
|
extern struct xenUnifiedDriver xenDaemonDriver;
|
||||||
int xenDaemonInit (void);
|
int xenDaemonInit (void);
|
||||||
|
|
||||||
|
virDomainPtr xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc,
|
||||||
|
unsigned int flags);
|
||||||
virDomainPtr xenDaemonLookupByID(virConnectPtr conn, int id);
|
virDomainPtr xenDaemonLookupByID(virConnectPtr conn, int id);
|
||||||
virDomainPtr xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid);
|
virDomainPtr xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid);
|
||||||
virDomainPtr xenDaemonLookupByName(virConnectPtr conn, const char *domname);
|
virDomainPtr xenDaemonLookupByName(virConnectPtr conn, const char *domname);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user