diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-vmstate.c | 273 | ||||
-rw-r--r-- | tests/vmstate-static-checker-data/dump1.json | 1163 | ||||
-rw-r--r-- | tests/vmstate-static-checker-data/dump2.json | 968 |
3 files changed, 2343 insertions, 61 deletions
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index 8b242c4536..a462335c4b 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -54,80 +54,232 @@ static QEMUFile *open_test_file(bool write) return qemu_fdopen(fd, write ? "wb" : "rb"); } -typedef struct TestSruct { - uint32_t a, b, c, e; - uint64_t d, f; - bool skip_c_e; -} TestStruct; +#define SUCCESS(val) \ + g_assert_cmpint((val), ==, 0) +#define FAILURE(val) \ + g_assert_cmpint((val), !=, 0) -static const VMStateDescription vmstate_simple = { - .name = "test", - .version_id = 1, - .minimum_version_id = 1, - .fields = (VMStateField[]) { - VMSTATE_UINT32(a, TestStruct), - VMSTATE_UINT32(b, TestStruct), - VMSTATE_UINT32(c, TestStruct), - VMSTATE_UINT64(d, TestStruct), - VMSTATE_END_OF_LIST() - } -}; +static void save_vmstate(const VMStateDescription *desc, void *obj) +{ + QEMUFile *f = open_test_file(true); + + /* Save file with vmstate */ + vmstate_save_state(f, desc, obj); + qemu_put_byte(f, QEMU_VM_EOF); + g_assert(!qemu_file_get_error(f)); + qemu_fclose(f); +} -static void test_simple_save(void) +static void compare_vmstate(uint8_t *wire, size_t size) { - QEMUFile *fsave = open_test_file(true); - TestStruct obj = { .a = 1, .b = 2, .c = 3, .d = 4 }; - vmstate_save_state(fsave, &vmstate_simple, &obj); - g_assert(!qemu_file_get_error(fsave)); - qemu_fclose(fsave); + QEMUFile *f = open_test_file(false); + uint8_t result[size]; - QEMUFile *loading = open_test_file(false); - uint8_t expected[] = { - 0, 0, 0, 1, /* a */ - 0, 0, 0, 2, /* b */ - 0, 0, 0, 3, /* c */ - 0, 0, 0, 0, 0, 0, 0, 4, /* d */ - }; - uint8_t result[sizeof(expected)]; - g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==, + /* read back as binary */ + + g_assert_cmpint(qemu_get_buffer(f, result, sizeof(result)), ==, sizeof(result)); - g_assert(!qemu_file_get_error(loading)); - g_assert_cmpint(memcmp(result, expected, sizeof(result)), ==, 0); + g_assert(!qemu_file_get_error(f)); + + /* Compare that what is on the file is the same that what we + expected to be there */ + SUCCESS(memcmp(result, wire, sizeof(result))); /* Must reach EOF */ - qemu_get_byte(loading); - g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO); + qemu_get_byte(f); + g_assert_cmpint(qemu_file_get_error(f), ==, -EIO); - qemu_fclose(loading); + qemu_fclose(f); } -static void test_simple_load(void) +static int load_vmstate_one(const VMStateDescription *desc, void *obj, + int version, uint8_t *wire, size_t size) { - QEMUFile *fsave = open_test_file(true); - uint8_t buf[] = { - 0, 0, 0, 10, /* a */ - 0, 0, 0, 20, /* b */ - 0, 0, 0, 30, /* c */ - 0, 0, 0, 0, 0, 0, 0, 40, /* d */ - QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */ - }; - qemu_put_buffer(fsave, buf, sizeof(buf)); - qemu_fclose(fsave); + QEMUFile *f; + int ret; + + f = open_test_file(true); + qemu_put_buffer(f, wire, size); + qemu_fclose(f); + + f = open_test_file(false); + ret = vmstate_load_state(f, desc, obj, version); + if (ret) { + g_assert(qemu_file_get_error(f)); + } else{ + g_assert(!qemu_file_get_error(f)); + } + qemu_fclose(f); + return ret; +} - QEMUFile *loading = open_test_file(false); - TestStruct obj; - vmstate_load_state(loading, &vmstate_simple, &obj, 1); - g_assert(!qemu_file_get_error(loading)); - g_assert_cmpint(obj.a, ==, 10); - g_assert_cmpint(obj.b, ==, 20); - g_assert_cmpint(obj.c, ==, 30); - g_assert_cmpint(obj.d, ==, 40); - qemu_fclose(loading); + +static int load_vmstate(const VMStateDescription *desc, + void *obj, void *obj_clone, + void (*obj_copy)(void *, void*), + int version, uint8_t *wire, size_t size) +{ + /* We test with zero size */ + obj_copy(obj_clone, obj); + FAILURE(load_vmstate_one(desc, obj, version, wire, 0)); + + /* Stream ends with QEMU_EOF, so we need at least 3 bytes to be + * able to test in the middle */ + + if (size > 3) { + + /* We test with size - 2. We can't test size - 1 due to EOF tricks */ + obj_copy(obj, obj_clone); + FAILURE(load_vmstate_one(desc, obj, version, wire, size - 2)); + + /* Test with size/2, first half of real state */ + obj_copy(obj, obj_clone); + FAILURE(load_vmstate_one(desc, obj, version, wire, size/2)); + + /* Test with size/2, second half of real state */ + obj_copy(obj, obj_clone); + FAILURE(load_vmstate_one(desc, obj, version, wire + (size/2), size/2)); + + } + obj_copy(obj, obj_clone); + return load_vmstate_one(desc, obj, version, wire, size); +} + +/* Test struct that we are going to use for our tests */ + +typedef struct TestSimple { + bool b_1, b_2; + uint8_t u8_1; + uint16_t u16_1; + uint32_t u32_1; + uint64_t u64_1; + int8_t i8_1, i8_2; + int16_t i16_1, i16_2; + int32_t i32_1, i32_2; + int64_t i64_1, i64_2; +} TestSimple; + +/* Object instantiation, we are going to use it in more than one test */ + +TestSimple obj_simple = { + .b_1 = true, + .b_2 = false, + .u8_1 = 130, + .u16_1 = 512, + .u32_1 = 70000, + .u64_1 = 12121212, + .i8_1 = 65, + .i8_2 = -65, + .i16_1 = 512, + .i16_2 = -512, + .i32_1 = 70000, + .i32_2 = -70000, + .i64_1 = 12121212, + .i64_2 = -12121212, +}; + +/* Description of the values. If you add a primitive type + you are expected to add a test here */ + +static const VMStateDescription vmstate_simple_primitive = { + .name = "simple/primitive", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_BOOL(b_1, TestSimple), + VMSTATE_BOOL(b_2, TestSimple), + VMSTATE_UINT8(u8_1, TestSimple), + VMSTATE_UINT16(u16_1, TestSimple), + VMSTATE_UINT32(u32_1, TestSimple), + VMSTATE_UINT64(u64_1, TestSimple), + VMSTATE_INT8(i8_1, TestSimple), + VMSTATE_INT8(i8_2, TestSimple), + VMSTATE_INT16(i16_1, TestSimple), + VMSTATE_INT16(i16_2, TestSimple), + VMSTATE_INT32(i32_1, TestSimple), + VMSTATE_INT32(i32_2, TestSimple), + VMSTATE_INT64(i64_1, TestSimple), + VMSTATE_INT64(i64_2, TestSimple), + VMSTATE_END_OF_LIST() + } +}; + +/* It describes what goes through the wire. Our tests are basically: + + * save test + - save a struct a vmstate to a file + - read that file back (binary read, no vmstate) + - compare it with what we expect to be on the wire + * load test + - save to the file what we expect to be on the wire + - read struct back with vmstate in a different + - compare back with the original struct +*/ + +uint8_t wire_simple_primitive[] = { + /* b_1 */ 0x01, + /* b_2 */ 0x00, + /* u8_1 */ 0x82, + /* u16_1 */ 0x02, 0x00, + /* u32_1 */ 0x00, 0x01, 0x11, 0x70, + /* u64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c, + /* i8_1 */ 0x41, + /* i8_2 */ 0xbf, + /* i16_1 */ 0x02, 0x00, + /* i16_2 */ 0xfe, 0x0, + /* i32_1 */ 0x00, 0x01, 0x11, 0x70, + /* i32_2 */ 0xff, 0xfe, 0xee, 0x90, + /* i64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c, + /* i64_2 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0x47, 0x0b, 0x84, + QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */ +}; + +static void obj_simple_copy(void *target, void *source) +{ + memcpy(target, source, sizeof(TestSimple)); +} + +static void test_simple_primitive(void) +{ + TestSimple obj, obj_clone; + + memset(&obj, 0, sizeof(obj)); + save_vmstate(&vmstate_simple_primitive, &obj_simple); + + compare_vmstate(wire_simple_primitive, sizeof(wire_simple_primitive)); + + SUCCESS(load_vmstate(&vmstate_simple_primitive, &obj, &obj_clone, + obj_simple_copy, 1, wire_simple_primitive, + sizeof(wire_simple_primitive))); + +#define FIELD_EQUAL(name) g_assert_cmpint(obj.name, ==, obj_simple.name) + + FIELD_EQUAL(b_1); + FIELD_EQUAL(b_2); + FIELD_EQUAL(u8_1); + FIELD_EQUAL(u16_1); + FIELD_EQUAL(u32_1); + FIELD_EQUAL(u64_1); + FIELD_EQUAL(i8_1); + FIELD_EQUAL(i8_2); + FIELD_EQUAL(i16_1); + FIELD_EQUAL(i16_2); + FIELD_EQUAL(i32_1); + FIELD_EQUAL(i32_2); + FIELD_EQUAL(i64_1); + FIELD_EQUAL(i64_2); } +#undef FIELD_EQUAL + +typedef struct TestStruct { + uint32_t a, b, c, e; + uint64_t d, f; + bool skip_c_e; +} TestStruct; static const VMStateDescription vmstate_versioned = { - .name = "test", + .name = "test/versioned", .version_id = 2, .minimum_version_id = 1, .fields = (VMStateField[]) { @@ -202,7 +354,7 @@ static bool test_skip(void *opaque, int version_id) } static const VMStateDescription vmstate_skipping = { - .name = "test", + .name = "test/skip", .version_id = 2, .minimum_version_id = 1, .fields = (VMStateField[]) { @@ -337,8 +489,7 @@ int main(int argc, char **argv) temp_fd = mkstemp(temp_file); g_test_init(&argc, &argv, NULL); - g_test_add_func("/vmstate/simple/save", test_simple_save); - g_test_add_func("/vmstate/simple/load", test_simple_load); + g_test_add_func("/vmstate/simple/primitive", test_simple_primitive); g_test_add_func("/vmstate/versioned/load/v1", test_load_v1); g_test_add_func("/vmstate/versioned/load/v2", test_load_v2); g_test_add_func("/vmstate/field_exists/load/noskip", test_load_noskip); diff --git a/tests/vmstate-static-checker-data/dump1.json b/tests/vmstate-static-checker-data/dump1.json new file mode 100644 index 0000000000..786ca0b484 --- /dev/null +++ b/tests/vmstate-static-checker-data/dump1.json @@ -0,0 +1,1163 @@ +{ + "vmschkmachine": { + "Name": "pc-i440fx-2.1" + }, + "fw_cfg": { + "Name": "fw_cfg", + "version_id": 2, + "minimum_version_id": 1, + "Description": { + "name": "fw_cfg", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "cur_entry", + "version_id": 0, + "field_exists": false, + "size": 2 + }, + { + "field": "cur_offset", + "version_id": 0, + "field_exists": true, + "size": 4 + }, + { + "field": "cur_offset", + "version_id": 2, + "field_exists": false, + "size": 4 + } + ] + } + }, + "fusbh200-ehci-usb": { + "Name": "fusbh200-ehci-usb", + "version_id": 2, + "minimum_version_id": 1, + "Description": { + "name": "ehci-sysbus", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "ehci", + "version_id": 2, + "field_exists": false, + "size": 1880, + "Description": { + "name": "ehci-core", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "usbcmd", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "usbsts", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "usbsts_pending", + "version_id": 2, + "field_exists": false, + "size": 4 + }, + { + "field": "usbsts_frindex", + "version_id": 2, + "field_exists": false, + "size": 4 + }, + { + "field": "usbintr", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "frindex", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "ctrldssegment", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "periodiclistbase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "asynclistaddr", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "configflag", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "portsc[0]", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "portsc[1]", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "portsc[2]", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "portsc[3]", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "portsc[4]", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "portsc[5]", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "frame_timer", + "version_id": 0, + "field_exists": false, + "size": 8 + }, + { + "field": "last_run_ns", + "version_id": 0, + "field_exists": false, + "size": 8 + }, + { + "field": "async_stepdown", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "astate", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "pstate", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "a_fetch_addr", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "p_fetch_addr", + "version_id": 0, + "field_exists": false, + "size": 4 + } + ] + } + } + ] + } + }, + "pci-serial-4x": { + "Name": "pci-serial-4x", + "version_id": 1, + "minimum_version_id": 1, + "Description": { + "name": "pci-serial-multi", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "dev", + "version_id": 0, + "field_exists": false, + "size": 1944, + "Description": { + "name": "PCIDevice", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "version_id", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "config", + "version_id": 0, + "field_exists": false, + "size": 256 + }, + { + "field": "irq_state", + "version_id": 2, + "field_exists": false, + "size": 16 + } + ] + } + }, + { + "field": "state", + "version_id": 0, + "field_exists": false, + "size": 368, + "Description": { + "name": "serial", + "version_id": 3, + "minimum_version_id": 2, + "Fields": [ + { + "field": "divider", + "version_id": 2, + "field_exists": false, + "size": 2 + }, + { + "field": "rbr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "ier", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "iir", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "lcr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "mcr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "lsr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "msr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "scr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "fcr_vmstate", + "version_id": 3, + "field_exists": false, + "size": 1 + } + ] + } + }, + { + "field": "level", + "version_id": 0, + "field_exists": false, + "size": 4 + } + ] + } + }, + "intel-hda-generic": { + "Name": "intel-hda-generic", + "version_id": 1, + "minimum_version_id": 0, + "Description": { + "name": "intel-hda", + "version_id": 1, + "minimum_version_id": 0, + "Fields": [ + { + "field": "pci", + "version_id": 0, + "field_exists": false, + "size": 1944, + "Description": { + "name": "PCIDevice", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "version_id", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "config", + "version_id": 0, + "field_exists": false, + "size": 256 + }, + { + "field": "irq_state", + "version_id": 2, + "field_exists": false, + "size": 16 + } + ] + } + }, + { + "field": "g_ctl", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "wake_en", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "state_sts", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "int_ctl", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "int_sts", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "wall_clk", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_lbase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_ubase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_rp", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_wp", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_ctl", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_sts", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_size", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_lbase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_ubase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_wp", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_cnt", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_ctl", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_sts", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_size", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "dp_lbase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "dp_ubase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "icw", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "irr", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "ics", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "st", + "version_id": 0, + "field_exists": false, + "size": 56, + "Description": { + "name": "intel-hda-stream", + "version_id": 1, + "minimum_version_id": 0, + "Fields": [ + { + "field": "ctl", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "lpib", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "cbl", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "lvi", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "fmt", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "bdlp_lbase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "bdlp_ubase", + "version_id": 0, + "field_exists": false, + "size": 4 + } + ] + } + }, + { + "field": "rirb_count", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "wall_base_ns", + "version_id": 0, + "field_exists": false, + "size": 8 + } + ] + } + }, + "cfi.pflash01": { + "Name": "cfi.pflash01", + "version_id": 1, + "minimum_version_id": 1, + "Description": { + "name": "pflash_cfi01", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "wcycle", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "cmd", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "status", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "counter", + "version_id": 0, + "field_exists": false, + "size": 8 + } + ] + } + }, + "megasas": { + "Name": "megasas", + "version_id": 0, + "minimum_version_id": 0, + "Description": { + "name": "megasas", + "version_id": 0, + "minimum_version_id": 0, + "Fields": [ + { + "field": "parent_obj", + "version_id": 0, + "field_exists": false, + "size": 1944, + "Description": { + "name": "PCIDevice", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "version_id", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "config", + "version_id": 0, + "field_exists": false, + "size": 256 + }, + { + "field": "irq_state", + "version_id": 2, + "field_exists": false, + "size": 16 + } + ] + } + }, + { + "field": "fw_state", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "intr_mask", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "doorbell", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "reply_queue_pa", + "version_id": 0, + "field_exists": false, + "size": 8 + }, + { + "field": "consumer_pa", + "version_id": 0, + "field_exists": false, + "size": 8 + }, + { + "field": "producer_pa", + "version_id": 0, + "field_exists": false, + "size": 8 + } + ] + } + }, + "PIIX3-xen": { + "Name": "PIIX3-xen", + "version_id": 3, + "minimum_version_id": 2, + "Description": { + "name": "PIIX3", + "version_id": 1, + "minimum_version_id": 2, + "Fields": [ + { + "field": "dev", + "version_id": 0, + "field_exists": false, + "size": 1944, + "Description": { + "name": "PCIDevice", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "version_id", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "config", + "version_id": 0, + "field_exists": false, + "size": 256 + }, + { + "field": "irq_state", + "version_id": 2, + "field_exists": false, + "size": 16 + } + ] + } + }, + { + "field": "pci_irq_levels_vmstate", + "version_id": 3, + "field_exists": false, + "size": 4 + } + ], + "Subsections": [ + { + "name": "PIIX3/rcr", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "rcr", + "version_id": 0, + "field_exists": false, + "size": 1 + } + ] + } + ] + } + }, + "tpci200": { + "Name": "tpci200", + "version_id": 1, + "minimum_version_id": 1, + "Description": { + "name": "tpci200", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "dev", + "version_id": 0, + "field_exists": false, + "size": 1944, + "Description": { + "name": "PCIDevice", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "version_id", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "config", + "version_id": 0, + "field_exists": false, + "size": 256 + }, + { + "field": "irq_state", + "version_id": 2, + "field_exists": false, + "size": 16 + } + ] + } + }, + { + "field": "big_endian", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "ctrl", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "status", + "version_id": 0, + "field_exists": false, + "size": 2 + }, + { + "field": "int_set", + "version_id": 0, + "field_exists": false, + "size": 1 + } + ] + } + }, + "SUNW,fdtwo": { + "Name": "SUNW,fdtwo", + "version_id": 2, + "minimum_version_id": 2, + "Description": { + "name": "fdc", + "version_id": 2, + "minimum_version_id": 2, + "Fields": [ + { + "field": "state", + "version_id": 0, + "field_exists": false, + "size": 360, + "Description": { + "name": "fdc", + "version_id": 2, + "minimum_version_id": 2, + "Fields": [ + { + "field": "sra", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "srb", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "dor_vmstate", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "tdr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "dsr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "msr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "status0", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "status1", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "status2", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "fifo", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "data_pos", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "data_len", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "data_state", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "data_dir", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "eot", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "timer0", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "timer1", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "precomp_trk", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "config", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "lock", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "pwrd", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "num_floppies", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "drives", + "version_id": 1, + "field_exists": false, + "size": 40, + "Description": { + "name": "fdrive", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "head", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "track", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "sect", + "version_id": 0, + "field_exists": false, + "size": 1 + } + ], + "Subsections": [ + { + "name": "fdrive/media_changed", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "media_changed", + "version_id": 0, + "field_exists": false, + "size": 1 + } + ] + }, + { + "name": "fdrive/media_rate", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "media_rate", + "version_id": 0, + "field_exists": false, + "size": 1 + } + ] + } + ] + } + } + ] + } + } + ] + } + }, + "usb-kbd": { + "Name": "usb-kbd", + "version_id": 1, + "minimum_version_id": 1, + "Description": { + "name": "usb-kbd", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "dev", + "version_id": 0, + "field_exists": false, + "size": 4352, + "Description": { + "name": "USBDevice", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "addr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "state", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "remote_wakeup", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "setup_state", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "setup_len", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "setup_index", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "setup_buf", + "version_id": 0, + "field_exists": false, + "size": 1 + } + ] + } + }, + { + "field": "kbd.keycodes", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "head", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "n", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "kbd.modifiers", + "version_id": 0, + "field_exists": false, + "size": 2 + }, + { + "field": "kbd.leds", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "kbd.key", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "kbd.keys", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "protocol", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "idle", + "version_id": 0, + "field_exists": false, + "size": 1 + } + ] + } + } +} diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json new file mode 100644 index 0000000000..75719f5ec9 --- /dev/null +++ b/tests/vmstate-static-checker-data/dump2.json @@ -0,0 +1,968 @@ +{ + "vmschkmachine": { + "Name": "pc-i440fx-2.2" + }, + "fw_cfg2": { + "Name": "fw_cfg", + "version_id": 2, + "minimum_version_id": 1, + "Description": { + "name": "fw_cfg", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "cur_entry", + "version_id": 0, + "field_exists": false, + "size": 2 + }, + { + "field": "cur_offset", + "version_id": 0, + "field_exists": true, + "size": 4 + }, + { + "field": "cur_offset", + "version_id": 2, + "field_exists": false, + "size": 4 + } + ] + } + }, + "fusbh200-ehci-usb": { + "Name": "fusbh200-ehci-usb", + "version_id": 1, + "minimum_version_id": 1, + "Description": { + "name": "ehci-sysbus", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "ehci", + "version_id": 2, + "field_exists": false, + "size": 1880, + "Description": { + "name": "ehci-core", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "usbcmd", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "usbsts_pending", + "version_id": 2, + "field_exists": false, + "size": 4 + }, + { + "field": "usbsts_frindex", + "version_id": 2, + "field_exists": false, + "size": 4 + }, + { + "field": "usbintr", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "frindex", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "ctrldssegment", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "periodiclistbase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "asynclistaddr", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "configflag", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "portsc[0]", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "portsc[1]", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "portsc[2]", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "portsc[3]", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "portsc[4]", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "portsc[5]", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "frame_timer", + "version_id": 0, + "field_exists": false, + "size": 8 + }, + { + "field": "last_run_ns", + "version_id": 0, + "field_exists": false, + "size": 8 + }, + { + "field": "async_stepdown", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "astate", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "pstate", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "a_fetch_addr", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "p_fetch_addr", + "version_id": 0, + "field_exists": false, + "size": 4 + } + ] + } + } + ] + } + }, + "pci-serial-4x": { + "Name": "pci-serial-4x", + "version_id": 1, + "minimum_version_id": 1, + "Description": { + "name": "pci-serial-multi", + "version_id": 1, + "minimum_version_id": 1 + } + }, + "intel-hda-generic": { + "Name": "intel-hda-generic", + "version_id": 1, + "minimum_version_id": 0, + "Description": { + "name": "intel-hda", + "version_id": 1, + "minimum_version_id": 0, + "Fields": [ + { + "field": "pci", + "version_id": 0, + "field_exists": false, + "size": 1944 + }, + { + "field": "g_ctl", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "wake_en", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "state_sts", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "int_ctl", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "int_sts", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "wall_clk", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_lbase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_ubase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_rp", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_wp", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_ctl", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_sts", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "corb_size", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_lbase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_ubase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_wp", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_cnt", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_ctl", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_sts", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "rirb_size", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "dp_lbase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "dp_ubase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "icw", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "irr", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "ics", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "st", + "version_id": 0, + "field_exists": false, + "size": 56, + "Description": { + "name": "intel-hda-stream", + "version_id": 1, + "minimum_version_id": 0, + "Fields": [ + { + "field": "ctl", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "lpib", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "cbl", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "lvi", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "fmt", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "bdlp_lbase", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "bdlp_ubase", + "version_id": 0, + "field_exists": false, + "size": 4 + } + ] + } + }, + { + "field": "rirb_count", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "wall_base_ns", + "version_id": 0, + "field_exists": false, + "size": 8 + } + ] + } + }, + "cfi.pflash01": { + "Name": "cfi.pflash01", + "version_id": 1, + "minimum_version_id": 1 + }, + "megasas": { + "Name": "megasas", + "version_id": 0, + "minimum_version_id": 0, + "Description": { + "name": "megasas", + "version_id": 0, + "minimum_version_id": 0, + "Fields": [ + { + "field": "parent_obj", + "version_id": 0, + "field_exists": false, + "size": 1944, + "Description": { + "name": "PCIDevice", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "version_id", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "config", + "version_id": 0, + "field_exists": false, + "size": 256 + } + ] + } + }, + { + "field": "fw_state", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "intr_mask", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "doorbell", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "reply_queue_pa", + "version_id": 0, + "field_exists": false, + "size": 8 + }, + { + "field": "consumer_pa", + "version_id": 0, + "field_exists": false, + "size": 8 + }, + { + "field": "producer_pa", + "version_id": 0, + "field_exists": false, + "size": 8 + } + ] + } + }, + "PIIX3-xen": { + "Name": "PIIX3-xen", + "version_id": 3, + "minimum_version_id": 2, + "Description": { + "name": "PIIX3", + "version_id": 3, + "minimum_version_id": 2, + "Fields": [ + { + "field": "dev", + "version_id": 0, + "field_exists": false, + "size": 1944, + "Description": { + "name": "PCIDevice", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "version_id", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "config", + "version_id": 0, + "field_exists": false, + "size": 256 + }, + { + "field": "irq_state", + "version_id": 2, + "field_exists": false, + "size": 16 + } + ] + } + }, + { + "field": "pci_irq_levels_vmstate", + "version_id": 3, + "field_exists": false, + "size": 4 + } + ] + } + }, + "tpci200": { + "Name": "tpci200", + "version_id": 1, + "minimum_version_id": 1, + "Description": { + "name": "tpci2002", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "dev", + "version_id": 0, + "field_exists": false, + "size": 1944, + "Description": { + "name": "PCIDevice", + "version_id": 2, + "minimum_version_id": 1, + "Fields": [ + { + "field": "version_id", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "config", + "version_id": 0, + "field_exists": false, + "size": 256 + }, + { + "field": "irq_state", + "version_id": 2, + "field_exists": false, + "size": 16 + } + ] + } + }, + { + "field": "big_endian", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "ctrl", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "status", + "version_id": 0, + "field_exists": false, + "size": 2 + }, + { + "field": "int_set", + "version_id": 0, + "field_exists": false, + "size": 1 + } + ] + } + }, + "SUNW,fdtwo": { + "Name": "SUNW,fdtwo", + "version_id": 2, + "minimum_version_id": 2, + "Description": { + "name": "fdc", + "version_id": 1, + "minimum_version_id": 2, + "Fields": [ + { + "field": "state", + "version_id": 0, + "field_exists": false, + "size": 360, + "Description": { + "name": "fdc", + "version_id": 2, + "minimum_version_id": 2, + "Fields": [ + { + "field": "sra", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "srb", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "dor_vmstate", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "tdr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "dsr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "msr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "status0", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "status1", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "status2", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "fifo", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "data_pos", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "data_len", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "data_state", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "data_dir", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "eot", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "timer0", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "timer1", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "precomp_trk", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "config", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "lock", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "pwrd", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "num_floppies", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "drives", + "version_id": 1, + "field_exists": false, + "size": 40, + "Description": { + "name": "fdrive", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "head", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "track", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "sect", + "version_id": 0, + "field_exists": false, + "size": 1 + } + ], + "Subsections": [ + { + "name": "fdrive/media_changed", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "media_changed", + "version_id": 0, + "field_exists": false, + "size": 1 + } + ] + } + ] + } + } + ] + } + } + ] + } + }, + "usb-kbd": { + "Name": "usb-kbd", + "version_id": 1, + "minimum_version_id": 1, + "Description": { + "name": "usb-kbd", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "dev", + "version_id": 0, + "field_exists": false, + "size": 5832, + "Description": { + "name": "USBDevice", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "addr", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "state", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "remote_wakeup", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "setup_state", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "setup_len", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "setup_index", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "setup_buf", + "version_id": 0, + "field_exists": false, + "size": 1 + } + ] + } + }, + { + "field": "hid", + "version_id": 0, + "field_exists": false, + "size": 312, + "Description": { + "name": "HIDKeyboardDevice", + "version_id": 1, + "minimum_version_id": 1, + "Fields": [ + { + "field": "kbd.keycodes", + "version_id": 0, + "field_exists": false, + "size": 2 + }, + { + "field": "head", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "n", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "kbd.modifiers", + "version_id": 0, + "field_exists": false, + "size": 2 + }, + { + "field": "kbd.leds", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "kbd.key", + "version_id": 0, + "field_exists": false, + "size": 1 + }, + { + "field": "kbd.keys", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "protocol", + "version_id": 0, + "field_exists": false, + "size": 4 + }, + { + "field": "idle", + "version_id": 0, + "field_exists": false, + "size": 1 + } + ] + } + } + ] + } + } +} |