mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
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: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
f0a528ce06
commit
a801f0e79b
@ -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/>
|
||||
|
Loading…
Reference in New Issue
Block a user