提交 6aa576cd 编写于 作者: P Pritesh Kothari 提交者: Daniel Veillard

Generic parsing support for video acceleration

* docs/schemas/domain.rng: augment the video model with an optional
  acceleration element with optional accel2d and accel3d flags
* src/domain_conf.c src/domain_conf.h: exten the virDomainVideoDef
  structure with an optional accel field, virDomainVideoAccelDefParseXML
  and virDomainVideoAccelDefFormat functions to parse and serialize
  the structure.
上级 6dfc042c
...@@ -819,6 +819,26 @@ ...@@ -819,6 +819,26 @@
<ref name="unsignedInt"/> <ref name="unsignedInt"/>
</attribute> </attribute>
</optional> </optional>
<optional>
<element name="acceleration">
<optional>
<attribute name="accel3d">
<choice>
<value>yes</value>
<value>no</value>
</choice>
</attribute>
</optional>
<optional>
<attribute name="accel2d">
<choice>
<value>yes</value>
<value>no</value>
</choice>
</attribute>
</optional>
</element>
</optional>
</element> </element>
</optional> </optional>
</element> </element>
......
...@@ -391,6 +391,7 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def) ...@@ -391,6 +391,7 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def)
if (!def) if (!def)
return; return;
VIR_FREE(def->accel);
VIR_FREE(def); VIR_FREE(def);
} }
...@@ -1777,6 +1778,52 @@ virDomainVideoDefaultType(virDomainDefPtr def) ...@@ -1777,6 +1778,52 @@ virDomainVideoDefaultType(virDomainDefPtr def)
} }
} }
static virDomainVideoAccelDefPtr
virDomainVideoAccelDefParseXML(virConnectPtr conn, const xmlNodePtr node) {
xmlNodePtr cur;
virDomainVideoAccelDefPtr 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 == NULL) && (support2d == NULL))
return(NULL);
if (VIR_ALLOC(def) < 0) {
virReportOOMError(conn);
return NULL;
}
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 static virDomainVideoDefPtr
virDomainVideoDefParseXML(virConnectPtr conn, virDomainVideoDefParseXML(virConnectPtr conn,
const xmlNodePtr node, const xmlNodePtr node,
...@@ -1801,6 +1848,7 @@ virDomainVideoDefParseXML(virConnectPtr conn, ...@@ -1801,6 +1848,7 @@ virDomainVideoDefParseXML(virConnectPtr conn,
type = virXMLPropString(cur, "type"); type = virXMLPropString(cur, "type");
vram = virXMLPropString(cur, "vram"); vram = virXMLPropString(cur, "vram");
heads = virXMLPropString(cur, "heads"); heads = virXMLPropString(cur, "heads");
def->accel = virDomainVideoAccelDefParseXML(conn, cur);
} }
} }
cur = cur->next; cur = cur->next;
...@@ -3852,6 +3900,19 @@ virDomainSoundDefFormat(virConnectPtr conn, ...@@ -3852,6 +3900,19 @@ virDomainSoundDefFormat(virConnectPtr conn,
return 0; return 0;
} }
static void
virDomainVideoAccelDefFormat(virBufferPtr buf,
virDomainVideoAccelDefPtr def)
{
virBufferVSprintf(buf, " <acceleration accel3d='%s'",
def->support3d ? "yes" : "no");
virBufferVSprintf(buf, " accel2d='%s'",
def->support2d ? "yes" : "no");
virBufferAddLit(buf, "/>\n");
}
static int static int
virDomainVideoDefFormat(virConnectPtr conn, virDomainVideoDefFormat(virConnectPtr conn,
virBufferPtr buf, virBufferPtr buf,
...@@ -3872,7 +3933,14 @@ virDomainVideoDefFormat(virConnectPtr conn, ...@@ -3872,7 +3933,14 @@ virDomainVideoDefFormat(virConnectPtr conn,
virBufferVSprintf(buf, " vram='%u'", def->vram); virBufferVSprintf(buf, " vram='%u'", def->vram);
if (def->heads) if (def->heads)
virBufferVSprintf(buf, " heads='%u'", def->heads); virBufferVSprintf(buf, " heads='%u'", def->heads);
virBufferAddLit(buf, "/>\n"); if (def->accel) {
virBufferAddLit(buf, ">\n");
virDomainVideoAccelDefFormat(buf, def->accel);
virBufferAddLit(buf, " </model>\n");
} else {
virBufferAddLit(buf, "/>\n");
}
virBufferAddLit(buf, " </video>\n"); virBufferAddLit(buf, " </video>\n");
return 0; return 0;
......
...@@ -309,12 +309,21 @@ enum virDomainVideoType { ...@@ -309,12 +309,21 @@ enum virDomainVideoType {
}; };
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
struct _virDomainVideoAccelDef {
int support3d : 1;
int support2d : 1;
};
typedef struct _virDomainVideoDef virDomainVideoDef; typedef struct _virDomainVideoDef virDomainVideoDef;
typedef virDomainVideoDef *virDomainVideoDefPtr; typedef virDomainVideoDef *virDomainVideoDefPtr;
struct _virDomainVideoDef { struct _virDomainVideoDef {
int type; int type;
unsigned int vram; unsigned int vram;
unsigned int heads; unsigned int heads;
virDomainVideoAccelDefPtr accel;
}; };
/* 3 possible graphics console modes */ /* 3 possible graphics console modes */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册