[Qemu-devel] [PATCH 0/9] monitor: enable OOB by default

Peter Xu posted 9 patches 7 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180704084507.14560-1-peterx@redhat.com
Test checkpatch passed
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
Test s390x passed
There is a newer version of this series
docs/devel/qapi-code-gen.txt |   6 +-
qapi/misc.json               |  40 ---------
include/monitor/monitor.h    |   1 -
include/qapi/qmp-event.h     |   3 +-
tests/libqtest.h             |   4 +-
block/block-backend.c        |   8 +-
block/qcow2.c                |   2 +-
block/quorum.c               |   4 +-
block/write-threshold.c      |   3 +-
blockjob.c                   |  13 ++-
cpus.c                       |   8 +-
dump.c                       |   3 +-
hw/acpi/core.c               |   2 +-
hw/acpi/cpu.c                |   2 +-
hw/acpi/memory_hotplug.c     |   5 +-
hw/char/virtio-console.c     |   3 +-
hw/core/qdev.c               |   3 +-
hw/net/virtio-net.c          |   2 +-
hw/ppc/spapr_rtc.c           |   2 +-
hw/timer/mc146818rtc.c       |   2 +-
hw/virtio/virtio-balloon.c   |   3 +-
hw/watchdog/watchdog.c       |  15 ++--
job.c                        |   2 +-
migration/migration.c        |   4 +-
migration/ram.c              |   2 +-
monitor.c                    | 159 +++++++++++++++++++----------------
scsi/pr-manager-helper.c     |   3 +-
tests/libqtest.c             |  10 +--
tests/qmp-test.c             |   6 +-
tests/test-qmp-event.c       |  11 ++-
ui/spice-core.c              |  10 +--
ui/vnc.c                     |   7 +-
vl.c                         |  21 ++---
scripts/qapi/common.py       |   4 +-
scripts/qapi/events.py       |  23 ++---
35 files changed, 164 insertions(+), 232 deletions(-)
[Qemu-devel] [PATCH 0/9] monitor: enable OOB by default
Posted by Peter Xu 7 years, 4 months ago
Based-on: <20180703085358.13941-1-armbru@redhat.com>

This work is based on Markus's latest out-of-band fixes:
  "[PATCH v2 00/32] ] qmp: Fixes and cleanups around OOB commands"

Major stuff: some cleanups that were previously suggested by Markus or
Eric.  Meanwhile fix up the flow control issue.  Since my proposal
here is to drop COMMAND_DROPPED event, then we don't need to introduce
per-monitor event emission API any more.  Though Markus told me that
he might use that code somewhere else, so I'll post that per-monitor
event code out separately as RFC later.

Patch 1-3: cleanups.

Patch 4-7: solve the flow control issue reported by Markus that
response queue might overflow even if we have limitation on the
request queue.  Firstly we drop the COMMAND_DROP event since that
won't work for response queue (since queuing an event will need to
append to the response queue itself), then we use monitor suspend and
resume to control the flow.  Last, we apply that to response queue
too.

Patch 8-9: the original patches to enable out-of-band by default.

Tests: I didn't write flow control tests for qtest, however I tested
the program with this tiny tool "slowread":

        #include <unistd.h>
        #include <assert.h>

        int main(void)
        {
                char c;
                ssize_t ret;

                while (1) {
                        ret = read(STDIN_FILENO, &c, 1);
                        if (ret != 1)
                                break;
                        write(STDOUT_FILENO, &c, 1);
                        usleep(1000);
                }

                return 0;
        }

Basically it limits the read speed to 1000Bps.  Then I prepare a
command list "cmd_list":

        {"execute": "qmp_capabilities", "arguments": {"enable": ["oob"]}}
        {"execute": "query-status"}
        {"execute": "query-status"}
        .....
        {"execute": "query-status"}
        {"execute": "query-status"}

Then I run this to make sure it works well:

  $ cat cmd_list | qemu-system-x86_64 -qmp stdio -nographic -nodefaults | slowread

Please review.  Thanks,

