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

[libvirt] [PATCH 1/4] video: cleanup usage of vram attribute and update documentation



The vram attribute was introduced to set the video memory but it is
usable only for few hypervisors excluding QEMU/KVM. QEMU/KVM has
different attribute for this purpose "vgamem_mb" and it will be
introduced lately.

The correct usage of vram is to set the video memory for other
hypervisors or to set secondary bar size for QXL video device for
QEMU/KVM.

This patch updates the documentation to reflect current code in libvirt
and also changes the cases when we will set the default vram attribute.
It's pointless to set it for QEMU/KVM if you aren't using QXL as it
won't be used.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1076098

Signed-off-by: Pavel Hrdina <phrdina redhat com>
---
 docs/formatdomain.html.in | 61 +++++++++++++++++++++++++++++------------------
 src/conf/domain_conf.c    | 19 +++++++++++----
 src/conf/domain_conf.h    |  3 ++-
 src/qemu/qemu_command.c   |  4 ++--
 4 files changed, 57 insertions(+), 30 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0099ce7..24be21c 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4615,33 +4615,48 @@ qemu-kvm -net nic,model=? /dev/null
     <dl>
       <dt><code>video</code></dt>
       <dd>
-        The <code>video</code> element is the container for describing
-        video devices. For backwards compatibility, if no <code>video</code>
-        is set but there is a <code>graphics</code> in domain xml, then libvirt
-        will add a default <code>video</code> according to the guest type.
-        For a guest of type "kvm", the default <code>video</code> for it is:
-        <code>type</code> with value "cirrus", <code>vram</code> with value
-        "9216", and <code>heads</code> with value "1". By default, the first
-        video device in domain xml is the primary one, but the optional
-        attribute <code>primary</code> (<span class="since">since 1.0.2</span>)
-        with value 'yes' can be used to mark the primary in cases of multiple
-        video device. The non-primary must be type of "qxl". The optional
-        attribute <code>ram</code> (<span class="since">since
-        1.0.2</span>) is allowed for "qxl" type only and specifies
-        the size of the primary bar, while <code>vram</code> specifies the
-        secondary bar size.  If "ram" or "vram" are not supplied a default
-        value is used.
+        <p>
+          The <code>video</code> element is the container for describing
+          video devices. For backwards compatibility, if no <code>video</code>
+          is set but there is a <code>graphics</code> in domain xml, then
+          libvirt will add a default <code>video</code> according to the guest
+          type.
+        </p>
+        <p>
+          For a guest of type "kvm", the default <code>video</code> is:
+          <code>type</code> with value "cirrus" and <code>heads</code> with
+          value "1". By default, the first video device in domain xml is
+          the primary one, but the optional attribute <code>primary</code>
+          (<span class="since">since 1.0.2</span>) with value 'yes' can be used
+          to mark the primary in cases of multiple video device. The non-primary
+          must be type of "qxl".
+        </p>
       </dd>
 
       <dt><code>model</code></dt>
       <dd>
-        The <code>model</code> element has a mandatory <code>type</code>
-        attribute which takes the value "vga", "cirrus", "vmvga", "xen",
-        "vbox", or "qxl" (<span class="since">since 0.8.6</span>)
-        depending on the hypervisor features available.
-        You can also provide the amount of video memory in kibibytes
-        (blocks of 1024 bytes) using
-        <code>vram</code> and the number of screen with <code>heads</code>.
+        <p>
+          The <code>model</code> element has a mandatory <code>type</code>
+          attribute which takes the value "vga", "cirrus", "vmvga", "xen",
+          "vbox", or "qxl" (<span class="since">since 0.8.6</span>) depending
+          on the hypervisor features available.
+        </p>
+        <p>
+          You can provide the amount of video memory in kibibytes (blocks of
+          1024 bytes) using <code>vram</code>. This is supported only for guest
+          type of "libxl", "parallels", "vbox", "vmx" and "xen".
+        </p>
+        <p>
+          The number of screen can be set using <code>heads</code>. This is
+          supported only for guests type of "parallels", "kvm", "vbox" and "vmx".
+        </p>
+        <p>
+          For guest type of kvm the optional attribute <code>ram</code>
+          (<span class="since">since 1.0.2</span>) is allowed for "qxl" type
+          only and specifies the size of the primary bar, while the optional
+          attribute <code>vram</code> specifies the secondary bar size.
+          If "ram" or "vram" are not supplied a default value is used.
+        </p>
       </dd>
 
       <dt><code>acceleration</code></dt>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1b8efb1..042364a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9995,9 +9995,9 @@ virSysinfoParseXML(xmlNodePtr node,
     goto cleanup;
 }
 
-int
+unsigned int
 virDomainVideoDefaultRAM(const virDomainDef *def,
-                         int type)
+                         const virDomainVideoType type)
 {
     /* Defer setting default vram to the Xen drivers */
     if (def->virtType == VIR_DOMAIN_VIRT_XEN)
@@ -10174,11 +10174,22 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     if (vram) {
         if (virStrToLong_ui(vram, NULL, 10, &def->vram) < 0) {
             virReportError(VIR_ERR_XML_ERROR,
-                           _("cannot parse video ram '%s'"), vram);
+                           _("cannot parse video vram '%s'"), vram);
             goto error;
         }
     } else {
-        def->vram = virDomainVideoDefaultRAM(dom, def->type);
+        switch (dom->virtType) {
+        case VIR_DOMAIN_VIRT_QEMU:
+        case VIR_DOMAIN_VIRT_KQEMU:
+        case VIR_DOMAIN_VIRT_KVM:
+            break;
+        default:
+            def->vram = virDomainVideoDefaultRAM(dom, def->type);
+            break;
+        }
+
+        if (def->type == VIR_DOMAIN_VIDEO_TYPE_QXL)
+            def->vram = virDomainVideoDefaultRAM(dom, def->type);
     }
 
     if (heads) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index fbb3b2f..8aa000a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2599,7 +2599,8 @@ int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
 virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);
 
 int virDomainVideoDefaultType(const virDomainDef *def);
-int virDomainVideoDefaultRAM(const virDomainDef *def, int type);
+unsigned int virDomainVideoDefaultRAM(const virDomainDef *def,
+                                      const virDomainVideoType type);
 
 int virDomainObjListNumOfDomains(virDomainObjListPtr doms,
                                  bool active,
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2e5af4f..a271997 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9272,8 +9272,8 @@ qemuBuildCommandLine(virConnectPtr conn,
                     virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
                     const char *dev = (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL_VGA)
                                        ? "qxl-vga" : "qxl");
-                    int ram = def->videos[0]->ram;
-                    int vram = def->videos[0]->vram;
+                    unsigned int ram = def->videos[0]->ram;
+                    unsigned int vram = def->videos[0]->vram;
 
                     if (vram > (UINT_MAX / 1024)) {
                         virReportError(VIR_ERR_OVERFLOW,
-- 
2.0.4


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