Bug 1813807

Summary: Should not add --if-newer to supermin arg when initrd is missing.
Product: [Community] Virtualization Tools Reporter: kanda.motohiro
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED DUPLICATE QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: ptoscano, tburke
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-16 07:38:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description kanda.motohiro 2020-03-16 07:11:17 UTC
Description of problem:
After a power failure or os crash, there are cases appliancedir is half-built.
The directory exists but required files can be missing.
In that case, we 'd better tell supermin to create appliance from scratch.

Version-Release number of selected component (if applicable):
v1.42.0

How reproducible:
rare

Steps to Reproduce:
1. Kill supermin while it is creating files under appliancedir. Or simply rm appliancedir/initrd.
2. Run virt-v2v or guestfish
3.

Actual results:
virt-v2v or guestfish fails with "appliance closed connection".
if run with verbose mode, it says:
supermin: if-newer: output does not need rebuilding

Expected results:
supermin creates an applience from scratch.

Additional info:
Patch suggestion:
diff --git a/lib/appliance.c b/lib/appliance.c
index 6b4ee78..487d64f 100644
--- a/lib/appliance.c
+++ b/lib/appliance.c
@@ -323,7 +323,11 @@ run_supermin_build (guestfs_h *g,
   guestfs_int_cmd_add_arg (cmd, "--build");
   if (g->verbose)
     guestfs_int_cmd_add_arg (cmd, "--verbose");
-  guestfs_int_cmd_add_arg (cmd, "--if-newer");
+
+  /* Make sure these files exist when reusing appliancedir. */
+  if (dir_contains_files(g, appliancedir, "kernel", "initrd", "root")) {
+    guestfs_int_cmd_add_arg (cmd, "--if-newer");
+  }
   guestfs_int_cmd_add_arg (cmd, "--lock");
   guestfs_int_cmd_add_arg (cmd, lockfile);
 #if 0

Comment 1 Pino Toscano 2020-03-16 07:38:09 UTC
Yes, this is already known as a supermin bug: bug 1813809. I just created by cloning one the same bugs we had already reported for RHEL (bug 1796120, bug 1796120).

The patch IMHO is not a good approach, as this is something supermin ought to check properly.

*** This bug has been marked as a duplicate of bug 1813809 ***