report error for some xend operations on shutdown domain

This commit is contained in:
John Levon 2009-02-05 17:24:51 +00:00
parent bc68ae8060
commit b8b4fd4c7d
2 changed files with 52 additions and 8 deletions

View File

@ -1,3 +1,8 @@
Thu Feb 5 17:19:24 GMT 2009 John Levon <john.levon@sun.com>
* src/xend_internal.c: report error for some xend operations on
shutdown domain
Thu Feb 5 16:53:37 GMT 2009 John Levon <john.levon@sun.com> Thu Feb 5 16:53:37 GMT 2009 John Levon <john.levon@sun.com>
* src/xend_internal.c: robustify sexpr parser for NICs * src/xend_internal.c: robustify sexpr parser for NICs

View File

@ -2828,8 +2828,13 @@ xenDaemonDomainSuspend(virDomainPtr domain)
__FUNCTION__); __FUNCTION__);
return(-1); return(-1);
} }
if (domain->id < 0)
if (domain->id < 0) {
virXendError(domain->conn, VIR_ERR_INVALID_ARG,
_("Domain %s isn't running."), domain->name);
return(-1); return(-1);
}
return xend_op(domain->conn, domain->name, "op", "pause", NULL); return xend_op(domain->conn, domain->name, "op", "pause", NULL);
} }
@ -2850,8 +2855,13 @@ xenDaemonDomainResume(virDomainPtr domain)
__FUNCTION__); __FUNCTION__);
return(-1); return(-1);
} }
if (domain->id < 0)
if (domain->id < 0) {
virXendError(domain->conn, VIR_ERR_INVALID_ARG,
_("Domain %s isn't running."), domain->name);
return(-1); return(-1);
}
return xend_op(domain->conn, domain->name, "op", "unpause", NULL); return xend_op(domain->conn, domain->name, "op", "unpause", NULL);
} }
@ -2873,8 +2883,13 @@ xenDaemonDomainShutdown(virDomainPtr domain)
__FUNCTION__); __FUNCTION__);
return(-1); return(-1);
} }
if (domain->id < 0)
if (domain->id < 0) {
virXendError(domain->conn, VIR_ERR_INVALID_ARG,
_("Domain %s isn't running."), domain->name);
return(-1); return(-1);
}
return xend_op(domain->conn, domain->name, "op", "shutdown", "reason", "poweroff", NULL); return xend_op(domain->conn, domain->name, "op", "shutdown", "reason", "poweroff", NULL);
} }
@ -2897,8 +2912,13 @@ xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags ATTRIBUTE_UNUSED)
__FUNCTION__); __FUNCTION__);
return(-1); return(-1);
} }
if (domain->id < 0)
if (domain->id < 0) {
virXendError(domain->conn, VIR_ERR_INVALID_ARG,
_("Domain %s isn't running."), domain->name);
return(-1); return(-1);
}
return xend_op(domain->conn, domain->name, "op", "shutdown", "reason", "reboot", NULL); return xend_op(domain->conn, domain->name, "op", "shutdown", "reason", "reboot", NULL);
} }
@ -2923,8 +2943,13 @@ xenDaemonDomainDestroy(virDomainPtr domain)
__FUNCTION__); __FUNCTION__);
return(-1); return(-1);
} }
if (domain->id < 0)
if (domain->id < 0) {
virXendError(domain->conn, VIR_ERR_INVALID_ARG,
_("Domain %s isn't running."), domain->name);
return(-1); return(-1);
}
return xend_op(domain->conn, domain->name, "op", "destroy", NULL); return xend_op(domain->conn, domain->name, "op", "destroy", NULL);
} }
@ -2988,12 +3013,17 @@ int
xenDaemonDomainSave(virDomainPtr domain, const char *filename) xenDaemonDomainSave(virDomainPtr domain, const char *filename)
{ {
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL) || if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL) ||
(filename == NULL) || (domain->id < 0)) { (filename == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG, virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__); __FUNCTION__);
return(-1); return(-1);
} }
if (domain->id < 0) {
virXendError(domain->conn, VIR_ERR_INVALID_ARG,
_("Domain %s isn't running."), domain->name);
return(-1);
}
/* We can't save the state of Domain-0, that would mean stopping it too */ /* We can't save the state of Domain-0, that would mean stopping it too */
if (domain->id == 0) { if (domain->id == 0) {
@ -3025,8 +3055,13 @@ xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
__FUNCTION__); __FUNCTION__);
return(-1); return(-1);
} }
if (domain->id < 0)
if (domain->id < 0) {
virXendError(domain->conn, VIR_ERR_INVALID_ARG,
_("Domain %s isn't running."), domain->name);
return(-1); return(-1);
}
return xend_op(domain->conn, domain->name, "op", "dump", "file", filename, return xend_op(domain->conn, domain->name, "op", "dump", "file", filename,
"live", "0", "crash", "0", NULL); "live", "0", "crash", "0", NULL);
} }
@ -3594,8 +3629,12 @@ xenDaemonDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
__FUNCTION__); __FUNCTION__);
return (-1); return (-1);
} }
if (domain->id < 0)
if (domain->id < 0) {
virXendError(domain->conn, VIR_ERR_INVALID_ARG,
_("Domain %s isn't running."), domain->name);
return(-1); return(-1);
}
/* from bit map, build character string of mapped CPU numbers */ /* from bit map, build character string of mapped CPU numbers */
for (i = 0; i < maplen; i++) for (j = 0; j < 8; j++) for (i = 0; i < maplen; i++) for (j = 0; j < 8; j++)