[PATCH for-6.2 1/8] softmmu: Use accel_find("xen") instead of xen_available()

Peter Maydell posted 8 patches 4 years, 6 months ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, Aurelien Jarno <aurelien@aurel32.net>, Eduardo Habkost <ehabkost@redhat.com>, Markus Armbruster <armbru@redhat.com>, "Hervé Poussineau" <hpoussin@reactos.org>, Kevin Wolf <kwolf@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, "Daniel P. Berrangé" <berrange@redhat.com>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Bin Meng <bin.meng@windriver.com>, Greg Kurz <groug@kaod.org>, "Michael S. Tsirkin" <mst@redhat.com>, David Hildenbrand <david@redhat.com>, David Gibson <david@gibson.dropbear.id.au>, Cornelia Huck <cohuck@redhat.com>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Alistair Francis <Alistair.Francis@wdc.com>, Palmer Dabbelt <palmer@dabbelt.com>, Thomas Huth <thuth@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
[PATCH for-6.2 1/8] softmmu: Use accel_find("xen") instead of xen_available()
Posted by Peter Maydell 4 years, 6 months ago
The xen_available() function is used only to produce an error
for some Xen-specific command line options in QEMU binaries where
Xen support was not compiled in: it just returns the value of
the CONFIG_XEN define.

Now that accelerators are QOM classes, we can check for
"does this binary have Xen compiled in" with accel_find("xen"),
and drop the xen_available() function.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/sysemu/arch_init.h | 1 -
 softmmu/arch_init.c        | 9 ---------
 softmmu/vl.c               | 6 +++---
 3 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index e723c467eb2..7acfc62418f 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -30,7 +30,6 @@ enum {
 extern const uint32_t arch_type;
 
 int kvm_available(void);
-int xen_available(void);
 
 /* default virtio transport per architecture */
 #define QEMU_ARCH_VIRTIO_PCI (QEMU_ARCH_ALPHA | QEMU_ARCH_ARM | \
diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c
index 6ff9f30badd..3f4d7c1b1cd 100644
--- a/softmmu/arch_init.c
+++ b/softmmu/arch_init.c
@@ -96,12 +96,3 @@ int kvm_available(void)
     return 0;
 #endif
 }
-
-int xen_available(void)
-{
-#ifdef CONFIG_XEN
-    return 1;
-#else
-    return 0;
-#endif
-}
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 4dee472c794..a32d15b6a1f 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3429,21 +3429,21 @@ void qemu_init(int argc, char **argv, char **envp)
                 has_defaults = 0;
                 break;
             case QEMU_OPTION_xen_domid:
-                if (!(xen_available())) {
+                if (!(accel_find("xen"))) {
                     error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_domid = atoi(optarg);
                 break;
             case QEMU_OPTION_xen_attach:
-                if (!(xen_available())) {
+                if (!(accel_find("xen"))) {
                     error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_mode = XEN_ATTACH;
                 break;
             case QEMU_OPTION_xen_domid_restrict:
-                if (!(xen_available())) {
+                if (!(accel_find("xen"))) {
                     error_report("Option not supported for this target");
                     exit(1);
                 }
-- 
2.20.1


Re: [PATCH for-6.2 1/8] softmmu: Use accel_find("xen") instead of xen_available()
Posted by Richard Henderson 4 years, 6 months ago
On 7/30/21 12:59 AM, Peter Maydell wrote:
> The xen_available() function is used only to produce an error
> for some Xen-specific command line options in QEMU binaries where
> Xen support was not compiled in: it just returns the value of
> the CONFIG_XEN define.
> 
> Now that accelerators are QOM classes, we can check for
> "does this binary have Xen compiled in" with accel_find("xen"),
> and drop the xen_available() function.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   include/sysemu/arch_init.h | 1 -
>   softmmu/arch_init.c        | 9 ---------
>   softmmu/vl.c               | 6 +++---
>   3 files changed, 3 insertions(+), 13 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~