mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
qemu: Format 'write-cache' parameter for disk frontends
The disk cache mode translates to various frontend and backend attributes for the qemu block layer. For the frontend device the 'writeback' parameter is used and provided as 'write-cache'. Implement this so that we can later switch to using -blockdev where we will not pass the cachemode directly any more. Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
955df88de6
commit
327430fcfc
@ -1824,6 +1824,30 @@ qemuCheckIOThreads(const virDomainDef *def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuBuildDriveDevCacheStr(virDomainDiskDefPtr disk,
|
||||||
|
virBufferPtr buf,
|
||||||
|
virQEMUCapsPtr qemuCaps)
|
||||||
|
{
|
||||||
|
bool wb;
|
||||||
|
|
||||||
|
if (disk->cachemode == VIR_DOMAIN_DISK_CACHE_DEFAULT)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISK_WRITE_CACHE))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (qemuDomainDiskCachemodeFlags(disk->cachemode, &wb, NULL, NULL) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
virBufferStrcat(buf, ",write-cache=",
|
||||||
|
virTristateSwitchTypeToString(virTristateSwitchFromBool(wb)),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
qemuBuildDriveDevStr(const virDomainDef *def,
|
qemuBuildDriveDevStr(const virDomainDef *def,
|
||||||
virDomainDiskDefPtr disk,
|
virDomainDiskDefPtr disk,
|
||||||
@ -2140,6 +2164,9 @@ qemuBuildDriveDevStr(const virDomainDef *def,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qemuBuildDriveDevCacheStr(disk, &opt, qemuCaps) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (virBufferCheckError(&opt) < 0)
|
if (virBufferCheckError(&opt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -28,16 +28,18 @@ server,nowait \
|
|||||||
-device lsi,id=scsi0,bus=pci.0,addr=0x2 \
|
-device lsi,id=scsi0,bus=pci.0,addr=0x2 \
|
||||||
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
|
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
|
||||||
cache=writeback \
|
cache=writeback \
|
||||||
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
|
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1,\
|
||||||
|
write-cache=on \
|
||||||
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-scsi0-0-0,\
|
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-scsi0-0-0,\
|
||||||
cache=none \
|
cache=none \
|
||||||
-device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 \
|
-device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0,\
|
||||||
|
write-cache=on \
|
||||||
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-virtio-disk0,\
|
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-virtio-disk0,\
|
||||||
cache=writethrough \
|
cache=writethrough \
|
||||||
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\
|
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\
|
||||||
id=virtio-disk0 \
|
id=virtio-disk0,write-cache=off \
|
||||||
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-usb-disk1,\
|
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-usb-disk1,\
|
||||||
cache=directsync \
|
cache=directsync \
|
||||||
-device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk1,id=usb-disk1,\
|
-device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk1,id=usb-disk1,\
|
||||||
removable=off \
|
removable=off,write-cache=off \
|
||||||
-msg timestamp=on
|
-msg timestamp=on
|
||||||
|
@ -28,18 +28,20 @@ server,nowait \
|
|||||||
-device lsi,id=scsi0,bus=pci.0,addr=0x2 \
|
-device lsi,id=scsi0,bus=pci.0,addr=0x2 \
|
||||||
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
|
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
|
||||||
cache=writeback \
|
cache=writeback \
|
||||||
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
|
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1,\
|
||||||
|
write-cache=on \
|
||||||
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-scsi0-0-0,\
|
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-scsi0-0-0,\
|
||||||
cache=none \
|
cache=none \
|
||||||
-device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 \
|
-device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0,\
|
||||||
|
write-cache=on \
|
||||||
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-virtio-disk0,\
|
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-virtio-disk0,\
|
||||||
cache=writethrough \
|
cache=writethrough \
|
||||||
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\
|
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\
|
||||||
id=virtio-disk0 \
|
id=virtio-disk0,write-cache=off \
|
||||||
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-usb-disk1,\
|
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-usb-disk1,\
|
||||||
cache=directsync \
|
cache=directsync \
|
||||||
-device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk1,id=usb-disk1,\
|
-device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk1,id=usb-disk1,\
|
||||||
removable=off \
|
removable=off,write-cache=off \
|
||||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
||||||
resourcecontrol=deny \
|
resourcecontrol=deny \
|
||||||
-msg timestamp=on
|
-msg timestamp=on
|
||||||
|
Loading…
Reference in New Issue
Block a user