* [PATCH v4 0/7] Add 'q35' machine type to hotplug tests
@ 2022-09-20 10:48 Michael Labiuk via
2022-09-20 10:48 ` [PATCH v4 1/7] tests/x86: Move common code to function in device-plug-test Michael Labiuk via
` (6 more replies)
0 siblings, 7 replies; 15+ messages in thread
From: Michael Labiuk via @ 2022-09-20 10:48 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini,
Dr . David Alan Gilbert, den
Add pci bridge setting to run hotplug tests on q35 machine type.
Hotplug tests was bounded to 'pc' machine type by commit 7b172333f1b
Changes from v3:
* Moving helper function process_device_remove() to separate commit.
* Refactoring hd-geo-test to avoid code duplication.
Michael Labiuk (7):
tests/x86: Move common code to function in device-plug-test
tests/x86: Add subtest with 'q35' machine type to device-plug-test
tests/x86: Add 'q35' machine type to ivshmem-test
tests/x86: Add 'q35' machine type to drive_del-test
tests/x86: Add 'q35' machine type to override-tests in hd-geo-test
tests/x86: Refactor hot unplug hd-geo-test
tests/x86: Add 'q35' machine type to hotplug hd-geo-test
tests/qtest/device-plug-test.c | 83 ++++++---
tests/qtest/drive_del-test.c | 111 ++++++++++++
tests/qtest/hd-geo-test.c | 318 ++++++++++++++++++++++++---------
tests/qtest/ivshmem-test.c | 30 ++++
4 files changed, 428 insertions(+), 114 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v4 1/7] tests/x86: Move common code to function in device-plug-test
2022-09-20 10:48 [PATCH v4 0/7] Add 'q35' machine type to hotplug tests Michael Labiuk via
@ 2022-09-20 10:48 ` Michael Labiuk via
2022-09-27 10:27 ` Thomas Huth
2022-09-20 10:48 ` [PATCH v4 2/7] tests/x86: Add subtest with 'q35' machine type to device-plug-test Michael Labiuk via
` (5 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Michael Labiuk via @ 2022-09-20 10:48 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini,
Dr . David Alan Gilbert, den
Move common code for device removing to function.
Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
---
tests/qtest/device-plug-test.c | 42 ++++++++++++++--------------------
1 file changed, 17 insertions(+), 25 deletions(-)
diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c
index a1fb99c8ff..e595b45b66 100644
--- a/tests/qtest/device-plug-test.c
+++ b/tests/qtest/device-plug-test.c
@@ -61,6 +61,18 @@ static void wait_device_deleted_event(QTestState *qtest, const char *id)
}
}
+static void process_device_remove(QTestState *qtest, const char *id)
+{
+ /*
+ * Request device removal. As the guest is not running, the request won't
+ * be processed. However during system reset, the removal will be
+ * handled, removing the device.
+ */
+ device_del(qtest, id);
+ system_reset(qtest);
+ wait_device_deleted_event(qtest, id);
+}
+
static void test_pci_unplug_request(void)
{
const char *arch = qtest_get_arch();
@@ -73,14 +85,7 @@ static void test_pci_unplug_request(void)
QTestState *qtest = qtest_initf("%s -device virtio-mouse-pci,id=dev0",
machine_addition);
- /*
- * Request device removal. As the guest is not running, the request won't
- * be processed. However during system reset, the removal will be
- * handled, removing the device.
- */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
@@ -98,14 +103,7 @@ static void test_pci_unplug_json_request(void)
"%s -device \"{'driver': 'virtio-mouse-pci', 'id': 'dev0'}\"",
machine_addition);
- /*
- * Request device removal. As the guest is not running, the request won't
- * be processed. However during system reset, the removal will be
- * handled, removing the device.
- */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
@@ -128,9 +126,7 @@ static void test_spapr_cpu_unplug_request(void)
"-device power9_v2.0-spapr-cpu-core,core-id=1,id=dev0");
/* similar to test_pci_unplug_request */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
@@ -144,9 +140,7 @@ static void test_spapr_memory_unplug_request(void)
"-device pc-dimm,id=dev0,memdev=mem0");
/* similar to test_pci_unplug_request */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
@@ -158,9 +152,7 @@ static void test_spapr_phb_unplug_request(void)
qtest = qtest_initf("-device spapr-pci-host-bridge,index=1,id=dev0");
/* similar to test_pci_unplug_request */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 2/7] tests/x86: Add subtest with 'q35' machine type to device-plug-test
2022-09-20 10:48 [PATCH v4 0/7] Add 'q35' machine type to hotplug tests Michael Labiuk via
2022-09-20 10:48 ` [PATCH v4 1/7] tests/x86: Move common code to function in device-plug-test Michael Labiuk via
@ 2022-09-20 10:48 ` Michael Labiuk via
2022-09-27 10:35 ` Thomas Huth
2022-09-27 10:40 ` Thomas Huth
2022-09-20 10:48 ` [PATCH v4 3/7] tests/x86: Add 'q35' machine type to ivshmem-test Michael Labiuk via
` (4 subsequent siblings)
6 siblings, 2 replies; 15+ messages in thread
From: Michael Labiuk via @ 2022-09-20 10:48 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini,
Dr . David Alan Gilbert, den
Configure pci bridge setting to plug pci device and unplug.
Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
---
tests/qtest/device-plug-test.c | 41 ++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c
index e595b45b66..d66c386ef4 100644
--- a/tests/qtest/device-plug-test.c
+++ b/tests/qtest/device-plug-test.c
@@ -90,6 +90,19 @@ static void test_pci_unplug_request(void)
qtest_quit(qtest);
}
+static void test_q35_pci_unplug_request(void)
+{
+
+ QTestState *qtest = qtest_initf("-machine q35 "
+ "-device pcie-root-port,id=p1 "
+ "-device pcie-pci-bridge,bus=p1,id=b1 "
+ "-device virtio-mouse-pci,bus=b1,id=dev0");
+
+ process_device_remove(qtest, "dev0");
+
+ qtest_quit(qtest);
+}
+
static void test_pci_unplug_json_request(void)
{
const char *arch = qtest_get_arch();
@@ -108,6 +121,27 @@ static void test_pci_unplug_json_request(void)
qtest_quit(qtest);
}
+static void test_q35_pci_unplug_json_request(void)
+{
+ const char *port = "-device '{\"driver\": \"pcie-root-port\", "
+ "\"id\": \"p1\"}'";
+
+ const char *bridge = "-device '{\"driver\": \"pcie-pci-bridge\", "
+ "\"id\": \"b1\", "
+ "\"bus\": \"p1\"}'";
+
+ const char *device = "-device '{\"driver\": \"virtio-mouse-pci\", "
+ "\"bus\": \"b1\", "
+ "\"id\": \"dev0\"}'";
+
+ QTestState *qtest = qtest_initf("-machine q35 %s %s %s",
+ port, bridge, device);
+
+ process_device_remove(qtest, "dev0");
+
+ qtest_quit(qtest);
+}
+
static void test_ccw_unplug(void)
{
QTestState *qtest = qtest_initf("-device virtio-balloon-ccw,id=dev0");
@@ -187,5 +221,12 @@ int main(int argc, char **argv)
test_spapr_phb_unplug_request);
}
+ if (!strcmp(arch, "x86_64")) {
+ qtest_add_func("/device-plug/q35-pci-unplug-request",
+ test_q35_pci_unplug_request);
+ qtest_add_func("/device-plug/q35-pci-unplug-json-request",
+ test_q35_pci_unplug_json_request);
+ }
+
return g_test_run();
}
--
2.34.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 3/7] tests/x86: Add 'q35' machine type to ivshmem-test
2022-09-20 10:48 [PATCH v4 0/7] Add 'q35' machine type to hotplug tests Michael Labiuk via
2022-09-20 10:48 ` [PATCH v4 1/7] tests/x86: Move common code to function in device-plug-test Michael Labiuk via
2022-09-20 10:48 ` [PATCH v4 2/7] tests/x86: Add subtest with 'q35' machine type to device-plug-test Michael Labiuk via
@ 2022-09-20 10:48 ` Michael Labiuk via
2022-09-27 10:57 ` Thomas Huth
2022-09-20 10:48 ` [PATCH v4 4/7] tests/x86: Add 'q35' machine type to drive_del-test Michael Labiuk via
` (3 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Michael Labiuk via @ 2022-09-20 10:48 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini,
Dr . David Alan Gilbert, den
Configure pci bridge setting to test ivshmem on 'q35'.
Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
---
tests/qtest/ivshmem-test.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/tests/qtest/ivshmem-test.c b/tests/qtest/ivshmem-test.c
index 9611d05eb5..0f9755abc6 100644
--- a/tests/qtest/ivshmem-test.c
+++ b/tests/qtest/ivshmem-test.c
@@ -378,6 +378,32 @@ static void test_ivshmem_server(void)
close(thread.pipe[0]);
}
+static void device_del(QTestState *qtest, const char *id)
+{
+ QDict *resp;
+
+ resp = qtest_qmp(qtest,
+ "{'execute': 'device_del',"
+ " 'arguments': { 'id': %s } }", id);
+
+ g_assert(qdict_haskey(resp, "return"));
+ qobject_unref(resp);
+}
+
+static void test_ivshmem_hotplug_q35(void)
+{
+ QTestState *qts = qtest_init("-object memory-backend-ram,size=1M,id=mb1 "
+ "-device pcie-root-port,id=p1 "
+ "-device pcie-pci-bridge,bus=p1,id=b1 "
+ "-machine q35");
+
+ qtest_qmp_device_add(qts, "ivshmem-plain", "iv1",
+ "{'memdev': 'mb1', 'bus': 'b1'}");
+ device_del(qts, "iv1");
+
+ qtest_quit(qts);
+}
+
#define PCI_SLOT_HP 0x06
static void test_ivshmem_hotplug(void)
@@ -469,6 +495,7 @@ int main(int argc, char **argv)
{
int ret, fd;
gchar dir[] = "/tmp/ivshmem-test.XXXXXX";
+ const char *arch = qtest_get_arch();
g_test_init(&argc, &argv, NULL);
@@ -494,6 +521,9 @@ int main(int argc, char **argv)
qtest_add_func("/ivshmem/pair", test_ivshmem_pair);
qtest_add_func("/ivshmem/server", test_ivshmem_server);
}
+ if (!strcmp(arch, "x86_64")) {
+ qtest_add_func("/ivshmem/hotplug-q35", test_ivshmem_hotplug_q35);
+ }
out:
ret = g_test_run();
--
2.34.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 4/7] tests/x86: Add 'q35' machine type to drive_del-test
2022-09-20 10:48 [PATCH v4 0/7] Add 'q35' machine type to hotplug tests Michael Labiuk via
` (2 preceding siblings ...)
2022-09-20 10:48 ` [PATCH v4 3/7] tests/x86: Add 'q35' machine type to ivshmem-test Michael Labiuk via
@ 2022-09-20 10:48 ` Michael Labiuk via
2022-09-27 12:29 ` Thomas Huth
2022-09-20 10:48 ` [PATCH v4 5/7] tests/x86: Add 'q35' machine type to override-tests in hd-geo-test Michael Labiuk via
` (2 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Michael Labiuk via @ 2022-09-20 10:48 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini,
Dr . David Alan Gilbert, den
Configure pci bridge setting to run tests on 'q35' machine type.
Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
---
tests/qtest/drive_del-test.c | 111 +++++++++++++++++++++++++++++++++++
1 file changed, 111 insertions(+)
diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c
index 5e6d58b4dd..3a2ddecf22 100644
--- a/tests/qtest/drive_del-test.c
+++ b/tests/qtest/drive_del-test.c
@@ -258,6 +258,27 @@ static void test_cli_device_del(void)
qtest_quit(qts);
}
+static void test_cli_device_del_q35(void)
+{
+ QTestState *qts;
+
+ /*
+ * -drive/-device and device_del. Start with a drive used by a
+ * device that unplugs after reset.
+ */
+ qts = qtest_initf("-drive if=none,id=drive0,file=null-co://,"
+ "file.read-zeroes=on,format=raw "
+ "-machine q35 -device pcie-root-port,id=p1 "
+ "-device pcie-pci-bridge,bus=p1,id=b1 "
+ "-device virtio-blk-%s,drive=drive0,bus=b1,id=dev0",
+ qvirtio_get_dev_type());
+
+ device_del(qts, true);
+ g_assert(!has_drive(qts));
+
+ qtest_quit(qts);
+}
+
static void test_empty_device_del(void)
{
QTestState *qts;
@@ -294,6 +315,45 @@ static void test_device_add_and_del(void)
qtest_quit(qts);
}
+static void device_add_q35(QTestState *qts)
+{
+ QDict *response;
+ char driver[32];
+ snprintf(driver, sizeof(driver), "virtio-blk-%s",
+ qvirtio_get_dev_type());
+
+ response = qtest_qmp(qts, "{'execute': 'device_add',"
+ " 'arguments': {"
+ " 'driver': %s,"
+ " 'drive': 'drive0',"
+ " 'id': 'dev0',"
+ " 'bus': 'b1'"
+ "}}", driver);
+ g_assert(response);
+ g_assert(qdict_haskey(response, "return"));
+ qobject_unref(response);
+}
+
+static void test_device_add_and_del_q35(void)
+{
+ QTestState *qts;
+
+ /*
+ * -drive/device_add and device_del. Start with a drive used by a
+ * device that unplugs after reset.
+ */
+ qts = qtest_initf("-machine q35 -device pcie-root-port,id=p1 "
+ "-device pcie-pci-bridge,bus=p1,id=b1 "
+ "-drive if=none,id=drive0,file=null-co://,"
+ "file.read-zeroes=on,format=raw");
+
+ device_add_q35(qts);
+ device_del(qts, true);
+ g_assert(!has_drive(qts));
+
+ qtest_quit(qts);
+}
+
static void test_drive_add_device_add_and_del(void)
{
QTestState *qts;
@@ -318,6 +378,25 @@ static void test_drive_add_device_add_and_del(void)
qtest_quit(qts);
}
+static void test_drive_add_device_add_and_del_q35(void)
+{
+ QTestState *qts;
+
+ qts = qtest_init("-machine q35 -device pcie-root-port,id=p1 "
+ "-device pcie-pci-bridge,bus=p1,id=b1");
+
+ /*
+ * drive_add/device_add and device_del. The drive is used by a
+ * device that unplugs after reset.
+ */
+ drive_add_with_media(qts);
+ device_add_q35(qts);
+ device_del(qts, true);
+ g_assert(!has_drive(qts));
+
+ qtest_quit(qts);
+}
+
static void test_blockdev_add_device_add_and_del(void)
{
QTestState *qts;
@@ -342,8 +421,29 @@ static void test_blockdev_add_device_add_and_del(void)
qtest_quit(qts);
}
+static void test_blockdev_add_device_add_and_del_q35(void)
+{
+ QTestState *qts;
+
+ qts = qtest_init("-machine q35 -device pcie-root-port,id=p1 "
+ "-device pcie-pci-bridge,bus=p1,id=b1");
+
+ /*
+ * blockdev_add/device_add and device_del. The it drive is used by a
+ * device that unplugs after reset, but it doesn't go away.
+ */
+ blockdev_add_with_media(qts);
+ device_add_q35(qts);
+ device_del(qts, true);
+ g_assert(has_blockdev(qts));
+
+ qtest_quit(qts);
+}
+
int main(int argc, char **argv)
{
+ const char *arch = qtest_get_arch();
+
g_test_init(&argc, &argv, NULL);
qtest_add_func("/drive_del/without-dev", test_drive_without_dev);
@@ -363,6 +463,17 @@ int main(int argc, char **argv)
test_empty_device_del);
qtest_add_func("/device_del/blockdev",
test_blockdev_add_device_add_and_del);
+
+ if (!strcmp(arch, "x86_64")) {
+ qtest_add_func("/device_del/drive/cli_device_q35",
+ test_cli_device_del_q35);
+ qtest_add_func("/device_del/drive/device_add_q35",
+ test_device_add_and_del_q35);
+ qtest_add_func("/device_del/drive/drive_add_device_add_q35",
+ test_drive_add_device_add_and_del_q35);
+ qtest_add_func("/device_del/blockdev_q35",
+ test_blockdev_add_device_add_and_del_q35);
+ }
}
return g_test_run();
--
2.34.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 5/7] tests/x86: Add 'q35' machine type to override-tests in hd-geo-test
2022-09-20 10:48 [PATCH v4 0/7] Add 'q35' machine type to hotplug tests Michael Labiuk via
` (3 preceding siblings ...)
2022-09-20 10:48 ` [PATCH v4 4/7] tests/x86: Add 'q35' machine type to drive_del-test Michael Labiuk via
@ 2022-09-20 10:48 ` Michael Labiuk via
2022-09-27 13:00 ` Thomas Huth
2022-09-20 10:48 ` [PATCH v4 6/7] tests/x86: Refactor hot unplug hd-geo-test Michael Labiuk via
2022-09-20 10:48 ` [PATCH v4 7/7] tests/x86: Add 'q35' machine type to hotplug hd-geo-test Michael Labiuk via
6 siblings, 1 reply; 15+ messages in thread
From: Michael Labiuk via @ 2022-09-20 10:48 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini,
Dr . David Alan Gilbert, den
Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
---
tests/qtest/hd-geo-test.c | 105 +++++++++++++++++++++++++++++++++++---
1 file changed, 98 insertions(+), 7 deletions(-)
diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c
index 413cf964c0..58b1107d64 100644
--- a/tests/qtest/hd-geo-test.c
+++ b/tests/qtest/hd-geo-test.c
@@ -693,7 +693,8 @@ static void add_virtio_disk(TestArgs *args,
args->n_virtio_disks++;
}
-static void test_override(TestArgs *args, CHSResult expected[])
+static void test_override(TestArgs *args, const char *arch,
+ CHSResult expected[])
{
QTestState *qts;
char *joined_args;
@@ -702,7 +703,7 @@ static void test_override(TestArgs *args, CHSResult expected[])
joined_args = g_strjoinv(" ", args->argv);
- qts = qtest_initf("-machine pc %s", joined_args);
+ qts = qtest_initf("-machine %s %s", arch, joined_args);
fw_cfg = pc_fw_cfg_init(qts);
read_bootdevices(fw_cfg, expected);
@@ -739,7 +740,28 @@ static void test_override_ide(void)
add_ide_disk(args, 1, 0, 1, 9000, 120, 30);
add_ide_disk(args, 2, 1, 0, 0, 1, 1);
add_ide_disk(args, 3, 1, 1, 1, 0, 0);
- test_override(args, expected);
+ test_override(args, "pc", expected);
+}
+
+static void test_override_sata(void)
+{
+ TestArgs *args = create_args();
+ CHSResult expected[] = {
+ {"/pci@i0cf8/pci8086,2922@1f,2/drive@0/disk@0", {10000, 120, 30} },
+ {"/pci@i0cf8/pci8086,2922@1f,2/drive@1/disk@0", {9000, 120, 30} },
+ {"/pci@i0cf8/pci8086,2922@1f,2/drive@2/disk@0", {0, 1, 1} },
+ {"/pci@i0cf8/pci8086,2922@1f,2/drive@3/disk@0", {1, 0, 0} },
+ {NULL, {0, 0, 0} }
+ };
+ add_drive_with_mbr(args, empty_mbr, 1);
+ add_drive_with_mbr(args, empty_mbr, 1);
+ add_drive_with_mbr(args, empty_mbr, 1);
+ add_drive_with_mbr(args, empty_mbr, 1);
+ add_ide_disk(args, 0, 0, 0, 10000, 120, 30);
+ add_ide_disk(args, 1, 1, 0, 9000, 120, 30);
+ add_ide_disk(args, 2, 2, 0, 0, 1, 1);
+ add_ide_disk(args, 3, 3, 0, 1, 0, 0);
+ test_override(args, "q35", expected);
}
static void test_override_scsi(void)
@@ -761,7 +783,43 @@ static void test_override_scsi(void)
add_scsi_disk(args, 1, 0, 0, 1, 0, 9000, 120, 30);
add_scsi_disk(args, 2, 0, 0, 2, 0, 1, 0, 0);
add_scsi_disk(args, 3, 0, 0, 3, 0, 0, 1, 0);
- test_override(args, expected);
+ test_override(args, "pc", expected);
+}
+
+static void setup_pci_bridge(TestArgs *args, const char *id, const char *rootid)
+{
+
+ char *root, *br;
+ root = g_strdup_printf("-device pcie-root-port,id=%s", rootid);
+ br = g_strdup_printf("-device pcie-pci-bridge,bus=%s,id=%s", rootid, id);
+
+ args->argc = append_arg(args->argc, args->argv, ARGV_SIZE, root);
+ args->argc = append_arg(args->argc, args->argv, ARGV_SIZE, br);
+}
+
+static void test_override_scsi_q35(void)
+{
+ TestArgs *args = create_args();
+ CHSResult expected[] = {
+ { "/pci@i0cf8/pci-bridge@1/scsi@3/channel@0/disk@0,0",
+ {10000, 120, 30}
+ },
+ {"/pci@i0cf8/pci-bridge@1/scsi@3/channel@0/disk@1,0", {9000, 120, 30} },
+ {"/pci@i0cf8/pci-bridge@1/scsi@3/channel@0/disk@2,0", {1, 0, 0} },
+ {"/pci@i0cf8/pci-bridge@1/scsi@3/channel@0/disk@3,0", {0, 1, 0} },
+ {NULL, {0, 0, 0} }
+ };
+ add_drive_with_mbr(args, empty_mbr, 1);
+ add_drive_with_mbr(args, empty_mbr, 1);
+ add_drive_with_mbr(args, empty_mbr, 1);
+ add_drive_with_mbr(args, empty_mbr, 1);
+ setup_pci_bridge(args, "pcie.0", "br");
+ add_scsi_controller(args, "lsi53c895a", "br", 3);
+ add_scsi_disk(args, 0, 0, 0, 0, 0, 10000, 120, 30);
+ add_scsi_disk(args, 1, 0, 0, 1, 0, 9000, 120, 30);
+ add_scsi_disk(args, 2, 0, 0, 2, 0, 1, 0, 0);
+ add_scsi_disk(args, 3, 0, 0, 3, 0, 0, 1, 0);
+ test_override(args, "q35", expected);
}
static void test_override_scsi_2_controllers(void)
@@ -784,7 +842,7 @@ static void test_override_scsi_2_controllers(void)
add_scsi_disk(args, 1, 0, 0, 1, 0, 9000, 120, 30);
add_scsi_disk(args, 2, 1, 0, 0, 1, 1, 0, 0);
add_scsi_disk(args, 3, 1, 0, 1, 2, 0, 1, 0);
- test_override(args, expected);
+ test_override(args, "pc", expected);
}
static void test_override_virtio_blk(void)
@@ -799,7 +857,23 @@ static void test_override_virtio_blk(void)
add_drive_with_mbr(args, empty_mbr, 1);
add_virtio_disk(args, 0, "pci.0", 3, 10000, 120, 30);
add_virtio_disk(args, 1, "pci.0", 4, 9000, 120, 30);
- test_override(args, expected);
+ test_override(args, "pc", expected);
+}
+
+static void test_override_virtio_blk_q35(void)
+{
+ TestArgs *args = create_args();
+ CHSResult expected[] = {
+ {"/pci@i0cf8/pci-bridge@2/scsi@3/disk@0,0", {10000, 120, 30} },
+ {"/pci@i0cf8/pci-bridge@2/scsi@4/disk@0,0", {9000, 120, 30} },
+ {NULL, {0, 0, 0} }
+ };
+ add_drive_with_mbr(args, empty_mbr, 1);
+ add_drive_with_mbr(args, empty_mbr, 1);
+ setup_pci_bridge(args, "pcie.0", "br");
+ add_virtio_disk(args, 0, "br", 3, 10000, 120, 30);
+ add_virtio_disk(args, 1, "br", 4, 9000, 120, 30);
+ test_override(args, "pc", expected);
}
static void test_override_zero_chs(void)
@@ -810,7 +884,18 @@ static void test_override_zero_chs(void)
};
add_drive_with_mbr(args, empty_mbr, 1);
add_ide_disk(args, 0, 1, 1, 0, 0, 0);
- test_override(args, expected);
+ test_override(args, "pc", expected);
+}
+
+static void test_override_zero_chs_q35(void)
+{
+ TestArgs *args = create_args();
+ CHSResult expected[] = {
+ {NULL, {0, 0, 0} }
+ };
+ add_drive_with_mbr(args, empty_mbr, 1);
+ add_ide_disk(args, 0, 0, 0, 0, 0, 0);
+ test_override(args, "q35", expected);
}
static void test_override_scsi_hot_unplug(void)
@@ -965,13 +1050,19 @@ int main(int argc, char **argv)
qtest_add_func("hd-geo/ide/device/user/chst", test_ide_device_user_chst);
if (have_qemu_img()) {
qtest_add_func("hd-geo/override/ide", test_override_ide);
+ qtest_add_func("hd-geo/override/sata", test_override_sata);
if (qtest_has_device("lsi53c895a")) {
qtest_add_func("hd-geo/override/scsi", test_override_scsi);
+ qtest_add_func("hd-geo/override/scsiq35", test_override_scsi_q35);
qtest_add_func("hd-geo/override/scsi_2_controllers",
test_override_scsi_2_controllers);
}
qtest_add_func("hd-geo/override/virtio_blk", test_override_virtio_blk);
+ qtest_add_func("hd-geo/override/virtio_blk_q35",
+ test_override_virtio_blk_q35);
qtest_add_func("hd-geo/override/zero_chs", test_override_zero_chs);
+ qtest_add_func("hd-geo/override/zero_chs_q35",
+ test_override_zero_chs_q35);
qtest_add_func("hd-geo/override/scsi_hot_unplug",
test_override_scsi_hot_unplug);
qtest_add_func("hd-geo/override/virtio_hot_unplug",
--
2.34.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 6/7] tests/x86: Refactor hot unplug hd-geo-test
2022-09-20 10:48 [PATCH v4 0/7] Add 'q35' machine type to hotplug tests Michael Labiuk via
` (4 preceding siblings ...)
2022-09-20 10:48 ` [PATCH v4 5/7] tests/x86: Add 'q35' machine type to override-tests in hd-geo-test Michael Labiuk via
@ 2022-09-20 10:48 ` Michael Labiuk via
2022-09-20 10:48 ` [PATCH v4 7/7] tests/x86: Add 'q35' machine type to hotplug hd-geo-test Michael Labiuk via
6 siblings, 0 replies; 15+ messages in thread
From: Michael Labiuk via @ 2022-09-20 10:48 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini,
Dr . David Alan Gilbert, den
Moving common code to function.
Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
---
tests/qtest/hd-geo-test.c | 133 +++++++++++++++-----------------------
1 file changed, 53 insertions(+), 80 deletions(-)
diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c
index 58b1107d64..d488ad9ac0 100644
--- a/tests/qtest/hd-geo-test.c
+++ b/tests/qtest/hd-geo-test.c
@@ -898,13 +898,55 @@ static void test_override_zero_chs_q35(void)
test_override(args, "q35", expected);
}
+static void test_override_hot_unplug(TestArgs *args, const char *devid,
+ CHSResult expected[], CHSResult expected2[])
+{
+ QTestState *qts;
+ char *joined_args;
+ QFWCFG *fw_cfg;
+ QDict *response;
+ int i;
+
+ joined_args = g_strjoinv(" ", args->argv);
+
+ qts = qtest_initf("%s", joined_args);
+ fw_cfg = pc_fw_cfg_init(qts);
+
+ read_bootdevices(fw_cfg, expected);
+
+ /* unplug device an restart */
+ response = qtest_qmp(qts,
+ "{ 'execute': 'device_del',"
+ " 'arguments': {'id': %s }}", devid);
+ g_assert(response);
+ g_assert(!qdict_haskey(response, "error"));
+ qobject_unref(response);
+ response = qtest_qmp(qts,
+ "{ 'execute': 'system_reset', 'arguments': { }}");
+ g_assert(response);
+ g_assert(!qdict_haskey(response, "error"));
+ qobject_unref(response);
+
+ qtest_qmp_eventwait(qts, "RESET");
+
+ read_bootdevices(fw_cfg, expected2);
+
+ g_free(joined_args);
+ qtest_quit(qts);
+
+ g_free(fw_cfg);
+
+ for (i = 0; i < args->n_drives; i++) {
+ unlink(args->drives[i]);
+ free(args->drives[i]);
+ }
+ g_free(args->drives);
+ g_strfreev(args->argv);
+ g_free(args);
+}
+
static void test_override_scsi_hot_unplug(void)
{
- QTestState *qts;
- char *joined_args;
- QFWCFG *fw_cfg;
- QDict *response;
- int i;
TestArgs *args = create_args();
CHSResult expected[] = {
{"/pci@i0cf8/scsi@2/channel@0/disk@0,0", {10000, 120, 30} },
@@ -921,51 +963,14 @@ static void test_override_scsi_hot_unplug(void)
add_scsi_disk(args, 0, 0, 0, 0, 0, 10000, 120, 30);
add_scsi_disk(args, 1, 0, 0, 1, 0, 20, 20, 20);
- joined_args = g_strjoinv(" ", args->argv);
+ args->argc = append_arg(args->argc, args->argv, ARGV_SIZE,
+ g_strdup("-machine pc"));
- qts = qtest_initf("-machine pc %s", joined_args);
- fw_cfg = pc_fw_cfg_init(qts);
-
- read_bootdevices(fw_cfg, expected);
-
- /* unplug device an restart */
- response = qtest_qmp(qts,
- "{ 'execute': 'device_del',"
- " 'arguments': {'id': 'scsi-disk0' }}");
- g_assert(response);
- g_assert(!qdict_haskey(response, "error"));
- qobject_unref(response);
- response = qtest_qmp(qts,
- "{ 'execute': 'system_reset', 'arguments': { }}");
- g_assert(response);
- g_assert(!qdict_haskey(response, "error"));
- qobject_unref(response);
-
- qtest_qmp_eventwait(qts, "RESET");
-
- read_bootdevices(fw_cfg, expected2);
-
- g_free(joined_args);
- qtest_quit(qts);
-
- g_free(fw_cfg);
-
- for (i = 0; i < args->n_drives; i++) {
- unlink(args->drives[i]);
- free(args->drives[i]);
- }
- g_free(args->drives);
- g_strfreev(args->argv);
- g_free(args);
+ test_override_hot_unplug(args, "scsi-disk0", expected, expected2);
}
static void test_override_virtio_hot_unplug(void)
{
- QTestState *qts;
- char *joined_args;
- QFWCFG *fw_cfg;
- QDict *response;
- int i;
TestArgs *args = create_args();
CHSResult expected[] = {
{"/pci@i0cf8/scsi@2/disk@0,0", {10000, 120, 30} },
@@ -981,42 +986,10 @@ static void test_override_virtio_hot_unplug(void)
add_virtio_disk(args, 0, "pci.0", 2, 10000, 120, 30);
add_virtio_disk(args, 1, "pci.0", 3, 20, 20, 20);
- joined_args = g_strjoinv(" ", args->argv);
+ args->argc = append_arg(args->argc, args->argv, ARGV_SIZE,
+ g_strdup("-machine pc"));
- qts = qtest_initf("-machine pc %s", joined_args);
- fw_cfg = pc_fw_cfg_init(qts);
-
- read_bootdevices(fw_cfg, expected);
-
- /* unplug device an restart */
- response = qtest_qmp(qts,
- "{ 'execute': 'device_del',"
- " 'arguments': {'id': 'virtio-disk0' }}");
- g_assert(response);
- g_assert(!qdict_haskey(response, "error"));
- qobject_unref(response);
- response = qtest_qmp(qts,
- "{ 'execute': 'system_reset', 'arguments': { }}");
- g_assert(response);
- g_assert(!qdict_haskey(response, "error"));
- qobject_unref(response);
-
- qtest_qmp_eventwait(qts, "RESET");
-
- read_bootdevices(fw_cfg, expected2);
-
- g_free(joined_args);
- qtest_quit(qts);
-
- g_free(fw_cfg);
-
- for (i = 0; i < args->n_drives; i++) {
- unlink(args->drives[i]);
- free(args->drives[i]);
- }
- g_free(args->drives);
- g_strfreev(args->argv);
- g_free(args);
+ test_override_hot_unplug(args, "virtio-disk0", expected, expected2);
}
int main(int argc, char **argv)
--
2.34.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 7/7] tests/x86: Add 'q35' machine type to hotplug hd-geo-test
2022-09-20 10:48 [PATCH v4 0/7] Add 'q35' machine type to hotplug tests Michael Labiuk via
` (5 preceding siblings ...)
2022-09-20 10:48 ` [PATCH v4 6/7] tests/x86: Refactor hot unplug hd-geo-test Michael Labiuk via
@ 2022-09-20 10:48 ` Michael Labiuk via
6 siblings, 0 replies; 15+ messages in thread
From: Michael Labiuk via @ 2022-09-20 10:48 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini,
Dr . David Alan Gilbert, den
Add pci bridge setting to test hotplug.
Duplicate tests for plugging scsi and virtio devices for q35 machine type.
Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
---
tests/qtest/hd-geo-test.c | 76 +++++++++++++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c
index d488ad9ac0..ada80d8828 100644
--- a/tests/qtest/hd-geo-test.c
+++ b/tests/qtest/hd-geo-test.c
@@ -969,6 +969,42 @@ static void test_override_scsi_hot_unplug(void)
test_override_hot_unplug(args, "scsi-disk0", expected, expected2);
}
+static void test_override_scsi_hot_unplug_q35(void)
+{
+ TestArgs *args = create_args();
+ CHSResult expected[] = {
+ {
+ "/pci@i0cf8/pci-bridge@1/pci-bridge@0/scsi@2/channel@0/disk@0,0",
+ {10000, 120, 30}
+ },
+ {
+ "/pci@i0cf8/pci-bridge@1/pci-bridge@0/scsi@2/channel@0/disk@1,0",
+ {20, 20, 20}
+ },
+ {NULL, {0, 0, 0} }
+ };
+ CHSResult expected2[] = {
+ {
+ "/pci@i0cf8/pci-bridge@1/pci-bridge@0/scsi@2/channel@0/disk@1,0",
+ {20, 20, 20}
+ },
+ {NULL, {0, 0, 0} }
+ };
+
+ args->argc = append_arg(args->argc, args->argv, ARGV_SIZE,
+ g_strdup("-device pcie-root-port,id=p0 "
+ "-device pcie-pci-bridge,bus=p0,id=b1 "
+ "-machine q35"));
+
+ add_drive_with_mbr(args, empty_mbr, 1);
+ add_drive_with_mbr(args, empty_mbr, 1);
+ add_scsi_controller(args, "virtio-scsi-pci", "b1", 2);
+ add_scsi_disk(args, 0, 0, 0, 0, 0, 10000, 120, 30);
+ add_scsi_disk(args, 1, 0, 0, 1, 0, 20, 20, 20);
+
+ test_override_hot_unplug(args, "scsi-disk0", expected, expected2);
+}
+
static void test_override_virtio_hot_unplug(void)
{
TestArgs *args = create_args();
@@ -992,6 +1028,41 @@ static void test_override_virtio_hot_unplug(void)
test_override_hot_unplug(args, "virtio-disk0", expected, expected2);
}
+static void test_override_virtio_hot_unplug_q35(void)
+{
+ TestArgs *args = create_args();
+ CHSResult expected[] = {
+ {
+ "/pci@i0cf8/pci-bridge@1/pci-bridge@0/scsi@2/disk@0,0",
+ {10000, 120, 30}
+ },
+ {
+ "/pci@i0cf8/pci-bridge@1/pci-bridge@0/scsi@3/disk@0,0",
+ {20, 20, 20}
+ },
+ {NULL, {0, 0, 0} }
+ };
+ CHSResult expected2[] = {
+ {
+ "/pci@i0cf8/pci-bridge@1/pci-bridge@0/scsi@3/disk@0,0",
+ {20, 20, 20}
+ },
+ {NULL, {0, 0, 0} }
+ };
+
+ args->argc = append_arg(args->argc, args->argv, ARGV_SIZE,
+ g_strdup("-device pcie-root-port,id=p0 "
+ "-device pcie-pci-bridge,bus=p0,id=b1 "
+ "-machine q35"));
+
+ add_drive_with_mbr(args, empty_mbr, 1);
+ add_drive_with_mbr(args, empty_mbr, 1);
+ add_virtio_disk(args, 0, "b1", 2, 10000, 120, 30);
+ add_virtio_disk(args, 1, "b1", 3, 20, 20, 20);
+
+ test_override_hot_unplug(args, "virtio-disk0", expected, expected2);
+}
+
int main(int argc, char **argv)
{
Backend i;
@@ -1038,8 +1109,13 @@ int main(int argc, char **argv)
test_override_zero_chs_q35);
qtest_add_func("hd-geo/override/scsi_hot_unplug",
test_override_scsi_hot_unplug);
+ qtest_add_func("hd-geo/override/scsi_hot_unplug_q35",
+ test_override_scsi_hot_unplug_q35);
qtest_add_func("hd-geo/override/virtio_hot_unplug",
test_override_virtio_hot_unplug);
+ qtest_add_func("hd-geo/override/virtio_hot_unplug_q35",
+ test_override_virtio_hot_unplug_q35);
+
} else {
g_test_message("QTEST_QEMU_IMG not set or qemu-img missing; "
"skipping hd-geo/override/* tests");
--
2.34.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v4 1/7] tests/x86: Move common code to function in device-plug-test
2022-09-20 10:48 ` [PATCH v4 1/7] tests/x86: Move common code to function in device-plug-test Michael Labiuk via
@ 2022-09-27 10:27 ` Thomas Huth
0 siblings, 0 replies; 15+ messages in thread
From: Thomas Huth @ 2022-09-27 10:27 UTC (permalink / raw)
To: Michael Labiuk, qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Dr . David Alan Gilbert, den
On 20/09/2022 12.48, Michael Labiuk wrote:
> Move common code for device removing to function.
>
> Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
> ---
> tests/qtest/device-plug-test.c | 42 ++++++++++++++--------------------
> 1 file changed, 17 insertions(+), 25 deletions(-)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 2/7] tests/x86: Add subtest with 'q35' machine type to device-plug-test
2022-09-20 10:48 ` [PATCH v4 2/7] tests/x86: Add subtest with 'q35' machine type to device-plug-test Michael Labiuk via
@ 2022-09-27 10:35 ` Thomas Huth
2022-09-27 10:40 ` Thomas Huth
1 sibling, 0 replies; 15+ messages in thread
From: Thomas Huth @ 2022-09-27 10:35 UTC (permalink / raw)
To: Michael Labiuk, qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Dr . David Alan Gilbert, den
On 20/09/2022 12.48, Michael Labiuk wrote:
> Configure pci bridge setting to plug pci device and unplug.
>
> Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
> ---
> tests/qtest/device-plug-test.c | 41 ++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 2/7] tests/x86: Add subtest with 'q35' machine type to device-plug-test
2022-09-20 10:48 ` [PATCH v4 2/7] tests/x86: Add subtest with 'q35' machine type to device-plug-test Michael Labiuk via
2022-09-27 10:35 ` Thomas Huth
@ 2022-09-27 10:40 ` Thomas Huth
1 sibling, 0 replies; 15+ messages in thread
From: Thomas Huth @ 2022-09-27 10:40 UTC (permalink / raw)
To: Michael Labiuk, qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Dr . David Alan Gilbert, den,
Juan Quintela
On 20/09/2022 12.48, Michael Labiuk wrote:
> Configure pci bridge setting to plug pci device and unplug.
>
> Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
> ---
> tests/qtest/device-plug-test.c | 41 ++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c
> index e595b45b66..d66c386ef4 100644
> --- a/tests/qtest/device-plug-test.c
> +++ b/tests/qtest/device-plug-test.c
> @@ -90,6 +90,19 @@ static void test_pci_unplug_request(void)
> qtest_quit(qtest);
> }
>
> +static void test_q35_pci_unplug_request(void)
> +{
> +
> + QTestState *qtest = qtest_initf("-machine q35 "
> + "-device pcie-root-port,id=p1 "
> + "-device pcie-pci-bridge,bus=p1,id=b1 "
> + "-device virtio-mouse-pci,bus=b1,id=dev0");
> +
> + process_device_remove(qtest, "dev0");
> +
> + qtest_quit(qtest);
> +}
> +
> static void test_pci_unplug_json_request(void)
> {
> const char *arch = qtest_get_arch();
> @@ -108,6 +121,27 @@ static void test_pci_unplug_json_request(void)
> qtest_quit(qtest);
> }
>
> +static void test_q35_pci_unplug_json_request(void)
> +{
> + const char *port = "-device '{\"driver\": \"pcie-root-port\", "
> + "\"id\": \"p1\"}'";
> +
> + const char *bridge = "-device '{\"driver\": \"pcie-pci-bridge\", "
> + "\"id\": \"b1\", "
> + "\"bus\": \"p1\"}'";
> +
> + const char *device = "-device '{\"driver\": \"virtio-mouse-pci\", "
> + "\"bus\": \"b1\", "
> + "\"id\": \"dev0\"}'";
> +
> + QTestState *qtest = qtest_initf("-machine q35 %s %s %s",
> + port, bridge, device);
> +
> + process_device_remove(qtest, "dev0");
> +
> + qtest_quit(qtest);
> +}
> +
> static void test_ccw_unplug(void)
> {
> QTestState *qtest = qtest_initf("-device virtio-balloon-ccw,id=dev0");
> @@ -187,5 +221,12 @@ int main(int argc, char **argv)
> test_spapr_phb_unplug_request);
> }
>
> + if (!strcmp(arch, "x86_64")) {
We should maybe also add a qtest_has_machine("q35") after the strcmp here
(there have recently been some efforts to make the qtests also run right if
one of the x86 machines has been disabled in the build)
Thomas
> + qtest_add_func("/device-plug/q35-pci-unplug-request",
> + test_q35_pci_unplug_request);
> + qtest_add_func("/device-plug/q35-pci-unplug-json-request",
> + test_q35_pci_unplug_json_request);
> + }
> +
> return g_test_run();
> }
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 3/7] tests/x86: Add 'q35' machine type to ivshmem-test
2022-09-20 10:48 ` [PATCH v4 3/7] tests/x86: Add 'q35' machine type to ivshmem-test Michael Labiuk via
@ 2022-09-27 10:57 ` Thomas Huth
0 siblings, 0 replies; 15+ messages in thread
From: Thomas Huth @ 2022-09-27 10:57 UTC (permalink / raw)
To: Michael Labiuk, qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Dr . David Alan Gilbert, den
On 20/09/2022 12.48, Michael Labiuk wrote:
> Configure pci bridge setting to test ivshmem on 'q35'.
>
> Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
> ---
> tests/qtest/ivshmem-test.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/tests/qtest/ivshmem-test.c b/tests/qtest/ivshmem-test.c
> index 9611d05eb5..0f9755abc6 100644
> --- a/tests/qtest/ivshmem-test.c
> +++ b/tests/qtest/ivshmem-test.c
> @@ -378,6 +378,32 @@ static void test_ivshmem_server(void)
> close(thread.pipe[0]);
> }
>
> +static void device_del(QTestState *qtest, const char *id)
> +{
> + QDict *resp;
> +
> + resp = qtest_qmp(qtest,
> + "{'execute': 'device_del',"
> + " 'arguments': { 'id': %s } }", id);
> +
> + g_assert(qdict_haskey(resp, "return"));
> + qobject_unref(resp);
> +}
Uh, this made me realize that we have lots of similar, yet quite different
device_del functions around in the qtests... could we maybe unify them a
little bit?
What about if you add your function above as qtest_qmp_device_del_nowait()
in libqtest.c (in a separate patch) and change qtest_qmp_device_del() to
call your new function before doing the qtest_qmp_eventwait() ?
A similar change could then be done to qpci_unplug_acpi_device_test() in
tests/qtest/libqos/pci-pc.c and to device_del() in
tests/qtest/drive_del-test.c ... ?
> +static void test_ivshmem_hotplug_q35(void)
> +{
> + QTestState *qts = qtest_init("-object memory-backend-ram,size=1M,id=mb1 "
> + "-device pcie-root-port,id=p1 "
> + "-device pcie-pci-bridge,bus=p1,id=b1 "
> + "-machine q35");
> +
> + qtest_qmp_device_add(qts, "ivshmem-plain", "iv1",
> + "{'memdev': 'mb1', 'bus': 'b1'}");
> + device_del(qts, "iv1");
> +
> + qtest_quit(qts);
> +}
> +
> #define PCI_SLOT_HP 0x06
>
> static void test_ivshmem_hotplug(void)
> @@ -469,6 +495,7 @@ int main(int argc, char **argv)
> {
> int ret, fd;
> gchar dir[] = "/tmp/ivshmem-test.XXXXXX";
> + const char *arch = qtest_get_arch();
>
> g_test_init(&argc, &argv, NULL);
>
> @@ -494,6 +521,9 @@ int main(int argc, char **argv)
> qtest_add_func("/ivshmem/pair", test_ivshmem_pair);
> qtest_add_func("/ivshmem/server", test_ivshmem_server);
> }
> + if (!strcmp(arch, "x86_64")) {
I'd suggest to use qtest_has_machine("q35") instead.
> + qtest_add_func("/ivshmem/hotplug-q35", test_ivshmem_hotplug_q35);
> + }
>
> out:
> ret = g_test_run();
Thomas
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 4/7] tests/x86: Add 'q35' machine type to drive_del-test
2022-09-20 10:48 ` [PATCH v4 4/7] tests/x86: Add 'q35' machine type to drive_del-test Michael Labiuk via
@ 2022-09-27 12:29 ` Thomas Huth
0 siblings, 0 replies; 15+ messages in thread
From: Thomas Huth @ 2022-09-27 12:29 UTC (permalink / raw)
To: Michael Labiuk, qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Dr . David Alan Gilbert, den
On 20/09/2022 12.48, Michael Labiuk wrote:
> Configure pci bridge setting to run tests on 'q35' machine type.
>
> Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
> ---
> tests/qtest/drive_del-test.c | 111 +++++++++++++++++++++++++++++++++++
> 1 file changed, 111 insertions(+)
>
> diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c
> index 5e6d58b4dd..3a2ddecf22 100644
> --- a/tests/qtest/drive_del-test.c
> +++ b/tests/qtest/drive_del-test.c
...
> @@ -294,6 +315,45 @@ static void test_device_add_and_del(void)
> qtest_quit(qts);
> }
>
> +static void device_add_q35(QTestState *qts)
> +{
> + QDict *response;
> + char driver[32];
> + snprintf(driver, sizeof(driver), "virtio-blk-%s",
> + qvirtio_get_dev_type());
array + snprintf is somewhat ugly, could you please either use
g_autofree char *driver = g_strdup_printf(...)
instead or ...
> + response = qtest_qmp(qts, "{'execute': 'device_add',"
> + " 'arguments': {"
> + " 'driver': %s,"
... simply use " 'driver': vrtio-blk-%s, " here?
> + " 'drive': 'drive0',"
> + " 'id': 'dev0',"
> + " 'bus': 'b1'"
> + "}}", driver);
> + g_assert(response);
> + g_assert(qdict_haskey(response, "return"));
> + qobject_unref(response);
> +}
...
> @@ -342,8 +421,29 @@ static void test_blockdev_add_device_add_and_del(void)
> qtest_quit(qts);
> }
>
> +static void test_blockdev_add_device_add_and_del_q35(void)
> +{
> + QTestState *qts;
> +
> + qts = qtest_init("-machine q35 -device pcie-root-port,id=p1 "
> + "-device pcie-pci-bridge,bus=p1,id=b1");
> +
> + /*
> + * blockdev_add/device_add and device_del. The it drive is used by a
s/The it drive/The drive/
> + * device that unplugs after reset, but it doesn't go away.
> + */
> + blockdev_add_with_media(qts);
> + device_add_q35(qts);
> + device_del(qts, true);
> + g_assert(has_blockdev(qts));
> +
> + qtest_quit(qts);
> +}
> +
> int main(int argc, char **argv)
> {
> + const char *arch = qtest_get_arch();
> +
> g_test_init(&argc, &argv, NULL);
>
> qtest_add_func("/drive_del/without-dev", test_drive_without_dev);
> @@ -363,6 +463,17 @@ int main(int argc, char **argv)
> test_empty_device_del);
> qtest_add_func("/device_del/blockdev",
> test_blockdev_add_device_add_and_del);
> +
> + if (!strcmp(arch, "x86_64")) {
Please use qtest_has_machine("q35") instead again.
> + qtest_add_func("/device_del/drive/cli_device_q35",
> + test_cli_device_del_q35);
> + qtest_add_func("/device_del/drive/device_add_q35",
> + test_device_add_and_del_q35);
> + qtest_add_func("/device_del/drive/drive_add_device_add_q35",
> + test_drive_add_device_add_and_del_q35);
> + qtest_add_func("/device_del/blockdev_q35",
> + test_blockdev_add_device_add_and_del_q35);
> + }
> }
>
> return g_test_run();
Thomas
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 5/7] tests/x86: Add 'q35' machine type to override-tests in hd-geo-test
2022-09-20 10:48 ` [PATCH v4 5/7] tests/x86: Add 'q35' machine type to override-tests in hd-geo-test Michael Labiuk via
@ 2022-09-27 13:00 ` Thomas Huth
2022-09-28 8:37 ` Michael Labiuk
0 siblings, 1 reply; 15+ messages in thread
From: Thomas Huth @ 2022-09-27 13:00 UTC (permalink / raw)
To: Michael Labiuk, qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Dr . David Alan Gilbert, den
On 20/09/2022 12.48, Michael Labiuk wrote:
> Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
> ---
> tests/qtest/hd-geo-test.c | 105 +++++++++++++++++++++++++++++++++++---
> 1 file changed, 98 insertions(+), 7 deletions(-)
>
> diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c
> index 413cf964c0..58b1107d64 100644
> --- a/tests/qtest/hd-geo-test.c
> +++ b/tests/qtest/hd-geo-test.c
...
> @@ -799,7 +857,23 @@ static void test_override_virtio_blk(void)
> add_drive_with_mbr(args, empty_mbr, 1);
> add_virtio_disk(args, 0, "pci.0", 3, 10000, 120, 30);
> add_virtio_disk(args, 1, "pci.0", 4, 9000, 120, 30);
> - test_override(args, expected);
> + test_override(args, "pc", expected);
> +}
> +
> +static void test_override_virtio_blk_q35(void)
> +{
> + TestArgs *args = create_args();
> + CHSResult expected[] = {
> + {"/pci@i0cf8/pci-bridge@2/scsi@3/disk@0,0", {10000, 120, 30} },
> + {"/pci@i0cf8/pci-bridge@2/scsi@4/disk@0,0", {9000, 120, 30} },
> + {NULL, {0, 0, 0} }
> + };
> + add_drive_with_mbr(args, empty_mbr, 1);
> + add_drive_with_mbr(args, empty_mbr, 1);
> + setup_pci_bridge(args, "pcie.0", "br");
> + add_virtio_disk(args, 0, "br", 3, 10000, 120, 30);
> + add_virtio_disk(args, 1, "br", 4, 9000, 120, 30);
> + test_override(args, "pc", expected);
Shouldn't that use "q35" as machine instead?
Thomas
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 5/7] tests/x86: Add 'q35' machine type to override-tests in hd-geo-test
2022-09-27 13:00 ` Thomas Huth
@ 2022-09-28 8:37 ` Michael Labiuk
0 siblings, 0 replies; 15+ messages in thread
From: Michael Labiuk @ 2022-09-28 8:37 UTC (permalink / raw)
To: Thomas Huth, qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Dr . David Alan Gilbert, den
Thanks for spotting the typo!
It should be "q35".
On 9/27/22 16:00, Thomas Huth wrote:
> On 20/09/2022 12.48, Michael Labiuk wrote:
>> Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
>> diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c
>> index 413cf964c0..58b1107d64 100644
>> --- a/tests/qtest/hd-geo-test.c
>> +++ b/tests/qtest/hd-geo-test.c
> ...
>> @@ -799,7 +857,23 @@ static void test_override_virtio_blk(void)
>> add_drive_with_mbr(args, empty_mbr, 1);
>> add_virtio_disk(args, 0, "pci.0", 3, 10000, 120, 30);
>> add_virtio_disk(args, 1, "pci.0", 4, 9000, 120, 30);
>> - test_override(args, expected);
>> + test_override(args, "pc", expected);
>> +}
>> +
>> +static void test_override_virtio_blk_q35(void)
>> +{
>> + TestArgs *args = create_args();
>> + CHSResult expected[] = {
>> + {"/pci@i0cf8/pci-bridge@2/scsi@3/disk@0,0", {10000, 120, 30} },
>> + {"/pci@i0cf8/pci-bridge@2/scsi@4/disk@0,0", {9000, 120, 30} },
>> + {NULL, {0, 0, 0} }
>> + };
>> + add_drive_with_mbr(args, empty_mbr, 1);
>> + add_drive_with_mbr(args, empty_mbr, 1);
>> + setup_pci_bridge(args, "pcie.0", "br");
>> + add_virtio_disk(args, 0, "br", 3, 10000, 120, 30);
>> + add_virtio_disk(args, 1, "br", 4, 9000, 120, 30);
>> + test_override(args, "pc", expected);
>
> Shouldn't that use "q35" as machine instead?
>
> Thomas
>
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2022-09-28 12:13 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-20 10:48 [PATCH v4 0/7] Add 'q35' machine type to hotplug tests Michael Labiuk via
2022-09-20 10:48 ` [PATCH v4 1/7] tests/x86: Move common code to function in device-plug-test Michael Labiuk via
2022-09-27 10:27 ` Thomas Huth
2022-09-20 10:48 ` [PATCH v4 2/7] tests/x86: Add subtest with 'q35' machine type to device-plug-test Michael Labiuk via
2022-09-27 10:35 ` Thomas Huth
2022-09-27 10:40 ` Thomas Huth
2022-09-20 10:48 ` [PATCH v4 3/7] tests/x86: Add 'q35' machine type to ivshmem-test Michael Labiuk via
2022-09-27 10:57 ` Thomas Huth
2022-09-20 10:48 ` [PATCH v4 4/7] tests/x86: Add 'q35' machine type to drive_del-test Michael Labiuk via
2022-09-27 12:29 ` Thomas Huth
2022-09-20 10:48 ` [PATCH v4 5/7] tests/x86: Add 'q35' machine type to override-tests in hd-geo-test Michael Labiuk via
2022-09-27 13:00 ` Thomas Huth
2022-09-28 8:37 ` Michael Labiuk
2022-09-20 10:48 ` [PATCH v4 6/7] tests/x86: Refactor hot unplug hd-geo-test Michael Labiuk via
2022-09-20 10:48 ` [PATCH v4 7/7] tests/x86: Add 'q35' machine type to hotplug hd-geo-test Michael Labiuk via
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).