test virtio-blk hotplug
v3 cover test virtio-blk hotplug
It's worth to add a hotplug test to qtest, but without cooperation of guest OS, new devices can't be initialized by guest, and hot-unplug doesn't work.
However, the new test can cover some part of code of hotplug/unplug.
I will write another subtest to test hotplug with pci support.
V2: move qmp_exec_hmp_cmd() to libqtest.c
excape hmp cmd (stefanha)
use qmp_exec_hmp_cmd() in blockdev-test
V3: use vp_list to format string, free escaped string
Amos Kong (4):
virtio-blk-test.c: change pci_nop() to virtblk_init()
qtest: introduce qmp_exec_hmp_cmd() virtio-blk-test.c: add hotplug subtest
qtest: use qmp_exec_hmp_cmd() in blockdev-test
tests/blockdev-test.c | 23 ++--------------------- tests/libqtest.c | 26 ++++++++++++++++++++++++++ tests/libqtest.h | 9 +++++++++ tests/virtio-blk-test.c | 44 +++++++++++++++++++++++++++++++++++++------- 4 files changed, 74 insertions(+), 28 deletions(-)
Signature · 1 line
1.9.3
PATCH v3 1/4 virtio-blk-test.c: change pci_nop() to virtblk_init()
I want to add a new subtest in virtio-blk-test.c, it will start guest without network. The original pci_init() did nothing, but it's good to reserve a very simple initialization testing.
--- tests/virtio-blk-test.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
tests/virtio-blk-test.c +6 -7
@@ -12,9 +12,12 @@#include "libqtest.h" #include "qemu/osdep.h" -/* Tests only initialization so far. TODO: Replace with functional tests */ -static void pci_nop (void ) +/* Tests only initialization */ +static void virtblk_init (void ) { +qtest_start ("-drive id=drv0,if=none,file=/dev/null " +"-device virtio-blk-pci,drive=drv0" ); +qtest_end (); }int main (int argc,char **argv)
@@ -22,13 +25,9 @@ int main(int argc, char **argv)int ret;g_test_init (&argc, &argv,NULL ); -qtest_add_func ("/virtio/blk/pci/nop" , pci_nop); +qtest_add_func ("/virtio/blk/pci/init" , virtblk_init); -qtest_start ("-drive id=drv0,if=none,file=/dev/null " -"-device virtio-blk-pci,drive=drv0" ); ret =g_test_run (); -qtest_end (); -return ret; }
Signature · 1 line
1.9.3
PATCH v3 2/4 qtest: introduce qmp_exec_hmp_cmd()
In reply to Amos KongThis patch wraps a helper function to execute human command by one QMP command (human-monitor-command). It also checks the return string.
--- tests/libqtest.c | 26 ++++++++++++++++++++++++++ tests/libqtest.h | 9 +++++++++ 2 files changed, 35 insertions(+)
tests/libqtest.c +26 -0
@@ -646,3 +646,29 @@ void qmp_discard_response(const char *fmt, ...)qtest_qmpv_discard_response (global_qtest, fmt, ap);va_end (ap); } + +void qmp_exec_hmp_cmd (const char *expected_ret,const char *fmt, ...) +{ +va_list ap; +char cmd[1024 ]; +char *escaped_cmd; +QDict *response; +const char *response_return; + +va_start (ap, fmt); +vsprintf (cmd, fmt, ap); +va_end (ap); + + escaped_cmd =g_strescape (cmd,NULL ); + response =qmp ("{\"execute\": \"human-monitor-command\"," +" \"arguments\": {" +" \"command-line\": \"%s\"" +"}}" , escaped_cmd); +free (escaped_cmd); + +g_assert (response); + response_return =qdict_get_try_str (response,"return" ); +g_assert (response_return); + g_assert_cmpstr(response_return, ==, expected_ret); +QDECREF (response); +}
tests/libqtest.h +9 -0
@@ -375,6 +375,15 @@ QDict *qmp(const char *fmt, ...);void qmp_discard_response (const char *fmt, ...);/** +* qmp_exec_hmp_cmd: +* @expected_ret: expected return string +* @fmt...: HMP command to execute +* +* Executes HMP command by 'human-monitor-command'. +*/ +void qmp_exec_hmp_cmd (const char *expected_ret,const char *fmt, ...); + +/** * qmp_receive: * * Reads a QMP message from QEMU and returns the response.
Signature · 1 line
1.9.3
PATCH v3 3/4 virtio-blk-test.c: add hotplug subtest
In reply to Amos KongThis patch adds a new subtest, it hotplugs 29 * 8 = 232 virtio-blk devices to guest, and try to hot-unplug them.
Note: the hot-unplug can't work without cooperation of guest OS.
--- tests/virtio-blk-test.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
tests/virtio-blk-test.c +31 -0
@@ -7,11 +7,41 @@* See the COPYING file in the top-level directory. */ +#include <stdio.h> #include <glib.h> #include <string.h> #include "libqtest.h" #include "qemu/osdep.h" +static void test_blk_hotplug (void ) +{ +int i, j; + +/* start with no network/block device, slots 3~0x1f are free */ +qtest_start ("-net none" ); + +for (i =3 ; i <=0x1f ; i++) { +for (j =7 ; j >=0 ; j--) { +qmp_exec_hmp_cmd ("OK\r\n" , +"drive_add 0 if=none,file=/dev/null,id=drv-%x.%x" , + i, j); +qmp_exec_hmp_cmd ("" , +"device_add virtio-blk-pci,id=dev-%x.%x,drive=drv-%x.%x," +"addr=0x%x.%x,multifunction=on" , i, j, i, j, i, j); + } + } + +/* hot-unplug doesn't work without cooperation of guest OS */ +for (i =3 ; i <=0x1f ; i++) { +for (j =7 ; j >=0 ; j--) { +qmp_exec_hmp_cmd ("" ,"drive_del drv-%x.%x" , i, j); +qmp_exec_hmp_cmd ("" ,"device_del dev-%x.%x" , i, j); + } + } + +qtest_end (); +} +/* Tests only initialization */ static void virtblk_init (void ) {
@@ -26,6 +56,7 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL );qtest_add_func ("/virtio/blk/pci/init" , virtblk_init); +qtest_add_func ("/virtio/blk/pci/hotplug" , test_blk_hotplug); ret =g_test_run ();
Signature · 1 line
1.9.3
PATCH v3 4/4 qtest: use qmp_exec_hmp_cmd() in blockdev-test
In reply to Amos Kong--- tests/blockdev-test.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)
tests/blockdev-test.c +2 -21
@@ -16,35 +16,16 @@static void test_drive_add_empty (void ) { -QDict *response; -const char *response_return; -/* Start with an empty drive */ qtest_start ("-drive if=none,id=drive0" );/* Delete the drive */ - response =qmp ("{\"execute\": \"human-monitor-command\"," -" \"arguments\": {" -" \"command-line\": \"drive_del drive0\"" -"}}" ); -g_assert (response); - response_return =qdict_get_try_str (response,"return" ); -g_assert (response_return); -g_assert (strcmp (response_return,"" ) ==0 ); -QDECREF (response); +qmp_exec_hmp_cmd ("" ,"drive_del drive0" );/* Ensure re-adding the drive works - there should be no duplicate ID error * because the old drive must be gone. */ - response =qmp ("{\"execute\": \"human-monitor-command\"," -" \"arguments\": {" -" \"command-line\": \"drive_add 0 if=none,id=drive0\"" -"}}" ); -g_assert (response); - response_return =qdict_get_try_str (response,"return" ); -g_assert (response_return); -g_assert (strcmp (response_return,"OK\r\n" ) ==0 ); -QDECREF (response); +qmp_exec_hmp_cmd ("OK\r\n" ,"drive_add 0 if=none,id=drive0" );qtest_end (); }
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH v3 3/4] virtio-blk-test.c: add hotplug subtest
In reply to Amos KongHi, Amos
Quoted 48 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 9:12 AM
To: [email protected]
Cc: [email protected]; [email protected]; Gonglei (Arei)
Subject: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestThis patch adds a new subtest, it hotplugs 29 * 8 = 232 virtio-blk devices to guest, and try to hot-unplug them.
Note: the hot-unplug can't work without cooperation of guest OS.
Signed-off-by Amos Kong <[email protected]>Reviewed-by Stefan Hajnoczi <[email protected]>--- tests/virtio-blk-test.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)tests/virtio-blk-test.c +15
-0@@ -7,11 +7,41 @@* See the COPYING file in the top-level directory. */ +#include <stdio.h> #include <glib.h> #include <string.h> #include "libqtest.h" #include "qemu/osdep.h" +static void test_blk_hotplug (void ) +{ +int i, j; + +/* start with no network/block device, slots 3~0x1f are free */ +qtest_start ("-net none" ); + +for (i =3 ; i <=0x1f ; i++) { +for (j =7 ; j >=0 ; j--) { +qmp_exec_hmp_cmd ("OK\r\n" , + "drive_add 0 if=none,file=/dev/null,id=drv-%x.%x", + i, j); + qmp_exec_hmp_cmd("", + "device_addvirtio-blk-pci,id=dev-%x.%x,drive=drv-%x.%x,"
tests/virtio-blk-test.c line 32
Quoted 3 lines
tests/virtio-blk-test.c +3
-0+ "addr=0x%x.%x,multifunction=on", i, j, i, j, i, j); + } + }
Do the pci multifunction devices support hotplug/unplug yet?
Best regards,
-Gonglei
Re: [Qemu-devel] [PATCH v3 3/4] virtio-blk-test.c: add hotplug subtest
Quoted 28 lines · Gonglei (Arei)
Hi, Amos
Quoted 26 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 9:12 AM
To: [email protected]
Cc: [email protected]; [email protected]; Gonglei (Arei)
Subject: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestThis patch adds a new subtest, it hotplugs 29 * 8 = 232 virtio-blk devices to guest, and try to hot-unplug them.
Note: the hot-unplug can't work without cooperation of guest OS.
tests/virtio-blk-test.c +11
-0+static void test_blk_hotplug (void ) +{ +int i, j; + +/* start with no network/block device, slots 3~0x1f are free */ +qtest_start ("-net none" ); + +for (i =3 ; i <=0x1f ; i++) { +for (j =7 ; j >=0 ; j--) { + qmp_exec_hmp_cmd("OK\r\n", + "drive_add 0if=none,file=/dev/null,id=drv-%x.%x",
+ i, j);
Quoted 8 lines
tests/virtio-blk-test.c line 32
Quoted 6 lines
(quoted diff) +2
-0+ qmp_exec_hmp_cmd("", + "device_addvirtio-blk-pci,id=dev-%x.%x,drive=drv-%x.%x,"
tests/virtio-blk-test.c +3
-0+ "addr=0x%x.%x,multifunction=on", i, j, i, j, i, j); + } + }Do the pci multifunction devices support hotplug/unplug yet?
Yes.
You can hotplug single functions one by one, guest will identify all the functions when function 0 is added.
Hotunplug function 0, all functions in same slot will be removed.
Quoted 2 lines
Best regards,
-Gonglei
Signature · 1 line
Amos.
Re: [Qemu-devel] [PATCH v3 3/4] virtio-blk-test.c: add hotplug subtest
Quoted 44 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 1:29 PM
To: Gonglei (Arei)
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestQuoted 24 lines · Gonglei (Arei)
Hi, Amos
Quoted 22 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 9:12 AM
To: [email protected]
Cc: [email protected]; [email protected]; Gonglei (Arei)
Subject: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestThis patch adds a new subtest, it hotplugs 29 * 8 = 232 virtio-blk devices to guest, and try to hot-unplug them.
Note: the hot-unplug can't work without cooperation of guest OS.
tests/virtio-blk-test.c +9
-0+static void test_blk_hotplug (void ) +{ +int i, j; + +/* start with no network/block device, slots 3~0x1f are free */ +qtest_start ("-net none" ); + +for (i =3 ; i <=0x1f ; i++) { +for (j =7 ; j >=0 ; j--) {Quoted 8 lines
Quoted 8 lines
(quoted diff) +2
-0+ qmp_exec_hmp_cmd("OK\r\n", + "drive_add 0if=none,file=/dev/null,id=drv-%x.%x",
tests/virtio-blk-test.c +3
-0+ i, j); + qmp_exec_hmp_cmd("", + "device_addvirtio-blk-pci,id=dev-%x.%x,drive=drv-%x.%x,"
+ "addr=0x%x.%x,multifunction=on", i, j, i, j, i,j);
Quoted 3 lines
Quoted 2 lines
(quoted diff) +2
-0+ } + }
Quoted 8 lines
Quoted 1 line
Do the pci multifunction devices support hotplug/unplug yet?
Yes.
You can hotplug single functions one by one, guest will identify all the functions when function 0 is added.
Hotunplug function 0, all functions in same slot will be removed.
Thanks.
IMHO, if we hot-plug function 0 first, the other functions will be not support to hot-plug. Similarly, it will not be allowed if we only hot-unplug function 1~7, but function 0, right?
Best regards,
-Gonglei
Re: [Qemu-devel] [PATCH v3 3/4] virtio-blk-test.c: add hotplug subtest
Quoted 48 lines · Gonglei (Arei)
Quoted 48 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 1:29 PM
To: Gonglei (Arei)
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestQuoted 24 lines · Gonglei (Arei)
Hi, Amos
Quoted 22 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 9:12 AM
To: [email protected]
Cc: [email protected]; [email protected]; Gonglei (Arei)
Subject: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestThis patch adds a new subtest, it hotplugs 29 * 8 = 232 virtio-blk devices to guest, and try to hot-unplug them.
Note: the hot-unplug can't work without cooperation of guest OS.
tests/virtio-blk-test.c +9
-0+static void test_blk_hotplug (void ) +{ +int i, j; + +/* start with no network/block device, slots 3~0x1f are free */ +qtest_start ("-net none" ); + +for (i =3 ; i <=0x1f ; i++) { +for (j =7 ; j >=0 ; j--) {Quoted 8 lines
Quoted 8 lines
(quoted diff) +2
-0+ qmp_exec_hmp_cmd("OK\r\n", + "drive_add 0if=none,file=/dev/null,id=drv-%x.%x",
tests/virtio-blk-test.c +3
-0+ i, j); + qmp_exec_hmp_cmd("", + "device_addvirtio-blk-pci,id=dev-%x.%x,drive=drv-%x.%x,"
+ "addr=0x%x.%x,multifunction=on", i, j, i, j, i,j);
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ } + }Do the pci multifunction devices support hotplug/unplug yet?
Yes.
Quoted 8 lines
Quoted 4 lines
You can hotplug single functions one by one, guest will identify all the functions when function 0 is added.
Hotunplug function 0, all functions in same slot will be removed.Thanks.
IMHO, if we hot-plug function 0 first, the other functions will be not support to hot-plug.
Actually other functions can also be identified by guest, I had a commit to add this support.
| commit f382a086f3129edc152b8044b69ccc6682e637bb | Author: Amos Kong <[email protected]> | Date: Fri Nov 25 15:03:07 2011 +0800 | | PCI: Can continually add funcs after adding func0
Quoted 2 lines
Similarly, it will not be allowed if we only hot-unplug function 1~7, but function 0, right?
Yes. function 0 is always necessary.
Quoted 2 lines
Best regards,
-Gonglei
Signature · 1 line
Amos.
Re: [Qemu-devel] [PATCH v3 3/4] virtio-blk-test.c: add hotplug subtest
Best regards,
-Gonglei
Quoted 67 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 4:24 PM
To: Gonglei (Arei)
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestQuoted 32 lines · Gonglei (Arei)
Quoted 32 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 1:29 PM
To: Gonglei (Arei)
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestQuoted 24 lines · Gonglei (Arei)
Hi, Amos
Quoted 22 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 9:12 AM
To: [email protected]
Cc: [email protected]; [email protected]; Gonglei (Arei)
Subject: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestThis patch adds a new subtest, it hotplugs 29 * 8 = 232 virtio-blk devices to guest, and try to hot-unplug them.
Note: the hot-unplug can't work without cooperation of guest OS.
tests/virtio-blk-test.c +9
-0+static void test_blk_hotplug (void ) +{ +int i, j; + +/* start with no network/block device, slots 3~0x1f are free */ +qtest_start ("-net none" ); + +for (i =3 ; i <=0x1f ; i++) { +for (j =7 ; j >=0 ; j--) {Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
(quoted diff) +2
-0+ qmp_exec_hmp_cmd("OK\r\n", + "drive_add 0if=none,file=/dev/null,id=drv-%x.%x",
tests/virtio-blk-test.c +3
-0+ i, j); + qmp_exec_hmp_cmd("", + "device_addvirtio-blk-pci,id=dev-%x.%x,drive=drv-%x.%x,"
+ "addr=0x%x.%x,multifunction=on", i, j, i, j,i,
Quoted 8 lines
Quoted 8 lines
j);
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ } + }Do the pci multifunction devices support hotplug/unplug yet?
Yes.
Quoted 7 lines
Quoted 4 lines
You can hotplug single functions one by one, guest will identify all the functions when function 0 is added.
Hotunplug function 0, all functions in same slot will be removed.Thanks.
IMHO, if we hot-plug function 0 first, the other functions will be not support
to
Quoted 1 line
hot-plug.
Quoted 10 lines
Actually other functions can also be identified by guest, I had a commit to add this support.
| commit f382a086f3129edc152b8044b69ccc6682e637bb | Author: Amos Kong <[email protected]> | Date: Fri Nov 25 15:03:07 2011 +0800 | | PCI: Can continually add funcs after adding func0
Good, Thanks!
BTW, the limits of ACPI DSDT table have been resolved yet?
Quoted 10 lines
Quoted 2 lines
Similarly, it will not be allowed if we only hot-unplug function 1~7, but function 0, right?
Yes. function 0 is always necessary.
Quoted 2 lines
Best regards,
-Gonglei--
Amos.
Re: [Qemu-devel] [PATCH v3 3/4] virtio-blk-test.c: add hotplug subtest
Quoted 77 lines · Gonglei (Arei)
Quoted 67 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 4:24 PM
To: Gonglei (Arei)
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestQuoted 32 lines · Gonglei (Arei)
Quoted 32 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 1:29 PM
To: Gonglei (Arei)
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestQuoted 24 lines · Gonglei (Arei)
Hi, Amos
Quoted 22 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 9:12 AM
To: [email protected]
Cc: [email protected]; [email protected]; Gonglei (Arei)
Subject: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestThis patch adds a new subtest, it hotplugs 29 * 8 = 232 virtio-blk devices to guest, and try to hot-unplug them.
Note: the hot-unplug can't work without cooperation of guest OS.
tests/virtio-blk-test.c +9
-0+static void test_blk_hotplug (void ) +{ +int i, j; + +/* start with no network/block device, slots 3~0x1f are free */ +qtest_start ("-net none" ); + +for (i =3 ; i <=0x1f ; i++) { +for (j =7 ; j >=0 ; j--) {Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
(quoted diff) +2
-0+ qmp_exec_hmp_cmd("OK\r\n", + "drive_add 0if=none,file=/dev/null,id=drv-%x.%x",
tests/virtio-blk-test.c +3
-0+ i, j); + qmp_exec_hmp_cmd("", + "device_addvirtio-blk-pci,id=dev-%x.%x,drive=drv-%x.%x,"
+ "addr=0x%x.%x,multifunction=on", i, j, i, j,i,
Quoted 8 lines
Quoted 8 lines
j);
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ } + }Do the pci multifunction devices support hotplug/unplug yet?
Yes.
Quoted 7 lines
Quoted 4 lines
You can hotplug single functions one by one, guest will identify all the functions when function 0 is added.
Hotunplug function 0, all functions in same slot will be removed.Thanks.
IMHO, if we hot-plug function 0 first, the other functions will be not support
to
Quoted 1 line
hot-plug.
Quoted 10 lines
Actually other functions can also be identified by guest, I had a commit to add this support.
| commit f382a086f3129edc152b8044b69ccc6682e637bb | Author: Amos Kong <[email protected]> | Date: Fri Nov 25 15:03:07 2011 +0800 | | PCI: Can continually add funcs after adding func0
Quoted 3 lines
Good, Thanks!
BTW, the limits of ACPI DSDT table have been resolved yet?
Which limit?
There was a hot-unplug bug of multiple function, I tried to fix it by change ACPI DSDT table in seabios, but finally we fixed this in kernel.
|commit ce29ca3ea40744f24c2b5d88431e8ac566d257cc |Author: Amos Kong <[email protected]> |Date: Wed May 23 10:20:35 2012 -0600 | | PCI: acpiphp: remove all functions in slot, even without ACPI _EJx
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
Similarly, it will not be allowed if we only hot-unplug function 1~7, but function 0, right?
Yes. function 0 is always necessary.
Quoted 2 lines
Best regards,
-Gonglei--
Amos.
Signature · 1 line
Amos.
Re: [Qemu-devel] [PATCH v3 3/4] virtio-blk-test.c: add hotplug subtest
Quoted 89 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 6:11 PM
To: Gonglei (Arei)
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestQuoted 40 lines · Gonglei (Arei)
Quoted 40 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 4:24 PM
To: Gonglei (Arei)
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestQuoted 32 lines · Gonglei (Arei)
Quoted 32 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 1:29 PM
To: Gonglei (Arei)
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestQuoted 24 lines · Gonglei (Arei)
Hi, Amos
Quoted 22 lines
-----Original Message-----
From: Amos Kong [mailto:[email protected]]
Sent: Friday, June 06, 2014 9:12 AM
To: [email protected]
Cc: [email protected]; [email protected]; Gonglei (Arei)
Subject: [PATCH v3 3/4]virtio-blk-test.c: add hotplug subtestThis patch adds a new subtest, it hotplugs 29 * 8 = 232 virtio-blk devices to guest, and try to hot-unplug them.
Note: the hot-unplug can't work without cooperation of guest OS.
(quoted diff) +9
-0+static void test_blk_hotplug(void) +{ + int i, j; + + /* start with no network/block device, slots 3~0x1f are free */ + qtest_start("-net none"); + + for (i = 3; i <= 0x1f; i++) { + for (j = 7; j >= 0; j--) {Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
(quoted diff) +2
-0+ qmp_exec_hmp_cmd("OK\r\n", + "drive_add 0if=none,file=/dev/null,id=drv-%x.%x",
(quoted diff) +3
-0+ i, j); + qmp_exec_hmp_cmd("", + "device_addvirtio-blk-pci,id=dev-%x.%x,drive=drv-%x.%x,"
+ "addr=0x%x.%x,multifunction=on", i, j,i, j,
Quoted 9 lines
Quoted 9 lines
i,
Quoted 8 lines
Quoted 8 lines
j);
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ } + }Do the pci multifunction devices support hotplug/unplug yet?
Yes.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
You can hotplug single functions one by one, guest will identify all the functions when function 0 is added.
Hotunplug function 0, all functions in same slot will be removed.Thanks.
IMHO, if we hot-plug function 0 first, the other functions will be not
support
Quoted 15 lines
Quoted 13 lines
to
Quoted 1 line
hot-plug.
Actually other functions can also be identified by guest, I had a commit to add this support.
| commit f382a086f3129edc152b8044b69ccc6682e637bb | Author: Amos Kong <[email protected]> | Date: Fri Nov 25 15:03:07 2011 +0800 | | PCI: Can continually add funcs after adding func0Good, Thanks!
Quoted 8 lines
Quoted 1 line
BTW, the limits of ACPI DSDT table have been resolved yet?
Which limit?
There was a hot-unplug bug of multiple function, I tried to fix it by change ACPI DSDT table in seabios, but finally we fixed this in kernel.
OK, understand it, " Note: the hot-unplug can't work without cooperation of guest OS."
I see your discussion at maillist:
https://lists.gnu.org/archive/html/qemu-devel/2012-05/msg01103.html
but I don't find the patch in seabios.git, so I have a doubt mentioned above.
Thanks for your patient answer.
Best regards,
-Gonglei
Re: [Qemu-devel] [PATCH v3 2/4] qtest: introduce qmp_exec_hmp_cmd()
In reply to Amos KongQuoted 8 lines · Amos Kong
tests/libqtest.c +8
-0+void qmp_exec_hmp_cmd (const char *expected_ret,const char *fmt, ...) +{ +va_list ap; +char cmd[1024 ]; +char *escaped_cmd; +QDict *response; +const char *response_return; +
tests/libqtest.c void qmp_discard_response(const char *fmt, ...) · line 667
Quoted 10 lines
tests/libqtest.c +10
-0+va_start (ap, fmt); +vsprintf (cmd, fmt, ap); +va_end (ap); + + escaped_cmd =g_strescape (cmd,NULL ); + response =qmp ("{\"execute\": \"human-monitor-command\"," +" \"arguments\": {" +" \"command-line\": \"%s\"" +"}}" , escaped_cmd); +free (escaped_cmd);
glib uses g_malloc()/g_free() instead of malloc()/free(). Please use g_free() since the string comes from g_strescape().
Re: [Qemu-devel] [PATCH v3 1/4] virtio-blk-test.c: change pci_nop() to virtblk_init()
In reply to Amos KongQuoted 8 lines · Amos Kong
I want to add a new subtest in
virtio-blk-test.c, it will start guest without network. The originalpci_init()did nothing, but it's good to reserve a very simple initialization testing.Signed-off-by Amos Kong <[email protected]>--- tests/virtio-blk-test.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
Re: [Qemu-devel] [PATCH v3 3/4] virtio-blk-test.c: add hotplug subtest
In reply to Amos KongQuoted 10 lines · Amos Kong
This patch adds a new subtest, it hotplugs 29 * 8 = 232 virtio-blk devices to guest, and try to hot-unplug them.
Note: the hot-unplug can't work without cooperation of guest OS.
Signed-off-by Amos Kong <[email protected]>Reviewed-by Stefan Hajnoczi <[email protected]>--- tests/virtio-blk-test.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
Re: [Qemu-devel] [PATCH v3 4/4] qtest: use qmp_exec_hmp_cmd() in blockdev-test
In reply to Amos KongQuoted 5 lines · Amos Kong
Signed-off-by Amos Kong <[email protected]>Reviewed-by Stefan Hajnoczi <[email protected]>--- tests/blockdev-test.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)