qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fix bug with virtio-9p xattr functions return values
@ 2011-04-28 13:48 Sassan Panahinejad
  2011-05-02 22:41 ` Venkateswararao Jujjuri
  0 siblings, 1 reply; 2+ messages in thread
From: Sassan Panahinejad @ 2011-04-28 13:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: Sassan Panahinejad

Several functions in virtio-9p-xattr.c are passing the return value of the associated host system call back to the client instead of errno.
Since this value is -1 for any error (which, when received in the guest app as errno, indicates "operation not permitted") it is causing guest applications to fail in cases where the operation is not supported by the host.
This causes a number of problems with dpkg and with install.
This patch fixes the bug and returns the correct value, which means that guest applications are able to handle the error correctly.

Signed-off-by: Sassan Panahinejad <sassan@sassan.me.uk>
---
 hw/virtio-9p-xattr.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/hw/virtio-9p-xattr.c b/hw/virtio-9p-xattr.c
index 1aab081..fd6d892 100644
--- a/hw/virtio-9p-xattr.c
+++ b/hw/virtio-9p-xattr.c
@@ -32,9 +32,14 @@ static XattrOperations *get_xattr_operations(XattrOperations **h,
 ssize_t v9fs_get_xattr(FsContext *ctx, const char *path,
                        const char *name, void *value, size_t size)
 {
+    int ret;
     XattrOperations *xops = get_xattr_operations(ctx->xops, name);
     if (xops) {
-        return xops->getxattr(ctx, path, name, value, size);
+        ret = xops->getxattr(ctx, path, name, value, size);
+        if (ret < 0) {
+            return -errno;
+        }
+        return ret;
     }
     errno = -EOPNOTSUPP;
     return -1;
@@ -117,9 +122,14 @@ err_out:
 int v9fs_set_xattr(FsContext *ctx, const char *path, const char *name,
                    void *value, size_t size, int flags)
 {
+    int ret;
     XattrOperations *xops = get_xattr_operations(ctx->xops, name);
     if (xops) {
-        return xops->setxattr(ctx, path, name, value, size, flags);
+        ret = xops->setxattr(ctx, path, name, value, size, flags);
+        if (ret < 0) {
+            return -errno;
+        }
+        return ret;
     }
     errno = -EOPNOTSUPP;
     return -1;
@@ -129,9 +139,14 @@ int v9fs_set_xattr(FsContext *ctx, const char *path, const char *name,
 int v9fs_remove_xattr(FsContext *ctx,
                       const char *path, const char *name)
 {
+    int ret;
     XattrOperations *xops = get_xattr_operations(ctx->xops, name);
     if (xops) {
-        return xops->removexattr(ctx, path, name);
+        ret = xops->removexattr(ctx, path, name);
+        if (ret < 0) {
+            return -errno;
+        }
+        return ret;
     }
     errno = -EOPNOTSUPP;
     return -1;
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-02 22:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-28 13:48 [Qemu-devel] [PATCH] Fix bug with virtio-9p xattr functions return values Sassan Panahinejad
2011-05-02 22:41 ` Venkateswararao Jujjuri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).