* [Qemu-devel] [PATCH 1/2] qtest: don't configure icount if qtest not allowed @ 2013-10-17 21:52 Michael S. Tsirkin 2013-10-17 21:52 ` [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test Michael S. Tsirkin 2013-10-18 11:51 ` [Qemu-devel] [PATCH 1/2] qtest: don't configure icount if qtest not allowed Paolo Bonzini 0 siblings, 2 replies; 11+ messages in thread From: Michael S. Tsirkin @ 2013-10-17 21:52 UTC (permalink / raw) To: qemu-devel; +Cc: pbonzini, Anthony Liguori This makes it possible to run bios under qtest Signed-off-by: Michael S. Tsirkin <mst@redhat.com> --- qtest.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qtest.c b/qtest.c index 584c707..48e3288 100644 --- a/qtest.c +++ b/qtest.c @@ -508,7 +508,9 @@ int qtest_init(void) g_assert(qtest_chrdev != NULL); - configure_icount("0"); + if (qtest_enabled()) { + configure_icount("0"); + } chr = qemu_chr_new("qtest", qtest_chrdev, NULL); qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr); -- MST ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test 2013-10-17 21:52 [Qemu-devel] [PATCH 1/2] qtest: don't configure icount if qtest not allowed Michael S. Tsirkin @ 2013-10-17 21:52 ` Michael S. Tsirkin 2013-10-18 5:30 ` Markus Armbruster 2013-10-19 0:13 ` Andreas Färber 2013-10-18 11:51 ` [Qemu-devel] [PATCH 1/2] qtest: don't configure icount if qtest not allowed Paolo Bonzini 1 sibling, 2 replies; 11+ messages in thread From: Michael S. Tsirkin @ 2013-10-17 21:52 UTC (permalink / raw) To: qemu-devel; +Cc: pbonzini, Anthony Liguori We run bios, and boot a minimal boot sector that immediately halts. Then poke at memory to find ACPI tables. This only checks that RSDP is there. More will be added later. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> --- tests/acpi-test.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/Makefile | 2 + 2 files changed, 131 insertions(+) create mode 100644 tests/acpi-test.c diff --git a/tests/acpi-test.c b/tests/acpi-test.c new file mode 100644 index 0000000..42de248 --- /dev/null +++ b/tests/acpi-test.c @@ -0,0 +1,129 @@ +/* + * Boot order test cases. + * + * Copyright (c) 2013 Red Hat Inc. + * + * Authors: + * Markus Armbruster <armbru@redhat.com>, + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include <string.h> +#include <stdio.h> +#include <glib.h> +#include "libqtest.h" + +typedef struct { + const char *args; + uint64_t expected_boot; + uint64_t expected_reboot; +} boot_order_test; + +#define LOW(x) ((x) & 0xff) +#define HIGH(x) ((x) >> 8) + +#define SIGNATURE 0xdead +#define SIGNATURE_OFFSET 0x10 +#define BOOT_SECTOR_ADDRESS 0x7c00 + +static uint8_t boot_sector[0x200] = { + /* 7c00: mov $0xdead,%ax */ + [0x00] = 0xb8, + [0x01] = LOW(SIGNATURE), + [0x02] = HIGH(SIGNATURE), + /* 7c03: mov %ax,0x7c10 */ + [0x03] = 0xa3, + [0x04] = LOW(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET), + [0x05] = HIGH(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET), + /* 7c06: hlt */ + [0x06] = 0xf4, + /* 7c07: jmp 0x7c06=0x7c09-3 */ + [0x07] = 0xeb, + [0x08] = LOW(-3), + /* We mov 0xdead here: set value to make debugging easier */ + [SIGNATURE_OFFSET] = LOW(0xface), + [SIGNATURE_OFFSET + 1] = HIGH(0xface), + /* End of boot sector marker */ + [0x1FE] = 0x55, + [0x1FF] = 0xAA, +}; + +static const char *disk = "tests/acpi-test-disk.raw"; + +static void test_acpi_one(const char *params) +{ + char *args; + uint8_t signature_low; + uint8_t signature_high; + uint16_t signature; + int i; + uint32_t off; + + + args = g_strdup_printf("-net none -display none %s %s", + params ? params : "", disk); + qtest_start(args); + + /* Wait at most 1 minute */ +#define TEST_DELAY (1 * G_USEC_PER_SEC / 10) +#define TEST_CYCLES (60 * G_USEC_PER_SEC / TEST_DELAY) + + for (i = 0; i < TEST_CYCLES; ++i) { + signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET); + signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1); + signature = (signature_high << 8) | signature_low; + if (signature == SIGNATURE) { + break; + } + g_usleep(TEST_DELAY); + } + g_assert_cmphex(signature, ==, SIGNATURE); + + /* OK, now find RSDP */ + for (off = 0xf0000; off < 0x100000; off += 0x10) + { + uint8_t sig[] = "RSD PTR "; + int i; + + for (i = 0; i < sizeof sig - 1; ++i) { + sig[i] = readb(off + i); + } + + if (!memcmp(sig, "RSD PTR ", sizeof sig)) { + break; + } + } + + g_assert_cmphex(off, <, 0x100000); + + qtest_quit(global_qtest); + g_free(args); +} + +static void test_acpi_tcg(void) +{ + test_acpi_one("-machine accel=tcg"); +} + +static void test_acpi_kvm(void) +{ + test_acpi_one("-enable-kvm -machine accel=kvm"); +} + +int main(int argc, char *argv[]) +{ + const char *arch = qtest_get_arch(); + FILE *f = fopen(disk, "w"); + fwrite(boot_sector, 1, sizeof boot_sector, f); + fclose(f); + + g_test_init(&argc, &argv, NULL); + + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { + qtest_add_func("acpi/tcg", test_acpi_tcg); + qtest_add_func("acpi/kvm", test_acpi_kvm); + } + return g_test_run(); +} diff --git a/tests/Makefile b/tests/Makefile index c13fefc..a81a005 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -64,6 +64,7 @@ check-qtest-i386-y += tests/ide-test$(EXESUF) check-qtest-i386-y += tests/hd-geo-test$(EXESUF) gcov-files-i386-y += hw/hd-geometry.c check-qtest-i386-y += tests/boot-order-test$(EXESUF) +check-qtest-i386-y += tests/acpi-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF) check-qtest-i386-y += tests/i440fx-test$(EXESUF) check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) @@ -171,6 +172,7 @@ tests/fdc-test$(EXESUF): tests/fdc-test.o tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y) tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) +tests/acpi-test$(EXESUF): tests/acpi-test.o $(libqos-obj-y) tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y) tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y) tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y) -- MST ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test 2013-10-17 21:52 ` [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test Michael S. Tsirkin @ 2013-10-18 5:30 ` Markus Armbruster 2013-10-18 6:36 ` Paolo Bonzini 2013-10-18 11:20 ` Michael S. Tsirkin 2013-10-19 0:13 ` Andreas Färber 1 sibling, 2 replies; 11+ messages in thread From: Markus Armbruster @ 2013-10-18 5:30 UTC (permalink / raw) To: Michael S. Tsirkin; +Cc: pbonzini, qemu-devel, Anthony Liguori "Michael S. Tsirkin" <mst@redhat.com> writes: > We run bios, and boot a minimal boot sector that immediately halts. > Then poke at memory to find ACPI tables. > > This only checks that RSDP is there. > More will be added later. > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > --- > tests/acpi-test.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > tests/Makefile | 2 + > 2 files changed, 131 insertions(+) > create mode 100644 tests/acpi-test.c > > diff --git a/tests/acpi-test.c b/tests/acpi-test.c > new file mode 100644 > index 0000000..42de248 > --- /dev/null > +++ b/tests/acpi-test.c > @@ -0,0 +1,129 @@ > +/* > + * Boot order test cases. > + * > + * Copyright (c) 2013 Red Hat Inc. > + * > + * Authors: > + * Markus Armbruster <armbru@redhat.com>, > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or later. > + * See the COPYING file in the top-level directory. > + */ Please update the file comment :) > + > +#include <string.h> > +#include <stdio.h> > +#include <glib.h> > +#include "libqtest.h" > + > +typedef struct { > + const char *args; > + uint64_t expected_boot; > + uint64_t expected_reboot; > +} boot_order_test; > + > +#define LOW(x) ((x) & 0xff) > +#define HIGH(x) ((x) >> 8) > + > +#define SIGNATURE 0xdead > +#define SIGNATURE_OFFSET 0x10 > +#define BOOT_SECTOR_ADDRESS 0x7c00 > + > +static uint8_t boot_sector[0x200] = { > + /* 7c00: mov $0xdead,%ax */ > + [0x00] = 0xb8, > + [0x01] = LOW(SIGNATURE), > + [0x02] = HIGH(SIGNATURE), > + /* 7c03: mov %ax,0x7c10 */ > + [0x03] = 0xa3, > + [0x04] = LOW(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET), > + [0x05] = HIGH(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET), > + /* 7c06: hlt */ > + [0x06] = 0xf4, > + /* 7c07: jmp 0x7c06=0x7c09-3 */ > + [0x07] = 0xeb, > + [0x08] = LOW(-3), > + /* We mov 0xdead here: set value to make debugging easier */ > + [SIGNATURE_OFFSET] = LOW(0xface), > + [SIGNATURE_OFFSET + 1] = HIGH(0xface), > + /* End of boot sector marker */ > + [0x1FE] = 0x55, > + [0x1FF] = 0xAA, > +}; > + > +static const char *disk = "tests/acpi-test-disk.raw"; > + > +static void test_acpi_one(const char *params) > +{ > + char *args; > + uint8_t signature_low; > + uint8_t signature_high; > + uint16_t signature; > + int i; > + uint32_t off; > + > + > + args = g_strdup_printf("-net none -display none %s %s", > + params ? params : "", disk); Never called with null params. > + qtest_start(args); > + > + /* Wait at most 1 minute */ > +#define TEST_DELAY (1 * G_USEC_PER_SEC / 10) > +#define TEST_CYCLES (60 * G_USEC_PER_SEC / TEST_DELAY) > + > + for (i = 0; i < TEST_CYCLES; ++i) { > + signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET); > + signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1); > + signature = (signature_high << 8) | signature_low; > + if (signature == SIGNATURE) { > + break; > + } > + g_usleep(TEST_DELAY); > + } > + g_assert_cmphex(signature, ==, SIGNATURE); > + > + /* OK, now find RSDP */ > + for (off = 0xf0000; off < 0x100000; off += 0x10) > + { > + uint8_t sig[] = "RSD PTR "; > + int i; > + > + for (i = 0; i < sizeof sig - 1; ++i) { > + sig[i] = readb(off + i); > + } > + > + if (!memcmp(sig, "RSD PTR ", sizeof sig)) { > + break; > + } > + } > + > + g_assert_cmphex(off, <, 0x100000); > + > + qtest_quit(global_qtest); > + g_free(args); > +} > + > +static void test_acpi_tcg(void) > +{ > + test_acpi_one("-machine accel=tcg"); > +} Since qtest_init() adds your parameters at the end, this should result in a command line ending with "-machine accel=qtest -machine accel=tcg", which should result in qtest. How does this work? > + > +static void test_acpi_kvm(void) > +{ > + test_acpi_one("-enable-kvm -machine accel=kvm"); > +} Isn't -enable-kvm redundant? > + > +int main(int argc, char *argv[]) > +{ > + const char *arch = qtest_get_arch(); > + FILE *f = fopen(disk, "w"); > + fwrite(boot_sector, 1, sizeof boot_sector, f); > + fclose(f); > + > + g_test_init(&argc, &argv, NULL); > + > + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { > + qtest_add_func("acpi/tcg", test_acpi_tcg); > + qtest_add_func("acpi/kvm", test_acpi_kvm); > + } > + return g_test_run(); > +} > diff --git a/tests/Makefile b/tests/Makefile > index c13fefc..a81a005 100644 > --- a/tests/Makefile > +++ b/tests/Makefile > @@ -64,6 +64,7 @@ check-qtest-i386-y += tests/ide-test$(EXESUF) > check-qtest-i386-y += tests/hd-geo-test$(EXESUF) > gcov-files-i386-y += hw/hd-geometry.c > check-qtest-i386-y += tests/boot-order-test$(EXESUF) > +check-qtest-i386-y += tests/acpi-test$(EXESUF) > check-qtest-i386-y += tests/rtc-test$(EXESUF) > check-qtest-i386-y += tests/i440fx-test$(EXESUF) > check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) > @@ -171,6 +172,7 @@ tests/fdc-test$(EXESUF): tests/fdc-test.o > tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y) > tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o > tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) > +tests/acpi-test$(EXESUF): tests/acpi-test.o $(libqos-obj-y) > tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y) > tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y) > tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y) ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test 2013-10-18 5:30 ` Markus Armbruster @ 2013-10-18 6:36 ` Paolo Bonzini 2013-10-18 11:43 ` Markus Armbruster 2013-10-18 11:20 ` Michael S. Tsirkin 1 sibling, 1 reply; 11+ messages in thread From: Paolo Bonzini @ 2013-10-18 6:36 UTC (permalink / raw) To: Markus Armbruster; +Cc: qemu-devel, Anthony Liguori, Michael S. Tsirkin Il 18/10/2013 07:30, Markus Armbruster ha scritto: > > +static void test_acpi_tcg(void) > > +{ > > + test_acpi_one("-machine accel=tcg"); > > +} > > Since qtest_init() adds your parameters at the end, this should result > in a command line ending with "-machine accel=qtest -machine accel=tcg", > which should result in qtest. How does this work? The last option wins. Paolo ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test 2013-10-18 6:36 ` Paolo Bonzini @ 2013-10-18 11:43 ` Markus Armbruster 0 siblings, 0 replies; 11+ messages in thread From: Markus Armbruster @ 2013-10-18 11:43 UTC (permalink / raw) To: Paolo Bonzini; +Cc: qemu-devel, Anthony Liguori, Michael S. Tsirkin Paolo Bonzini <pbonzini@redhat.com> writes: > Il 18/10/2013 07:30, Markus Armbruster ha scritto: >> > +static void test_acpi_tcg(void) >> > +{ >> > + test_acpi_one("-machine accel=tcg"); >> > +} >> >> Since qtest_init() adds your parameters at the end, this should result >> in a command line ending with "-machine accel=qtest -machine accel=tcg", >> which should result in qtest. How does this work? > > The last option wins. You're right. Exploiting it in a qtest is quite a hack :) ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test 2013-10-18 5:30 ` Markus Armbruster 2013-10-18 6:36 ` Paolo Bonzini @ 2013-10-18 11:20 ` Michael S. Tsirkin 1 sibling, 0 replies; 11+ messages in thread From: Michael S. Tsirkin @ 2013-10-18 11:20 UTC (permalink / raw) To: Markus Armbruster; +Cc: pbonzini, qemu-devel, Anthony Liguori On Fri, Oct 18, 2013 at 07:30:48AM +0200, Markus Armbruster wrote: > "Michael S. Tsirkin" <mst@redhat.com> writes: > > > We run bios, and boot a minimal boot sector that immediately halts. > > Then poke at memory to find ACPI tables. > > > > This only checks that RSDP is there. > > More will be added later. > > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > --- > > tests/acpi-test.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > tests/Makefile | 2 + > > 2 files changed, 131 insertions(+) > > create mode 100644 tests/acpi-test.c > > > > diff --git a/tests/acpi-test.c b/tests/acpi-test.c > > new file mode 100644 > > index 0000000..42de248 > > --- /dev/null > > +++ b/tests/acpi-test.c > > @@ -0,0 +1,129 @@ > > +/* > > + * Boot order test cases. > > + * > > + * Copyright (c) 2013 Red Hat Inc. > > + * > > + * Authors: > > + * Markus Armbruster <armbru@redhat.com>, > > + * > > + * This work is licensed under the terms of the GNU GPL, version 2 or later. > > + * See the COPYING file in the top-level directory. > > + */ > > Please update the file comment :) > > > + > > +#include <string.h> > > +#include <stdio.h> > > +#include <glib.h> > > +#include "libqtest.h" > > + > > +typedef struct { > > + const char *args; > > + uint64_t expected_boot; > > + uint64_t expected_reboot; > > +} boot_order_test; > > + > > +#define LOW(x) ((x) & 0xff) > > +#define HIGH(x) ((x) >> 8) > > + > > +#define SIGNATURE 0xdead > > +#define SIGNATURE_OFFSET 0x10 > > +#define BOOT_SECTOR_ADDRESS 0x7c00 > > + > > +static uint8_t boot_sector[0x200] = { > > + /* 7c00: mov $0xdead,%ax */ > > + [0x00] = 0xb8, > > + [0x01] = LOW(SIGNATURE), > > + [0x02] = HIGH(SIGNATURE), > > + /* 7c03: mov %ax,0x7c10 */ > > + [0x03] = 0xa3, > > + [0x04] = LOW(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET), > > + [0x05] = HIGH(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET), > > + /* 7c06: hlt */ > > + [0x06] = 0xf4, > > + /* 7c07: jmp 0x7c06=0x7c09-3 */ > > + [0x07] = 0xeb, > > + [0x08] = LOW(-3), > > + /* We mov 0xdead here: set value to make debugging easier */ > > + [SIGNATURE_OFFSET] = LOW(0xface), > > + [SIGNATURE_OFFSET + 1] = HIGH(0xface), > > + /* End of boot sector marker */ > > + [0x1FE] = 0x55, > > + [0x1FF] = 0xAA, > > +}; > > + > > +static const char *disk = "tests/acpi-test-disk.raw"; > > + > > +static void test_acpi_one(const char *params) > > +{ > > + char *args; > > + uint8_t signature_low; > > + uint8_t signature_high; > > + uint16_t signature; > > + int i; > > + uint32_t off; > > + > > + > > + args = g_strdup_printf("-net none -display none %s %s", > > + params ? params : "", disk); > > Never called with null params. > > > + qtest_start(args); > > + > > + /* Wait at most 1 minute */ > > +#define TEST_DELAY (1 * G_USEC_PER_SEC / 10) > > +#define TEST_CYCLES (60 * G_USEC_PER_SEC / TEST_DELAY) > > + > > + for (i = 0; i < TEST_CYCLES; ++i) { > > + signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET); > > + signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1); > > + signature = (signature_high << 8) | signature_low; > > + if (signature == SIGNATURE) { > > + break; > > + } > > + g_usleep(TEST_DELAY); > > + } > > + g_assert_cmphex(signature, ==, SIGNATURE); > > + > > + /* OK, now find RSDP */ > > + for (off = 0xf0000; off < 0x100000; off += 0x10) > > + { > > + uint8_t sig[] = "RSD PTR "; > > + int i; > > + > > + for (i = 0; i < sizeof sig - 1; ++i) { > > + sig[i] = readb(off + i); > > + } > > + > > + if (!memcmp(sig, "RSD PTR ", sizeof sig)) { > > + break; > > + } > > + } > > + > > + g_assert_cmphex(off, <, 0x100000); > > + > > + qtest_quit(global_qtest); > > + g_free(args); > > +} > > + > > +static void test_acpi_tcg(void) > > +{ > > + test_acpi_one("-machine accel=tcg"); > > +} > > Since qtest_init() adds your parameters at the end, this should result > in a command line ending with "-machine accel=qtest -machine accel=tcg", > which should result in qtest. How does this work? At least I can testify that it works :) >From what I saw latest value for accel overrides the former value. > > + > > +static void test_acpi_kvm(void) > > +{ > > + test_acpi_one("-enable-kvm -machine accel=kvm"); > > +} > > Isn't -enable-kvm redundant? I'm not sure - is it? Will have to check. > > + > > +int main(int argc, char *argv[]) > > +{ > > + const char *arch = qtest_get_arch(); > > + FILE *f = fopen(disk, "w"); > > + fwrite(boot_sector, 1, sizeof boot_sector, f); > > + fclose(f); > > + > > + g_test_init(&argc, &argv, NULL); > > + > > + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { > > + qtest_add_func("acpi/tcg", test_acpi_tcg); > > + qtest_add_func("acpi/kvm", test_acpi_kvm); > > + } > > + return g_test_run(); > > +} > > diff --git a/tests/Makefile b/tests/Makefile > > index c13fefc..a81a005 100644 > > --- a/tests/Makefile > > +++ b/tests/Makefile > > @@ -64,6 +64,7 @@ check-qtest-i386-y += tests/ide-test$(EXESUF) > > check-qtest-i386-y += tests/hd-geo-test$(EXESUF) > > gcov-files-i386-y += hw/hd-geometry.c > > check-qtest-i386-y += tests/boot-order-test$(EXESUF) > > +check-qtest-i386-y += tests/acpi-test$(EXESUF) > > check-qtest-i386-y += tests/rtc-test$(EXESUF) > > check-qtest-i386-y += tests/i440fx-test$(EXESUF) > > check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) > > @@ -171,6 +172,7 @@ tests/fdc-test$(EXESUF): tests/fdc-test.o > > tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y) > > tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o > > tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) > > +tests/acpi-test$(EXESUF): tests/acpi-test.o $(libqos-obj-y) > > tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y) > > tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y) > > tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y) ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test 2013-10-17 21:52 ` [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test Michael S. Tsirkin 2013-10-18 5:30 ` Markus Armbruster @ 2013-10-19 0:13 ` Andreas Färber 2013-10-19 1:25 ` Anthony Liguori 2013-10-19 17:27 ` Michael S. Tsirkin 1 sibling, 2 replies; 11+ messages in thread From: Andreas Färber @ 2013-10-19 0:13 UTC (permalink / raw) To: Michael S. Tsirkin, qemu-devel Cc: pbonzini, Markus Armbruster, Anthony Liguori Am 17.10.2013 23:52, schrieb Michael S. Tsirkin: > diff --git a/tests/acpi-test.c b/tests/acpi-test.c > new file mode 100644 > index 0000000..42de248 > --- /dev/null > +++ b/tests/acpi-test.c [...] > +static void test_acpi_one(const char *params) > +{ > + char *args; > + uint8_t signature_low; > + uint8_t signature_high; > + uint16_t signature; > + int i; > + uint32_t off; > + > + > + args = g_strdup_printf("-net none -display none %s %s", > + params ? params : "", disk); > + qtest_start(args); > + > + /* Wait at most 1 minute */ > +#define TEST_DELAY (1 * G_USEC_PER_SEC / 10) > +#define TEST_CYCLES (60 * G_USEC_PER_SEC / TEST_DELAY) > + > + for (i = 0; i < TEST_CYCLES; ++i) { > + signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET); > + signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1); > + signature = (signature_high << 8) | signature_low; > + if (signature == SIGNATURE) { > + break; > + } > + g_usleep(TEST_DELAY); > + } > + g_assert_cmphex(signature, ==, SIGNATURE); Might be a good safety precaution to use QEMU_BUG_ON() or MIN(..., 1) for TEST_CYCLES to assure signature gets initialized before comparison. > + > + /* OK, now find RSDP */ > + for (off = 0xf0000; off < 0x100000; off += 0x10) > + { > + uint8_t sig[] = "RSD PTR "; > + int i; > + > + for (i = 0; i < sizeof sig - 1; ++i) { > + sig[i] = readb(off + i); > + } > + > + if (!memcmp(sig, "RSD PTR ", sizeof sig)) { > + break; > + } > + } > + > + g_assert_cmphex(off, <, 0x100000); > + > + qtest_quit(global_qtest); > + g_free(args); > +} > + > +static void test_acpi_tcg(void) > +{ > + test_acpi_one("-machine accel=tcg"); > +} > + > +static void test_acpi_kvm(void) > +{ > + test_acpi_one("-enable-kvm -machine accel=kvm"); > +} > + > +int main(int argc, char *argv[]) > +{ > + const char *arch = qtest_get_arch(); > + FILE *f = fopen(disk, "w"); > + fwrite(boot_sector, 1, sizeof boot_sector, f); > + fclose(f); > + > + g_test_init(&argc, &argv, NULL); > + > + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { > + qtest_add_func("acpi/tcg", test_acpi_tcg); > + qtest_add_func("acpi/kvm", test_acpi_kvm); Sorry, while the intention is good, this is a no-go. Not only will make check fail on KVM-incompatible x86 hosts (including insufficient permissions for /dev/kvm), it will also fail on ppc or arm hosts since we are testing the target architecture here. Regards, Andreas > + } > + return g_test_run(); > +} [snip] -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test 2013-10-19 0:13 ` Andreas Färber @ 2013-10-19 1:25 ` Anthony Liguori 2013-10-19 17:27 ` Michael S. Tsirkin 1 sibling, 0 replies; 11+ messages in thread From: Anthony Liguori @ 2013-10-19 1:25 UTC (permalink / raw) To: Andreas Färber Cc: Paolo Bonzini, qemu-devel, Markus Armbruster, Michael S. Tsirkin On Fri, Oct 18, 2013 at 5:13 PM, Andreas Färber <afaerber@suse.de> wrote: > Am 17.10.2013 23:52, schrieb Michael S. Tsirkin: >> diff --git a/tests/acpi-test.c b/tests/acpi-test.c >> new file mode 100644 >> index 0000000..42de248 >> --- /dev/null >> +++ b/tests/acpi-test.c > [...] >> +static void test_acpi_one(const char *params) >> +{ >> + char *args; >> + uint8_t signature_low; >> + uint8_t signature_high; >> + uint16_t signature; >> + int i; >> + uint32_t off; >> + >> + >> + args = g_strdup_printf("-net none -display none %s %s", >> + params ? params : "", disk); >> + qtest_start(args); >> + >> + /* Wait at most 1 minute */ >> +#define TEST_DELAY (1 * G_USEC_PER_SEC / 10) >> +#define TEST_CYCLES (60 * G_USEC_PER_SEC / TEST_DELAY) >> + >> + for (i = 0; i < TEST_CYCLES; ++i) { >> + signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET); >> + signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1); >> + signature = (signature_high << 8) | signature_low; >> + if (signature == SIGNATURE) { >> + break; >> + } >> + g_usleep(TEST_DELAY); >> + } >> + g_assert_cmphex(signature, ==, SIGNATURE); > > Might be a good safety precaution to use QEMU_BUG_ON() or MIN(..., 1) > for TEST_CYCLES to assure signature gets initialized before comparison. > >> + >> + /* OK, now find RSDP */ >> + for (off = 0xf0000; off < 0x100000; off += 0x10) >> + { >> + uint8_t sig[] = "RSD PTR "; >> + int i; >> + >> + for (i = 0; i < sizeof sig - 1; ++i) { >> + sig[i] = readb(off + i); >> + } >> + >> + if (!memcmp(sig, "RSD PTR ", sizeof sig)) { >> + break; >> + } >> + } >> + >> + g_assert_cmphex(off, <, 0x100000); >> + >> + qtest_quit(global_qtest); >> + g_free(args); >> +} >> + >> +static void test_acpi_tcg(void) >> +{ >> + test_acpi_one("-machine accel=tcg"); >> +} >> + >> +static void test_acpi_kvm(void) >> +{ >> + test_acpi_one("-enable-kvm -machine accel=kvm"); >> +} >> + >> +int main(int argc, char *argv[]) >> +{ >> + const char *arch = qtest_get_arch(); >> + FILE *f = fopen(disk, "w"); >> + fwrite(boot_sector, 1, sizeof boot_sector, f); >> + fclose(f); >> + >> + g_test_init(&argc, &argv, NULL); >> + >> + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { >> + qtest_add_func("acpi/tcg", test_acpi_tcg); >> + qtest_add_func("acpi/kvm", test_acpi_kvm); > > Sorry, while the intention is good, this is a no-go. Not only will make > check fail on KVM-incompatible x86 hosts (including insufficient > permissions for /dev/kvm), it will also fail on ppc or arm hosts since > we are testing the target architecture here. I think it would be possible to call query-kvm and dynamically add the test when it's possible. Regards, Anthony Liguori > > Regards, > Andreas > >> + } >> + return g_test_run(); >> +} > [snip] > > -- > SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany > GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test 2013-10-19 0:13 ` Andreas Färber 2013-10-19 1:25 ` Anthony Liguori @ 2013-10-19 17:27 ` Michael S. Tsirkin 1 sibling, 0 replies; 11+ messages in thread From: Michael S. Tsirkin @ 2013-10-19 17:27 UTC (permalink / raw) To: Andreas Färber Cc: pbonzini, qemu-devel, Anthony Liguori, Markus Armbruster On Sat, Oct 19, 2013 at 02:13:44AM +0200, Andreas Färber wrote: > Am 17.10.2013 23:52, schrieb Michael S. Tsirkin: > > diff --git a/tests/acpi-test.c b/tests/acpi-test.c > > new file mode 100644 > > index 0000000..42de248 > > --- /dev/null > > +++ b/tests/acpi-test.c > [...] > > +static void test_acpi_one(const char *params) > > +{ > > + char *args; > > + uint8_t signature_low; > > + uint8_t signature_high; > > + uint16_t signature; > > + int i; > > + uint32_t off; > > + > > + > > + args = g_strdup_printf("-net none -display none %s %s", > > + params ? params : "", disk); > > + qtest_start(args); > > + > > + /* Wait at most 1 minute */ > > +#define TEST_DELAY (1 * G_USEC_PER_SEC / 10) > > +#define TEST_CYCLES (60 * G_USEC_PER_SEC / TEST_DELAY) > > + > > + for (i = 0; i < TEST_CYCLES; ++i) { > > + signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET); > > + signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1); > > + signature = (signature_high << 8) | signature_low; > > + if (signature == SIGNATURE) { > > + break; > > + } > > + g_usleep(TEST_DELAY); > > + } > > + g_assert_cmphex(signature, ==, SIGNATURE); > > Might be a good safety precaution to use QEMU_BUG_ON() or MIN(..., 1) > for TEST_CYCLES to assure signature gets initialized before comparison. You mean check that TEST_CYCLES > 0? > > + > > + /* OK, now find RSDP */ > > + for (off = 0xf0000; off < 0x100000; off += 0x10) > > + { > > + uint8_t sig[] = "RSD PTR "; > > + int i; > > + > > + for (i = 0; i < sizeof sig - 1; ++i) { > > + sig[i] = readb(off + i); > > + } > > + > > + if (!memcmp(sig, "RSD PTR ", sizeof sig)) { > > + break; > > + } > > + } > > + > > + g_assert_cmphex(off, <, 0x100000); > > + > > + qtest_quit(global_qtest); > > + g_free(args); > > +} > > + > > +static void test_acpi_tcg(void) > > +{ > > + test_acpi_one("-machine accel=tcg"); > > +} > > + > > +static void test_acpi_kvm(void) > > +{ > > + test_acpi_one("-enable-kvm -machine accel=kvm"); > > +} > > + > > +int main(int argc, char *argv[]) > > +{ > > + const char *arch = qtest_get_arch(); > > + FILE *f = fopen(disk, "w"); > > + fwrite(boot_sector, 1, sizeof boot_sector, f); > > + fclose(f); > > + > > + g_test_init(&argc, &argv, NULL); > > + > > + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { > > + qtest_add_func("acpi/tcg", test_acpi_tcg); > > + qtest_add_func("acpi/kvm", test_acpi_kvm); > > Sorry, while the intention is good, this is a no-go. Not only will make > check fail on KVM-incompatible x86 hosts (including insufficient > permissions for /dev/kvm), it will also fail on ppc or arm hosts since > we are testing the target architecture here. > > Regards, > Andreas I'll limit this to tcg for now. > > + } > > + return g_test_run(); > > +} > [snip] > > -- > SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany > GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] qtest: don't configure icount if qtest not allowed 2013-10-17 21:52 [Qemu-devel] [PATCH 1/2] qtest: don't configure icount if qtest not allowed Michael S. Tsirkin 2013-10-17 21:52 ` [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test Michael S. Tsirkin @ 2013-10-18 11:51 ` Paolo Bonzini 2013-10-18 12:13 ` Michael S. Tsirkin 1 sibling, 1 reply; 11+ messages in thread From: Paolo Bonzini @ 2013-10-18 11:51 UTC (permalink / raw) To: Michael S. Tsirkin; +Cc: qemu-devel, Anthony Liguori Il 17/10/2013 23:52, Michael S. Tsirkin ha scritto: > This makes it possible to run bios under qtest Alternatively, let's split qtest_init into a part for "-machine accel=qtest" and one for -qtest. Also has the advantage of fixing an assertion with "qemu-system-x86_64 -machine accel=qtest". Paolo -------------- 8< -------------------- From: Paolo Bonzini <pbonzini@redhat.com> Subject: [PATCH] qtest: split configuration of qtest accelerator and chardev qtest uses the icount infrastructure to implement a test-driven vm_clock. This however is not necessary when using -qtest as a "probe" together with a normal TCG-, KVM- or Xen-based virtual machine. Hence, split out the call to configure_icount into a new function that is called only for "-machine accel=qtest"; and disable those commands when running with an accelerator other than qtest. This also fixes an assertion failure with "qemu-system-x86_64 -machine accel=qtest" but no -qtest option. This is a valid case, albeit somewhat weird; nothing will happen in the VM but you'll still be able to interact with the monitor or the GUI. Now that qtest_init is not limited to an int(void) function, change global variables that are not used outside qtest_init to arguments. And finally, cleanup useless parts of include/sysemu/qtest.h. The file is not used at all for user-only emulation, and qtest is not available on Win32 due to its usage of sigwait. Reported-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> diff --git a/include/sysemu/qtest.h b/include/sysemu/qtest.h index 3927ebb..9b138e9 100644 --- a/include/sysemu/qtest.h +++ b/include/sysemu/qtest.h @@ -16,33 +16,23 @@ #include "qemu-common.h" -#if !defined(CONFIG_USER_ONLY) extern bool qtest_allowed; -extern const char *qtest_chrdev; -extern const char *qtest_log; static inline bool qtest_enabled(void) { return qtest_allowed; } -static inline int qtest_available(void) -{ - return 1; -} - int qtest_init_accel(void); void qtest_init(const char *qtest_chrdev, const char *qtest_log); -#else -static inline bool qtest_enabled(void) -{ - return false; -} static inline int qtest_available(void) { +#ifdef CONFIG_POSIX + return 1; +#else return 0; -} #endif +} #endif diff --git a/qtest.c b/qtest.c index 584c707..dcf1301 100644 --- a/qtest.c +++ b/qtest.c @@ -22,8 +22,6 @@ #define MAX_IRQ 256 -const char *qtest_chrdev; -const char *qtest_log; bool qtest_allowed; static DeviceState *irq_intercept_dev; @@ -406,7 +404,7 @@ static void qtest_process_command(CharDriverState *chr, gchar **words) qtest_send_prefix(chr); qtest_send(chr, "OK\n"); - } else if (strcmp(words[0], "clock_step") == 0) { + } else if (qtest_enabled() && strcmp(words[0], "clock_step") == 0) { int64_t ns; if (words[1]) { @@ -417,7 +415,7 @@ static void qtest_process_command(CharDriverState *chr, gchar **words) qtest_clock_warp(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns); qtest_send_prefix(chr); qtest_send(chr, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); - } else if (strcmp(words[0], "clock_set") == 0) { + } else if (qtest_enabled() && strcmp(words[0], "clock_set") == 0) { int64_t ns; g_assert(words[1]); @@ -502,13 +500,17 @@ static void qtest_event(void *opaque, int event) } } -int qtest_init(void) +int qtest_init_accel(void) { - CharDriverState *chr; + configure_icount("0"); - g_assert(qtest_chrdev != NULL); + return 0; +} + +void qtest_init(const char *qtest_chrdev, const char *qtest_log) +{ + CharDriverState *chr; - configure_icount("0"); chr = qemu_chr_new("qtest", qtest_chrdev, NULL); qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr); @@ -525,6 +527,4 @@ int qtest_init(void) } qtest_chr = chr; - - return 0; } diff --git a/vl.c b/vl.c index 983cdc6..568a6f5 100644 --- a/vl.c +++ b/vl.c @@ -2624,7 +2624,7 @@ static struct { { "tcg", "tcg", tcg_available, tcg_init, &tcg_allowed }, { "xen", "Xen", xen_available, xen_init, &xen_allowed }, { "kvm", "KVM", kvm_available, kvm_init, &kvm_allowed }, - { "qtest", "QTest", qtest_available, qtest_init, &qtest_allowed }, + { "qtest", "QTest", qtest_available, qtest_init_accel, &qtest_allowed }, }; static int configure_accelerator(void) @@ -2836,6 +2836,8 @@ int main(int argc, char **argv, char **envp) QEMUMachine *machine; const char *cpu_model; const char *vga_model = "none"; + const char *qtest_chrdev = NULL; + const char *qtest_log = NULL; const char *pid_file = NULL; const char *incoming = NULL; #ifdef CONFIG_VNC @@ -4041,8 +4043,8 @@ int main(int argc, char **argv, char **envp) configure_accelerator(); - if (!qtest_enabled() && qtest_chrdev) { - qtest_init(); + if (qtest_chrdev) { + qtest_init(qtest_chrdev, qtest_log); } machine_opts = qemu_get_machine_opts(); > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > --- > qtest.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/qtest.c b/qtest.c > index 584c707..48e3288 100644 > --- a/qtest.c > +++ b/qtest.c > @@ -508,7 +508,9 @@ int qtest_init(void) > > g_assert(qtest_chrdev != NULL); > > - configure_icount("0"); > + if (qtest_enabled()) { > + configure_icount("0"); > + } > chr = qemu_chr_new("qtest", qtest_chrdev, NULL); > > qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr); > ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] qtest: don't configure icount if qtest not allowed 2013-10-18 11:51 ` [Qemu-devel] [PATCH 1/2] qtest: don't configure icount if qtest not allowed Paolo Bonzini @ 2013-10-18 12:13 ` Michael S. Tsirkin 0 siblings, 0 replies; 11+ messages in thread From: Michael S. Tsirkin @ 2013-10-18 12:13 UTC (permalink / raw) To: Paolo Bonzini; +Cc: qemu-devel, Anthony Liguori On Fri, Oct 18, 2013 at 01:51:11PM +0200, Paolo Bonzini wrote: > Il 17/10/2013 23:52, Michael S. Tsirkin ha scritto: > > This makes it possible to run bios under qtest > > Alternatively, let's split qtest_init into a part for "-machine > accel=qtest" and one for -qtest. > > Also has the advantage of fixing an assertion with "qemu-system-x86_64 > -machine accel=qtest". > > Paolo > > -------------- 8< -------------------- > From: Paolo Bonzini <pbonzini@redhat.com> > Subject: [PATCH] qtest: split configuration of qtest accelerator and chardev > > qtest uses the icount infrastructure to implement a test-driven vm_clock. This > however is not necessary when using -qtest as a "probe" together with a normal > TCG-, KVM- or Xen-based virtual machine. Hence, split out the call to > configure_icount into a new function that is called only for "-machine > accel=qtest"; and disable those commands when running with an accelerator > other than qtest. > > This also fixes an assertion failure with "qemu-system-x86_64 -machine > accel=qtest" but no -qtest option. This is a valid case, albeit somewhat > weird; nothing will happen in the VM but you'll still be able to > interact with the monitor or the GUI. > > Now that qtest_init is not limited to an int(void) function, change > global variables that are not used outside qtest_init to arguments. > > And finally, cleanup useless parts of include/sysemu/qtest.h. The file > is not used at all for user-only emulation, and qtest is not available > on Win32 due to its usage of sigwait. > > Reported-by: Michael S. Tsirkin <mst@redhat.com> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> > diff --git a/include/sysemu/qtest.h b/include/sysemu/qtest.h > index 3927ebb..9b138e9 100644 > --- a/include/sysemu/qtest.h > +++ b/include/sysemu/qtest.h > @@ -16,33 +16,23 @@ > > #include "qemu-common.h" > > -#if !defined(CONFIG_USER_ONLY) > extern bool qtest_allowed; > -extern const char *qtest_chrdev; > -extern const char *qtest_log; > > static inline bool qtest_enabled(void) > { > return qtest_allowed; > } > > -static inline int qtest_available(void) > -{ > - return 1; > -} > - > int qtest_init_accel(void); > void qtest_init(const char *qtest_chrdev, const char *qtest_log); > -#else > -static inline bool qtest_enabled(void) > -{ > - return false; > -} > > static inline int qtest_available(void) > { > +#ifdef CONFIG_POSIX > + return 1; > +#else > return 0; > -} > #endif > +} > > #endif > diff --git a/qtest.c b/qtest.c > index 584c707..dcf1301 100644 > --- a/qtest.c > +++ b/qtest.c > @@ -22,8 +22,6 @@ > > #define MAX_IRQ 256 > > -const char *qtest_chrdev; > -const char *qtest_log; > bool qtest_allowed; > > static DeviceState *irq_intercept_dev; > @@ -406,7 +404,7 @@ static void qtest_process_command(CharDriverState *chr, gchar **words) > > qtest_send_prefix(chr); > qtest_send(chr, "OK\n"); > - } else if (strcmp(words[0], "clock_step") == 0) { > + } else if (qtest_enabled() && strcmp(words[0], "clock_step") == 0) { > int64_t ns; > > if (words[1]) { > @@ -417,7 +415,7 @@ static void qtest_process_command(CharDriverState *chr, gchar **words) > qtest_clock_warp(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns); > qtest_send_prefix(chr); > qtest_send(chr, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); > - } else if (strcmp(words[0], "clock_set") == 0) { > + } else if (qtest_enabled() && strcmp(words[0], "clock_set") == 0) { > int64_t ns; > > g_assert(words[1]); > @@ -502,13 +500,17 @@ static void qtest_event(void *opaque, int event) > } > } > > -int qtest_init(void) > +int qtest_init_accel(void) > { > - CharDriverState *chr; > + configure_icount("0"); > > - g_assert(qtest_chrdev != NULL); > + return 0; > +} > + > +void qtest_init(const char *qtest_chrdev, const char *qtest_log) > +{ > + CharDriverState *chr; > > - configure_icount("0"); > chr = qemu_chr_new("qtest", qtest_chrdev, NULL); > > qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr); > @@ -525,6 +527,4 @@ int qtest_init(void) > } > > qtest_chr = chr; > - > - return 0; > } > diff --git a/vl.c b/vl.c > index 983cdc6..568a6f5 100644 > --- a/vl.c > +++ b/vl.c > @@ -2624,7 +2624,7 @@ static struct { > { "tcg", "tcg", tcg_available, tcg_init, &tcg_allowed }, > { "xen", "Xen", xen_available, xen_init, &xen_allowed }, > { "kvm", "KVM", kvm_available, kvm_init, &kvm_allowed }, > - { "qtest", "QTest", qtest_available, qtest_init, &qtest_allowed }, > + { "qtest", "QTest", qtest_available, qtest_init_accel, &qtest_allowed }, > }; > > static int configure_accelerator(void) > @@ -2836,6 +2836,8 @@ int main(int argc, char **argv, char **envp) > QEMUMachine *machine; > const char *cpu_model; > const char *vga_model = "none"; > + const char *qtest_chrdev = NULL; > + const char *qtest_log = NULL; > const char *pid_file = NULL; > const char *incoming = NULL; > #ifdef CONFIG_VNC > @@ -4041,8 +4043,8 @@ int main(int argc, char **argv, char **envp) > > configure_accelerator(); > > - if (!qtest_enabled() && qtest_chrdev) { > - qtest_init(); > + if (qtest_chrdev) { > + qtest_init(qtest_chrdev, qtest_log); > } > > machine_opts = qemu_get_machine_opts(); > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > --- > > qtest.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/qtest.c b/qtest.c > > index 584c707..48e3288 100644 > > --- a/qtest.c > > +++ b/qtest.c > > @@ -508,7 +508,9 @@ int qtest_init(void) > > > > g_assert(qtest_chrdev != NULL); > > > > - configure_icount("0"); > > + if (qtest_enabled()) { > > + configure_icount("0"); > > + } > > chr = qemu_chr_new("qtest", qtest_chrdev, NULL); > > > > qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr); > > ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-10-19 17:25 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-10-17 21:52 [Qemu-devel] [PATCH 1/2] qtest: don't configure icount if qtest not allowed Michael S. Tsirkin 2013-10-17 21:52 ` [Qemu-devel] [PATCH 2/2] acpi-test: basic acpi unit-test Michael S. Tsirkin 2013-10-18 5:30 ` Markus Armbruster 2013-10-18 6:36 ` Paolo Bonzini 2013-10-18 11:43 ` Markus Armbruster 2013-10-18 11:20 ` Michael S. Tsirkin 2013-10-19 0:13 ` Andreas Färber 2013-10-19 1:25 ` Anthony Liguori 2013-10-19 17:27 ` Michael S. Tsirkin 2013-10-18 11:51 ` [Qemu-devel] [PATCH 1/2] qtest: don't configure icount if qtest not allowed Paolo Bonzini 2013-10-18 12:13 ` Michael S. Tsirkin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).