You need to sign in or sign up before continuing.
提交 fa9b8b04 编写于 作者: D Daniel P. Berrange

Convert Xen domain core dump driver methods to use virDomainDefPtr

Introduce use of a virDomainDefPtr in the domain coredump
APIs to simplify introduction of ACL security checks.
The virDomainPtr cannot be safely used, since the app
may have supplied mis-matching name/uuid/id fields. eg
the name points to domain X, while the uuid points to
domain Y. Resolving the virDomainPtr to a virDomainDefPtr
ensures a consistent name/uuid/id set.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 89d819f2
...@@ -1191,7 +1191,19 @@ xenUnifiedDomainRestore(virConnectPtr conn, const char *from) ...@@ -1191,7 +1191,19 @@ xenUnifiedDomainRestore(virConnectPtr conn, const char *from)
static int static int
xenUnifiedDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags) xenUnifiedDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
{ {
return xenDaemonDomainCoreDump(dom, to, flags); virDomainDefPtr def = NULL;
int ret = -1;
virCheckFlags(0, -1);
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
ret = xenDaemonDomainCoreDump(dom->conn, def, to, flags);
cleanup:
virDomainDefFree(def);
return ret;
} }
static int static int
......
...@@ -1446,7 +1446,8 @@ xenDaemonDomainSave(virConnectPtr conn, ...@@ -1446,7 +1446,8 @@ xenDaemonDomainSave(virConnectPtr conn,
/** /**
* xenDaemonDomainCoreDump: * xenDaemonDomainCoreDump:
* @domain: pointer to the Domain block * @conn: the connection object
* @def: domain configuration
* @filename: path for the output file * @filename: path for the output file
* @flags: extra flags, currently unused * @flags: extra flags, currently unused
* *
...@@ -1457,19 +1458,20 @@ xenDaemonDomainSave(virConnectPtr conn, ...@@ -1457,19 +1458,20 @@ xenDaemonDomainSave(virConnectPtr conn,
* Returns 0 in case of success, -1 in case of error. * Returns 0 in case of success, -1 in case of error.
*/ */
int int
xenDaemonDomainCoreDump(virDomainPtr domain, xenDaemonDomainCoreDump(virConnectPtr conn,
virDomainDefPtr def,
const char *filename, const char *filename,
unsigned int flags) unsigned int flags)
{ {
virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH, -1); virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH, -1);
if (domain->id < 0) { if (def->id < 0) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("Domain %s isn't running."), domain->name); _("Domain %s isn't running."), def->name);
return -1; return -1;
} }
return xend_op(domain->conn, domain->name, return xend_op(conn, def->name,
"op", "dump", "file", filename, "op", "dump", "file", filename,
"live", (flags & VIR_DUMP_LIVE ? "1" : "0"), "live", (flags & VIR_DUMP_LIVE ? "1" : "0"),
"crash", (flags & VIR_DUMP_CRASH ? "1" : "0"), "crash", (flags & VIR_DUMP_CRASH ? "1" : "0"),
......
...@@ -102,7 +102,9 @@ int xenDaemonDomainDestroy(virConnectPtr conn, virDomainDefPtr def); ...@@ -102,7 +102,9 @@ int xenDaemonDomainDestroy(virConnectPtr conn, virDomainDefPtr def);
int xenDaemonDomainSave(virConnectPtr conn, int xenDaemonDomainSave(virConnectPtr conn,
virDomainDefPtr def, virDomainDefPtr def,
const char *filename); const char *filename);
int xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename, int xenDaemonDomainCoreDump(virConnectPtr conn,
virDomainDefPtr def,
const char *filename,
unsigned int flags); unsigned int flags);
int xenDaemonDomainRestore(virConnectPtr conn, const char *filename); int xenDaemonDomainRestore(virConnectPtr conn, const char *filename);
int xenDaemonDomainSetMemory(virConnectPtr conn, int xenDaemonDomainSetMemory(virConnectPtr conn,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册