Thanks to visit codestin.com
Credit goes to github.com

Skip to content

lib/create.c: Capture and raise qemu-img stderr #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2025

Conversation

crobinso
Copy link
Contributor

https://issues.redhat.com/browse/RHEL-92239

After this, output looks like

$ ./run guestfish --ro --format=qcow222 -a test.img
libguestfs: error: qemu-img: qemu-img: .../overlay1.qcow2: Unknown driver 'qcow222'
Could not open backing image.
: qemu-img exited with error status 1.
To see full error messages you may need to enable debugging.
...

This is ugly as is, but I'm looking for advice before I go off into the weeds.

Before this commit:

  • stdout is thrown away
  • stderr always ends up in guestfs trace log
  • error message just mentions exit status and qemu-img filename

After this commit

  • combines stderr and stdout and crams it into guestfs_int_external_command_failed when command fails.
  • debug() prints it all on command success

IMO ideal would be:

  • stderr, but not stdout, reported on error
  • guestfs_int_external_command_failed boiler plate is still printed, but formatted nicely.
  • stderr still shows up in some debug output, when command succeeds.

But decoupling the stdout piece may need lib/command.c additions, and formatting the error may need lib/errors.c additions.

@rwmjones suggestions?

@rwmjones
Copy link
Member

Seems fine actually. Would it be possible to convert \n chars to a space? (Might consider adding that feature to lib/command.c).

Also what's the output if the --format parameter is a valid format name, but not the correct format for the backing file (ie the original bug report)?

@crobinso crobinso force-pushed the qemu-img-error-output branch from 5701ff6 to 2792029 Compare May 20, 2025 18:10
@crobinso
Copy link
Contributor Author

Here's output with newlines replaced. I adjust patches to do the newline replacement unconditionally in guestfs_int_external_command_failed which seems reasonable.

$ ./run guestfish --ro --format=qcow2 -a test.img
 libguestfs: error: qemu-img: qemu-img: /home/crobinso/src/libguestfs/tmp/libguestfsFlxnb0/overlay1.qcow2: Image is not in qcow2 format Could not open backing image. : qemu-img exited with error status 1.
 To see full error messages you may need to enable debugging.
...

@crobinso crobinso changed the title WIP: lib/create.c: Capture and raise qemu-img stderr lib/create.c: Capture and raise qemu-img stderr May 20, 2025
crobinso added 2 commits May 21, 2025 11:38
Otherwise string output looks quite awkward

Signed-off-by: Cole Robinson <[email protected]>
https://issues.redhat.com/browse/RHEL-92239

After this, output looks like

   $ ./run guestfish --ro --format=qcow2 -a test.img
   libguestfs: error: qemu-img: qemu-img: /home/crobinso/src/libguestfs/tmp/libguestfsFlxnb0/overlay1.qcow2: Image is not in qcow2 format Could not open backing image. : qemu-img exited with error status 1.
   To see full error messages you may need to enable debugging.
   ...

Signed-off-by: Cole Robinson <[email protected]>
@crobinso crobinso force-pushed the qemu-img-error-output branch from 2792029 to 5e01824 Compare May 21, 2025 15:39
@rwmjones rwmjones merged commit 606aa1d into libguestfs:master May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants