mirror of https://github.com/xqemu/xqemu.git
This pull request fixes some leaks (memory, fd) in the handle and proxy
backends. -----BEGIN PGP SIGNATURE----- iEYEABECAAYFAlg1kVUACgkQAvw66wEB28IIzACfXKtN7ut2ZiakDKHH182CadeO PoMAni7ivvO1KGqO9osvwiEeY2KPIkED =ZAcB -----END PGP SIGNATURE----- Merge remote-tracking branch 'gkurz/tags/for-upstream' into staging This pull request fixes some leaks (memory, fd) in the handle and proxy backends. # gpg: Signature made Wed 23 Nov 2016 12:53:41 PM GMT # gpg: using DSA key 0x02FC3AEB0101DBC2 # gpg: Good signature from "Greg Kurz <groug@kaod.org>" # gpg: aka "Greg Kurz <groug@free.fr>" # gpg: aka "Greg Kurz <gkurz@fr.ibm.com>" # gpg: aka "Greg Kurz <gkurz@linux.vnet.ibm.com>" # gpg: aka "Gregory Kurz (Groug) <groug@free.fr>" # gpg: aka "Gregory Kurz (Cimai Technology) <gkurz@cimai.com>" # gpg: aka "Gregory Kurz (Meiosys Technology) <gkurz@meiosys.com>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 2BD4 3B44 535E C0A7 9894 DBA2 02FC 3AEB 0101 DBC2 * gkurz/tags/for-upstream: 9pfs: add cleanup operation for proxy backend driver 9pfs: add cleanup operation for handle backend driver 9pfs: add cleanup operation in FileOperations 9pfs: adjust the order of resource cleanup in device unrealize Message-id: 1479920298-24983-1-git-send-email-groug@kaod.org Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
commit
0fecd0292c
|
@ -100,6 +100,7 @@ struct FileOperations
|
||||||
{
|
{
|
||||||
int (*parse_opts)(QemuOpts *, struct FsDriverEntry *);
|
int (*parse_opts)(QemuOpts *, struct FsDriverEntry *);
|
||||||
int (*init)(struct FsContext *);
|
int (*init)(struct FsContext *);
|
||||||
|
void (*cleanup)(struct FsContext *);
|
||||||
int (*lstat)(FsContext *, V9fsPath *, struct stat *);
|
int (*lstat)(FsContext *, V9fsPath *, struct stat *);
|
||||||
ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t);
|
ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t);
|
||||||
int (*chmod)(FsContext *, V9fsPath *, FsCred *);
|
int (*chmod)(FsContext *, V9fsPath *, FsCred *);
|
||||||
|
|
|
@ -649,6 +649,14 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_cleanup(FsContext *ctx)
|
||||||
|
{
|
||||||
|
struct handle_data *data = ctx->private;
|
||||||
|
|
||||||
|
close(data->mountfd);
|
||||||
|
g_free(data);
|
||||||
|
}
|
||||||
|
|
||||||
static int handle_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse)
|
static int handle_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse)
|
||||||
{
|
{
|
||||||
const char *sec_model = qemu_opt_get(opts, "security_model");
|
const char *sec_model = qemu_opt_get(opts, "security_model");
|
||||||
|
@ -671,6 +679,7 @@ static int handle_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse)
|
||||||
FileOperations handle_ops = {
|
FileOperations handle_ops = {
|
||||||
.parse_opts = handle_parse_opts,
|
.parse_opts = handle_parse_opts,
|
||||||
.init = handle_init,
|
.init = handle_init,
|
||||||
|
.cleanup = handle_cleanup,
|
||||||
.lstat = handle_lstat,
|
.lstat = handle_lstat,
|
||||||
.readlink = handle_readlink,
|
.readlink = handle_readlink,
|
||||||
.close = handle_close,
|
.close = handle_close,
|
||||||
|
|
|
@ -1168,9 +1168,22 @@ static int proxy_init(FsContext *ctx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void proxy_cleanup(FsContext *ctx)
|
||||||
|
{
|
||||||
|
V9fsProxy *proxy = ctx->private;
|
||||||
|
|
||||||
|
g_free(proxy->out_iovec.iov_base);
|
||||||
|
g_free(proxy->in_iovec.iov_base);
|
||||||
|
if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) {
|
||||||
|
close(proxy->sockfd);
|
||||||
|
}
|
||||||
|
g_free(proxy);
|
||||||
|
}
|
||||||
|
|
||||||
FileOperations proxy_ops = {
|
FileOperations proxy_ops = {
|
||||||
.parse_opts = proxy_parse_opts,
|
.parse_opts = proxy_parse_opts,
|
||||||
.init = proxy_init,
|
.init = proxy_init,
|
||||||
|
.cleanup = proxy_cleanup,
|
||||||
.lstat = proxy_lstat,
|
.lstat = proxy_lstat,
|
||||||
.readlink = proxy_readlink,
|
.readlink = proxy_readlink,
|
||||||
.close = proxy_close,
|
.close = proxy_close,
|
||||||
|
|
10
hw/9pfs/9p.c
10
hw/9pfs/9p.c
|
@ -3521,8 +3521,11 @@ int v9fs_device_realize_common(V9fsState *s, Error **errp)
|
||||||
rc = 0;
|
rc = 0;
|
||||||
out:
|
out:
|
||||||
if (rc) {
|
if (rc) {
|
||||||
g_free(s->ctx.fs_root);
|
if (s->ops->cleanup && s->ctx.private) {
|
||||||
|
s->ops->cleanup(&s->ctx);
|
||||||
|
}
|
||||||
g_free(s->tag);
|
g_free(s->tag);
|
||||||
|
g_free(s->ctx.fs_root);
|
||||||
v9fs_path_free(&path);
|
v9fs_path_free(&path);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -3530,8 +3533,11 @@ out:
|
||||||
|
|
||||||
void v9fs_device_unrealize_common(V9fsState *s, Error **errp)
|
void v9fs_device_unrealize_common(V9fsState *s, Error **errp)
|
||||||
{
|
{
|
||||||
g_free(s->ctx.fs_root);
|
if (s->ops->cleanup) {
|
||||||
|
s->ops->cleanup(&s->ctx);
|
||||||
|
}
|
||||||
g_free(s->tag);
|
g_free(s->tag);
|
||||||
|
g_free(s->ctx.fs_root);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct VirtfsCoResetData {
|
typedef struct VirtfsCoResetData {
|
||||||
|
|
Loading…
Reference in New Issue