All of lore.kernel.org
 help / color / mirror / Atom feed
From: linhaifeng <haifeng.lin@huawei.com>
To: qemu-devel@nongnu.org
Cc: arei.gonglei@huawei.com, Linhaifeng <haifeng.lin@huawei.com>,
	mst@redhat.com
Subject: [Qemu-devel] [PATCH v1 2/2] vhost-user: add reply for set_mem_table
Date: Tue, 10 Feb 2015 13:48:13 +0800	[thread overview]
Message-ID: <1423547293-8448-2-git-send-email-haifeng.lin@huawei.com> (raw)
In-Reply-To: <1423547293-8448-1-git-send-email-haifeng.lin@huawei.com>

From: Linhaifeng <haifeng.lin@huawei.com>

If u64 is not 0 we should return -1 to tell qemu not going on.

Remove some unnecessary '\n' in error_report.

Signed-off-by: Linhaifeng <haifeng.lin@huawei.com>
---
 hw/virtio/vhost-user.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index aefe0bb..d69bb33 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -128,7 +128,7 @@ static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
 
     r = qemu_chr_fe_read_all(chr, p, size);
     if (r != size) {
-        error_report("Failed to read msg header. Read %d instead of %d.\n", r,
+        error_report("Failed to read msg header. Read %d instead of %d.", r,
                 size);
         goto fail;
     }
@@ -136,7 +136,7 @@ static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
     /* validate received flags */
     if (msg->flags != (VHOST_USER_REPLY_MASK | VHOST_USER_VERSION)) {
         error_report("Failed to read msg header."
-                " Flags 0x%x instead of 0x%x.\n", msg->flags,
+                " Flags 0x%x instead of 0x%x.", msg->flags,
                 VHOST_USER_REPLY_MASK | VHOST_USER_VERSION);
         goto fail;
     }
@@ -144,7 +144,7 @@ static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
     /* validate message size is sane */
     if (msg->size > VHOST_USER_PAYLOAD_SIZE) {
         error_report("Failed to read msg header."
-                " Size %d exceeds the maximum %zu.\n", msg->size,
+                " Size %d exceeds the maximum %zu.", msg->size,
                 VHOST_USER_PAYLOAD_SIZE);
         goto fail;
     }
@@ -155,7 +155,7 @@ static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
         r = qemu_chr_fe_read_all(chr, p, size);
         if (r != size) {
             error_report("Failed to read msg payload."
-                         " Read %d instead of %d.\n", r, msg->size);
+                         " Read %d instead of %d.", r, msg->size);
             goto fail;
         }
     }
@@ -236,14 +236,14 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
 
         if (!fd_num) {
             error_report("Failed initializing vhost-user memory map\n"
-                    "consider using -object memory-backend-file share=on\n");
+                    "consider using -object memory-backend-file share=on");
             return -1;
         }
 
         msg.size = sizeof(m.memory.nregions);
         msg.size += sizeof(m.memory.padding);
         msg.size += fd_num * sizeof(VhostUserMemoryRegion);
-
+        need_reply = 1;
         break;
 
     case VHOST_SET_LOG_FD:
@@ -280,7 +280,7 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
         }
         break;
     default:
-        error_report("vhost-user trying to send unhandled ioctl\n");
+        error_report("vhost-user trying to send unhandled ioctl");
         return -1;
         break;
     }
@@ -296,27 +296,38 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
 
         if (msg_request != msg.request) {
             error_report("Received unexpected msg type."
-                    " Expected %d received %d\n", msg_request, msg.request);
+                    " Expected %d received %d", msg_request, msg.request);
             return -1;
         }
 
         switch (msg_request) {
         case VHOST_USER_GET_FEATURES:
             if (msg.size != sizeof(m.u64)) {
-                error_report("Received bad msg size.\n");
+                error_report("Received bad msg size.");
                 return -1;
             }
             *((__u64 *) arg) = msg.u64;
             break;
         case VHOST_USER_GET_VRING_BASE:
             if (msg.size != sizeof(m.state)) {
-                error_report("Received bad msg size.\n");
+                error_report("Received bad msg size.");
                 return -1;
             }
             memcpy(arg, &msg.state, sizeof(struct vhost_vring_state));
             break;
+        case VHOST_SET_MEM_TABLE:
+            if (msg.size != sizeof(m.u64)) {
+                error_report("Received bad msg size.");
+                return -1;
+            } else {
+                if (m.u64) {
+                    error_report("Failed to set memory table.");
+                    return -1;
+                }
+            }
+            break;
         default:
-            error_report("Received unexpected msg type.\n");
+            error_report("Received unexpected msg type.");
             return -1;
             break;
         }
-- 
1.7.12.4

  reply	other threads:[~2015-02-10  5:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10  5:48 [Qemu-devel] [PATCH v1 1/2] vhost-user: support SET_MEM_TABLE waite the result of mmap linhaifeng
2015-02-10  5:48 ` linhaifeng [this message]
2015-02-10  6:35   ` [Qemu-devel] [PATCH v1 2/2] vhost-user: add reply for set_mem_table Gonglei
2015-02-10  6:54     ` Linhaifeng
2015-02-10  8:46 ` [Qemu-devel] [PATCH v1 1/2] vhost-user: support SET_MEM_TABLE waite the result of mmap Michael S. Tsirkin
2015-02-10 10:27   ` Linhaifeng
2015-02-10 10:41     ` Michael S. Tsirkin
2015-02-10 11:59       ` Linhaifeng
2015-02-10 12:04         ` Michael S. Tsirkin
2015-02-11  1:38           ` Linhaifeng
2015-02-12 16:38             ` Michael S. Tsirkin
2015-02-11  6:30           ` Linhaifeng
2015-02-12  3:25           ` Linhaifeng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423547293-8448-2-git-send-email-haifeng.lin@huawei.com \
    --to=haifeng.lin@huawei.com \
    --cc=arei.gonglei@huawei.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.