qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

blockjobs: Expose manual property

Expose the "manual" property via QAPI for the backup-related jobs.
As of this commit, this allows the management API to request the
"concluded" and "dismiss" semantics for backup jobs.

Signed-off-by: John Snow <jsnow@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>

authored by

John Snow and committed by
Kevin Wolf
b40dacdc 11b61fbc

+82 -23
+28 -3
blockdev.c
··· 3274 3274 AioContext *aio_context; 3275 3275 QDict *options = NULL; 3276 3276 Error *local_err = NULL; 3277 - int flags; 3277 + int flags, job_flags = BLOCK_JOB_DEFAULT; 3278 3278 int64_t size; 3279 3279 bool set_backing_hd = false; 3280 3280 ··· 3292 3292 } 3293 3293 if (!backup->has_job_id) { 3294 3294 backup->job_id = NULL; 3295 + } 3296 + if (!backup->has_auto_finalize) { 3297 + backup->auto_finalize = true; 3298 + } 3299 + if (!backup->has_auto_dismiss) { 3300 + backup->auto_dismiss = true; 3295 3301 } 3296 3302 if (!backup->has_compress) { 3297 3303 backup->compress = false; ··· 3390 3396 goto out; 3391 3397 } 3392 3398 } 3399 + if (!backup->auto_finalize) { 3400 + job_flags |= BLOCK_JOB_MANUAL_FINALIZE; 3401 + } 3402 + if (!backup->auto_dismiss) { 3403 + job_flags |= BLOCK_JOB_MANUAL_DISMISS; 3404 + } 3393 3405 3394 3406 job = backup_job_create(backup->job_id, bs, target_bs, backup->speed, 3395 3407 backup->sync, bmap, backup->compress, 3396 3408 backup->on_source_error, backup->on_target_error, 3397 - BLOCK_JOB_DEFAULT, NULL, NULL, txn, &local_err); 3409 + job_flags, NULL, NULL, txn, &local_err); 3398 3410 bdrv_unref(target_bs); 3399 3411 if (local_err != NULL) { 3400 3412 error_propagate(errp, local_err); ··· 3429 3441 Error *local_err = NULL; 3430 3442 AioContext *aio_context; 3431 3443 BlockJob *job = NULL; 3444 + int job_flags = BLOCK_JOB_DEFAULT; 3432 3445 3433 3446 if (!backup->has_speed) { 3434 3447 backup->speed = 0; ··· 3441 3454 } 3442 3455 if (!backup->has_job_id) { 3443 3456 backup->job_id = NULL; 3457 + } 3458 + if (!backup->has_auto_finalize) { 3459 + backup->auto_finalize = true; 3460 + } 3461 + if (!backup->has_auto_dismiss) { 3462 + backup->auto_dismiss = true; 3444 3463 } 3445 3464 if (!backup->has_compress) { 3446 3465 backup->compress = false; ··· 3470 3489 goto out; 3471 3490 } 3472 3491 } 3492 + if (!backup->auto_finalize) { 3493 + job_flags |= BLOCK_JOB_MANUAL_FINALIZE; 3494 + } 3495 + if (!backup->auto_dismiss) { 3496 + job_flags |= BLOCK_JOB_MANUAL_DISMISS; 3497 + } 3473 3498 job = backup_job_create(backup->job_id, bs, target_bs, backup->speed, 3474 3499 backup->sync, NULL, backup->compress, 3475 3500 backup->on_source_error, backup->on_target_error, 3476 - BLOCK_JOB_DEFAULT, NULL, NULL, txn, &local_err); 3501 + job_flags, NULL, NULL, txn, &local_err); 3477 3502 if (local_err != NULL) { 3478 3503 error_propagate(errp, local_err); 3479 3504 }
+2
blockjob.c
··· 821 821 info->io_status = job->iostatus; 822 822 info->ready = job->ready; 823 823 info->status = job->status; 824 + info->auto_finalize = job->auto_finalize; 825 + info->auto_dismiss = job->auto_dismiss; 824 826 return info; 825 827 } 826 828
+40 -8
qapi/block-core.json
··· 1057 1057 # 1058 1058 # @status: Current job state/status (since 2.12) 1059 1059 # 1060 + # @auto-finalize: Job will finalize itself when PENDING, moving to 1061 + # the CONCLUDED state. (since 2.12) 1062 + # 1063 + # @auto-dismiss: Job will dismiss itself when CONCLUDED, moving to the NULL 1064 + # state and disappearing from the query list. (since 2.12) 1065 + # 1060 1066 # Since: 1.1 1061 1067 ## 1062 1068 { 'struct': 'BlockJobInfo', 1063 1069 'data': {'type': 'str', 'device': 'str', 'len': 'int', 1064 1070 'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int', 1065 1071 'io-status': 'BlockDeviceIoStatus', 'ready': 'bool', 1066 - 'status': 'BlockJobStatus' } } 1072 + 'status': 'BlockJobStatus', 1073 + 'auto-finalize': 'bool', 'auto-dismiss': 'bool' } } 1067 1074 1068 1075 ## 1069 1076 # @query-block-jobs: ··· 1213 1220 # default 'report' (no limitations, since this applies to 1214 1221 # a different block device than @device). 1215 1222 # 1223 + # @auto-finalize: When false, this job will wait in a PENDING state after it has 1224 + # finished its work, waiting for @block-job-finalize. 1225 + # When true, this job will automatically perform its abort or 1226 + # commit actions. 1227 + # Defaults to true. (Since 2.12) 1228 + # 1229 + # @auto-dismiss: When false, this job will wait in a CONCLUDED state after it 1230 + # has completed ceased all work, and wait for @block-job-dismiss. 1231 + # When true, this job will automatically disappear from the query 1232 + # list without user intervention. 1233 + # Defaults to true. (Since 2.12) 1234 + # 1216 1235 # Note: @on-source-error and @on-target-error only affect background 1217 1236 # I/O. If an error occurs during a guest write request, the device's 1218 1237 # rerror/werror actions will be used. ··· 1221 1240 ## 1222 1241 { 'struct': 'DriveBackup', 1223 1242 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', 1224 - '*format': 'str', 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode', 1225 - '*speed': 'int', '*bitmap': 'str', '*compress': 'bool', 1243 + '*format': 'str', 'sync': 'MirrorSyncMode', 1244 + '*mode': 'NewImageMode', '*speed': 'int', 1245 + '*bitmap': 'str', '*compress': 'bool', 1226 1246 '*on-source-error': 'BlockdevOnError', 1227 - '*on-target-error': 'BlockdevOnError' } } 1247 + '*on-target-error': 'BlockdevOnError', 1248 + '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } } 1228 1249 1229 1250 ## 1230 1251 # @BlockdevBackup: ··· 1254 1275 # default 'report' (no limitations, since this applies to 1255 1276 # a different block device than @device). 1256 1277 # 1278 + # @auto-finalize: When false, this job will wait in a PENDING state after it has 1279 + # finished its work, waiting for @block-job-finalize. 1280 + # When true, this job will automatically perform its abort or 1281 + # commit actions. 1282 + # Defaults to true. (Since 2.12) 1283 + # 1284 + # @auto-dismiss: When false, this job will wait in a CONCLUDED state after it 1285 + # has completed ceased all work, and wait for @block-job-dismiss. 1286 + # When true, this job will automatically disappear from the query 1287 + # list without user intervention. 1288 + # Defaults to true. (Since 2.12) 1289 + # 1257 1290 # Note: @on-source-error and @on-target-error only affect background 1258 1291 # I/O. If an error occurs during a guest write request, the device's 1259 1292 # rerror/werror actions will be used. ··· 1262 1295 ## 1263 1296 { 'struct': 'BlockdevBackup', 1264 1297 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', 1265 - 'sync': 'MirrorSyncMode', 1266 - '*speed': 'int', 1267 - '*compress': 'bool', 1298 + 'sync': 'MirrorSyncMode', '*speed': 'int', '*compress': 'bool', 1268 1299 '*on-source-error': 'BlockdevOnError', 1269 - '*on-target-error': 'BlockdevOnError' } } 1300 + '*on-target-error': 'BlockdevOnError', 1301 + '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } } 1270 1302 1271 1303 ## 1272 1304 # @blockdev-snapshot-sync:
+12 -12
tests/qemu-iotests/109.out
··· 19 19 {"return": {}} 20 20 {"return": {}} 21 21 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "src", "len": 1024, "offset": 1024, "speed": 0, "type": "mirror"}} 22 - {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 1024, "offset": 1024, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 22 + {"return": [{"auto-finalize": true, "io-status": "ok", "device": "src", "auto-dismiss": true, "busy": false, "len": 1024, "offset": 1024, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 23 23 {"return": {}} 24 24 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} 25 25 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 1024, "offset": 1024, "speed": 0, "type": "mirror"}} ··· 45 45 {"return": {}} 46 46 {"return": {}} 47 47 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "src", "len": 197120, "offset": 197120, "speed": 0, "type": "mirror"}} 48 - {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 197120, "offset": 197120, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 48 + {"return": [{"auto-finalize": true, "io-status": "ok", "device": "src", "auto-dismiss": true, "busy": false, "len": 197120, "offset": 197120, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 49 49 {"return": {}} 50 50 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} 51 51 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 197120, "offset": 197120, "speed": 0, "type": "mirror"}} ··· 71 71 {"return": {}} 72 72 {"return": {}} 73 73 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "src", "len": 327680, "offset": 327680, "speed": 0, "type": "mirror"}} 74 - {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 327680, "offset": 327680, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 74 + {"return": [{"auto-finalize": true, "io-status": "ok", "device": "src", "auto-dismiss": true, "busy": false, "len": 327680, "offset": 327680, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 75 75 {"return": {}} 76 76 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} 77 77 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 327680, "offset": 327680, "speed": 0, "type": "mirror"}} ··· 97 97 {"return": {}} 98 98 {"return": {}} 99 99 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "src", "len": 1024, "offset": 1024, "speed": 0, "type": "mirror"}} 100 - {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 1024, "offset": 1024, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 100 + {"return": [{"auto-finalize": true, "io-status": "ok", "device": "src", "auto-dismiss": true, "busy": false, "len": 1024, "offset": 1024, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 101 101 {"return": {}} 102 102 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} 103 103 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 1024, "offset": 1024, "speed": 0, "type": "mirror"}} ··· 123 123 {"return": {}} 124 124 {"return": {}} 125 125 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "src", "len": 65536, "offset": 65536, "speed": 0, "type": "mirror"}} 126 - {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 65536, "offset": 65536, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 126 + {"return": [{"auto-finalize": true, "io-status": "ok", "device": "src", "auto-dismiss": true, "busy": false, "len": 65536, "offset": 65536, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 127 127 {"return": {}} 128 128 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} 129 129 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 65536, "offset": 65536, "speed": 0, "type": "mirror"}} ··· 149 149 {"return": {}} 150 150 {"return": {}} 151 151 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "src", "len": 2560, "offset": 2560, "speed": 0, "type": "mirror"}} 152 - {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 2560, "offset": 2560, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 152 + {"return": [{"auto-finalize": true, "io-status": "ok", "device": "src", "auto-dismiss": true, "busy": false, "len": 2560, "offset": 2560, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 153 153 {"return": {}} 154 154 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} 155 155 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2560, "offset": 2560, "speed": 0, "type": "mirror"}} ··· 174 174 {"return": {}} 175 175 {"return": {}} 176 176 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "src", "len": 2560, "offset": 2560, "speed": 0, "type": "mirror"}} 177 - {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 2560, "offset": 2560, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 177 + {"return": [{"auto-finalize": true, "io-status": "ok", "device": "src", "auto-dismiss": true, "busy": false, "len": 2560, "offset": 2560, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 178 178 {"return": {}} 179 179 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} 180 180 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2560, "offset": 2560, "speed": 0, "type": "mirror"}} ··· 199 199 {"return": {}} 200 200 {"return": {}} 201 201 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "src", "len": 31457280, "offset": 31457280, "speed": 0, "type": "mirror"}} 202 - {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 31457280, "offset": 31457280, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 202 + {"return": [{"auto-finalize": true, "io-status": "ok", "device": "src", "auto-dismiss": true, "busy": false, "len": 31457280, "offset": 31457280, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 203 203 {"return": {}} 204 204 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} 205 205 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 31457280, "offset": 31457280, "speed": 0, "type": "mirror"}} ··· 224 224 {"return": {}} 225 225 {"return": {}} 226 226 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "src", "len": 327680, "offset": 327680, "speed": 0, "type": "mirror"}} 227 - {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 327680, "offset": 327680, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 227 + {"return": [{"auto-finalize": true, "io-status": "ok", "device": "src", "auto-dismiss": true, "busy": false, "len": 327680, "offset": 327680, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 228 228 {"return": {}} 229 229 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} 230 230 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 327680, "offset": 327680, "speed": 0, "type": "mirror"}} ··· 249 249 {"return": {}} 250 250 {"return": {}} 251 251 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "src", "len": 2048, "offset": 2048, "speed": 0, "type": "mirror"}} 252 - {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 2048, "offset": 2048, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 252 + {"return": [{"auto-finalize": true, "io-status": "ok", "device": "src", "auto-dismiss": true, "busy": false, "len": 2048, "offset": 2048, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 253 253 {"return": {}} 254 254 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} 255 255 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2048, "offset": 2048, "speed": 0, "type": "mirror"}} ··· 265 265 Specify the 'raw' format explicitly to remove the restrictions. 266 266 {"return": {}} 267 267 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "src", "len": 512, "offset": 512, "speed": 0, "type": "mirror"}} 268 - {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 512, "offset": 512, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 268 + {"return": [{"auto-finalize": true, "io-status": "ok", "device": "src", "auto-dismiss": true, "busy": false, "len": 512, "offset": 512, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 269 269 {"return": {}} 270 270 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} 271 271 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 512, "offset": 512, "speed": 0, "type": "mirror"}} ··· 274 274 {"return": {}} 275 275 {"return": {}} 276 276 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "src", "len": 512, "offset": 512, "speed": 0, "type": "mirror"}} 277 - {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 512, "offset": 512, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 277 + {"return": [{"auto-finalize": true, "io-status": "ok", "device": "src", "auto-dismiss": true, "busy": false, "len": 512, "offset": 512, "status": "ready", "paused": false, "speed": 0, "ready": true, "type": "mirror"}]} 278 278 {"return": {}} 279 279 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} 280 280 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 512, "offset": 512, "speed": 0, "type": "mirror"}}