qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 08/17] add unix_msgfd_lookup() to callback get_b


From: Lei Li
Subject: Re: [Qemu-devel] [PATCH 08/17] add unix_msgfd_lookup() to callback get_buffer
Date: Tue, 26 Nov 2013 22:00:59 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

On 11/26/2013 07:31 PM, Paolo Bonzini wrote:
Il 21/11/2013 10:11, Lei Li ha scritto:
+            /*
+             * recvmsg is called here to catch the control message for
+             * the exchange of PIPE file descriptor until it is received.
+             */
+            len = recvmsg(s->sockfd, &msg, 0);
+            if (len != -1) {
+                if (unix_msgfd_lookup(s, &msg) > 0) {
+                    pipefd_passed = 1;
+                    /*
+                     * Do not count one byte taken by the PIPE file
+                     * descriptor.
+                     */
+                    len--;
I think adding a byte in the middle of the stream is not reliable.

Rather, you should transmit the socket always at the same place, for
example in the first call of qemu_local_save_ram, after it has written
the 64-bit field.

I guess 'transmit the socket' you mean transmit the fd?

Sorry that I am quite understand your suggestion here.. Do you
mean that send_pipefd in the first call of qemu_local_save_ram
after it has written the 64-bit field? In this way, get rid of
qemu_local_send_pipefd?

Currently, the fd control message is sent at the end of the stream
in ram_save_setup stage, followed by the ram page. The control
message of fd is always at the same place.


The matching code in qemu_local_ram_load will be like this:

static int qemu_local_ram_load(QEMUFile *f, void *opaque,
                                uint64_t flags)
{
     QEMUFileLocal *s = opaque;
     ram_addr_t addr;
     struct iovec iov;
     ssize_t ret = -EINVAL;

     if (!s->pipefd_received) {
         /*
          * send_pipefd was called at this point, and it wrote one byte
          * to the stream.
          */
         qemu_get_byte(s);
         s->pipefd_received = true;
     }

     if (pipefd_passed) {
         ...
     }
     return -EINVAL;
}

Also, please move pipefd_passed within QEMUFileLocal.

Thanks,

Paolo



--
Lei




reply via email to

[Prev in Thread] Current Thread [Next in Thread]