diff options
author | Eric Blake <eblake@redhat.com> | 2017-09-11 12:20:08 -0500 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2018-12-17 15:36:39 +0100 |
commit | 273e3d92cfa26ae07a72657b75b4b76105a0fbc4 (patch) | |
tree | 8d0c2fda69cbd7116c38d75ff337fefc70f63114 /tests/vmgenid-test.c | |
parent | 24c01ffa9d356eed4530e31f7ef93844b6599502 (diff) |
tests/acpi-utils: Drop dependence on global_qtest
As a general rule, we prefer avoiding implicit global state
because it makes code harder to safely copy and paste without
thinking about the global state. Adjust the helper code to
use explicit state instead, and update all callers.
bios-tables-test no longer depends on global_qtest, now that it
passes explicit state through the testsuite data; an assert
proves this fact (although we will get rid of it later, once
global_qtest is gone).
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Igor Mammedov <imammedo@redhat.com>
[thuth: adapted patch to current master branch]
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/vmgenid-test.c')
-rw-r--r-- | tests/vmgenid-test.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index 0a6fb55f2e..c9c4f8c375 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -31,7 +31,7 @@ typedef struct { uint32_t vgia_val; } QEMU_PACKED VgidTable; -static uint32_t acpi_find_vgia(void) +static uint32_t acpi_find_vgia(QTestState *qts) { uint32_t rsdp_offset; uint32_t guid_offset = 0; @@ -45,18 +45,18 @@ static uint32_t acpi_find_vgia(void) int i; /* Wait for guest firmware to finish and start the payload. */ - boot_sector_test(global_qtest); + boot_sector_test(qts); /* Tables should be initialized now. */ - rsdp_offset = acpi_find_rsdp_address(); + rsdp_offset = acpi_find_rsdp_address(qts); g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID); - acpi_parse_rsdp_table(rsdp_offset, &rsdp_table); + acpi_parse_rsdp_table(qts, rsdp_offset, &rsdp_table); rsdt = le32_to_cpu(rsdp_table.rsdt_physical_address); /* read the header */ - ACPI_READ_TABLE_HEADER(&rsdt_table, rsdt); + ACPI_READ_TABLE_HEADER(qts, &rsdt_table, rsdt); ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT"); rsdt_table_length = le32_to_cpu(rsdt_table.length); @@ -67,22 +67,22 @@ static uint32_t acpi_find_vgia(void) /* get the addresses of the tables pointed by rsdt */ tables = g_new0(uint32_t, tables_nr); - ACPI_READ_ARRAY_PTR(tables, tables_nr, rsdt); + ACPI_READ_ARRAY_PTR(qts, tables, tables_nr, rsdt); for (i = 0; i < tables_nr; i++) { uint32_t addr = le32_to_cpu(tables[i]); - ACPI_READ_TABLE_HEADER(&ssdt_table, addr); + ACPI_READ_TABLE_HEADER(qts, &ssdt_table, addr); if (!strncmp((char *)ssdt_table.oem_table_id, "VMGENID", 7)) { /* the first entry in the table should be VGIA * That's all we need */ - ACPI_READ_FIELD(vgid_table.name_op, addr); + ACPI_READ_FIELD(qts, vgid_table.name_op, addr); g_assert(vgid_table.name_op == 0x08); /* name */ - ACPI_READ_ARRAY(vgid_table.vgia, addr); + ACPI_READ_ARRAY(qts, vgid_table.vgia, addr); g_assert(memcmp(vgid_table.vgia, "VGIA", 4) == 0); - ACPI_READ_FIELD(vgid_table.val_op, addr); + ACPI_READ_FIELD(qts, vgid_table.val_op, addr); g_assert(vgid_table.val_op == 0x0C); /* dword */ - ACPI_READ_FIELD(vgid_table.vgia_val, addr); + ACPI_READ_FIELD(qts, vgid_table.vgia_val, addr); /* The GUID is written at a fixed offset into the fw_cfg file * in order to implement the "OVMF SDT Header probe suppressor" * see docs/specs/vmgenid.txt for more details @@ -100,7 +100,7 @@ static void read_guid_from_memory(QemuUUID *guid) uint32_t vmgenid_addr; int i; - vmgenid_addr = acpi_find_vgia(); + vmgenid_addr = acpi_find_vgia(global_qtest); g_assert(vmgenid_addr); /* Read the GUID directly from guest memory */ |