Patchwork [02/12] vl.c: check for qxl availability

login
register
mail settings
Submitter Aurelien Jarno
Date Sept. 8, 2012, 11:26 a.m.
Message ID <1347103584-20598-3-git-send-email-aurelien@aurel32.net>
Download mbox | patch
Permalink /patch/182533/
State New
Headers show

Comments

Aurelien Jarno - Sept. 8, 2012, 11:26 a.m.
Check for qxl availability in vl.c. This will allow to remove #ifdef
CONFIG_SPICE .. #endif later in this series

Cc: Anthony Liguori <aliguori@us.ibm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 vl.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
Andreas Färber - Sept. 8, 2012, 12:40 p.m.
Am 08.09.2012 13:26, schrieb Aurelien Jarno:
> Check for qxl availability in vl.c. This will allow to remove #ifdef
> CONFIG_SPICE .. #endif later in this series
> 
> Cc: Anthony Liguori <aliguori@us.ibm.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
>  vl.c |   12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/vl.c b/vl.c
> index 7c577fa..6363915 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1703,6 +1703,11 @@ static bool vmware_vga_available(void)
>      return qdev_exists("vmware-svga");
>  }
>  
> +static bool qxl_vga_available(void)
> +{
> +    return qdev_exists("qxl-vga");

I'd suggest to use the QOM equivalent:

object_class_by_name("qxl-vga")

Andreas

> +}
> +
>  static void select_vgahw (const char *p)
>  {
>      const char *opts;
> @@ -1732,7 +1737,12 @@ static void select_vgahw (const char *p)
>      } else if (strstart(p, "xenfb", &opts)) {
>          vga_interface_type = VGA_XENFB;
>      } else if (strstart(p, "qxl", &opts)) {
> -        vga_interface_type = VGA_QXL;
> +        if (qxl_vga_available()) {
> +            vga_interface_type = VGA_QXL;
> +        } else {
> +            fprintf(stderr, "Error: QXL VGA not available\n");
> +            exit(0);
> +        }
>      } else if (!strstart(p, "none", &opts)) {
>      invalid_vga:
>          fprintf(stderr, "Unknown vga type: %s\n", p);
>

Patch

diff --git a/vl.c b/vl.c
index 7c577fa..6363915 100644
--- a/vl.c
+++ b/vl.c
@@ -1703,6 +1703,11 @@  static bool vmware_vga_available(void)
     return qdev_exists("vmware-svga");
 }
 
+static bool qxl_vga_available(void)
+{
+    return qdev_exists("qxl-vga");
+}
+
 static void select_vgahw (const char *p)
 {
     const char *opts;
@@ -1732,7 +1737,12 @@  static void select_vgahw (const char *p)
     } else if (strstart(p, "xenfb", &opts)) {
         vga_interface_type = VGA_XENFB;
     } else if (strstart(p, "qxl", &opts)) {
-        vga_interface_type = VGA_QXL;
+        if (qxl_vga_available()) {
+            vga_interface_type = VGA_QXL;
+        } else {
+            fprintf(stderr, "Error: QXL VGA not available\n");
+            exit(0);
+        }
     } else if (!strstart(p, "none", &opts)) {
     invalid_vga:
         fprintf(stderr, "Unknown vga type: %s\n", p);