Skip to contentSkip to conversation

wire up -g <width>x<height> switch for virtio and qxl.

PATCH In review Gerd Hoffmann 7 participants 20 messages Feb 21, 2017 – Feb 28, 2017

lore
Share & tools
lore
#0 lore raw

cover wire up -g <width>x<height> switch for virtio and qxl.

Hi,

Made a nice patch series out of it, first cleaning up graphics_* variables, then adding support for -g to virtio (just works), qxl (needs guest driver fixes) and stdvga (needs virtual hardware update, and therefore also an guest driver update for obvious reasons).

linux kernel patches to test qxl and stdvga are here:
https://www.kraxel.org/cgit/linux/log/?h=qxl-display-size

please review & test,
Gerd

Gerd Hoffmann (9):
sysemu: add defines for sparc & ppc graphics_*
sparc: use sparc_graphic_* defines
ppc: use ppc_graphic_* defines
drop arch-specific graphic_* initialization.
enable -g command line switch for all archs
virtio-gpu: use graphic_* variables.
qxl: use graphic_* variables.
update -g command line switch documentation
[RfC] stdvga: use graphic_* variables.

 arch_init.c             | 11 -----------
 hw/display/qxl.c        | 32 ++++++++++++++++++++----------
 hw/display/vga-pci.c    | 52 ++++++++++++++++++++++++++++++++++---------------
 hw/display/vga_int.h    |  4 ++--
 hw/display/virtio-gpu.c |  9 +++++++--
 hw/display/virtio-vga.c |  3 ++-
 hw/ppc/mac_newworld.c   |  6 +++---
 hw/ppc/mac_oldworld.c   |  6 +++---
 hw/ppc/prep.c           | 10 +++++-----
 hw/ppc/spapr.c          |  6 +++---
 hw/sparc/sun4m.c        | 36 +++++++++++++++++-----------------
 include/sysemu/sysemu.h |  7 +++++++
 qemu-options.hx         | 15 ++++++++++++--
 vl.c                    |  3 +++
 14 files changed, 124 insertions(+), 76 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/9 sysemu: add defines for sparc & ppc graphics_*

Add defines for the sparc and ppc arch specific graphics defaults. They return the graphic_* values these variables are non-zero, and the default values otherwise.

After switching over ppc and sparc to use these we don't need the arch-specific initialization for the graphic_* variables any more.

---
 include/sysemu/sysemu.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/sysemu/sysemu.h +7 -0
index 576c7ce..9450788 100644
@@ -142,9 +142,16 @@ typedef enum {
 extern int vga_interface_type;
 #define xenfb_enabled (vga_interface_type == VGA_XENFB)
 
+#define sparc_graphic_width  (graphic_width  ? graphic_width  : 1024)
+#define sparc_graphic_height (graphic_height ? graphic_height :  768)
+#define sparc_graphic_depth  (graphic_depth  ? graphic_depth  :    8)
+#define ppc_graphic_width    (graphic_width  ? graphic_width  :  800)
+#define ppc_graphic_height   (graphic_height ? graphic_height :  600)
+#define ppc_graphic_depth    (graphic_depth  ? graphic_depth  :   32)
 extern int graphic_width;
 extern int graphic_height;
 extern int graphic_depth;
+
 extern int display_opengl;
 extern const char *keyboard_layout;
 extern int win2k_install_hack;
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/9] sysemu: add defines for sparc & ppc graphics_*

Quoted 17 lines · Gerd Hoffmann

Add defines for the sparc and ppc arch specific graphics defaults. They return the graphic_* values these variables are non-zero, and the default values otherwise.

After switching over ppc and sparc to use these we don't need the arch-specific initialization for the graphic_* variables any more.

---
 include/sysemu/sysemu.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/sysemu/sysemu.h +0 -0
index 576c7ce..9450788 100644

