1 /* 2 * QTest 3 * 4 * Copyright IBM, Corp. 2012 5 * Copyright Red Hat, Inc. 2012 6 * Copyright SUSE LINUX Products GmbH 2013 7 * 8 * Authors: 9 * Anthony Liguori <aliguori@us.ibm.com> 10 * Paolo Bonzini <pbonzini@redhat.com> 11 * Andreas Färber <afaerber@suse.de> 12 * 13 * This work is licensed under the terms of the GNU GPL, version 2 or later. 14 * See the COPYING file in the top-level directory. 15 * 16 */ 17 #ifndef LIBQTEST_H 18 #define LIBQTEST_H 19 20 #include "qapi/qmp/qobject.h" 21 #include "qapi/qmp/qdict.h" 22 #include "libqmp.h" 23 24 typedef struct QTestState QTestState; 25 26 /** 27 * qtest_initf: 28 * @fmt: Format for creating other arguments to pass to QEMU, formatted 29 * like sprintf(). 30 * 31 * Convenience wrapper around qtest_init(). 32 * 33 * Returns: #QTestState instance. 34 */ 35 QTestState *qtest_initf(const char *fmt, ...) G_GNUC_PRINTF(1, 2); 36 37 /** 38 * qtest_vinitf: 39 * @fmt: Format for creating other arguments to pass to QEMU, formatted 40 * like vsprintf(). 41 * @ap: Format arguments. 42 * 43 * Convenience wrapper around qtest_init(). 44 * 45 * Returns: #QTestState instance. 46 */ 47 QTestState *qtest_vinitf(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0); 48 49 /** 50 * qtest_init: 51 * @extra_args: other arguments to pass to QEMU. CAUTION: these 52 * arguments are subject to word splitting and shell evaluation. 53 * 54 * Returns: #QTestState instance. 55 */ 56 QTestState *qtest_init(const char *extra_args); 57 58 /** 59 * qtest_init_without_qmp_handshake: 60 * @extra_args: other arguments to pass to QEMU. CAUTION: these 61 * arguments are subject to word splitting and shell evaluation. 62 * 63 * Returns: #QTestState instance. 64 */ 65 QTestState *qtest_init_without_qmp_handshake(const char *extra_args); 66 67 /** 68 * qtest_init_with_serial: 69 * @extra_args: other arguments to pass to QEMU. CAUTION: these 70 * arguments are subject to word splitting and shell evaluation. 71 * @sock_fd: pointer to store the socket file descriptor for 72 * connection with serial. 73 * 74 * Returns: #QTestState instance. 75 */ 76 QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd); 77 78 /** 79 * qtest_wait_qemu: 80 * @s: #QTestState instance to operate on. 81 * 82 * Wait for the QEMU process to terminate. It is safe to call this function 83 * multiple times. 84 */ 85 void qtest_wait_qemu(QTestState *s); 86 87 /** 88 * qtest_kill_qemu: 89 * @s: #QTestState instance to operate on. 90 * 91 * Kill the QEMU process and wait for it to terminate. It is safe to call this 92 * function multiple times. Normally qtest_quit() is used instead because it 93 * also frees QTestState. Use qtest_kill_qemu() when you just want to kill QEMU 94 * and qtest_quit() will be called later. 95 */ 96 void qtest_kill_qemu(QTestState *s); 97 98 /** 99 * qtest_quit: 100 * @s: #QTestState instance to operate on. 101 * 102 * Shut down the QEMU process associated to @s. 103 */ 104 void qtest_quit(QTestState *s); 105 106 #ifndef _WIN32 107 /** 108 * qtest_qmp_fds: 109 * @s: #QTestState instance to operate on. 110 * @fds: array of file descriptors 111 * @fds_num: number of elements in @fds 112 * @fmt: QMP message to send to qemu, formatted like 113 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 114 * supported after '%'. 115 * 116 * Sends a QMP message to QEMU with fds and returns the response. 117 */ 118 QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num, 119 const char *fmt, ...) 120 G_GNUC_PRINTF(4, 5); 121 #endif /* _WIN32 */ 122 123 /** 124 * qtest_qmp: 125 * @s: #QTestState instance to operate on. 126 * @fmt: QMP message to send to qemu, formatted like 127 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 128 * supported after '%'. 129 * 130 * Sends a QMP message to QEMU and returns the response. 131 */ 132 QDict *qtest_qmp(QTestState *s, const char *fmt, ...) 133 G_GNUC_PRINTF(2, 3); 134 135 /** 136 * qtest_qmp_send: 137 * @s: #QTestState instance to operate on. 138 * @fmt: QMP message to send to qemu, formatted like 139 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 140 * supported after '%'. 141 * 142 * Sends a QMP message to QEMU and leaves the response in the stream. 143 */ 144 void qtest_qmp_send(QTestState *s, const char *fmt, ...) 145 G_GNUC_PRINTF(2, 3); 146 147 /** 148 * qtest_qmp_send_raw: 149 * @s: #QTestState instance to operate on. 150 * @fmt: text to send, formatted like sprintf() 151 * 152 * Sends text to the QMP monitor verbatim. Need not be valid JSON; 153 * this is useful for negative tests. 154 */ 155 void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...) 156 G_GNUC_PRINTF(2, 3); 157 158 /** 159 * qtest_socket_server: 160 * @socket_path: the UNIX domain socket path 161 * 162 * Create and return a listen socket file descriptor, or abort on failure. 163 */ 164 int qtest_socket_server(const char *socket_path); 165 166 #ifndef _WIN32 167 /** 168 * qtest_vqmp_fds: 169 * @s: #QTestState instance to operate on. 170 * @fds: array of file descriptors 171 * @fds_num: number of elements in @fds 172 * @fmt: QMP message to send to QEMU, formatted like 173 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 174 * supported after '%'. 175 * @ap: QMP message arguments 176 * 177 * Sends a QMP message to QEMU with fds and returns the response. 178 */ 179 QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num, 180 const char *fmt, va_list ap) 181 G_GNUC_PRINTF(4, 0); 182 #endif /* _WIN32 */ 183 184 /** 185 * qtest_vqmp: 186 * @s: #QTestState instance to operate on. 187 * @fmt: QMP message to send to QEMU, formatted like 188 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 189 * supported after '%'. 190 * @ap: QMP message arguments 191 * 192 * Sends a QMP message to QEMU and returns the response. 193 */ 194 QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap) 195 G_GNUC_PRINTF(2, 0); 196 197 #ifndef _WIN32 198 /** 199 * qtest_qmp_vsend_fds: 200 * @s: #QTestState instance to operate on. 201 * @fds: array of file descriptors 202 * @fds_num: number of elements in @fds 203 * @fmt: QMP message to send to QEMU, formatted like 204 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 205 * supported after '%'. 206 * @ap: QMP message arguments 207 * 208 * Sends a QMP message to QEMU and leaves the response in the stream. 209 */ 210 void qtest_qmp_vsend_fds(QTestState *s, int *fds, size_t fds_num, 211 const char *fmt, va_list ap) 212 G_GNUC_PRINTF(4, 0); 213 #endif /* _WIN32 */ 214 215 /** 216 * qtest_qmp_vsend: 217 * @s: #QTestState instance to operate on. 218 * @fmt: QMP message to send to QEMU, formatted like 219 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 220 * supported after '%'. 221 * @ap: QMP message arguments 222 * 223 * Sends a QMP message to QEMU and leaves the response in the stream. 224 */ 225 void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap) 226 G_GNUC_PRINTF(2, 0); 227 228 /** 229 * qtest_qmp_receive_dict: 230 * @s: #QTestState instance to operate on. 231 * 232 * Reads a QMP message from QEMU and returns the response. 233 */ 234 QDict *qtest_qmp_receive_dict(QTestState *s); 235 236 /** 237 * qtest_qmp_receive: 238 * @s: #QTestState instance to operate on. 239 * 240 * Reads a QMP message from QEMU and returns the response. 241 * Buffers all the events received meanwhile, until a 242 * call to qtest_qmp_eventwait 243 */ 244 QDict *qtest_qmp_receive(QTestState *s); 245 246 /** 247 * qtest_qmp_eventwait: 248 * @s: #QTestState instance to operate on. 249 * @event: event to wait for. 250 * 251 * Continuously polls for QMP responses until it receives the desired event. 252 */ 253 void qtest_qmp_eventwait(QTestState *s, const char *event); 254 255 /** 256 * qtest_qmp_eventwait_ref: 257 * @s: #QTestState instance to operate on. 258 * @event: event to wait for. 259 * 260 * Continuously polls for QMP responses until it receives the desired event. 261 * Returns a copy of the event for further investigation. 262 */ 263 QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event); 264 265 /** 266 * qtest_qmp_event_ref: 267 * @s: #QTestState instance to operate on. 268 * @event: event to return. 269 * 270 * Removes non-matching events from the buffer that was set by 271 * qtest_qmp_receive, until an event bearing the given name is found, 272 * and returns it. 273 * If no event matches, clears the buffer and returns NULL. 274 * 275 */ 276 QDict *qtest_qmp_event_ref(QTestState *s, const char *event); 277 278 /** 279 * qtest_hmp: 280 * @s: #QTestState instance to operate on. 281 * @fmt: HMP command to send to QEMU, formats arguments like sprintf(). 282 * 283 * Send HMP command to QEMU via QMP's human-monitor-command. 284 * QMP events are discarded. 285 * 286 * Returns: the command's output. The caller should g_free() it. 287 */ 288 char *qtest_hmp(QTestState *s, const char *fmt, ...) G_GNUC_PRINTF(2, 3); 289 290 /** 291 * qtest_hmpv: 292 * @s: #QTestState instance to operate on. 293 * @fmt: HMP command to send to QEMU, formats arguments like vsprintf(). 294 * @ap: HMP command arguments 295 * 296 * Send HMP command to QEMU via QMP's human-monitor-command. 297 * QMP events are discarded. 298 * 299 * Returns: the command's output. The caller should g_free() it. 300 */ 301 char *qtest_vhmp(QTestState *s, const char *fmt, va_list ap) 302 G_GNUC_PRINTF(2, 0); 303 304 void qtest_module_load(QTestState *s, const char *prefix, const char *libname); 305 306 /** 307 * qtest_get_irq: 308 * @s: #QTestState instance to operate on. 309 * @num: Interrupt to observe. 310 * 311 * Returns: The level of the @num interrupt. 312 */ 313 bool qtest_get_irq(QTestState *s, int num); 314 315 /** 316 * qtest_irq_intercept_in: 317 * @s: #QTestState instance to operate on. 318 * @string: QOM path of a device. 319 * 320 * Associate qtest irqs with the GPIO-in pins of the device 321 * whose path is specified by @string. 322 */ 323 void qtest_irq_intercept_in(QTestState *s, const char *string); 324 325 /** 326 * qtest_irq_intercept_out: 327 * @s: #QTestState instance to operate on. 328 * @string: QOM path of a device. 329 * 330 * Associate qtest irqs with the GPIO-out pins of the device 331 * whose path is specified by @string. 332 */ 333 void qtest_irq_intercept_out(QTestState *s, const char *string); 334 335 /** 336 * qtest_set_irq_in: 337 * @s: QTestState instance to operate on. 338 * @string: QOM path of a device 339 * @name: IRQ name 340 * @irq: IRQ number 341 * @level: IRQ level 342 * 343 * Force given device/irq GPIO-in pin to the given level. 344 */ 345 void qtest_set_irq_in(QTestState *s, const char *string, const char *name, 346 int irq, int level); 347 348 /** 349 * qtest_outb: 350 * @s: #QTestState instance to operate on. 351 * @addr: I/O port to write to. 352 * @value: Value being written. 353 * 354 * Write an 8-bit value to an I/O port. 355 */ 356 void qtest_outb(QTestState *s, uint16_t addr, uint8_t value); 357 358 /** 359 * qtest_outw: 360 * @s: #QTestState instance to operate on. 361 * @addr: I/O port to write to. 362 * @value: Value being written. 363 * 364 * Write a 16-bit value to an I/O port. 365 */ 366 void qtest_outw(QTestState *s, uint16_t addr, uint16_t value); 367 368 /** 369 * qtest_outl: 370 * @s: #QTestState instance to operate on. 371 * @addr: I/O port to write to. 372 * @value: Value being written. 373 * 374 * Write a 32-bit value to an I/O port. 375 */ 376 void qtest_outl(QTestState *s, uint16_t addr, uint32_t value); 377 378 /** 379 * qtest_inb: 380 * @s: #QTestState instance to operate on. 381 * @addr: I/O port to read from. 382 * 383 * Returns an 8-bit value from an I/O port. 384 */ 385 uint8_t qtest_inb(QTestState *s, uint16_t addr); 386 387 /** 388 * qtest_inw: 389 * @s: #QTestState instance to operate on. 390 * @addr: I/O port to read from. 391 * 392 * Returns a 16-bit value from an I/O port. 393 */ 394 uint16_t qtest_inw(QTestState *s, uint16_t addr); 395 396 /** 397 * qtest_inl: 398 * @s: #QTestState instance to operate on. 399 * @addr: I/O port to read from. 400 * 401 * Returns a 32-bit value from an I/O port. 402 */ 403 uint32_t qtest_inl(QTestState *s, uint16_t addr); 404 405 /** 406 * qtest_writeb: 407 * @s: #QTestState instance to operate on. 408 * @addr: Guest address to write to. 409 * @value: Value being written. 410 * 411 * Writes an 8-bit value to memory. 412 */ 413 void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value); 414 415 /** 416 * qtest_writew: 417 * @s: #QTestState instance to operate on. 418 * @addr: Guest address to write to. 419 * @value: Value being written. 420 * 421 * Writes a 16-bit value to memory. 422 */ 423 void qtest_writew(QTestState *s, uint64_t addr, uint16_t value); 424 425 /** 426 * qtest_writel: 427 * @s: #QTestState instance to operate on. 428 * @addr: Guest address to write to. 429 * @value: Value being written. 430 * 431 * Writes a 32-bit value to memory. 432 */ 433 void qtest_writel(QTestState *s, uint64_t addr, uint32_t value); 434 435 /** 436 * qtest_writeq: 437 * @s: #QTestState instance to operate on. 438 * @addr: Guest address to write to. 439 * @value: Value being written. 440 * 441 * Writes a 64-bit value to memory. 442 */ 443 void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value); 444 445 /** 446 * qtest_readb: 447 * @s: #QTestState instance to operate on. 448 * @addr: Guest address to read from. 449 * 450 * Reads an 8-bit value from memory. 451 * 452 * Returns: Value read. 453 */ 454 uint8_t qtest_readb(QTestState *s, uint64_t addr); 455 456 /** 457 * qtest_readw: 458 * @s: #QTestState instance to operate on. 459 * @addr: Guest address to read from. 460 * 461 * Reads a 16-bit value from memory. 462 * 463 * Returns: Value read. 464 */ 465 uint16_t qtest_readw(QTestState *s, uint64_t addr); 466 467 /** 468 * qtest_readl: 469 * @s: #QTestState instance to operate on. 470 * @addr: Guest address to read from. 471 * 472 * Reads a 32-bit value from memory. 473 * 474 * Returns: Value read. 475 */ 476 uint32_t qtest_readl(QTestState *s, uint64_t addr); 477 478 /** 479 * qtest_readq: 480 * @s: #QTestState instance to operate on. 481 * @addr: Guest address to read from. 482 * 483 * Reads a 64-bit value from memory. 484 * 485 * Returns: Value read. 486 */ 487 uint64_t qtest_readq(QTestState *s, uint64_t addr); 488 489 /** 490 * qtest_memread: 491 * @s: #QTestState instance to operate on. 492 * @addr: Guest address to read from. 493 * @data: Pointer to where memory contents will be stored. 494 * @size: Number of bytes to read. 495 * 496 * Read guest memory into a buffer. 497 */ 498 void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size); 499 500 /** 501 * qtest_rtas_call: 502 * @s: #QTestState instance to operate on. 503 * @name: name of the command to call. 504 * @nargs: Number of args. 505 * @args: Guest address to read args from. 506 * @nret: Number of return value. 507 * @ret: Guest address to write return values to. 508 * 509 * Call an RTAS function 510 */ 511 uint64_t qtest_rtas_call(QTestState *s, const char *name, 512 uint32_t nargs, uint64_t args, 513 uint32_t nret, uint64_t ret); 514 515 /** 516 * qtest_bufread: 517 * @s: #QTestState instance to operate on. 518 * @addr: Guest address to read from. 519 * @data: Pointer to where memory contents will be stored. 520 * @size: Number of bytes to read. 521 * 522 * Read guest memory into a buffer and receive using a base64 encoding. 523 */ 524 void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size); 525 526 /** 527 * qtest_memwrite: 528 * @s: #QTestState instance to operate on. 529 * @addr: Guest address to write to. 530 * @data: Pointer to the bytes that will be written to guest memory. 531 * @size: Number of bytes to write. 532 * 533 * Write a buffer to guest memory. 534 */ 535 void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size); 536 537 /** 538 * qtest_bufwrite: 539 * @s: #QTestState instance to operate on. 540 * @addr: Guest address to write to. 541 * @data: Pointer to the bytes that will be written to guest memory. 542 * @size: Number of bytes to write. 543 * 544 * Write a buffer to guest memory and transmit using a base64 encoding. 545 */ 546 void qtest_bufwrite(QTestState *s, uint64_t addr, 547 const void *data, size_t size); 548 549 /** 550 * qtest_memset: 551 * @s: #QTestState instance to operate on. 552 * @addr: Guest address to write to. 553 * @patt: Byte pattern to fill the guest memory region with. 554 * @size: Number of bytes to write. 555 * 556 * Write a pattern to guest memory. 557 */ 558 void qtest_memset(QTestState *s, uint64_t addr, uint8_t patt, size_t size); 559 560 /** 561 * qtest_clock_step_next: 562 * @s: #QTestState instance to operate on. 563 * 564 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline. 565 * 566 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds. 567 */ 568 int64_t qtest_clock_step_next(QTestState *s); 569 570 /** 571 * qtest_clock_step: 572 * @s: QTestState instance to operate on. 573 * @step: Number of nanoseconds to advance the clock by. 574 * 575 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds. 576 * 577 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds. 578 */ 579 int64_t qtest_clock_step(QTestState *s, int64_t step); 580 581 /** 582 * qtest_clock_set: 583 * @s: QTestState instance to operate on. 584 * @val: Nanoseconds value to advance the clock to. 585 * 586 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched. 587 * 588 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds. 589 */ 590 int64_t qtest_clock_set(QTestState *s, int64_t val); 591 592 /** 593 * qtest_big_endian: 594 * @s: QTestState instance to operate on. 595 * 596 * Returns: True if the architecture under test has a big endian configuration. 597 */ 598 bool qtest_big_endian(QTestState *s); 599 600 /** 601 * qtest_get_arch: 602 * 603 * Returns: The architecture for the QEMU executable under test. 604 */ 605 const char *qtest_get_arch(void); 606 607 /** 608 * qtest_has_accel: 609 * @accel_name: Accelerator name to check for. 610 * 611 * Returns: true if the accelerator is built in. 612 */ 613 bool qtest_has_accel(const char *accel_name); 614 615 /** 616 * qtest_add_func: 617 * @str: Test case path. 618 * @fn: Test case function 619 * 620 * Add a GTester testcase with the given name and function. 621 * The path is prefixed with the architecture under test, as 622 * returned by qtest_get_arch(). 623 */ 624 void qtest_add_func(const char *str, void (*fn)(void)); 625 626 /** 627 * qtest_add_data_func: 628 * @str: Test case path. 629 * @data: Test case data 630 * @fn: Test case function 631 * 632 * Add a GTester testcase with the given name, data and function. 633 * The path is prefixed with the architecture under test, as 634 * returned by qtest_get_arch(). 635 */ 636 void qtest_add_data_func(const char *str, const void *data, 637 void (*fn)(const void *)); 638 639 /** 640 * qtest_add_data_func_full: 641 * @str: Test case path. 642 * @data: Test case data 643 * @fn: Test case function 644 * @data_free_func: GDestroyNotify for data 645 * 646 * Add a GTester testcase with the given name, data and function. 647 * The path is prefixed with the architecture under test, as 648 * returned by qtest_get_arch(). 649 * 650 * @data is passed to @data_free_func() on test completion. 651 */ 652 void qtest_add_data_func_full(const char *str, void *data, 653 void (*fn)(const void *), 654 GDestroyNotify data_free_func); 655 656 /** 657 * qtest_add: 658 * @testpath: Test case path 659 * @Fixture: Fixture type 660 * @tdata: Test case data 661 * @fsetup: Test case setup function 662 * @ftest: Test case function 663 * @fteardown: Test case teardown function 664 * 665 * Add a GTester testcase with the given name, data and functions. 666 * The path is prefixed with the architecture under test, as 667 * returned by qtest_get_arch(). 668 */ 669 #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \ 670 do { \ 671 char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \ 672 g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \ 673 g_free(path); \ 674 } while (0) 675 676 /** 677 * qtest_add_abrt_handler: 678 * @fn: Handler function 679 * @data: Argument that is passed to the handler 680 * 681 * Add a handler function that is invoked on SIGABRT. This can be used to 682 * terminate processes and perform other cleanup. The handler can be removed 683 * with qtest_remove_abrt_handler(). 684 */ 685 void qtest_add_abrt_handler(GHookFunc fn, const void *data); 686 687 /** 688 * qtest_remove_abrt_handler: 689 * @data: Argument previously passed to qtest_add_abrt_handler() 690 * 691 * Remove an abrt handler that was previously added with 692 * qtest_add_abrt_handler(). 693 */ 694 void qtest_remove_abrt_handler(void *data); 695 696 /** 697 * qtest_qmp_assert_success: 698 * @qts: QTestState instance to operate on 699 * @fmt: QMP message to send to qemu, formatted like 700 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 701 * supported after '%'. 702 * 703 * Sends a QMP message to QEMU and asserts that a 'return' key is present in 704 * the response. 705 */ 706 void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...) 707 G_GNUC_PRINTF(2, 3); 708 709 /** 710 * qtest_cb_for_every_machine: 711 * @cb: Pointer to the callback function 712 * @skip_old_versioned: true if versioned old machine types should be skipped 713 * 714 * Call a callback function for every name of all available machines. 715 */ 716 void qtest_cb_for_every_machine(void (*cb)(const char *machine), 717 bool skip_old_versioned); 718 719 /** 720 * qtest_has_machine: 721 * @machine: The machine to look for 722 * 723 * Returns: true if the machine is available in the target binary. 724 */ 725 bool qtest_has_machine(const char *machine); 726 727 /** 728 * qtest_has_device: 729 * @device: The device to look for 730 * 731 * Returns: true if the device is available in the target binary. 732 */ 733 bool qtest_has_device(const char *device); 734 735 /** 736 * qtest_qmp_device_add_qdict: 737 * @qts: QTestState instance to operate on 738 * @drv: Name of the device that should be added 739 * @arguments: QDict with properties for the device to initialize 740 * 741 * Generic hot-plugging test via the device_add QMP command with properties 742 * supplied in form of QDict. Use NULL for empty properties list. 743 */ 744 void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv, 745 const QDict *arguments); 746 747 /** 748 * qtest_qmp_device_add: 749 * @qts: QTestState instance to operate on 750 * @driver: Name of the device that should be added 751 * @id: Identification string 752 * @fmt: QMP message to send to qemu, formatted like 753 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 754 * supported after '%'. 755 * 756 * Generic hot-plugging test via the device_add QMP command. 757 */ 758 void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id, 759 const char *fmt, ...) G_GNUC_PRINTF(4, 5); 760 761 /** 762 * qtest_qmp_add_client: 763 * @qts: QTestState instance to operate on 764 * @protocol: the protocol to add to 765 * @fd: the client file-descriptor 766 * 767 * Call QMP ``getfd`` (on Windows ``get-win32-socket``) followed by 768 * ``add_client`` with the given @fd. 769 */ 770 void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd); 771 772 /** 773 * qtest_qmp_device_del_send: 774 * @qts: QTestState instance to operate on 775 * @id: Identification string 776 * 777 * Generic hot-unplugging test via the device_del QMP command. 778 */ 779 void qtest_qmp_device_del_send(QTestState *qts, const char *id); 780 781 /** 782 * qtest_qmp_device_del: 783 * @qts: QTestState instance to operate on 784 * @id: Identification string 785 * 786 * Generic hot-unplugging test via the device_del QMP command. 787 * Waiting for command completion event. 788 */ 789 void qtest_qmp_device_del(QTestState *qts, const char *id); 790 791 /** 792 * qtest_probe_child: 793 * @s: QTestState instance to operate on. 794 * 795 * Returns: true if the child is still alive. 796 */ 797 bool qtest_probe_child(QTestState *s); 798 799 /** 800 * qtest_set_expected_status: 801 * @s: QTestState instance to operate on. 802 * @status: an expected exit status. 803 * 804 * Set expected exit status of the child. 805 */ 806 void qtest_set_expected_status(QTestState *s, int status); 807 808 QTestState *qtest_inproc_init(QTestState **s, bool log, const char* arch, 809 void (*send)(void*, const char*)); 810 811 void qtest_client_inproc_recv(void *opaque, const char *str); 812 813 /** 814 * qtest_qom_set_bool: 815 * @s: QTestState instance to operate on. 816 * @path: Path to the property being set. 817 * @property: Property being set. 818 * @value: Value to set the property. 819 * 820 * Set the property with passed in value. 821 */ 822 void qtest_qom_set_bool(QTestState *s, const char *path, const char *property, 823 bool value); 824 825 /** 826 * qtest_qom_get_bool: 827 * @s: QTestState instance to operate on. 828 * @path: Path to the property being retrieved. 829 * @property: Property from where the value is being retrieved. 830 * 831 * Returns: Value retrieved from property. 832 */ 833 bool qtest_qom_get_bool(QTestState *s, const char *path, const char *property); 834 #endif 835