From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> 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: Daniel P. Berrange <berrange@xxxxxxxxxx> --- src/xen/xen_driver.c | 14 +++++++++++++- src/xen/xend_internal.c | 9 +++++---- src/xen/xend_internal.h | 4 +++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 7c00b70..a6c87ce 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -1193,7 +1193,19 @@ xenUnifiedDomainRestore(virConnectPtr conn, const char *from) static int 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 diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index 273408d..8dc1a2d 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -1447,19 +1447,20 @@ xenDaemonDomainSave(virConnectPtr conn, * Returns 0 in case of success, -1 in case of error. */ int -xenDaemonDomainCoreDump(virDomainPtr domain, +xenDaemonDomainCoreDump(virConnectPtr conn, + virDomainDefPtr def, const char *filename, unsigned int flags) { virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH, -1); - 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, + return xend_op(conn, def->name, "op", "dump", "file", filename, "live", (flags & VIR_DUMP_LIVE ? "1" : "0"), "crash", (flags & VIR_DUMP_CRASH ? "1" : "0"), diff --git a/src/xen/xend_internal.h b/src/xen/xend_internal.h index aa05130..b2d4368 100644 --- a/src/xen/xend_internal.h +++ b/src/xen/xend_internal.h @@ -95,7 +95,9 @@ int xenDaemonDomainDestroy(virConnectPtr conn, virDomainDefPtr def); int xenDaemonDomainSave(virConnectPtr conn, virDomainDefPtr def, const char *filename); -int xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename, +int xenDaemonDomainCoreDump(virConnectPtr conn, + virDomainDefPtr def, + const char *filename, unsigned int flags); int xenDaemonDomainRestore(virConnectPtr conn, const char *filename); int xenDaemonDomainSetMemory(virConnectPtr conn, -- 1.8.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list