}
+static virDomainDefPtr xenGetDomainDefForDom(virDomainPtr dom)
+{
+ /* UUID lookup is more efficient than name lookup */
+ return xenGetDomainDefForUUID(dom->conn, dom->uuid);
+}
+
+
/**
* xenNumaInit:
* @conn: pointer to the hypervisor connection
static int
xenUnifiedDomainSuspend(virDomainPtr dom)
{
- return xenDaemonDomainSuspend(dom);
+ int ret = -1;
+ virDomainDefPtr def;
+
+ if (!(def = xenGetDomainDefForDom(dom)))
+ goto cleanup;
+
+ ret = xenDaemonDomainSuspend(dom->conn, def);
+
+cleanup:
+ virDomainDefFree(def);
+ return ret;
}
static int
xenUnifiedDomainResume(virDomainPtr dom)
{
- return xenDaemonDomainResume(dom);
+ int ret = -1;
+ virDomainDefPtr def;
+
+ if (!(def = xenGetDomainDefForDom(dom)))
+ goto cleanup;
+
+ ret = xenDaemonDomainResume(dom->conn, def);
+
+cleanup:
+ virDomainDefFree(def);
+ return ret;
}
static int
xenUnifiedDomainShutdownFlags(virDomainPtr dom,
unsigned int flags)
{
+ int ret = -1;
+ virDomainDefPtr def;
+
virCheckFlags(0, -1);
- return xenDaemonDomainShutdown(dom);
+ if (!(def = xenGetDomainDefForDom(dom)))
+ goto cleanup;
+
+ ret = xenDaemonDomainShutdown(dom->conn, def);
+
+cleanup:
+ virDomainDefFree(def);
+ return ret;
}
static int
static int
xenUnifiedDomainReboot(virDomainPtr dom, unsigned int flags)
{
+ int ret = -1;
+ virDomainDefPtr def;
+
virCheckFlags(0, -1);
- return xenDaemonDomainReboot(dom);
+ if (!(def = xenGetDomainDefForDom(dom)))
+ goto cleanup;
+
+ ret = xenDaemonDomainReboot(dom->conn, def);
+
+cleanup:
+ virDomainDefFree(def);
+ return ret;
}
static int
xenUnifiedDomainDestroyFlags(virDomainPtr dom,
unsigned int flags)
{
+ int ret = -1;
+ virDomainDefPtr def;
+
virCheckFlags(0, -1);
- return xenDaemonDomainDestroy(dom);
+ if (!(def = xenGetDomainDefForDom(dom)))
+ goto cleanup;
+
+ ret = xenDaemonDomainDestroy(dom->conn, def);
+
+cleanup:
+ virDomainDefFree(def);
+ return ret;
}
static int
/**
* xenDaemonDomainSuspend:
- * @domain: pointer to the Domain block
+ * @conn: the connection object
+ * @def: the domain to suspend
*
* Pause the domain, the domain is not scheduled anymore though its resources
* are preserved. Use xenDaemonDomainResume() to resume execution.
* Returns 0 in case of success, -1 (with errno) in case of error.
*/
int
-xenDaemonDomainSuspend(virDomainPtr domain)
+xenDaemonDomainSuspend(virConnectPtr conn, virDomainDefPtr def)
{
- if (domain->id < 0) {
+ if (def->id < 0) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("Domain %s isn't running."), domain->name);
+ _("Domain %s isn't running."), def->name);
return -1;
}
- return xend_op(domain->conn, domain->name, "op", "pause", NULL);
+ return xend_op(conn, def->name, "op", "pause", NULL);
}
/**
* xenDaemonDomainResume:
- * @xend: pointer to the Xen Daemon block
- * @name: name for the domain
+ * @conn: the connection object
+ * @def: the domain to resume
*
* Resume the domain after xenDaemonDomainSuspend() has been called
*
* Returns 0 in case of success, -1 (with errno) in case of error.
*/
int
-xenDaemonDomainResume(virDomainPtr domain)
+xenDaemonDomainResume(virConnectPtr conn, virDomainDefPtr def)
{
- if (domain->id < 0) {
+ if (def->id < 0) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("Domain %s isn't running."), domain->name);
+ _("Domain %s isn't running."), def->name);
return -1;
}
- return xend_op(domain->conn, domain->name, "op", "unpause", NULL);
+ return xend_op(conn, def->name, "op", "unpause", NULL);
}
/**
* xenDaemonDomainShutdown:
- * @domain: pointer to the Domain block
+ * @conn: the connection object
+ * @def: the domain to shutdown
*
* Shutdown the domain, the OS is requested to properly shutdown
* and the domain may ignore it. It will return immediately
* Returns 0 in case of success, -1 (with errno) in case of error.
*/
int
-xenDaemonDomainShutdown(virDomainPtr domain)
+xenDaemonDomainShutdown(virConnectPtr conn, virDomainDefPtr def)
{
- if (domain->id < 0) {
+ if (def->id < 0) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("Domain %s isn't running."), domain->name);
+ _("Domain %s isn't running."), def->name);
return -1;
}
- return xend_op(domain->conn, domain->name, "op", "shutdown", "reason", "poweroff", NULL);
+ return xend_op(conn, def->name, "op", "shutdown", "reason", "poweroff", NULL);
}
/**
* xenDaemonDomainReboot:
- * @domain: pointer to the Domain block
+ * @conn: the connection object
+ * @def: the domain to reboot
*
* Reboot the domain, the OS is requested to properly shutdown
* and restart but the domain may ignore it. It will return immediately
* Returns 0 in case of success, -1 (with errno) in case of error.
*/
int
-xenDaemonDomainReboot(virDomainPtr domain)
+xenDaemonDomainReboot(virConnectPtr conn, virDomainDefPtr def)
{
- if (domain->id < 0) {
+ if (def->id < 0) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("Domain %s isn't running."), domain->name);
+ _("Domain %s isn't running."), def->name);
return -1;
}
- return xend_op(domain->conn, domain->name, "op", "shutdown", "reason", "reboot", NULL);
+ return xend_op(conn, def->name, "op", "shutdown", "reason", "reboot", NULL);
}
/**
* xenDaemonDomainDestroy:
- * @domain: pointer to the Domain block
+ * @conn: the connection object
+ * @def: the domain to destroy
*
* Abruptly halt the domain, the OS is not properly shutdown and the
* resources allocated for the domain are immediately freed, mounted
* Returns 0 in case of success, -1 (with errno) in case of error.
*/
int
-xenDaemonDomainDestroy(virDomainPtr domain)
+xenDaemonDomainDestroy(virConnectPtr conn, virDomainDefPtr def)
{
- if (domain->id < 0) {
+ if (def->id < 0) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("Domain %s isn't running."), domain->name);
+ _("Domain %s isn't running."), def->name);
return -1;
}
- return xend_op(domain->conn, domain->name, "op", "destroy", NULL);
+ return xend_op(conn, def->name, "op", "destroy", NULL);
}
/**
if (xend_wait_for_devices(conn, def->name) < 0)
goto error;
- if (xenDaemonDomainResume(dom) < 0)
+ if (xenDaemonDomainResume(conn, def) < 0)
goto error;
virDomainDefFree(def);
error:
/* Make sure we don't leave a still-born domain around */
if (dom != NULL) {
- xenDaemonDomainDestroy(dom);
+ xenDaemonDomainDestroy(conn, def);
virObjectUnref(dom);
}
virDomainDefFree(def);