diff mbox series

[v2,6/6] tests/device-plug: Add memory unplug request test for spapr

Message ID 20190215133005.15955-7-david@redhat.com (mailing list archive)
State New, archived
Headers show
Series tests: Add device unplug tests | expand

Commit Message

David Hildenbrand Feb. 15, 2019, 1:30 p.m. UTC
We can easily test this, just like PCI.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 tests/device-plug-test.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Thomas Huth Feb. 15, 2019, 3:56 p.m. UTC | #1
On 15/02/2019 14.30, David Hildenbrand wrote:
> We can easily test this, just like PCI.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  tests/device-plug-test.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/tests/device-plug-test.c b/tests/device-plug-test.c
> index ec6cb5de7b..4c581319c0 100644
> --- a/tests/device-plug-test.c
> +++ b/tests/device-plug-test.c
> @@ -116,6 +116,22 @@ static void test_spapr_cpu_unplug_request(void)
>      qtest_quit(qtest);
>  }
>  
> +static void test_spapr_memory_unplug_request(void)
> +{
> +    QTestState *qtest;
> +
> +    qtest = qtest_initf("-m 1G,slots=1,maxmem=2G "
> +                        "-object memory-backend-ram,id=mem0,size=1G "
> +                        "-device pc-dimm,id=dev0,memdev=mem0");
> +
> +    /* similar to test_pci_unplug_request */
> +    device_del_request(qtest, "dev0");
> +    system_reset(qtest);
> +    wait_device_deleted_event(qtest, "dev0");
> +
> +    qtest_quit(qtest);
> +}
> +
>  int main(int argc, char **argv)
>  {
>      const char *arch = qtest_get_arch();
> @@ -140,5 +156,10 @@ int main(int argc, char **argv)
>                         test_spapr_cpu_unplug_request);
>      }
>  
> +    if (!strcmp(arch, "ppc64")) {
> +        qtest_add_func("/device-plug/spapr_memory_unplug_request",
> +                       test_spapr_memory_unplug_request);
> +    }
> +
>      return g_test_run();
>  }

I think I'd maybe use a smaller DIMM (256 MiB? 512 MiB), just in case
the test runs on an overloaded CI system with memory constraints ... but
anyway:

Reviewed-by: Thomas Huth <thuth@redhat.com>
Thomas Huth Feb. 15, 2019, 3:58 p.m. UTC | #2
On 15/02/2019 14.30, David Hildenbrand wrote:
> We can easily test this, just like PCI.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  tests/device-plug-test.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/tests/device-plug-test.c b/tests/device-plug-test.c
> index ec6cb5de7b..4c581319c0 100644
> --- a/tests/device-plug-test.c
> +++ b/tests/device-plug-test.c
> @@ -116,6 +116,22 @@ static void test_spapr_cpu_unplug_request(void)
>      qtest_quit(qtest);
>  }
>  
> +static void test_spapr_memory_unplug_request(void)
> +{
> +    QTestState *qtest;
> +
> +    qtest = qtest_initf("-m 1G,slots=1,maxmem=2G "
> +                        "-object memory-backend-ram,id=mem0,size=1G "
> +                        "-device pc-dimm,id=dev0,memdev=mem0");
> +
> +    /* similar to test_pci_unplug_request */
> +    device_del_request(qtest, "dev0");
> +    system_reset(qtest);
> +    wait_device_deleted_event(qtest, "dev0");
> +
> +    qtest_quit(qtest);
> +}
> +
>  int main(int argc, char **argv)
>  {
>      const char *arch = qtest_get_arch();
> @@ -140,5 +156,10 @@ int main(int argc, char **argv)
>                         test_spapr_cpu_unplug_request);
>      }
>  
> +    if (!strcmp(arch, "ppc64")) {
> +        qtest_add_func("/device-plug/spapr_memory_unplug_request",
> +                       test_spapr_memory_unplug_request);
> +    }

By the way, it's maybe nicer to put all ppc-related tests into the same
if-statement?

 Thomas
Greg Kurz Feb. 15, 2019, 4:03 p.m. UTC | #3
On Fri, 15 Feb 2019 14:30:05 +0100
David Hildenbrand <david@redhat.com> wrote:

