Description of problem: virt-customize --commands-from-file will fail if there is an extra blank in the file. Version-Release number of selected component (if applicable): libguestfs-1.32.5-6.el7.x86_64 How reproducible: Always Steps to Reproduce: 1. Prepare a RHEL guest image: RHEL-Server-7.2-64-hvm.raw 2. Create a script file as following (Note that there is a blank between the arg and the command or before the command line): # cat test.sh install git mkdir /root/dir1 write /root/dir1/fiel1:"test file1" 3. # virt-customize -a RHEL-Server-7.2-64-hvm.raw --commands-from-file test.sh virt-customize: error: command '' not valid, see the man page If reporting bugs, run virt-customize with debugging enabled and include the complete output: virt-customize -v -x [...] There is no difference when using -v -x. Actual results: As above output. Expected results: It should ignore the blank and finish the commands successfully. Additional info:
Patch posted upstream: https://www.redhat.com/archives/libguestfs/2020-January/msg00180.html
Fixed upstream with https://github.com/libguestfs/libguestfs-common/commit/12f3fb0f6ccdacb4c6fb81385550b62665fc1497
Try to verify this bug with package: libguestfs-1.40.2-21.module+el8.2.0+5851+8d6a931b.x86_64 Steps: 1. Create a script file and there are whitespaces before the first command line # cat test.sh mkdir /root/dir1 write /root/dir1/file1:"test file1" 2. # virt-customize -a RHEL-Server-8.2.0-64-20191203.0-hvm.raw --commands-from-file test.sh [ 0.0] Examining the guest ... [ 8.4] Setting a random seed [ 8.4] Making directory: /root/dir1 [ 8.4] Writing: /root/dir1/file1 [ 8.5] Finishing off It works. 3. Change the test.sh and add whitespace between the install command and its argument. # cat test.sh install git mkdir /root/dir1 write /root/dir1/file1:"test file1" 4. # virt-customize -a RHEL-Server-8.2.0-64-20191203.0-hvm.raw --commands-from-file test.sh [ 0.0] Examining the guest ... [ 8.0] Setting a random seed [ 8.1] Installing packages: git ... No match for argument: git Error: Unable to find a match: git virt-customize: error: dnf -y install ' git': command exited with an error If reporting bugs, run virt-customize with debugging enabled and include the complete output: virt-customize -v -x [...] It failed due to the extra whitespace before the argument.
(In reply to YongkuiGuo from comment #5) > 3. Change the test.sh and add whitespace between the install command and its > argument. > # cat test.sh > install git > mkdir /root/dir1 > write /root/dir1/file1:"test file1" > > 4. > # virt-customize -a RHEL-Server-8.2.0-64-20191203.0-hvm.raw > --commands-from-file test.sh > [ 0.0] Examining the guest ... > [ 8.0] Setting a random seed > [ 8.1] Installing packages: git > ... > No match for argument: git > Error: Unable to find a match: git > virt-customize: error: dnf -y install ' git': command exited with an error This was not what this bug was about, and indeed it was not covered by the fix. The fix is only about the whitespaces before the command.
(In reply to Pino Toscano from comment #6) > (In reply to YongkuiGuo from comment #5) > > 3. Change the test.sh and add whitespace between the install command and its > > argument. > > # cat test.sh > > install git > > mkdir /root/dir1 > > write /root/dir1/file1:"test file1" > > > > 4. > > # virt-customize -a RHEL-Server-8.2.0-64-20191203.0-hvm.raw > > --commands-from-file test.sh > > [ 0.0] Examining the guest ... > > [ 8.0] Setting a random seed > > [ 8.1] Installing packages: git > > ... > > No match for argument: git > > Error: Unable to find a match: git > > virt-customize: error: dnf -y install ' git': command exited with an error > > This was not what this bug was about, and indeed it was not covered by the > fix. > The fix is only about the whitespaces before the command. I saw this type of whitespace is included in the reproducible steps of the reporter(comment 0). Should we open a new bug for tracking this issue?
(In reply to YongkuiGuo from comment #7) > I saw this type of whitespace is included in the reproducible steps of the > reporter(comment 0). Should we open a new bug for tracking this issue? Martin?
Even though it is almost the same thing from the users' perspective, it is slightly different thing in the code. I don't have a preference of whether we need another BZ or not, but it is not going to be fixed anyway. I would say if you want that fixed than file another BZ with some reasoning behind that change. Otherwise just leave it as it is and we can close this one. The whitespace is just treated as part of the argument and I did not find any mention about them being supported in a way that would allow indentation or anything else. The original problem was good to get fixed since it did not provide a useful error message. This one, however, feels pointless to spent time on IMNSHO. But thanks for trying it out.
According to comment 5 and comment 9, i will verify this bug. Thanks pino and martin for the explanation.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2020:2017