* src/xen_internal.c: applied patch from Peter Vetere so that

crashed domains ain't reported as shut off.
Daniel
This commit is contained in:
Daniel Veillard 2006-10-11 16:11:59 +00:00
parent 1da9cd13af
commit d9388dbfbd
2 changed files with 32 additions and 2 deletions

View File

@ -1,3 +1,8 @@
Wed Oct 11 17:16:44 CEST 2006 Daniel Veillard <veillard@redhat.com>
* src/xen_internal.c: applied patch from Peter Vetere so that
crashed domains ain't reported as shut off.
Wed Oct 11 16:23:58 CEST 2006 Daniel Veillard <veillard@redhat.com>
* virsh.1: fixed some typo and unclear language pointed out by

View File

@ -27,6 +27,9 @@
#include <xen/xen.h>
#include <xen/linux/privcmd.h>
/* required for shutdown flags */
#include <xen/sched.h>
/* #define DEBUG */
/*
* so far there is 2 versions of the structures usable for doing
@ -81,6 +84,17 @@ static int dom_interface_version = -1;
#define DOMFLAGS_SHUTDOWNSHIFT 16
#endif
/*
* These flags explain why a system is in the state of "shutdown". Normally,
* They are defined in xen/sched.h
*/
#ifndef SHUTDOWN_poweroff
#define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */
#define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */
#define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */
#define SHUTDOWN_crash 3 /* Tell controller we've crashed. */
#endif
#define XEN_V0_OP_GETDOMAININFOLIST 38
#define XEN_V1_OP_GETDOMAININFOLIST 38
#define XEN_V2_OP_GETDOMAININFOLIST 6
@ -1500,6 +1514,7 @@ xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info)
xen_getdomaininfo dominfo;
int ret;
static int kb_per_pages = 0;
uint32_t domain_flags, domain_state, domain_shutdown_cause;
if (kb_per_pages == 0) {
kb_per_pages = sysconf(_SC_PAGESIZE) / 1024;
@ -1518,12 +1533,22 @@ xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info)
if ((ret < 0) || (XEN_GETDOMAININFO_DOMAIN(dominfo) != id))
return (-1);
switch (XEN_GETDOMAININFO_FLAGS(dominfo) & 0xFF) {
domain_flags = XEN_GETDOMAININFO_FLAGS(dominfo);
domain_state = domain_flags & 0xFF;
switch (domain_state) {
case DOMFLAGS_DYING:
info->state = VIR_DOMAIN_SHUTDOWN;
break;
case DOMFLAGS_SHUTDOWN:
info->state = VIR_DOMAIN_SHUTOFF;
/* The domain is shutdown. Determine the cause. */
domain_shutdown_cause = domain_flags >> DOMFLAGS_SHUTDOWNSHIFT;
switch (domain_shutdown_cause) {
case SHUTDOWN_crash:
info->state = VIR_DOMAIN_CRASHED;
break;
default:
info->state = VIR_DOMAIN_SHUTOFF;
}
break;
case DOMFLAGS_PAUSED:
info->state = VIR_DOMAIN_PAUSED;