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) {
|
if (disk->cachemode) {
|
||||||
virBufferAsprintf(&opt, ",cache=%s",
|
virBufferAsprintf(&opt, ",cache=%s",
|
||||||
qemuDiskCacheV2TypeToString(disk->cachemode));
|
qemuDiskCacheV2TypeToString(disk->cachemode));
|
||||||
} else if (disk->src->shared && !disk->src->readonly) {
|
|
||||||
virBufferAddLit(&opt, ",cache=none");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disk->copy_on_read) {
|
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
|
int
|
||||||
qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
|
qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
|
||||||
qemuDomainObjPrivatePtr priv,
|
qemuDomainObjPrivatePtr priv,
|
||||||
virQEMUDriverConfigPtr cfg)
|
virQEMUDriverConfigPtr cfg)
|
||||||
{
|
{
|
||||||
|
qemuDomainPrepareDiskCachemode(disk);
|
||||||
|
|
||||||
if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0)
|
if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<devices>
|
<devices>
|
||||||
<emulator>/usr/bin/qemu-system-i686</emulator>
|
<emulator>/usr/bin/qemu-system-i686</emulator>
|
||||||
<disk type='block' device='disk'>
|
<disk type='block' device='disk'>
|
||||||
<driver name='qemu' type='raw'/>
|
<driver name='qemu' type='raw' cache='none'/>
|
||||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||||
<target dev='hda' bus='ide'/>
|
<target dev='hda' bus='ide'/>
|
||||||
<shareable/>
|
<shareable/>
|
||||||
|
Loading…
Reference in New Issue
Block a user