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

qemu-io: adds option to use aio engine

Signed-off-by: Aarushi Mehta <mehta.aaru20@gmail.com>
Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20200120141858.587874-12-stefanha@redhat.com
Message-Id: <20200120141858.587874-12-stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

authored by

Aarushi Mehta and committed by
Stefan Hajnoczi
1c5a2aec daffeb02

+21 -4
+21 -4
qemu-io.c
··· 130 130 " -C, -- use copy-on-read\n" 131 131 " -n, -- disable host cache, short for -t none\n" 132 132 " -U, -- force shared permissions\n" 133 - " -k, -- use kernel AIO implementation (on Linux only)\n" 133 + " -k, -- use kernel AIO implementation (Linux only, prefer use of -i)\n" 134 + " -i, -- use AIO mode (threads, native or io_uring)\n" 134 135 " -t, -- use the given cache mode for the image\n" 135 136 " -d, -- use the given discard mode for the image\n" 136 137 " -o, -- options to be given to the block driver" ··· 172 173 QDict *opts; 173 174 bool force_share = false; 174 175 175 - while ((c = getopt(argc, argv, "snCro:kt:d:U")) != -1) { 176 + while ((c = getopt(argc, argv, "snCro:ki:t:d:U")) != -1) { 176 177 switch (c) { 177 178 case 's': 178 179 flags |= BDRV_O_SNAPSHOT; ··· 200 201 case 'd': 201 202 if (bdrv_parse_discard_flags(optarg, &flags) < 0) { 202 203 error_report("Invalid discard option: %s", optarg); 204 + qemu_opts_reset(&empty_opts); 205 + return -EINVAL; 206 + } 207 + break; 208 + case 'i': 209 + if (bdrv_parse_aio(optarg, &flags) < 0) { 210 + error_report("Invalid aio option: %s", optarg); 203 211 qemu_opts_reset(&empty_opts); 204 212 return -EINVAL; 205 213 } ··· 291 299 " -n, --nocache disable host cache, short for -t none\n" 292 300 " -C, --copy-on-read enable copy-on-read\n" 293 301 " -m, --misalign misalign allocations for O_DIRECT\n" 294 - " -k, --native-aio use kernel AIO implementation (on Linux only)\n" 302 + " -k, --native-aio use kernel AIO implementation\n" 303 + " (Linux only, prefer use of -i)\n" 304 + " -i, --aio=MODE use AIO mode (threads, native or io_uring)\n" 295 305 " -t, --cache=MODE use the given cache mode for the image\n" 296 306 " -d, --discard=MODE use the given discard mode for the image\n" 297 307 " -T, --trace [[enable=]<pattern>][,events=<file>][,file=<file>]\n" ··· 496 506 int main(int argc, char **argv) 497 507 { 498 508 int readonly = 0; 499 - const char *sopt = "hVc:d:f:rsnCmkt:T:U"; 509 + const char *sopt = "hVc:d:f:rsnCmki:t:T:U"; 500 510 const struct option lopt[] = { 501 511 { "help", no_argument, NULL, 'h' }, 502 512 { "version", no_argument, NULL, 'V' }, ··· 508 518 { "copy-on-read", no_argument, NULL, 'C' }, 509 519 { "misalign", no_argument, NULL, 'm' }, 510 520 { "native-aio", no_argument, NULL, 'k' }, 521 + { "aio", required_argument, NULL, 'i' }, 511 522 { "discard", required_argument, NULL, 'd' }, 512 523 { "cache", required_argument, NULL, 't' }, 513 524 { "trace", required_argument, NULL, 'T' }, ··· 574 585 break; 575 586 case 'k': 576 587 flags |= BDRV_O_NATIVE_AIO; 588 + break; 589 + case 'i': 590 + if (bdrv_parse_aio(optarg, &flags) < 0) { 591 + error_report("Invalid aio option: %s", optarg); 592 + exit(1); 593 + } 577 594 break; 578 595 case 't': 579 596 if (bdrv_parse_cache_mode(optarg, &flags, &writethrough) < 0) {