If there are multiple video devices
primary = 'yes' marks this video device as the primary one.
The rest are secondary video devices. No more than one could be
mark as primary. If none of them has primary attribute, the first
one will be the primary by default like what it was.
The reason of this changing is that for qemu, only one primary video
device is permitted which can be of any type. For secondary video
devices, only qxl is allowd. Primary attribute removes the restriction
that the first have to be the primary one.
We always put the primary video device into the first position of
video device structure array after parsing.
---
src/conf/domain_conf.c | 25 +++++++++++++++++++++++++
src/conf/domain_conf.h | 1 +
2 files changed, 26 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6aa5f79..862ab0f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7275,6 +7275,7 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
char *type = NULL;
char *heads = NULL;
char *vram = NULL;
+ char *primary = NULL;
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
@@ -7289,6 +7290,11 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
type = virXMLPropString(cur, "type");
vram = virXMLPropString(cur, "vram");
heads = virXMLPropString(cur, "heads");
+
+ if ((primary = virXMLPropString(cur, "primary"))!= NULL)
+ if (STREQ(primary, "yes"))
+ def->primary = 1;
+
def->accel = virDomainVideoAccelDefParseXML(cur);
}
}
@@ -8669,6 +8675,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
xmlNodePtr cur;
bool usb_none = false;
bool usb_other = false;
+ bool primaryVideo = false;
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
@@ -9961,6 +9968,22 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
flags);
if (!video)
goto error;
+
+ if (!primaryVideo && video->primary) {
+ if (def->nvideos != 0)
+ memmove(def->videos + 1,
+ def->videos,
+ (sizeof(def->videos[0]) * def->nvideos));
+
+ def->videos[0] = video;
+ def->nvideos++;
+ primaryVideo = true;
+ continue;
+ } else if (primaryVideo && video->primary) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Only one primary video device is supported"));
+ goto error;
+ }
def->videos[def->nvideos++] = video;
}
VIR_FREE(nodes);
@@ -13109,6 +13132,8 @@ virDomainVideoDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, " vram='%u'", def->vram);
if (def->heads)
virBufferAsprintf(buf, " heads='%u'", def->heads);
+ if (def->primary)
+ virBufferAddLit(buf, " primary='yes'");
if (def->accel) {
virBufferAddLit(buf, ">\n");
virDomainVideoAccelDefFormat(buf, def->accel);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 7ad5377..bf6b532 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1120,6 +1120,7 @@ struct _virDomainVideoDef {
int type;
unsigned int vram;
unsigned int heads;
+ unsigned int primary : 1;
virDomainVideoAccelDefPtr accel;
virDomainDeviceInfo info;
};
--
1.7.11.2