RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1003291 - Backport cachemode patch to RHEL 7
Summary: Backport cachemode patch to RHEL 7
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 994517 1003685
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-09-01 17:58 UTC by Richard W.M. Jones
Modified: 2014-06-18 02:01 UTC (History)
6 users (show)

Fixed In Version: libguestfs-1.22.6-8.el7
Doc Type: Bug Fix
Doc Text:
Clone Of: 994517
Environment:
Last Closed: 2014-06-13 13:17:20 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Richard W.M. Jones 2013-09-01 17:58:23 UTC
+++ This bug was initially created as a clone of Bug #994517 +++

Description of problem:

libguestfs 1.23 introduces a new cachemode parameter for add_drive,
so that users can select the level of caching (and safety) they
require for drives.

http://libguestfs.org/guestfs.3.html#guestfs_add_drive_opts
(and scroll down to description of cachemode)

It turns out this makes many operations a lot faster, while still
preserving sufficient safety.  Therefore it makes sense to put this
into RHEL 7 if at all possible.

These commits are required:

https://github.com/libguestfs/libguestfs/commit/749e947bb0103f19feda0f29b6cbbf3cbfa350da
https://github.com/libguestfs/libguestfs/commit/96cd7fcecb031bfe6baa49addfb026ae988fb7c1
https://github.com/libguestfs/libguestfs/commit/f3a9c9f867bed178d1aabf9675955f633bf3069a
https://github.com/libguestfs/libguestfs/commit/3f0748f1fc64e42517c0d4535c27b1f32da86023

Comment 1 Richard W.M. Jones 2013-09-02 12:45:28 UTC
The suggested way to test this patch would be to run
guestfish as follows:

  $ truncate -s1G /tmp/test.img
  $ guestfish
  ><fs> add /tmp/test.img
  ><fs> run

In another window, look at the qemu command line.  For guestfish < 1.22.6-6
you would see either:

  $ ps ax | grep 'file='
  [...]
  -drive file=/tmp/test.img,[...],cache=none

or:

  -drive file=/tmp/test.img,[...]  (no cache= parameter at all).

Which you see would depend on whether /tmp uses tmpfs or not.

For guestfish >= 1.22.6-6 you should see:

  -drive file=/tmp/test.img,[...],cache=writeback

Also try:

  $ guestfish
  ><fs> add /tmp/test.img cachemode:unsafe
  ><fs> run

which should translate into:

  -drive file=/tmp/test.img,[...],cache=unsafe

Also try:

  $ guestfish
  ><fs> add /tmp/test.img cachemode:writeback
  ><fs> run

which should translate into:

  -drive file=/tmp/test.img,[...],cache=writeback

Also try:

  $ guestfish
  ><fs> add-drive-scratch 1G
  ><fs> run

which should translate into:

  -drive file=[temporary_name],[...],cache=unsafe

Note that libguestfs only supports cache modes "unsafe" and "writeback".
qemu supports a lot more modes, but they are not relevant to libguestfs
(except they should give an error if you try to use them).

Also your tests should run much more quickly, especially if you
use 'add-drive-scratch' instead of 'add' to add scratch/testing/temporary
drives (ie. drives where you don't care about the data in the
event of sudden power failure).

Comment 2 Richard W.M. Jones 2013-09-02 18:50:14 UTC
Moving back to ASSIGNED, waiting for libvirt bug 1003685 to be fixed.

Comment 3 Richard W.M. Jones 2013-09-13 13:52:04 UTC
https://brewweb.devel.redhat.com/taskinfo?taskID=6283204

Comment 5 Lingfei Kong 2013-11-04 11:37:33 UTC
Steps to reproduce:

1. 
#truncate -s1G /tmp/test.img
#guestfish
 ><fs> add /tmp/test.img
 ><fs> run

In another window, look at the qemu command line:
[host]#ps ax | grep 'file='
 2819 pts/0    Sl     0:02 /usr/libexec/qemu-kvm -global virtio-blk-pci.scsi=off -nodefconfig -nodefaults -nographic -machine accel=kvm:tcg -cpu host,+kvmclock -m 500 -no-reboot -kernel /var/tmp/.guestfs-0/kernel.2781 -initrd /var/tmp/.guestfs-0/initrd.2781 -device virtio-scsi-pci,id=scsi -drive file=/tmp/test.img,cache=none,id=hd0,if=none -device scsi-hd,drive=hd0 -drive file=/var/tmp/.guestfs-0/root.2781,snapshot=on,id=appliance,if=none,cache=unsafe -device scsi-hd,drive=appliance -device virtio-serial -serial stdio -device sga -chardev socket,path=/tmp/libguestfsRwKJa3/guestfsd.sock,id=channel0 -device virtserialport,chardev=channel0,name=org.libguestfs.channel.0 -append panic=1 console=ttyS0 udevtimeout=600 no_timer_check acpi=off printk.time=1 cgroup_disable=memory root=/dev/sdb selinux=0 TERM=xterm
 2832 pts/1    S+     0:00 grep file=

===> cache=none 


2.
 $ guestfish
  ><fs> add /tmp/test.img cachemode:unsafe
add: unknown optional argument "cachemode:unsafe"
><fs> add /tmp/test.img cachemode:writeback
add: unknown optional argument "cachemode:writeback"
><fs> 

===> unknow optional argument


3. 
 $ guestfish
><fs> add-drive-scratch 1G
add-drive-scratch: unknown command
><fs>

===>unknow command

