This pull request contains:
- a patch to add a vdc->reset() handler to virtio-9p - a bunch of patches to fix various memory leaks (thanks to Li Qiang) - some code cleanups for 9pfs -----BEGIN PGP SIGNATURE----- iEYEABECAAYFAlgE59oACgkQAvw66wEB28IrzgCePLq8RVQHvxJKcx9CO1XQaXCE Dp4AoJm+CDVuaBd+cojoUmwGaLmZG8lb =8nIw -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/gkurz/tags/for-upstream' into staging This pull request contains: - a patch to add a vdc->reset() handler to virtio-9p - a bunch of patches to fix various memory leaks (thanks to Li Qiang) - some code cleanups for 9pfs # gpg: Signature made Mon 17 Oct 2016 16:01:46 BST # 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 * remotes/gkurz/tags/for-upstream: 9pfs: fix memory leak in v9fs_write 9pfs: fix memory leak in v9fs_link 9pfs: fix memory leak in v9fs_xattrcreate 9pfs: fix information leak in xattr read virtio-9p: add reset handler 9pfs: only free completed request if not flushed 9pfs: drop useless check in pdu_free() 9pfs: use coroutine_fn annotation in hw/9pfs/9p.[ch] 9pfs: use coroutine_fn annotation in hw/9pfs/co*.[ch] 9pfs: fsdev: drop useless extern annotation for functions 9pfs: fix potential host memory leak in v9fs_read 9pfs: allocate space for guest originated empty strings Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
		
						commit
						0975b8b823
					
				@ -125,7 +125,7 @@ ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int out_num, size_t offset,
 | 
				
			|||||||
                str->data = g_malloc(str->size + 1);
 | 
					                str->data = g_malloc(str->size + 1);
 | 
				
			||||||
                copied = v9fs_unpack(str->data, out_sg, out_num, offset,
 | 
					                copied = v9fs_unpack(str->data, out_sg, out_num, offset,
 | 
				
			||||||
                                     str->size);
 | 
					                                     str->size);
 | 
				
			||||||
                if (copied > 0) {
 | 
					                if (copied >= 0) {
 | 
				
			||||||
                    str->data[str->size] = 0;
 | 
					                    str->data[str->size] = 0;
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    v9fs_string_free(str);
 | 
					                    v9fs_string_free(str);
 | 
				
			||||||
 | 
				
			|||||||
@ -76,8 +76,8 @@ static inline void v9fs_string_init(V9fsString *str)
 | 
				
			|||||||
    str->data = NULL;
 | 
					    str->data = NULL;
 | 
				
			||||||
    str->size = 0;
 | 
					    str->size = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
extern void v9fs_string_free(V9fsString *str);
 | 
					void v9fs_string_free(V9fsString *str);
 | 
				
			||||||
extern void v9fs_string_sprintf(V9fsString *str, const char *fmt, ...);
 | 
					void v9fs_string_sprintf(V9fsString *str, const char *fmt, ...);
 | 
				
			||||||
extern void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs);
 | 
					void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -43,9 +43,9 @@ typedef struct V9fsSynthOpenState {
 | 
				
			|||||||
    struct dirent dent;
 | 
					    struct dirent dent;
 | 
				
			||||||
} V9fsSynthOpenState;
 | 
					} V9fsSynthOpenState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,
 | 
					int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,
 | 
				
			||||||
                          const char *name, V9fsSynthNode **result);
 | 
					                          const char *name, V9fsSynthNode **result);
 | 
				
			||||||
extern int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
 | 
					int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
 | 
				
			||||||
                             const char *name, v9fs_synth_read read,
 | 
					                             const char *name, v9fs_synth_read read,
 | 
				
			||||||
                             v9fs_synth_write write, void *arg);
 | 
					                             v9fs_synth_write write, void *arg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										166
									
								
								hw/9pfs/9p.c
									
									
									
									
									
								
							
							
						
						
									
										166
									
								
								hw/9pfs/9p.c
									
									
									
									
									
								
							@ -236,7 +236,7 @@ static size_t v9fs_string_size(V9fsString *str)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * returns 0 if fid got re-opened, 1 if not, < 0 on error */
 | 
					 * returns 0 if fid got re-opened, 1 if not, < 0 on error */
 | 
				
			||||||
