diff mbox series

hw/display/virtio-vga: made vga memory size configurable

Message ID 20210314122314.3201195-1-vitaly@cyberhaven.com (mailing list archive)
State New, archived
Headers show
Series hw/display/virtio-vga: made vga memory size configurable | expand

Commit Message

Vitaly Chipounov March 14, 2021, 12:23 p.m. UTC
From: Vitaly Chipounov <vitaly@cyberhaven.com>

This enables higher resolutions. The default is still 8MB for
backwards compatibility with existing snapshots.

The property name "vgamem_fb" is similar to that of the other
graphic adapters.

seabios/vgasrc/svgamodes.c needs to be updated as well.
For example, adding the following line would expose
a 3840x2160 resolution to the guest.

{ 0x199, { MM_DIRECT, 3840, 2160, 32, 8, 16, SEG_GRAPH } },

Signed-off-by: Vitaly Chipounov <vitaly@cyberhaven.com>
---
 hw/display/virtio-vga.c | 3 ++-
 hw/virtio/virtio-pci.h  | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

BALATON Zoltan March 14, 2021, 12:45 p.m. UTC | #1
On Sun, 14 Mar 2021, vitaly@cyberhaven.com wrote:
> From: Vitaly Chipounov <vitaly@cyberhaven.com>
>
> This enables higher resolutions. The default is still 8MB for
> backwards compatibility with existing snapshots.
>
> The property name "vgamem_fb" is similar to that of the other

Isn't that vgamem_mb? Code has that so it's just a typo in commit message.

Regards,
BALATON Zoltan

> graphic adapters.
>
> seabios/vgasrc/svgamodes.c needs to be updated as well.
> For example, adding the following line would expose
> a 3840x2160 resolution to the guest.
>
> { 0x199, { MM_DIRECT, 3840, 2160, 32, 8, 16, SEG_GRAPH } },
>
> Signed-off-by: Vitaly Chipounov <vitaly@cyberhaven.com>
> ---
> hw/display/virtio-vga.c | 3 ++-
> hw/virtio/virtio-pci.h  | 2 ++
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
> index d3c6404061..657fafc48f 100644
> --- a/hw/display/virtio-vga.c
> +++ b/hw/display/virtio-vga.c
> @@ -118,7 +118,7 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
>     int i;
>
>     /* init vga compat bits */
> -    vga->vram_size_mb = 8;
> +    vga->vram_size_mb = vpci_dev->vgamem_size_mb;
>     vga_common_init(vga, OBJECT(vpci_dev));
>     vga_init(vga, OBJECT(vpci_dev), pci_address_space(&vpci_dev->pci_dev),
>              pci_address_space_io(&vpci_dev->pci_dev), true);
> @@ -204,6 +204,7 @@ static void virtio_vga_set_big_endian_fb(Object *obj, bool value, Error **errp)
>
> static Property virtio_vga_base_properties[] = {
>     DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
> +    DEFINE_PROP_UINT32("vgamem_mb", VirtIOPCIProxy, vgamem_size_mb, 8),
>     DEFINE_PROP_END_OF_LIST(),
> };
>
> diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
> index d7d5d403a9..8684311a8d 100644
> --- a/hw/virtio/virtio-pci.h
> +++ b/hw/virtio/virtio-pci.h
> @@ -151,6 +151,8 @@ struct VirtIOPCIProxy {
>     VirtIOIRQFD *vector_irqfd;
>     int nvqs_with_notifiers;
>     VirtioBusState bus;
> +
> +    uint32_t vgamem_size_mb;
> };
>
> static inline bool virtio_pci_modern(VirtIOPCIProxy *proxy)
>
Vitaly Chipounov March 14, 2021, 12:50 p.m. UTC | #2
Yes, it's a typo in the commit message, sorry.

Vitaly