Comment 6 Lingfei Kong 2013-11-04 12:19:08 UTC
Sorry, Just ignore Comment 5, I reproduce it with a wrong libguestfs version.

Here I reproduce it with libguestfs-1.22.6-4.el7


Steps to reproduce:
1. 
#truncate -s1G /tmp/test.img
#guestfish
><fs> add /tmp/test.img
><fs> run


# ps ax | grep 'file='
 3700 ?        Sl     0:03 /usr/libexec/qemu-kvm -name guestfs-tnlgedhcldk9lev5 -S -machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -cpu Opteron_G2,+3dnowprefetch,+cr8legacy,+extapic,+cmp_legacy,+3dnow,+3dnowext,+fxsr_opt,+mmxext,+ht,+vme -m 500 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 5ac33e52-b34d-4ec0-953a-e88c5f886f6f -nographic -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/guestfs-tnlgedhcldk9lev5.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-reboot -no-acpi -kernel /var/tmp/.guestfs-0/kernel.3626 -initrd /var/tmp/.guestfs-0/initrd.3626 -append panic=1 console=ttyS0 udevtimeout=600 no_timer_check acpi=off printk.time=1 cgroup_disable=memory root=/dev/sdb selinux=0 TERM=xterm -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4 -drive file=/tmp/test.img,if=none,id=drive-scsi0-0-0-0,format=raw,cache=none -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 -drive file=/tmp/libguestfsEzHcCk/snapshot1,if=none,id=drive-scsi0-0-1-0,format=qcow2,cache=unsafe -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=1,lun=0,drive=drive-scsi0-0-1-0,id=scsi0-0-1-0 -chardev socket,id=charserial0,path=/tmp/libguestfsEzHcCk/console.sock -device isa-serial,chardev=charserial0,id=serial0 -chardev socket,id=charchannel0,path=/tmp/libguestfsEzHcCk/guestfsd.sock -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.libguestfs.channel.0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5


===> -drive file=/tmp/test.img,if=none,id=drive-scsi0-0-0-0,format=raw,cache=none

2.
# guestfish
><fs> add /tmp/test.img cachemode:unsafe
add: unknown optional argument "cachemode:unsafe"
><fs> add /tmp/test.img cachemode:writeback
add: unknown optional argument "cachemode:writeback"

===> unknown optional argument cachemode:unsafe & cachemode:writeback

3.
#guestfish
><fs> add-drive-scratch 1G
><fs> run

# ps ax | grep 'file='
 4282 ?        Sl     0:04 /usr/libexec/qemu-kvm -name guestfs-ukgewoabfadacucb -S -machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -cpu Opteron_G2,+3dnowprefetch,+cr8legacy,+extapic,+cmp_legacy,+3dnow,+3dnowext,+fxsr_opt,+mmxext,+ht,+vme -m 500 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid ab4b0acd-41d2-4cfd-80c0-1f37f0c7909a -nographic -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/guestfs-ukgewoabfadacucb.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-reboot -no-acpi -kernel /var/tmp/.guestfs-0/kernel.4249 -initrd /var/tmp/.guestfs-0/initrd.4249 -append panic=1 console=ttyS0 udevtimeout=600 no_timer_check acpi=off printk.time=1 cgroup_disable=memory root=/dev/sdb selinux=0 TERM=xterm -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4 -drive file=/tmp/libguestfs1nlMcA/scratch.1,if=none,id=drive-scsi0-0-0-0,format=raw,cache=none -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 -drive file=/tmp/libguestfs1nlMcA/snapshot2,if=none,id=drive-scsi0-0-1-0,format=qcow2,cache=unsafe -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=1,lun=0,drive=drive-scsi0-0-1-0,id=scsi0-0-1-0 -chardev socket,id=charserial0,path=/tmp/libguestfs1nlMcA/console.sock -device isa-serial,chardev=charserial0,id=serial0 -chardev socket,id=charchannel0,path=/tmp/libguestfs1nlMcA/guestfsd.sock -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.libguestfs.channel.0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

===>  -drive file=/tmp/libguestfs1nlMcA/scratch.1,if=none,id=drive-scsi0-0-0-0,format=raw,cache=none

Comment 7 Lingfei Kong 2013-12-06 08:03:58 UTC
Verified with 

Steps to verify
1.
 #truncate -s1G /tmp/test.img
#guestfish
><fs> add /tmp/test.img
><fs>  run


# ps ax | grep 'file='
...
 -drive file=/tmp/test.img,if=none,id=drive-scsi0-0-0-0,format=raw,cache=writeback
...

2.
><fs> add /tmp/test.img cachemode:unsafe
><fs> run

#ps ax | grep 'file=
....
-drive file=/tmp/test.img,if=none,id=drive-scsi0-0-0-0,format=raw,cache=unsafe
...

3. 
><fs> add /tmp/test.img cachemode:writeback
><fs> run

#ps ax | grep 'file=
...
-drive file=/tmp/test.img,if=none,id=drive-scsi0-0-0-0,format=raw,cache=writeback
....

4. 
><fs> add-drive-scratch 1G
><fs> run

#ps ax | grep 'file=
...
-drive file=/tmp/libguestfsmI0cRv/scratch.1,if=none,id=drive-scsi0-0-0-0,format=raw,cache=unsafe
....


Summary:
All have the correct cache mode

Comment 8 Lingfei Kong 2013-12-06 08:05:50 UTC
I verified  with libguestfs-1.22.6-15.el7 in Comment #7

Comment 9 Ludek Smid 2014-06-13 13:17:20 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.


Note You need to log in before you can comment on or make changes to this bug.