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