[libvirt] [PATCH 01/11] qemu: process: report useful error if alias formatting fails

Jiri Denemark jdenemar at redhat.com
Thu Nov 20 16:43:43 UTC 2014


On Wed, Nov 19, 2014 at 11:23:14 +0100, Peter Krempa wrote:
> When retrieving the paths for PTY devices the alias gets formatted into
> a static string. If it doesn't fit we wouldn't report an error.
> ---
>  src/qemu/qemu_process.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index 7518138..e58a46d 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -1878,8 +1878,12 @@ qemuProcessLookupPTYs(virDomainDefPtr def,
> 
>              if (snprintf(id, sizeof(id), "%s%s",
>                           chardevfmt ? "char" : "",
> -                         chr->info.alias) >= sizeof(id))
> +                         chr->info.alias) >= sizeof(id)) {
> +                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                               _("failed to format device alias "
> +                                 "for PTY retrieval"));
>                  return -1;
> +            }
> 
>              path = (const char *) virHashLookup(paths, id);
>              if (path == NULL) {

ACK although I thought we had some neat wrapper around snprintf, or is
my memory playing games with me?

Jirka




More information about the libvir-list mailing list