All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@citrix.com>
To: Anthony PERARD <anthony.perard@citrix.com>
Cc: xen-devel@lists.xenproject.org, Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH v5 15/15] libxl: Re-implement domain_suspend_device_model using libxl__ev_qmp
Date: Tue, 16 Oct 2018 16:28:55 +0100	[thread overview]
Message-ID: <23494.951.777903.157046@mariner.uk.xensource.com> (raw)
In-Reply-To: <20180907151104.32306-16-anthony.perard@citrix.com>

Anthony PERARD writes ("[PATCH v5 15/15] libxl: Re-implement domain_suspend_device_model using libxl__ev_qmp"):
> The re-implementation is done because we want to be able to send the
> file description that QEMU can use to save its state. When QEMU is
> restricted, it would not be able to write to a path.

Thanks, this basically LGTM.  I have only very minor comments.

> -static bool qmp_qemu_check_version(libxl__qmp_handler *qmp, int major,
> -                                   int minor, int micro)
> +static bool qmp_ev_qemu_check_version(libxl__ev_qmp *ev, int major,
> +                                      int minor, int micro)
>  {
> -    return qmp->version.major > major ||
> -        (qmp->version.major == major &&
> -            (qmp->version.minor > minor ||
> -             (qmp->version.minor == minor && qmp->version.micro >= micro)));
> +    return ev->qemu_version.major > major ||
> +        (ev->qemu_version.major == major &&
> +            (ev->qemu_version.minor > minor ||
> +             (ev->qemu_version.minor == minor &&
> +              ev->qemu_version.micro >= micro)));

Not your fault, but:

Ow my eyes.  Does this not make you dizzy ?  How about a pre-patch
which replaces this with

#define CHECK(field) do{ \
   if (qmp->version.field > (field)) return +1; \
   if (qmp->version.field < (field)) return -1; \
  }while(0)
   CHECK(major);
   CHECK(minor);
   CHECK(micro);
   return 0;
#undef CHECK

?

Then your actual change here is

 -   if (qmp->version.field > (field)) return +1; \
 -   if (qmp->version.field < (field)) return -1; \
 +   if (ev->qemu_version.field > (field)) return +1; \
 +   if (ev->qemu_version.field < (field)) return -1; \

Or some such.

Up to you, anyway.  While your diff there is hard to read it is at
least making things no worse and the compiler would have spotted
a missed search-and-replace of qmp->version.  You did use
search-and-replace, didn't you ? :-)

> +/*
> + * Function using libxl__ev_qmp
> + */
> +
> +static void dm_stopped(libxl__egc *egc, libxl__ev_qmp *ev,
> +                       const libxl__json_object *response, int rc);
> +static void dm_state_fd_ready(libxl__egc *egc, libxl__ev_qmp *ev,
> +                              const libxl__json_object *response, int rc);
> +static void dm_state_saved(libxl__egc *egc, libxl__ev_qmp *ev,
> +                           const libxl__json_object *response, int rc);
> +int libxl__qmp_suspend_save(libxl__gc *gc, libxl__domain_suspend_state *dsps)

Would you mind adding a blank line just before `int
libxl__qmp_suspend_save' ?

> +    if (rc)
> +        goto error;
> +
> +    libxl__carefd_begin();
> +    ev->cfd = libxl__carefd_opened(CTX,
> +                                 open(filename, O_WRONLY | O_CREAT, 0600));

Does this statefile fd really need to be a carefd ?  Is it a pipe or a
file ?  If it is a file, is it of nontrivial size ?

If it's a file of a few kb, which I think is the case, then the worst
result of (with very low probability) leaking this fd into another
process is simply that the file might be kept alive for a while after
it was deleted.

> +    /* live parameter was added to QEMU 2.11. It signal QEMU that the save

          The `live' parameter                   It signals

> +     * operation is for a live migration rather that for taking a snapshot. */

                                            rather than

> +    if (qmp_ev_qemu_check_version(ev, 2, 11, 0))

