[PATCH] virsh: domain: Use global constant for XML file size limit

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

 



Few places still used hardcoded limit for maximum XML size for commands
that accept XML files. The hardcoded limits ranged from 8k to 1M. Use
VSH_MAX_XML_FILE to express this limit in a unified way. This will bump
the limit for the commands that used hardcoded string lengths to 10M.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1152427
---
 tools/virsh-domain.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 12550ff..94ae3d3 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1984,7 +1984,7 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
     }

     if (xml) {
-        if (virFileReadAll(xml, 8192, &xmlstr) < 0) {
+        if (virFileReadAll(xml, VSH_MAX_XML_FILE, &xmlstr) < 0) {
             vshReportError(ctl);
             goto cleanup;
         }
@@ -3889,7 +3889,7 @@ doSave(void *opaque)
         goto out;

     if (xmlfile &&
-        virFileReadAll(xmlfile, 8192, &xml) < 0) {
+        virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) {
         vshReportError(ctl);
         goto out;
     }
@@ -4182,7 +4182,7 @@ cmdSaveImageDefine(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0)
         return false;

-    if (virFileReadAll(xmlfile, 8192, &xml) < 0)
+    if (virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0)
         goto cleanup;

     if (virDomainSaveImageDefineXML(ctl->conn, file, xml, flags) < 0) {
@@ -4765,7 +4765,7 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
         return false;

     if (xmlfile &&
-        virFileReadAll(xmlfile, 8192, &xml) < 0)
+        virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0)
         goto cleanup;

     if (((flags || xml)
@@ -8945,7 +8945,7 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd)
         vshCommandOptStringReq(ctl, cmd, "config", &configFile) < 0)
         return false;

-    if (virFileReadAll(configFile, 1024*1024, &configData) < 0)
+    if (virFileReadAll(configFile, VSH_MAX_XML_FILE, &configData) < 0)
         return false;

     xmlData = virConnectDomainXMLFromNative(ctl->conn, format, configData, flags);
@@ -9001,7 +9001,7 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
         vshCommandOptStringReq(ctl, cmd, "xml", &xmlFile) < 0)
         return false;

-    if (virFileReadAll(xmlFile, 1024*1024, &xmlData) < 0)
+    if (virFileReadAll(xmlFile, VSH_MAX_XML_FILE, &xmlData) < 0)
         return false;

     configData = virConnectDomainXMLToNative(ctl->conn, format, xmlData, flags);
@@ -9318,7 +9318,7 @@ doMigrate(void *opaque)
     if (opt) {
         char *xml;

-        if (virFileReadAll(opt, 1024 * 1024, &xml) < 0) {
+        if (virFileReadAll(opt, VSH_MAX_XML_FILE, &xml) < 0) {
             vshError(ctl, _("cannot read file '%s'"), opt);
             goto save_error;
         }
-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]