[libvirt] [PATCH 6/7] qemu: assume -drive argument is always available

John Ferlan jferlan at redhat.com
Thu Nov 5 20:18:38 UTC 2015



[...]

Ran the series through the Coverity checks...

> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 79d1692..7676237 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -1104,29 +1104,27 @@ virQEMUCapsComputeCmdFlags(const char *help,
>          virQEMUCapsSet(qemuCaps, QEMU_CAPS_XEN_DOMID);
>      else if (strstr(help, "-domid"))
>          virQEMUCapsSet(qemuCaps, QEMU_CAPS_DOMID);
> -    if (strstr(help, "-drive")) {
> -        const char *cache = strstr(help, "cache=");
> -
> -        virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE);
> -        if (cache && (p = strchr(cache, ']'))) {
> -            if (memmem(cache, p - cache, "on|off", sizeof("on|off") - 1) == NULL)
> -                virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_CACHE_V2);
> -            if (memmem(cache, p - cache, "directsync", sizeof("directsync") - 1))
> -                virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_CACHE_DIRECTSYNC);
> +    const char *cache = strstr(help, "cache=");
> +
> +    if (cache && (p = strchr(cache, ']'))) {
> +        if (memmem(cache, p - cache, "on|off", sizeof("on|off") - 1) == NULL)
> +            virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_CACHE_V2);
> +        if (memmem(cache, p - cache, "directsync", sizeof("directsync") - 1))
> +            virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_CACHE_DIRECTSYNC);
>              if (memmem(cache, p - cache, "unsafe", sizeof("unsafe") - 1))
>                  virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_CACHE_UNSAFE);

Coverity complains here because of indent mismatching

Looks like these two lines need to be dropped back a level

John
> -        }
> -        if (strstr(help, "format="))
> -            virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_FORMAT);
> -        if (strstr(help, "readonly="))
> -            virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_READONLY);
> -        if (strstr(help, "aio=threads|native"))
> -            virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_AIO);
> -        if (strstr(help, "copy-on-read=on|off"))
> -            virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_COPY_ON_READ);
> -        if (strstr(help, "bps="))
> -            virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE);
>      }
> +    if (strstr(help, "format="))
> +        virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_FORMAT);
> +    if (strstr(help, "readonly="))
> +        virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_READONLY);
> +    if (strstr(help, "aio=threads|native"))
> +        virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_AIO);
> +    if (strstr(help, "copy-on-read=on|off"))
> +        virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_COPY_ON_READ);
> +    if (strstr(help, "bps="))
> +        virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE);
> +
>      if ((p = strstr(help, "-vga")) && !strstr(help, "-std-vga")) {
>          const char *nl = strstr(p, "\n");
>  

[...]




More information about the libvir-list mailing list