mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
conf: add optional attribte primary to video <model> element
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.
This commit is contained in:
parent
4c993d8ab5
commit
09938bb3b0
@ -3500,7 +3500,11 @@ qemu-kvm -net nic,model=? /dev/null
|
|||||||
will add a default <code>video</code> according to the guest type.
|
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:
|
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
|
<code>type</code> with value "cirrus", <code>vram</code> with value
|
||||||
"9216", and <code>heads</code> with value "1".
|
"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 mutiple
|
||||||
|
video device. The non-primary must be type of "qxl".
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt><code>model</code></dt>
|
<dt><code>model</code></dt>
|
||||||
|
@ -2259,6 +2259,14 @@
|
|||||||
<ref name="unsignedInt"/>
|
<ref name="unsignedInt"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<attribute name="primary">
|
||||||
|
<choice>
|
||||||
|
<value>yes</value>
|
||||||
|
<value>no</value>
|
||||||
|
</choice>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
<optional>
|
<optional>
|
||||||
<element name="acceleration">
|
<element name="acceleration">
|
||||||
<optional>
|
<optional>
|
||||||
|
@ -7275,6 +7275,7 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
|
|||||||
char *type = NULL;
|
char *type = NULL;
|
||||||
char *heads = NULL;
|
char *heads = NULL;
|
||||||
char *vram = NULL;
|
char *vram = NULL;
|
||||||
|
char *primary = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0) {
|
if (VIR_ALLOC(def) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
@ -7289,6 +7290,11 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
|
|||||||
type = virXMLPropString(cur, "type");
|
type = virXMLPropString(cur, "type");
|
||||||
vram = virXMLPropString(cur, "vram");
|
vram = virXMLPropString(cur, "vram");
|
||||||
heads = virXMLPropString(cur, "heads");
|
heads = virXMLPropString(cur, "heads");
|
||||||
|
|
||||||
|
if ((primary = virXMLPropString(cur, "primary")) != NULL)
|
||||||
|
if (STREQ(primary, "yes"))
|
||||||
|
def->primary = 1;
|
||||||
|
|
||||||
def->accel = virDomainVideoAccelDefParseXML(cur);
|
def->accel = virDomainVideoAccelDefParseXML(cur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8709,6 +8715,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
|
|||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
bool usb_none = false;
|
bool usb_none = false;
|
||||||
bool usb_other = false;
|
bool usb_other = false;
|
||||||
|
bool primaryVideo = false;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0) {
|
if (VIR_ALLOC(def) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
@ -9996,12 +10003,28 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
|
|||||||
if (n && VIR_ALLOC_N(def->videos, n) < 0)
|
if (n && VIR_ALLOC_N(def->videos, n) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
for (i = 0 ; i < n ; i++) {
|
for (i = 0 ; i < n ; i++) {
|
||||||
|
size_t ii = def->nvideos;
|
||||||
virDomainVideoDefPtr video = virDomainVideoDefParseXML(nodes[i],
|
virDomainVideoDefPtr video = virDomainVideoDefParseXML(nodes[i],
|
||||||
def,
|
def,
|
||||||
flags);
|
flags);
|
||||||
if (!video)
|
if (!video)
|
||||||
goto error;
|
goto error;
|
||||||
def->videos[def->nvideos++] = video;
|
|
||||||
|
if (video->primary) {
|
||||||
|
if (primaryVideo) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Only one primary video device is supported"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
ii = 0;
|
||||||
|
primaryVideo = true;
|
||||||
|
}
|
||||||
|
if (VIR_INSERT_ELEMENT_INPLACE(def->videos,
|
||||||
|
ii,
|
||||||
|
def->nvideos,
|
||||||
|
video) < 0)
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
VIR_FREE(nodes);
|
VIR_FREE(nodes);
|
||||||
|
|
||||||
@ -13151,6 +13174,8 @@ virDomainVideoDefFormat(virBufferPtr buf,
|
|||||||
virBufferAsprintf(buf, " vram='%u'", def->vram);
|
virBufferAsprintf(buf, " vram='%u'", def->vram);
|
||||||
if (def->heads)
|
if (def->heads)
|
||||||
virBufferAsprintf(buf, " heads='%u'", def->heads);
|
virBufferAsprintf(buf, " heads='%u'", def->heads);
|
||||||
|
if (def->primary)
|
||||||
|
virBufferAddLit(buf, " primary='yes'");
|
||||||
if (def->accel) {
|
if (def->accel) {
|
||||||
virBufferAddLit(buf, ">\n");
|
virBufferAddLit(buf, ">\n");
|
||||||
virDomainVideoAccelDefFormat(buf, def->accel);
|
virDomainVideoAccelDefFormat(buf, def->accel);
|
||||||
|
@ -1121,6 +1121,7 @@ struct _virDomainVideoDef {
|
|||||||
int type;
|
int type;
|
||||||
unsigned int vram;
|
unsigned int vram;
|
||||||
unsigned int heads;
|
unsigned int heads;
|
||||||
|
bool primary;
|
||||||
virDomainVideoAccelDefPtr accel;
|
virDomainVideoAccelDefPtr accel;
|
||||||
virDomainDeviceInfo info;
|
virDomainDeviceInfo info;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user