diff mbox

tests/acpi: speedup acpi tests

Message ID 1473173750-11761-1-git-send-email-marcel@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marcel Apfelbaum Sept. 6, 2016, 2:55 p.m. UTC
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(-)

Comments

Michael S. Tsirkin Sept. 6, 2016, 3:13 p.m. UTC | #1
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
Marcel Apfelbaum Sept. 6, 2016, 3:22 p.m. UTC | #2
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
Marcel Apfelbaum Sept. 6, 2016, 3:44 p.m. UTC | #3
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);
>
Paolo Bonzini Sept. 6, 2016, 3:47 p.m. UTC | #4
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);
>
Michael S. Tsirkin Sept. 6, 2016, 3:51 p.m. UTC | #5
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);
> >
Marcel Apfelbaum Sept. 6, 2016, 3:51 p.m. UTC | #6
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
>>


[...]
Paolo Bonzini Sept. 6, 2016, 3:54 p.m. UTC | #7
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
Michael S. Tsirkin Sept. 6, 2016, 4:10 p.m. UTC | #8
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?
Paolo Bonzini Sept. 6, 2016, 7:11 p.m. UTC | #9
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
Michael S. Tsirkin Sept. 6, 2016, 7:21 p.m. UTC | #10
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.
Paolo Bonzini Sept. 6, 2016, 8:22 p.m. UTC | #11
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
Michael S. Tsirkin Sept. 7, 2016, 1:18 a.m. UTC | #12
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
Michael S. Tsirkin Sept. 9, 2016, 6:43 p.m. UTC | #13
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.
Eduardo Habkost Sept. 22, 2020, 5:03 p.m. UTC | #14
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.
Paolo Bonzini Sept. 22, 2020, 5:17 p.m. UTC | #15
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
Eduardo Habkost Sept. 22, 2020, 5:29 p.m. UTC | #16
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.
Paolo Bonzini Sept. 22, 2020, 5:42 p.m. UTC | #17
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 mbox

Patch

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);