> We can easily test this, just like PCI.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  tests/device-plug-test.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/tests/device-plug-test.c b/tests/device-plug-test.c
> index ec6cb5de7b..4c581319c0 100644
> --- a/tests/device-plug-test.c
> +++ b/tests/device-plug-test.c
> @@ -116,6 +116,22 @@ static void test_spapr_cpu_unplug_request(void)
>      qtest_quit(qtest);
>  }
>  
> +static void test_spapr_memory_unplug_request(void)
> +{
> +    QTestState *qtest;
> +
> +    qtest = qtest_initf("-m 1G,slots=1,maxmem=2G "
> +                        "-object memory-backend-ram,id=mem0,size=1G "
> +                        "-device pc-dimm,id=dev0,memdev=mem0");
> +
> +    /* similar to test_pci_unplug_request */
> +    device_del_request(qtest, "dev0");
> +    system_reset(qtest);
> +    wait_device_deleted_event(qtest, "dev0");
> +
> +    qtest_quit(qtest);
> +}
> +
>  int main(int argc, char **argv)
>  {
>      const char *arch = qtest_get_arch();
> @@ -140,5 +156,10 @@ int main(int argc, char **argv)
>                         test_spapr_cpu_unplug_request);
>      }
>  
> +    if (!strcmp(arch, "ppc64")) {
> +        qtest_add_func("/device-plug/spapr_memory_unplug_request",
> +                       test_spapr_memory_unplug_request);
> +    }
> +
>      return g_test_run();
>  }
David Gibson Feb. 18, 2019, 3:23 a.m. UTC | #4
On Fri, Feb 15, 2019 at 04:56:53PM +0100, Thomas Huth wrote:
> On 15/02/2019 14.30, David Hildenbrand wrote:
> > We can easily test this, just like PCI.
> > 
> > Signed-off-by: David Hildenbrand <david@redhat.com>
> > ---
> >  tests/device-plug-test.c | 21 +++++++++++++++++++++
> >  1 file changed, 21 insertions(+)
> > 
> > diff --git a/tests/device-plug-test.c b/tests/device-plug-test.c
> > index ec6cb5de7b..4c581319c0 100644
> > --- a/tests/device-plug-test.c
> > +++ b/tests/device-plug-test.c
> > @@ -116,6 +116,22 @@ static void test_spapr_cpu_unplug_request(void)
> >      qtest_quit(qtest);
> >  }
> >  
> > +static void test_spapr_memory_unplug_request(void)
> > +{
> > +    QTestState *qtest;
> > +
> > +    qtest = qtest_initf("-m 1G,slots=1,maxmem=2G "
> > +                        "-object memory-backend-ram,id=mem0,size=1G "
> > +                        "-device pc-dimm,id=dev0,memdev=mem0");
> > +
> > +    /* similar to test_pci_unplug_request */
> > +    device_del_request(qtest, "dev0");
> > +    system_reset(qtest);
> > +    wait_device_deleted_event(qtest, "dev0");
> > +
> > +    qtest_quit(qtest);
> > +}
> > +
> >  int main(int argc, char **argv)
> >  {
> >      const char *arch = qtest_get_arch();
> > @@ -140,5 +156,10 @@ int main(int argc, char **argv)
> >                         test_spapr_cpu_unplug_request);
> >      }
> >  
> > +    if (!strcmp(arch, "ppc64")) {
> > +        qtest_add_func("/device-plug/spapr_memory_unplug_request",
> > +                       test_spapr_memory_unplug_request);
> > +    }
> > +
> >      return g_test_run();
> >  }
> 
> I think I'd maybe use a smaller DIMM (256 MiB? 512 MiB), just in case
> the test runs on an overloaded CI system with memory constraints ... but
> anyway:

256MiB is the smallest we can do - that's the LMB size.  I'd suggest
512MiB so we're testing the logic that gathers the multiple LMBs for
the DIMM, since that's kind of hairy (it's basically the bridge
between the PAPR and qemu hotplug models which are quite different for
memory).
David Hildenbrand Feb. 18, 2019, 8:50 a.m. UTC | #5
On 15.02.19 16:58, Thomas Huth wrote:
> On 15/02/2019 14.30, David Hildenbrand wrote:
>> We can easily test this, just like PCI.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>>  tests/device-plug-test.c | 21 +++++++++++++++++++++
>>  1 file changed, 21 insertions(+)
>>
>> diff --git a/tests/device-plug-test.c b/tests/device-plug-test.c
>> index ec6cb5de7b..4c581319c0 100644
>> --- a/tests/device-plug-test.c
>> +++ b/tests/device-plug-test.c
>> @@ -116,6 +116,22 @@ static void test_spapr_cpu_unplug_request(void)
>>      qtest_quit(qtest);
>>  }
>>  
>> +static void test_spapr_memory_unplug_request(void)
>> +{
>> +    QTestState *qtest;
>> +
>> +    qtest = qtest_initf("-m 1G,slots=1,maxmem=2G "
>> +                        "-object memory-backend-ram,id=mem0,size=1G "
>> +                        "-device pc-dimm,id=dev0,memdev=mem0");
>> +
>> +    /* similar to test_pci_unplug_request */
>> +    device_del_request(qtest, "dev0");
>> +    system_reset(qtest);
>> +    wait_device_deleted_event(qtest, "dev0");
>> +
>> +    qtest_quit(qtest);
>> +}
>> +
>>  int main(int argc, char **argv)
>>  {
>>      const char *arch = qtest_get_arch();
>> @@ -140,5 +156,10 @@ int main(int argc, char **argv)
>>                         test_spapr_cpu_unplug_request);
>>      }
>>  
>> +    if (!strcmp(arch, "ppc64")) {
>> +        qtest_add_func("/device-plug/spapr_memory_unplug_request",
>> +                       test_spapr_memory_unplug_request);
>> +    }
> 
> By the way, it's maybe nicer to put all ppc-related tests into the same
> if-statement?

Yes, makes sense!

> 
>  Thomas
>
diff mbox series

Patch

diff --git a/tests/device-plug-test.c b/tests/device-plug-test.c
index ec6cb5de7b..4c581319c0 100644
--- a/tests/device-plug-test.c
+++ b/tests/device-plug-test.c
@@ -116,6 +116,22 @@  static void test_spapr_cpu_unplug_request(void)
     qtest_quit(qtest);
 }
 
+static void test_spapr_memory_unplug_request(void)
+{
+    QTestState *qtest;
+
+    qtest = qtest_initf("-m 1G,slots=1,maxmem=2G "
+                        "-object memory-backend-ram,id=mem0,size=1G "
+                        "-device pc-dimm,id=dev0,memdev=mem0");
+
+    /* similar to test_pci_unplug_request */
+    device_del_request(qtest, "dev0");
+    system_reset(qtest);
+    wait_device_deleted_event(qtest, "dev0");
+
+    qtest_quit(qtest);
+}
+
 int main(int argc, char **argv)
 {
     const char *arch = qtest_get_arch();
@@ -140,5 +156,10 @@  int main(int argc, char **argv)
                        test_spapr_cpu_unplug_request);
     }
 
+    if (!strcmp(arch, "ppc64")) {
+        qtest_add_func("/device-plug/spapr_memory_unplug_request",
+                       test_spapr_memory_unplug_request);
+    }
+
     return g_test_run();
 }