include/sysemu/sysemu.h typedef enum { · line 150

Quoted 9 lines
include/sysemu/sysemu.h +6 -0
@@ -142,9 +142,16 @@ typedef enum {
 extern int vga_interface_type;
 #define xenfb_enabled (vga_interface_type == VGA_XENFB)
 
+#define sparc_graphic_width  (graphic_width  ? graphic_width  : 1024)
+#define sparc_graphic_height (graphic_height ? graphic_height :  768)
+#define sparc_graphic_depth  (graphic_depth  ? graphic_depth  :    8)
+#define ppc_graphic_width    (graphic_width  ? graphic_width  :  800)
+#define ppc_graphic_height   (graphic_height ? graphic_height :  600)
+#define ppc_graphic_depth    (graphic_depth  ? graphic_depth  :   32)

I have to say that I really dislike the idea to hide this logic in such macros. Could we please do it without such macros, i.e. by just adding some code a la

	if (!graphic_width) {
		graphic_width = 800;
	}

to the right machine_init() functions instead?

Thomas

#3 lore raw

PATCH 2/9 sparc: use sparc_graphic_* defines

In reply to Gerd Hoffmann

This switches over sparc to use the new sparc_graphic_* defines.

---
 hw/sparc/sun4m.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
hw/sparc/sun4m.c +18 -18
index f5b6efd..1aaad68 100644
@@ -908,43 +908,43 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
     ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
                              slavio_irq[16], iommu, &ledma_irq, 1);
 
-    if (graphic_depth != 8 && graphic_depth != 24) {
-        error_report("Unsupported depth: %d", graphic_depth);
+    if (sparc_graphic_depth != 8 && sparc_graphic_depth != 24) {
+        error_report("Unsupported depth: %d", sparc_graphic_depth);
         exit (1);
     }
     num_vsimms = 0;
     if (num_vsimms == 0) {
         if (vga_interface_type == VGA_CG3) {
-            if (graphic_depth != 8) {
-                error_report("Unsupported depth: %d", graphic_depth);
+            if (sparc_graphic_depth != 8) {
+                error_report("Unsupported depth: %d", sparc_graphic_depth);
                 exit(1);
             }
 
-            if (!(graphic_width == 1024 && graphic_height == 768) &&
-                !(graphic_width == 1152 && graphic_height == 900)) {
-                error_report("Unsupported resolution: %d x %d", graphic_width,
-                             graphic_height);
+            if (!(sparc_graphic_width == 1024 && sparc_graphic_height == 768) &&
+                !(sparc_graphic_width == 1152 && sparc_graphic_height == 900)) {
+                error_report("Unsupported resolution: %d x %d", sparc_graphic_width,
+                             sparc_graphic_height);
                 exit(1);
             }
 
             /* sbus irq 5 */
             cg3_init(hwdef->tcx_base, slavio_irq[11], 0x00100000,
-                     graphic_width, graphic_height, graphic_depth);
+                     sparc_graphic_width, sparc_graphic_height, sparc_graphic_depth);
         } else {
             /* If no display specified, default to TCX */
-            if (graphic_depth != 8 && graphic_depth != 24) {
-                error_report("Unsupported depth: %d", graphic_depth);
+            if (sparc_graphic_depth != 8 && sparc_graphic_depth != 24) {
+                error_report("Unsupported depth: %d", sparc_graphic_depth);
                 exit(1);
             }
 
-            if (!(graphic_width == 1024 && graphic_height == 768)) {
+            if (!(sparc_graphic_width == 1024 && sparc_graphic_height == 768)) {
                 error_report("Unsupported resolution: %d x %d",
-                             graphic_width, graphic_height);
+                             sparc_graphic_width, sparc_graphic_height);
                 exit(1);
             }
 
             tcx_init(hwdef->tcx_base, slavio_irq[11], 0x00100000,
-                     graphic_width, graphic_height, graphic_depth);
+                     sparc_graphic_width, sparc_graphic_height, sparc_graphic_depth);
         }
     }
 
@@ -1025,7 +1025,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
 
     nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, machine->kernel_cmdline,
                machine->boot_order, machine->ram_size, kernel_size,
-               graphic_width, graphic_height, graphic_depth,
+               sparc_graphic_width, sparc_graphic_height, sparc_graphic_depth,
                hwdef->nvram_machine_id, "Sun4m");
 
     if (hwdef->ecc_base)
@@ -1037,9 +1037,9 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
     fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
     fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
     fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_WIDTH, graphic_width);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_HEIGHT, graphic_height);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, sparc_graphic_depth);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_WIDTH, sparc_graphic_width);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_HEIGHT, sparc_graphic_height);
     fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
     fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
     if (machine->kernel_cmdline) {
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 3/9 ppc: use ppc_graphic_* defines

In reply to Gerd Hoffmann

This switches over ppc to use the new ppc_graphic_* defines.

---
 hw/ppc/mac_newworld.c |  6 +++---
 hw/ppc/mac_oldworld.c |  6 +++---
 hw/ppc/prep.c         | 10 +++++-----
 hw/ppc/spapr.c        |  6 +++---
 4 files changed, 14 insertions(+), 14 deletions(-)
hw/ppc/mac_newworld.c +3 -3
index 2bfdb64..4722277 100644
@@ -482,9 +482,9 @@ static void ppc_core99_init(MachineState *machine)
     fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device);
 
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, ppc_graphic_width);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, ppc_graphic_height);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, ppc_graphic_depth);
 
     fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
     if (kvm_enabled()) {
hw/ppc/mac_oldworld.c +3 -3
index 56282c5..a79f011 100644
@@ -335,9 +335,9 @@ static void ppc_heathrow_init(MachineState *machine)
     fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device);
 
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, ppc_graphic_width);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, ppc_graphic_height);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, ppc_graphic_depth);
 
     fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
     if (kvm_enabled()) {
hw/ppc/prep.c +5 -5
index ca7959c..82bf6b5 100644
@@ -677,7 +677,7 @@ static void ppc_prep_init(MachineState *machine)
                          initrd_base, initrd_size,
                          /* XXX: need an option to load a NVRAM image */
                          0,
-                         graphic_width, graphic_height, graphic_depth);
+                         ppc_graphic_width, ppc_graphic_height, ppc_graphic_depth);
 }
 
 static void prep_machine_init(MachineClass *mc)
