Message ID | 1473173750-11761-1-git-send-email-marcel@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Sep 06, 2016 at 05:55:50PM +0300, Marcel Apfelbaum wrote: > Use kvm acceleration if available. > > Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> > --- > > Hi, > > It saves a few seconds so we'll be able to add more tests. > I cc-ed Paolo to get his opinion on the correct way to look > for the kvm support. > > Thanks, > Marcel > > tests/bios-tables-test.c | 51 +++++++++++++++++++++++++++++++----------------- > 1 file changed, 33 insertions(+), 18 deletions(-) > > diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c > index de4019e..c10b356 100644 > --- a/tests/bios-tables-test.c > +++ b/tests/bios-tables-test.c > @@ -114,6 +114,7 @@ typedef struct { > > static const char *disk = "tests/acpi-test-disk.raw"; > static const char *data_dir = "tests/acpi-test-data"; > +static bool kvm_enabled; > #ifdef CONFIG_IASL > static const char *iasl = stringify(CONFIG_IASL); > #else > @@ -707,13 +708,15 @@ static void test_smbios_structs(test_data *data) > } > } > > -static void test_acpi_one(const char *params, test_data *data) > +static void test_acpi_one(const char *machine, const char *params, > + test_data *data) > { > char *args; > > - args = g_strdup_printf("-net none -display none %s " > + args = g_strdup_printf("-machine %s,accel=%s -net none -display none %s " > "-drive id=hd0,if=none,file=%s,format=raw " > "-device ide-hd,drive=hd0 ", > + machine, kvm_enabled ? "kvm" : "tcg", > params ? params : "", disk); > > qtest_start(args); > @@ -758,7 +761,7 @@ static void test_acpi_piix4_tcg(void) > data.machine = MACHINE_PC; > data.required_struct_types = base_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > - test_acpi_one("-machine accel=tcg", &data); > + test_acpi_one("pc", NULL, &data); > free_test_data(&data); > } > > @@ -771,7 +774,7 @@ static void test_acpi_piix4_tcg_bridge(void) > data.variant = ".bridge"; > data.required_struct_types = base_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > - test_acpi_one("-machine accel=tcg -device pci-bridge,chassis_nr=1", &data); > + test_acpi_one("pc", "-device pci-bridge,chassis_nr=1", &data); > free_test_data(&data); > } > > @@ -783,7 +786,7 @@ static void test_acpi_q35_tcg(void) > data.machine = MACHINE_Q35; > data.required_struct_types = base_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > - test_acpi_one("-machine q35,accel=tcg", &data); > + test_acpi_one("q35", NULL, &data); > free_test_data(&data); > } > > @@ -796,7 +799,7 @@ static void test_acpi_q35_tcg_bridge(void) > data.variant = ".bridge"; > data.required_struct_types = base_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > - test_acpi_one("-machine q35,accel=tcg -device pci-bridge,chassis_nr=1", > + test_acpi_one("q35", "-device pci-bridge,chassis_nr=1", > &data); > free_test_data(&data); > } > @@ -808,7 +811,7 @@ static void test_acpi_piix4_tcg_cphp(void) > memset(&data, 0, sizeof(data)); > data.machine = MACHINE_PC; > data.variant = ".cphp"; > - test_acpi_one("-machine accel=tcg" > + test_acpi_one("pc", > " -smp 2,cores=3,sockets=2,maxcpus=6", > &data); > free_test_data(&data); > @@ -821,7 +824,7 @@ static void test_acpi_q35_tcg_cphp(void) > memset(&data, 0, sizeof(data)); > data.machine = MACHINE_Q35; > data.variant = ".cphp"; > - test_acpi_one("-machine q35,accel=tcg" > + test_acpi_one("q35", > " -smp 2,cores=3,sockets=2,maxcpus=6", > &data); > free_test_data(&data); > @@ -840,7 +843,7 @@ static void test_acpi_q35_tcg_ipmi(void) > data.variant = ".ipmibt"; > data.required_struct_types = ipmi_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); > - test_acpi_one("-machine q35,accel=tcg -device ipmi-bmc-sim,id=bmc0" > + test_acpi_one("q35", "-device ipmi-bmc-sim,id=bmc0" > " -device isa-ipmi-bt,bmc=bmc0", > &data); > free_test_data(&data); > @@ -858,12 +861,22 @@ static void test_acpi_piix4_tcg_ipmi(void) > data.variant = ".ipmikcs"; > data.required_struct_types = ipmi_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); > - test_acpi_one("-machine accel=tcg -device ipmi-bmc-sim,id=bmc0" > + test_acpi_one("pc", "-device ipmi-bmc-sim,id=bmc0" > " -device isa-ipmi-kcs,irq=0,bmc=bmc0", > &data); > free_test_data(&data); > } > > +static void check_kvm(void) > +{ > + int fd = qemu_open("/dev/kvm", O_RDWR); > + > + if (fd > 0) { > + kvm_enabled = true; > + qemu_close(fd); > + } > +} > + > int main(int argc, char *argv[]) > { > const char *arch = qtest_get_arch(); > @@ -873,17 +886,19 @@ int main(int argc, char *argv[]) > if(ret) > return ret; > > + check_kvm(); > + > g_test_init(&argc, &argv, NULL); > > if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { > - qtest_add_func("acpi/piix4/tcg", test_acpi_piix4_tcg); > - qtest_add_func("acpi/piix4/tcg/bridge", test_acpi_piix4_tcg_bridge); > - qtest_add_func("acpi/q35/tcg", test_acpi_q35_tcg); > - qtest_add_func("acpi/q35/tcg/bridge", test_acpi_q35_tcg_bridge); > - qtest_add_func("acpi/piix4/tcg/ipmi", test_acpi_piix4_tcg_ipmi); > - qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi); > - qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp); > - qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp); > + qtest_add_func("acpi/piix4", test_acpi_piix4_tcg); > + qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge); > + qtest_add_func("acpi/q35", test_acpi_q35_tcg); > + qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge); > + qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi); > + qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi); > + qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp); > + qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp); > } > ret = g_test_run(); > boot_sector_cleanup(disk); I think you need to check kvm_allows_irq0_override though. > -- > 2.5.5
On 09/06/2016 06:13 PM, Michael S. Tsirkin wrote: > On Tue, Sep 06, 2016 at 05:55:50PM +0300, Marcel Apfelbaum wrote: >> Use kvm acceleration if available. >> >> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> >> --- >> >> Hi, >> >> It saves a few seconds so we'll be able to add more tests. >> I cc-ed Paolo to get his opinion on the correct way to look >> for the kvm support. >> >> Thanks, >> Marcel >> >> tests/bios-tables-test.c | 51 +++++++++++++++++++++++++++++++----------------- >> 1 file changed, 33 insertions(+), 18 deletions(-) >> >> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c >> index de4019e..c10b356 100644 >> --- a/tests/bios-tables-test.c >> +++ b/tests/bios-tables-test.c >> @@ -114,6 +114,7 @@ typedef struct { >> >> static const char *disk = "tests/acpi-test-disk.raw"; >> static const char *data_dir = "tests/acpi-test-data"; >> +static bool kvm_enabled; >> #ifdef CONFIG_IASL >> static const char *iasl = stringify(CONFIG_IASL); >> #else >> @@ -707,13 +708,15 @@ static void test_smbios_structs(test_data *data) >> } >> } >> >> -static void test_acpi_one(const char *params, test_data *data) >> +static void test_acpi_one(const char *machine, const char *params, >> + test_data *data) >> { >> char *args; >> >> - args = g_strdup_printf("-net none -display none %s " >> + args = g_strdup_printf("-machine %s,accel=%s -net none -display none %s " >> "-drive id=hd0,if=none,file=%s,format=raw " >> "-device ide-hd,drive=hd0 ", >> + machine, kvm_enabled ? "kvm" : "tcg", >> params ? params : "", disk); >> >> qtest_start(args); >> @@ -758,7 +761,7 @@ static void test_acpi_piix4_tcg(void) >> data.machine = MACHINE_PC; >> data.required_struct_types = base_required_struct_types; >> data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); >> - test_acpi_one("-machine accel=tcg", &data); >> + test_acpi_one("pc", NULL, &data); >> free_test_data(&data); >> } >> >> @@ -771,7 +774,7 @@ static void test_acpi_piix4_tcg_bridge(void) >> data.variant = ".bridge"; >> data.required_struct_types = base_required_struct_types; >> data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); >> - test_acpi_one("-machine accel=tcg -device pci-bridge,chassis_nr=1", &data); >> + test_acpi_one("pc", "-device pci-bridge,chassis_nr=1", &data); >> free_test_data(&data); >> } >> >> @@ -783,7 +786,7 @@ static void test_acpi_q35_tcg(void) >> data.machine = MACHINE_Q35; >> data.required_struct_types = base_required_struct_types; >> data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); >> - test_acpi_one("-machine q35,accel=tcg", &data); >> + test_acpi_one("q35", NULL, &data); >> free_test_data(&data); >> } >> >> @@ -796,7 +799,7 @@ static void test_acpi_q35_tcg_bridge(void) >> data.variant = ".bridge"; >> data.required_struct_types = base_required_struct_types; >> data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); >> - test_acpi_one("-machine q35,accel=tcg -device pci-bridge,chassis_nr=1", >> + test_acpi_one("q35", "-device pci-bridge,chassis_nr=1", >> &data); >> free_test_data(&data); >> } >> @@ -808,7 +811,7 @@ static void test_acpi_piix4_tcg_cphp(void) >> memset(&data, 0, sizeof(data)); >> data.machine = MACHINE_PC; >> data.variant = ".cphp"; >> - test_acpi_one("-machine accel=tcg" >> + test_acpi_one("pc", >> " -smp 2,cores=3,sockets=2,maxcpus=6", >> &data); >> free_test_data(&data); >> @@ -821,7 +824,7 @@ static void test_acpi_q35_tcg_cphp(void) >> memset(&data, 0, sizeof(data)); >> data.machine = MACHINE_Q35; >> data.variant = ".cphp"; >> - test_acpi_one("-machine q35,accel=tcg" >> + test_acpi_one("q35", >> " -smp 2,cores=3,sockets=2,maxcpus=6", >> &data); >> free_test_data(&data); >> @@ -840,7 +843,7 @@ static void test_acpi_q35_tcg_ipmi(void) >> data.variant = ".ipmibt"; >> data.required_struct_types = ipmi_required_struct_types; >> data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); >> - test_acpi_one("-machine q35,accel=tcg -device ipmi-bmc-sim,id=bmc0" >> + test_acpi_one("q35", "-device ipmi-bmc-sim,id=bmc0" >> " -device isa-ipmi-bt,bmc=bmc0", >> &data); >> free_test_data(&data); >> @@ -858,12 +861,22 @@ static void test_acpi_piix4_tcg_ipmi(void) >> data.variant = ".ipmikcs"; >> data.required_struct_types = ipmi_required_struct_types; >> data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); >> - test_acpi_one("-machine accel=tcg -device ipmi-bmc-sim,id=bmc0" >> + test_acpi_one("pc", "-device ipmi-bmc-sim,id=bmc0" >> " -device isa-ipmi-kcs,irq=0,bmc=bmc0", >> &data); >> free_test_data(&data); >> } >> >> +static void check_kvm(void) >> +{ >> + int fd = qemu_open("/dev/kvm", O_RDWR); >> + >> + if (fd > 0) { >> + kvm_enabled = true; >> + qemu_close(fd); >> + } >> +} >> + >> int main(int argc, char *argv[]) >> { >> const char *arch = qtest_get_arch(); >> @@ -873,17 +886,19 @@ int main(int argc, char *argv[]) >> if(ret) >> return ret; >> >> + check_kvm(); >> + >> g_test_init(&argc, &argv, NULL); >> >> if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { >> - qtest_add_func("acpi/piix4/tcg", test_acpi_piix4_tcg); >> - qtest_add_func("acpi/piix4/tcg/bridge", test_acpi_piix4_tcg_bridge); >> - qtest_add_func("acpi/q35/tcg", test_acpi_q35_tcg); >> - qtest_add_func("acpi/q35/tcg/bridge", test_acpi_q35_tcg_bridge); >> - qtest_add_func("acpi/piix4/tcg/ipmi", test_acpi_piix4_tcg_ipmi); >> - qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi); >> - qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp); >> - qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp); >> + qtest_add_func("acpi/piix4", test_acpi_piix4_tcg); >> + qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge); >> + qtest_add_func("acpi/q35", test_acpi_q35_tcg); >> + qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge); >> + qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi); >> + qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi); >> + qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp); >> + qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp); >> } >> ret = g_test_run(); >> boot_sector_cleanup(disk); > > I think you need to check kvm_allows_irq0_override though. > Do you mean we should check both: - we can use the /dev/kvm device - the kvm_allows_irq0_override is true? Thanks, Marcel >> -- >> 2.5.5
On 09/06/2016 05:55 PM, Marcel Apfelbaum wrote: > Use kvm acceleration if available. > > Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> > --- > > Hi, > > It saves a few seconds so we'll be able to add more tests. > I cc-ed Paolo to get his opinion on the correct way to look > for the kvm support. > > Thanks, > Marcel > > tests/bios-tables-test.c | 51 +++++++++++++++++++++++++++++++----------------- > 1 file changed, 33 insertions(+), 18 deletions(-) > > diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c > index de4019e..c10b356 100644 > --- a/tests/bios-tables-test.c > +++ b/tests/bios-tables-test.c > @@ -114,6 +114,7 @@ typedef struct { > > static const char *disk = "tests/acpi-test-disk.raw"; > static const char *data_dir = "tests/acpi-test-data"; > +static bool kvm_enabled; > #ifdef CONFIG_IASL > static const char *iasl = stringify(CONFIG_IASL); > #else > @@ -707,13 +708,15 @@ static void test_smbios_structs(test_data *data) > } > } > > -static void test_acpi_one(const char *params, test_data *data) > +static void test_acpi_one(const char *machine, const char *params, > + test_data *data) We don't need to pass the machine parameter since is part of test_data structure. Will be fixed in V2. Thanks, Marcel > { > char *args; > > - args = g_strdup_printf("-net none -display none %s " > + args = g_strdup_printf("-machine %s,accel=%s -net none -display none %s " > "-drive id=hd0,if=none,file=%s,format=raw " > "-device ide-hd,drive=hd0 ", > + machine, kvm_enabled ? "kvm" : "tcg", > params ? params : "", disk); > > qtest_start(args); > @@ -758,7 +761,7 @@ static void test_acpi_piix4_tcg(void) > data.machine = MACHINE_PC; > data.required_struct_types = base_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > - test_acpi_one("-machine accel=tcg", &data); > + test_acpi_one("pc", NULL, &data); > free_test_data(&data); > } > > @@ -771,7 +774,7 @@ static void test_acpi_piix4_tcg_bridge(void) > data.variant = ".bridge"; > data.required_struct_types = base_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > - test_acpi_one("-machine accel=tcg -device pci-bridge,chassis_nr=1", &data); > + test_acpi_one("pc", "-device pci-bridge,chassis_nr=1", &data); > free_test_data(&data); > } > > @@ -783,7 +786,7 @@ static void test_acpi_q35_tcg(void) > data.machine = MACHINE_Q35; > data.required_struct_types = base_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > - test_acpi_one("-machine q35,accel=tcg", &data); > + test_acpi_one("q35", NULL, &data); > free_test_data(&data); > } > > @@ -796,7 +799,7 @@ static void test_acpi_q35_tcg_bridge(void) > data.variant = ".bridge"; > data.required_struct_types = base_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > - test_acpi_one("-machine q35,accel=tcg -device pci-bridge,chassis_nr=1", > + test_acpi_one("q35", "-device pci-bridge,chassis_nr=1", > &data); > free_test_data(&data); > } > @@ -808,7 +811,7 @@ static void test_acpi_piix4_tcg_cphp(void) > memset(&data, 0, sizeof(data)); > data.machine = MACHINE_PC; > data.variant = ".cphp"; > - test_acpi_one("-machine accel=tcg" > + test_acpi_one("pc", > " -smp 2,cores=3,sockets=2,maxcpus=6", > &data); > free_test_data(&data); > @@ -821,7 +824,7 @@ static void test_acpi_q35_tcg_cphp(void) > memset(&data, 0, sizeof(data)); > data.machine = MACHINE_Q35; > data.variant = ".cphp"; > - test_acpi_one("-machine q35,accel=tcg" > + test_acpi_one("q35", > " -smp 2,cores=3,sockets=2,maxcpus=6", > &data); > free_test_data(&data); > @@ -840,7 +843,7 @@ static void test_acpi_q35_tcg_ipmi(void) > data.variant = ".ipmibt"; > data.required_struct_types = ipmi_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); > - test_acpi_one("-machine q35,accel=tcg -device ipmi-bmc-sim,id=bmc0" > + test_acpi_one("q35", "-device ipmi-bmc-sim,id=bmc0" > " -device isa-ipmi-bt,bmc=bmc0", > &data); > free_test_data(&data); > @@ -858,12 +861,22 @@ static void test_acpi_piix4_tcg_ipmi(void) > data.variant = ".ipmikcs"; > data.required_struct_types = ipmi_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); > - test_acpi_one("-machine accel=tcg -device ipmi-bmc-sim,id=bmc0" > + test_acpi_one("pc", "-device ipmi-bmc-sim,id=bmc0" > " -device isa-ipmi-kcs,irq=0,bmc=bmc0", > &data); > free_test_data(&data); > } > > +static void check_kvm(void) > +{ > + int fd = qemu_open("/dev/kvm", O_RDWR); > + > + if (fd > 0) { > + kvm_enabled = true; > + qemu_close(fd); > + } > +} > + > int main(int argc, char *argv[]) > { > const char *arch = qtest_get_arch(); > @@ -873,17 +886,19 @@ int main(int argc, char *argv[]) > if(ret) > return ret; > > + check_kvm(); > + > g_test_init(&argc, &argv, NULL); > > if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { > - qtest_add_func("acpi/piix4/tcg", test_acpi_piix4_tcg); > - qtest_add_func("acpi/piix4/tcg/bridge", test_acpi_piix4_tcg_bridge); > - qtest_add_func("acpi/q35/tcg", test_acpi_q35_tcg); > - qtest_add_func("acpi/q35/tcg/bridge", test_acpi_q35_tcg_bridge); > - qtest_add_func("acpi/piix4/tcg/ipmi", test_acpi_piix4_tcg_ipmi); > - qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi); > - qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp); > - qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp); > + qtest_add_func("acpi/piix4", test_acpi_piix4_tcg); > + qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge); > + qtest_add_func("acpi/q35", test_acpi_q35_tcg); > + qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge); > + qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi); > + qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi); > + qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp); > + qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp); > } > ret = g_test_run(); > boot_sector_cleanup(disk); >
On 06/09/2016 16:55, Marcel Apfelbaum wrote: > Use kvm acceleration if available. > > Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> > --- > > Hi, > > It saves a few seconds so we'll be able to add more tests. > I cc-ed Paolo to get his opinion on the correct way to look > for the kvm support. Just use "-machine accel=kvm:tcg" and let QEMU do the hard work. :) Paolo > Thanks, > Marcel > > tests/bios-tables-test.c | 51 +++++++++++++++++++++++++++++++----------------- > 1 file changed, 33 insertions(+), 18 deletions(-) > > diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c > index de4019e..c10b356 100644 > --- a/tests/bios-tables-test.c > +++ b/tests/bios-tables-test.c > @@ -114,6 +114,7 @@ typedef struct { > > static const char *disk = "tests/acpi-test-disk.raw"; > static const char *data_dir = "tests/acpi-test-data"; > +static bool kvm_enabled; > #ifdef CONFIG_IASL > static const char *iasl = stringify(CONFIG_IASL); > #else > @@ -707,13 +708,15 @@ static void test_smbios_structs(test_data *data) > } > } > > -static void test_acpi_one(const char *params, test_data *data) > +static void test_acpi_one(const char *machine, const char *params, > + test_data *data) > { > char *args; > > - args = g_strdup_printf("-net none -display none %s " > + args = g_strdup_printf("-machine %s,accel=%s -net none -display none %s " > "-drive id=hd0,if=none,file=%s,format=raw " > "-device ide-hd,drive=hd0 ", > + machine, kvm_enabled ? "kvm" : "tcg", > params ? params : "", disk); > > qtest_start(args); > @@ -758,7 +761,7 @@ static void test_acpi_piix4_tcg(void) > data.machine = MACHINE_PC; > data.required_struct_types = base_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > - test_acpi_one("-machine accel=tcg", &data); > + test_acpi_one("pc", NULL, &data); > free_test_data(&data); > } > > @@ -771,7 +774,7 @@ static void test_acpi_piix4_tcg_bridge(void) > data.variant = ".bridge"; > data.required_struct_types = base_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > - test_acpi_one("-machine accel=tcg -device pci-bridge,chassis_nr=1", &data); > + test_acpi_one("pc", "-device pci-bridge,chassis_nr=1", &data); > free_test_data(&data); > } > > @@ -783,7 +786,7 @@ static void test_acpi_q35_tcg(void) > data.machine = MACHINE_Q35; > data.required_struct_types = base_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > - test_acpi_one("-machine q35,accel=tcg", &data); > + test_acpi_one("q35", NULL, &data); > free_test_data(&data); > } > > @@ -796,7 +799,7 @@ static void test_acpi_q35_tcg_bridge(void) > data.variant = ".bridge"; > data.required_struct_types = base_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > - test_acpi_one("-machine q35,accel=tcg -device pci-bridge,chassis_nr=1", > + test_acpi_one("q35", "-device pci-bridge,chassis_nr=1", > &data); > free_test_data(&data); > } > @@ -808,7 +811,7 @@ static void test_acpi_piix4_tcg_cphp(void) > memset(&data, 0, sizeof(data)); > data.machine = MACHINE_PC; > data.variant = ".cphp"; > - test_acpi_one("-machine accel=tcg" > + test_acpi_one("pc", > " -smp 2,cores=3,sockets=2,maxcpus=6", > &data); > free_test_data(&data); > @@ -821,7 +824,7 @@ static void test_acpi_q35_tcg_cphp(void) > memset(&data, 0, sizeof(data)); > data.machine = MACHINE_Q35; > data.variant = ".cphp"; > - test_acpi_one("-machine q35,accel=tcg" > + test_acpi_one("q35", > " -smp 2,cores=3,sockets=2,maxcpus=6", > &data); > free_test_data(&data); > @@ -840,7 +843,7 @@ static void test_acpi_q35_tcg_ipmi(void) > data.variant = ".ipmibt"; > data.required_struct_types = ipmi_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); > - test_acpi_one("-machine q35,accel=tcg -device ipmi-bmc-sim,id=bmc0" > + test_acpi_one("q35", "-device ipmi-bmc-sim,id=bmc0" > " -device isa-ipmi-bt,bmc=bmc0", > &data); > free_test_data(&data); > @@ -858,12 +861,22 @@ static void test_acpi_piix4_tcg_ipmi(void) > data.variant = ".ipmikcs"; > data.required_struct_types = ipmi_required_struct_types; > data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); > - test_acpi_one("-machine accel=tcg -device ipmi-bmc-sim,id=bmc0" > + test_acpi_one("pc", "-device ipmi-bmc-sim,id=bmc0" > " -device isa-ipmi-kcs,irq=0,bmc=bmc0", > &data); > free_test_data(&data); > } > > +static void check_kvm(void) > +{ > + int fd = qemu_open("/dev/kvm", O_RDWR); > + > + if (fd > 0) { > + kvm_enabled = true; > + qemu_close(fd); > + } > +} > + > int main(int argc, char *argv[]) > { > const char *arch = qtest_get_arch(); > @@ -873,17 +886,19 @@ int main(int argc, char *argv[]) > if(ret) > return ret; > > + check_kvm(); > + > g_test_init(&argc, &argv, NULL); > > if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { > - qtest_add_func("acpi/piix4/tcg", test_acpi_piix4_tcg); > - qtest_add_func("acpi/piix4/tcg/bridge", test_acpi_piix4_tcg_bridge); > - qtest_add_func("acpi/q35/tcg", test_acpi_q35_tcg); > - qtest_add_func("acpi/q35/tcg/bridge", test_acpi_q35_tcg_bridge); > - qtest_add_func("acpi/piix4/tcg/ipmi", test_acpi_piix4_tcg_ipmi); > - qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi); > - qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp); > - qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp); > + qtest_add_func("acpi/piix4", test_acpi_piix4_tcg); > + qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge); > + qtest_add_func("acpi/q35", test_acpi_q35_tcg); > + qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge); > + qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi); > + qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi); > + qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp); > + qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp); > } > ret = g_test_run(); > boot_sector_cleanup(disk); >
On Tue, Sep 06, 2016 at 05:47:06PM +0200, Paolo Bonzini wrote: > > > On 06/09/2016 16:55, Marcel Apfelbaum wrote: > > Use kvm acceleration if available. > > > > Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> > > --- > > > > Hi, > > > > It saves a few seconds so we'll be able to add more tests. > > I cc-ed Paolo to get his opinion on the correct way to look > > for the kvm support. > > Just use "-machine accel=kvm:tcg" and let QEMU do the hard work. :) > > Paolo Sounds good, but we really need to skip it when gsi capability is not there (and when using kernel irqchip) (because in that case we can't override apic irq0). > > Thanks, > > Marcel > > > > tests/bios-tables-test.c | 51 +++++++++++++++++++++++++++++++----------------- > > 1 file changed, 33 insertions(+), 18 deletions(-) > > > > diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c > > index de4019e..c10b356 100644 > > --- a/tests/bios-tables-test.c > > +++ b/tests/bios-tables-test.c > > @@ -114,6 +114,7 @@ typedef struct { > > > > static const char *disk = "tests/acpi-test-disk.raw"; > > static const char *data_dir = "tests/acpi-test-data"; > > +static bool kvm_enabled; > > #ifdef CONFIG_IASL > > static const char *iasl = stringify(CONFIG_IASL); > > #else > > @@ -707,13 +708,15 @@ static void test_smbios_structs(test_data *data) > > } > > } > > > > -static void test_acpi_one(const char *params, test_data *data) > > +static void test_acpi_one(const char *machine, const char *params, > > + test_data *data) > > { > > char *args; > > > > - args = g_strdup_printf("-net none -display none %s " > > + args = g_strdup_printf("-machine %s,accel=%s -net none -display none %s " > > "-drive id=hd0,if=none,file=%s,format=raw " > > "-device ide-hd,drive=hd0 ", > > + machine, kvm_enabled ? "kvm" : "tcg", > > params ? params : "", disk); > > > > qtest_start(args); > > @@ -758,7 +761,7 @@ static void test_acpi_piix4_tcg(void) > > data.machine = MACHINE_PC; > > data.required_struct_types = base_required_struct_types; > > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > > - test_acpi_one("-machine accel=tcg", &data); > > + test_acpi_one("pc", NULL, &data); > > free_test_data(&data); > > } > > > > @@ -771,7 +774,7 @@ static void test_acpi_piix4_tcg_bridge(void) > > data.variant = ".bridge"; > > data.required_struct_types = base_required_struct_types; > > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > > - test_acpi_one("-machine accel=tcg -device pci-bridge,chassis_nr=1", &data); > > + test_acpi_one("pc", "-device pci-bridge,chassis_nr=1", &data); > > free_test_data(&data); > > } > > > > @@ -783,7 +786,7 @@ static void test_acpi_q35_tcg(void) > > data.machine = MACHINE_Q35; > > data.required_struct_types = base_required_struct_types; > > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > > - test_acpi_one("-machine q35,accel=tcg", &data); > > + test_acpi_one("q35", NULL, &data); > > free_test_data(&data); > > } > > > > @@ -796,7 +799,7 @@ static void test_acpi_q35_tcg_bridge(void) > > data.variant = ".bridge"; > > data.required_struct_types = base_required_struct_types; > > data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); > > - test_acpi_one("-machine q35,accel=tcg -device pci-bridge,chassis_nr=1", > > + test_acpi_one("q35", "-device pci-bridge,chassis_nr=1", > > &data); > > free_test_data(&data); > > } > > @@ -808,7 +811,7 @@ static void test_acpi_piix4_tcg_cphp(void) > > memset(&data, 0, sizeof(data)); > > data.machine = MACHINE_PC; > > data.variant = ".cphp"; > > - test_acpi_one("-machine accel=tcg" > > + test_acpi_one("pc", > > " -smp 2,cores=3,sockets=2,maxcpus=6", > > &data); > > free_test_data(&data); > > @@ -821,7 +824,7 @@ static void test_acpi_q35_tcg_cphp(void) > > memset(&data, 0, sizeof(data)); > > data.machine = MACHINE_Q35; > > data.variant = ".cphp"; > > - test_acpi_one("-machine q35,accel=tcg" > > + test_acpi_one("q35", > > " -smp 2,cores=3,sockets=2,maxcpus=6", > > &data); > > free_test_data(&data); > > @@ -840,7 +843,7 @@ static void test_acpi_q35_tcg_ipmi(void) > > data.variant = ".ipmibt"; > > data.required_struct_types = ipmi_required_struct_types; > > data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); > > - test_acpi_one("-machine q35,accel=tcg -device ipmi-bmc-sim,id=bmc0" > > + test_acpi_one("q35", "-device ipmi-bmc-sim,id=bmc0" > > " -device isa-ipmi-bt,bmc=bmc0", > > &data); > > free_test_data(&data); > > @@ -858,12 +861,22 @@ static void test_acpi_piix4_tcg_ipmi(void) > > data.variant = ".ipmikcs"; > > data.required_struct_types = ipmi_required_struct_types; > > data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); > > - test_acpi_one("-machine accel=tcg -device ipmi-bmc-sim,id=bmc0" > > + test_acpi_one("pc", "-device ipmi-bmc-sim,id=bmc0" > > " -device isa-ipmi-kcs,irq=0,bmc=bmc0", > > &data); > > free_test_data(&data); > > } > > > > +static void check_kvm(void) > > +{ > > + int fd = qemu_open("/dev/kvm", O_RDWR); > > + > > + if (fd > 0) { > > + kvm_enabled = true; > > + qemu_close(fd); > > + } > > +} > > + > > int main(int argc, char *argv[]) > > { > > const char *arch = qtest_get_arch(); > > @@ -873,17 +886,19 @@ int main(int argc, char *argv[]) > > if(ret) > > return ret; > > > > + check_kvm(); > > + > > g_test_init(&argc, &argv, NULL); > > > > if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { > > - qtest_add_func("acpi/piix4/tcg", test_acpi_piix4_tcg); > > - qtest_add_func("acpi/piix4/tcg/bridge", test_acpi_piix4_tcg_bridge); > > - qtest_add_func("acpi/q35/tcg", test_acpi_q35_tcg); > > - qtest_add_func("acpi/q35/tcg/bridge", test_acpi_q35_tcg_bridge); > > - qtest_add_func("acpi/piix4/tcg/ipmi", test_acpi_piix4_tcg_ipmi); > > - qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi); > > - qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp); > > - qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp); > > + qtest_add_func("acpi/piix4", test_acpi_piix4_tcg); > > + qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge); > > + qtest_add_func("acpi/q35", test_acpi_q35_tcg); > > + qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge); > > + qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi); > > + qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi); > > + qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp); > > + qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp); > > } > > ret = g_test_run(); > > boot_sector_cleanup(disk); > >
On 09/06/2016 06:47 PM, Paolo Bonzini wrote: > > > On 06/09/2016 16:55, Marcel Apfelbaum wrote: >> Use kvm acceleration if available. >> >> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> >> --- >> >> Hi, >> >> It saves a few seconds so we'll be able to add more tests. >> I cc-ed Paolo to get his opinion on the correct way to look >> for the kvm support. > > Just use "-machine accel=kvm:tcg" and let QEMU do the hard work. :) > Thanks Paolo, That is really cool! Would we still need Michael's kvm_allows_irq0_override check? Thanks, Marcel > Paolo > >> Thanks, >> Marcel >> [...]
On 06/09/2016 17:51, Michael S. Tsirkin wrote: > On Tue, Sep 06, 2016 at 05:47:06PM +0200, Paolo Bonzini wrote: >> >> >> On 06/09/2016 16:55, Marcel Apfelbaum wrote: >>> Use kvm acceleration if available. >>> >>> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> >>> --- >>> >>> Hi, >>> >>> It saves a few seconds so we'll be able to add more tests. >>> I cc-ed Paolo to get his opinion on the correct way to look >>> for the kvm support. >> >> Just use "-machine accel=kvm:tcg" and let QEMU do the hard work. :) >> >> Paolo > > Sounds good, but we really need to skip it when gsi > capability is not there (and when using kernel irqchip) > (because in that case we can't override apic irq0). Should it just use -machine kernel_irqchip=false? Paolo
On Tue, Sep 06, 2016 at 05:54:14PM +0200, Paolo Bonzini wrote: > > > On 06/09/2016 17:51, Michael S. Tsirkin wrote: > > On Tue, Sep 06, 2016 at 05:47:06PM +0200, Paolo Bonzini wrote: > >> > >> > >> On 06/09/2016 16:55, Marcel Apfelbaum wrote: > >>> Use kvm acceleration if available. > >>> > >>> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> > >>> --- > >>> > >>> Hi, > >>> > >>> It saves a few seconds so we'll be able to add more tests. > >>> I cc-ed Paolo to get his opinion on the correct way to look > >>> for the kvm support. > >> > >> Just use "-machine accel=kvm:tcg" and let QEMU do the hard work. :) > >> > >> Paolo > > > > Sounds good, but we really need to skip it when gsi > > capability is not there (and when using kernel irqchip) > > (because in that case we can't override apic irq0). > > Should it just use -machine kernel_irqchip=false? > > Paolo Well that's not optimal, but still better than tcg I guess. Does it slow us a lot?
On 06/09/2016 17:51, Michael S. Tsirkin wrote: > > Just use "-machine accel=kvm:tcg" and let QEMU do the hard work. :) > > > > Paolo > > Sounds good, but we really need to skip it when gsi > capability is not there (and when using kernel irqchip) > (because in that case we can't override apic irq0). We should just remove support for !kvm_has_gsi_routing on x86. It's been there since November 2008. Paolo
On Tue, Sep 06, 2016 at 09:11:16PM +0200, Paolo Bonzini wrote: > > > On 06/09/2016 17:51, Michael S. Tsirkin wrote: > > > Just use "-machine accel=kvm:tcg" and let QEMU do the hard work. :) > > > > > > Paolo > > > > Sounds good, but we really need to skip it when gsi > > capability is not there (and when using kernel irqchip) > > (because in that case we can't override apic irq0). > > We should just remove support for !kvm_has_gsi_routing on x86. It's > been there since November 2008. > > Paolo Fine by me. Can you post a patch that does this? This one can be a follow-up, and we can also drop the conditional handling from acpi-build.
On 06/09/2016 21:21, Michael S. Tsirkin wrote: > On Tue, Sep 06, 2016 at 09:11:16PM +0200, Paolo Bonzini wrote: >> >> >> On 06/09/2016 17:51, Michael S. Tsirkin wrote: >>>> Just use "-machine accel=kvm:tcg" and let QEMU do the hard work. :) >>>> >>>> Paolo >>> >>> Sounds good, but we really need to skip it when gsi >>> capability is not there (and when using kernel irqchip) >>> (because in that case we can't override apic irq0). >> >> We should just remove support for !kvm_has_gsi_routing on x86. It's >> been there since November 2008. >> >> Paolo > > Fine by me. Can you post a patch that does this? > This one can be a follow-up, and we can also > drop the conditional handling from acpi-build. Go ahead and merge Marcel's patch. I can remove kernel_irqchip=off once apic irq0 override is assumed. Paolo
On Tue, Sep 06, 2016 at 10:22:26PM +0200, Paolo Bonzini wrote: > > > On 06/09/2016 21:21, Michael S. Tsirkin wrote: > > On Tue, Sep 06, 2016 at 09:11:16PM +0200, Paolo Bonzini wrote: > >> > >> > >> On 06/09/2016 17:51, Michael S. Tsirkin wrote: > >>>> Just use "-machine accel=kvm:tcg" and let QEMU do the hard work. :) > >>>> > >>>> Paolo > >>> > >>> Sounds good, but we really need to skip it when gsi > >>> capability is not there (and when using kernel irqchip) > >>> (because in that case we can't override apic irq0). > >> > >> We should just remove support for !kvm_has_gsi_routing on x86. It's > >> been there since November 2008. > >> > >> Paolo > > > > Fine by me. Can you post a patch that does this? > > This one can be a follow-up, and we can also > > drop the conditional handling from acpi-build. > > Go ahead and merge Marcel's patch. I can remove kernel_irqchip=off once > apic irq0 override is assumed. > > Paolo OK
On Tue, Sep 06, 2016 at 10:22:26PM +0200, Paolo Bonzini wrote: > > > On 06/09/2016 21:21, Michael S. Tsirkin wrote: > > On Tue, Sep 06, 2016 at 09:11:16PM +0200, Paolo Bonzini wrote: > >> > >> > >> On 06/09/2016 17:51, Michael S. Tsirkin wrote: > >>>> Just use "-machine accel=kvm:tcg" and let QEMU do the hard work. :) > >>>> > >>>> Paolo > >>> > >>> Sounds good, but we really need to skip it when gsi > >>> capability is not there (and when using kernel irqchip) > >>> (because in that case we can't override apic irq0). > >> > >> We should just remove support for !kvm_has_gsi_routing on x86. It's > >> been there since November 2008. > >> > >> Paolo > > > > Fine by me. Can you post a patch that does this? > > This one can be a follow-up, and we can also > > drop the conditional handling from acpi-build. > > Go ahead and merge Marcel's patch. I can remove kernel_irqchip=off once > apic irq0 override is assumed. > > Paolo I just noticed that this patch causes warnings: GTESTER check-qtest-ppc64 "kvm" accelerator not found. "kvm" accelerator not found. On x86, when kvm module is removed, there are a bunch of other warnings: Could not access KVM kernel module: No such file or directory failed to initialize KVM: No such file or directory Back to tcg accelerator.
On Tue, Sep 06, 2016 at 10:22:26PM +0200, Paolo Bonzini wrote: > On 06/09/2016 21:21, Michael S. Tsirkin wrote: > > On Tue, Sep 06, 2016 at 09:11:16PM +0200, Paolo Bonzini wrote: > >> > >> > >> On 06/09/2016 17:51, Michael S. Tsirkin wrote: > >>>> Just use "-machine accel=kvm:tcg" and let QEMU do the hard work. :) > >>>> > >>>> Paolo > >>> > >>> Sounds good, but we really need to skip it when gsi > >>> capability is not there (and when using kernel irqchip) > >>> (because in that case we can't override apic irq0). > >> > >> We should just remove support for !kvm_has_gsi_routing on x86. It's > >> been there since November 2008. > >> > >> Paolo > > > > Fine by me. Can you post a patch that does this? > > This one can be a follow-up, and we can also > > drop the conditional handling from acpi-build. > > Go ahead and merge Marcel's patch. I can remove kernel_irqchip=off once > apic irq0 override is assumed. [4 years later] Can we remove it now? I couldn't find out if we can assume kvm_has_gsi_routing() is true everywhere, or just on a few architectures.
On 22/09/20 19:03, Eduardo Habkost wrote: >> I can remove kernel_irqchip=off once >> apic irq0 override is assumed. > [4 years later] > > Can we remove it now? I couldn't find out if we can assume > kvm_has_gsi_routing() is true everywhere, or just on a few > architectures. Yes, we can. Other architectures don't matter, what counts is that we can require kvm_has_gsi_routing() == true on x86. Paolo
On Tue, Sep 22, 2020 at 07:17:24PM +0200, Paolo Bonzini wrote: > On 22/09/20 19:03, Eduardo Habkost wrote: > >> I can remove kernel_irqchip=off once > >> apic irq0 override is assumed. > > [4 years later] > > > > Can we remove it now? I couldn't find out if we can assume > > kvm_has_gsi_routing() is true everywhere, or just on a few > > architectures. > > Yes, we can. Other architectures don't matter, what counts is that we > can require kvm_has_gsi_routing() == true on x86. Do we have other architectures where we can assume that? I'm in the mood for deleting some code today.
Unfortunately my remark on this patch was only for the irq0 override thing, which is x86-specific. I think other architectures still need userspace irqchip in some cases. Paolo Il mar 22 set 2020, 19:29 Eduardo Habkost <ehabkost@redhat.com> ha scritto: > On Tue, Sep 22, 2020 at 07:17:24PM +0200, Paolo Bonzini wrote: > > On 22/09/20 19:03, Eduardo Habkost wrote: > > >> I can remove kernel_irqchip=off once > > >> apic irq0 override is assumed. > > > [4 years later] > > > > > > Can we remove it now? I couldn't find out if we can assume > > > kvm_has_gsi_routing() is true everywhere, or just on a few > > > architectures. > > > > Yes, we can. Other architectures don't matter, what counts is that we > > can require kvm_has_gsi_routing() == true on x86. > > Do we have other architectures where we can assume that? I'm in > the mood for deleting some code today. > > -- > Eduardo > >
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index de4019e..c10b356 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -114,6 +114,7 @@ typedef struct { static const char *disk = "tests/acpi-test-disk.raw"; static const char *data_dir = "tests/acpi-test-data"; +static bool kvm_enabled; #ifdef CONFIG_IASL static const char *iasl = stringify(CONFIG_IASL); #else @@ -707,13 +708,15 @@ static void test_smbios_structs(test_data *data) } } -static void test_acpi_one(const char *params, test_data *data) +static void test_acpi_one(const char *machine, const char *params, + test_data *data) { char *args; - args = g_strdup_printf("-net none -display none %s " + args = g_strdup_printf("-machine %s,accel=%s -net none -display none %s " "-drive id=hd0,if=none,file=%s,format=raw " "-device ide-hd,drive=hd0 ", + machine, kvm_enabled ? "kvm" : "tcg", params ? params : "", disk); qtest_start(args); @@ -758,7 +761,7 @@ static void test_acpi_piix4_tcg(void) data.machine = MACHINE_PC; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); - test_acpi_one("-machine accel=tcg", &data); + test_acpi_one("pc", NULL, &data); free_test_data(&data); } @@ -771,7 +774,7 @@ static void test_acpi_piix4_tcg_bridge(void) data.variant = ".bridge"; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); - test_acpi_one("-machine accel=tcg -device pci-bridge,chassis_nr=1", &data); + test_acpi_one("pc", "-device pci-bridge,chassis_nr=1", &data); free_test_data(&data); } @@ -783,7 +786,7 @@ static void test_acpi_q35_tcg(void) data.machine = MACHINE_Q35; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); - test_acpi_one("-machine q35,accel=tcg", &data); + test_acpi_one("q35", NULL, &data); free_test_data(&data); } @@ -796,7 +799,7 @@ static void test_acpi_q35_tcg_bridge(void) data.variant = ".bridge"; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); - test_acpi_one("-machine q35,accel=tcg -device pci-bridge,chassis_nr=1", + test_acpi_one("q35", "-device pci-bridge,chassis_nr=1", &data); free_test_data(&data); } @@ -808,7 +811,7 @@ static void test_acpi_piix4_tcg_cphp(void) memset(&data, 0, sizeof(data)); data.machine = MACHINE_PC; data.variant = ".cphp"; - test_acpi_one("-machine accel=tcg" + test_acpi_one("pc", " -smp 2,cores=3,sockets=2,maxcpus=6", &data); free_test_data(&data); @@ -821,7 +824,7 @@ static void test_acpi_q35_tcg_cphp(void) memset(&data, 0, sizeof(data)); data.machine = MACHINE_Q35; data.variant = ".cphp"; - test_acpi_one("-machine q35,accel=tcg" + test_acpi_one("q35", " -smp 2,cores=3,sockets=2,maxcpus=6", &data); free_test_data(&data); @@ -840,7 +843,7 @@ static void test_acpi_q35_tcg_ipmi(void) data.variant = ".ipmibt"; data.required_struct_types = ipmi_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); - test_acpi_one("-machine q35,accel=tcg -device ipmi-bmc-sim,id=bmc0" + test_acpi_one("q35", "-device ipmi-bmc-sim,id=bmc0" " -device isa-ipmi-bt,bmc=bmc0", &data); free_test_data(&data); @@ -858,12 +861,22 @@ static void test_acpi_piix4_tcg_ipmi(void) data.variant = ".ipmikcs"; data.required_struct_types = ipmi_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); - test_acpi_one("-machine accel=tcg -device ipmi-bmc-sim,id=bmc0" + test_acpi_one("pc", "-device ipmi-bmc-sim,id=bmc0" " -device isa-ipmi-kcs,irq=0,bmc=bmc0", &data); free_test_data(&data); } +static void check_kvm(void) +{ + int fd = qemu_open("/dev/kvm", O_RDWR); + + if (fd > 0) { + kvm_enabled = true; + qemu_close(fd); + } +} + int main(int argc, char *argv[]) { const char *arch = qtest_get_arch(); @@ -873,17 +886,19 @@ int main(int argc, char *argv[]) if(ret) return ret; + check_kvm(); + g_test_init(&argc, &argv, NULL); if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { - qtest_add_func("acpi/piix4/tcg", test_acpi_piix4_tcg); - qtest_add_func("acpi/piix4/tcg/bridge", test_acpi_piix4_tcg_bridge); - qtest_add_func("acpi/q35/tcg", test_acpi_q35_tcg); - qtest_add_func("acpi/q35/tcg/bridge", test_acpi_q35_tcg_bridge); - qtest_add_func("acpi/piix4/tcg/ipmi", test_acpi_piix4_tcg_ipmi); - qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi); - qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp); - qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp); + qtest_add_func("acpi/piix4", test_acpi_piix4_tcg); + qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge); + qtest_add_func("acpi/q35", test_acpi_q35_tcg); + qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge); + qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi); + qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi); + qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp); + qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp); } ret = g_test_run(); boot_sector_cleanup(disk);
Use kvm acceleration if available. Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> --- Hi, It saves a few seconds so we'll be able to add more tests. I cc-ed Paolo to get his opinion on the correct way to look for the kvm support. Thanks, Marcel tests/bios-tables-test.c | 51 +++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 18 deletions(-)