If you adopt my proposal above then maybe qmp_ev_qemu_check_version
should be renamed qmp_ev_qemu_compare_version and you would then write

       if (qmp_ev_qemu_compare_version(ev, 2, 11, 0) >= 0) {

> +    if (rc)
> +        goto error;
> +
> +    return;
> +error:

I think a blank line before `error:' would be better.

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-10-16 15:29 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20181015151630.3887-1-ian.jackson@eu.citrix.com>
2018-09-07 15:10 ` [PATCH v5 00/15] libxl: Enable save/restore/migration of a restricted QEMU + libxl__ev_qmp_* Anthony PERARD
2018-09-07 15:10   ` [PATCH v5 01/15] libxl: Design of an async API to issue QMP commands to QEMU Anthony PERARD
2018-10-10 15:18     ` Ian Jackson
2018-10-11 11:17       ` Anthony PERARD
2018-10-11 11:21         ` Ian Jackson
2018-10-10 23:49     ` Marek Marczykowski-Górecki
2018-10-11 14:29       ` Anthony PERARD
2018-09-07 15:10   ` [PATCH v5 02/15] libxl_qmp: Connect to QMP socket Anthony PERARD
2018-10-10 15:29     ` Ian Jackson
2018-10-11 11:27       ` Anthony PERARD
2018-09-07 15:10   ` [PATCH v5 03/15] libxl_qmp: Implement fd callback and read data Anthony PERARD
2018-10-10 15:47     ` Ian Jackson
2018-10-11 14:06       ` Anthony PERARD
2018-10-15 14:04         ` Ian Jackson
2018-10-15 16:35         ` [PATCH v5 03/15] libxl_qmp: Implement fd callback and read data [and 1 more messages] Ian Jackson
2018-10-29 15:52           ` Anthony PERARD
2018-10-29 17:31             ` Ian Jackson
2018-10-30 18:03               ` Anthony PERARD
2018-10-30 18:25                 ` Ian Jackson
2018-09-07 15:10   ` [PATCH v5 04/15] libxl_qmp: Parse JSON input from QMP Anthony PERARD
2018-09-07 15:10   ` [PATCH v5 05/15] libxl_qmp: Separate QMP message generation from qmp_send_prepare Anthony PERARD
2018-09-07 15:10   ` [PATCH v5 06/15] libxl_qmp: Prepare the command to be sent Anthony PERARD
2018-09-07 15:10   ` [PATCH v5 07/15] libxl_qmp: Handle write to QMP socket Anthony PERARD
2018-09-07 15:10   ` [PATCH v5 08/15] libxl_qmp: Handle messages from QEMU Anthony PERARD
2018-09-07 15:10   ` [PATCH v5 09/15] libxl_qmp: Respond to QMP greeting Anthony PERARD
2018-09-07 15:10   ` [PATCH v5 10/15] libxl_exec: Add libxl__spawn_initiate_failure Anthony PERARD
2018-10-16 14:02     ` Ian Jackson
2018-11-09 12:26       ` Anthony PERARD
2018-09-07 15:11   ` [PATCH v5 11/15] libxl_dm: Pre-open QMP socket for QEMU Anthony PERARD
2018-10-16 14:11     ` Ian Jackson
2018-11-12 14:52       ` Anthony PERARD
2018-11-12 15:14         ` Ian Jackson
2018-11-12 15:22           ` Anthony PERARD
2018-11-12 15:54             ` Ian Jackson
2018-09-07 15:11   ` [PATCH v5 12/15] libxl: QEMU startup sync based on QMP Anthony PERARD
2018-10-16 14:23     ` Ian Jackson
2018-11-12 15:00       ` Anthony PERARD
2018-11-12 15:17         ` Ian Jackson
2018-09-07 15:11   ` [PATCH v5 13/15] libxl_qmp: Store advertised QEMU version in libxl__ev_qmp Anthony PERARD
2018-10-16 14:25     ` Ian Jackson
2018-09-07 15:11   ` [PATCH v5 14/15] libxl: Change libxl__domain_suspend_device_model() to be async Anthony PERARD
2018-10-16 15:14     ` Ian Jackson
2018-09-07 15:11   ` [PATCH v5 15/15] libxl: Re-implement domain_suspend_device_model using libxl__ev_qmp Anthony PERARD
2018-10-16 15:28     ` Ian Jackson [this message]
2018-11-09 16:59       ` Anthony PERARD
2018-11-09 17:11         ` Ian Jackson
2018-11-09 17:30           ` Anthony PERARD

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=23494.951.777903.157046@mariner.uk.xensource.com \
    --to=ian.jackson@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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.