On 3/14/21 1:45 PM, BALATON Zoltan wrote:
> On Sun, 14 Mar 2021, vitaly@cyberhaven.com wrote:
>> From: Vitaly Chipounov <vitaly@cyberhaven.com>
>>
>> This enables higher resolutions. The default is still 8MB for
>> backwards compatibility with existing snapshots.
>>
>> The property name "vgamem_fb" is similar to that of the other
>
> Isn't that vgamem_mb? Code has that so it's just a typo in commit 
> message.
>
> Regards,
> BALATON Zoltan
>
>> graphic adapters.
>>
>> seabios/vgasrc/svgamodes.c needs to be updated as well.
>> For example, adding the following line would expose
>> a 3840x2160 resolution to the guest.
>>
>> { 0x199, { MM_DIRECT, 3840, 2160, 32, 8, 16, SEG_GRAPH } },
>>
>> Signed-off-by: Vitaly Chipounov <vitaly@cyberhaven.com>
>> ---
>> hw/display/virtio-vga.c | 3 ++-
>> hw/virtio/virtio-pci.h  | 2 ++
>> 2 files changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
>> index d3c6404061..657fafc48f 100644
>> --- a/hw/display/virtio-vga.c
>> +++ b/hw/display/virtio-vga.c
>> @@ -118,7 +118,7 @@ static void 
>> virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
>>     int i;
>>
>>     /* init vga compat bits */
>> -    vga->vram_size_mb = 8;
>> +    vga->vram_size_mb = vpci_dev->vgamem_size_mb;
>>     vga_common_init(vga, OBJECT(vpci_dev));
>>     vga_init(vga, OBJECT(vpci_dev), 
>> pci_address_space(&vpci_dev->pci_dev),
>>              pci_address_space_io(&vpci_dev->pci_dev), true);
>> @@ -204,6 +204,7 @@ static void virtio_vga_set_big_endian_fb(Object 
>> *obj, bool value, Error **errp)
>>
>> static Property virtio_vga_base_properties[] = {
>>     DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
>> +    DEFINE_PROP_UINT32("vgamem_mb", VirtIOPCIProxy, vgamem_size_mb, 8),
>>     DEFINE_PROP_END_OF_LIST(),
>> };
>>
>> diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
>> index d7d5d403a9..8684311a8d 100644
>> --- a/hw/virtio/virtio-pci.h
>> +++ b/hw/virtio/virtio-pci.h
>> @@ -151,6 +151,8 @@ struct VirtIOPCIProxy {
>>     VirtIOIRQFD *vector_irqfd;
>>     int nvqs_with_notifiers;
>>     VirtioBusState bus;
>> +
>> +    uint32_t vgamem_size_mb;
>> };
>>
>> static inline bool virtio_pci_modern(VirtIOPCIProxy *proxy)
>>
Gerd Hoffmann March 15, 2021, 7:21 a.m. UTC | #3
On Sun, Mar 14, 2021 at 01:23:14PM +0100, vitaly@cyberhaven.com wrote:
> From: Vitaly Chipounov <vitaly@cyberhaven.com>
> 
> This enables higher resolutions.

No.  virtio-vga supports higher resolutions just fine once the guest
driver is loaded.  The video memory is used at boot only, before the
guest driver is loaded, and 8MB just for a boot display is more than
generous.

If your guest has no virtio driver use stdvga instead of running
virtio-vga permanently in vga compatibility mode.

take care,
  Gerd
Vitaly Chipounov March 15, 2021, 11:29 a.m. UTC | #4
On Mon, Mar 15, 2021 at 8:21 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> On Sun, Mar 14, 2021 at 01:23:14PM +0100, vitaly@cyberhaven.com wrote:
> > From: Vitaly Chipounov <vitaly@cyberhaven.com>
> >
> > This enables higher resolutions.
>
> No.  virtio-vga supports higher resolutions just fine once the guest
> driver is loaded.  The video memory is used at boot only, before the
> guest driver is loaded, and 8MB just for a boot display is more than
> generous.
>
> If your guest has no virtio driver use stdvga instead of running
> virtio-vga permanently in vga compatibility mode.

I tried -device VGA,vgamem_mb=32. I did not see any resolution above
1080p on a Windows 10 guest.
virtio-vga has many more resolutions available, it was just missing 4k.
I have the virtio-win-0.1.190 driver pack installed.
I don't use qxl, because it makes the Windows GUI sluggish for me. I
don't have problems with VGA or virtio-vga.