@@ -861,9 +861,9 @@ static void ibm_40p_init(MachineState *machine)
     fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size);
     fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_PREP);
 
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, ppc_graphic_width);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, ppc_graphic_height);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, ppc_graphic_depth);
 
     fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
     if (kvm_enabled()) {
@@ -891,7 +891,7 @@ static void ibm_40p_init(MachineState *machine)
                              initrd_base, initrd_size,
                              /* XXX: need an option to load a NVRAM image */
                              0,
-                             graphic_width, graphic_height, graphic_depth);
+                             ppc_graphic_width, ppc_graphic_height, ppc_graphic_depth);
     }
 }
 
hw/ppc/spapr.c +3 -3
index e465d7a..ba8f81e 100644
@@ -824,9 +824,9 @@ static void spapr_dt_chosen(sPAPRMachineState *spapr, void *fdt)
     if (boot_menu) {
         _FDT((fdt_setprop_cell(fdt, chosen, "qemu,boot-menu", boot_menu)));
     }
-    _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-width", graphic_width));
-    _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-height", graphic_height));
-    _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-depth", graphic_depth));
+    _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-width", ppc_graphic_width));
+    _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-height", ppc_graphic_height));
+    _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-depth", ppc_graphic_depth));
 
     if (cb && bootlist) {
         int i;
Signature · 1 line
1.8.3.1
Reviewed-by on v1 3/9
#5 lore raw

Re: [Qemu-devel] [PATCH 3/9] ppc: use ppc_graphic_* defines

Quoted 9 lines · Gerd Hoffmann

This switches over ppc to use the new ppc_graphic_* defines.

---
 hw/ppc/mac_newworld.c |  6 +++---
 hw/ppc/mac_oldworld.c |  6 +++---
 hw/ppc/prep.c         | 10 +++++-----
 hw/ppc/spapr.c        |  6 +++---
 4 files changed, 14 insertions(+), 14 deletions(-)
Reviewed-by on v1 3/9
#6 lore raw

Re: [Qemu-devel] [PATCH 3/9] ppc: use ppc_graphic_* defines

In reply to Gerd Hoffmann
Quoted 3 lines · Gerd Hoffmann

This switches over ppc to use the new ppc_graphic_* defines.

Of course, the idea of a per-arch, rather than per-machine, default graphics size is nuts, but this change doesn't make it any worse than it already is.

Quoted 93 lines
---
 hw/ppc/mac_newworld.c |  6 +++---
 hw/ppc/mac_oldworld.c |  6 +++---
 hw/ppc/prep.c         | 10 +++++-----
 hw/ppc/spapr.c        |  6 +++---
 4 files changed, 14 insertions(+), 14 deletions(-)
hw/ppc/mac_newworld.c +3 -3
index 2bfdb64..4722277 100644
@@ -482,9 +482,9 @@ static void ppc_core99_init(MachineState *machine)
     fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device);
 
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, ppc_graphic_width);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, ppc_graphic_height);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, ppc_graphic_depth);
 
     fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
     if (kvm_enabled()) {
hw/ppc/mac_oldworld.c +3 -3
index 56282c5..a79f011 100644
@@ -335,9 +335,9 @@ static void ppc_heathrow_init(MachineState *machine)
     fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device);
 
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, ppc_graphic_width);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, ppc_graphic_height);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, ppc_graphic_depth);
 
     fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
     if (kvm_enabled()) {
hw/ppc/prep.c +5 -5
index ca7959c..82bf6b5 100644
@@ -677,7 +677,7 @@ static void ppc_prep_init(MachineState *machine)
                          initrd_base, initrd_size,
                          /* XXX: need an option to load a NVRAM image */
                          0,
-                         graphic_width, graphic_height, graphic_depth);
+                         ppc_graphic_width, ppc_graphic_height, ppc_graphic_depth);
 }
 
 static void prep_machine_init(MachineClass *mc)
@@ -861,9 +861,9 @@ static void ibm_40p_init(MachineState *machine)
     fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size);
     fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_PREP);
 
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, ppc_graphic_width);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, ppc_graphic_height);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, ppc_graphic_depth);
 
     fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
     if (kvm_enabled()) {
@@ -891,7 +891,7 @@ static void ibm_40p_init(MachineState *machine)
                              initrd_base, initrd_size,
                              /* XXX: need an option to load a NVRAM image */
                              0,
-                             graphic_width, graphic_height, graphic_depth);
+                             ppc_graphic_width, ppc_graphic_height, ppc_graphic_depth);
     }
 }
 
