[PATCH] Define STATE_XMLFILE_LEN as 8192

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

 



Save/restore the state of domain and migrate need read state XML file.
8192B is not the exactly maximum file length of state file.

restore command could work successfully in virsh shell.
virsh # list --all
 Id    Name                           State
----------------------------------------------------
 9     sdk                            running

virsh # save sdk pp

Domain sdk saved to pp

virsh # list --all
 Id    Name                           State
----------------------------------------------------
 -     sdk                            shut off

virsh # restore pp
Domain restored from pp

virsh # list --all
 Id    Name                           State
----------------------------------------------------
 10    sdk                            running

But it will fail with 'virsh restore' command because the state file is oversized.
~# virsh restore pp
error: Failed to read file 'pp': Value too large for defined data type

Signed-off-by: Olivia Yin <Hong-Hua.Yin@xxxxxxxxxxxxx>
---
 tools/virsh-domain.c | 6 +++---
 tools/virsh.h        | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 73414f8..8ade296 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -3547,7 +3547,7 @@ doSave(void *opaque)
         goto out;
 
     if (xmlfile &&
-        virFileReadAll(xmlfile, 8192, &xml) < 0) {
+        virFileReadAll(xmlfile, STATE_XMLFILE_LEN, &xml) < 0) {
         vshReportError(ctl);
         goto out;
     }
@@ -3840,7 +3840,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, STATE_XMLFILE_LEN, &xml) < 0)
         goto cleanup;
 
     if (virDomainSaveImageDefineXML(ctl->conn, file, xml, flags) < 0) {
@@ -4424,7 +4424,7 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     if (xmlfile &&
-        virFileReadAll(xmlfile, 8192, &xml) < 0)
+        virFileReadAll(xmlfile, STATE_XMLFILE_LEN, &xml) < 0)
         goto cleanup;
 
     if (((flags || xml)
diff --git a/tools/virsh.h b/tools/virsh.h
index 3e0251b..3f95216 100644
--- a/tools/virsh.h
+++ b/tools/virsh.h
@@ -41,6 +41,7 @@
 # include "virstring.h"
 
 # define VSH_MAX_XML_FILE (10*1024*1024)
+# define STATE_XMLFILE_LEN (8*1024)
 
 # define VSH_PROMPT_RW    "virsh # "
 # define VSH_PROMPT_RO    "virsh > "
-- 
1.8.5


--
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]