提交 ac4818d0 编写于 作者: D Daniel Veillard

* src/driver.h src/libvirt.c src/test.c src/xen_internal.c

  src/xend_internal.c src/xs_internal.c: add driver numbers and
  tweak a bit suspend/resume/destroy operation to avoid doing
  them directly though the hypervisor if other succeeded first.
Daniel
上级 a2e2e465
Wed Jun 21 13:02:30 EDT 2006 Daniel Veillard <veillard@redhat.com>
* src/driver.h src/libvirt.c src/test.c src/xen_internal.c
src/xend_internal.c src/xs_internal.c: add driver numbers and
tweak a bit suspend/resume/destroy operation to avoid doing
them directly though the hypervisor if other succeeded first.
Wed Jun 21 12:23:15 EDT 2006 Daniel Veillard <veillard@redhat.com>
* src/xen_internal.c: try to autodetect the Xen hypervisor version
......
......@@ -13,6 +13,17 @@
extern "C" {
#endif
/*
* List of registered drivers numbers
*/
typedef enum {
VIR_DRV_XEN_HYPERVISOR = 1,
VIR_DRV_XEN_STORE = 2,
VIR_DRV_XEN_DAEMON = 3,
VIR_DRV_TEST = 4
} virDrvNo;
typedef enum {
VIR_DRV_OPEN_QUIET = 1,
VIR_DRV_OPEN_RO = 2
......@@ -103,8 +114,9 @@ typedef virDriver *virDriverPtr;
* entry points for it.
*/
struct _virDriver {
const char *name;
unsigned long ver;
int no; /* the number virDrvNo */
const char * name; /* the name of the driver */
unsigned long ver; /* the version of the backend */
virDrvInit init;
virDrvOpen open;
virDrvClose close;
......
......@@ -731,9 +731,21 @@ virDomainDestroy(virDomainPtr domain)
return (-1);
#endif
/* Go though the driver registered entry points */
/*
* Go though the driver registered entry points but use the
* XEN_HYPERVISOR directly only as a last mechanism
*/
for (i = 0;i < conn->nb_drivers;i++) {
if ((conn->drivers[i] != NULL) &&
(conn->drivers[i]->no != VIR_DRV_XEN_HYPERVISOR) &&
(conn->drivers[i]->domainDestroy != NULL)) {
if (conn->drivers[i]->domainDestroy(domain) == 0)
ret = 0;
}
}
for (i = 0;i < conn->nb_drivers;i++) {
if ((conn->drivers[i] != NULL) &&
(conn->drivers[i]->no == VIR_DRV_XEN_HYPERVISOR) &&
(conn->drivers[i]->domainDestroy != NULL)) {
if (conn->drivers[i]->domainDestroy(domain) == 0)
ret = 0;
......@@ -798,9 +810,21 @@ virDomainSuspend(virDomainPtr domain)
return (-1);
#endif
/* Go though the driver registered entry points */
/*
* Go though the driver registered entry points but use the
* XEN_HYPERVISOR directly only as a last mechanism
*/
for (i = 0;i < conn->nb_drivers;i++) {
if ((conn->drivers[i] != NULL) &&
(conn->drivers[i]->no != VIR_DRV_XEN_HYPERVISOR) &&
(conn->drivers[i]->domainSuspend != NULL)) {
if (conn->drivers[i]->domainSuspend(domain) == 0)
ret = 0;
}
}
for (i = 0;i < conn->nb_drivers;i++) {
if ((conn->drivers[i] != NULL) &&
(conn->drivers[i]->no == VIR_DRV_XEN_HYPERVISOR) &&
(conn->drivers[i]->domainSuspend != NULL)) {
if (conn->drivers[i]->domainSuspend(domain) == 0)
ret = 0;
......@@ -842,9 +866,21 @@ virDomainResume(virDomainPtr domain)
return (-1);
#endif
/* Go though the driver registered entry points */
/*
* Go though the driver registered entry points but use the
* XEN_HYPERVISOR directly only as a last mechanism
*/
for (i = 0;i < conn->nb_drivers;i++) {
if ((conn->drivers[i] != NULL) &&
(conn->drivers[i]->no != VIR_DRV_XEN_HYPERVISOR) &&
(conn->drivers[i]->domainResume != NULL)) {
if (conn->drivers[i]->domainResume(domain) == 0)
return(0);
}
}
for (i = 0;i < conn->nb_drivers;i++) {
if ((conn->drivers[i] != NULL) &&
(conn->drivers[i]->no == VIR_DRV_XEN_HYPERVISOR) &&
(conn->drivers[i]->domainResume != NULL)) {
if (conn->drivers[i]->domainResume(domain) == 0)
return(0);
......
......@@ -17,6 +17,7 @@
#include "test.h"
static virDriver testDriver = {
VIR_DRV_TEST,
"Test",
LIBVIR_VERSION_NUMBER,
NULL, /* init */
......
......@@ -54,6 +54,7 @@ static unsigned long xenHypervisorGetMaxMemory(virDomainPtr domain);
static int xenHypervisorInit(void);
static virDriver xenHypervisorDriver = {
VIR_DRV_XEN_HYPERVISOR,
"Xen",
(DOM0_INTERFACE_VERSION >> 24) * 1000000 +
((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 +
......@@ -143,7 +144,7 @@ int xenHypervisorInit(void)
ret = ioctl(fd, cmd, (unsigned long) &hc);
if ((ret != -1) && (ret != 0)) {
fprintf(stderr, "Using new hypervisor call: %X\n", ret);
/* fprintf(stderr, "Using new hypervisor call: %X\n", ret); */
hv_version = ret;
xen_ioctl_hypercall_cmd = cmd;
old_hypervisor = 0;
......@@ -156,7 +157,7 @@ int xenHypervisorInit(void)
cmd = _IOC(_IOC_NONE, 'P', 0, sizeof(old_hypercall_t));
ret = ioctl(fd, cmd, (unsigned long) &old_hc);
if ((ret != -1) && (ret != 0)) {
fprintf(stderr, "Using old hypervisor call: %X\n", ret);
/* fprintf(stderr, "Using old hypervisor call: %X\n", ret); */
hv_version = ret;
xen_ioctl_hypercall_cmd = cmd;
old_hypervisor = 1;
......
......@@ -49,6 +49,7 @@ static virDomainPtr xenDaemonCreateLinux(virConnectPtr conn,
unsigned int flags);
static virDriver xenDaemonDriver = {
VIR_DRV_XEN_DAEMON,
"XenDaemon",
(DOM0_INTERFACE_VERSION >> 24) * 1000000 +
((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 +
......
......@@ -32,6 +32,7 @@
#define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd"
static virDriver xenStoreDriver = {
VIR_DRV_XEN_STORE,
"XenStore",
(DOM0_INTERFACE_VERSION >> 24) * 1000000 +
((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 +
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册