hw/ppc/spapr.c +3 -3
index e465d7a..ba8f81e 100644
@@ -824,9 +824,9 @@ static void spapr_dt_chosen(sPAPRMachineState *spapr, void *fdt)
     if (boot_menu) {
         _FDT((fdt_setprop_cell(fdt, chosen, "qemu,boot-menu", boot_menu)));
     }
-    _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-width", graphic_width));
-    _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-height", graphic_height));
-    _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-depth", graphic_depth));
+    _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-width", ppc_graphic_width));
+    _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-height", ppc_graphic_height));
+    _FDT(fdt_setprop_cell(fdt, chosen, "qemu,graphic-depth", ppc_graphic_depth));
 
     if (cb && bootlist) {
         int i;
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#7 lore raw

PATCH 4/9 drop arch-specific graphic_* initialization.

In reply to Gerd Hoffmann

Now that sparc and ppc can deal with uninitialized graphic_* variables we can drop the #ifdefs and also move the variables out of arch_init.c as they are not arch specific any more.

---
 arch_init.c | 11 -----------
 vl.c        |  3 +++
 2 files changed, 3 insertions(+), 11 deletions(-)
arch_init.c +0 -11
index 0810116..f41af1c 100644
@@ -34,17 +34,6 @@
 #include "hw/acpi/acpi.h"
 #include "qemu/help_option.h"
 
-#ifdef TARGET_SPARC
-int graphic_width = 1024;
-int graphic_height = 768;
-int graphic_depth = 8;
-#else
-int graphic_width = 800;
-int graphic_height = 600;
-int graphic_depth = 32;
-#endif
-
-
 #if defined(TARGET_ALPHA)
 #define QEMU_ARCH QEMU_ARCH_ALPHA
 #elif defined(TARGET_ARM)
vl.c +3 -0
index 27d9829..3be883e 100644
@@ -135,6 +135,9 @@ const char *bios_name = NULL;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 int request_opengl = -1;
 int display_opengl;
+int graphic_width;
+int graphic_height;
+int graphic_depth;
 const char* keyboard_layout = NULL;
 ram_addr_t ram_size;
 const char *mem_path = NULL;
Signature · 1 line
1.8.3.1
#8 lore raw

PATCH 5/9 enable -g command line switch for all archs

In reply to Gerd Hoffmann

Virtual display adapters will learn to use graphic_* variables (which are set by the -g switch), so enable this for all archs.

RfC: Maybe restrict to PCI-capable archs?
Or would that be pretty much anything anyway?

---
 qemu-options.hx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qemu-options.hx +1 -1
index 809b2b0..4e89610 100644
@@ -1237,7 +1237,7 @@ ETEXI
 
 DEF("g", 1, QEMU_OPTION_g ,
     "-g WxH[xDEPTH]  Set the initial graphical resolution and depth\n",
-    QEMU_ARCH_PPC | QEMU_ARCH_SPARC)
+    QEMU_ARCH_ALL)
 STEXI
 @item -g @var{width}x@var{height}[x@var{depth}]
 @findex -g
Signature · 1 line
1.8.3.1
#9 lore raw

Re: [Qemu-devel] [PATCH 5/9] enable -g command line switch for all archs

Quoted 5 lines · Gerd Hoffmann

Virtual display adapters will learn to use graphic_* variables (which are set by the -g switch), so enable this for all archs.

RfC: Maybe restrict to PCI-capable archs?
Or would that be pretty much anything anyway?

I think there could also be systems without PCI, but with graphics card, so limiting it to PCI-capable systems seems also wrong to me.

Thomas

#10 lore raw

PATCH 6/9 virtio-gpu: use graphic_* variables.

In reply to Gerd Hoffmann

If graphic_* variables are set (via -g switch), pass on that information to the guest so the driver can use it.

---
 hw/display/virtio-gpu.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
hw/display/virtio-gpu.c +7 -2
index 9b530ab..04ba221 100644
@@ -1170,8 +1170,13 @@ static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
     virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU,
                 g->config_size);
 
-    g->req_state[0].width = 1024;
-    g->req_state[0].height = 768;
+    if (graphic_width && graphic_height) {
+        g->req_state[0].width = graphic_width;
+        g->req_state[0].height = graphic_height;
+    } else {
+        g->req_state[0].width = 1024;
+        g->req_state[0].height = 768;
+    }
 
     if (virtio_gpu_virgl_enabled(g->conf)) {
         /* use larger control queue in 3d mode */
Signature · 1 line
1.8.3.1
#11 lore raw

Re: [Qemu-devel] [PATCH 6/9] virtio-gpu: use graphic_* variables.

Quoted 15 lines · Gerd Hoffmann

If graphic_* variables are set (via -g switch), pass on that information to the guest so the driver can use it.

---
 hw/display/virtio-gpu.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
hw/display/virtio-gpu.c +0 -0
index 9b530ab..04ba221 100644
@@ -1170,8 +1170,13 @@ static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
     virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU,
                 g->config_size);

