[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] qemu: Support vram for video of qxl type



On Mon, Feb 21, 2011 at 06:17:25PM +0800, Osier Yang wrote:
> For qemu names the primary vga as "qxl-vga":
> 
>   1) if vram is specified for 2nd qxl device:
> 
>     -vga qxl -global qxl-vga.vram_size=$SIZE \
>     -device qxl,id=video1,vram_size=$SIZE,...
> 
>   2) if vram is not specified for 2nd qxl device, (use the default
>      set by global):
> 
>     -vga qxl -global qxl-vga.vram_size=$SIZE \
>     -device qxl,id=video1,...
> 
> For qemu names all qxl devices as "qxl":
> 
>   1) if vram is specified for 2nd qxl device:
> 
>     -vga qxl -global qxl.vram_size=$SIZE \
>     -device qxl,id=video1,vram_size=$SIZE ...
> 
>   2) if vram is not specified for 2nd qxl device:
> 
>     -vga qxl -global qxl-vga.vram_size=$SIZE \
>     -device qxl,id=video1,...
> 
> "-global" is the only way to define vram_size for the primary qxl
> device, regardless of how qemu names it, (It's not good a good
> way, as original idea of "-global" is to set a global default for
> a driver property, but to specify vram for first qxl device, we
> have to use it).
> 
> For other qxl devices, as they are represented by "-device", could
> specify it directly and seperately for each, and it overrides the
> default set by "-global" if specified.
> 
> ---
>  src/qemu/qemu_capabilities.c                       |    2 +
>  src/qemu/qemu_capabilities.h                       |    1 +
>  src/qemu/qemu_command.c                            |   16 +++++++++
>  tests/qemuhelptest.c                               |    1 +
>  .../qemuxml2argv-graphics-spice-qxl-vga.args       |    7 ++++
>  .../qemuxml2argv-graphics-spice-qxl-vga.xml        |   36 ++++++++++++++++++++
>  .../qemuxml2argv-graphics-spice.args               |    4 +-
>  tests/qemuxml2argvtest.c                           |    4 ++
>  tests/qemuxml2xmltest.c                            |    1 +
>  9 files changed, 70 insertions(+), 2 deletions(-)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 5f08a20..cce6b5f 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -1118,6 +1118,8 @@ qemuCapsParseDeviceStr(const char *str, unsigned long long *flags)
>      }
>      if (strstr(str, "virtio-net-pci.tx="))
>          *flags |= QEMUD_CMD_FLAG_VIRTIO_TX_ALG;
> +    if (strstr(str, "name \"qxl-vga\""))
> +        *flags |= QEMUD_CMD_FLAG_DEVICE_QXL_VGA;
> 
>      return 0;
>  }
> diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
> index 63cbbb3..f36c3ab 100644
> --- a/src/qemu/qemu_capabilities.h
> +++ b/src/qemu/qemu_capabilities.h
> @@ -93,6 +93,7 @@ enum qemuCapsFlags {
>      QEMUD_CMD_FLAG_CHARDEV_SPICEVMC = (1LL << 56), /* newer -chardev spicevmc */
>      QEMUD_CMD_FLAG_DEVICE_SPICEVMC = (1LL << 57), /* older -device spicevmc*/
>      QEMUD_CMD_FLAG_VIRTIO_TX_ALG = (1LL << 58), /* -device virtio-net-pci,tx=string */
> +    QEMUD_CMD_FLAG_DEVICE_QXL_VGA = (1LL << 59), /* Is the primary and vga compatible qxl device named qxl-vga? */
>  };
> 
>  virCapsPtr qemuCapsInit(virCapsPtr old_caps);
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 0db2843..c0bc343 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -1928,6 +1928,10 @@ qemuBuildVideoDevStr(virDomainVideoDefPtr video,
> 
>      virBufferVSprintf(&buf, "%s", model);
>      virBufferVSprintf(&buf, ",id=%s", video->info.alias);
> +
> +    if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL && video->vram)
> +        virBufferVSprintf(&buf, ",vram_size=%u", video->vram);
> +
>      if (qemuBuildDeviceAddressStr(&buf, &video->info, qemuCmdFlags) < 0)
>          goto error;
> 
> @@ -4023,6 +4027,18 @@ qemuBuildCommandLine(virConnectPtr conn,
>                  }
> 
>                  virCommandAddArgList(cmd, "-vga", vgastr, NULL);
> +
> +                if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
> +                    if (def->videos[0]->vram &&
> +                        (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
> +                            if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE_QXL_VGA)
> +                                virCommandAddArgFormat(cmd, "-global qxl-vga.vram_size=%u",
> +                                                       def->videos[0]->vram);
> +                            else
> +                                virCommandAddArgFormat(cmd, "-global qxl.vram_size=%u",
> +                                                       def->videos[0]->vram);
> +                    }
> +                }
>              }
>          } else {

This doesn't work correctly in the following scenario

   <video>
     <model type='qxl' vram='128'/>
   </video>
   <video>
     <model type='qxl'/>
   </video>

Because the -global arg for the first case will override the default VRAM
for the second card. So if we set vram for the first card, we must always
set vram for all other cards, even if it wasn't set in the XML for those
cards.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]