aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2025-02-03 13:41:48 -0500
committerStefan Hajnoczi <stefanha@redhat.com>2025-02-03 13:41:48 -0500
commitf58eb46a5ba284a97e45fd754871333ba2aeff39 (patch)
tree8b42b9b034523f2be69307120a8f4456e939d6eb
parent6fccaa2fba391815308a746d68f7fa197bc93586 (diff)
parentcd6406df15ed2216e70e34c45a4a82f42b55873f (diff)
downloadqemu-f58eb46a5ba284a97e45fd754871333ba2aeff39.zip
qemu-f58eb46a5ba284a97e45fd754871333ba2aeff39.tar.gz
qemu-f58eb46a5ba284a97e45fd754871333ba2aeff39.tar.bz2
Merge tag 'qtest-20250203-pull-request' of https://gitlab.com/farosas/qemu into staging
Qtest pull request - fw-cfg: DMA support and new vmcoreinfo test - accel detection via QOM for non-KVM accels - use virtio modern for vhost-user # -----BEGIN PGP SIGNATURE----- # # iQJEBAABCAAuFiEEqhtIsKIjJqWkw2TPx5jcdBvsMZ0FAmeg8+cQHGZhcm9zYXNA # c3VzZS5kZQAKCRDHmNx0G+wxnS1jD/9/xx8i9fQgA9znEZmzMvQ0xXrlUz8jQkA8 # yd/iCZT1ue4ff39XA/Z01J/lUaHFV5x4xV4/YL+I0IcMddwIuI3xXexAEyO76rRC # dRxjKrq20s2W6VPnOT0NHBnvpNnYoQDunIZxY+16QMWajTRbA45G8R7W4dWWOhLQ # 2sWNuQHsj1lQ4lZMYlaMuFZC31PgFgPiEwIfS2NHST3WfxJVPpsLU5/Pc8UGs6fd # Sq58jXPS1Akhov7IuC8VG/icjnDpMe3f7OFWQ8u8MC5OhwFNnD7aNnf6V7LmM4f+ # vhwLPewKxS3KQ2j1Vt2iWGebxlJHDbvifaBpIiVIibaHvtzcOdwK/bK0i+ji3oTk # NgDB80+UKEUGzj0A+BNMcI+ZMonRT2wmBucWdGCosEG1FUlDONdX2a8Zs5Cfxipe # N2a30OmIfbHo905JLYbTw5SXFSyWdYTSgXOEyNlXjq/B+v3qtpdrHXtMOJaXfk/V # Ln0pKT/mDKx/haiooJdMheJpvRDYxFUHub1MrqnVWWeoiTS2wRwu9QAbFusNwyrk # cEYQRPwuX0AnGk6swRUVLdd7HHeeNDZtVBr30Gi1hzQUZRsfW/YmKunoXJ38XAoG # ZD/7VdTgmpQcoXNBJFnyi9Ie6NSWZwgNmZmZn3yWQtV5ACWIt0cqwF8POh8TOY25 # 5mVQly/UAA== # =FJP7 # -----END PGP SIGNATURE----- # gpg: Signature made Mon 03 Feb 2025 11:50:47 EST # gpg: using RSA key AA1B48B0A22326A5A4C364CFC798DC741BEC319D # gpg: issuer "farosas@suse.de" # gpg: Good signature from "Fabiano Rosas <farosas@suse.de>" [unknown] # gpg: aka "Fabiano Almeida Rosas <fabiano.rosas@suse.com>" [unknown] # gpg: WARNING: The key's User ID is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: AA1B 48B0 A223 26A5 A4C3 64CF C798 DC74 1BEC 319D * tag 'qtest-20250203-pull-request' of https://gitlab.com/farosas/qemu: tests/qtest/vhost-user-test: Use modern virtio for vhost-user tests tests/qtest: Make qtest_has_accel() generic tests/qtest: Extract qtest_qom_has_concrete_type() helper tests/qtest/vmcoreinfo: add a unit test to exercize basic vmcoreinfo function tests/qtest/libqos: add DMA support for writing and reading fw_cfg files libqos/fw_cfg: refactor file directory iteraton to make it more reusable Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-rw-r--r--MAINTAINERS2
-rw-r--r--tests/qtest/libqos/fw_cfg.c202
-rw-r--r--tests/qtest/libqos/fw_cfg.h6
-rw-r--r--tests/qtest/libqtest.c110
-rw-r--r--tests/qtest/meson.build1
-rw-r--r--tests/qtest/vhost-user-test.c3
-rw-r--r--tests/qtest/vmcoreinfo-test.c90
7 files changed, 340 insertions, 74 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index bf737eb..0cf37fc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3019,6 +3019,7 @@ F: include/system/device_tree.h
Dump
S: Supported
M: Marc-André Lureau <marcandre.lureau@redhat.com>
+R: Ani Sinha <anisinha@redhat.com>
F: dump/
F: hw/misc/vmcoreinfo.c
F: include/hw/misc/vmcoreinfo.h
@@ -3029,6 +3030,7 @@ F: qapi/dump.json
F: scripts/dump-guest-memory.py
F: stubs/dump.c
F: docs/specs/vmcoreinfo.rst
+F: tests/qtest/vmcoreinfo-test.c
Error reporting
M: Markus Armbruster <armbru@redhat.com>
diff --git a/tests/qtest/libqos/fw_cfg.c b/tests/qtest/libqos/fw_cfg.c
index 89f053c..0ab3959 100644
--- a/tests/qtest/libqos/fw_cfg.c
+++ b/tests/qtest/libqos/fw_cfg.c
@@ -14,6 +14,8 @@
#include "qemu/osdep.h"
#include "fw_cfg.h"
+#include "malloc-pc.h"
+#include "libqos-malloc.h"
#include "../libqtest.h"
#include "qemu/bswap.h"
#include "hw/nvram/fw_cfg.h"
@@ -60,6 +62,91 @@ static void mm_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
qtest_writew(fw_cfg->qts, fw_cfg->base, key);
}
+static void qfw_cfg_dma_transfer(QFWCFG *fw_cfg, QOSState *qs, void *address,
+ uint32_t length, uint32_t control)
+{
+ FWCfgDmaAccess access;
+ uint32_t addr;
+ uint64_t guest_access_addr;
+ uint64_t gaddr;
+
+ /* create a data buffer in guest memory */
+ gaddr = guest_alloc(&qs->alloc, length);
+
+ if (control & FW_CFG_DMA_CTL_WRITE) {
+ qtest_bufwrite(fw_cfg->qts, gaddr, address, length);
+ }
+ access.address = cpu_to_be64(gaddr);
+ access.length = cpu_to_be32(length);
+ access.control = cpu_to_be32(control);
+
+ /* now create a separate buffer in guest memory for 'access' */
+ guest_access_addr = guest_alloc(&qs->alloc, sizeof(access));
+ qtest_bufwrite(fw_cfg->qts, guest_access_addr, &access, sizeof(access));
+
+ /* write lower 32 bits of address */
+ addr = cpu_to_be32((uint32_t)(uintptr_t)guest_access_addr);
+ qtest_outl(fw_cfg->qts, fw_cfg->base + 8, addr);
+
+ /* write upper 32 bits of address */
+ addr = cpu_to_be32((uint32_t)(uintptr_t)(guest_access_addr >> 32));
+ qtest_outl(fw_cfg->qts, fw_cfg->base + 4, addr);
+
+ g_assert(!(be32_to_cpu(access.control) & FW_CFG_DMA_CTL_ERROR));
+
+ if (control & FW_CFG_DMA_CTL_READ) {
+ qtest_bufread(fw_cfg->qts, gaddr, address, length);
+ }
+
+ guest_free(&qs->alloc, guest_access_addr);
+ guest_free(&qs->alloc, gaddr);
+}
+
+static void qfw_cfg_write_entry(QFWCFG *fw_cfg, QOSState *qs, uint16_t key,
+ void *buf, uint32_t len)
+{
+ qfw_cfg_select(fw_cfg, key);
+ qfw_cfg_dma_transfer(fw_cfg, qs, buf, len, FW_CFG_DMA_CTL_WRITE);
+}
+
+static void qfw_cfg_read_entry(QFWCFG *fw_cfg, QOSState *qs, uint16_t key,
+ void *buf, uint32_t len)
+{
+ qfw_cfg_select(fw_cfg, key);
+ qfw_cfg_dma_transfer(fw_cfg, qs, buf, len, FW_CFG_DMA_CTL_READ);
+}
+
+static bool find_pdir_entry(QFWCFG *fw_cfg, const char *filename,
+ uint16_t *sel, uint32_t *size)
+{
+ g_autofree unsigned char *filesbuf = NULL;
+ uint32_t count;
+ size_t dsize;
+ FWCfgFile *pdir_entry;
+ uint32_t i;
+ bool found = false;
+
+ *size = 0;
+ *sel = 0;
+
+ qfw_cfg_get(fw_cfg, FW_CFG_FILE_DIR, &count, sizeof(count));
+ count = be32_to_cpu(count);
+ dsize = sizeof(uint32_t) + count * sizeof(struct fw_cfg_file);
+ filesbuf = g_malloc(dsize);
+ qfw_cfg_get(fw_cfg, FW_CFG_FILE_DIR, filesbuf, dsize);
+ pdir_entry = (FWCfgFile *)(filesbuf + sizeof(uint32_t));
+ for (i = 0; i < count; ++i, ++pdir_entry) {
+ if (!strcmp(pdir_entry->name, filename)) {
+ *size = be32_to_cpu(pdir_entry->size);
+ *sel = be16_to_cpu(pdir_entry->select);
+ found = true;
+ break;
+ }
+ }
+
+ return found;
+}
+
/*
* The caller need check the return value. When the return value is
* nonzero, it means that some bytes have been transferred.
@@ -73,37 +160,106 @@ static void mm_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
* populated, it has received only a starting slice of the fw_cfg file.
*/
size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *filename,
- void *data, size_t buflen)
+ void *data, size_t buflen)
{
- uint32_t count;
- uint32_t i;
- unsigned char *filesbuf = NULL;
- size_t dsize;
- FWCfgFile *pdir_entry;
size_t filesize = 0;
+ uint32_t len;
+ uint16_t sel;
- qfw_cfg_get(fw_cfg, FW_CFG_FILE_DIR, &count, sizeof(count));
- count = be32_to_cpu(count);
- dsize = sizeof(uint32_t) + count * sizeof(struct fw_cfg_file);
- filesbuf = g_malloc(dsize);
- qfw_cfg_get(fw_cfg, FW_CFG_FILE_DIR, filesbuf, dsize);
- pdir_entry = (FWCfgFile *)(filesbuf + sizeof(uint32_t));
- for (i = 0; i < count; ++i, ++pdir_entry) {
- if (!strcmp(pdir_entry->name, filename)) {
- uint32_t len = be32_to_cpu(pdir_entry->size);
- uint16_t sel = be16_to_cpu(pdir_entry->select);
- filesize = len;
- if (len > buflen) {
- len = buflen;
- }
- qfw_cfg_get(fw_cfg, sel, data, len);
- break;
+ if (find_pdir_entry(fw_cfg, filename, &sel, &len)) {
+ filesize = len;
+ if (len > buflen) {
+ len = buflen;
}
+ qfw_cfg_get(fw_cfg, sel, data, len);
}
- g_free(filesbuf);
+
return filesize;
}
+/*
+ * The caller need check the return value. When the return value is
+ * nonzero, it means that some bytes have been transferred.
+ *
+ * If the fw_cfg file in question is smaller than the allocated & passed-in
+ * buffer, then the first len bytes were read.
+ *
+ * If the fw_cfg file in question is larger than the passed-in
+ * buffer, then the return value explains how much was actually read.
+ *
+ * It is illegal to call this function if fw_cfg does not support DMA
+ * interface. The caller should ensure that DMA is supported before
+ * calling this function.
+ *
+ * Passed QOSState pointer qs must be initialized. qs->alloc must also be
+ * properly initialized.
+ */
+size_t qfw_cfg_read_file(QFWCFG *fw_cfg, QOSState *qs, const char *filename,
+ void *data, size_t buflen)
+{
+ uint32_t len = 0;
+ uint16_t sel;
+ uint32_t id;
+
+ g_assert(qs);
+ g_assert(filename);
+ g_assert(data);
+ g_assert(buflen);
+ /* check if DMA is supported since we use DMA for read */
+ id = qfw_cfg_get_u32(fw_cfg, FW_CFG_ID);
+ g_assert(id & FW_CFG_VERSION_DMA);
+
+ if (find_pdir_entry(fw_cfg, filename, &sel, &len)) {
+ if (len > buflen) {
+ len = buflen;
+ }
+ qfw_cfg_read_entry(fw_cfg, qs, sel, data, len);
+ }
+
+ return len;
+}
+
+/*
+ * The caller need check the return value. When the return value is
+ * nonzero, it means that some bytes have been transferred.
+ *
+ * If the fw_cfg file in question is smaller than the allocated & passed-in
+ * buffer, then the buffer has been partially written.
+ *
+ * If the fw_cfg file in question is larger than the passed-in
+ * buffer, then the return value explains how much was actually written.
+ *
+ * It is illegal to call this function if fw_cfg does not support DMA
+ * interface. The caller should ensure that DMA is supported before
+ * calling this function.
+ *
+ * Passed QOSState pointer qs must be initialized. qs->alloc must also be
+ * properly initialized.
+ */
+size_t qfw_cfg_write_file(QFWCFG *fw_cfg, QOSState *qs, const char *filename,
+ void *data, size_t buflen)
+{
+ uint32_t len = 0;
+ uint16_t sel;
+ uint32_t id;
+
+ g_assert(qs);
+ g_assert(filename);
+ g_assert(data);
+ g_assert(buflen);
+ /* write operation is only valid if DMA is supported */
+ id = qfw_cfg_get_u32(fw_cfg, FW_CFG_ID);
+ g_assert(id & FW_CFG_VERSION_DMA);
+
+ if (find_pdir_entry(fw_cfg, filename, &sel, &len)) {
+ if (len > buflen) {
+ len = buflen;
+ }
+ qfw_cfg_write_entry(fw_cfg, qs, sel, data, len);
+ }
+ return len;
+}
+
static void mm_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
{
uint8_t *ptr = data;
diff --git a/tests/qtest/libqos/fw_cfg.h b/tests/qtest/libqos/fw_cfg.h
index b0456a1..6d6ff09 100644
--- a/tests/qtest/libqos/fw_cfg.h
+++ b/tests/qtest/libqos/fw_cfg.h
@@ -14,6 +14,7 @@
#define LIBQOS_FW_CFG_H
#include "../libqtest.h"
+#include "libqos.h"
typedef struct QFWCFG QFWCFG;
@@ -33,7 +34,10 @@ uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key);
uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key);
size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *filename,
void *data, size_t buflen);
-
+size_t qfw_cfg_write_file(QFWCFG *fw_cfg, QOSState *qs, const char *filename,
+ void *data, size_t buflen);
+size_t qfw_cfg_read_file(QFWCFG *fw_cfg, QOSState *qs, const char *filename,
+ void *data, size_t buflen);
QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base);
void mm_fw_cfg_uninit(QFWCFG *fw_cfg);
QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base);
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 437b24f..fe8606b 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -30,6 +30,7 @@
#include "libqtest.h"
#include "libqmp.h"
+#include "qemu/accel.h"
#include "qemu/ctype.h"
#include "qemu/cutils.h"
#include "qemu/sockets.h"
@@ -1011,15 +1012,62 @@ const char *qtest_get_arch(void)
return end + 1;
}
+static bool qtest_qom_has_concrete_type(const char *parent_typename,
+ const char *child_typename,
+ QList **cached_list)
+{
+ QList *list = cached_list ? *cached_list : NULL;
+ const QListEntry *p;
+ QObject *qobj;
+ QString *qstr;
+ QDict *devinfo;
+ int idx;
+
+ if (!list) {
+ QDict *resp;
+ QDict *args;
+ QTestState *qts = qtest_init("-machine none");
+
+ args = qdict_new();
+ qdict_put_bool(args, "abstract", false);
+ qdict_put_str(args, "implements", parent_typename);
+
+ resp = qtest_qmp(qts, "{'execute': 'qom-list-types', 'arguments': %p }",
+ args);
+ g_assert(qdict_haskey(resp, "return"));
+ list = qdict_get_qlist(resp, "return");
+ qobject_ref(list);
+ qobject_unref(resp);
+
+ qtest_quit(qts);
+
+ if (cached_list) {
+ *cached_list = list;
+ }
+ }
+
+ for (p = qlist_first(list), idx = 0; p; p = qlist_next(p), idx++) {
+ devinfo = qobject_to(QDict, qlist_entry_obj(p));
+ g_assert(devinfo);
+
+ qobj = qdict_get(devinfo, "name");
+ g_assert(qobj);
+ qstr = qobject_to(QString, qobj);
+ g_assert(qstr);
+ if (g_str_equal(qstring_get_str(qstr), child_typename)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
bool qtest_has_accel(const char *accel_name)
{
- if (g_str_equal(accel_name, "tcg")) {
-#if defined(CONFIG_TCG)
- return true;
-#else
- return false;
-#endif
- } else if (g_str_equal(accel_name, "kvm")) {
+ static QList *list;
+ g_autofree char *accel_type = NULL;
+
+ if (g_str_equal(accel_name, "kvm")) {
int i;
const char *arch = qtest_get_arch();
const char *targets[] = { CONFIG_KVM_TARGETS };
@@ -1031,11 +1079,12 @@ bool qtest_has_accel(const char *accel_name)
}
}
}
- } else {
- /* not implemented */
- g_assert_not_reached();
+ return false;
}
- return false;
+
+ accel_type = g_strconcat(accel_name, ACCEL_CLASS_SUFFIX, NULL);
+
+ return qtest_qom_has_concrete_type("accel", accel_type, &list);
}
bool qtest_get_irq(QTestState *s, int num)
@@ -1790,45 +1839,8 @@ bool qtest_has_machine(const char *machine)
bool qtest_has_device(const char *device)
{
static QList *list;
- const QListEntry *p;
- QObject *qobj;
- QString *qstr;
- QDict *devinfo;
- int idx;
-
- if (!list) {
- QDict *resp;
- QDict *args;
- QTestState *qts = qtest_init("-machine none");
-
- args = qdict_new();
- qdict_put_bool(args, "abstract", false);
- qdict_put_str(args, "implements", "device");
-
- resp = qtest_qmp(qts, "{'execute': 'qom-list-types', 'arguments': %p }",
- args);
- g_assert(qdict_haskey(resp, "return"));
- list = qdict_get_qlist(resp, "return");
- qobject_ref(list);
- qobject_unref(resp);
-
- qtest_quit(qts);
- }
-
- for (p = qlist_first(list), idx = 0; p; p = qlist_next(p), idx++) {
- devinfo = qobject_to(QDict, qlist_entry_obj(p));
- g_assert(devinfo);
- qobj = qdict_get(devinfo, "name");
- g_assert(qobj);
- qstr = qobject_to(QString, qobj);
- g_assert(qstr);
- if (g_str_equal(qstring_get_str(qstr), device)) {
- return true;
- }
- }
-
- return false;
+ return qtest_qom_has_concrete_type("device", device, &list);
}
/*
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index e60e92f..5e062c7 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -57,6 +57,7 @@ qtests_i386 = \
(config_all_devices.has_key('CONFIG_AHCI_ICH9') ? ['tco-test'] : []) + \
(config_all_devices.has_key('CONFIG_FDC_ISA') ? ['fdc-test'] : []) + \
(config_all_devices.has_key('CONFIG_I440FX') ? ['fw_cfg-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_FW_CFG_DMA') ? ['vmcoreinfo-test'] : []) + \
(config_all_devices.has_key('CONFIG_I440FX') ? ['i440fx-test'] : []) + \
(config_all_devices.has_key('CONFIG_I440FX') ? ['ide-test'] : []) + \
(config_all_devices.has_key('CONFIG_I440FX') ? ['numa-test'] : []) + \
diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c
index 76d142a..bd977ef 100644
--- a/tests/qtest/vhost-user-test.c
+++ b/tests/qtest/vhost-user-test.c
@@ -1043,7 +1043,8 @@ static void test_multiqueue(void *obj, void *arg, QGuestAllocator *alloc)
static uint64_t vu_net_get_features(TestServer *s)
{
- uint64_t features = 0x1ULL << VHOST_F_LOG_ALL |
+ uint64_t features = 0x1ULL << VIRTIO_F_VERSION_1 |
+ 0x1ULL << VHOST_F_LOG_ALL |
0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES;
if (s->queues > 1) {
diff --git a/tests/qtest/vmcoreinfo-test.c b/tests/qtest/vmcoreinfo-test.c
new file mode 100644
index 0000000..dcf3b5a
--- /dev/null
+++ b/tests/qtest/vmcoreinfo-test.c
@@ -0,0 +1,90 @@
+/*
+ * qtest vmcoreinfo test case
+ *
+ * Copyright Red Hat. 2025.
+ *
+ * Authors:
+ * Ani Sinha <anisinha@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/units.h"
+#include "libqos/libqos-pc.h"
+#include "libqtest.h"
+#include "standard-headers/linux/qemu_fw_cfg.h"
+#include "libqos/fw_cfg.h"
+#include "qemu/bswap.h"
+#include "hw/misc/vmcoreinfo.h"
+
+static void test_vmcoreinfo_write_basic(void)
+{
+ QFWCFG *fw_cfg;
+ QOSState *qs;
+ FWCfgVMCoreInfo info;
+ size_t filesize;
+ uint16_t guest_format;
+ uint16_t host_format;
+ uint32_t size;
+ uint64_t paddr;
+
+ qs = qtest_pc_boot("-device vmcoreinfo");
+ fw_cfg = pc_fw_cfg_init(qs->qts);
+
+ memset(&info, 0 , sizeof(info));
+ /* read vmcoreinfo and read back the host format */
+ filesize = qfw_cfg_read_file(fw_cfg, qs, FW_CFG_VMCOREINFO_FILENAME,
+ &info, sizeof(info));
+ g_assert_cmpint(filesize, ==, sizeof(info));
+
+ host_format = le16_to_cpu(info.host_format);
+ g_assert_cmpint(host_format, ==, FW_CFG_VMCOREINFO_FORMAT_ELF);
+
+ memset(&info, 0 , sizeof(info));
+ info.guest_format = cpu_to_le16(FW_CFG_VMCOREINFO_FORMAT_ELF);
+ info.size = cpu_to_le32(1 * MiB);
+ info.paddr = cpu_to_le64(0xffffff00);
+ info.host_format = cpu_to_le16(host_format);
+
+ /* write the values to the host */
+ filesize = qfw_cfg_write_file(fw_cfg, qs, FW_CFG_VMCOREINFO_FILENAME,
+ &info, sizeof(info));
+ g_assert_cmpint(filesize, ==, sizeof(info));
+
+ memset(&info, 0 , sizeof(info));
+
+ /* now read back the values we wrote and compare that they are the same */
+ filesize = qfw_cfg_read_file(fw_cfg, qs, FW_CFG_VMCOREINFO_FILENAME,
+ &info, sizeof(info));
+ g_assert_cmpint(filesize, ==, sizeof(info));
+
+ size = le32_to_cpu(info.size);
+ paddr = le64_to_cpu(info.paddr);
+ guest_format = le16_to_cpu(info.guest_format);
+
+ g_assert_cmpint(size, ==, 1 * MiB);
+ g_assert_cmpint(paddr, ==, 0xffffff00);
+ g_assert_cmpint(guest_format, ==, FW_CFG_VMCOREINFO_FORMAT_ELF);
+
+ pc_fw_cfg_uninit(fw_cfg);
+ qtest_shutdown(qs);
+}
+
+int main(int argc, char **argv)
+{
+ const char *arch = qtest_get_arch();
+
+ g_test_init(&argc, &argv, NULL);
+
+ if (strcmp(arch, "i386") && strcmp(arch, "x86_64")) {
+ /* skip for non-x86 */
+ exit(EXIT_SUCCESS);
+ }
+
+ qtest_add_func("vmcoreinfo/basic-write",
+ test_vmcoreinfo_write_basic);
+
+ return g_test_run();
+}