Generic background jobs
Subsystems (2)
PATCH 38/42 job: Add JOB_STATUS_CHANGE QMP event
In reply to Kevin WolfThis adds a QMP event that is emitted whenever a job transitions from one status to another. For the event, a new qapi/job.json schema file is created which will contain all job-related definitions that aren't tied to the block layer.
--- qapi/block-core.json | 47 +----------- qapi/job.json | 65 +++++++++++++++++ qapi/qapi-schema.json | 1 + job.c | 10 +++ Makefile | 9 +++ Makefile.objs | 4 + tests/qemu-iotests/030 | 6 +- tests/qemu-iotests/040 | 2 + tests/qemu-iotests/041 | 17 ++++- tests/qemu-iotests/095 | 2 +- tests/qemu-iotests/095.out | 6 ++ tests/qemu-iotests/109 | 2 +- tests/qemu-iotests/109.out | 178 +++++++++++++++++++++++++++++++++++++++------ tests/qemu-iotests/124 | 8 ++ tests/qemu-iotests/127.out | 7 ++ tests/qemu-iotests/141 | 10 +-- tests/qemu-iotests/141.out | 29 ++++++++ tests/qemu-iotests/144 | 2 +- tests/qemu-iotests/144.out | 7 ++ tests/qemu-iotests/156 | 2 +- tests/qemu-iotests/156.out | 7 ++ tests/qemu-iotests/185 | 12 +-- tests/qemu-iotests/185.out | 10 +++ tests/qemu-iotests/191 | 4 +- tests/qemu-iotests/191.out | 132 +++++++++++++++++++++++++++++++++ 25 files changed, 492 insertions(+), 87 deletions(-) create mode 100644 qapi/job.json
qapi/block-core.json +1 -46
@@ -6,6 +6,7 @@ { 'include': 'common.json' } { 'include': 'crypto.json' } +{ 'include': 'job.json' } { 'include': 'sockets.json' } ##
@@ -1093,52 +1094,6 @@ 'finalize' ] } ## -# @JobStatus: -# -# Indicates the present state of a given job in its lifetime. -# -# @undefined: Erroneous, default state. Should not ever be visible. -# -# @created: The job has been created, but not yet started. -# -# @running: The job is currently running. -# -# @paused: The job is running, but paused. The pause may be requested by -# either the QMP user or by internal processes. -# -# @ready: The job is running, but is ready for the user to signal completion. -# This is used for long-running jobs like mirror that are designed to -# run indefinitely. -# -# @standby: The job is ready, but paused. This is nearly identical to @paused. -# The job may return to @ready or otherwise be canceled. -# -# @waiting: The job is waiting for other jobs in the transaction to converge -# to the waiting state. This status will likely not be visible for -# the last job in a transaction. -# -# @pending: The job has finished its work, but has finalization steps that it -# needs to make prior to completing. These changes may require -# manual intervention by the management process if manual was set -# to true. These changes may still fail. -# -# @aborting: The job is in the process of being aborted, and will finish with -# an error. The job will afterwards report that it is @concluded. -# This status may not be visible to the management process. -# -# @concluded: The job has finished all work. If manual was set to true, the job -# will remain in the query list until it is dismissed. -# -# @null: The job is in the process of being dismantled. This state should not -# ever be visible externally. -# -# Since: 2.12 -## -{ 'enum': 'JobStatus', - 'data': ['undefined', 'created', 'running', 'paused', 'ready', 'standby', - 'waiting', 'pending', 'aborting', 'concluded', 'null' ] } - -## # @BlockJobInfo: # # Information about a long-running block device operation.
qapi/job.json new file +65 -0
65 lines not on this page · raw message
qapi/qapi-schema.json +1 -0
@@ -84,6 +84,7 @@ { 'include': 'crypto.json' } { 'include': 'block.json' } { 'include': 'char.json' } +{ 'include': 'job.json' } { 'include': 'net.json' } { 'include': 'rocker.json' } { 'include': 'tpm.json' }
job.c +10 -0
@@ -30,6 +30,7 @@#include "qemu/id.h" #include "qemu/main-loop.h" #include "trace-root.h" +#include "qapi/qapi-events-job.h" static QLIST_HEAD(, Job) jobs = QLIST_HEAD_INITIALIZER(jobs);
@@ -157,6 +158,11 @@ static int job_txn_apply(JobTxn *txn, int fn(Job *), bool lock)return rc; } +static bool job_is_internal (Job *job) +{ +return (job->id ==NULL ); +} +static void job_state_transition (Job *job,JobStatus s1) {JobStatus s0 = job->status;
@@ -166,6 +172,10 @@ static void job_state_transition(Job *job, JobStatus s1) JobStatus_str(s0), JobStatus_str(s1));assert (JobSTT[s0][s1]); job->status = s1; + +if (!job_is_internal (job) && s1 != s0) { +qapi_event_send_job_status_change (job->id, job->status, &error_abort); + } }int job_apply_verb (Job *job,JobVerb bv,Error **errp)
Makefile +9 -0
@@ -98,6 +98,7 @@ GENERATED_FILES += qapi/qapi-types-char.h qapi/qapi-types-char.c GENERATED_FILES += qapi/qapi-types-common.h qapi/qapi-types-common.c GENERATED_FILES += qapi/qapi-types-crypto.h qapi/qapi-types-crypto.c GENERATED_FILES += qapi/qapi-types-introspect.h qapi/qapi-types-introspect.c +GENERATED_FILES += qapi/qapi-types-job.h qapi/qapi-types-job.c GENERATED_FILES += qapi/qapi-types-migration.h qapi/qapi-types-migration.c GENERATED_FILES += qapi/qapi-types-misc.h qapi/qapi-types-misc.c GENERATED_FILES += qapi/qapi-types-net.h qapi/qapi-types-net.c
@@ -116,6 +117,7 @@ GENERATED_FILES += qapi/qapi-visit-char.h qapi/qapi-visit-char.c GENERATED_FILES += qapi/qapi-visit-common.h qapi/qapi-visit-common.c GENERATED_FILES += qapi/qapi-visit-crypto.h qapi/qapi-visit-crypto.c GENERATED_FILES += qapi/qapi-visit-introspect.h qapi/qapi-visit-introspect.c +GENERATED_FILES += qapi/qapi-visit-job.h qapi/qapi-visit-job.c GENERATED_FILES += qapi/qapi-visit-migration.h qapi/qapi-visit-migration.c GENERATED_FILES += qapi/qapi-visit-misc.h qapi/qapi-visit-misc.c GENERATED_FILES += qapi/qapi-visit-net.h qapi/qapi-visit-net.c
@@ -133,6 +135,7 @@ GENERATED_FILES += qapi/qapi-commands-char.h qapi/qapi-commands-char.c GENERATED_FILES += qapi/qapi-commands-common.h qapi/qapi-commands-common.c GENERATED_FILES += qapi/qapi-commands-crypto.h qapi/qapi-commands-crypto.c GENERATED_FILES += qapi/qapi-commands-introspect.h qapi/qapi-commands-introspect.c +GENERATED_FILES += qapi/qapi-commands-job.h qapi/qapi-commands-job.c GENERATED_FILES += qapi/qapi-commands-migration.h qapi/qapi-commands-migration.c GENERATED_FILES += qapi/qapi-commands-misc.h qapi/qapi-commands-misc.c GENERATED_FILES += qapi/qapi-commands-net.h qapi/qapi-commands-net.c
@@ -150,6 +153,7 @@ GENERATED_FILES += qapi/qapi-events-char.h qapi/qapi-events-char.c GENERATED_FILES += qapi/qapi-events-common.h qapi/qapi-events-common.c GENERATED_FILES += qapi/qapi-events-crypto.h qapi/qapi-events-crypto.c GENERATED_FILES += qapi/qapi-events-introspect.h qapi/qapi-events-introspect.c +GENERATED_FILES += qapi/qapi-events-job.h qapi/qapi-events-job.c GENERATED_FILES += qapi/qapi-events-migration.h qapi/qapi-events-migration.c GENERATED_FILES += qapi/qapi-events-misc.h qapi/qapi-events-misc.c GENERATED_FILES += qapi/qapi-events-net.h qapi/qapi-events-net.c
@@ -582,6 +586,7 @@ qapi-modules = $(SRC_PATH)/qapi/qapi-schema.json $(SRC_PATH)/qapi/common.json \ $(SRC_PATH)/qapi/char.json \ $(SRC_PATH)/qapi/crypto.json \ $(SRC_PATH)/qapi/introspect.json \ + $(SRC_PATH)/qapi/job.json \ $(SRC_PATH)/qapi/migration.json \ $(SRC_PATH)/qapi/misc.json \ $(SRC_PATH)/qapi/net.json \
@@ -601,6 +606,7 @@ qapi/qapi-types-char.c qapi/qapi-types-char.h \ qapi/qapi-types-common.c qapi/qapi-types-common.h \ qapi/qapi-types-crypto.c qapi/qapi-types-crypto.h \ qapi/qapi-types-introspect.c qapi/qapi-types-introspect.h \ +qapi/qapi-types-job.c qapi/qapi-types-job.h \ qapi/qapi-types-migration.c qapi/qapi-types-migration.h \ qapi/qapi-types-misc.c qapi/qapi-types-misc.h \ qapi/qapi-types-net.c qapi/qapi-types-net.h \
@@ -619,6 +625,7 @@ qapi/qapi-visit-char.c qapi/qapi-visit-char.h \ qapi/qapi-visit-common.c qapi/qapi-visit-common.h \ qapi/qapi-visit-crypto.c qapi/qapi-visit-crypto.h \ qapi/qapi-visit-introspect.c qapi/qapi-visit-introspect.h \ +qapi/qapi-visit-job.c qapi/qapi-visit-job.h \ qapi/qapi-visit-migration.c qapi/qapi-visit-migration.h \ qapi/qapi-visit-misc.c qapi/qapi-visit-misc.h \ qapi/qapi-visit-net.c qapi/qapi-visit-net.h \
@@ -636,6 +643,7 @@ qapi/qapi-commands-char.c qapi/qapi-commands-char.h \ qapi/qapi-commands-common.c qapi/qapi-commands-common.h \ qapi/qapi-commands-crypto.c qapi/qapi-commands-crypto.h \ qapi/qapi-commands-introspect.c qapi/qapi-commands-introspect.h \ +qapi/qapi-commands-job.c qapi/qapi-commands-job.h \ qapi/qapi-commands-migration.c qapi/qapi-commands-migration.h \ qapi/qapi-commands-misc.c qapi/qapi-commands-misc.h \ qapi/qapi-commands-net.c qapi/qapi-commands-net.h \
@@ -653,6 +661,7 @@ qapi/qapi-events-char.c qapi/qapi-events-char.h \ qapi/qapi-events-common.c qapi/qapi-events-common.h \ qapi/qapi-events-crypto.c qapi/qapi-events-crypto.h \ qapi/qapi-events-introspect.c qapi/qapi-events-introspect.h \ +qapi/qapi-events-job.c qapi/qapi-events-job.h \ qapi/qapi-events-migration.c qapi/qapi-events-migration.h \ qapi/qapi-events-misc.c qapi/qapi-events-misc.h \ qapi/qapi-events-net.c qapi/qapi-events-net.h \
Makefile.objs +4 -0
@@ -10,6 +10,7 @@ util-obj-y += qapi/qapi-types-char.o util-obj-y += qapi/qapi-types-common.o util-obj-y += qapi/qapi-types-crypto.o util-obj-y += qapi/qapi-types-introspect.o +util-obj-y += qapi/qapi-types-job.o util-obj-y += qapi/qapi-types-migration.o util-obj-y += qapi/qapi-types-misc.o util-obj-y += qapi/qapi-types-net.o
@@ -28,6 +29,7 @@ util-obj-y += qapi/qapi-visit-char.o util-obj-y += qapi/qapi-visit-common.o util-obj-y += qapi/qapi-visit-crypto.o util-obj-y += qapi/qapi-visit-introspect.o +util-obj-y += qapi/qapi-visit-job.o util-obj-y += qapi/qapi-visit-migration.o util-obj-y += qapi/qapi-visit-misc.o util-obj-y += qapi/qapi-visit-net.o
@@ -45,6 +47,7 @@ util-obj-y += qapi/qapi-events-char.o util-obj-y += qapi/qapi-events-common.o util-obj-y += qapi/qapi-events-crypto.o util-obj-y += qapi/qapi-events-introspect.o +util-obj-y += qapi/qapi-events-job.o util-obj-y += qapi/qapi-events-migration.o util-obj-y += qapi/qapi-events-misc.o util-obj-y += qapi/qapi-events-net.o
@@ -140,6 +143,7 @@ common-obj-y += qapi/qapi-commands-char.o common-obj-y += qapi/qapi-commands-common.o common-obj-y += qapi/qapi-commands-crypto.o common-obj-y += qapi/qapi-commands-introspect.o +common-obj-y += qapi/qapi-commands-job.o common-obj-y += qapi/qapi-commands-migration.o common-obj-y += qapi/qapi-commands-misc.o common-obj-y += qapi/qapi-commands-net.o
tests/qemu-iotests/030 +4 -2
@@ -304,7 +304,7 @@ class TestParallelOps(iotests.QMPTestCase): result = self.vm.qmp('block-stream', device='node5', base=self.imgs[3], job_id='stream-node6') self.assert_qmp(result, 'error/class', 'GenericError') - event = self.vm.get_qmp_event(wait=True) + event = self.vm.event_wait(name='BLOCK_JOB_READY') self.assertEqual(event['event'], 'BLOCK_JOB_READY') self.assert_qmp(event, 'data/device', 'commit-drive0') self.assert_qmp(event, 'data/type', 'commit')
@@ -751,7 +751,9 @@ class TestStreamStop(iotests.QMPTestCase): time.sleep(0.1) events = self.vm.get_qmp_events(wait=False) - self.assertEqual(events, [], 'unexpected QMP event: %s' % events) + for e in events: + if e['event'] != 'JOB_STATUS_CHANGE': + self.assertEqual(events, [], 'unexpected QMP event: %s' % events) self.cancel_and_wait(resume=True)
tests/qemu-iotests/040 +2 -0
@@ -162,6 +162,8 @@ class TestSingleDrive(ImageCommitTestCase): elif event['event'] == 'BLOCK_JOB_CANCELLED': self.assert_qmp(event, 'data/device', 'drive0') cancelled = True + elif event['event'] == 'JOB_STATUS_CHANGE': + self.assert_qmp(event, 'data/id', 'drive0') else: self.fail("Unexpected event %s" % (event['event']))
tests/qemu-iotests/041 +16 -1
@@ -445,6 +445,8 @@ new_state = "1" self.assert_qmp(event, 'data/device', 'drive0') self.assert_qmp(event, 'data/error', 'Input/output error') completed = True + elif event['event'] == 'JOB_STATUS_CHANGE': + self.assert_qmp(event, 'data/id', 'drive0') self.assert_no_active_block_jobs() self.vm.shutdown()
@@ -457,6 +459,10 @@ new_state = "1" self.assert_qmp(result, 'return', {}) event = self.vm.get_qmp_event(wait=True) + while event['event'] == 'JOB_STATUS_CHANGE': + self.assert_qmp(event, 'data/id', 'drive0') + event = self.vm.get_qmp_event(wait=True) + self.assertEquals(event['event'], 'BLOCK_JOB_ERROR') self.assert_qmp(event, 'data/device', 'drive0') self.assert_qmp(event, 'data/operation', 'read')
@@ -478,6 +484,10 @@ new_state = "1" self.assert_qmp(result, 'return', {}) event = self.vm.get_qmp_event(wait=True) + while event['event'] == 'JOB_STATUS_CHANGE': + self.assert_qmp(event, 'data/id', 'drive0') + event = self.vm.get_qmp_event(wait=True) + self.assertEquals(event['event'], 'BLOCK_JOB_ERROR') self.assert_qmp(event, 'data/device', 'drive0') self.assert_qmp(event, 'data/operation', 'read')
@@ -608,7 +618,7 @@ new_state = "1" on_target_error='ignore') self.assert_qmp(result, 'return', {}) - event = self.vm.get_qmp_event(wait=True) + event = self.vm.event_wait(name='BLOCK_JOB_ERROR') self.assertEquals(event['event'], 'BLOCK_JOB_ERROR') self.assert_qmp(event, 'data/device', 'drive0') self.assert_qmp(event, 'data/operation', 'write')
@@ -784,7 +794,12 @@ class TestGranularity(iotests.QMPTestCase): sync='full', target=target_img, mode='absolute-paths', granularity=8192) self.assert_qmp(result, 'return', {}) + event = self.vm.get_qmp_event(wait=60.0) + while event['event'] == 'JOB_STATUS_CHANGE': + self.assert_qmp(event, 'data/id', 'drive0') + event = self.vm.get_qmp_event(wait=60.0) + # Failures will manifest as COMPLETED/ERROR. self.assert_qmp(event, 'event', 'BLOCK_JOB_READY') self.complete_and_wait(drive='drive0', wait_ready=False)
tests/qemu-iotests/095 +1 -1
@@ -72,7 +72,7 @@ _send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return" _send_qemu_cmd $h "{ 'execute': 'block-commit', 'arguments': { 'device': 'test', - 'top': '"${TEST_IMG}.snp1"' } }" "BLOCK_JOB_COMPLETED" + 'top': '"${TEST_IMG}.snp1"' } }" '"status": "null"' _cleanup_qemu
tests/qemu-iotests/095.out +6 -0
@@ -11,8 +11,14 @@ virtual size: 5.0M (5242880 bytes) === Running QEMU Live Commit Test === {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "test"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "test"}} {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "test"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "test"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "test", "len": 104857600, "offset": 104857600, "speed": 0, "type": "commit"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "test"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "test"}} === Base image info after commit and resize === image: TEST_DIR/t.IMGFMT.base
tests/qemu-iotests/109 +1 -1
@@ -64,7 +64,7 @@ function run_qemu() _send_qemu_cmd $QEMU_HANDLE '' "$qmp_event" if test "$qmp_event" = BLOCK_JOB_ERROR; then - _send_qemu_cmd $QEMU_HANDLE '' "BLOCK_JOB_COMPLETED" + _send_qemu_cmd $QEMU_HANDLE '' '"status": "null"' fi _send_qemu_cmd $QEMU_HANDLE '{"execute":"query-block-jobs"}' "return" _send_qemu_cmd $QEMU_HANDLE '{"execute":"quit"}' "return"
tests/qemu-iotests/109.out +156 -22
409 lines not on this page · raw message
tests/qemu-iotests/124 +8 -0
@@ -151,10 +151,17 @@ class TestIncrementalBackupBase(iotests.QMPTestCase): return self.wait_qmp_backup(kwargs['device'], error) + def ignore_job_status_change_events(self): + while True: + e = self.vm.event_wait(name="JOB_STATUS_CHANGE") + if e['data']['status'] == 'null': + break + def wait_qmp_backup(self, device, error='Input/output error'): event = self.vm.event_wait(name="BLOCK_JOB_COMPLETED", match={'data': {'device': device}}) self.assertNotEqual(event, None) + self.ignore_job_status_change_events() try: failure = self.dictpath(event, 'data/error')
@@ -172,6 +179,7 @@ class TestIncrementalBackupBase(iotests.QMPTestCase): event = self.vm.event_wait(name='BLOCK_JOB_CANCELLED', match={'data': {'device': device}}) self.assertNotEqual(event, None) + self.ignore_job_status_change_events() def create_anchor_backup(self, drive=None):
tests/qemu-iotests/127.out +7 -0
@@ -5,10 +5,17 @@ Formatting 'TEST_DIR/t.IMGFMT.overlay1', fmt=IMGFMT size=65536 backing_file=TEST wrote 42/42 bytes at offset 0 42 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "mirror"}} {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "mirror", "len": 65536, "offset": 65536, "speed": 0, "type": "mirror"}} {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "mirror", "len": 65536, "offset": 65536, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "mirror"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} *** done
tests/qemu-iotests/141 +5 -5
@@ -107,7 +107,7 @@ test_blockjob \ 'format': '$IMGFMT', 'sync': 'none'}}" \ 'return' \ - 'BLOCK_JOB_CANCELLED' + '"status": "null"' echo echo '=== Testing drive-mirror ==='
@@ -124,7 +124,7 @@ test_blockjob \ 'format': '$IMGFMT', 'sync': 'none'}}" \ 'BLOCK_JOB_READY' \ - 'BLOCK_JOB_COMPLETED' + '"status": "null"' echo echo '=== Testing active block-commit ==='
@@ -138,7 +138,7 @@ test_blockjob \ "{'execute': 'block-commit', 'arguments': {'job-id': 'job0', 'device': 'drv0'}}" \ 'BLOCK_JOB_READY' \ - 'BLOCK_JOB_COMPLETED' + '"status": "null"' echo echo '=== Testing non-active block-commit ==='
@@ -157,7 +157,7 @@ test_blockjob \ 'top': '$TEST_DIR/m.$IMGFMT', 'speed': 1}}" \ 'return' \ - 'BLOCK_JOB_CANCELLED' + '"status": "null"' echo echo '=== Testing block-stream ==='
@@ -179,7 +179,7 @@ test_blockjob \ 'device': 'drv0', 'speed': 1}}" \ 'return' \ - 'BLOCK_JOB_CANCELLED' + '"status": "null"' _cleanup_qemu
tests/qemu-iotests/141.out +29 -0
@@ -8,31 +8,50 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/m. {"return": {}} Formatting 'TEST_DIR/o.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT backing_fmt=IMGFMT +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} {"return": {}} {"error": {"class": "GenericError", "desc": "Node drv0 is in use"}} {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "job0", "len": 1048576, "offset": 0, "speed": 0, "type": "backup"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} {"return": {}} === Testing drive-mirror === {"return": {}} Formatting 'TEST_DIR/o.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT backing_fmt=IMGFMT +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "mirror"}} {"return": {}} {"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: node is used as backing hd of 'NODE_NAME'"}} {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} {"return": {}} === Testing active block-commit === {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} {"return": {}} {"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: node is used as backing hd of 'NODE_NAME'"}} {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} {"return": {}} === Testing non-active block-commit ===
@@ -40,10 +59,15 @@ Formatting 'TEST_DIR/o.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t. wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} {"return": {}} {"error": {"class": "GenericError", "desc": "Node drv0 is in use"}} {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "job0", "len": 1048576, "offset": 524288, "speed": 1, "type": "commit"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} {"return": {}} === Testing block-stream ===
@@ -51,9 +75,14 @@ wrote 1048576/1048576 bytes at offset 0 wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} {"return": {}} {"error": {"class": "GenericError", "desc": "Node drv0 is in use"}} {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "job0", "len": 1048576, "offset": 524288, "speed": 1, "type": "stream"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} {"return": {}} *** done
tests/qemu-iotests/144 +1 -1
@@ -93,7 +93,7 @@ _send_qemu_cmd $h "{ 'execute': 'block-job-complete', 'arguments': { 'device': 'virtio0' } - }" "COMPLETED" + }" '"status": "null"' echo echo === Performing Live Snapshot 2 ===
tests/qemu-iotests/144.out +7 -0
@@ -12,10 +12,17 @@ Formatting 'TEST_DIR/tmp.qcow2', fmt=qcow2 size=536870912 backing_file=TEST_DIR/ === Performing block-commit on active layer === +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "virtio0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "virtio0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "virtio0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "virtio0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} {"return": {}} {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "virtio0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "virtio0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "virtio0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "virtio0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "virtio0"}} === Performing Live Snapshot 2 ===
tests/qemu-iotests/156 +1 -1
@@ -119,7 +119,7 @@ _send_qemu_cmd $QEMU_HANDLE \ _send_qemu_cmd $QEMU_HANDLE \ '' \ - 'BLOCK_JOB_COMPLETED' + '"status": "null"' # Remove the source images rm -f "$TEST_IMG{,.backing,.overlay}"
tests/qemu-iotests/156.out +7 -0
@@ -12,13 +12,20 @@ wrote 131072/131072 bytes at offset 131072 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} Formatting 'TEST_DIR/t.IMGFMT.target.overlay', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT.target +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "source"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "source"}} {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "source"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "source", "len": 131072, "offset": 131072, "speed": 0, "type": "mirror"}} wrote 65536/65536 bytes at offset 196608 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "source"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "source"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "source", "len": 196608, "offset": 196608, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "source"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "source"}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
tests/qemu-iotests/185 +7 -5
@@ -118,8 +118,10 @@ _send_qemu_cmd $h \ 'speed': 65536 } }" \ "return" +# Ignore the JOB_STATUS_CHANGE events while shutting down the VM. Depending on +# the timing, jobs may or may not transition through a paused state. _send_qemu_cmd $h "{ 'execute': 'quit' }" "return" -wait=1 _cleanup_qemu +wait=1 _cleanup_qemu | grep -v 'JOB_STATUS_CHANGE' echo echo === Start active commit job and exit qemu ===
@@ -138,7 +140,7 @@ _send_qemu_cmd $h \ "return" _send_qemu_cmd $h "{ 'execute': 'quit' }" "return" -wait=1 _cleanup_qemu +wait=1 _cleanup_qemu | grep -v 'JOB_STATUS_CHANGE' echo echo === Start mirror job and exit qemu ===
@@ -163,7 +165,7 @@ _send_qemu_cmd $h \ sleep 0.5 _send_qemu_cmd $h "{ 'execute': 'quit' }" "return" -wait=1 _cleanup_qemu +wait=1 _cleanup_qemu | grep -v 'JOB_STATUS_CHANGE' echo echo === Start backup job and exit qemu ===
@@ -184,7 +186,7 @@ _send_qemu_cmd $h \ "return" _send_qemu_cmd $h "{ 'execute': 'quit' }" "return" -wait=1 _cleanup_qemu +wait=1 _cleanup_qemu | grep -v 'JOB_STATUS_CHANGE' echo echo === Start streaming job and exit qemu ===
@@ -202,7 +204,7 @@ _send_qemu_cmd $h \ "return" _send_qemu_cmd $h "{ 'execute': 'quit' }" "return" -wait=1 _cleanup_qemu +wait=1 _cleanup_qemu | grep -v 'JOB_STATUS_CHANGE' _check_test_img
tests/qemu-iotests/185.out +10 -0
@@ -17,6 +17,8 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q === Start commit job and exit qemu === +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
@@ -25,6 +27,8 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q === Start active commit job and exit qemu === {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
@@ -35,6 +39,8 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q {"return": {}} Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16 +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
@@ -45,6 +51,8 @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 l {"return": {}} Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16 +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
@@ -53,6 +61,8 @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 l === Start streaming job and exit qemu === {"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
tests/qemu-iotests/191 +2 -2
@@ -83,7 +83,7 @@ _send_qemu_cmd $h \ 'device': 'top', 'base':'$TEST_IMG.base', 'top': '$TEST_IMG.mid' } }" \ - "BLOCK_JOB_COMPLETED" + '"status": "null"' _send_qemu_cmd $h "" "^}" echo
@@ -131,7 +131,7 @@ _send_qemu_cmd $h \ 'device': 'top', 'base':'$TEST_IMG.base', 'top': '$TEST_IMG.mid' } }" \ - "BLOCK_JOB_COMPLETED" + '"status": "null"' _send_qemu_cmd $h "" "^}" echo
tests/qemu-iotests/191.out +132 -0
168 lines not on this page · raw message
Signature · 1 line
2.13.6
Re: [Qemu-devel] [PATCH 38/42] job: Add JOB_STATUS_CHANGE QMP event
Quoted 26 lines · Kevin Wolf
This adds a QMP event that is emitted whenever a job transitions from one status to another. For the event, a new
qapi/job.jsonschema file is created which will contain all job-related definitions that aren't tied to the block layer.Signed-off-by Kevin Wolf <[email protected]>--- qapi/block-core.json | 47 +----------- qapi/job.json | 65 +++++++++++++++++ qapi/qapi-schema.json | 1 + job.c | 10 +++ Makefile | 9 +++ Makefile.objs | 4 + tests/qemu-iotests/030 | 6 +- tests/qemu-iotests/040 | 2 + tests/qemu-iotests/041 | 17 ++++- tests/qemu-iotests/095 | 2 +- tests/qemu-iotests/095.out | 6 ++ tests/qemu-iotests/109 | 2 +- tests/qemu-iotests/109.out | 178 +++++++++++++++++++++++++++++++++++++++------ tests/qemu-iotests/124 | 8 ++ tests/qemu-iotests/127.out | 7 ++ tests/qemu-iotests/141 | 10 +-- tests/qemu-iotests/141.out | 29 ++++++++ tests/qemu-iotests/144 | 2 +- tests/qemu-iotests/144.out | 7 ++
Quoted 8 lines
tests/qemu-iotests/156 | 2 +- tests/qemu-iotests/156.out | 7 ++ tests/qemu-iotests/185 | 12 +-- tests/qemu-iotests/185.out | 10 +++ tests/qemu-iotests/191 | 4 +- tests/qemu-iotests/191.out | 132 +++++++++++++++++++++++++++++++++ 25 files changed, 492 insertions(+), 87 deletions(-) create mode 100644 qapi/job.json
Your effort to keep this series in 42 patches in Ehren, but I think it would make sense to have a separate patch that creates qapi/job.json. ;-)
[...]
tests/qemu-iotests/030 class TestParallelOps(iotests.QMPTestCase): · line 308
Quoted 11 lines
tests/qemu-iotests/030 +1
-1@@ -304,7 +304,7 @@ class TestParallelOps(iotests.QMPTestCase): result = self.vm.qmp('block-stream', device='node5', base=self.imgs[3], job_id='stream-node6') self.assert_qmp(result, 'error/class', 'GenericError') - event = self.vm.get_qmp_event(wait=True) + event = self.vm.event_wait(name='BLOCK_JOB_READY') self.assertEqual(event['event'], 'BLOCK_JOB_READY')
This assertion is a bit useless, now, but whatever.
tests/qemu-iotests/030 class TestStreamStop(iotests.QMPTestCase): · line 756
Quoted 10 lines
tests/qemu-iotests/030 +3
-1self.assert_qmp(event, 'data/device', 'commit-drive0') self.assert_qmp(event, 'data/type', 'commit')@@ -751,7 +751,9 @@ class TestStreamStop(iotests.QMPTestCase): time.sleep(0.1) events = self.vm.get_qmp_events(wait=False) - self.assertEqual(events, [], 'unexpected QMP event: %s' % events) + for e in events: + if e['event'] != 'JOB_STATUS_CHANGE': + self.assertEqual(events, [], 'unexpected QMP event: %s' % events)
self.fail() would be nicer to read.
Quoted 3 lines
tests/qemu-iotests/030 +0
-0self.cancel_and_wait(resume=True)
[...]
tests/qemu-iotests/041 new_state = "1" · line 449
Quoted 10 lines
tests/qemu-iotests/041 +2
-0@@ -445,6 +445,8 @@ new_state = "1" self.assert_qmp(event, 'data/device', 'drive0') self.assert_qmp(event, 'data/error', 'Input/output error') completed = True + elif event['event'] == 'JOB_STATUS_CHANGE': + self.assert_qmp(event, 'data/id', 'drive0')
There were plenty of such loops in 030. Why did you leave them as they are and add this check here?
(I can understand it in the previous hunk, because that one has an else branch, but this one does not.)
((And if you decide to always do this check, iotests.py needs it, too.))
tests/qemu-iotests/041 new_state = "1" · line 466
Quoted 12 lines
tests/qemu-iotests/041 +4
-0self.assert_no_active_block_jobs() self.vm.shutdown()@@ -457,6 +459,10 @@ new_state = "1" self.assert_qmp(result, 'return', {}) event = self.vm.get_qmp_event(wait=True) + while event['event'] == 'JOB_STATUS_CHANGE': + self.assert_qmp(event, 'data/id', 'drive0') + event = self.vm.get_qmp_event(wait=True) + self.assertEquals(event['event'], 'BLOCK_JOB_ERROR')
Wouldn't this be simpler with
event = self.vm.event_wait(name='BLOCK_JOB_ERROR')?
Same in other hunks in this file.
(And technically in all cases (like 056) that use event_wait already.)
(Sure, if you want to check @id... But then you'd have to do the same in 030. And I don't quite see the point of checking JOB_STATUS_CHANGE just sporadically, and not even checking the target status.)
Quoted 2 lines
tests/qemu-iotests/041 +0
-0self.assert_qmp(event, 'data/device', 'drive0') self.assert_qmp(event, 'data/operation', 'read')
[...]
Quoted 4 lines
tests/qemu-iotests/141 +0
-0
[...]
tests/qemu-iotests/141 test_blockjob \ · line 183
Quoted 7 lines
tests/qemu-iotests/141 +1
-1@@ -179,7 +179,7 @@ test_blockjob \ 'device': 'drv0', 'speed': 1}}" \ 'return' \ - 'BLOCK_JOB_CANCELLED' + '"status": "null"'
The comment above this hunk says that "no event other than BLOCK_JOB_CANCELLED will be emitted". It would make sense to change it to e.g. "no block job event other than [...]".
tests/qemu-iotests/141 test_blockjob \ · line 185
Quoted 2 lines
tests/qemu-iotests/141 +0
-0_cleanup_qemu
[...]
You forgot to adjust 094, and although I cannot prove it (I don't have an nfs setup handy right now), I have a hunch that this patch breaks 173 as well.
Max
Re: [Qemu-devel] [PATCH 38/42] job: Add JOB_STATUS_CHANGE QMP event
Am 15.05.2018 um 00:11 hat Max Reitz geschrieben:
Quoted 3 lines
You forgot to adjust 094, and although I cannot prove it (I don't have an nfs setup handy right now), I have a hunch that this patch breaks 173 as well.
NFS qemu-iotests look completely broken. And the block driver, too. I've sent a fix for the block driver at least...
Not sure how the qemu-iotests are supposed to work, but I get messages like these:
+mkdir: cannot create directory 'nfs://127.0.0.1//home/kwolf/source/qemu/tests/qemu-iotests/scratch': No such file or directory +common.config: Error: $TEST_DIR (nfs://127.0.0.1//home/kwolf/source/qemu/tests/qemu-iotests/scratch) is not a directory
I guess I'm okay with breaking 173 in this series when the NFS tests are in this state...
Kevin
Re: [Qemu-devel] [PATCH 38/42] job: Add JOB_STATUS_CHANGE QMP event
In reply to Kevin WolfQuoted 13 lines · Kevin Wolf
This adds a QMP event that is emitted whenever a job transitions from one status to another. For the event, a new
qapi/job.jsonschema file is created which will contain all job-related definitions that aren't tied to the block layer.Signed-off-by Kevin Wolf <[email protected]>---
+++
b/qapi/job.jsonqapi/job.json new file +3
-0+## +# @JOB_STATUS_CHANGE: +#
qapi/job.json line 65
Quoted 10 lines
qapi/job.json new file +10
-0+# Emitted when a job transitions to a different status. +# +# @id: The job identifier +# @status: The new job status +# +# Since: 2.13 +## +{ 'event': 'JOB_STATUS_CHANGE', + 'data': { 'id': 'str', + 'status': 'JobStatus' } }
Is it worth also trying to list the old state that the transition came from? But that's new compared to what block jobs are currently doing, so if we can't come up with a strong reason to add that, I'm okay.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH 38/42] job: Add JOB_STATUS_CHANGE QMP event
Am 16.05.2018 um 21:26 hat Eric Blake geschrieben:
Quoted 20 lines · Kevin Wolf
Quoted 19 lines
This adds a QMP event that is emitted whenever a job transitions from one status to another. For the event, a new
qapi/job.jsonschema file is created which will contain all job-related definitions that aren't tied to the block layer.Signed-off-by Kevin Wolf <[email protected]>---
+++
b/qapi/job.jsonqapi/job.json new file +9
-0+## +# @JOB_STATUS_CHANGE: +# +# Emitted when a job transitions to a different status. +# +# @id: The job identifier +# @status: The new job status +# +# Since: 2.13
Quoted 8 lines
qapi/job.json line 65
Quoted 4 lines
qapi/job.json new file +4
-0+## +{ 'event': 'JOB_STATUS_CHANGE', + 'data': { 'id': 'str', + 'status': 'JobStatus' } }Is it worth also trying to list the old state that the transition came from? But that's new compared to what block jobs are currently doing, so if we can't come up with a strong reason to add that, I'm okay.
If a management tool needs this information (I don't see why), it just needs to keep track of the last state it had seen, no?
Kevin
Re: [Qemu-devel] [PATCH 38/42] job: Add JOB_STATUS_CHANGE QMP event
Quoted 10 lines · Kevin Wolf
Quoted 7 lines
qapi/job.json line 65
Quoted 3 lines
qapi/job.json new file +3
-0+{ 'event': 'JOB_STATUS_CHANGE', + 'data': { 'id': 'str', + 'status': 'JobStatus' } }Is it worth also trying to list the old state that the transition came from? But that's new compared to what block jobs are currently doing, so if we can't come up with a strong reason to add that, I'm okay.
If a management tool needs this information (I don't see why), it just needs to keep track of the last state it had seen, no?
And if you miss an event, the previous state is not preserved for any later query-job command. Exposing something in a (possibly-missed) event that is not available elsewhere doesn't buy us much. So I agree - there is no strong reason to advertise the previous state.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 39/42 job: Add lifecycle QMP commands
In reply to Kevin WolfThis adds QMP commands that control the transition between states of the job lifecycle.
--- qapi/job.json | 112 ++++++++++++++++++++++++++++++++++++++++++++++ job-qmp.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + Makefile.objs | 2 +- trace-events | 9 ++++ 5 files changed, 263 insertions(+), 1 deletion(-) create mode 100644 job-qmp.c
qapi/job.json +112 -0
@@ -63,3 +63,115 @@ { 'event': 'JOB_STATUS_CHANGE', 'data': { 'id': 'str', 'status': 'JobStatus' } } + +## +# @job-pause: +# +# Pause an active job. +# +# This command returns immediately after marking the active job for pausing. +# Pausing an already paused job has no cumulative effect; a single job-resume +# command will resume the job. +# +# The job will pause as soon as possible, which means transitioning into the +# PAUSED state if it was RUNNING, or into STANDBY if it was READY. The +# corresponding JOB_STATUS_CHANGE event will be emitted. +# +# Cancelling a paused job automatically resumes it. +# +# @id: The job identifier. +# +# Since: 2.13 +## +{ 'command': 'job-pause', 'data': { 'id': 'str' } } + +## +# @job-resume: +# +# Resume a paused job. +# +# This command returns immediately after resuming a paused job. Resuming an +# already running job is an error. +# +# @id : The job identifier. +# +# Since: 2.13 +## +{ 'command': 'job-resume', 'data': { 'id': 'str' } } + +## +# @job-cancel: +# +# Instruct an active background job to cancel at the next opportunity. +# This command returns immediately after marking the active job for +# cancellation. +# +# The job will cancel as soon as possible and then emit a JOB_STATUS_CHANGE +# event. Usually, the status will change to ABORTING, but it is possible that +# a job successfully completes (e.g. because it was almost done and there was +# no opportunity to cancel earlier than completing the job) and transitions to +# PENDING instead. +# +# Note that if you issue 'job-cancel' after a mirror block job has indicated +# (via the event BLOCK_JOB_READY, and by transitioning into the READY state) +# that the source and destination are synchronized, then the job always +# completes successfully and transitions to PENDING as well as triggering the +# event BLOCK_JOB_COMPLETED, to indicate that the mirroring has ended and the +# destination now has a point-in-time copy tied to the time of the +# cancellation. +# +# @id: The job identifier. +# +# @force: If true, and the job is already in the READY state, abandon the job +# immediately (even if it is paused) instead of waiting for the +# destination to complete its final synchronization +# +# Since: 2.13 +## +{ 'command': 'job-cancel', 'data': { 'id': 'str', '*force': 'bool' } } + + +## +# @job-complete: +# +# Manually trigger completion of an active job in the READY state. +# +# @id: The job identifier. +# +# Since: 2.13 +## +{ 'command': 'job-complete', 'data': { 'id': 'str' } } + +## +# @job-dismiss: +# +# Deletes a job that is in the CONCLUDED state. This command only needs to be +# run explicitly for jobs that don't have automatic dismiss enabled. +# +# This command will refuse to operate on any job that has not yet reached its +# terminal state, JOB_STATUS_CONCLUDED. For jobs that make use of JOB_READY +# event, job-cancel or job-complete will still need to be used as appropriate. +# +# @id: The job identifier. +# +# Since: 2.13 +## +{ 'command': 'job-dismiss', 'data': { 'id': 'str' } } + +## +# @job-finalize: +# +# Instructs all jobs in a transaction (or a single job if it is not part of any +# transaction) to finalize any graph changes and do any necessary cleanup. This +# command requires that all involved jobs are in the PENDING state. +# +# For jobs in a transaction, instructing one job to finalize will force +# ALL jobs in the transaction to finalize, so it is only necessary to instruct +# a single member job to finalize. +# +# @id: The identifier of any job in the transaction, or of a job that is not +# part of any transaction. +# +# Since: 2.13 +## +{ 'command': 'job-finalize', 'data': { 'id': 'str' } }
job-qmp.c new file +140 -0
140 lines not on this page · raw message
MAINTAINERS +1 -0
@@ -1370,6 +1370,7 @@ S: Supported F: blockjob.c F: include/block/blockjob.h F: job.c +F: job-qmp.c F: include/block/job.h F: block/backup.c F: block/commit.c
Makefile.objs +1 -1
@@ -66,7 +66,7 @@ chardev-obj-y = chardev/ # block-obj-y is code used by both qemu system emulation and qemu-img block-obj-y += nbd/ -block-obj-y += block.o blockjob.o job.o +block-obj-y += block.o blockjob.o job.o job-qmp.o block-obj-y += block/ scsi/ block-obj-y += qemu-io-cmds.o block-obj-$(CONFIG_REPLICATION) += replication.o
trace-events +9 -0
@@ -109,6 +109,15 @@ job_state_transition(void *job, int ret, const char *legal, const char *s0, con job_apply_verb(void *job, const char *state, const char *verb, const char *legal) "job %p in state %s; applying verb %s (%s)" job_completed(void *job, int ret, int jret) "job %p ret %d corrected ret %d" +# job-qmp.c +qmp_job_cancel(void *job) "job %p" +qmp_job_pause(void *job) "job %p" +qmp_job_resume(void *job) "job %p" +qmp_job_complete(void *job) "job %p" +qmp_job_finalize(void *job) "job %p" +qmp_job_dismiss(void *job) "job %p" + + ### Guest events, keep at bottom
Signature · 1 line
2.13.6
Re: [Qemu-devel] [PATCH 39/42] job: Add lifecycle QMP commands
Quoted 20 lines · Kevin Wolf
This adds QMP commands that control the transition between states of the job lifecycle.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/job.json | 112 ++++++++++++++++++++++++++++++++++++++++++++++ job-qmp.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + Makefile.objs | 2 +- trace-events | 9 ++++ 5 files changed, 263 insertions(+), 1 deletion(-) create mode 100644 job-qmp.cqapi/job.json +0
-0@@ -63,3 +63,115 @@ { 'event': 'JOB_STATUS_CHANGE', 'data': { 'id': 'str',
qapi/job.json line 74
Quoted 10 lines
qapi/job.json +9
-0'status': 'JobStatus' } } + +## +# @job-pause: +# +# Pause an active job. +# +# This command returns immediately after marking the active job for pausing. +# Pausing an already paused job has no cumulative effect; a single job-resume +# command will resume the job.
Pausing an already paused job is, in fact, an error.
(Which should be noted here instead of making it appear like it'd be idempotent.)
Quoted 12 lines
qapi/job.json +12
-0+# +# The job will pause as soon as possible, which means transitioning into the +# PAUSED state if it was RUNNING, or into STANDBY if it was READY. The +# corresponding JOB_STATUS_CHANGE event will be emitted. +# +# Cancelling a paused job automatically resumes it. +# +# @id: The job identifier. +# +# Since: 2.13 +## +{ 'command': 'job-pause', 'data': { 'id': 'str' } }
[...]
Quoted 16 lines
qapi/job.json +16
-0+## +# @job-cancel: +# +# Instruct an active background job to cancel at the next opportunity. +# This command returns immediately after marking the active job for +# cancellation. +# +# The job will cancel as soon as possible and then emit a JOB_STATUS_CHANGE +# event. Usually, the status will change to ABORTING, but it is possible that +# a job successfully completes (e.g. because it was almost done and there was +# no opportunity to cancel earlier than completing the job) and transitions to +# PENDING instead. +# +# Note that if you issue 'job-cancel' after a mirror block job has indicated +# (via the event BLOCK_JOB_READY, and by transitioning into the READY state) +# that the source and destination are synchronized, then the job always
qapi/job.json line 127
Quoted 10 lines
qapi/job.json +10
-0+# completes successfully and transitions to PENDING as well as triggering the +# event BLOCK_JOB_COMPLETED, to indicate that the mirroring has ended and the +# destination now has a point-in-time copy tied to the time of the +# cancellation. +# +# @id: The job identifier. +# +# @force: If true, and the job is already in the READY state, abandon the job +# immediately (even if it is paused) instead of waiting for the +# destination to complete its final synchronization
The note on "final synchronization" is extremely mirror-specific. I see three choices here:
(1) If mirror stays the only job with this special cancel semantics, then we are free to note that this is a mirror-specific flag here.
(2) Even if some other job might come along at some point where use of @force may make sense, that doesn't stop us from now noting that only mirror supports this, which helps readers understand what "destination" and "final synchronization" mean.
(Yes, so (1) and (2) are basically the same.)
(3) We try to find some general description and drop the last part. Like "If a job would normally decide to complete instead of actually aborting, this flag can be used to convince it otherwise." But that's so handwavy, I'd rather just mark it as a special mirror flag for now.
Quoted 4 lines
qapi/job.json +4
-0+# +# Since: 2.13 +## +{ 'command': 'job-cancel', 'data': { 'id': 'str', '*force': 'bool' } }
[...]
Makefile.objs chardev-obj-y = chardev/ · line 69
Quoted 10 lines
Makefile.objs +1
-1@@ -66,7 +66,7 @@ chardev-obj-y = chardev/ # block-obj-y is code used by both qemu system emulation and qemu-img block-obj-y += nbd/ -block-obj-y += block.o blockjob.o job.o +block-obj-y += block.o blockjob.o job.o job-qmp.o
Shouldn't this be in common-obj-y like blockdev?
Max
Quoted 3 lines
Makefile.objs +0
-0block-obj-y += block/ scsi/ block-obj-y += qemu-io-cmds.o block-obj-$(CONFIG_REPLICATION) += replication.o
Re: [Qemu-devel] [PATCH 39/42] job: Add lifecycle QMP commands
Am 15.05.2018 um 00:31 hat Max Reitz geschrieben:
Quoted 34 lines · Kevin Wolf
Quoted 20 lines
This adds QMP commands that control the transition between states of the job lifecycle.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/job.json | 112 ++++++++++++++++++++++++++++++++++++++++++++++ job-qmp.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + Makefile.objs | 2 +- trace-events | 9 ++++ 5 files changed, 263 insertions(+), 1 deletion(-) create mode 100644 job-qmp.cqapi/job.json +0
-0@@ -63,3 +63,115 @@ { 'event': 'JOB_STATUS_CHANGE', 'data': { 'id': 'str',qapi/job.json line 74
Quoted 10 lines
qapi/job.json +9
-0'status': 'JobStatus' } } + +## +# @job-pause: +# +# Pause an active job. +# +# This command returns immediately after marking the active job for pausing. +# Pausing an already paused job has no cumulative effect; a single job-resume +# command will resume the job.Pausing an already paused job is, in fact, an error.
Quoted 2 lines
(Which should be noted here instead of making it appear like it'd be idempotent.)
Aye. Interestingly, I managed to fix it below in job-resume, but missed it here. I should also stick in a patch somewhere early in the series that fixes the documentation of block-job-pause/resume.
Quoted 38 lines
Quoted 16 lines
qapi/job.json +16
-0+## +# @job-cancel: +# +# Instruct an active background job to cancel at the next opportunity. +# This command returns immediately after marking the active job for +# cancellation. +# +# The job will cancel as soon as possible and then emit a JOB_STATUS_CHANGE +# event. Usually, the status will change to ABORTING, but it is possible that +# a job successfully completes (e.g. because it was almost done and there was +# no opportunity to cancel earlier than completing the job) and transitions to +# PENDING instead. +# +# Note that if you issue 'job-cancel' after a mirror block job has indicated +# (via the event BLOCK_JOB_READY, and by transitioning into the READY state) +# that the source and destination are synchronized, then the job alwaysqapi/job.json line 127
Quoted 10 lines
qapi/job.json +10
-0+# completes successfully and transitions to PENDING as well as triggering the +# event BLOCK_JOB_COMPLETED, to indicate that the mirroring has ended and the +# destination now has a point-in-time copy tied to the time of the +# cancellation. +# +# @id: The job identifier. +# +# @force: If true, and the job is already in the READY state, abandon the job +# immediately (even if it is paused) instead of waiting for the +# destination to complete its final synchronizationThe note on "final synchronization" is extremely mirror-specific. I see three choices here:
(1) If mirror stays the only job with this special cancel semantics, then we are free to note that this is a mirror-specific flag here.
(2) Even if some other job might come along at some point where use of @force may make sense, that doesn't stop us from now noting that only mirror supports this, which helps readers understand what "destination" and "final synchronization" mean.
Quoted 6 lines
(Yes, so (1) and (2) are basically the same.)
(3) We try to find some general description and drop the last part. Like "If a job would normally decide to complete instead of actually aborting, this flag can be used to convince it otherwise." But that's so handwavy, I'd rather just mark it as a special mirror flag for now.
Or how about this one?
(4) Mirror is really abusing cancel for a second completion mode and we don't want to have this kind of ugliness in job-cancel. Remove @force from the schema and internally always use force=true. For now, block-job-cancel does the job (no pun intended) for mirror, and maybe we can later introduce a way to select completion mode with job-complete.
This would also get us rid of that whole long paragraph above that explains how mirror jobs have an exceptional behaviour.
Quoted 7 lines
Quoted 7 lines
Makefile.objs +0
-0@@ -66,7 +66,7 @@ chardev-obj-y = chardev/ # block-obj-y is code used by both qemu system emulation and qemu-img
Quoted 5 lines
Makefile.objs chardev-obj-y = chardev/ · line 69
Quoted 3 lines
Makefile.objs +1
-1block-obj-y += nbd/ -block-obj-y += block.o blockjob.o job.o +block-obj-y += block.o blockjob.o job.o job-qmp.oShouldn't this be in common-obj-y like blockdev?
Seems to build with that change, so it can't be wrong...
Kevin
Re: [Qemu-devel] [PATCH 39/42] job: Add lifecycle QMP commands
Quoted 87 lines · Kevin Wolf
Am 15.05.2018 um 00:31 hat Max Reitz geschrieben:
Quoted 34 lines · Kevin Wolf
Quoted 20 lines
This adds QMP commands that control the transition between states of the job lifecycle.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/job.json | 112 ++++++++++++++++++++++++++++++++++++++++++++++ job-qmp.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + Makefile.objs | 2 +- trace-events | 9 ++++ 5 files changed, 263 insertions(+), 1 deletion(-) create mode 100644 job-qmp.cqapi/job.json +0
-0@@ -63,3 +63,115 @@ { 'event': 'JOB_STATUS_CHANGE', 'data': { 'id': 'str',qapi/job.json line 74
Quoted 10 lines
qapi/job.json +9
-0'status': 'JobStatus' } } + +## +# @job-pause: +# +# Pause an active job. +# +# This command returns immediately after marking the active job for pausing. +# Pausing an already paused job has no cumulative effect; a single job-resume +# command will resume the job.Pausing an already paused job is, in fact, an error.
Quoted 2 lines
(Which should be noted here instead of making it appear like it'd be idempotent.)
Aye. Interestingly, I managed to fix it below in job-resume, but missed it here. I should also stick in a patch somewhere early in the series that fixes the documentation of block-job-pause/resume.
Quoted 38 lines
Quoted 16 lines
qapi/job.json +16
-0+## +# @job-cancel: +# +# Instruct an active background job to cancel at the next opportunity. +# This command returns immediately after marking the active job for +# cancellation. +# +# The job will cancel as soon as possible and then emit a JOB_STATUS_CHANGE +# event. Usually, the status will change to ABORTING, but it is possible that +# a job successfully completes (e.g. because it was almost done and there was +# no opportunity to cancel earlier than completing the job) and transitions to +# PENDING instead. +# +# Note that if you issue 'job-cancel' after a mirror block job has indicated +# (via the event BLOCK_JOB_READY, and by transitioning into the READY state) +# that the source and destination are synchronized, then the job alwaysqapi/job.json line 127
Quoted 10 lines
qapi/job.json +10
-0+# completes successfully and transitions to PENDING as well as triggering the +# event BLOCK_JOB_COMPLETED, to indicate that the mirroring has ended and the +# destination now has a point-in-time copy tied to the time of the +# cancellation. +# +# @id: The job identifier. +# +# @force: If true, and the job is already in the READY state, abandon the job +# immediately (even if it is paused) instead of waiting for the +# destination to complete its final synchronizationThe note on "final synchronization" is extremely mirror-specific. I see three choices here:
(1) If mirror stays the only job with this special cancel semantics, then we are free to note that this is a mirror-specific flag here.
(2) Even if some other job might come along at some point where use of @force may make sense, that doesn't stop us from now noting that only mirror supports this, which helps readers understand what "destination" and "final synchronization" mean.
Quoted 6 lines
(Yes, so (1) and (2) are basically the same.)
(3) We try to find some general description and drop the last part. Like "If a job would normally decide to complete instead of actually aborting, this flag can be used to convince it otherwise." But that's so handwavy, I'd rather just mark it as a special mirror flag for now.
Quoted 4 lines
Or how about this one?
(4) Mirror is really abusing cancel for a second completion mode and we don't want to have this kind of ugliness in job-cancel.
Yeah, well, right, that was implicit and I tried to be more diplomatic by calling it "special semantics". :-)
Quoted 5 lines
Remove
@force from the schema and internally always use force=true. For now, block-job-cancel does the job (no pun intended) for mirror, and maybe we can later introduce a way to select completion mode with job-complete.
Sounds good to me.
Quoted 2 lines
This would also get us rid of that whole long paragraph above that explains how mirror jobs have an exceptional behaviour.
Yes.
Max
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
Makefile.objs +0
-0@@ -66,7 +66,7 @@ chardev-obj-y = chardev/ # block-obj-y is code used by both qemu system emulation and qemu-imgQuoted 5 lines
Makefile.objs chardev-obj-y = chardev/ · line 69
Quoted 3 lines
Makefile.objs +1
-1block-obj-y += nbd/ -block-obj-y += block.o blockjob.o job.o +block-obj-y += block.o blockjob.o job.o job-qmp.oShouldn't this be in common-obj-y like blockdev?
Seems to build with that change, so it can't be wrong...
Kevin
PATCH 40/42 job: Add query-jobs QMP command
In reply to Kevin WolfThis adds a minimal query-jobs implementation that shouldn't pose many design questions. It can later be extended to expose more information, and especially job-specific information.
--- qapi/block-core.json | 18 ---------------- qapi/job.json | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/qemu/job.h | 3 +++ job-qmp.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ job.c | 2 +- 5 files changed, 117 insertions(+), 19 deletions(-)
qapi/block-core.json +0 -18
@@ -1051,24 +1051,6 @@ 'data': ['top', 'full', 'none', 'incremental'] } ## -# @JobType: -# -# Type of a background job. -# -# @commit: block commit job type, see "block-commit" -# -# @stream: block stream job type, see "block-stream" -# -# @mirror: drive mirror job type, see "drive-mirror" -# -# @backup: drive backup job type, see "drive-backup" -# -# Since: 1.7 -## -{ 'enum': 'JobType', - 'data': ['commit', 'stream', 'mirror', 'backup'] } - -## # @JobVerb: # # Represents command verbs that can be applied to a job.
qapi/job.json +59 -0
68 lines not on this page · raw message
include/qemu/job.h +3 -0
@@ -391,6 +391,9 @@ JobType job_type(Job *job);/** Returns the enum string for the JobType of a given Job. */ const char *job_type_str (Job *job); +/** Returns true if the job should not be visible to the management layer. */ +bool job_is_internal (Job *job); +/** Returns whether the job is scheduled for cancellation. */ bool job_is_cancelled (Job *job);
job-qmp.c +54 -0
57 lines not on this page · raw message
job.c +1 -1
@@ -158,7 +158,7 @@ static int job_txn_apply(JobTxn *txn, int fn(Job *), bool lock)return rc; } -static bool job_is_internal (Job *job) +bool job_is_internal (Job *job) {return (job->id ==NULL ); }
Signature · 1 line
2.13.6
Re: [Qemu-devel] [PATCH 40/42] job: Add query-jobs QMP command
Quoted 58 lines · Kevin Wolf
This adds a minimal query-jobs implementation that shouldn't pose many design questions. It can later be extended to expose more information, and especially job-specific information.
Signed-off-by Kevin Wolf <[email protected]>--- qapi/block-core.json | 18 ---------------- qapi/job.json | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/qemu/job.h | 3 +++ job-qmp.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ job.c | 2 +- 5 files changed, 117 insertions(+), 19 deletions(-)qapi/block-core.json +0
-18@@ -1051,24 +1051,6 @@ 'data': ['top', 'full', 'none', 'incremental'] } ## -# @JobType: -# -# Type of a background job. -# -# @commit: block commit job type, see "block-commit" -# -# @stream: block stream job type, see "block-stream" -# -# @mirror: drive mirror job type, see "drive-mirror" -# -# @backup: drive backup job type, see "drive-backup" -# -# Since: 1.7 -## -{ 'enum': 'JobType', - 'data': ['commit', 'stream', 'mirror', 'backup'] } - -## # @JobVerb: # # Represents command verbs that can be applied to a job.qapi/job.json +8
-0@@ -5,6 +5,24 @@ ## ## +# @JobType: +# +# Type of a background job. +# +# @commit: block commit job type, see "block-commit" +# +# @stream: block stream job type, see "block-stream" +#
qapi/job.json line 25
Quoted 10 lines
qapi/job.json +10
-0+# @mirror: drive mirror job type, see "drive-mirror" +# +# @backup: drive backup job type, see "drive-backup" +# +# Since: 1.7 +## +{ 'enum': 'JobType', + 'data': ['commit', 'stream', 'mirror', 'backup'] } + +##
FWIW, I'd put this code movement into the hypothetical commit which specifically adds job.json.
(Same as JobVerb, which is not moved in this series, but which very likely should be.)
Quoted 6 lines
qapi/job.json +0
-0# @JobStatus: # # Indicates the present state of a given job in its lifetime.@@ -175,3 +193,44 @@ # Since: 2.13 ##
qapi/job.json line 204
Quoted 10 lines
qapi/job.json +9
-0{ 'command': 'job-finalize', 'data': { 'id': 'str' } } + +## +# @JobInfo: +# +# Information about a job. +# +# @id: The job identifier +# +# @type: The job type
I'm not really happy with this description that effectively provides no information that one cannot already get from the field name, but I cannot come up with something better, so I'd rather stop typing now.
(OK, my issue here is that "job type" can be anything. That could mean
e.g. "Is this a block job?". Maybe an explicit reference to JobType
might help here, although that is already part of the documentation. On that note, maybe a quote from the documentation might help make my point that this description is not very useful:
"type: JobType"
The job type
Maybe "The kind of job that is being performed"?)
qapi/job.json line 206
Quoted 1 line
qapi/job.json +1
-0+# @status: Current job state/status
Why the "state/status"? Forgive me my incompetence, but I don't see a real difference here. But in any case, one ought to be enough, no?
(OK, full disclosure: My gut tells me "status" is what we now call the "progress", and this field should be called "state". But it's called "status" now and it doesn't really make a difference, so it's fine to describe it as either.)
qapi/job.json line 210
Quoted 4 lines
qapi/job.json +4
-0+# +# @current-progress: The current progress value +# +# @total-progress: The maximum progress value
Hm, not really. This makes it sound like at any point, this will be the maximum even in the future, but that's not true.
Maybe "estimated progress maximum"? Or be even more verbose (no, that doesn't hurt): "This is an estimation of the value @current-progress needs to reach for the job to complete."
(Actually, I find it important to note that it is an estimation, maybe we event want to be really explicit about the fact that this value may change all the time, in any direction.)
Quoted 26 lines
qapi/job.json +26
-0+# +# @error: If this field is present, the job failed; if it is +# still missing in the CONCLUDED state, this indicates +# successful completion. +# +# The value is a human-readable error message to describe +# the reason for the job failure. It should not be parsed +# by applications. +# +# Since: 2.13 +## +{ 'struct': 'JobInfo', + 'data': { 'id': 'str', 'type': 'JobType', 'status': 'JobStatus', + 'current-progress': 'int', 'total-progress': 'int', + '*error': 'str' } } + +## +# @query-jobs: +# +# Return information about jobs. +# +# Returns: a list with a @JobInfo for each active job +# +# Since: 2.13 +## +{ 'command': 'query-jobs', 'returns': ['JobInfo'] }
[...]
Quoted 5 lines
job-qmp.c +0
-0
job-qmp.c void qmp_job_dismiss(const char *id, Error **errp) · line 147
Quoted 10 lines
job-qmp.c +7
-0@@ -138,3 +138,57 @@ void qmp_job_dismiss(const char *id, Error **errp)job_dismiss (&job, errp);aio_context_release (aio_context); } + +static JobInfo *job_query_single (Job *job,Error **errp) +{ +JobInfo *info; +const char *errmsg =NULL ; + +assert (!job_is_internal (job));
One stray space.
Max
Quoted 47 lines
job-qmp.c +47
-0+ +if (job->ret <0 ) { + errmsg =strerror (-job->ret); + } + + info =g_new (JobInfo,1 ); + *info = (JobInfo ) { + .id =g_strdup (job->id), + .type =job_type (job), + .status = job->status, + .current_progress = job->progress_current, + .total_progress = job->progress_total, + .has_error = !!errmsg, + .error =g_strdup (errmsg), + }; + +return info; +} + +JobInfoList *qmp_query_jobs (Error **errp) +{ +JobInfoList *head =NULL , **p_next = &head; +Job *job; + +for (job =job_next (NULL ); job; job =job_next (job)) { +JobInfoList *elem; +AioContext *aio_context; + +if (job_is_internal (job)) { +continue ; + } + elem =g_new0 (JobInfoList,1 ); + aio_context = job->aio_context; +aio_context_acquire (aio_context); + elem->value =job_query_single (job, errp); +aio_context_release (aio_context); +if (!elem->value) { +g_free (elem); +qapi_free_JobInfoList (head); +return NULL ; + } + *p_next = elem; + p_next = &elem->next; + } + +return head; +}
Re: [Qemu-devel] [PATCH 40/42] job: Add query-jobs QMP command
Am 15.05.2018 um 01:09 hat Max Reitz geschrieben:
Quoted 26 lines · Kevin Wolf
Quoted 6 lines
This adds a minimal query-jobs implementation that shouldn't pose many design questions. It can later be extended to expose more information, and especially job-specific information.
Signed-off-by Kevin Wolf <[email protected]>qapi/job.json line 204
Quoted 8 lines
qapi/job.json +8
-0+## +# @JobInfo: +# +# Information about a job. +# +# @id: The job identifier +# +# @type: The job typeI'm not really happy with this description that effectively provides no information that one cannot already get from the field name, but I cannot come up with something better, so I'd rather stop typing now.
(OK, my issue here is that "job type" can be anything. That could mean
e.g. "Is this a block job?". Maybe an explicit reference to JobType
might help here, although that is already part of the documentation. On that note, maybe a quote from the documentation might help make my point that this description is not very useful:
Quoted 4 lines
"type: JobType"
The job typeMaybe "The kind of job that is being performed"?)
IMHO, that's just a more verbose way of saying nothing new. The "problem" is that "type: JobType" is already descriptive enough, there is no real need for providing any additional information.
Also, I'd like to mention that almost all of the documentation is taken from BlockJobInfo, so if we decide to change something, we should probably change it in both places.
Quoted 9 lines
Quoted 1 line
+# @status: Current job state/status
Why the "state/status"? Forgive me my incompetence, but I don't see a real difference here. But in any case, one ought to be enough, no?
(OK, full disclosure: My gut tells me "status" is what we now call the "progress", and this field should be called "state". But it's called "status" now and it doesn't really make a difference, so it's fine to describe it as either.)
I'll defer to John who wrote this description originally. I think we're just using status/state inconsistently for the same thing (JobStatus, which represents the states of the job state machine).
Quoted 8 lines
qapi/job.json line 210
Quoted 4 lines
qapi/job.json +4
-0+# +# @current-progress: The current progress value +# +# @total-progress: The maximum progress valueHm, not really. This makes it sound like at any point, this will be the maximum even in the future, but that's not true.
Quoted 7 lines
Maybe "estimated progress maximum"? Or be even more verbose (no, that doesn't hurt): "This is an estimation of the value @current-progress needs to reach for the job to complete."
(Actually, I find it important to note that it is an estimation, maybe we event want to be really explicit about the fact that this value may change all the time, in any direction.)
I'll try to improve the documentation of these fields (both here and in BlockJobInfo) for v2.
Kevin
Re: [Qemu-devel] [PATCH 40/42] job: Add query-jobs QMP command
Quoted 27 lines · Kevin Wolf
Am 15.05.2018 um 01:09 hat Max Reitz geschrieben:
Quoted 26 lines · Kevin Wolf
Quoted 6 lines
This adds a minimal query-jobs implementation that shouldn't pose many design questions. It can later be extended to expose more information, and especially job-specific information.
Signed-off-by Kevin Wolf <[email protected]>qapi/job.json line 204
Quoted 8 lines
qapi/job.json +8
-0+## +# @JobInfo: +# +# Information about a job. +# +# @id: The job identifier +# +# @type: The job typeI'm not really happy with this description that effectively provides no information that one cannot already get from the field name, but I cannot come up with something better, so I'd rather stop typing now.
(OK, my issue here is that "job type" can be anything. That could mean
e.g. "Is this a block job?". Maybe an explicit reference to JobType
might help here, although that is already part of the documentation. On that note, maybe a quote from the documentation might help make my point that this description is not very useful:
Quoted 6 lines
Quoted 4 lines
"type: JobType"
The job typeMaybe "The kind of job that is being performed"?)
IMHO, that's just a more verbose way of saying nothing new.
True, but “Job.type: JobType -- The job type” is exactly the kind of documentation people like to make fun of.
Quoted 3 lines
The
"problem" is that "type: JobType" is already descriptive enough, there is no real need for providing any additional information.
Yes, but it still doesn’t read nicely.
One could give examples (“e.g. mirror or backup”), but then again, if we were to remove any of those, we’d have to update the documentation here.
Also, you can again argue that such a list is precisely under JobType,
which is true.
Quoted 3 lines
Also, I'd like to mention that almost all of the documentation is taken from BlockJobInfo, so if we decide to change something, we should probably change it in both places.
Ha! Good excuse, but you know, you touched this, now you own it. :-)
Quoted 26 lines
Quoted 9 lines
Quoted 1 line
+# @status: Current job state/status
Why the "state/status"? Forgive me my incompetence, but I don't see a real difference here. But in any case, one ought to be enough, no?
(OK, full disclosure: My gut tells me "status" is what we now call the "progress", and this field should be called "state". But it's called "status" now and it doesn't really make a difference, so it's fine to describe it as either.)
I'll defer to John who wrote this description originally. I think we're just using status/state inconsistently for the same thing (JobStatus, which represents the states of the job state machine).
Quoted 12 lines
qapi/job.json line 210
Quoted 4 lines
qapi/job.json +4
-0+# +# @current-progress: The current progress value +# +# @total-progress: The maximum progress valueHm, not really. This makes it sound like at any point, this will be the maximum even in the future, but that's not true.
Maybe "estimated progress maximum"? Or be even more verbose (no, that doesn't hurt): "This is an estimation of the value @current-progress needs to reach for the job to complete."
Quoted 6 lines
Quoted 3 lines
(Actually, I find it important to note that it is an estimation, maybe we event want to be really explicit about the fact that this value may change all the time, in any direction.)
I'll try to improve the documentation of these fields (both here and in BlockJobInfo) for v2.
Thanks!
Max
PATCH 41/42 iotests: Move qmp_to_opts() to VM
In reply to Kevin Wolfqmp_to_opts() used to be a method of QMPTestCase, but recently we started to add more Python test cases that don't make use of QMPTestCase. In order to make the method usable there, move it to VM.
--- tests/qemu-iotests/041 | 6 +++--- tests/qemu-iotests/155 | 2 +- tests/qemu-iotests/iotests.py | 45 ++++++++++++++++++++++--------------------- 3 files changed, 27 insertions(+), 26 deletions(-)
tests/qemu-iotests/041 +3 -3
@@ -1030,9 +1030,9 @@ class TestOrphanedSource(iotests.QMPTestCase): 'read-only': 'on' } self.vm = iotests.VM() - self.vm.add_blockdev(self.qmp_to_opts(blk0)) - self.vm.add_blockdev(self.qmp_to_opts(blk1)) - self.vm.add_blockdev(self.qmp_to_opts(blk2)) + self.vm.add_blockdev(self.vm.qmp_to_opts(blk0)) + self.vm.add_blockdev(self.vm.qmp_to_opts(blk1)) + self.vm.add_blockdev(self.vm.qmp_to_opts(blk2)) self.vm.launch() def tearDown(self):
tests/qemu-iotests/155 +1 -1
@@ -63,7 +63,7 @@ class BaseClass(iotests.QMPTestCase): 'driver': iotests.imgfmt, 'file': {'driver': 'file', 'filename': source_img}} - self.vm.add_blockdev(self.qmp_to_opts(blockdev)) + self.vm.add_blockdev(self.vm.qmp_to_opts(blockdev)) self.vm.add_device('virtio-blk,id=qdev0,drive=source') self.vm.launch()
tests/qemu-iotests/iotests.py +23 -22
63 lines not on this page · raw message
Signature · 1 line
2.13.6
Re: [Qemu-devel] [PATCH 41/42] iotests: Move qmp_to_opts() to VM
Quoted 10 lines · Kevin Wolf
qmp_to_opts()used to be a method of QMPTestCase, but recently we started to add more Python test cases that don't make use of QMPTestCase. In order to make the method usable there, move it to VM.Signed-off-by Kevin Wolf <[email protected]>--- tests/qemu-iotests/041 | 6 +++--- tests/qemu-iotests/155 | 2 +- tests/qemu-iotests/iotests.py | 45 ++++++++++++++++++++++--------------------- 3 files changed, 27 insertions(+), 26 deletions(-)
PATCH 42/42 qemu-iotests: Test job-* with block jobs
In reply to Kevin WolfThis adds a test case that tests the new job-* QMP commands with mirror and backup block jobs.
--- tests/qemu-iotests/219 | 201 ++++++++++++++++++++++++++++ tests/qemu-iotests/219.out | 327 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 529 insertions(+) create mode 100755 tests/qemu-iotests/219 create mode 100644 tests/qemu-iotests/219.out
tests/qemu-iotests/219 new file +201 -0
@@ -0,0 +1,201 @@ +#!/usr/bin/env python +# +# Copyright (C) 2018 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# Creator/Owner: Kevin Wolf <[email protected]> +# +# Check using the job-* QMP commands with block jobs + +import iotests + +iotests.verify_image_format(supported_fmts=['qcow2']) + +def pause_wait(vm, job_id): + with iotests.Timeout(3, "Timeout waiting for job to pause"): + while True: + result = vm.qmp('query-jobs') + for job in result['return']: + if job['id'] == job_id and job['status'] in ['paused', 'standby']: + return job + +# Test that block-job-pause/resume and job-pause/resume can be mixed +def test_pause_resume(vm): + for pause_cmd, pause_arg in [('block-job-pause', 'device'), + ('job-pause', 'id')]: + for resume_cmd, resume_arg in [('block-job-resume', 'device'), + ('job-resume', 'id')]: + iotests.log('=== Testing %s/%s ===' % (pause_cmd, resume_cmd)) + + iotests.log(vm.qmp(pause_cmd, **{pause_arg: 'job0'})) + pause_wait(vm, 'job0') + iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'))) + iotests.log(vm.qmp('query-jobs')) + + iotests.log(vm.qmp(resume_cmd, **{resume_arg: 'job0'})) + iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'))) + iotests.log(vm.qmp('query-jobs')) + +def test_job_lifecycle(vm, job, job_args, has_ready=False): + iotests.log('') + iotests.log('') + iotests.log('Starting block job: %s (auto-finalize: %s; auto-dismiss: %s)' % + (job, + job_args.get('auto-finalize', True), + job_args.get('auto-dismiss', True))) + iotests.log(vm.qmp(job, job_id='job0', **job_args)) + iotests.log(vm.qmp('query-jobs')) + + # undefined -> created -> running + iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'))) + iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'))) + + # RUNNING state: + # pause/resume should work, complete/finalize/dismiss should error out + iotests.log('') + iotests.log('Pause/resume in RUNNING') + test_pause_resume(vm) + + iotests.log(vm.qmp('job-complete', id='job0')) + iotests.log(vm.qmp('job-finalize', id='job0')) + iotests.log(vm.qmp('job-dismiss', id='job0')) + + iotests.log(vm.qmp('block-job-complete', device='job0')) + iotests.log(vm.qmp('block-job-finalize', id='job0')) + iotests.log(vm.qmp('block-job-dismiss', id='job0')) + + # Let the job complete (or transition to READY if it supports that) + iotests.log(vm.qmp('block-job-set-speed', device='job0', speed=0)) + if has_ready: + iotests.log('') + iotests.log('Waiting for READY state...') + vm.event_wait('BLOCK_JOB_READY') + iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'))) + iotests.log(vm.qmp('query-jobs')) + + # READY state: + # pause/resume/complete should work, finalize/dismiss should error out + iotests.log('') + iotests.log('Pause/resume in READY') + test_pause_resume(vm) + + iotests.log(vm.qmp('job-finalize', id='job0')) + iotests.log(vm.qmp('job-dismiss', id='job0')) + + iotests.log(vm.qmp('block-job-finalize', id='job0')) + iotests.log(vm.qmp('block-job-dismiss', id='job0')) + + # Transition to WAITING + iotests.log(vm.qmp('job-complete', id='job0')) + + # Move to WAITING and PENDING state + iotests.log('') + iotests.log('Waiting for PENDING state...') + iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'))) + iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'))) + + if not job_args.get('auto-finalize', True): + # PENDING state: + # finalize should work, pause/complete/dismiss should error out + iotests.log(vm.qmp('query-jobs')) + + iotests.log(vm.qmp('job-pause', id='job0')) + iotests.log(vm.qmp('job-complete', id='job0')) + iotests.log(vm.qmp('job-dismiss', id='job0')) + + iotests.log(vm.qmp('block-job-pause', device='job0')) + iotests.log(vm.qmp('block-job-complete', device='job0')) + iotests.log(vm.qmp('block-job-dismiss', id='job0')) + + # Transition to CONCLUDED + iotests.log(vm.qmp('job-finalize', id='job0')) + + + # Move to CONCLUDED state + iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'))) + + if not job_args.get('auto-dismiss', True): + # CONCLUDED state: + # dismiss should work, pause/complete/finalize should error out + iotests.log(vm.qmp('query-jobs')) + + iotests.log(vm.qmp('job-pause', id='job0')) + iotests.log(vm.qmp('job-complete', id='job0')) + iotests.log(vm.qmp('job-finalize', id='job0')) + + iotests.log(vm.qmp('block-job-pause', device='job0')) + iotests.log(vm.qmp('block-job-complete', device='job0')) + iotests.log(vm.qmp('block-job-finalize', id='job0')) + + # Transition to NULL + iotests.log(vm.qmp('job-dismiss', id='job0')) + + # Move to NULL state + iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'))) + iotests.log(vm.qmp('query-jobs')) + + +with iotests.FilePath('disk.img') as disk_path, \ + iotests.FilePath('copy.img') as copy_path, \ + iotests.VM() as vm: + + img_size = '4M' + iotests.qemu_img_create('-f', iotests.imgfmt, disk_path, img_size) + iotests.qemu_io('-c', 'write 0 %s' % (img_size), + '-f', iotests.imgfmt, disk_path) + + iotests.log('Launching VM...') + vm.add_blockdev(vm.qmp_to_opts({ + 'driver': iotests.imgfmt, + 'node-name': 'drive0-node', + 'file': { + 'driver': 'file', + 'filename': disk_path, + }, + })) + vm.launch() + + # In order to keep things deterministic (especially progress in query-job, + # but related to this also automatic state transitions like job + # completion), but still get pause points often enough to avoid making this + # test veey slow, it's important to have the right ratio between speed and + # buf_size. + # + # For backup, buf_size is hard-coded to the source image cluser size (64k), + # so we'll pick the same for mirror. The slice time, i.e. the granularity + # of the rate limiting is 100ms. With a speed of 256k per second, we can + # get four pause points per second. This gives us 250ms per iteration, + # which should be enough to stay deterministic. + + test_job_lifecycle(vm, 'drive-mirror', has_ready=True, job_args={ + 'device': 'drive0-node', + 'target': copy_path, + 'sync': 'full', + 'speed': 262144, + 'buf_size': 65536, + }) + + for auto_finalize in [True, False]: + for auto_dismiss in [True, False]: + test_job_lifecycle(vm, 'drive-backup', job_args={ + 'device': 'drive0-node', + 'target': copy_path, + 'sync': 'full', + 'speed': 262144, + 'auto-finalize': auto_finalize, + 'auto-dismiss': auto_dismiss, + }) + + vm.shutdown()
tests/qemu-iotests/219.out new file +327 -0
327 lines not on this page · raw message
tests/qemu-iotests/group +1 -0
@@ -213,3 +213,4 @@ 212 rw auto quick 213 rw auto quick 218 rw auto quick +219 rw auto
Signature · 1 line
2.13.6
Re: [Qemu-devel] [PATCH 42/42] qemu-iotests: Test job-* with block jobs
Quoted 11 lines · Kevin Wolf
This adds a test case that tests the new job-* QMP commands with mirror and backup block jobs.
Signed-off-by Kevin Wolf <[email protected]>--- tests/qemu-iotests/219 | 201 ++++++++++++++++++++++++++++ tests/qemu-iotests/219.out | 327 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 529 insertions(+) create mode 100755 tests/qemu-iotests/219 create mode 100644 tests/qemu-iotests/219.out
Test looks good, but it fails (for me) on tmpfs because at the point of the first query-jobs, they already have an offset of 65536.
Quoted 6 lines
tests/qemu-iotests/219 new file +0
-0@@ -0,0 +1,201 @@
[...]
Quoted 14 lines
tests/qemu-iotests/219 new file +14
-0+with iotests.FilePath('disk.img') as disk_path, \ + iotests.FilePath('copy.img') as copy_path, \ + iotests.VM() as vm: + + img_size = '4M' + iotests.qemu_img_create('-f', iotests.imgfmt, disk_path, img_size) + iotests.qemu_io('-c', 'write 0 %s' % (img_size), + '-f', iotests.imgfmt, disk_path) + + iotests.log('Launching VM...') + vm.add_blockdev(vm.qmp_to_opts({ + 'driver': iotests.imgfmt, + 'node-name': 'drive0-node', + 'file': {
tests/qemu-iotests/219 line 173
Quoted 10 lines
tests/qemu-iotests/219 new file +10
-0+ 'driver': 'file', + 'filename': disk_path, + }, + })) + vm.launch() + + # In order to keep things deterministic (especially progress in query-job, + # but related to this also automatic state transitions like job + # completion), but still get pause points often enough to avoid making this + # test veey slow, it's important to have the right ratio between speed and
s/veey/very/
(Although "veey" does have its charm.)
tests/qemu-iotests/219 line 176
Quoted 3 lines
tests/qemu-iotests/219 new file +3
-0+ # buf_size. + # + # For backup, buf_size is hard-coded to the source image cluser size (64k),
s/cluser/cluster/
Quoted 31 lines
tests/qemu-iotests/219 new file +25
-0+ # so we'll pick the same for mirror. The slice time, i.e. the granularity + # of the rate limiting is 100ms. With a speed of 256k per second, we can + # get four pause points per second. This gives us 250ms per iteration, + # which should be enough to stay deterministic. + + test_job_lifecycle(vm, 'drive-mirror', has_ready=True, job_args={ + 'device': 'drive0-node', + 'target': copy_path, + 'sync': 'full', + 'speed': 262144, + 'buf_size': 65536, + }) + + for auto_finalize in [True, False]: + for auto_dismiss in [True, False]: + test_job_lifecycle(vm, 'drive-backup', job_args={ + 'device': 'drive0-node', + 'target': copy_path, + 'sync': 'full', + 'speed': 262144, + 'auto-finalize': auto_finalize, + 'auto-dismiss': auto_dismiss, + }) + + vm.shutdown()tests/qemu-iotests/219.out new file +0
-0@@ -0,0 +1,327 @@
[...]
Quoted 19 lines
tests/qemu-iotests/219.out new file +19
-0+Pause/resume in READY +=== Testing block-job-pause/block-job-resume === +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'standby', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'standby', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'ready', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'ready', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +=== Testing block-job-pause/job-resume === +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'standby', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'standby', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'ready', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'ready', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +=== Testing job-pause/block-job-resume === +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'standby', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'standby', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]}
tests/qemu-iotests/219.out line 79
Quoted 10 lines
tests/qemu-iotests/219.out new file +10
-0+{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'ready', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'ready', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +=== Testing job-pause/job-resume === +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'standby', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'standby', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'ready', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'ready', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]}
This is really, really mean. Don't you have any compassion with the poor little job that just wants to have Feierabend?
It worked so hard and it's always on standby and instantly ready when you need it. Yet, you keep it hanging. That's not nice.
Max
Quoted 12 lines
tests/qemu-iotests/219.out new file +12
-0+{u'error': {u'class': u'GenericError', u'desc': u"Job 'job0' in state 'ready' cannot accept command verb 'finalize'"}} +{u'error': {u'class': u'GenericError', u'desc': u"Job 'job0' in state 'ready' cannot accept command verb 'dismiss'"}} +{u'error': {u'class': u'GenericError', u'desc': u"Job 'job0' in state 'ready' cannot accept command verb 'finalize'"}} +{u'error': {u'class': u'GenericError', u'desc': u"Job 'job0' in state 'ready' cannot accept command verb 'dismiss'"}} +{u'return': {}} + +Waiting for PENDING state... +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'waiting', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'pending', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'concluded', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'null', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': []}
Re: [Qemu-devel] [PATCH 42/42] qemu-iotests: Test job-* with block jobs
Am 15.05.2018 um 01:44 hat Max Reitz geschrieben:
Quoted 46 lines · Kevin Wolf
Quoted 31 lines
This adds a test case that tests the new job-* QMP commands with mirror and backup block jobs.
Signed-off-by Kevin Wolf <[email protected]>--- tests/qemu-iotests/219 | 201 ++++++++++++++++++++++++++++ tests/qemu-iotests/219.out | 327 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 529 insertions(+) create mode 100755 tests/qemu-iotests/219 create mode 100644 tests/qemu-iotests/219.outtests/qemu-iotests/219.out new file +19
-0+Pause/resume in READY +=== Testing block-job-pause/block-job-resume === +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'standby', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'standby', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'ready', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'ready', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +=== Testing block-job-pause/job-resume === +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'standby', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'standby', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'ready', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'ready', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +=== Testing job-pause/block-job-resume === +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'standby', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'standby', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]}tests/qemu-iotests/219.out line 79
Quoted 10 lines
tests/qemu-iotests/219.out new file +10
-0+{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'ready', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'ready', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +=== Testing job-pause/job-resume === +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'standby', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'standby', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'ready', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'ready', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]}This is really, really mean. Don't you have any compassion with the poor little job that just wants to have Feierabend?
Quoted 2 lines
It worked so hard and it's always on standby and instantly ready when you need it. Yet, you keep it hanging. That's not nice.
If you just mean that I do some testing with the poor job before I complete it, then I'm afraid the job will have to suffer this.
But if you have a more serious concern, I don't see it. Isn't the job properly completed in the end, as the following lines show?
Quoted 4 lines
Quoted 4 lines
tests/qemu-iotests/219.out new file +4
-0+{u'error': {u'class': u'GenericError', u'desc': u"Job 'job0' in state 'ready' cannot accept command verb 'finalize'"}} +{u'error': {u'class': u'GenericError', u'desc': u"Job 'job0' in state 'ready' cannot accept command verb 'dismiss'"}} +{u'error': {u'class': u'GenericError', u'desc': u"Job 'job0' in state 'ready' cannot accept command verb 'finalize'"}} +{u'error': {u'class': u'GenericError', u'desc': u"Job 'job0' in state 'ready' cannot accept command verb 'dismiss'"}}
Quoted 8 lines
tests/qemu-iotests/219.out line 91
Quoted 8 lines
tests/qemu-iotests/219.out new file +8
-0+{u'return': {}} + +Waiting for PENDING state... +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'waiting', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'pending', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'concluded', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'null', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': []}
Kevin
Re: [Qemu-devel] [PATCH 42/42] qemu-iotests: Test job-* with block jobs
Quoted 47 lines · Kevin Wolf
Am 15.05.2018 um 01:44 hat Max Reitz geschrieben:
Quoted 46 lines · Kevin Wolf
Quoted 31 lines
This adds a test case that tests the new job-* QMP commands with mirror and backup block jobs.
Signed-off-by Kevin Wolf <[email protected]>--- tests/qemu-iotests/219 | 201 ++++++++++++++++++++++++++++ tests/qemu-iotests/219.out | 327 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 529 insertions(+) create mode 100755 tests/qemu-iotests/219 create mode 100644 tests/qemu-iotests/219.outtests/qemu-iotests/219.out new file +19
-0+Pause/resume in READY +=== Testing block-job-pause/block-job-resume === +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'standby', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'standby', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'ready', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'ready', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +=== Testing block-job-pause/job-resume === +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'standby', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'standby', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'ready', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'ready', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +=== Testing job-pause/block-job-resume === +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'standby', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'standby', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]}tests/qemu-iotests/219.out line 79
Quoted 10 lines
tests/qemu-iotests/219.out new file +10
-0+{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'ready', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'ready', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +=== Testing job-pause/job-resume === +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'standby', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'standby', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]} +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'ready', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': [{u'status': u'ready', u'current-progress': 4194304, u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]}This is really, really mean. Don't you have any compassion with the poor little job that just wants to have Feierabend?
Quoted 8 lines
Quoted 2 lines
It worked so hard and it's always on standby and instantly ready when you need it. Yet, you keep it hanging. That's not nice.
If you just mean that I do some testing with the poor job before I complete it, then I'm afraid the job will have to suffer this.
But if you have a more serious concern, I don't see it. Isn't the job properly completed in the end, as the following lines show?
No, I was just making fun of the standby <-> ready transition. :-)
Max
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
tests/qemu-iotests/219.out new file +4
-0+{u'error': {u'class': u'GenericError', u'desc': u"Job 'job0' in state 'ready' cannot accept command verb 'finalize'"}} +{u'error': {u'class': u'GenericError', u'desc': u"Job 'job0' in state 'ready' cannot accept command verb 'dismiss'"}} +{u'error': {u'class': u'GenericError', u'desc': u"Job 'job0' in state 'ready' cannot accept command verb 'finalize'"}} +{u'error': {u'class': u'GenericError', u'desc': u"Job 'job0' in state 'ready' cannot accept command verb 'dismiss'"}}Quoted 8 lines
tests/qemu-iotests/219.out line 91
Quoted 8 lines
tests/qemu-iotests/219.out new file +8
-0+{u'return': {}} + +Waiting for PENDING state... +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'waiting', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'pending', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'concluded', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'null', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} +{u'return': []}Kevin
Am 09.05.2018 um 18:25 hat Kevin Wolf geschrieben:
Quoted 4 lines
Before we can make x-blockdev-create a background job, we need to generalise the job infrastructure so that it can be used without any associated block node.
Quoted 8 lines
This series extracts a Job object from the block job infrastructure, which should contain everything related to jobs that doesn't require the block layer to be involved.
Job creation with a centralised job-create command (if we even want this) as well as the actual conversion of x-blockdev-create to Job is left for another series. With 42 patches, the series must be perfect and I can't add any more patches.
Thanks for the review, applied patches 1-6 in the hope of making v2 at least a little bit shorter. :-)
Kevin
Quoted 9 lines · Kevin Wolf
Am 09.05.2018 um 18:25 hat Kevin Wolf geschrieben:
Quoted 8 lines
Before we can make x-blockdev-create a background job, we need to generalise the job infrastructure so that it can be used without any associated block node.
This series extracts a Job object from the block job infrastructure, which should contain everything related to jobs that doesn't require the block layer to be involved.
Quoted 7 lines
Quoted 4 lines
Job creation with a centralised job-create command (if we even want this) as well as the actual conversion of x-blockdev-create to Job is left for another series. With 42 patches, the series must be perfect and I can't add any more patches.
Thanks for the review, applied patches 1-6 in the hope of making v2 at least a little bit shorter. :-)
Or now you can split/add patches until you're back up to 42 patches in v2 ;)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org