• E
    blockjob: allow omitted arguments to QMP block-commit · 47549d5a
    Eric Blake 提交于
    We are about to turn on support for active block commit.  Although
    qemu 2.0 was the first version to mostly support it, that version
    mis-handles 0-length files, and doesn't have anything available for
    easy probing.  But qemu 2.1 fixed bugs, and made life simpler by
    letting the 'top' argument be optional.  Unless someone begs for
    active commit with qemu 2.0, for now we are just going to enable
    it only by probing for qemu 2.1 behavior (anyone backporting active
    commit can also backport the optional argument behavior).  This
    requires qemu.git commit 7676e2c597000eff3a7233b40cca768b358f9bc9.
    
    Although all our actual uses of block-commit supply arguments for
    both base and top, we can omit both arguments and use a bogus
    device string to trigger an interesting behavior in qemu.  All QMP
    commands first do argument validation, failing with GenericError
    if a mandatory argument is missing.  Once that passes, the code
    in the specific command gets to do further checking, and the qemu
    developers made sure that if device is the only supplied argument,
    then the block-commit code will look up the device first, with a
    failure of DeviceNotFound, before attempting any further argument
    validation (most other validations fail with GenericError).  Thus,
    the category of error class can reliably be used to decipher
    whether the top argument was optional, which in turn implies a
    working active commit.  Since we expect our bogus device string to
    trigger an error either way, the code is written to return a
    distinct return value without spamming the logs.
    
    * src/qemu/qemu_monitor.h (qemuMonitorSupportsActiveCommit): New
    prototype.
    * src/qemu/qemu_monitor.c (qemuMonitorSupportsActiveCommit):
    Implement it.
    * src/qemu/qemu_monitor_json.h (qemuMonitorJSONBlockCommit):
    Allow NULL for top and base, for probing purposes.
    * src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockCommit):
    Likewise, implementing the probe.
    * tests/qemumonitorjsontest.c (mymain): Enable...
    (testQemuMonitorJSONqemuMonitorSupportsActiveCommit): ...a new test.
    Signed-off-by: NEric Blake <eblake@redhat.com>
    47549d5a
qemumonitorjsontest.c 79.1 KB