import: append % to X_IMPORT_PROGRESS=
authorFrantisek Sumsal <frantisek@sumsal.cz>
Sat, 25 Nov 2023 19:42:13 +0000 (20:42 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Sat, 25 Nov 2023 19:42:13 +0000 (20:42 +0100)
Since we parse it on the other side via parse_percent() which requires
that, otherwise we get an error:

[    8.133131] testsuite-13.sh[649]: + machinectl import-raw /tmp/container.raw container-raw
[    8.175035] machinectl[1143]: Enqueued transfer job 1. Press C-c to continue download in background.
[    8.182130] machinectl[1143]: Importing '/tmp/container.raw', saving as 'container-raw'.
[    8.182377] systemd-importd[1144]: Got invalid percent value '0', ignoring.
[    8.182451] machinectl[1143]: Imported 0%.
[    8.282669] systemd-importd[1144]: Got invalid percent value '40', ignoring.
[    8.282746] machinectl[1143]: Imported 40%.
[    8.366448] machinectl[1143]: Wrote 64.0M.
[    8.366519] machinectl[1143]: Operation completed successfully.
[    8.366617] machinectl[1143]: Exiting.

src/import/export-raw.c
src/import/export-tar.c
src/import/import-raw.c
src/import/import-tar.c
src/import/importd.c
src/import/pull-raw.c
src/import/pull-tar.c

index 5c9c2bb..f425396 100644 (file)
@@ -120,7 +120,7 @@ static void raw_export_report_progress(RawExport *e) {
         if (!ratelimit_below(&e->progress_ratelimit))
                 return;
 
-        sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent);
+        sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent);
         log_info("Exported %u%%.", percent);
 
         e->last_percent = percent;
index 2f54cd8..9e92bad 100644 (file)
@@ -131,7 +131,7 @@ static void tar_export_report_progress(TarExport *e) {
         if (!ratelimit_below(&e->progress_ratelimit))
                 return;
 
-        sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent);
+        sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent);
         log_info("Exported %u%%.", percent);
 
         e->last_percent = percent;
index 2db3198..f7ed163 100644 (file)
@@ -147,7 +147,7 @@ static void raw_import_report_progress(RawImport *i) {
         if (!ratelimit_below(&i->progress_ratelimit))
                 return;
 
-        sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent);
+        sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent);
         log_info("Imported %u%%.", percent);
 
         i->last_percent = percent;
index 8c18457..9020270 100644 (file)
@@ -148,7 +148,7 @@ static void tar_import_report_progress(TarImport *i) {
         if (!ratelimit_below(&i->progress_ratelimit))
                 return;
 
-        sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent);
+        sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent);
         log_info("Imported %u%%.", percent);
 
         i->last_percent = percent;
index cb5156b..e1a1ddc 100644 (file)
@@ -598,7 +598,7 @@ static int manager_on_notify(sd_event_source *s, int fd, uint32_t revents, void
 
         r = parse_percent(p);
         if (r < 0) {
-                log_warning("Got invalid percent value, ignoring.");
+                log_warning("Got invalid percent value '%s', ignoring.", p);
                 return 0;
         }
 
index e96be4d..66c3f65 100644 (file)
@@ -232,7 +232,7 @@ static void raw_pull_report_progress(RawPull *i, RawProgress p) {
                 assert_not_reached();
         }
 
-        sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent);
+        sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent);
         log_debug("Combined progress %u%%", percent);
 }
 
index 2db2519..c32fc29 100644 (file)
@@ -192,7 +192,7 @@ static void tar_pull_report_progress(TarPull *i, TarProgress p) {
                 assert_not_reached();
         }
 
-        sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent);
+        sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent);
         log_debug("Combined progress %u%%", percent);
 }