hw/display/virtio-gpu.c static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) · line 1179

Quoted 10 lines
hw/display/virtio-gpu.c +7 -2
 
-    g->req_state[0].width = 1024;
-    g->req_state[0].height = 768;
+    if (graphic_width && graphic_height) {
+        g->req_state[0].width = graphic_width;
+        g->req_state[0].height = graphic_height;
+    } else {
+        g->req_state[0].width = 1024;
+        g->req_state[0].height = 768;
+    }

What about adding properties for this, and only using graphic_* as a fallback?

Paolo

Quoted 3 lines
hw/display/virtio-gpu.c +0 -0
     if (virtio_gpu_virgl_enabled(g->conf)) {
         /* use larger control queue in 3d mode */
 
#12 lore raw

Re: [Qemu-devel] [PATCH 6/9] virtio-gpu: use graphic_* variables.

Hi,

Quoted 10 lines

hw/display/virtio-gpu.c static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) · line 1179

Quoted 7 lines
hw/display/virtio-gpu.c +7 -0
+    if (graphic_width && graphic_height) {
+        g->req_state[0].width = graphic_width;
+        g->req_state[0].height = graphic_height;
+    } else {
+        g->req_state[0].width = 1024;
+        g->req_state[0].height = 768;
+    }

What about adding properties for this, and only using graphic_* as a fallback?

Hmm, I guess in that case I'd prefer to not use graphic_* at all ...

cheers,
Gerd

#13 lore raw

PATCH 7/9 qxl: use graphic_* variables.

In reply to Gerd Hoffmann

If graphic_* variables are set (via -g switch), pass on that information to the guest so the driver can use it.

Also move up qxl_crc32() function so we don't need a forward declaration.

Additionally guest driver updates are needed so the guest driver will actually pick this up, which will probably land in linux kernel 4.12.

---
 hw/display/qxl.c | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)
hw/display/qxl.c +22 -10
index af4c0ca..37c84a8 100644
@@ -304,6 +304,16 @@ void qxl_spice_reset_cursor(PCIQXLDevice *qxl)
     qxl->ssd.cursor = cursor_builtin_hidden();
 }
 
