提交 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,
int maxnames)
{
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
xenUnifiedConnectNumOfDefinedDomains(virConnectPtr conn)
{
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
......
......@@ -93,8 +93,6 @@ extern int xenRegister (void);
* structure with direct calls in xen_unified.c.
*/
struct xenUnifiedDriver {
virDrvConnectListDefinedDomains xenListDefinedDomains;
virDrvConnectNumOfDefinedDomains xenNumOfDefinedDomains;
virDrvDomainCreate xenDomainCreate;
virDrvDomainDefineXML xenDomainDefineXML;
virDrvDomainUndefine xenDomainUndefine;
......
......@@ -2937,19 +2937,12 @@ xenDaemonDomainUndefine(virDomainPtr domain)
*
* Returns the number of domain found or -1 in case of error
*/
static int
int
xenDaemonNumOfDefinedDomains(virConnectPtr conn)
{
struct sexpr *root = NULL;
int ret = -1;
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");
if (root == NULL)
......@@ -2970,7 +2963,7 @@ error:
return ret;
}
static int
int
xenDaemonListDefinedDomains(virConnectPtr conn,
char **const names,
int maxnames)
......@@ -2978,10 +2971,6 @@ xenDaemonListDefinedDomains(virConnectPtr conn,
struct sexpr *root = NULL;
int i, ret = -1;
struct sexpr *_for_i, *node;
xenUnifiedPrivatePtr priv = conn->privateData;
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return -1;
if (maxnames == 0)
return 0;
......@@ -3387,8 +3376,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain,
}
struct xenUnifiedDriver xenDaemonDriver = {
.xenListDefinedDomains = xenDaemonListDefinedDomains,
.xenNumOfDefinedDomains = xenDaemonNumOfDefinedDomains,
.xenDomainCreate = xenDaemonDomainCreate,
.xenDomainDefineXML = xenDaemonDomainDefineXML,
.xenDomainUndefine = xenDaemonDomainUndefine,
......
......@@ -109,6 +109,11 @@ char **xenDaemonListDomainsOld(virConnectPtr xend);
char *xenDaemonDomainGetOSType(virDomainPtr domain);
int xenDaemonNumOfDefinedDomains(virConnectPtr conn);
int xenDaemonListDefinedDomains(virConnectPtr conn,
char **const names,
int maxnames);
virDomainPtr xenDaemonDomainDefineXML(virConnectPtr xend, const char *sexpr);
int xenDaemonDomainCreate(virDomainPtr domain);
int xenDaemonDomainUndefine(virDomainPtr domain);
......
......@@ -81,8 +81,6 @@ static int xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
#define XM_XML_ERROR "Invalid xml"
struct xenUnifiedDriver xenXMDriver = {
.xenListDefinedDomains = xenXMListDefinedDomains,
.xenNumOfDefinedDomains = xenXMNumOfDefinedDomains,
.xenDomainCreate = xenXMDomainCreate,
.xenDomainDefineXML = xenXMDomainDefineXML,
.xenDomainUndefine = xenXMDomainUndefine,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册