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

Re: [libvirt] [PATCH] Support for 3d Acceleration in video tag



> true, will add a element called <acceleration/> cause there are some
> features for 2d acceleration as well, so that will take care of 3d and 2d
> acceleration both.
>
> will post a patch soon with the above changes in it.

Reposting the patch with changes mentioned above.

Regards,
Pritesh
commit aec8cb4fe4c6b45c6a026bfdcf3192024c56f7c5
Author: pritesh <pritesh d6844923-1013-0410-bc22-a9adef35e721>
Date:   Tue Aug 18 15:14:42 2009 +0000

    libvirt: support for <acceleration/> element in video tag
    
    git-svn-id: https://linserv.germany.sun.com/vbox/svn/trunk/src/libs/libvirt 51235 d6844923-1013-0410-bc22-a9adef35e721

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index f857301..8f82e01 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -814,6 +814,26 @@
               <ref name="unsignedInt"/>
             </attribute>
           </optional>
+          <optional>
+            <element name="acceleration">
+              <optional>
+                <attribute name="3d">
+                  <choice>
+                    <value>yes</value>
+                    <value>no</value>
+                  </choice>
+                </attribute>
+              </optional>
+              <optional>
+                <attribute name="2d">
+                  <choice>
+                    <value>yes</value>
+                    <value>no</value>
+                  </choice>
+                </attribute>
+              </optional>
+            </element>
+          </optional>
 	</element>
       </optional>
     </element>
diff --git a/src/domain_conf.c b/src/domain_conf.c
index 1d2cc7c..8a3ea66 100644
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -1777,6 +1777,44 @@ virDomainVideoDefaultType(virDomainDefPtr def)
     }
 }
 
+static virDomainVideoAccelDef
+virDomainVideoAccelDefParseXML(const xmlNodePtr node) {
+    xmlNodePtr cur;
+    virDomainVideoAccelDef def;
+    char *support3d = NULL;
+    char *support2d = NULL;
+
+    cur = node->children;
+    while (cur != NULL) {
+        if (cur->type == XML_ELEMENT_NODE) {
+            if ((support3d == NULL) && (support2d == NULL) &&
+                xmlStrEqual(cur->name, BAD_CAST "acceleration")) {
+                support3d = virXMLPropString(cur, "accel3d");
+                support2d = virXMLPropString(cur, "accel2d");
+            }
+        }
+        cur = cur->next;
+    }
+
+    if (support3d) {
+        if (STREQ(support3d, "yes"))
+            def.support3d = 1;
+        else
+            def.support3d = 0;
+        VIR_FREE(support3d);
+    }
+
+    if (support2d) {
+        if (STREQ(support2d, "yes"))
+            def.support2d = 1;
+        else
+            def.support2d = 0;
+        VIR_FREE(support2d);
+    }
+
+    return def;
+}
+
 static virDomainVideoDefPtr
 virDomainVideoDefParseXML(virConnectPtr conn,
                           const xmlNodePtr node,
@@ -1801,6 +1839,7 @@ virDomainVideoDefParseXML(virConnectPtr conn,
                 type = virXMLPropString(cur, "type");
                 vram = virXMLPropString(cur, "vram");
                 heads = virXMLPropString(cur, "heads");
+                def->accel = virDomainVideoAccelDefParseXML(cur);
             }
         }
         cur = cur->next;
@@ -3804,6 +3843,19 @@ virDomainSoundDefFormat(virConnectPtr conn,
     return 0;
 }
 
+
+static void
+virDomainVideoAccelDefFormat(virBufferPtr buf,
+                             virDomainVideoAccelDef def)
+{
+    virBufferVSprintf(buf, "        <acceleration accel3d='%s'",
+                      def.support3d ? "yes" : "no");
+    virBufferVSprintf(buf, " accel2d='%s'",
+                      def.support2d ? "yes" : "no");
+    virBufferAddLit(buf, "/>\n");
+}
+
+
 static int
 virDomainVideoDefFormat(virConnectPtr conn,
                         virBufferPtr buf,
@@ -3824,7 +3876,12 @@ virDomainVideoDefFormat(virConnectPtr conn,
         virBufferVSprintf(buf, " vram='%u'", def->vram);
     if (def->heads)
         virBufferVSprintf(buf, " heads='%u'", def->heads);
-    virBufferAddLit(buf, "/>\n");
+    virBufferAddLit(buf, ">\n");
+
+    virDomainVideoAccelDefFormat(buf, def->accel);
+
+    virBufferAddLit(buf, "      </model>\n");
+
     virBufferAddLit(buf, "    </video>\n");
 
     return 0;
diff --git a/src/domain_conf.h b/src/domain_conf.h
index 44302be..2f3a02d 100644
--- a/src/domain_conf.h
+++ b/src/domain_conf.h
@@ -307,12 +307,21 @@ enum virDomainVideoType {
 };
 
 
+typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
+typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
+struct _virDomainVideoAccelDef {
+    int support3d : 1;
+    int support2d : 1;
+};
+
+
 typedef struct _virDomainVideoDef virDomainVideoDef;
 typedef virDomainVideoDef *virDomainVideoDefPtr;
 struct _virDomainVideoDef {
     int type;
     unsigned int vram;
     unsigned int heads;
+    virDomainVideoAccelDef accel;
 };
 
 /* 3 possible graphics console modes */

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