+static uint32_t qxl_crc32(const uint8_t *p, unsigned len)
+{
+    /*
+     * zlib xors the seed with 0xffffffff, and xors the result
+     * again with 0xffffffff; Both are not done with linux's crc32,
+     * which we want to be compatible with, so undo that.
+     */
+    return crc32(0xffffffff, p, len) ^ 0xffffffff;
+}
+
 static ram_addr_t qxl_rom_size(void)
 {
 #define QXL_REQUIRED_SZ (sizeof(QXLRom) + sizeof(QXLModes) + sizeof(qxl_modes))
@@ -368,6 +378,18 @@ static void init_qxl_rom(PCIQXLDevice *d)
     rom->num_pages          = cpu_to_le32(num_pages);
     rom->ram_header_offset  = cpu_to_le32(d->vga.vram_size - ram_header_size);
 
+    if (graphic_width && graphic_height) {
+        /* needs linux kernel 4.12+ to work */
+        rom->client_monitors_config.count = 1;
+        rom->client_monitors_config.heads[0].left = 0;
+        rom->client_monitors_config.heads[0].top = 0;
+        rom->client_monitors_config.heads[0].right = cpu_to_le32(graphic_width);
+        rom->client_monitors_config.heads[0].bottom = cpu_to_le32(graphic_height);
+        rom->client_monitors_config_crc = qxl_crc32(
+            (const uint8_t *)&rom->client_monitors_config,
+            sizeof(rom->client_monitors_config));
+    }
+
     d->shadow_rom = *rom;
     d->rom        = rom;
     d->modes      = modes;
@@ -981,16 +1003,6 @@ static void interface_set_client_capabilities(QXLInstance *sin,
     qxl_send_events(qxl, QXL_INTERRUPT_CLIENT);
 }
 
-static uint32_t qxl_crc32(const uint8_t *p, unsigned len)
-{
-    /*
-     * zlib xors the seed with 0xffffffff, and xors the result
-     * again with 0xffffffff; Both are not done with linux's crc32,
-     * which we want to be compatible with, so undo that.
-     */
-    return crc32(0xffffffff, p, len) ^ 0xffffffff;
-}
-
 static bool qxl_rom_monitors_config_changed(QXLRom *rom,
         VDAgentMonitorsConfig *monitors_config,
         unsigned int max_outputs)
Signature · 1 line
1.8.3.1
#14 lore raw

Re: [Qemu-devel] [PATCH 7/9] qxl: use graphic_* variables.

hw/display/qxl.c static void init_qxl_rom(PCIQXLDevice *d) · line 392

Quoted 13 lines · Gerd Hoffmann
hw/display/qxl.c +12 -0
+    if (graphic_width && graphic_height) {
+        /* needs linux kernel 4.12+ to work */
+        rom->client_monitors_config.count = 1;
+        rom->client_monitors_config.heads[0].left = 0;
+        rom->client_monitors_config.heads[0].top = 0;
+        rom->client_monitors_config.heads[0].right = cpu_to_le32(graphic_width);
+        rom->client_monitors_config.heads[0].bottom = cpu_to_le32(graphic_height);
+        rom->client_monitors_config_crc = qxl_crc32(
+            (const uint8_t *)&rom->client_monitors_config,
+            sizeof(rom->client_monitors_config));
+    }
+

Same here.

Paolo

#15 lore raw

PATCH 8/9 update -g command line switch documentation

In reply to Gerd Hoffmann

Bring documentation in line with the recent changes. Text suggested by László Érsek.

---
 qemu-options.hx | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
qemu-options.hx +12 -1
index 4e89610..ae62e0d 100644
@@ -1241,7 +1241,18 @@ DEF("g", 1, QEMU_OPTION_g ,
 STEXI
 @item -g @var{width}x@var{height}[x@var{depth}]
 @findex -g
-Set the initial graphical resolution and depth (PPC, SPARC only).
+Set the initial graphical resolution and depth.
+
+This setting may be masked by guest firmware temporarily.
+
+On PPC and SPARC, the guest firmware will configure the display from
+this setting, and the guest OS will inherit the display resolution
+and depth.
+
+On x86 and ARM, if the guest firmware is an edk2 (UEFI) platform,
+the firmware may initially configure the display according to its own,
+persistent, independent settings. The guest OS drivers, once loaded,
+should adhere to "-g" however, for virtio and qxl adapters.
 ETEXI
 
 DEF("vnc", HAS_ARG, QEMU_OPTION_vnc ,
Signature · 1 line
1.8.3.1
Reviewed-by on v1 8/9
#16 lore raw

Re: [Qemu-devel] [PATCH 8/9] update -g command line switch documentation

Quoted 19 lines · Gerd Hoffmann

Bring documentation in line with the recent changes. Text suggested by László Érsek.

---
 qemu-options.hx | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
qemu-options.hx +2 -1
index 4e89610..ae62e0d 100644
@@ -1241,7 +1241,18 @@ DEF("g", 1, QEMU_OPTION_g ,
 STEXI
 @item -g @var{width}x@var{height}[x@var{depth}]
 @findex -g
-Set the initial graphical resolution and depth (PPC, SPARC only).
+Set the initial graphical resolution and depth.
+

qemu-options.hx DEF("g", 1, QEMU_OPTION_g , · line 1255

Quoted 10 lines
qemu-options.hx +10 -0
+This setting may be masked by guest firmware temporarily.
+
+On PPC and SPARC, the guest firmware will configure the display from
+this setting, and the guest OS will inherit the display resolution
+and depth.
+
+On x86 and ARM, if the guest firmware is an edk2 (UEFI) platform,
+the firmware may initially configure the display according to its own,
+persistent, independent settings. The guest OS drivers, once loaded,
+should adhere to "-g" however, for virtio and qxl adapters.

I think I made a small mistake here in my earlier suggestion; I think I should have restricted qxl to x86 only, something like:

... should adhere to "-g" however, for virtio (x86, ARM) and qxl (x86 only) adapters

Lest we appear to suggest that QXL will ever be available in aarch64 guests :)

qemu-options.hx DEF("g", 1, QEMU_OPTION_g , · line 1258

Quoted 4 lines
qemu-options.hx +0 -0
 ETEXI
 
 DEF("vnc", HAS_ARG, QEMU_OPTION_vnc ,

Looks good to me (and thank you for considering my response earlier). With the above tweak:

Furthermore, once patch #9 becomes a real patch, this documentation should be updated again, adding "VGA (x86 only)" as well.

Thanks!
Laszlo

#17 lore raw

RFC PATCH 9/9 stdvga: use graphic_* variables.

In reply to Gerd Hoffmann

Add two new registers to the qemu extended register range, carrying the suggested width and height of the display device. In case the graphic_* variables are set (via -g switch), fill these new registers accordingly.

Additionally guest driver updates are needed to support the new registers. These changes will probably land in linux kernel 4.12.

TODO: add compat properties to turn off qemu-display-size for machine

      types older than 2.9-or-10
---
 hw/display/vga-pci.c    | 52 ++++++++++++++++++++++++++++++++++---------------
 hw/display/vga_int.h    |  4 ++--
 hw/display/virtio-vga.c |  3 ++-
 3 files changed, 40 insertions(+), 19 deletions(-)
hw/display/vga-pci.c +36 -16
index ac9a764..78e00df 100644
@@ -31,23 +31,28 @@
 #include "ui/pixel_ops.h"
 #include "qemu/timer.h"
 #include "hw/loader.h"
+#include "sysemu/sysemu.h"
 
 #define PCI_VGA_IOPORT_OFFSET 0x400
 #define PCI_VGA_IOPORT_SIZE   (0x3e0 - 0x3c0)
 #define PCI_VGA_BOCHS_OFFSET  0x500
 #define PCI_VGA_BOCHS_SIZE    (0x0b * 2)
 #define PCI_VGA_QEXT_OFFSET   0x600
-#define PCI_VGA_QEXT_SIZE     (2 * 4)
+#define PCI_VGA_QEXT_SIZE_V1  (2 * 4)
+#define PCI_VGA_QEXT_SIZE_V2  (4 * 4)
 #define PCI_VGA_MMIO_SIZE     0x1000
 
 #define PCI_VGA_QEXT_REG_SIZE         (0 * 4)
 #define PCI_VGA_QEXT_REG_BYTEORDER    (1 * 4)
 #define  PCI_VGA_QEXT_LITTLE_ENDIAN   0x1e1e1e1e
 #define  PCI_VGA_QEXT_BIG_ENDIAN      0xbebebebe
+#define PCI_VGA_QEXT_REG_WIDTH        (2 * 4)
+#define PCI_VGA_QEXT_REG_HEIGHT       (3 * 4)
 
 enum vga_pci_flags {
-    PCI_VGA_FLAG_ENABLE_MMIO = 1,
-    PCI_VGA_FLAG_ENABLE_QEXT = 2,
+    PCI_VGA_FLAG_ENABLE_MMIO    = 1,
+    PCI_VGA_FLAG_ENABLE_QEXT    = 2,
+    PCI_VGA_FLAG_ENABLE_QEXT_V2 = 3,
 };
 
 typedef struct PCIVGAState {
@@ -157,10 +162,14 @@ static uint64_t pci_vga_qext_read(void *ptr, hwaddr addr, unsigned size)
 
     switch (addr) {
     case PCI_VGA_QEXT_REG_SIZE:
-        return PCI_VGA_QEXT_SIZE;
+        return s->qext_size;
     case PCI_VGA_QEXT_REG_BYTEORDER:
         return s->big_endian_fb ?
             PCI_VGA_QEXT_BIG_ENDIAN : PCI_VGA_QEXT_LITTLE_ENDIAN;
+    case PCI_VGA_QEXT_REG_WIDTH:
+        return graphic_width;
+    case PCI_VGA_QEXT_REG_HEIGHT:
+        return graphic_height;
     default:
         return 0;
     }
@@ -207,8 +216,7 @@ static const MemoryRegionOps pci_vga_qext_ops = {
 
 void pci_std_vga_mmio_region_init(VGACommonState *s,
                                   MemoryRegion *parent,
-                                  MemoryRegion *subs,
-                                  bool qext)
+                                  MemoryRegion *subs)
 {
     memory_region_init_io(&subs[0], NULL, &pci_vga_ioport_ops, s,
                           "vga ioports remapped", PCI_VGA_IOPORT_SIZE);
@@ -220,9 +228,9 @@ void pci_std_vga_mmio_region_init(VGACommonState *s,
     memory_region_add_subregion(parent, PCI_VGA_BOCHS_OFFSET,
                                 &subs[1]);
 
-    if (qext) {
+    if (s->qext_size) {
         memory_region_init_io(&subs[2], NULL, &pci_vga_qext_ops, s,
-                              "qemu extended regs", PCI_VGA_QEXT_SIZE);
+                              "qemu extended regs", s->qext_size);
         memory_region_add_subregion(parent, PCI_VGA_QEXT_OFFSET,
                                     &subs[2]);
     }
@@ -232,7 +240,6 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp)
 {
     PCIVGAState *d = PCI_VGA(dev);
     VGACommonState *s = &d->vga;
-    bool qext = false;
 
     /* vga + console init */
     vga_common_init(s, OBJECT(dev), true);
@@ -249,10 +256,15 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp)
         memory_region_init(&d->mmio, NULL, "vga.mmio", 4096);
 
         if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT)) {
-            qext = true;
-            pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
+            if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT_V2)) {
+                s->qext_size = PCI_VGA_QEXT_SIZE_V2;
+                pci_set_byte(&d->dev.config[PCI_REVISION_ID], 3);
+            } else {
+                s->qext_size = PCI_VGA_QEXT_SIZE_V1;
+                pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
+            }
         }
-        pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs, qext);
+        pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs);
 
         pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
     }
@@ -274,7 +286,6 @@ static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
 {
     PCIVGAState *d = PCI_VGA(dev);
     VGACommonState *s = &d->vga;
-    bool qext = false;
 
     /* vga + console init */
     vga_common_init(s, OBJECT(dev), false);
@@ -284,10 +295,15 @@ static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
     memory_region_init(&d->mmio, OBJECT(dev), "vga.mmio", 4096);
 
     if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT)) {
-        qext = true;
-        pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
+        if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT_V2)) {
+            s->qext_size = PCI_VGA_QEXT_SIZE_V2;
+            pci_set_byte(&d->dev.config[PCI_REVISION_ID], 3);
+        } else {
+            s->qext_size = PCI_VGA_QEXT_SIZE_V1;
+            pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
+        }
     }
