[libvirt] [PATCHv3] Add unsafe cache mode support for disk driver
Eric Blake
eblake at redhat.com
Fri Sep 23 14:32:04 UTC 2011
On 09/22/2011 01:33 PM, Oskari Saarenmaa wrote:
> QEMU 0.13 introduced cache=unsafe for -drive, this patch exposes
> it in the libvirt layer.
>
> * Introduced a new QEMU capability flag ($prefix_CACHE_UNSAFE),
> as even if $prefix_CACHE_V2 is set, we can't known if unsafe
s/known/know/
> is supported.
>
> * Improved the reliability of qemu cache type detection.
> ---
> Updated patch based on Eric Blake's comments and rebased it to c4111bd0
>
> +++ b/docs/formatdomain.html.in
> @@ -996,10 +996,15 @@
> <li>
> The optional<code>cache</code> attribute controls the
> cache mechanism, possible values are "default", "none",
> - "writethrough", "writeback", and "directsync". "directsync"
> - is like "writethrough", but it bypasses the host page
> - cache.
> -<span class="since">Since 0.6.0</span>
> + "writethrough", "writeback", "directsync" (like
> + "writethrough", but it bypasses the host page cache) and
> + "unsafe" (host may cache all disk io and sync requests from
s/io and/io, and/
> @@ -912,12 +914,16 @@ qemuCapsComputeCmdFlags(const char *help,
> else if (strstr(help, "-domid"))
> qemuCapsSet(flags, QEMU_CAPS_DOMID);
> if (strstr(help, "-drive")) {
> + const char *cache = strstr(help, "cache=");
> +
> qemuCapsSet(flags, QEMU_CAPS_DRIVE);
> - if (strstr(help, "cache=")&&
> - !strstr(help, "cache=on|off")) {
> - qemuCapsSet(flags, QEMU_CAPS_DRIVE_CACHE_V2);
> - if (strstr(help, "directsync"))
> + if (cache&& (p = strchr(cache, ']'))) {
> + if (memmem(cache, p - cache, "on|off", sizeof("on|off") - 1) == NULL)
> + qemuCapsSet(flags, QEMU_CAPS_DRIVE_CACHE_V2);
> + if (memmem(cache, p - cache, "directsync", sizeof("directsync") - 1))
> qemuCapsSet(flags, QEMU_CAPS_DRIVE_CACHE_DIRECTSYNC);
> + if (memmem(cache, p - cache, "unsafe", sizeof("unsafe") - 1))
> + qemuCapsSet(flags, QEMU_CAPS_DRIVE_CACHE_UNSAFE);
Nice! And indeed, unsafe but not directsync is present in qemu 0.14.0,
so this does need another capability bit.
ACK and pushed.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
More information about the libvir-list
mailing list