]> xenbits.xensource.com Git - libvirt.git/commitdiff
net: leaseshelper: Ignore corrupted lease file and rewrite it
authorPeter Krempa <pkrempa@redhat.com>
Mon, 16 Jun 2014 14:53:42 +0000 (16:53 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 17 Jun 2014 07:02:26 +0000 (09:02 +0200)
Instead of reporting an error and terminating, rewrite the file with
the newly learned info.

src/network/leaseshelper.c

index 99c47a9b7b3624e0253a2bd4a223b2e982711a4a..d4b48bbf5140b006f5484978296ce69e74c0a7e9 100644 (file)
@@ -274,14 +274,14 @@ main(int argc, char **argv)
     if (custom_lease_file_len) {
         if (!(leases_array = virJSONValueFromString(lease_entries))) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("invalid json in file: %s"), custom_lease_file);
-            goto cleanup;
-        }
-
-        if ((size = virJSONValueArraySize(leases_array)) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("couldn't fetch array of leases"));
-            goto cleanup;
+                           _("invalid json in file: %s, rewriting it"),
+                           custom_lease_file);
+        } else {
+            if ((size = virJSONValueArraySize(leases_array)) < 0) {
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                               _("couldn't fetch array of leases"));
+                goto cleanup;
+            }
         }
     }