-    pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs, qext);
+    pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs);
 
     pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
     pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
@@ -311,6 +327,8 @@ static Property vga_pci_properties[] = {
     DEFINE_PROP_BIT("mmio", PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_MMIO, true),
     DEFINE_PROP_BIT("qemu-extended-regs",
                     PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_QEXT, true),
+    DEFINE_PROP_BIT("qemu-display-size",
+                    PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_QEXT_V2, true),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -318,6 +336,8 @@ static Property secondary_pci_properties[] = {
     DEFINE_PROP_UINT32("vgamem_mb", PCIVGAState, vga.vram_size_mb, 16),
     DEFINE_PROP_BIT("qemu-extended-regs",
                     PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_QEXT, true),
+    DEFINE_PROP_BIT("qemu-display-size",
+                    PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_QEXT_V2, true),
     DEFINE_PROP_END_OF_LIST(),
 };
 
hw/display/vga_int.h +2 -2
index dd6c958..51217cf 100644
@@ -162,6 +162,7 @@ typedef struct VGACommonState {
     bool full_update_gfx;
     bool big_endian_fb;
     bool default_endian_fb;
+    uint32_t qext_size;
     /* hardware mouse cursor support */
     uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32];
     uint32_t hw_cursor_x;
@@ -223,7 +224,6 @@ extern const MemoryRegionOps vga_mem_ops;
 /* vga-pci.c */
 void pci_std_vga_mmio_region_init(VGACommonState *s,
                                   MemoryRegion *parent,
-                                  MemoryRegion *subs,
-                                  bool qext);
+                                  MemoryRegion *subs);
 
 #endif
