qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v4 35/47] Page request: Add MIG_RPCOMM_REQPAGES


From: Dr. David Alan Gilbert
Subject: Re: [Qemu-devel] [PATCH v4 35/47] Page request: Add MIG_RPCOMM_REQPAGES reverse command
Date: Wed, 19 Nov 2014 20:01:31 +0000
User-agent: Mutt/1.5.23 (2014-03-12)

* David Gibson (address@hidden) wrote:
> On Fri, Oct 03, 2014 at 06:47:41PM +0100, Dr. David Alan Gilbert (git) wrote:
> > From: "Dr. David Alan Gilbert" <address@hidden>
> > 
> > Add MIG_RPCOMM_REQPAGES command on Return path for the postcopy
> > destination to request a page from the source.

> > +    buf64[0] = (uint64_t)start;
> > +    buf64[0] = cpu_to_be64(buf64[0]);
> 
> I think this would be clearer as well as less verbose, as just:
>       buf64[0] = cpu_to_be64(start);

I've gone with the halfway mark of:

buf64[0] = cpu_to_be64((uint64_t)start);

it jsut doesn't feel right passing something into a byteswap
unless you know the size.

> > +    buf64[1] = (uint64_t)len;
> > +    buf64[1] = cpu_to_be64(buf64[1]);
> > +    migrate_send_rp_message(mis, MIG_RPCOMM_REQPAGES, msglen, bufc);
> > +}
> > +
> >  void qemu_start_incoming_migration(const char *uri, Error **errp)
> >  {
> >      const char *p;
> > @@ -784,6 +816,17 @@ static void source_return_path_bad(MigrationState *s)
> >  }
> >  
> >  /*
> > + * Process a request for pages received on the return path,
> > + * We're allowed to send more than requested (e.g. to round to our page 
> > size)
> > + * and we don't need to send pages that have already been sent.
> > + */
> > +static void migrate_handle_rp_reqpages(MigrationState *ms, const char* 
> > rbname,
> > +                                       ram_addr_t start, ram_addr_t len)
> > +{
> > +    DPRINTF("migrate_handle_rp_reqpages: at %zx for len %zx", start, len);
> > +}
> > +
> > +/*
> >   * Handles messages sent on the return path towards the source VM
> >   *
> >   */
> > @@ -795,6 +838,8 @@ static void *source_return_path_thread(void *opaque)
> >      const int max_len = 512;
> >      uint8_t buf[max_len];
> >      uint32_t tmp32;
> > +    uint64_t tmp64a, tmp64b;
> 
> Hrm.. calling everything "tmp*" doesn't help readability.

True; most of the rest of those tmps are used by multiple commands and
just read off the wire and immediately used.
They're now start/len for tmp64a/b.

Dave
> 
> > +    char *tmpstr;
> >      int res;
> >  
> >      DPRINTF("RP: %s entry", __func__);
> > @@ -810,6 +855,11 @@ static void *source_return_path_thread(void *opaque)
> >              expected_len = 4;
> >              break;
> >  
> > +        case MIG_RPCOMM_REQPAGES:
> > +            /* 16 byte start/len _possibly_ plus an id str */
> > +            expected_len = 16 + 256;
> > +            break;
> > +
> >          default:
> >              error_report("RP: Received invalid cmd 0x%04x length 0x%04x",
> >                      header_com, header_len);
> > @@ -857,6 +907,30 @@ static void *source_return_path_thread(void *opaque)
> >              atomic_xchg(&ms->rp_state.latest_ack, tmp32);
> >              break;
> >  
> > +        case MIG_RPCOMM_REQPAGES:
> > +            tmp64a = be64_to_cpup((uint64_t *)buf);  /* Start */
> > +            tmp64b = be64_to_cpup(((uint64_t *)buf)+1); /* Len */
> > +            tmpstr = NULL;
> > +            if (tmp64b & 1) {
> > +                tmp64b -= 1; /* Remove the flag */
> > +                /* Now we expect an idstr */
> > +                tmp32 = buf[16]; /* Length of the following idstr */
> > +                tmpstr = (char *)&buf[17];
> > +                buf[17+tmp32] = '\0';
> > +                expected_len = 16+1+tmp32;
> > +            } else {
> > +                expected_len = 16;
> > +            }
> > +            if (header_len != expected_len) {
> > +                error_report("RP: Received ReqPage with length %d 
> > expecting %d",
> > +                        header_len, expected_len);
> > +                source_return_path_bad(ms);
> > +            }
> > +            migrate_handle_rp_reqpages(ms, tmpstr,
> > +                                          (ram_addr_t)tmp64a,
> > +                                          (ram_addr_t)tmp64b);
> > +            break;
> > +
> >          default:
> >              /* This shouldn't happen because we should catch this above */
> >              DPRINTF("RP: Bad header_com in dispatch");
> 
> -- 
> David Gibson                  | I'll have my music baroque, and my code
> david AT gibson.dropbear.id.au        | minimalist, thank you.  NOT _the_ 
> _other_
>                               | _way_ _around_!
> http://www.ozlabs.org/~dgibson


--
Dr. David Alan Gilbert / address@hidden / Manchester, UK



reply via email to

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