mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 06:35:24 +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:
|
||||
VIR_DEBUG("Failed to activate a mandatory sub-driver");
|
||||
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);
|
||||
VIR_FREE(priv);
|
||||
conn->privateData = NULL;
|
||||
@ -434,8 +435,8 @@ xenUnifiedClose (virConnectPtr conn)
|
||||
virDomainEventCallbackListFree(priv->domainEventCallbacks);
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (priv->opened[i] && drivers[i]->xenClose)
|
||||
(void) drivers[i]->xenClose (conn);
|
||||
if (priv->opened[i])
|
||||
drivers[i]->xenClose(conn);
|
||||
|
||||
virMutexDestroy(&priv->lock);
|
||||
VIR_FREE(conn->privateData);
|
||||
@ -537,14 +538,9 @@ static int
|
||||
xenUnifiedNodeGetInfo (virConnectPtr conn, virNodeInfoPtr info)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -621,15 +617,9 @@ xenUnifiedDomainCreateXML (virConnectPtr conn,
|
||||
const char *xmlDesc, unsigned int flags)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1056,7 +1046,6 @@ xenUnifiedDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
|
||||
unsigned int flags)
|
||||
{
|
||||
GET_PRIVATE(dom->conn);
|
||||
int i;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
if (dxml) {
|
||||
@ -1065,12 +1054,8 @@ xenUnifiedDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (priv->opened[i] &&
|
||||
drivers[i]->xenDomainSave &&
|
||||
drivers[i]->xenDomainSave (dom, to) == 0)
|
||||
return 0;
|
||||
|
||||
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
||||
return xenDaemonDomainSave(dom, to);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1085,7 +1070,6 @@ xenUnifiedDomainRestoreFlags(virConnectPtr conn, const char *from,
|
||||
const char *dxml, unsigned int flags)
|
||||
{
|
||||
GET_PRIVATE(conn);
|
||||
int i;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
if (dxml) {
|
||||
@ -1094,12 +1078,8 @@ xenUnifiedDomainRestoreFlags(virConnectPtr conn, const char *from,
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (priv->opened[i] &&
|
||||
drivers[i]->xenDomainRestore &&
|
||||
drivers[i]->xenDomainRestore (conn, from) == 0)
|
||||
return 0;
|
||||
|
||||
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
||||
return xenDaemonDomainRestore(conn, from);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1113,14 +1093,9 @@ static int
|
||||
xenUnifiedDomainCoreDump (virDomainPtr dom, const char *to, unsigned int flags)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1651,13 +1626,9 @@ xenUnifiedDomainUpdateDeviceFlags (virDomainPtr dom, const char *xml,
|
||||
unsigned int flags)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -81,8 +81,8 @@ extern int xenRegister (void);
|
||||
* structure with direct calls in xen_unified.c.
|
||||
*/
|
||||
struct xenUnifiedDriver {
|
||||
virDrvOpen xenOpen;
|
||||
virDrvClose xenClose;
|
||||
virDrvOpen xenOpen; /* Must not be NULL */
|
||||
virDrvClose xenClose; /* Must not be NULL */
|
||||
virDrvGetVersion xenVersion;
|
||||
virDrvGetHostname xenGetHostname;
|
||||
virDrvNodeGetInfo xenNodeGetInfo;
|
||||
|
@ -1638,7 +1638,7 @@ xenDaemonDomainSave(virDomainPtr domain, const char *filename)
|
||||
*
|
||||
* Returns 0 in case of success, -1 in case of error.
|
||||
*/
|
||||
static int
|
||||
int
|
||||
xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
|
||||
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
|
||||
*/
|
||||
static virDomainPtr
|
||||
virDomainPtr
|
||||
xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc,
|
||||
unsigned int flags)
|
||||
{
|
||||
@ -2841,7 +2841,7 @@ cleanup:
|
||||
*
|
||||
* Returns 0 in case of success, -1 in case of failure.
|
||||
*/
|
||||
static int
|
||||
int
|
||||
xenDaemonUpdateDeviceFlags(virDomainPtr domain, const char *xml,
|
||||
unsigned int flags)
|
||||
{
|
||||
|
@ -107,6 +107,8 @@ int xenDaemonDomainShutdown(virDomainPtr domain);
|
||||
int xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags);
|
||||
int xenDaemonDomainDestroyFlags(virDomainPtr domain, unsigned int flags);
|
||||
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 xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory);
|
||||
int xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory);
|
||||
@ -140,6 +142,8 @@ int xenDaemonDomainGetVcpus (virDomainPtr domain,
|
||||
int maxinfo,
|
||||
unsigned char *cpumaps,
|
||||
int maplen);
|
||||
int xenDaemonUpdateDeviceFlags(virDomainPtr domain, const char *xml,
|
||||
unsigned int flags);
|
||||
int xenDaemonDomainGetAutostart (virDomainPtr dom,
|
||||
int *autostart);
|
||||
int xenDaemonDomainSetAutostart (virDomainPtr domain,
|
||||
@ -149,6 +153,8 @@ int xenDaemonDomainSetAutostart (virDomainPtr domain,
|
||||
extern struct xenUnifiedDriver xenDaemonDriver;
|
||||
int xenDaemonInit (void);
|
||||
|
||||
virDomainPtr xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc,
|
||||
unsigned int flags);
|
||||
virDomainPtr xenDaemonLookupByID(virConnectPtr conn, int id);
|
||||
virDomainPtr xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid);
|
||||
virDomainPtr xenDaemonLookupByName(virConnectPtr conn, const char *domname);
|
||||
|
Loading…
Reference in New Issue
Block a user