Re: [PATCH] Managed-Save: False warning on successful managed save restoration

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

 



On 05/27/2014 08:06 AM, Jason J. Herne wrote:
> From: "Jason J. Herne" <jjherne@xxxxxxxxxx>
> 
> qemuDomainObjStart is checking the return code from qemuDomainObjRestore for
> errors even after determining that the return code is 0. This causes the
> following error message to appear even when the restore was successful.
> 
> Unable to restore from managed state [path]. Maybe the file is corrupted?
> 
> A simple conditional to handle the error case takes care of the problem.
> 
> Signed-off-by: Jason J. Herne <jjherne@xxxxxxxxxx>
> ---
>  src/qemu/qemu_driver.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 2b852eb..cec2b6c 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -6081,14 +6081,15 @@ qemuDomainObjStart(virConnectPtr conn,
>                  else
>                      vm->hasManagedSave = false;
>              }
> -
> -            if (ret > 0) {
> -                VIR_WARN("Ignoring incomplete managed state %s", managed_save);
> -            } else {
> -                VIR_WARN("Unable to restore from managed state %s. "
> -                         "Maybe the file is corrupted?", managed_save);
> -                goto cleanup;
> +            else {

Wrong coding style; the else should appear next to the } of the if.

> +                if (ret > 0) {
> +                    VIR_WARN("Ignoring incomplete managed state %s", managed_save);
> +                } else {
> +                    VIR_WARN("Unable to restore from managed state %s. "
> +                             "Maybe the file is corrupted?", managed_save);
> +                }
>              }
> +            goto cleanup;

This goto is placed wrong; it causes us to skip starting the domain even
when loading managed state was successful.

But you are right that the logic is screwy here.  Does this diff look
better?


diff --git i/src/qemu/qemu_driver.c w/src/qemu/qemu_driver.c
index f008763..bae70ff 100644
--- i/src/qemu/qemu_driver.c
+++ w/src/qemu/qemu_driver.c
@@ -6080,9 +6080,7 @@ qemuDomainObjStart(virConnectPtr conn,
                     VIR_WARN("Failed to remove the managed state %s",
managed_save);
                 else
                     vm->hasManagedSave = false;
-            }
-
-            if (ret > 0) {
+            } else if (ret > 0) {
                 VIR_WARN("Ignoring incomplete managed state %s",
managed_save);
             } else {
                 VIR_WARN("Unable to restore from managed state %s. "


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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