Best regards,
Vitaly
Gerd Hoffmann March 15, 2021, 3:24 p.m. UTC | #5
On Mon, Mar 15, 2021 at 12:29:16PM +0100, Vitaly Chipounov wrote:
> On Mon, Mar 15, 2021 at 8:21 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
> >
> > On Sun, Mar 14, 2021 at 01:23:14PM +0100, vitaly@cyberhaven.com wrote:
> > > From: Vitaly Chipounov <vitaly@cyberhaven.com>
> > >
> > > This enables higher resolutions.
> >
> > No.  virtio-vga supports higher resolutions just fine once the guest
> > driver is loaded.  The video memory is used at boot only, before the
> > guest driver is loaded, and 8MB just for a boot display is more than
> > generous.
> >
> > If your guest has no virtio driver use stdvga instead of running
> > virtio-vga permanently in vga compatibility mode.
> 
> I tried -device VGA,vgamem_mb=32. I did not see any resolution above
> 1080p on a Windows 10 guest.

Try "-device VGA,vgamem_mb=32,edid=off".  Windows seems to not like our
edid block for some reason.

take care,
  Gerd
Vitaly Chipounov March 16, 2021, 7:51 p.m. UTC | #6
On Mon, Mar 15, 2021 at 4:24 PM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> On Mon, Mar 15, 2021 at 12:29:16PM +0100, Vitaly Chipounov wrote:
> > On Mon, Mar 15, 2021 at 8:21 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
> > >
> > > If your guest has no virtio driver use stdvga instead of running
> > > virtio-vga permanently in vga compatibility mode.
> >
> > I tried -device VGA,vgamem_mb=32. I did not see any resolution above
> > 1080p on a Windows 10 guest.
>
> Try "-device VGA,vgamem_mb=32,edid=off".  Windows seems to not like our
> edid block for some reason.
>

This worked, thanks for the tip. Regarding the patch, I can resubmit
it with an amended commit message if people think it's still better to
have a configurable memory size here.

Vitaly
Gerd Hoffmann March 17, 2021, 6:45 a.m. UTC | #7
On Tue, Mar 16, 2021 at 08:51:21PM +0100, Vitaly Chipounov wrote:
> On Mon, Mar 15, 2021 at 4:24 PM Gerd Hoffmann <kraxel@redhat.com> wrote:
> >
> > On Mon, Mar 15, 2021 at 12:29:16PM +0100, Vitaly Chipounov wrote:
> > > On Mon, Mar 15, 2021 at 8:21 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
> > > >
> > > > If your guest has no virtio driver use stdvga instead of running
> > > > virtio-vga permanently in vga compatibility mode.
> > >
> > > I tried -device VGA,vgamem_mb=32. I did not see any resolution above
> > > 1080p on a Windows 10 guest.
> >
> > Try "-device VGA,vgamem_mb=32,edid=off".  Windows seems to not like our
> > edid block for some reason.
> >
> 
> This worked, thanks for the tip. Regarding the patch, I can resubmit
> it with an amended commit message if people think it's still better to
> have a configurable memory size here.

Given that the vram is used for vga compatibility only and not used any
more once the virtio-gpu driver initialized the device I don't think
this should be configurable.

take care,
  Gerd
diff mbox series

Patch

diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
index d3c6404061..657fafc48f 100644
--- a/hw/display/virtio-vga.c
+++ b/hw/display/virtio-vga.c
@@ -118,7 +118,7 @@  static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
     int i;
 
     /* init vga compat bits */
-    vga->vram_size_mb = 8;
+    vga->vram_size_mb = vpci_dev->vgamem_size_mb;
     vga_common_init(vga, OBJECT(vpci_dev));
     vga_init(vga, OBJECT(vpci_dev), pci_address_space(&vpci_dev->pci_dev),
              pci_address_space_io(&vpci_dev->pci_dev), true);
@@ -204,6 +204,7 @@  static void virtio_vga_set_big_endian_fb(Object *obj, bool value, Error **errp)
 
 static Property virtio_vga_base_properties[] = {
     DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
+    DEFINE_PROP_UINT32("vgamem_mb", VirtIOPCIProxy, vgamem_size_mb, 8),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
index d7d5d403a9..8684311a8d 100644
--- a/hw/virtio/virtio-pci.h
+++ b/hw/virtio/virtio-pci.h
@@ -151,6 +151,8 @@  struct VirtIOPCIProxy {
     VirtIOIRQFD *vector_irqfd;
     int nvqs_with_notifiers;
     VirtioBusState bus;
+
+    uint32_t vgamem_size_mb;
 };
 
 static inline bool virtio_pci_modern(VirtIOPCIProxy *proxy)