提交 a801f0e7 编写于 作者: P Peter Krempa

qemu: domain: Move initialization of disk cachemode for <shareable> disks

The qemu command line generator code set disk caching of shareable disks
to 'none' when formatting the command line silently. Move this code to a
common place when preparing the domain definition for startup so that it
does not have to be duplicated.

The new test case shows that the actual cache mode will now be recorded
in the live XML definition.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
上级 f0a528ce
......@@ -1804,8 +1804,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
if (disk->cachemode) {
virBufferAsprintf(&opt, ",cache=%s",
qemuDiskCacheV2TypeToString(disk->cachemode));
} else if (disk->src->shared && !disk->src->readonly) {
virBufferAddLit(&opt, ",cache=none");
}
if (disk->copy_on_read) {
......
......@@ -11891,11 +11891,22 @@ qemuDomainPrepareDiskSourceChain(virDomainDiskDefPtr disk,
}
static void
qemuDomainPrepareDiskCachemode(virDomainDiskDefPtr disk)
{
if (disk->cachemode == VIR_DOMAIN_DISK_CACHE_DEFAULT &&
disk->src->shared && !disk->src->readonly)
disk->cachemode = VIR_DOMAIN_DISK_CACHE_DISABLE;
}
int
qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
qemuDomainObjPrivatePtr priv,
virQEMUDriverConfigPtr cfg)
{
qemuDomainPrepareDiskCachemode(disk);
if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0)
return -1;
......
......@@ -15,7 +15,7 @@
<devices>
<emulator>/usr/bin/qemu-system-i686</emulator>
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<driver name='qemu' type='raw' cache='none'/>
<source dev='/dev/HostVG/QEMUGuest1'/>
<target dev='hda' bus='ide'/>
<shareable/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册