提交 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 @@
<ref name="unsignedInt"/>
</attribute>
</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>
</optional>
</element>
......
......@@ -391,6 +391,7 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def)
if (!def)
return;
VIR_FREE(def->accel);
VIR_FREE(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
virDomainVideoDefParseXML(virConnectPtr conn,
const xmlNodePtr node,
......@@ -1801,6 +1848,7 @@ virDomainVideoDefParseXML(virConnectPtr conn,
type = virXMLPropString(cur, "type");
vram = virXMLPropString(cur, "vram");
heads = virXMLPropString(cur, "heads");
def->accel = virDomainVideoAccelDefParseXML(conn, cur);
}
}
cur = cur->next;
......@@ -3852,6 +3900,19 @@ virDomainSoundDefFormat(virConnectPtr conn,
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
virDomainVideoDefFormat(virConnectPtr conn,
virBufferPtr buf,
......@@ -3872,7 +3933,14 @@ virDomainVideoDefFormat(virConnectPtr conn,
virBufferVSprintf(buf, " vram='%u'", def->vram);
if (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");
return 0;
......
......@@ -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 virDomainVideoDef *virDomainVideoDefPtr;
struct _virDomainVideoDef {
int type;
unsigned int vram;
unsigned int heads;
virDomainVideoAccelDefPtr accel;
};
/* 3 possible graphics console modes */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册