From: Julio Faracco <jcfaracco@xxxxxxxxx> XML need to support both properties together. This commit adds XML support for video model if they are set. Domain configuration is able to parse this properties as 'x' and 'y'. Code is not using same label as QEMU: 'xres' and 'yres'. Signed-off-by: Julio Faracco <jcfaracco@xxxxxxxxx> --- src/conf/domain_conf.c | 74 ++++++++++++++++++++++++++++++++++++++++- src/conf/domain_conf.h | 5 +++ src/conf/virconftypes.h | 3 ++ 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a53cd6a725..950c4522f9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15403,6 +15403,52 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) return def; } +static virDomainVideoResolutionDefPtr +virDomainVideoResolutionDefParseXML(xmlNodePtr node) +{ + xmlNodePtr cur; + virDomainVideoResolutionDefPtr def; + VIR_AUTOFREE(char *) x = NULL; + VIR_AUTOFREE(char *) y = NULL; + + cur = node->children; + while (cur != NULL) { + if (cur->type == XML_ELEMENT_NODE) { + if (!x && !y && + virXMLNodeNameEqual(cur, "resolution")) { + x = virXMLPropString(cur, "x"); + y = virXMLPropString(cur, "y"); + } + } + cur = cur->next; + } + + if (!x || !y) + return NULL; + + if (VIR_ALLOC(def) < 0) + goto cleanup; + + if (x) { + if (virStrToLong_uip(x, NULL, 10, &def->x) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("cannot parse video x-resolution '%s'"), x); + goto cleanup; + } + } + + if (y) { + if (virStrToLong_uip(y, NULL, 10, &def->y) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("cannot parse video y-resolution '%s'"), y); + goto cleanup; + } + } + + cleanup: + return def; +} + static virDomainVideoDriverDefPtr virDomainVideoDriverDefParseXML(xmlNodePtr node) { @@ -15482,6 +15528,7 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt, } def->accel = virDomainVideoAccelDefParseXML(cur); + def->res = virDomainVideoResolutionDefParseXML(cur); } if (virXMLNodeNameEqual(cur, "driver")) { if (virDomainVirtioOptionsParseXML(cur, &def->virtio) < 0) @@ -15569,6 +15616,17 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt, } } + if (def->res) { + if (def->type != VIR_DOMAIN_VIDEO_TYPE_VGA && + def->type != VIR_DOMAIN_VIDEO_TYPE_QXL && + def->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO && + def->type != VIR_DOMAIN_VIDEO_TYPE_BOCHS) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("model resolution is not supported")); + goto error; + } + } + if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) goto error; @@ -26574,6 +26632,18 @@ virDomainVideoAccelDefFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } +static void +virDomainVideoResolutionDefFormat(virBufferPtr buf, + virDomainVideoResolutionDefPtr def) +{ + virBufferAddLit(buf, "<resolution"); + if (def->x && def->y) { + virBufferAsprintf(buf, " x='%u' y='%u'", + def->x, def->y); + } + virBufferAddLit(buf, "/>\n"); +} + static int virDomainVideoDefFormat(virBufferPtr buf, virDomainVideoDefPtr def, @@ -26621,11 +26691,13 @@ virDomainVideoDefFormat(virBufferPtr buf, virBufferAsprintf(buf, " heads='%u'", def->heads); if (def->primary) virBufferAddLit(buf, " primary='yes'"); - if (def->accel) { + if (def->accel || def->res) { virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); if (def->accel) virDomainVideoAccelDefFormat(buf, def->accel); + if (def->res) + virDomainVideoResolutionDefFormat(buf, def->res); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</model>\n"); } else { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2884af49d8..ce5da4ddf4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1420,6 +1420,10 @@ struct _virDomainVideoAccelDef { char *rendernode; }; +struct _virDomainVideoResolutionDef { + unsigned int x; + unsigned int y; +}; struct _virDomainVideoDriverDef { virDomainVideoVGAConf vgaconf; @@ -1437,6 +1441,7 @@ struct _virDomainVideoDef { unsigned int heads; bool primary; virDomainVideoAccelDefPtr accel; + virDomainVideoResolutionDefPtr res; virDomainVideoDriverDefPtr driver; virDomainDeviceInfo info; virDomainVirtioOptionsPtr virtio; diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h index a15cfb5f9e..462842f324 100644 --- a/src/conf/virconftypes.h +++ b/src/conf/virconftypes.h @@ -324,6 +324,9 @@ typedef virDomainVcpuDef *virDomainVcpuDefPtr; typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef; typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr; +typedef struct _virDomainVideoResolutionDef virDomainVideoResolutionDef; +typedef virDomainVideoResolutionDef *virDomainVideoResolutionDefPtr; + typedef struct _virDomainVideoDef virDomainVideoDef; typedef virDomainVideoDef *virDomainVideoDefPtr; -- 2.20.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list