George Dunlap
2011-Feb-24 14:37 UTC
[Xen-devel] [PATCH] tools: Handle failed xc_get_hvm_param in domain save
The domain save code will read an HVM param, and if it''s not zero, make an entry for it. However, if the hypercall fails for any reason, the data may not be written, and the value for the previous parameter may be written in the save file as the parameter that failed. Initialize the value to zero before each hypercall, so that in case of a failure, no value will be written. Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> diff -r 13a7d1f7f62c -r 9261ae7a9a9c tools/libxc/xc_domain_save.c --- a/tools/libxc/xc_domain_save.c Mon Feb 21 09:11:57 2011 +0000 +++ b/tools/libxc/xc_domain_save.c Thu Feb 24 14:37:15 2011 +0000 @@ -1597,6 +1597,7 @@ } chunk = { 0, }; chunk.id = XC_SAVE_ID_HVM_IDENT_PT; + chunk.data = 0; xc_get_hvm_param(xch, dom, HVM_PARAM_IDENT_PT, (unsigned long *)&chunk.data); @@ -1608,6 +1609,7 @@ } chunk.id = XC_SAVE_ID_HVM_VM86_TSS; + chunk.data = 0; xc_get_hvm_param(xch, dom, HVM_PARAM_VM86_TSS, (unsigned long *)&chunk.data); @@ -1619,6 +1621,7 @@ } chunk.id = XC_SAVE_ID_HVM_CONSOLE_PFN; + chunk.data = 0; xc_get_hvm_param(xch, dom, HVM_PARAM_CONSOLE_PFN, (unsigned long *)&chunk.data); @@ -1630,6 +1633,7 @@ } chunk.id = XC_SAVE_ID_HVM_ACPI_IOPORTS_LOCATION; + chunk.data = 0; xc_get_hvm_param(xch, dom, HVM_PARAM_ACPI_IOPORTS_LOCATION, (unsigned long *)&chunk.data); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Feb-25 17:25 UTC
Re: [Xen-devel] [PATCH] tools: Handle failed xc_get_hvm_param in domain save
George Dunlap writes ("[Xen-devel] [PATCH] tools: Handle failed xc_get_hvm_param in domain save"):> The domain save code will read an HVM param, and if it''s not zero, > make an entry for it. However, if the hypercall fails for any reason, > the data may not be written, and the value for the previous parameter > may be written in the save file as the parameter that failed.Thanks, I''m applying this. But: what an unpleasantly formulaic section of code! Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel