mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
* src/libvirt.c src/xen_internal.c src/xend_internal.c
src/xs_internal.c: fix the connection and GetType initialization. Daniel
This commit is contained in:
parent
7efa1c11b5
commit
2bfd45c942
@ -1,3 +1,8 @@
|
|||||||
|
Tue Jun 13 18:35:22 EDT 2006 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
|
* src/libvirt.c src/xen_internal.c src/xend_internal.c
|
||||||
|
src/xs_internal.c: fix the connection and GetType initialization.
|
||||||
|
|
||||||
Tue Jun 13 16:37:27 EDT 2006 Daniel Veillard <veillard@redhat.com>
|
Tue Jun 13 16:37:27 EDT 2006 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* docs//*: rebuilt the documentation
|
* docs//*: rebuilt the documentation
|
||||||
|
@ -217,12 +217,19 @@ virGetVersion(unsigned long *libVer, const char *type,
|
|||||||
virConnectPtr
|
virConnectPtr
|
||||||
virConnectOpen(const char *name)
|
virConnectOpen(const char *name)
|
||||||
{
|
{
|
||||||
int i, res;
|
int i, res, for_xen = 0;
|
||||||
virConnectPtr ret = NULL;
|
virConnectPtr ret = NULL;
|
||||||
|
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
virInitialize();
|
virInitialize();
|
||||||
|
|
||||||
|
if (name == NULL) {
|
||||||
|
name = "Xen";
|
||||||
|
for_xen = 1;
|
||||||
|
} else if (strncasecmp(name, "xen", 3)) {
|
||||||
|
for_xen = 1;
|
||||||
|
}
|
||||||
|
|
||||||
ret = virGetConnect();
|
ret = virGetConnect();
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
virLibConnError(NULL, VIR_ERR_NO_MEMORY, "Allocating connection");
|
virLibConnError(NULL, VIR_ERR_NO_MEMORY, "Allocating connection");
|
||||||
@ -236,8 +243,8 @@ virConnectOpen(const char *name)
|
|||||||
* For a default connect to Xen make sure we manage to contact
|
* For a default connect to Xen make sure we manage to contact
|
||||||
* all related drivers.
|
* all related drivers.
|
||||||
*/
|
*/
|
||||||
if ((res < 0) && (name == NULL) &&
|
if ((res < 0) && (for_xen) &&
|
||||||
(!strncmp(virDriverTab[i]->name, "Xen", 3)))
|
(!strncasecmp(virDriverTab[i]->name, "xen", 3)))
|
||||||
goto failed;
|
goto failed;
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
ret->drivers[ret->nb_drivers++] = virDriverTab[i];
|
ret->drivers[ret->nb_drivers++] = virDriverTab[i];
|
||||||
@ -282,6 +289,9 @@ virConnectOpenReadOnly(const char *name)
|
|||||||
if (!initialized)
|
if (!initialized)
|
||||||
virInitialize();
|
virInitialize();
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
name = "Xen";
|
||||||
|
|
||||||
ret = virGetConnect();
|
ret = virGetConnect();
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
virLibConnError(NULL, VIR_ERR_NO_MEMORY, "Allocating connection");
|
virLibConnError(NULL, VIR_ERR_NO_MEMORY, "Allocating connection");
|
||||||
@ -354,11 +364,20 @@ const char *
|
|||||||
virConnectGetType(virConnectPtr conn)
|
virConnectGetType(virConnectPtr conn)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
const char *ret;
|
||||||
|
|
||||||
if (!VIR_IS_CONNECT(conn)) {
|
if (!VIR_IS_CONNECT(conn)) {
|
||||||
virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
|
virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
for (i = 0;i < conn->nb_drivers;i++) {
|
||||||
|
if ((conn->drivers[i] != NULL) &&
|
||||||
|
(conn->drivers[i]->type != NULL)) {
|
||||||
|
ret = conn->drivers[i]->type(conn);
|
||||||
|
if (ret != NULL)
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
for (i = 0;i < conn->nb_drivers;i++) {
|
for (i = 0;i < conn->nb_drivers;i++) {
|
||||||
if ((conn->drivers[i] != NULL) &&
|
if ((conn->drivers[i] != NULL) &&
|
||||||
(conn->drivers[i]->name != NULL)) {
|
(conn->drivers[i]->name != NULL)) {
|
||||||
|
@ -40,6 +40,8 @@ typedef struct hypercall_struct {
|
|||||||
|
|
||||||
#define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd"
|
#define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd"
|
||||||
|
|
||||||
|
static const char * xenHypervisorGetType(virConnectPtr conn);
|
||||||
|
|
||||||
static virDriver xenHypervisorDriver = {
|
static virDriver xenHypervisorDriver = {
|
||||||
"Xen",
|
"Xen",
|
||||||
(DOM0_INTERFACE_VERSION >> 24) * 1000000 +
|
(DOM0_INTERFACE_VERSION >> 24) * 1000000 +
|
||||||
@ -48,7 +50,7 @@ static virDriver xenHypervisorDriver = {
|
|||||||
NULL, /* init */
|
NULL, /* init */
|
||||||
xenHypervisorOpen, /* open */
|
xenHypervisorOpen, /* open */
|
||||||
xenHypervisorClose, /* close */
|
xenHypervisorClose, /* close */
|
||||||
NULL, /* type */
|
xenHypervisorGetType, /* type */
|
||||||
xenHypervisorGetVersion, /* version */
|
xenHypervisorGetVersion, /* version */
|
||||||
NULL, /* nodeGetInfo */
|
NULL, /* nodeGetInfo */
|
||||||
xenHypervisorListDomains, /* listDomains */
|
xenHypervisorListDomains, /* listDomains */
|
||||||
@ -121,7 +123,7 @@ xenHypervisorOpen(virConnectPtr conn, const char *name, int flags)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if ((name != NULL) && (strcmp(name, "xen")))
|
if ((name != NULL) && (strcasecmp(name, "xen")))
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
conn->handle = -1;
|
conn->handle = -1;
|
||||||
@ -201,6 +203,26 @@ xenHypervisorDoOp(int handle, dom0_op_t * op)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xenHypervisorGetType:
|
||||||
|
* @conn: pointer to the Xen Hypervisor block
|
||||||
|
*
|
||||||
|
* Get the version level of the Hypervisor running.
|
||||||
|
*
|
||||||
|
* Returns -1 in case of error, 0 otherwise. if the version can't be
|
||||||
|
* extracted by lack of capacities returns 0 and @hvVer is 0, otherwise
|
||||||
|
* @hvVer value is major * 1,000,000 + minor * 1,000 + release
|
||||||
|
*/
|
||||||
|
static const char *
|
||||||
|
xenHypervisorGetType(virConnectPtr conn)
|
||||||
|
{
|
||||||
|
if (!VIR_IS_CONNECT(conn)) {
|
||||||
|
virXenError(VIR_ERR_INVALID_CONN, __FUNCTION__, 0);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
return("Xen");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenHypervisorGetVersion:
|
* xenHypervisorGetVersion:
|
||||||
* @conn: pointer to the connection block
|
* @conn: pointer to the connection block
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "xend_internal.h"
|
#include "xend_internal.h"
|
||||||
#include "xen_internal.h" /* for DOM0_INTERFACE_VERSION */
|
#include "xen_internal.h" /* for DOM0_INTERFACE_VERSION */
|
||||||
|
|
||||||
|
static const char * xenDaemonGetType(virConnectPtr conn);
|
||||||
static int xenDaemonNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info);
|
static int xenDaemonNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info);
|
||||||
static int xenDaemonGetVersion(virConnectPtr conn, unsigned long *hvVer);
|
static int xenDaemonGetVersion(virConnectPtr conn, unsigned long *hvVer);
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ static virDriver xenDaemonDriver = {
|
|||||||
NULL, /* init */
|
NULL, /* init */
|
||||||
xenDaemonOpen, /* open */
|
xenDaemonOpen, /* open */
|
||||||
xenDaemonClose, /* close */
|
xenDaemonClose, /* close */
|
||||||
NULL, /* type */
|
xenDaemonGetType, /* type */
|
||||||
xenDaemonGetVersion, /* version */
|
xenDaemonGetVersion, /* version */
|
||||||
xenDaemonNodeGetInfo, /* nodeGetInfo */
|
xenDaemonNodeGetInfo, /* nodeGetInfo */
|
||||||
NULL, /* listDomains */
|
NULL, /* listDomains */
|
||||||
@ -2076,6 +2077,26 @@ xenDaemonNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) {
|
|||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xenDaemonGetType:
|
||||||
|
* @conn: pointer to the Xen Daemon block
|
||||||
|
*
|
||||||
|
* Get the version level of the Hypervisor running.
|
||||||
|
*
|
||||||
|
* Returns -1 in case of error, 0 otherwise. if the version can't be
|
||||||
|
* extracted by lack of capacities returns 0 and @hvVer is 0, otherwise
|
||||||
|
* @hvVer value is major * 1,000,000 + minor * 1,000 + release
|
||||||
|
*/
|
||||||
|
static const char *
|
||||||
|
xenDaemonGetType(virConnectPtr conn)
|
||||||
|
{
|
||||||
|
if (!VIR_IS_CONNECT(conn)) {
|
||||||
|
virXendError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
return("XenDaemon");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDaemonGetVersion:
|
* xenDaemonGetVersion:
|
||||||
* @conn: pointer to the Xen Daemon block
|
* @conn: pointer to the Xen Daemon block
|
||||||
|
@ -288,7 +288,7 @@ virConnectCheckStoreID(virConnectPtr conn, int id)
|
|||||||
int
|
int
|
||||||
xenStoreOpen(virConnectPtr conn, const char *name, int flags)
|
xenStoreOpen(virConnectPtr conn, const char *name, int flags)
|
||||||
{
|
{
|
||||||
if ((name != NULL) && (strcmp(name, "xen")))
|
if ((name != NULL) && (strcasecmp(name, "xen")))
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
if (flags & VIR_DRV_OPEN_RO)
|
if (flags & VIR_DRV_OPEN_RO)
|
||||||
|
Loading…
Reference in New Issue
Block a user