summaryrefslogtreecommitdiff
path: root/hw/9pfs/virtio-9p.c
AgeCommit message (Collapse)AuthorFilesLines
2014-02-02hw/9pfs: fix P9_STATS_GEN handlingKirill A. Shutemov1-2/+10
Currently we fail getattr request altogether if we can't read P9_STATS_GEN for some reason. It breaks valid use cases: E.g let's assume we have non-readable directory with execution bit set on host and we export it to client over 9p On host we can chdir into directory, but not open directory on read and list content. But if client will try to call getattr (as part of chdir(2)) for the directory it will fail with -EACCES. It happens because we try to open the directory on read to call ioctl(FS_IOC_GETVERSION), it fails and we return the error code to client. It's excessive. The solution is to make P9_STATS_GEN failure non-fatal for getattr request. Just don't set P9_STATS_GEN flag in result mask on failure. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2013-05-28hw/9pfs: Fix segfault with 9p2000.uAneesh Kumar K.V1-1/+1
When guest tries to chmod a block or char device file over 9pfs, the qemu process segfaults. With 9p2000.u protocol we use wstat to change mode bits and client don't send extension information for chmod. We need to check for size field to check whether extension info is present or not. Reported-by: Michael Tokarev <mjt@tls.msk.ru> Acked-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2013-04-23virtio-9p: cleanup: QOM casts.KONRAD Frederic1-1/+1
As the virtio-9p-pci is switched to the new API, we can use QOM casts. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Message-id: 1366708123-19626-5-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-08hw: move headers to include/Paolo Bonzini1-2/+2
Many of these should be cleaned up with proper qdev-/QOM-ification. Right now there are many catch-all headers in include/hw/ARCH depending on cpu.h, and this makes it necessary to compile these files per-target. However, fixing this does not belong in these patches. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-03-01virtio-9p: remove PCI dependencies from hw/9pfs/Paolo Bonzini1-2/+1
Also move the 9p.h file to 9pfs/virtio-9p-device.h, for consistency with the corresponding .c file. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-02-06qemu/9p: Don't ignore error in fid clunkAneesh Kumar K.V1-5/+7
We use the clunk request to do the actual xattr operation. So don't ignore the error value for fid clunk. Security model "none" don't support posix acl. Without this patch guest won't get EOPNOTSUPP error on setxattr("system.posix_acl_access") Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-30g_malloc(0) and g_malloc0(0) return NULL; simplifyMarkus Armbruster1-5/+1
Once upon a time, it was decided that qemu_malloc(0) should abort. Switching to glib retired that bright idea. Some code that was added to cope with it (e.g. in commits 702ef63, b76b6e9) is still around. Bury it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19migration: move include files to include/migration/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-10-05cleanup useless return sentenceAmos Kong1-5/+0
This patch cleans up return sentences in the end of void functions. Reported-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Amos Kong <akong@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2012-07-31hw/9pfs: Fix assert when disabling migrationAneesh Kumar K.V1-5/+10
For 9p we can get the attach request multiple times for the same export. So don't adding migration blocker for every attach request. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2012-06-11consolidate qemu_iovec_copy() and qemu_iovec_concat() and make them consistentMichael Tokarev1-4/+4
qemu_iovec_concat() is currently a wrapper for qemu_iovec_copy(), use the former (with extra "0" arg) in a few places where it is used. Change skip argument of qemu_iovec_copy() from uint64_t to size_t, since size of qiov itself is size_t, so there's no way to skip larger sizes. Rename it to soffset, to make it clear that the offset is applied to src. Also change the only usage of uint64_t in hw/9pfs/virtio-9p.c, in v9fs_init_qiov_from_pdu() - all callers of it actually uses size_t too, not uint64_t. One added restriction: as for all other iovec-related functions, soffset must point inside src. Order of argumens is already good: qemu_iovec_memset(QEMUIOVector *qiov, size_t offset, int c, size_t bytes) vs: qemu_iovec_concat(QEMUIOVector *dst, QEMUIOVector *src, size_t soffset, size_t sbytes) (note soffset is after _src_ not dst, since it applies to src; for memset it applies to qiov). Note that in many places where this function is used, the previous call is qemu_iovec_reset(), which means many callers actually want copy (replacing dst content), not concat. So we may want to add a wrapper like qemu_iovec_copy() with the same arguments but which calls qemu_iovec_reset() before _concat(). Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2012-02-24hw/9pfs: Endian fixes for virtfsBenjamin Herrenschmidt1-3/+5
This patch fixes several endian bugs in virtfs. Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2012-01-30hw/9pfs: Remove O_NOATIME flag from 9pfs open() calls in readonly modeDaniel P. Berrange1-1/+0
When 2c74c2cb4bedddbfa67628fbd5f9273b4e0e9903 added support for the 'readonly' flag against 9p filesystems, it also made QEMU add the O_NOATIME flag as a side-effect. The O_NOATIME flag, however, may only be set by the file owner, or a user with CAP_FOWNER capability. QEMU cannot assume that this is the case for filesytems exported to QEMU. eg, run QEMU as non-root, and attempt to pass the host OS filesystem through to the guest OS with readonly enable. The result is that the guest OS cannot open any files at all. If O_NOATIME is really required, it should be optionally enabled via a separate QEMU command line flag. * hw/9pfs/virtio-9p.c: Remove O_NOATIME Acked-by: M. Mohan Kumar <mohan@in.ibm.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2012-01-30hw/9pfs: Fix crash when mounting with synthfsAneesh Kumar K.V1-1/+1
Some Fsdriver backend don't have fs_root. So check for that in migrate message. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2012-01-04hw/9pfs: Add validation to {un}marshal codeM. Mohan Kumar1-123/+338
Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2012-01-04hw/9pfs: Move pdu_marshal/unmarshal code to a seperate fileM. Mohan Kumar1-247/+4
Move p9 marshaling/unmarshaling code to a separate file so that proxy filesytem driver can use these calls. Also made marshaling code generic to accept "struct iovec" instead of V9fsPDU. Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-12-21hw/9pfs: iattr_valid flags are kernel internal flags map them to 9p values.Aneesh Kumar K.V1-23/+24
Kernel internal values can change, add protocol values for these constant and use them. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-12-21hw/9pfs: Use the correct signed type for different variablesAneesh Kumar K.V1-10/+11
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-12-21hw/9pfs: replace iovec manipulation with QEMUIOVectorStefan Hajnoczi1-102/+60
The v9fs_read() and v9fs_write() functions rely on iovec[] manipulation code should be replaced with QEMUIOVector to avoid duplicating code. In the future it may be possible to make the code even more concise by using QEMUIOVector consistently across virtio and 9pfs. The "v" format specifier for pdu_marshal() and pdu_unmarshal() is dropped since it does not actually pack/unpack anything. The specifier was also not implemented to update the offset variable and could only be used at the end of a format string, another sign that this shouldn't really be a format specifier. Instead, see the new v9fs_init_qiov_from_pdu() function. This change avoids a possible iovec[] buffer overflow when indirect vrings are used since the number of vectors is now limited by the underlying VirtQueueElement and cannot be out-of-bounds. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-12-06fix typo: delete redundant semicolonDong Xu Wang1-2/+2
Double semicolons should be single. Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-04hw/9pfs: Reset server state during TVERSIONDeepak C Shetty1-0/+26
As per the 9p rfc, during TVERSION its necessary to clean all the active fids, so that we start the session from a clean state. Its also needed in scenarios where the guest is booting off 9p, and boot fails, and client restarts, without any knowledge of the past, it will issue a TVERSION again so this ensures that we always start from a clean state. Signed-off-by: Deepak C Shetty <deepakcs@linux.vnet.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-12-04hw/9pfs: use migration blockers to prevent live migration when virtfs export ↵Aneesh Kumar K.V1-0/+19
path is mounted Now when you try to migrate with VirtFS export path mounted, you get a proper QMP error: (qemu) migrate tcp:localhost:4444 Migration is disabled when VirtFS export path '/tmp/' is mounted in the guest using mount_tag 'v_tmp' (qemu) Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-11-219p: pass dotl flags to the unlinkat methodPaolo Bonzini1-10/+0
AT_REMOVEDIR is not defined on all systems. Pass the raw flags from the 9p protocol, which are always there. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-02hw/9pfs: use g_vasprintf() instead of rolling our ownStefan Hajnoczi1-99/+4
Markus Armbruster <armbru@redhat.com> sent fixes for va_list vararg issues in v9fs_string_alloc_printf(). It turns out the function duplicates g_vasprintf() and can therefore be eliminated entirely. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-10-31hw/9pfs: Abstract open state of fid to V9fsFidOpenStateAneesh Kumar K.V1-6/+6
To implement synthetic file system in Qemu we may not really require file descriptor and Dir *. Make generic code use V9fsFidOpenState instead. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-10-31hw/9pfs: Read-only support for 9p exportM. Mohan Kumar1-0/+50
A new fsdev parameter "readonly" is introduced to control accessing 9p export. "readonly" can be used to specify the access type. By default "rw" access is given to 9p export. Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-10-30hw/9pfs: Make VirtFS tracing work correctlyAneesh Kumar K.V1-31/+29
this patch fix multiple issues with VirtFS tracing. a) Add tracepoint to the correct code path. We handle error in complete_pdu b) Fix indentation in python script c) Fix variable naming issue in python script Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-15hw/9pfs: Use export_flag for indicating whether fs driver use path names.Aneesh Kumar K.V1-3/+3
This allows us to remove another member from the struct Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-10-15hw/9pfs: Remove virtio-9p-debug.* infra to be replaced by Qemu Tracing.Harsh Prateek Bora1-8/+0
Removing the existing debug infrastrucure as proposed to be replaced by Qemu Tracing infrastructure. Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-10-15hw/9pfs: Introduce tracing for 9p pdu handlersHarsh Prateek Bora1-0/+72
Plan is to replace the existing debug infrastructure with Qemu tracing infrastructure so that user can dynamically enable/disable trace events and therefore a meaningful trace log can be generated which can be further filtered using an analysis script. Note: Because of current simpletrace limitations, the trace events are logging at max 6 args, however, once the more args are supported, we can change trace events to log more info as well. Also, This initial patch only provides a replacement for existing debug infra. More trace events to be added later for newly added handlers and sub-routines. Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-10-15hw/9pfs: Add st_gen support in getattr replyHarsh Prateek Bora1-0/+9
This patch use file system specific ioctl for getting i_generation value. Not all file system support the ioctl. So we add an export specific extended operation and assign right callback for the file system that support i_generation ioctl ["M. Mohan Kumar" <mohan@in.ibm.com> we can do ioctl only for regular files and directories on the server] Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-10-15hw/9pfs: Add open flag mappingM. Mohan Kumar1-1/+52
Some of the flags are OS/arch dependent we need to use 9P defined value on wire, Based on the original patch from Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com> Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-10-15virtio-9p: Use 9P specific Lock constantsM. Mohan Kumar1-1/+1
Use 9P specific lock constants instead of arch specific lock constants. Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-10-12hw/9pfs: Add new virtfs option writeout=immediate skip host page cacheAneesh Kumar K.V1-6/+16
writeout=immediate implies the after pwritev we do a sync_file_range. Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22hw/9pfs: Implement TFLUSH operationAneesh Kumar K.V1-187/+225
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22hw/9pfs: Avoid unnecessary get_fid in v9fs_clunkAneesh Kumar K.V1-10/+10
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22hw/9pfs: Add fs driver specific details to fscontextAneesh Kumar K.V1-8/+22
Add a new context flag PATHNAME_FSCONTEXT and indicate whether the fs driver track fid using path names. Also add a private pointer that help us to track fs driver specific values in there Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22hw/9pfs: Move fid pathname tracking to seperate data type.Aneesh Kumar K.V1-163/+203
This enables us to add handles to track fids later. The V9fsPath added is similar to V9fsString except that the size include the NULL byte also. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22hw/9pfs: Use read-write lock for protecting fid path.Aneesh Kumar K.V1-68/+42
On rename we take the write lock and this ensure path doesn't change as we operate on them. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22hw/9pfs: Make v9fs_string* functions non-staticAneesh Kumar K.V1-5/+5
We will use them later in other files Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-09hw/9pfs: add 9P2000.L unlinkat operationAneesh Kumar K.V1-0/+40
unlinkat - Remove a directory entry size[4] Tunlinkat tag[2] dirfid[4] name[s] flag[4] size[4] Runlinkat tag[2] older Tremove have the below request format size[4] Tremove tag[2] fid[4] The remove message is used to remove a directory entry either file or directory The remove opreation is actually a directory opertation and should ideally have dirfid, if not we cannot represent the fid on server with anything other than name. We will have to derive the directory name from fid in the Tremove request. NOTE: The operation doesn't clunk the unlink fid. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-09hw/9pfs: add 9P2000.L renameat operationAneesh Kumar K.V1-0/+82
rename - change name of file or directory size[4] Trenameat tag[2] olddirfid[4] oldname[s] newdirfid[4] newname[s] size[4] Rrenameat tag[2] older Trename have the below request format size[4] Trename tag[2] fid[4] newdirfid[4] name[s] The rename message is used to change the name of a file, possibly moving it to a new directory. The rename opreation is actually a directory opertation and should ideally have olddirfid, if not we cannot represent the fid on server with anything other than name. We will have to derive the old directory name from fid in the Trename request. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-09hw/9pfs: Fix memleaks in some 9p operationAneesh Kumar K.V1-0/+2
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-09hw/9pfs: Initialize rest of qid field to zero.Aneesh Kumar K.V1-0/+1
Since qid is allocated out of stack we need to intialize the field to zero. Otherwise we will send wrong qid value to client. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-09hw/9pfs: Update the fidp path before opendirAneesh Kumar K.V1-0/+1
We need to update the fidp path before opendir. Since we don't use the fid returned by mkdir, earlier code should not have much issue. We do a double v9fs_string_copy here. The later patch cleanup the entire function. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-25hw/9pfs: mark directories also as un-reclaimable on unlinkAneesh Kumar K.V1-35/+38
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-25hw/9pfs: Add directory reclaim supportAneesh Kumar K.V1-2/+29
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-25hw/9pfs: Use v9fs_do_close instead of closeAneesh Kumar K.V1-2/+2
we should use the local abstraction instead of directly calling close. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-25hw/9pfs: Add file descriptor reclaim supportAneesh Kumar K.V1-3/+184
[M. Mohan Kumar <mohan@in.ibm.com> removed some unused variables] Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>