[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 2/4] conf: Adding XML support for 'xres' and 'yres'



From: Julio Faracco <jcfaracco gmail com>

XML need to support both properties together. This commit adds XML
support for QXL model if they are set. Domain configuration is able to
parse this properties.

Signed-off-by: Julio Faracco <jcfaracco gmail com>
---
 src/conf/domain_conf.c | 26 ++++++++++++++++++++++++++
 src/conf/domain_conf.h |  2 ++
 2 files changed, 28 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 441eb1a5a2..120c6ccf5f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15360,6 +15360,8 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt,
     VIR_AUTOFREE(char *) ram = NULL;
     VIR_AUTOFREE(char *) vgamem = NULL;
     VIR_AUTOFREE(char *) primary = NULL;
+    VIR_AUTOFREE(char *) xres = NULL;
+    VIR_AUTOFREE(char *) yres = NULL;
 
     if (!(def = virDomainVideoDefNew()))
         return NULL;
@@ -15377,6 +15379,8 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt,
                 vram64 = virXMLPropString(cur, "vram64");
                 vgamem = virXMLPropString(cur, "vgamem");
                 heads = virXMLPropString(cur, "heads");
+                xres = virXMLPropString(cur, "xres");
+                yres = virXMLPropString(cur, "yres");
 
                 if ((primary = virXMLPropString(cur, "primary")) != NULL) {
                     if (STREQ(primary, "yes"))
@@ -15459,6 +15463,24 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt,
         }
     }
 
+    if (xres && yres) {
+        if (def->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("xres and yres attribute only supported for type of qxl"));
+            goto error;
+        }
+        if (virStrToLong_uip(xres, NULL, 10, &def->xres) < 0) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("cannot parse video xres '%s'"), xres);
+            goto error;
+        }
+        if (virStrToLong_uip(yres, NULL, 10, &def->yres) < 0) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("cannot parse video yres '%s'"), yres);
+            goto error;
+        }
+    }
+
     if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0)
         goto error;
 
@@ -26427,6 +26449,10 @@ virDomainVideoDefFormat(virBufferPtr buf,
         virBufferAsprintf(buf, " vgamem='%u'", def->vgamem);
     if (def->heads)
         virBufferAsprintf(buf, " heads='%u'", def->heads);
+    if (def->xres)
+        virBufferAsprintf(buf, " xres='%u'", def->xres);
+    if (def->yres)
+        virBufferAsprintf(buf, " yres='%u'", def->yres);
     if (def->primary)
         virBufferAddLit(buf, " primary='yes'");
     if (def->accel) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8a4425df64..bfee86efcf 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1419,6 +1419,8 @@ struct _virDomainVideoDef {
     unsigned int vram64; /* kibibytes (multiples of 1024) */
     unsigned int vgamem; /* kibibytes (multiples of 1024) */
     unsigned int heads;
+    unsigned int xres;
+    unsigned int yres;
     bool primary;
     virDomainVideoAccelDefPtr accel;
     virDomainVideoDriverDefPtr driver;
-- 
2.20.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]