Peter Xu (9):
  monitor: simplify monitor_qmp_setup_handlers_bh
  qapi: allow build_params to return "void"
  qapi: remove error checks for event emission
  monitor: move need_resume flag into monitor struct
  monitor: suspend monitor instead of send CMD_DROP
  qapi: remove COMMAND_DROPPED event
  monitor: restrict response queue length too
  monitor: remove "x-oob", turn oob on by default
  Revert "tests: Add parameter to qtest_init_without_qmp_handshake"

 docs/devel/qapi-code-gen.txt |   6 +-
 qapi/misc.json               |  40 ---------
 include/monitor/monitor.h    |   1 -
 include/qapi/qmp-event.h     |   3 +-
 tests/libqtest.h             |   4 +-
 block/block-backend.c        |   8 +-
 block/qcow2.c                |   2 +-
 block/quorum.c               |   4 +-
 block/write-threshold.c      |   3 +-
 blockjob.c                   |  13 ++-
 cpus.c                       |   8 +-
 dump.c                       |   3 +-
 hw/acpi/core.c               |   2 +-
 hw/acpi/cpu.c                |   2 +-
 hw/acpi/memory_hotplug.c     |   5 +-
 hw/char/virtio-console.c     |   3 +-
 hw/core/qdev.c               |   3 +-
 hw/net/virtio-net.c          |   2 +-
 hw/ppc/spapr_rtc.c           |   2 +-
 hw/timer/mc146818rtc.c       |   2 +-
 hw/virtio/virtio-balloon.c   |   3 +-
 hw/watchdog/watchdog.c       |  15 ++--
 job.c                        |   2 +-
 migration/migration.c        |   4 +-
 migration/ram.c              |   2 +-
 monitor.c                    | 159 +++++++++++++++++++----------------
 scsi/pr-manager-helper.c     |   3 +-
 tests/libqtest.c             |  10 +--
 tests/qmp-test.c             |   6 +-
 tests/test-qmp-event.c       |  11 ++-
 ui/spice-core.c              |  10 +--
 ui/vnc.c                     |   7 +-
 vl.c                         |  21 ++---
 scripts/qapi/common.py       |   4 +-
 scripts/qapi/events.py       |  23 ++---
 35 files changed, 164 insertions(+), 232 deletions(-)

-- 
2.17.1


Re: [Qemu-devel] [PATCH 0/9] monitor: enable OOB by default
Posted by Markus Armbruster 7 years, 3 months ago
Peter Xu <peterx@redhat.com> writes:

> Based-on: <20180703085358.13941-1-armbru@redhat.com>

Now in master.

> This work is based on Markus's latest out-of-band fixes:
>   "[PATCH v2 00/32] ] qmp: Fixes and cleanups around OOB commands"
>
> Major stuff: some cleanups that were previously suggested by Markus or
> Eric.  Meanwhile fix up the flow control issue.  Since my proposal
> here is to drop COMMAND_DROPPED event, then we don't need to introduce
> per-monitor event emission API any more.  Though Markus told me that
> he might use that code somewhere else, so I'll post that per-monitor
> event code out separately as RFC later.
>
> Patch 1-3: cleanups.

I expect these to be ready in the next version.

Since it's just cleanup, there's no need to rush these into 3.0 unless
they enable something we want in 3.0.

> Patch 4-7: solve the flow control issue reported by Markus that
> response queue might overflow even if we have limitation on the
> request queue.  Firstly we drop the COMMAND_DROP event since that
> won't work for response queue (since queuing an event will need to
> append to the response queue itself), then we use monitor suspend and
> resume to control the flow.  Last, we apply that to response queue
> too.

