qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 03/30] test: virtio-rng: check if hot-plug/unplu


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 03/30] test: virtio-rng: check if hot-plug/unplug works
Date: Wed, 24 Sep 2014 14:35:16 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0

Il 24/09/2014 13:47, Igor Mammedov ha scritto:
> Signed-off-by: Igor Mammedov <address@hidden>
> ---
>  tests/virtio-rng-test.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/tests/virtio-rng-test.c b/tests/virtio-rng-test.c
> index 402c206..7f62f84 100644
> --- a/tests/virtio-rng-test.c
> +++ b/tests/virtio-rng-test.c
> @@ -12,17 +12,55 @@
>  #include "libqtest.h"
>  #include "qemu/osdep.h"
>  
> +#define PCI_SLOT_HP             0x06
> +#define ACPI_PCIHP_ADDR         0xae00
> +#define PCI_EJ_BASE             0x0008
> +
>  /* Tests only initialization so far. TODO: Replace with functional tests */
>  static void pci_nop(void)
>  {
>  }
>  
> +static void hotplug(void)
> +{
> +    QDict *response;
> +
> +    response = qmp("{\"execute\": \"device_add\","

Remember that, for all these tests, you can use '' strings instead of "".

> +                   " \"arguments\": {"
> +                   "   \"driver\": \"virtio-rng-pci\","
> +                   "   \"addr\": \"" stringify(PCI_SLOT_HP) "\","
> +                   "   \"id\": \"rng1\""
> +                   "}}");
> +
> +    g_assert(response);
> +    g_assert(!qdict_haskey(response, "error"));
> +    QDECREF(response);
> +
> +    response = qmp("{\"execute\": \"device_del\","
> +                   " \"arguments\": {"
> +                   "   \"id\": \"rng1\""
> +                   "}}");
> +
> +    g_assert(response);
> +    g_assert(!qdict_haskey(response, "error"));
> +    QDECREF(response);
> +
> +    outb(ACPI_PCIHP_ADDR + PCI_EJ_BASE, 1 << PCI_SLOT_HP);

Please replace this with a callback in tests/libqos/pci.h (with the
implementation in tests/libqos/pci-pc.c).

Paolo

> +    response = qmp("");
> +    g_assert(response);
> +    g_assert(qdict_haskey(response, "event"));
> +    g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
> +    QDECREF(response);
> +}
> +
>  int main(int argc, char **argv)
>  {
>      int ret;
>  
>      g_test_init(&argc, &argv, NULL);
>      qtest_add_func("/virtio/rng/pci/nop", pci_nop);
> +    qtest_add_func("/virtio/rng/pci/hotplug", hotplug);
>  
>      qtest_start("-device virtio-rng-pci");
>      ret = g_test_run();
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]