hw/display/virtio-vga.c +2 -1
index f9b017d..8684dc0 100644
@@ -153,8 +153,9 @@ static void virtio_vga_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
     }
 
     /* add stdvga mmio regions */
+    vga->qext_size = 2 * 4; /* PCI_VGA_QEXT_SIZE_V1 */
     pci_std_vga_mmio_region_init(vga, &vpci_dev->modern_bar,
-                                 vvga->vga_mrs, true);
+                                 vvga->vga_mrs);
 
     vga->con = g->scanout[0].con;
     graphic_console_set_hwops(vga->con, &virtio_vga_ops, vvga);
Signature · 1 line
1.8.3.1
#18 lore raw
In reply to Gerd Hoffmann
Quoted 7 lines · Gerd Hoffmann

Hi,

Made a nice patch series out of it, first cleaning up graphics_* variables, then adding support for -g to virtio (just works), qxl (needs guest driver fixes) and stdvga (needs virtual hardware update, and therefore also an guest driver update for obvious reasons).

Quoted 5 lines

linux kernel patches to test qxl and stdvga are here:
https://www.kraxel.org/cgit/linux/log/?h=qxl-display-size

please review & test,
Gerd

Interestingly enough, there have been recent discussions from the guys over at emaculation as to whether it would be possible to pass in valid resolutions from the host graphics driver for full-screen MacOS 9 emulation in QEMU.

With this patchset I believe Ben's OS 9 VGA driver could read the suggested resolution from the command line via the QEMU extended VGA registers, so I'm wondering if it would make sense to have a similar mechanism for passing in a range of resolutions from the local video driver that could be offered by the guest driver? Or is the normal guest driver behaviour to just offer the standard set of *GA resolutions plus whatever custom resolution is supplied via -g?

ATB,

Mark.

#19 lore raw

Hi,

Quoted 3 lines

With this patchset I believe Ben's OS 9 VGA driver could read the suggested resolution from the command line via the QEMU extended VGA registers,

Yes.

Quoted 5 lines

so I'm wondering if it would make sense to have a similar mechanism for passing in a range of resolutions from the local video driver that could be offered by the guest driver? Or is the normal guest driver behaviour to just offer the standard set of *GA resolutions plus whatever custom resolution is supplied via -g?

The linux kms drivers simply use the kernel's mode database, to provide a list of standard resolutions. Additionally you also can define your own resolutions, using xrandr --newmode & --addmode).

If we want go beyond passing a simple "please use <width>y<height>" we probably should generate a edid block and pass that to the guest, but I don't see a strong reason to do so.

cheers,
Gerd