These need work.  We need to agree on how exactly flow control should
work.  Moreover, we need to reconcile your work with Marc-André's
"[PATCH 00/12] RFC: monitor: various code simplification and fixes"
(which I haven't fully reviewed yet).

> Patch 8-9: the original patches to enable out-of-band by default.

I figure these patches are good; we just need to decide whether we're
ready to enable OOB.  Let's review the known issues.

* We might want to make "id" mandatory with exec-oob

  Best to do that right in the first release that fully supports OOB.

* OOB offered but rejected by client is not obviously the same as
  OOB not offered

  I still need to digest and reply to your
  Message-ID: <20180629090115.GH2455@xz-mi>

* COMMAND_DROPPED is broken by design, and
* Flow control limits only request queue; response buffer can still
  grow without bounds

  You proposed to drop COMMAND_DROPPED, and do flow control by corking
  input, see above.

  Getting rid of broken COMMAND_DROPPED is a blocker.  Fully functional
  flow control isn't, since the QMP client is trusted.

* We lack test coverage for flow control
* test-qmp-cmds neglects to cover the OOB additions to qmp-dispatch.c

  I'm inclined to treating lack of test coverage as a blocker.

* scripts/qmp/ doesn't support OOB, yet.  qmp-shell.py in particular.

  Not a blocker.

Whatever we don't address right away we should at least mark FIXME in
the source code.

Assuming my list is complete, and my assessments correct, then we're
quite close to the point where we can enable OOB.  But since rc1 is
tomorrow already, I feel enabling it in 3.0 has become unrealistic.  I
understand we need it sooner rather than later for postcopy recovery.
However, the current state should be servicable for teaching OOB to
libvirt: just follow the recommendation to supply "id" (libvirt always
does anyway), pretend COMMAND_DROPPED doesn't exist, and pretend flow
control isn't an issue.

[...]

Re: [Qemu-devel] [PATCH 0/9] monitor: enable OOB by default
Posted by Peter Xu 7 years, 3 months ago
On Mon, Jul 16, 2018 at 07:18:28PM +0200, Markus Armbruster wrote:
> Peter Xu <peterx@redhat.com> writes:
> 
> > Based-on: <20180703085358.13941-1-armbru@redhat.com>
> 
> Now in master.
> 
> > This work is based on Markus's latest out-of-band fixes:
> >   "[PATCH v2 00/32] ] qmp: Fixes and cleanups around OOB commands"
> >
> > Major stuff: some cleanups that were previously suggested by Markus or
> > Eric.  Meanwhile fix up the flow control issue.  Since my proposal
> > here is to drop COMMAND_DROPPED event, then we don't need to introduce
> > per-monitor event emission API any more.  Though Markus told me that
> > he might use that code somewhere else, so I'll post that per-monitor
> > event code out separately as RFC later.
> >
> > Patch 1-3: cleanups.
> 
> I expect these to be ready in the next version.
> 
> Since it's just cleanup, there's no need to rush these into 3.0 unless
> they enable something we want in 3.0.
> 
> > Patch 4-7: solve the flow control issue reported by Markus that
> > response queue might overflow even if we have limitation on the
> > request queue.  Firstly we drop the COMMAND_DROP event since that
> > won't work for response queue (since queuing an event will need to
> > append to the response queue itself), then we use monitor suspend and
> > resume to control the flow.  Last, we apply that to response queue
> > too.
> 
> These need work.  We need to agree on how exactly flow control should
> work.  Moreover, we need to reconcile your work with Marc-André's
> "[PATCH 00/12] RFC: monitor: various code simplification and fixes"
> (which I haven't fully reviewed yet).

Sure.

> 
> > Patch 8-9: the original patches to enable out-of-band by default.
> 
> I figure these patches are good; we just need to decide whether we're
> ready to enable OOB.  Let's review the known issues.
> 
> * We might want to make "id" mandatory with exec-oob
> 
>   Best to do that right in the first release that fully supports OOB.

Yeah, I'd say I would prefer it that way, but after all we're having
that optional now in master, so it's fine for me in either way.

> 
> * OOB offered but rejected by client is not obviously the same as
>   OOB not offered
> 
>   I still need to digest and reply to your
>   Message-ID: <20180629090115.GH2455@xz-mi>

As a summary of the reply - I think the only difference is where we
run the chardev IOs for the monitor:

- When OOB not offered: we run chardev IOs in main thread

- When OOB offered but client rejected: we run chardev IOs in iothread

The rest of the things should be all the same.

> 
> * COMMAND_DROPPED is broken by design, and
> * Flow control limits only request queue; response buffer can still
>   grow without bounds
> 
>   You proposed to drop COMMAND_DROPPED, and do flow control by corking
>   input, see above.
> 
>   Getting rid of broken COMMAND_DROPPED is a blocker.  Fully functional
>   flow control isn't, since the QMP client is trusted.
> 
> * We lack test coverage for flow control
> * test-qmp-cmds neglects to cover the OOB additions to qmp-dispatch.c
> 
>   I'm inclined to treating lack of test coverage as a blocker.

I will look at this one before repost after 3.0.

> 
> * scripts/qmp/ doesn't support OOB, yet.  qmp-shell.py in particular.
> 
>   Not a blocker.

I'll possibly temporarily put this one aside.  If not, I'll leave a
FIXME there (or I'll just do).

> 
> Whatever we don't address right away we should at least mark FIXME in
> the source code.
> 
> Assuming my list is complete, and my assessments correct, then we're
> quite close to the point where we can enable OOB.  But since rc1 is
> tomorrow already, I feel enabling it in 3.0 has become unrealistic.  I
> understand we need it sooner rather than later for postcopy recovery.
> However, the current state should be servicable for teaching OOB to
> libvirt: just follow the recommendation to supply "id" (libvirt always
> does anyway), pretend COMMAND_DROPPED doesn't exist, and pretend flow
> control isn't an issue.

I guess the thing is not about COMMAND_DROPPED; it's about we're going
to drop the x-oob parameter.  Now we can only use that parameter to
enable out-of-band, and after we enable it by default we possibly want
to remove that x-oob parameter.  So we'd better provide a constant way
for libvirt to enable out-of-band first (and now I'll assume the
"exec-oob" interface won't change again).  But yes I think we can do
that after 3.0.

Thanks,

-- 
Peter Xu

Re: [Qemu-devel] [PATCH 0/9] monitor: enable OOB by default
Posted by Peter Xu 7 years, 3 months ago
On Tue, Jul 17, 2018 at 08:08:55PM +0800, Peter Xu wrote:

[...]

> > 
> > Whatever we don't address right away we should at least mark FIXME in
> > the source code.
> > 
> > Assuming my list is complete, and my assessments correct, then we're
> > quite close to the point where we can enable OOB.  But since rc1 is
> > tomorrow already, I feel enabling it in 3.0 has become unrealistic.  I
> > understand we need it sooner rather than later for postcopy recovery.
> > However, the current state should be servicable for teaching OOB to
> > libvirt: just follow the recommendation to supply "id" (libvirt always
> > does anyway), pretend COMMAND_DROPPED doesn't exist, and pretend flow
> > control isn't an issue.
> 
> I guess the thing is not about COMMAND_DROPPED; it's about we're going
> to drop the x-oob parameter.  Now we can only use that parameter to
> enable out-of-band, and after we enable it by default we possibly want
> to remove that x-oob parameter.  So we'd better provide a constant way
> for libvirt to enable out-of-band first (and now I'll assume the
> "exec-oob" interface won't change again).  But yes I think we can do
> that after 3.0.

Btw, note that patches 4-7 might still be candidates of bug fixes for
existing out-of-band feature.  It'll drop COMMAND_DROPPED event, but
IMHO it's still better than having a broken flow control for it (and
dropping event declaration is pretty safe even clients implemented
them).  Though the changes are not trivial, so I'll leave the decision
to you on whether we'll still consider them as 3.0 material.  Anyway,
please feel free to let me know if you want me to post them
separately.

Regards,

-- 
Peter Xu

Re: [Qemu-devel] [PATCH 0/9] monitor: enable OOB by default
Posted by Markus Armbruster 7 years, 3 months ago
Peter Xu <peterx@redhat.com> writes:

> On Tue, Jul 17, 2018 at 08:08:55PM +0800, Peter Xu wrote:
>
> [...]
>
>> > 
>> > Whatever we don't address right away we should at least mark FIXME in
>> > the source code.
>> > 
>> > Assuming my list is complete, and my assessments correct, then we're
>> > quite close to the point where we can enable OOB.  But since rc1 is
>> > tomorrow already, I feel enabling it in 3.0 has become unrealistic.  I
>> > understand we need it sooner rather than later for postcopy recovery.
>> > However, the current state should be servicable for teaching OOB to
>> > libvirt: just follow the recommendation to supply "id" (libvirt always
>> > does anyway), pretend COMMAND_DROPPED doesn't exist, and pretend flow
>> > control isn't an issue.
>> 
>> I guess the thing is not about COMMAND_DROPPED; it's about we're going
>> to drop the x-oob parameter.  Now we can only use that parameter to
>> enable out-of-band, and after we enable it by default we possibly want
>> to remove that x-oob parameter.  So we'd better provide a constant way
>> for libvirt to enable out-of-band first (and now I'll assume the
>> "exec-oob" interface won't change again).  But yes I think we can do
>> that after 3.0.

Yes, x-oob will go away right when OOB transitions from experimental to
supported.

I don't expect the request interface (exec-oob) to change, except we
might still make "id" mandatory.  Libvirt won't care, as it always
supplies "id".

If having to enable OOB with x-oob hampers libvirt work, I'd be willing
to enable OOB by default early in the 3.1 development cycle.  We can
always go back to disabled by default for the 3.1 release in case we
fail at getting it ready for 3.1,

> Btw, note that patches 4-7 might still be candidates of bug fixes for
> existing out-of-band feature.  It'll drop COMMAND_DROPPED event, but
> IMHO it's still better than having a broken flow control for it (and
> dropping event declaration is pretty safe even clients implemented
> them).  Though the changes are not trivial, so I'll leave the decision
> to you on whether we'll still consider them as 3.0 material.  Anyway,
> please feel free to let me know if you want me to post them
> separately.

Yes, COMMAND_DROPPED is flawed, and I dislike shipping flawed stuff as
much as you do.  However, it's clearly documented as flawed, and to get
it, you have to enable OOB with x-oob, where the x- clearly marks this
as experimental.

I think I'd rather not rock the boat now.