qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Disk cache defaults
@ 2020-07-22  6:14 anthony smith
  2020-07-29 13:02 ` Stefan Hajnoczi
  0 siblings, 1 reply; 3+ messages in thread
From: anthony smith @ 2020-07-22  6:14 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 899 bytes --]

Having spent a while searching for answers on this I am making a last-ditch
effort by contacting the devel group.

Could someone let me know if it is possible to change the default disk
cache setting in qemu globally?

Currently it is set to writeback, in many if not most use cases "none" is
optimal.

I am aware I can change it per instance however I really need to find a
global method so that unless specified otherwise the default becomes
cache=none

It does seem a little strange that options appear to exist:

qemu-img -h | grep writeback
    options are: 'none', 'writeback' (default, except for convert),
'writethrough',

However I can't find any documentation that hints at a method of changing
the default, rather all documentation provides is a method per use/instance.

Appreciate any assistance even if the answer is just "Not possible" so I
can at least drop this search for answers.

[-- Attachment #2: Type: text/html, Size: 1086 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Disk cache defaults
  2020-07-22  6:14 Disk cache defaults anthony smith
@ 2020-07-29 13:02 ` Stefan Hajnoczi
  2020-07-30 15:23   ` Markus Armbruster
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2020-07-29 13:02 UTC (permalink / raw)
  To: anthony smith; +Cc: Kevin Wolf, qemu-devel, qemu-block, Markus Armbruster

[-- Attachment #1: Type: text/plain, Size: 938 bytes --]

On Wed, Jul 22, 2020 at 07:14:59AM +0100, anthony smith wrote:
> Appreciate any assistance even if the answer is just "Not possible" so I
> can at least drop this search for answers.

You can create an /etc/qemu/qemu.conf file but I don't remember if there
is syntax to set -drive cache=none.

CCing Kevin Wolf and Markus Armbruster for ideas.

The hacky "solution" is to write a wrapper script (e.g. a shell script)
that modifies QEMU command-line arguments to use cache=none if no
explicit cache= option was given:

  $ cat qemu-wrapper.sh
  #!/bin/bash
  # Add QEMU -drive cache=none

  declare -a opts

  i=0
  is_drive=0
  for opt in "$@"; do
    if [ "$is_drive" -eq 1 ]; then
      opt="$opt,cache=none" # TODO skip if cache= is already in opts?
    fi
    opts[$i]="$opt"
    if [ "$opt" = "-drive" ]; then
      is_drive=1
    else
      is_drive=0
    fi
    i=$((i + 1))
  done

  exec /usr/bin/qemu-system-x86_64 "${opts[@]}"

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Disk cache defaults
  2020-07-29 13:02 ` Stefan Hajnoczi
@ 2020-07-30 15:23   ` Markus Armbruster
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2020-07-30 15:23 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Kevin Wolf, anthony smith, qemu-devel, qemu-block

Stefan Hajnoczi <stefanha@gmail.com> writes:

> On Wed, Jul 22, 2020 at 07:14:59AM +0100, anthony smith wrote:
>> Appreciate any assistance even if the answer is just "Not possible" so I
>> can at least drop this search for answers.
>
> You can create an /etc/qemu/qemu.conf file but I don't remember if there
> is syntax to set -drive cache=none.
>
> CCing Kevin Wolf and Markus Armbruster for ideas.

I'm not aware of a way to modify defaults (except for device propeties
with -global, which doesn't help you, and is usually a bad idea anyway).

[...]



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-30 15:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-22  6:14 Disk cache defaults anthony smith
2020-07-29 13:02 ` Stefan Hajnoczi
2020-07-30 15:23   ` Markus Armbruster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).