All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@virtuozzo.com>
To: Michael Labiuk <michael.labiuk@virtuozzo.com>, qemu-devel@nongnu.org
Cc: Thomas Huth <thuth@redhat.com>,
	Laurent Vivier <lvivier@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [PATCH v3 1/5] tests/x86: Add subtest with 'q35' machine type to device-plug-test
Date: Mon, 19 Sep 2022 15:07:49 +0200	[thread overview]
Message-ID: <491ee271-0342-d281-c9f2-e1c3e0c5f74b@virtuozzo.com> (raw)
In-Reply-To: <20220915131407.372485-2-michael.labiuk@virtuozzo.com>

On 9/15/22 15:14, Michael Labiuk wrote:
> Configure pci bridge setting to plug pci device and unplug.
> Move common code for device removing to function.
> Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
> ---
>   tests/qtest/device-plug-test.c | 83 ++++++++++++++++++++++++----------
>   1 file changed, 58 insertions(+), 25 deletions(-)
>
> diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c
> index a1fb99c8ff..d66c386ef4 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,20 @@ 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);
> +}
> +
> +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);
>   }
> @@ -98,14 +116,28 @@ 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);
> +}
> +
> +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);
>   }
> @@ -128,9 +160,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 +174,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 +186,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);
>   }
> @@ -195,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();
>   }
this patch mixes non-functional changes - process_device_remove() helper
introduction and functional ones - new test cases added. It is mandatory
to have such stuff separated into different patches.

Den


  reply	other threads:[~2022-09-19 13:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15 13:14 [PATCH v3 0/5] Add 'q35' machine type to hotplug tests Michael Labiuk via
2022-09-15 13:14 ` [PATCH v3 1/5] tests/x86: Add subtest with 'q35' machine type to device-plug-test Michael Labiuk via
2022-09-19 13:07   ` Denis V. Lunev [this message]
2022-09-15 13:14 ` [PATCH v3 2/5] tests/x86: Add 'q35' machine type to ivshmem-test Michael Labiuk via
2022-09-19 13:13   ` Denis V. Lunev
2022-09-19 15:26     ` Michael Labiuk
2022-09-15 13:14 ` [PATCH v3 3/5] tests/x86: Add 'q35' machine type to drive_del-test Michael Labiuk via
2022-09-15 13:14 ` [PATCH v3 4/5] tests/x86: Add 'q35' machine type to hotplug hd-geo-test Michael Labiuk via
2022-09-19 13:19   ` Denis V. Lunev
2022-09-15 13:14 ` [PATCH v3 5/5] tests/x86: Add 'q35' machine type to override-tests in hd-geo-test Michael Labiuk via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=491ee271-0342-d281-c9f2-e1c3e0c5f74b@virtuozzo.com \
    --to=den@virtuozzo.com \
    --cc=dgilbert@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=michael.labiuk@virtuozzo.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.