Opened 3 years ago

Closed 3 years ago

Last modified 2 years ago

#12096 closed Bug/Something is broken (fixed)

modify kvm-manager to support SSD cards

Reported by: Jamie McClelland Owned by: Jamie McClelland
Priority: High Component: Tech
Keywords: ssd kvm-manager Cc: Daniel Kahn Gillmor
Sensitive: no


To prolong the life of SSD cards, we need to be able to use trim (which is a way that the filesystems communicates to the SSD cards which sectors are not in use).

Through some tedious research, I've figured out how to propagate trim requests through our various layers of crytpo and LVM.

However, it still doesn't propagate from KVM guests to the hardware (I test by running fstrim on the guest and see if it returns an error).

Through some experimentation, I found that it does propagate if I change kvm-manager, switching the KVMARGS variable to use:


Instead of


I'm wondering:

  • Is this the best approach? What are the downsides?
  • How can we tweak kvm-manager to use scsi for SSD cards?

Change History (6)

comment:1 Changed 3 years ago by Jamie McClelland

Owner: set to Jamie McClelland
Status: newassigned

comment:2 Changed 3 years ago by Jamie McClelland

I noticed that when I attach two disks with different bus types (one with virtio and one with scsi) the guests fails to boot. There is no error or failure, however, the console just show black.

If both are set to virtio OR both are set to scsi it works as expected.

comment:3 Changed 3 years ago by Jamie McClelland

dkg: I just created a new branch in my kvm-manager git repo (git:// called "diskoptions".

Would you mind reviewing and merging if you think it is acceptable?

It aims to resolve this issue (allow us to specify a if/bus type other than virtio). Also, it tries to resolve #11856 (allowing kvm-manager to add various disk throttling settings).

My initial suggestion for patching #11856 was to add variables for all of the disk IO options. Somewhere (maybe on IRC?) you suggested adding them all to the single existing variable for each disk (e.g. HDA, HDB, etc) to avoid variable proliferation.

So, I took that approach. With this patch, you can continue specifying something along the lines of:


And, it will work just as before.

However, now you can also specify:

HDA="/dev/mapper/vg-disk scsi"

To use the scsi driver instead of the virtio driver.

Or, you could specify:

HDA="/dev/mapper/vg-disk scsi iops-total=100,iops-total-max=2000,iops-total-max-length=60"

(These last options are only supported in qemu 2.6 (in stretch) but it will be nice to have them ready for when we upgrade.)

comment:4 Changed 3 years ago by Jamie McClelland

Resolution: fixed
Status: assignedclosed

I've just implemented this change via puppet (currently only live on wiwa)

comment:5 Changed 3 years ago by Jamie McClelland

And the last step is prep jacobs as a trial with:

0 wiwa:/etc/sv/kvm/jacobs/env# cat HD*
/dev/mapper/vg_wiwa0-jacobs scsi
/dev/mapper/vg_wiwa1-jacobs scsi
0 wiwa:/etc/sv/kvm/jacobs/env#

I will be confirming with Ben about making these changes live before we restart anything.

comment:6 Changed 2 years ago by Jamie McClelland

Update! I've submitted a patch to kvm-manager that allows us to change the driver from virtio to scsi in a different way (by adding an environment variable, e.g. HDB_DRIVER). See 12797#comment:4.

Please login to add comments to this ticket.

Note: See TracTickets for help on using tickets.