提交 f53ffba6 编写于 作者: D Daniel P. Berrange

Simplify the Xen driver define domain driver methods

Directly call either XenD or the XM driver for handling
domain define operations.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 69b8c557
...@@ -1320,32 +1320,24 @@ xenUnifiedConnectListDefinedDomains(virConnectPtr conn, char **const names, ...@@ -1320,32 +1320,24 @@ xenUnifiedConnectListDefinedDomains(virConnectPtr conn, char **const names,
int maxnames) int maxnames)
{ {
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
int i;
int ret;
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (priv->opened[i] && drivers[i]->xenListDefinedDomains) {
ret = drivers[i]->xenListDefinedDomains(conn, names, maxnames);
if (ret >= 0) return ret;
}
return -1; if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
return xenXMListDefinedDomains(conn, names, maxnames);
} else {
return xenDaemonListDefinedDomains(conn, names, maxnames);
}
} }
static int static int
xenUnifiedConnectNumOfDefinedDomains(virConnectPtr conn) xenUnifiedConnectNumOfDefinedDomains(virConnectPtr conn)
{ {
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
int i;
int ret;
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (priv->opened[i] && drivers[i]->xenNumOfDefinedDomains) {
ret = drivers[i]->xenNumOfDefinedDomains(conn);
if (ret >= 0) return ret;
}
return -1; if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
return xenXMNumOfDefinedDomains(conn);
} else {
return xenDaemonNumOfDefinedDomains(conn);
}
} }
static int static int
......
...@@ -93,8 +93,6 @@ extern int xenRegister (void); ...@@ -93,8 +93,6 @@ extern int xenRegister (void);
* structure with direct calls in xen_unified.c. * structure with direct calls in xen_unified.c.
*/ */
struct xenUnifiedDriver { struct xenUnifiedDriver {
virDrvConnectListDefinedDomains xenListDefinedDomains;
virDrvConnectNumOfDefinedDomains xenNumOfDefinedDomains;
virDrvDomainCreate xenDomainCreate; virDrvDomainCreate xenDomainCreate;
virDrvDomainDefineXML xenDomainDefineXML; virDrvDomainDefineXML xenDomainDefineXML;
virDrvDomainUndefine xenDomainUndefine; virDrvDomainUndefine xenDomainUndefine;
......
...@@ -2937,19 +2937,12 @@ xenDaemonDomainUndefine(virDomainPtr domain) ...@@ -2937,19 +2937,12 @@ xenDaemonDomainUndefine(virDomainPtr domain)
* *
* Returns the number of domain found or -1 in case of error * Returns the number of domain found or -1 in case of error
*/ */
static int int
xenDaemonNumOfDefinedDomains(virConnectPtr conn) xenDaemonNumOfDefinedDomains(virConnectPtr conn)
{ {
struct sexpr *root = NULL; struct sexpr *root = NULL;
int ret = -1; int ret = -1;
struct sexpr *_for_i, *node; struct sexpr *_for_i, *node;
xenUnifiedPrivatePtr priv = conn->privateData;
/* xm_internal.c (the support for defined domains from /etc/xen
* config files used by old Xen) will handle this.
*/
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return -1;
root = sexpr_get(conn, "/xend/domain?state=halted"); root = sexpr_get(conn, "/xend/domain?state=halted");
if (root == NULL) if (root == NULL)
...@@ -2970,7 +2963,7 @@ error: ...@@ -2970,7 +2963,7 @@ error:
return ret; return ret;
} }
static int int
xenDaemonListDefinedDomains(virConnectPtr conn, xenDaemonListDefinedDomains(virConnectPtr conn,
char **const names, char **const names,
int maxnames) int maxnames)
...@@ -2978,10 +2971,6 @@ xenDaemonListDefinedDomains(virConnectPtr conn, ...@@ -2978,10 +2971,6 @@ xenDaemonListDefinedDomains(virConnectPtr conn,
struct sexpr *root = NULL; struct sexpr *root = NULL;
int i, ret = -1; int i, ret = -1;
struct sexpr *_for_i, *node; struct sexpr *_for_i, *node;
xenUnifiedPrivatePtr priv = conn->privateData;
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return -1;
if (maxnames == 0) if (maxnames == 0)
return 0; return 0;
...@@ -3387,8 +3376,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain, ...@@ -3387,8 +3376,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain,
} }
struct xenUnifiedDriver xenDaemonDriver = { struct xenUnifiedDriver xenDaemonDriver = {
.xenListDefinedDomains = xenDaemonListDefinedDomains,
.xenNumOfDefinedDomains = xenDaemonNumOfDefinedDomains,
.xenDomainCreate = xenDaemonDomainCreate, .xenDomainCreate = xenDaemonDomainCreate,
.xenDomainDefineXML = xenDaemonDomainDefineXML, .xenDomainDefineXML = xenDaemonDomainDefineXML,
.xenDomainUndefine = xenDaemonDomainUndefine, .xenDomainUndefine = xenDaemonDomainUndefine,
......
...@@ -109,6 +109,11 @@ char **xenDaemonListDomainsOld(virConnectPtr xend); ...@@ -109,6 +109,11 @@ char **xenDaemonListDomainsOld(virConnectPtr xend);
char *xenDaemonDomainGetOSType(virDomainPtr domain); char *xenDaemonDomainGetOSType(virDomainPtr domain);
int xenDaemonNumOfDefinedDomains(virConnectPtr conn);
int xenDaemonListDefinedDomains(virConnectPtr conn,
char **const names,
int maxnames);
virDomainPtr xenDaemonDomainDefineXML(virConnectPtr xend, const char *sexpr); virDomainPtr xenDaemonDomainDefineXML(virConnectPtr xend, const char *sexpr);
int xenDaemonDomainCreate(virDomainPtr domain); int xenDaemonDomainCreate(virDomainPtr domain);
int xenDaemonDomainUndefine(virDomainPtr domain); int xenDaemonDomainUndefine(virDomainPtr domain);
......
...@@ -81,8 +81,6 @@ static int xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml, ...@@ -81,8 +81,6 @@ static int xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
#define XM_XML_ERROR "Invalid xml" #define XM_XML_ERROR "Invalid xml"
struct xenUnifiedDriver xenXMDriver = { struct xenUnifiedDriver xenXMDriver = {
.xenListDefinedDomains = xenXMListDefinedDomains,
.xenNumOfDefinedDomains = xenXMNumOfDefinedDomains,
.xenDomainCreate = xenXMDomainCreate, .xenDomainCreate = xenXMDomainCreate,
.xenDomainDefineXML = xenXMDomainDefineXML, .xenDomainDefineXML = xenXMDomainDefineXML,
.xenDomainUndefine = xenXMDomainUndefine, .xenDomainUndefine = xenXMDomainUndefine,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册