static int v9fs_reopen_fid(V9fsPDU *pdu, V9fsFidState *f)
 | 
					static int coroutine_fn v9fs_reopen_fid(V9fsPDU *pdu, V9fsFidState *f)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err = 1;
 | 
					    int err = 1;
 | 
				
			||||||
    if (f->fid_type == P9_FID_FILE) {
 | 
					    if (f->fid_type == P9_FID_FILE) {
 | 
				
			||||||
@ -255,7 +255,7 @@ static int v9fs_reopen_fid(V9fsPDU *pdu, V9fsFidState *f)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static V9fsFidState *get_fid(V9fsPDU *pdu, int32_t fid)
 | 
					static V9fsFidState *coroutine_fn get_fid(V9fsPDU *pdu, int32_t fid)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsFidState *f;
 | 
					    V9fsFidState *f;
 | 
				
			||||||
@ -321,7 +321,7 @@ static V9fsFidState *alloc_fid(V9fsState *s, int32_t fid)
 | 
				
			|||||||
    return f;
 | 
					    return f;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int v9fs_xattr_fid_clunk(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
					static int coroutine_fn v9fs_xattr_fid_clunk(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int retval = 0;
 | 
					    int retval = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -353,7 +353,7 @@ free_value:
 | 
				
			|||||||
    return retval;
 | 
					    return retval;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int free_fid(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
					static int coroutine_fn free_fid(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int retval = 0;
 | 
					    int retval = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -374,7 +374,7 @@ static int free_fid(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
				
			|||||||
    return retval;
 | 
					    return retval;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int put_fid(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
					static int coroutine_fn put_fid(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    BUG_ON(!fidp->ref);
 | 
					    BUG_ON(!fidp->ref);
 | 
				
			||||||
    fidp->ref--;
 | 
					    fidp->ref--;
 | 
				
			||||||
@ -418,7 +418,7 @@ static V9fsFidState *clunk_fid(V9fsState *s, int32_t fid)
 | 
				
			|||||||
    return fidp;
 | 
					    return fidp;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void v9fs_reclaim_fd(V9fsPDU *pdu)
 | 
					void coroutine_fn v9fs_reclaim_fd(V9fsPDU *pdu)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int reclaim_count = 0;
 | 
					    int reclaim_count = 0;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -499,7 +499,7 @@ void v9fs_reclaim_fd(V9fsPDU *pdu)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int v9fs_mark_fids_unreclaim(V9fsPDU *pdu, V9fsPath *path)
 | 
					static int coroutine_fn v9fs_mark_fids_unreclaim(V9fsPDU *pdu, V9fsPath *path)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -532,7 +532,7 @@ static int v9fs_mark_fids_unreclaim(V9fsPDU *pdu, V9fsPath *path)
 | 
				
			|||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void virtfs_reset(V9fsPDU *pdu)
 | 
					static void coroutine_fn virtfs_reset(V9fsPDU *pdu)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
    V9fsFidState *fidp = NULL;
 | 
					    V9fsFidState *fidp = NULL;
 | 
				
			||||||
@ -598,7 +598,8 @@ static void stat_to_qid(const struct stat *stbuf, V9fsQID *qidp)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int fid_to_qid(V9fsPDU *pdu, V9fsFidState *fidp, V9fsQID *qidp)
 | 
					static int coroutine_fn fid_to_qid(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
				
			||||||
 | 
					                                   V9fsQID *qidp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    struct stat stbuf;
 | 
					    struct stat stbuf;
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
@ -625,17 +626,11 @@ V9fsPDU *pdu_alloc(V9fsState *s)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void pdu_free(V9fsPDU *pdu)
 | 
					void pdu_free(V9fsPDU *pdu)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (pdu) {
 | 
					 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
        /*
 | 
					
 | 
				
			||||||
         * Cancelled pdu are added back to the freelist
 | 
					    g_assert(!pdu->cancelled);
 | 
				
			||||||
         * by flush request .
 | 
					 | 
				
			||||||
         */
 | 
					 | 
				
			||||||
        if (!pdu->cancelled) {
 | 
					 | 
				
			||||||
    QLIST_REMOVE(pdu, next);
 | 
					    QLIST_REMOVE(pdu, next);
 | 
				
			||||||
    QLIST_INSERT_HEAD(&s->free_list, pdu, next);
 | 
					    QLIST_INSERT_HEAD(&s->free_list, pdu, next);
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
@ -643,7 +638,7 @@ void pdu_free(V9fsPDU *pdu)
 | 
				
			|||||||
 * because we always expect to have enough space to encode
 | 
					 * because we always expect to have enough space to encode
 | 
				
			||||||
 * error details
 | 
					 * error details
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void pdu_complete(V9fsPDU *pdu, ssize_t len)
 | 
					static void coroutine_fn pdu_complete(V9fsPDU *pdu, ssize_t len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int8_t id = pdu->id + 1; /* Response */
 | 
					    int8_t id = pdu->id + 1; /* Response */
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -680,9 +675,9 @@ static void pdu_complete(V9fsPDU *pdu, ssize_t len)
 | 
				
			|||||||
    pdu_push_and_notify(pdu);
 | 
					    pdu_push_and_notify(pdu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Now wakeup anybody waiting in flush for this request */
 | 
					    /* Now wakeup anybody waiting in flush for this request */
 | 
				
			||||||
    qemu_co_queue_next(&pdu->complete);
 | 
					    if (!qemu_co_queue_next(&pdu->complete)) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        pdu_free(pdu);
 | 
					        pdu_free(pdu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static mode_t v9mode_to_mode(uint32_t mode, V9fsString *extension)
 | 
					static mode_t v9mode_to_mode(uint32_t mode, V9fsString *extension)
 | 
				
			||||||
@ -810,7 +805,7 @@ static uint32_t stat_to_v9mode(const struct stat *stbuf)
 | 
				
			|||||||
    return mode;
 | 
					    return mode;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int stat_to_v9stat(V9fsPDU *pdu, V9fsPath *name,
 | 
					static int coroutine_fn stat_to_v9stat(V9fsPDU *pdu, V9fsPath *name,
 | 
				
			||||||
                                       const struct stat *stbuf,
 | 
					                                       const struct stat *stbuf,
 | 
				
			||||||
                                       V9fsStat *v9stat)
 | 
					                                       V9fsStat *v9stat)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -941,7 +936,7 @@ static inline bool is_ro_export(FsContext *ctx)
 | 
				
			|||||||
    return ctx->export_flags & V9FS_RDONLY;
 | 
					    return ctx->export_flags & V9FS_RDONLY;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_version(void *opaque)
 | 
					static void coroutine_fn v9fs_version(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ssize_t err;
 | 
					    ssize_t err;
 | 
				
			||||||
    V9fsPDU *pdu = opaque;
 | 
					    V9fsPDU *pdu = opaque;
 | 
				
			||||||
@ -979,7 +974,7 @@ out:
 | 
				
			|||||||
    v9fs_string_free(&version);
 | 
					    v9fs_string_free(&version);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_attach(void *opaque)
 | 
					static void coroutine_fn v9fs_attach(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    V9fsPDU *pdu = opaque;
 | 
					    V9fsPDU *pdu = opaque;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -1045,7 +1040,7 @@ out_nofid:
 | 
				
			|||||||
    v9fs_string_free(&aname);
 | 
					    v9fs_string_free(&aname);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_stat(void *opaque)
 | 
					static void coroutine_fn v9fs_stat(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
    V9fsStat v9stat;
 | 
					    V9fsStat v9stat;
 | 
				
			||||||
@ -1089,7 +1084,7 @@ out_nofid:
 | 
				
			|||||||
    pdu_complete(pdu, err);
 | 
					    pdu_complete(pdu, err);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_getattr(void *opaque)
 | 
					static void coroutine_fn v9fs_getattr(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
    size_t offset = 7;
 | 
					    size_t offset = 7;
 | 
				
			||||||
@ -1165,7 +1160,7 @@ out_nofid:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define P9_ATTR_MASK    127
 | 
					#define P9_ATTR_MASK    127
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_setattr(void *opaque)
 | 
					static void coroutine_fn v9fs_setattr(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err = 0;
 | 
					    int err = 0;
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
@ -1283,7 +1278,7 @@ static bool not_same_qid(const V9fsQID *qid1, const V9fsQID *qid2)
 | 
				
			|||||||
        qid1->path != qid2->path;
 | 
					        qid1->path != qid2->path;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_walk(void *opaque)
 | 
					static void coroutine_fn v9fs_walk(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int name_idx;
 | 
					    int name_idx;
 | 
				
			||||||
    V9fsQID *qids = NULL;
 | 
					    V9fsQID *qids = NULL;
 | 
				
			||||||
@ -1397,7 +1392,7 @@ out_nofid:
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int32_t get_iounit(V9fsPDU *pdu, V9fsPath *path)
 | 
					static int32_t coroutine_fn get_iounit(V9fsPDU *pdu, V9fsPath *path)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    struct statfs stbuf;
 | 
					    struct statfs stbuf;
 | 
				
			||||||
    int32_t iounit = 0;
 | 
					    int32_t iounit = 0;
 | 
				
			||||||
@ -1417,7 +1412,7 @@ static int32_t get_iounit(V9fsPDU *pdu, V9fsPath *path)
 | 
				
			|||||||
    return iounit;
 | 
					    return iounit;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_open(void *opaque)
 | 
					static void coroutine_fn v9fs_open(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int flags;
 | 
					    int flags;
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
@ -1507,7 +1502,7 @@ out_nofid:
 | 
				
			|||||||
    pdu_complete(pdu, err);
 | 
					    pdu_complete(pdu, err);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_lcreate(void *opaque)
 | 
					static void coroutine_fn v9fs_lcreate(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int32_t dfid, flags, mode;
 | 
					    int32_t dfid, flags, mode;
 | 
				
			||||||
    gid_t gid;
 | 
					    gid_t gid;
 | 
				
			||||||
@ -1604,7 +1599,7 @@ out_nofid:
 | 
				
			|||||||
    pdu_complete(pdu, err);
 | 
					    pdu_complete(pdu, err);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_clunk(void *opaque)
 | 
					static void coroutine_fn v9fs_clunk(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
@ -1673,8 +1668,9 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
 | 
				
			|||||||
    return offset;
 | 
					    return offset;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int v9fs_do_readdir_with_stat(V9fsPDU *pdu,
 | 
					static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu,
 | 
				
			||||||
                                     V9fsFidState *fidp, uint32_t max_count)
 | 
					                                                  V9fsFidState *fidp,
 | 
				
			||||||
 | 
					                                                  uint32_t max_count)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    V9fsPath path;
 | 
					    V9fsPath path;
 | 
				
			||||||
    V9fsStat v9stat;
 | 
					    V9fsStat v9stat;
 | 
				
			||||||
@ -1764,7 +1760,7 @@ static void v9fs_init_qiov_from_pdu(QEMUIOVector *qiov, V9fsPDU *pdu,
 | 
				
			|||||||
    qemu_iovec_concat(qiov, &elem, skip, size);
 | 
					    qemu_iovec_concat(qiov, &elem, skip, size);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_read(void *opaque)
 | 
					static void coroutine_fn v9fs_read(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
    uint64_t off;
 | 
					    uint64_t off;
 | 
				
			||||||
@ -1826,14 +1822,15 @@ static void v9fs_read(void *opaque)
 | 
				
			|||||||
            if (len < 0) {
 | 
					            if (len < 0) {
 | 
				
			||||||
                /* IO error return the error */
 | 
					                /* IO error return the error */
 | 
				
			||||||
                err = len;
 | 
					                err = len;
 | 
				
			||||||
                goto out;
 | 
					                goto out_free_iovec;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } while (count < max_count && len > 0);
 | 
					        } while (count < max_count && len > 0);
 | 
				
			||||||
        err = pdu_marshal(pdu, offset, "d", count);
 | 
					        err = pdu_marshal(pdu, offset, "d", count);
 | 
				
			||||||
        if (err < 0) {
 | 
					        if (err < 0) {
 | 
				
			||||||
            goto out;
 | 
					            goto out_free_iovec;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        err += offset + count;
 | 
					        err += offset + count;
 | 
				
			||||||
 | 
					out_free_iovec:
 | 
				
			||||||
        qemu_iovec_destroy(&qiov);
 | 
					        qemu_iovec_destroy(&qiov);
 | 
				
			||||||
        qemu_iovec_destroy(&qiov_full);
 | 
					        qemu_iovec_destroy(&qiov_full);
 | 
				
			||||||
    } else if (fidp->fid_type == P9_FID_XATTR) {
 | 
					    } else if (fidp->fid_type == P9_FID_XATTR) {
 | 
				
			||||||
@ -1857,8 +1854,8 @@ static size_t v9fs_readdir_data_size(V9fsString *name)
 | 
				
			|||||||
    return 24 + v9fs_string_size(name);
 | 
					    return 24 + v9fs_string_size(name);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int v9fs_do_readdir(V9fsPDU *pdu,
 | 
					static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
				
			||||||
                           V9fsFidState *fidp, int32_t max_count)
 | 
					                                        int32_t max_count)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    size_t size;
 | 
					    size_t size;
 | 
				
			||||||
    V9fsQID qid;
 | 
					    V9fsQID qid;
 | 
				
			||||||
@ -1927,7 +1924,7 @@ static int v9fs_do_readdir(V9fsPDU *pdu,
 | 
				
			|||||||
    return count;
 | 
					    return count;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_readdir(void *opaque)
 | 
					static void coroutine_fn v9fs_readdir(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
    V9fsFidState *fidp;
 | 
					    V9fsFidState *fidp;
 | 
				
			||||||
@ -2023,7 +2020,7 @@ out:
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_write(void *opaque)
 | 
					static void coroutine_fn v9fs_write(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ssize_t err;
 | 
					    ssize_t err;
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
@ -2093,7 +2090,7 @@ static void v9fs_write(void *opaque)
 | 
				
			|||||||
    offset = 7;
 | 
					    offset = 7;
 | 
				
			||||||
    err = pdu_marshal(pdu, offset, "d", total);
 | 
					    err = pdu_marshal(pdu, offset, "d", total);
 | 
				
			||||||
    if (err < 0) {
 | 
					    if (err < 0) {
 | 
				
			||||||
        goto out;
 | 
					        goto out_qiov;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    err += offset;
 | 
					    err += offset;
 | 
				
			||||||
    trace_v9fs_write_return(pdu->tag, pdu->id, total, err);
 | 
					    trace_v9fs_write_return(pdu->tag, pdu->id, total, err);
 | 
				
			||||||
@ -2106,7 +2103,7 @@ out_nofid:
 | 
				
			|||||||
    pdu_complete(pdu, err);
 | 
					    pdu_complete(pdu, err);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_create(void *opaque)
 | 
					static void coroutine_fn v9fs_create(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
    int err = 0;
 | 
					    int err = 0;
 | 
				
			||||||
@ -2286,7 +2283,7 @@ out_nofid:
 | 
				
			|||||||
   v9fs_path_free(&path);
 | 
					   v9fs_path_free(&path);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_symlink(void *opaque)
 | 
					static void coroutine_fn v9fs_symlink(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    V9fsPDU *pdu = opaque;
 | 
					    V9fsPDU *pdu = opaque;
 | 
				
			||||||
    V9fsString name;
 | 
					    V9fsString name;
 | 
				
			||||||
@ -2375,7 +2372,7 @@ static void v9fs_flush(void *opaque)
 | 
				
			|||||||
    pdu_complete(pdu, 7);
 | 
					    pdu_complete(pdu, 7);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_link(void *opaque)
 | 
					static void coroutine_fn v9fs_link(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    V9fsPDU *pdu = opaque;
 | 
					    V9fsPDU *pdu = opaque;
 | 
				
			||||||
    int32_t dfid, oldfid;
 | 
					    int32_t dfid, oldfid;
 | 
				
			||||||
@ -2416,6 +2413,7 @@ static void v9fs_link(void *opaque)
 | 
				
			|||||||
    if (!err) {
 | 
					    if (!err) {
 | 
				
			||||||
        err = offset;
 | 
					        err = offset;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    put_fid(pdu, oldfidp);
 | 
				
			||||||
out:
 | 
					out:
 | 
				
			||||||
    put_fid(pdu, dfidp);
 | 
					    put_fid(pdu, dfidp);
 | 
				
			||||||
out_nofid:
 | 
					out_nofid:
 | 
				
			||||||
@ -2424,7 +2422,7 @@ out_nofid:
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Only works with path name based fid */
 | 
					/* Only works with path name based fid */
 | 
				
			||||||
static void v9fs_remove(void *opaque)
 | 
					static void coroutine_fn v9fs_remove(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
    int err = 0;
 | 
					    int err = 0;
 | 
				
			||||||
@ -2468,7 +2466,7 @@ out_nofid:
 | 
				
			|||||||
    pdu_complete(pdu, err);
 | 
					    pdu_complete(pdu, err);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_unlinkat(void *opaque)
 | 
					static void coroutine_fn v9fs_unlinkat(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err = 0;
 | 
					    int err = 0;
 | 
				
			||||||
    V9fsString name;
 | 
					    V9fsString name;
 | 
				
			||||||
@ -2531,8 +2529,9 @@ out_nofid:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Only works with path name based fid */
 | 
					/* Only works with path name based fid */
 | 
				
			||||||
static int v9fs_complete_rename(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
					static int coroutine_fn v9fs_complete_rename(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
				
			||||||
                                int32_t newdirfid, V9fsString *name)
 | 
					                                             int32_t newdirfid,
 | 
				
			||||||
 | 
					                                             V9fsString *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    char *end;
 | 
					    char *end;
 | 
				
			||||||
    int err = 0;
 | 
					    int err = 0;
 | 
				
			||||||
@ -2589,7 +2588,7 @@ out_nofid:
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Only works with path name based fid */
 | 
					/* Only works with path name based fid */
 | 
				
			||||||
static void v9fs_rename(void *opaque)
 | 
					static void coroutine_fn v9fs_rename(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
    ssize_t err = 0;
 | 
					    ssize_t err = 0;
 | 
				
			||||||
@ -2640,8 +2639,9 @@ out_nofid:
 | 
				
			|||||||
    v9fs_string_free(&name);
 | 
					    v9fs_string_free(&name);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_fix_fid_paths(V9fsPDU *pdu, V9fsPath *olddir,
 | 
					static void coroutine_fn v9fs_fix_fid_paths(V9fsPDU *pdu, V9fsPath *olddir,
 | 
				
			||||||
                               V9fsString *old_name, V9fsPath *newdir,
 | 
					                                            V9fsString *old_name,
 | 
				
			||||||
 | 
					                                            V9fsPath *newdir,
 | 
				
			||||||
                                            V9fsString *new_name)
 | 
					                                            V9fsString *new_name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    V9fsFidState *tfidp;
 | 
					    V9fsFidState *tfidp;
 | 
				
			||||||
@ -2668,8 +2668,9 @@ static void v9fs_fix_fid_paths(V9fsPDU *pdu, V9fsPath *olddir,
 | 
				
			|||||||
    v9fs_path_free(&newpath);
 | 
					    v9fs_path_free(&newpath);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int v9fs_complete_renameat(V9fsPDU *pdu, int32_t olddirfid,
 | 
					static int coroutine_fn v9fs_complete_renameat(V9fsPDU *pdu, int32_t olddirfid,
 | 
				
			||||||
                                  V9fsString *old_name, int32_t newdirfid,
 | 
					                                               V9fsString *old_name,
 | 
				
			||||||
 | 
					                                               int32_t newdirfid,
 | 
				
			||||||
                                               V9fsString *new_name)
 | 
					                                               V9fsString *new_name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err = 0;
 | 
					    int err = 0;
 | 
				
			||||||
@ -2711,7 +2712,7 @@ out:
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_renameat(void *opaque)
 | 
					static void coroutine_fn v9fs_renameat(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ssize_t err = 0;
 | 
					    ssize_t err = 0;
 | 
				
			||||||
    size_t offset = 7;
 | 
					    size_t offset = 7;
 | 
				
			||||||
@ -2753,7 +2754,7 @@ out_err:
 | 
				
			|||||||
    v9fs_string_free(&new_name);
 | 
					    v9fs_string_free(&new_name);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_wstat(void *opaque)
 | 
					static void coroutine_fn v9fs_wstat(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
    int err = 0;
 | 
					    int err = 0;
 | 
				
			||||||
@ -2892,7 +2893,7 @@ static int v9fs_fill_statfs(V9fsState *s, V9fsPDU *pdu, struct statfs *stbuf)
 | 
				
			|||||||
                       fsid_val, f_namelen);
 | 
					                       fsid_val, f_namelen);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_statfs(void *opaque)
 | 
					static void coroutine_fn v9fs_statfs(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
    ssize_t retval = 0;
 | 
					    ssize_t retval = 0;
 | 
				
			||||||
@ -2926,7 +2927,7 @@ out_nofid:
 | 
				
			|||||||
    pdu_complete(pdu, retval);
 | 
					    pdu_complete(pdu, retval);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_mknod(void *opaque)
 | 
					static void coroutine_fn v9fs_mknod(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int mode;
 | 
					    int mode;
 | 
				
			||||||
@ -2992,7 +2993,7 @@ out_nofid:
 | 
				
			|||||||
 * do any thing in * qemu 9p server side lock code path.
 | 
					 * do any thing in * qemu 9p server side lock code path.
 | 
				
			||||||
 * So when a TLOCK request comes, always return success
 | 
					 * So when a TLOCK request comes, always return success
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void v9fs_lock(void *opaque)
 | 
					static void coroutine_fn v9fs_lock(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int8_t status;
 | 
					    int8_t status;
 | 
				
			||||||
    V9fsFlock flock;
 | 
					    V9fsFlock flock;
 | 
				
			||||||
@ -3045,7 +3046,7 @@ out_nofid:
 | 
				
			|||||||
 * When a TGETLOCK request comes, always return success because all lock
 | 
					 * When a TGETLOCK request comes, always return success because all lock
 | 
				
			||||||
 * handling is done by client's VFS layer.
 | 
					 * handling is done by client's VFS layer.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void v9fs_getlock(void *opaque)
 | 
					static void coroutine_fn v9fs_getlock(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    size_t offset = 7;
 | 
					    size_t offset = 7;
 | 
				
			||||||
    struct stat stbuf;
 | 
					    struct stat stbuf;
 | 
				
			||||||
@ -3090,7 +3091,7 @@ out_nofid:
 | 
				
			|||||||
    v9fs_string_free(&glock.client_id);
 | 
					    v9fs_string_free(&glock.client_id);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_mkdir(void *opaque)
 | 
					static void coroutine_fn v9fs_mkdir(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    V9fsPDU *pdu = opaque;
 | 
					    V9fsPDU *pdu = opaque;
 | 
				
			||||||
    size_t offset = 7;
 | 
					    size_t offset = 7;
 | 
				
			||||||
@ -3144,7 +3145,7 @@ out_nofid:
 | 
				
			|||||||
    v9fs_string_free(&name);
 | 
					    v9fs_string_free(&name);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_xattrwalk(void *opaque)
 | 
					static void coroutine_fn v9fs_xattrwalk(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int64_t size;
 | 
					    int64_t size;
 | 
				
			||||||
    V9fsString name;
 | 
					    V9fsString name;
 | 
				
			||||||
@ -3174,7 +3175,7 @@ static void v9fs_xattrwalk(void *opaque)
 | 
				
			|||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    v9fs_path_copy(&xattr_fidp->path, &file_fidp->path);
 | 
					    v9fs_path_copy(&xattr_fidp->path, &file_fidp->path);
 | 
				
			||||||
    if (name.data == NULL) {
 | 
					    if (!v9fs_string_size(&name)) {
 | 
				
			||||||
        /*
 | 
					        /*
 | 
				
			||||||
         * listxattr request. Get the size first
 | 
					         * listxattr request. Get the size first
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
@ -3250,7 +3251,7 @@ out_nofid:
 | 
				
			|||||||
    v9fs_string_free(&name);
 | 
					    v9fs_string_free(&name);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_xattrcreate(void *opaque)
 | 
					static void coroutine_fn v9fs_xattrcreate(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int flags;
 | 
					    int flags;
 | 
				
			||||||
    int32_t fid;
 | 
					    int32_t fid;
 | 
				
			||||||
@ -3282,7 +3283,8 @@ static void v9fs_xattrcreate(void *opaque)
 | 
				
			|||||||
    xattr_fidp->fs.xattr.flags = flags;
 | 
					    xattr_fidp->fs.xattr.flags = flags;
 | 
				
			||||||
    v9fs_string_init(&xattr_fidp->fs.xattr.name);
 | 
					    v9fs_string_init(&xattr_fidp->fs.xattr.name);
 | 
				
			||||||
    v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name);
 | 
					    v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name);
 | 
				
			||||||
    xattr_fidp->fs.xattr.value = g_malloc(size);
 | 
					    g_free(xattr_fidp->fs.xattr.value);
 | 
				
			||||||
 | 
					    xattr_fidp->fs.xattr.value = g_malloc0(size);
 | 
				
			||||||
    err = offset;
 | 
					    err = offset;
 | 
				
			||||||
    put_fid(pdu, file_fidp);
 | 
					    put_fid(pdu, file_fidp);
 | 
				
			||||||
out_nofid:
 | 
					out_nofid:
 | 
				
			||||||
@ -3290,7 +3292,7 @@ out_nofid:
 | 
				
			|||||||
    v9fs_string_free(&name);
 | 
					    v9fs_string_free(&name);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_readlink(void *opaque)
 | 
					static void coroutine_fn v9fs_readlink(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    V9fsPDU *pdu = opaque;
 | 
					    V9fsPDU *pdu = opaque;
 | 
				
			||||||
    size_t offset = 7;
 | 
					    size_t offset = 7;
 | 
				
			||||||
@ -3366,13 +3368,13 @@ static CoroutineEntry *pdu_co_handlers[] = {
 | 
				
			|||||||
    [P9_TREMOVE] = v9fs_remove,
 | 
					    [P9_TREMOVE] = v9fs_remove,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_op_not_supp(void *opaque)
 | 
					static void coroutine_fn v9fs_op_not_supp(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    V9fsPDU *pdu = opaque;
 | 
					    V9fsPDU *pdu = opaque;
 | 
				
			||||||
    pdu_complete(pdu, -EOPNOTSUPP);
 | 
					    pdu_complete(pdu, -EOPNOTSUPP);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void v9fs_fs_ro(void *opaque)
 | 
					static void coroutine_fn v9fs_fs_ro(void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    V9fsPDU *pdu = opaque;
 | 
					    V9fsPDU *pdu = opaque;
 | 
				
			||||||
    pdu_complete(pdu, -EROFS);
 | 
					    pdu_complete(pdu, -EROFS);
 | 
				
			||||||
@ -3522,6 +3524,36 @@ void v9fs_device_unrealize_common(V9fsState *s, Error **errp)
 | 
				
			|||||||
    g_free(s->tag);
 | 
					    g_free(s->tag);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct VirtfsCoResetData {
 | 
				
			||||||
 | 
					    V9fsPDU pdu;
 | 
				
			||||||
 | 
					    bool done;
 | 
				
			||||||
 | 
					} VirtfsCoResetData;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void coroutine_fn virtfs_co_reset(void *opaque)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    VirtfsCoResetData *data = opaque;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    virtfs_reset(&data->pdu);
 | 
				
			||||||
 | 
					    data->done = true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void v9fs_reset(V9fsState *s)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    VirtfsCoResetData data = { .pdu = { .s = s }, .done = false };
 | 
				
			||||||
 | 
					    Coroutine *co;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    while (!QLIST_EMPTY(&s->active_list)) {
 | 
				
			||||||
 | 
					        aio_poll(qemu_get_aio_context(), true);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    co = qemu_coroutine_create(virtfs_co_reset, &data);
 | 
				
			||||||
 | 
					    qemu_coroutine_enter(co);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    while (!data.done) {
 | 
				
			||||||
 | 
					        aio_poll(qemu_get_aio_context(), true);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void __attribute__((__constructor__)) v9fs_set_fd_limit(void)
 | 
					static void __attribute__((__constructor__)) v9fs_set_fd_limit(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    struct rlimit rlim;
 | 
					    struct rlimit rlim;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										17
									
								
								hw/9pfs/9p.h
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								hw/9pfs/9p.h
									
									
									
									
									
								
							@ -324,20 +324,21 @@ static inline uint8_t v9fs_request_cancelled(V9fsPDU *pdu)
 | 
				
			|||||||
    return pdu->cancelled;
 | 
					    return pdu->cancelled;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void v9fs_reclaim_fd(V9fsPDU *pdu);
 | 
					void coroutine_fn v9fs_reclaim_fd(V9fsPDU *pdu);
 | 
				
			||||||
extern void v9fs_path_init(V9fsPath *path);
 | 
					void v9fs_path_init(V9fsPath *path);
 | 
				
			||||||
extern void v9fs_path_free(V9fsPath *path);
 | 
					void v9fs_path_free(V9fsPath *path);
 | 
				
			||||||
extern void v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...);
 | 
					void v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...);
 | 
				
			||||||
extern void v9fs_path_copy(V9fsPath *lhs, V9fsPath *rhs);
 | 
					void v9fs_path_copy(V9fsPath *lhs, V9fsPath *rhs);
 | 
				
			||||||
extern int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath,
 | 
					int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath,
 | 
				
			||||||
                      const char *name, V9fsPath *path);
 | 
					                      const char *name, V9fsPath *path);
 | 
				
			||||||
extern int v9fs_device_realize_common(V9fsState *s, Error **errp);
 | 
					int v9fs_device_realize_common(V9fsState *s, Error **errp);
 | 
				
			||||||
extern void v9fs_device_unrealize_common(V9fsState *s, Error **errp);
 | 
					void v9fs_device_unrealize_common(V9fsState *s, Error **errp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ssize_t pdu_marshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...);
 | 
					ssize_t pdu_marshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...);
 | 
				
			||||||
ssize_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...);
 | 
					ssize_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...);
 | 
				
			||||||
V9fsPDU *pdu_alloc(V9fsState *s);
 | 
					V9fsPDU *pdu_alloc(V9fsState *s);
 | 
				
			||||||
void pdu_free(V9fsPDU *pdu);
 | 
					void pdu_free(V9fsPDU *pdu);
 | 
				
			||||||
void pdu_submit(V9fsPDU *pdu);
 | 
					void pdu_submit(V9fsPDU *pdu);
 | 
				
			||||||
 | 
					void v9fs_reset(V9fsState *s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -17,7 +17,8 @@
 | 
				
			|||||||
#include "qemu/coroutine.h"
 | 
					#include "qemu/coroutine.h"
 | 
				
			||||||
#include "coth.h"
 | 
					#include "coth.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_readdir(V9fsPDU *pdu, V9fsFidState *fidp, struct dirent **dent)
 | 
					int coroutine_fn v9fs_co_readdir(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
				
			||||||
 | 
					                                 struct dirent **dent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -59,7 +60,8 @@ off_t v9fs_co_telldir(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void v9fs_co_seekdir(V9fsPDU *pdu, V9fsFidState *fidp, off_t offset)
 | 
					void coroutine_fn v9fs_co_seekdir(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
				
			||||||
 | 
					                                  off_t offset)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
    if (v9fs_request_cancelled(pdu)) {
 | 
					    if (v9fs_request_cancelled(pdu)) {
 | 
				
			||||||
@ -71,7 +73,7 @@ void v9fs_co_seekdir(V9fsPDU *pdu, V9fsFidState *fidp, off_t offset)
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void v9fs_co_rewinddir(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
					void coroutine_fn v9fs_co_rewinddir(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
    if (v9fs_request_cancelled(pdu)) {
 | 
					    if (v9fs_request_cancelled(pdu)) {
 | 
				
			||||||
@ -83,8 +85,9 @@ void v9fs_co_rewinddir(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_mkdir(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name,
 | 
					int coroutine_fn v9fs_co_mkdir(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
				
			||||||
                  mode_t mode, uid_t uid, gid_t gid, struct stat *stbuf)
 | 
					                               V9fsString *name, mode_t mode, uid_t uid,
 | 
				
			||||||
 | 
					                               gid_t gid, struct stat *stbuf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    FsCred cred;
 | 
					    FsCred cred;
 | 
				
			||||||
@ -120,7 +123,7 @@ int v9fs_co_mkdir(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name,
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_opendir(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
					int coroutine_fn v9fs_co_opendir(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -148,7 +151,7 @@ int v9fs_co_opendir(V9fsPDU *pdu, V9fsFidState *fidp)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_closedir(V9fsPDU *pdu, V9fsFidOpenState *fs)
 | 
					int coroutine_fn v9fs_co_closedir(V9fsPDU *pdu, V9fsFidOpenState *fs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
 | 
				
			|||||||
@ -17,7 +17,7 @@
 | 
				
			|||||||
#include "qemu/coroutine.h"
 | 
					#include "qemu/coroutine.h"
 | 
				
			||||||
#include "coth.h"
 | 
					#include "coth.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode,
 | 
					int coroutine_fn v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode,
 | 
				
			||||||
                                V9fsStatDotl *v9stat)
 | 
					                                V9fsStatDotl *v9stat)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err = 0;
 | 
					    int err = 0;
 | 
				
			||||||
@ -41,7 +41,7 @@ int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode,
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_lstat(V9fsPDU *pdu, V9fsPath *path, struct stat *stbuf)
 | 
					int coroutine_fn v9fs_co_lstat(V9fsPDU *pdu, V9fsPath *path, struct stat *stbuf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -61,7 +61,8 @@ int v9fs_co_lstat(V9fsPDU *pdu, V9fsPath *path, struct stat *stbuf)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_fstat(V9fsPDU *pdu, V9fsFidState *fidp, struct stat *stbuf)
 | 
					int coroutine_fn v9fs_co_fstat(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
				
			||||||
 | 
					                               struct stat *stbuf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -93,7 +94,7 @@ int v9fs_co_fstat(V9fsPDU *pdu, V9fsFidState *fidp, struct stat *stbuf)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_open(V9fsPDU *pdu, V9fsFidState *fidp, int flags)
 | 
					int coroutine_fn v9fs_co_open(V9fsPDU *pdu, V9fsFidState *fidp, int flags)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -121,8 +122,9 @@ int v9fs_co_open(V9fsPDU *pdu, V9fsFidState *fidp, int flags)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_open2(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name, gid_t gid,
 | 
					int coroutine_fn v9fs_co_open2(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
				
			||||||
                  int flags, int mode, struct stat *stbuf)
 | 
					                               V9fsString *name, gid_t gid, int flags, int mode,
 | 
				
			||||||
 | 
					                               struct stat *stbuf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    FsCred cred;
 | 
					    FsCred cred;
 | 
				
			||||||
@ -175,7 +177,7 @@ int v9fs_co_open2(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name, gid_t gid,
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_close(V9fsPDU *pdu, V9fsFidOpenState *fs)
 | 
					int coroutine_fn v9fs_co_close(V9fsPDU *pdu, V9fsFidOpenState *fs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -196,7 +198,7 @@ int v9fs_co_close(V9fsPDU *pdu, V9fsFidOpenState *fs)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_fsync(V9fsPDU *pdu, V9fsFidState *fidp, int datasync)
 | 
					int coroutine_fn v9fs_co_fsync(V9fsPDU *pdu, V9fsFidState *fidp, int datasync)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -214,7 +216,7 @@ int v9fs_co_fsync(V9fsPDU *pdu, V9fsFidState *fidp, int datasync)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_link(V9fsPDU *pdu, V9fsFidState *oldfid,
 | 
					int coroutine_fn v9fs_co_link(V9fsPDU *pdu, V9fsFidState *oldfid,
 | 
				
			||||||
                              V9fsFidState *newdirfid, V9fsString *name)
 | 
					                              V9fsFidState *newdirfid, V9fsString *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
@ -236,7 +238,7 @@ int v9fs_co_link(V9fsPDU *pdu, V9fsFidState *oldfid,
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_pwritev(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
					int coroutine_fn v9fs_co_pwritev(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
				
			||||||
                                 struct iovec *iov, int iovcnt, int64_t offset)
 | 
					                                 struct iovec *iov, int iovcnt, int64_t offset)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
@ -255,7 +257,7 @@ int v9fs_co_pwritev(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_preadv(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
					int coroutine_fn v9fs_co_preadv(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
				
			||||||
                                struct iovec *iov, int iovcnt, int64_t offset)
 | 
					                                struct iovec *iov, int iovcnt, int64_t offset)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
 | 
				
			|||||||
@ -49,7 +49,7 @@ static ssize_t __readlink(V9fsState *s, V9fsPath *path, V9fsString *buf)
 | 
				
			|||||||
    return len;
 | 
					    return len;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_readlink(V9fsPDU *pdu, V9fsPath *path, V9fsString *buf)
 | 
					int coroutine_fn v9fs_co_readlink(V9fsPDU *pdu, V9fsPath *path, V9fsString *buf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -69,7 +69,8 @@ int v9fs_co_readlink(V9fsPDU *pdu, V9fsPath *path, V9fsString *buf)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_statfs(V9fsPDU *pdu, V9fsPath *path, struct statfs *stbuf)
 | 
					int coroutine_fn v9fs_co_statfs(V9fsPDU *pdu, V9fsPath *path,
 | 
				
			||||||
 | 
					                                struct statfs *stbuf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -89,7 +90,7 @@ int v9fs_co_statfs(V9fsPDU *pdu, V9fsPath *path, struct statfs *stbuf)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_chmod(V9fsPDU *pdu, V9fsPath *path, mode_t mode)
 | 
					int coroutine_fn v9fs_co_chmod(V9fsPDU *pdu, V9fsPath *path, mode_t mode)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    FsCred cred;
 | 
					    FsCred cred;
 | 
				
			||||||
@ -112,7 +113,7 @@ int v9fs_co_chmod(V9fsPDU *pdu, V9fsPath *path, mode_t mode)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_utimensat(V9fsPDU *pdu, V9fsPath *path,
 | 
					int coroutine_fn v9fs_co_utimensat(V9fsPDU *pdu, V9fsPath *path,
 | 
				
			||||||
                                   struct timespec times[2])
 | 
					                                   struct timespec times[2])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
@ -133,7 +134,8 @@ int v9fs_co_utimensat(V9fsPDU *pdu, V9fsPath *path,
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_chown(V9fsPDU *pdu, V9fsPath *path, uid_t uid, gid_t gid)
 | 
					int coroutine_fn v9fs_co_chown(V9fsPDU *pdu, V9fsPath *path, uid_t uid,
 | 
				
			||||||
 | 
					                               gid_t gid)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    FsCred cred;
 | 
					    FsCred cred;
 | 
				
			||||||
@ -157,7 +159,7 @@ int v9fs_co_chown(V9fsPDU *pdu, V9fsPath *path, uid_t uid, gid_t gid)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_truncate(V9fsPDU *pdu, V9fsPath *path, off_t size)
 | 
					int coroutine_fn v9fs_co_truncate(V9fsPDU *pdu, V9fsPath *path, off_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -177,8 +179,9 @@ int v9fs_co_truncate(V9fsPDU *pdu, V9fsPath *path, off_t size)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_mknod(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name, uid_t uid,
 | 
					int coroutine_fn v9fs_co_mknod(V9fsPDU *pdu, V9fsFidState *fidp,
 | 
				
			||||||
                  gid_t gid, dev_t dev, mode_t mode, struct stat *stbuf)
 | 
					                               V9fsString *name, uid_t uid, gid_t gid,
 | 
				
			||||||
 | 
					                               dev_t dev, mode_t mode, struct stat *stbuf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsPath path;
 | 
					    V9fsPath path;
 | 
				
			||||||
@ -216,7 +219,7 @@ int v9fs_co_mknod(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name, uid_t uid,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Only works with path name based fid */
 | 
					/* Only works with path name based fid */
 | 
				
			||||||
int v9fs_co_remove(V9fsPDU *pdu, V9fsPath *path)
 | 
					int coroutine_fn v9fs_co_remove(V9fsPDU *pdu, V9fsPath *path)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -236,7 +239,8 @@ int v9fs_co_remove(V9fsPDU *pdu, V9fsPath *path)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_unlinkat(V9fsPDU *pdu, V9fsPath *path, V9fsString *name, int flags)
 | 
					int coroutine_fn v9fs_co_unlinkat(V9fsPDU *pdu, V9fsPath *path,
 | 
				
			||||||
 | 
					                                  V9fsString *name, int flags)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -257,7 +261,8 @@ int v9fs_co_unlinkat(V9fsPDU *pdu, V9fsPath *path, V9fsString *name, int flags)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Only work with path name based fid */
 | 
					/* Only work with path name based fid */
 | 
				
			||||||
int v9fs_co_rename(V9fsPDU *pdu, V9fsPath *oldpath, V9fsPath *newpath)
 | 
					int coroutine_fn v9fs_co_rename(V9fsPDU *pdu, V9fsPath *oldpath,
 | 
				
			||||||
 | 
					                                V9fsPath *newpath)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -275,8 +280,9 @@ int v9fs_co_rename(V9fsPDU *pdu, V9fsPath *oldpath, V9fsPath *newpath)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_renameat(V9fsPDU *pdu, V9fsPath *olddirpath, V9fsString *oldname,
 | 
					int coroutine_fn v9fs_co_renameat(V9fsPDU *pdu, V9fsPath *olddirpath,
 | 
				
			||||||
                     V9fsPath *newdirpath, V9fsString *newname)
 | 
					                                  V9fsString *oldname, V9fsPath *newdirpath,
 | 
				
			||||||
 | 
					                                  V9fsString *newname)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -295,8 +301,9 @@ int v9fs_co_renameat(V9fsPDU *pdu, V9fsPath *olddirpath, V9fsString *oldname,
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_symlink(V9fsPDU *pdu, V9fsFidState *dfidp, V9fsString *name,
 | 
					int coroutine_fn v9fs_co_symlink(V9fsPDU *pdu, V9fsFidState *dfidp,
 | 
				
			||||||
                    const char *oldpath, gid_t gid, struct stat *stbuf)
 | 
					                                 V9fsString *name, const char *oldpath,
 | 
				
			||||||
 | 
					                                 gid_t gid, struct stat *stbuf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    FsCred cred;
 | 
					    FsCred cred;
 | 
				
			||||||
@ -337,7 +344,7 @@ int v9fs_co_symlink(V9fsPDU *pdu, V9fsFidState *dfidp, V9fsString *name,
 | 
				
			|||||||
 * For path name based fid we don't block. So we can
 | 
					 * For path name based fid we don't block. So we can
 | 
				
			||||||
 * directly call the fs driver ops.
 | 
					 * directly call the fs driver ops.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
int v9fs_co_name_to_path(V9fsPDU *pdu, V9fsPath *dirpath,
 | 
					int coroutine_fn v9fs_co_name_to_path(V9fsPDU *pdu, V9fsPath *dirpath,
 | 
				
			||||||
                                      const char *name, V9fsPath *path)
 | 
					                                      const char *name, V9fsPath *path)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
 | 
				
			|||||||
@ -47,52 +47,53 @@
 | 
				
			|||||||
        qemu_coroutine_yield();                                         \
 | 
					        qemu_coroutine_yield();                                         \
 | 
				
			||||||
    } while (0)
 | 
					    } while (0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void co_run_in_worker_bh(void *);
 | 
					void co_run_in_worker_bh(void *);
 | 
				
			||||||
extern int v9fs_co_readlink(V9fsPDU *, V9fsPath *, V9fsString *);
 | 
					int coroutine_fn v9fs_co_readlink(V9fsPDU *, V9fsPath *, V9fsString *);
 | 
				
			||||||
extern int v9fs_co_readdir(V9fsPDU *, V9fsFidState *, struct dirent **);
 | 
					int coroutine_fn v9fs_co_readdir(V9fsPDU *, V9fsFidState *, struct dirent **);
 | 
				
			||||||
extern off_t v9fs_co_telldir(V9fsPDU *, V9fsFidState *);
 | 
					off_t coroutine_fn v9fs_co_telldir(V9fsPDU *, V9fsFidState *);
 | 
				
			||||||
extern void v9fs_co_seekdir(V9fsPDU *, V9fsFidState *, off_t);
 | 
					void coroutine_fn v9fs_co_seekdir(V9fsPDU *, V9fsFidState *, off_t);
 | 
				
			||||||
extern void v9fs_co_rewinddir(V9fsPDU *, V9fsFidState *);
 | 
					void coroutine_fn v9fs_co_rewinddir(V9fsPDU *, V9fsFidState *);
 | 
				
			||||||
extern int v9fs_co_statfs(V9fsPDU *, V9fsPath *, struct statfs *);
 | 
					int coroutine_fn v9fs_co_statfs(V9fsPDU *, V9fsPath *, struct statfs *);
 | 
				
			||||||
extern int v9fs_co_lstat(V9fsPDU *, V9fsPath *, struct stat *);
 | 
					int coroutine_fn v9fs_co_lstat(V9fsPDU *, V9fsPath *, struct stat *);
 | 
				
			||||||
extern int v9fs_co_chmod(V9fsPDU *, V9fsPath *, mode_t);
 | 
					int coroutine_fn v9fs_co_chmod(V9fsPDU *, V9fsPath *, mode_t);
 | 
				
			||||||
extern int v9fs_co_utimensat(V9fsPDU *, V9fsPath *, struct timespec [2]);
 | 
					int coroutine_fn v9fs_co_utimensat(V9fsPDU *, V9fsPath *, struct timespec [2]);
 | 
				
			||||||
extern int v9fs_co_chown(V9fsPDU *, V9fsPath *, uid_t, gid_t);
 | 
					int coroutine_fn v9fs_co_chown(V9fsPDU *, V9fsPath *, uid_t, gid_t);
 | 
				
			||||||
extern int v9fs_co_truncate(V9fsPDU *, V9fsPath *, off_t);
 | 
					int coroutine_fn v9fs_co_truncate(V9fsPDU *, V9fsPath *, off_t);
 | 
				
			||||||
extern int v9fs_co_llistxattr(V9fsPDU *, V9fsPath *, void *, size_t);
 | 
					int coroutine_fn v9fs_co_llistxattr(V9fsPDU *, V9fsPath *, void *, size_t);
 | 
				
			||||||
extern int v9fs_co_lgetxattr(V9fsPDU *, V9fsPath *,
 | 
					int coroutine_fn v9fs_co_lgetxattr(V9fsPDU *, V9fsPath *,
 | 
				
			||||||
                                   V9fsString *, void *, size_t);
 | 
					                                   V9fsString *, void *, size_t);
 | 
				
			||||||
extern int v9fs_co_mknod(V9fsPDU *, V9fsFidState *, V9fsString *, uid_t,
 | 
					int coroutine_fn v9fs_co_mknod(V9fsPDU *, V9fsFidState *, V9fsString *, uid_t,
 | 
				
			||||||
                               gid_t, dev_t, mode_t, struct stat *);
 | 
					                               gid_t, dev_t, mode_t, struct stat *);
 | 
				
			||||||
extern int v9fs_co_mkdir(V9fsPDU *, V9fsFidState *, V9fsString *,
 | 
					int coroutine_fn v9fs_co_mkdir(V9fsPDU *, V9fsFidState *, V9fsString *,
 | 
				
			||||||
                               mode_t, uid_t, gid_t, struct stat *);
 | 
					                               mode_t, uid_t, gid_t, struct stat *);
 | 
				
			||||||
extern int v9fs_co_remove(V9fsPDU *, V9fsPath *);
 | 
					int coroutine_fn v9fs_co_remove(V9fsPDU *, V9fsPath *);
 | 
				
			||||||
extern int v9fs_co_rename(V9fsPDU *, V9fsPath *, V9fsPath *);
 | 
					int coroutine_fn v9fs_co_rename(V9fsPDU *, V9fsPath *, V9fsPath *);
 | 
				
			||||||
extern int v9fs_co_unlinkat(V9fsPDU *, V9fsPath *, V9fsString *, int flags);
 | 
					int coroutine_fn v9fs_co_unlinkat(V9fsPDU *, V9fsPath *, V9fsString *,
 | 
				
			||||||
extern int v9fs_co_renameat(V9fsPDU *, V9fsPath *, V9fsString *,
 | 
					                                  int flags);
 | 
				
			||||||
 | 
					int coroutine_fn v9fs_co_renameat(V9fsPDU *, V9fsPath *, V9fsString *,
 | 
				
			||||||
                                  V9fsPath *, V9fsString *);
 | 
					                                  V9fsPath *, V9fsString *);
 | 
				
			||||||
extern int v9fs_co_fstat(V9fsPDU *, V9fsFidState *, struct stat *);
 | 
					int coroutine_fn v9fs_co_fstat(V9fsPDU *, V9fsFidState *, struct stat *);
 | 
				
			||||||
extern int v9fs_co_opendir(V9fsPDU *, V9fsFidState *);
 | 
					int coroutine_fn v9fs_co_opendir(V9fsPDU *, V9fsFidState *);
 | 
				
			||||||
extern int v9fs_co_open(V9fsPDU *, V9fsFidState *, int);
 | 
					int coroutine_fn v9fs_co_open(V9fsPDU *, V9fsFidState *, int);
 | 
				
			||||||
extern int v9fs_co_open2(V9fsPDU *, V9fsFidState *, V9fsString *,
 | 
					int coroutine_fn v9fs_co_open2(V9fsPDU *, V9fsFidState *, V9fsString *,
 | 
				
			||||||
                               gid_t, int, int, struct stat *);
 | 
					                               gid_t, int, int, struct stat *);
 | 
				
			||||||
extern int v9fs_co_lsetxattr(V9fsPDU *, V9fsPath *, V9fsString *,
 | 
					int coroutine_fn v9fs_co_lsetxattr(V9fsPDU *, V9fsPath *, V9fsString *,
 | 
				
			||||||
                                   void *, size_t, int);
 | 
					                                   void *, size_t, int);
 | 
				
			||||||
extern int v9fs_co_lremovexattr(V9fsPDU *, V9fsPath *, V9fsString *);
 | 
					int coroutine_fn v9fs_co_lremovexattr(V9fsPDU *, V9fsPath *, V9fsString *);
 | 
				
			||||||
extern int v9fs_co_closedir(V9fsPDU *, V9fsFidOpenState *);
 | 
					int coroutine_fn v9fs_co_closedir(V9fsPDU *, V9fsFidOpenState *);
 | 
				
			||||||
extern int v9fs_co_close(V9fsPDU *, V9fsFidOpenState *);
 | 
					int coroutine_fn v9fs_co_close(V9fsPDU *, V9fsFidOpenState *);
 | 
				
			||||||
extern int v9fs_co_fsync(V9fsPDU *, V9fsFidState *, int);
 | 
					int coroutine_fn v9fs_co_fsync(V9fsPDU *, V9fsFidState *, int);
 | 
				
			||||||
extern int v9fs_co_symlink(V9fsPDU *, V9fsFidState *, V9fsString *,
 | 
					int coroutine_fn v9fs_co_symlink(V9fsPDU *, V9fsFidState *, V9fsString *,
 | 
				
			||||||
                                 const char *, gid_t, struct stat *);
 | 
					                                 const char *, gid_t, struct stat *);
 | 
				
			||||||
extern int v9fs_co_link(V9fsPDU *, V9fsFidState *,
 | 
					int coroutine_fn v9fs_co_link(V9fsPDU *, V9fsFidState *,
 | 
				
			||||||
                              V9fsFidState *, V9fsString *);
 | 
					                              V9fsFidState *, V9fsString *);
 | 
				
			||||||
extern int v9fs_co_pwritev(V9fsPDU *, V9fsFidState *,
 | 
					int coroutine_fn v9fs_co_pwritev(V9fsPDU *, V9fsFidState *,
 | 
				
			||||||
                                 struct iovec *, int, int64_t);
 | 
					                                 struct iovec *, int, int64_t);
 | 
				
			||||||
extern int v9fs_co_preadv(V9fsPDU *, V9fsFidState *,
 | 
					int coroutine_fn v9fs_co_preadv(V9fsPDU *, V9fsFidState *,
 | 
				
			||||||
                                struct iovec *, int, int64_t);
 | 
					                                struct iovec *, int, int64_t);
 | 
				
			||||||
extern int v9fs_co_name_to_path(V9fsPDU *, V9fsPath *,
 | 
					int coroutine_fn v9fs_co_name_to_path(V9fsPDU *, V9fsPath *,
 | 
				
			||||||
                                      const char *, V9fsPath *);
 | 
					                                      const char *, V9fsPath *);
 | 
				
			||||||
extern int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t,
 | 
					int coroutine_fn v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t,
 | 
				
			||||||
                                V9fsStatDotl *v9stat);
 | 
					                                V9fsStatDotl *v9stat);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -17,7 +17,8 @@
 | 
				
			|||||||
#include "qemu/coroutine.h"
 | 
					#include "qemu/coroutine.h"
 | 
				
			||||||
#include "coth.h"
 | 
					#include "coth.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_llistxattr(V9fsPDU *pdu, V9fsPath *path, void *value, size_t size)
 | 
					int coroutine_fn v9fs_co_llistxattr(V9fsPDU *pdu, V9fsPath *path, void *value,
 | 
				
			||||||
 | 
					                                    size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -37,9 +38,9 @@ int v9fs_co_llistxattr(V9fsPDU *pdu, V9fsPath *path, void *value, size_t size)
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_lgetxattr(V9fsPDU *pdu, V9fsPath *path,
 | 
					int coroutine_fn v9fs_co_lgetxattr(V9fsPDU *pdu, V9fsPath *path,
 | 
				
			||||||
                      V9fsString *xattr_name,
 | 
					                                   V9fsString *xattr_name, void *value,
 | 
				
			||||||
                      void *value, size_t size)
 | 
					                                   size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    V9fsState *s = pdu->s;
 | 
					    V9fsState *s = pdu->s;
 | 
				
			||||||
@ -61,7 +62,7 @@ int v9fs_co_lgetxattr(V9fsPDU *pdu, V9fsPath *path,
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_lsetxattr(V9fsPDU *pdu, V9fsPath *path,
 | 
					int coroutine_fn v9fs_co_lsetxattr(V9fsPDU *pdu, V9fsPath *path,
 | 
				
			||||||
                                   V9fsString *xattr_name, void *value,
 | 
					                                   V9fsString *xattr_name, void *value,
 | 
				
			||||||
                                   size_t size, int flags)
 | 
					                                   size_t size, int flags)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -85,7 +86,7 @@ int v9fs_co_lsetxattr(V9fsPDU *pdu, V9fsPath *path,
 | 
				
			|||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int v9fs_co_lremovexattr(V9fsPDU *pdu, V9fsPath *path,
 | 
					int coroutine_fn v9fs_co_lremovexattr(V9fsPDU *pdu, V9fsPath *path,
 | 
				
			||||||
                                      V9fsString *xattr_name)
 | 
					                                      V9fsString *xattr_name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
 | 
				
			|||||||
@ -141,6 +141,13 @@ static void virtio_9p_device_unrealize(DeviceState *dev, Error **errp)
 | 
				
			|||||||
    v9fs_device_unrealize_common(s, errp);
 | 
					    v9fs_device_unrealize_common(s, errp);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void virtio_9p_reset(VirtIODevice *vdev)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    V9fsVirtioState *v = (V9fsVirtioState *)vdev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    v9fs_reset(&v->state);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ssize_t virtio_pdu_vmarshal(V9fsPDU *pdu, size_t offset,
 | 
					ssize_t virtio_pdu_vmarshal(V9fsPDU *pdu, size_t offset,
 | 
				
			||||||
                            const char *fmt, va_list ap)
 | 
					                            const char *fmt, va_list ap)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -207,6 +214,7 @@ static void virtio_9p_class_init(ObjectClass *klass, void *data)
 | 
				
			|||||||
    vdc->unrealize = virtio_9p_device_unrealize;
 | 
					    vdc->unrealize = virtio_9p_device_unrealize;
 | 
				
			||||||
    vdc->get_features = virtio_9p_get_features;
 | 
					    vdc->get_features = virtio_9p_get_features;
 | 
				
			||||||
    vdc->get_config = virtio_9p_get_config;
 | 
					    vdc->get_config = virtio_9p_get_config;
 | 
				
			||||||
 | 
					    vdc->reset = virtio_9p_reset;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const TypeInfo virtio_device_info = {
 | 
					static const TypeInfo virtio_device_info = {
 | 
				
			||||||
 | 
				
			|||||||
@ -15,7 +15,7 @@ typedef struct V9fsVirtioState
 | 
				
			|||||||
    V9fsState state;
 | 
					    V9fsState state;
 | 
				
			||||||
} V9fsVirtioState;
 | 
					} V9fsVirtioState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void virtio_9p_push_and_notify(V9fsPDU *pdu);
 | 
					void virtio_9p_push_and_notify(V9fsPDU *pdu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ssize_t virtio_pdu_vmarshal(V9fsPDU *pdu, size_t offset,
 | 
					ssize_t virtio_pdu_vmarshal(V9fsPDU *pdu, size_t offset,
 | 
				
			||||||
                            const char *fmt, va_list ap);
 | 
					                            const char *fmt, va_list ap);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user