Bug 844909

Summary: RFE: Add cache mode "directsync" and "unsafe"
Product: Red Hat Enterprise Linux 6 Reporter: Daisy Wu <jwu>
Component: python-virtinstAssignee: virt-mgr-maint
Status: CLOSED DUPLICATE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 6.3CC: dallan, gscrivan, juzhou, martin.millnert, mzhan, rwu, tzheng, yupzhang, zpeng
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-01 16:01:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch to add support for cache=unsafe, directsync
none
Patch to add support for cache=unsafe, directsync (v2) none

Description Daisy Wu 2012-08-01 08:55:03 UTC
Description of problem:
libvirt support cache mode "directsync" and "unsafe", but virt-install does not support these two mode.

Version-Release number of selected component (if applicable):
python-virtinst-0.600.0-8.el6.noarch
qemu-kvm-0.12.1.2-2.297.el6.x86_64
libvirt-0.9.10-21.el6_3.3.x86_64


How reproducible:
Always.

Steps to Reproduce:
1. # virt-install --name cache --ram 1024 --vcpu=1 --disk path=/var/lib/libvirt/images/cache.img,size=6,cache=directsync --location http://tree.englab.nay.redhat.com/pub/rhel/released/RHEL-6/6.3/Server/x86_64/os/ --debug
Tue, 31 Jul 2012 06:59:18 DEBUG    Launched with command line:
/usr/sbin/virt-install --name cache --ram 1024 --vcpu=1 --disk path=/var/lib/libvirt/images/cache.img,size=6,cache=directsync --location http://tree.englab.nay.redhat.com/pub/rhel/released/RHEL-6/6.3/Server/x86_64/os/ --debug
Tue, 31 Jul 2012 06:59:18 DEBUG    Requesting libvirt URI default
Tue, 31 Jul 2012 06:59:18 DEBUG    Received libvirt URI qemu:///system
Tue, 31 Jul 2012 06:59:19 DEBUG    Requesting virt method 'default', hv type 'default'.
Tue, 31 Jul 2012 06:59:19 DEBUG    Received virt method 'hvm'
Tue, 31 Jul 2012 06:59:19 DEBUG    Hypervisor name is 'kvm'
Tue, 31 Jul 2012 06:59:22 DEBUG    DISPLAY is set: graphics defaulting to VNC.
Tue, 31 Jul 2012 06:59:22 DEBUG    --graphics compat generated: vnc
Tue, 31 Jul 2012 06:59:22 DEBUG    Path '/var/lib/libvirt/images' is target for pool 'default'. Creating volume 'cache.img'.
Tue, 31 Jul 2012 06:59:23 DEBUG    Path '/var/lib/libvirt/images' is target for pool 'default'. Creating volume 'cache.img'.
Tue, 31 Jul 2012 06:59:23 ERROR    Error with storage parameters: Unknown cache mode 'directsync'
Tue, 31 Jul 2012 06:59:23 DEBUG    Traceback (most recent call last):
  File "/usr/sbin/virt-install", line 137, in get_disk
    dev, size = cli.parse_disk(guest, diskopts)
  File "/usr/lib/python2.6/site-packages/virtinst/cli.py", line 1574, in parse_disk
    set_param("driver_cache", "cache")
  File "/usr/lib/python2.6/site-packages/virtinst/cli.py", line 1124, in _set_param
    setattr(inst, paramname, val)
  File "/usr/lib/python2.6/site-packages/virtinst/XMLBuilderDomain.py", line 309, in new_setter
    fset(self, val, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/virtinst/VirtualDisk.py", line 850, in _set_driver_cache
    raise ValueError(_("Unknown cache mode '%s'" % val))
ValueError: Unknown cache mode 'directsync'


2. # virt-install --name cache --ram 1024 --vcpu=1 --disk path=/var/lib/libvirt/images/cache.img,size=6,cache=unsafe --location http://tree.englab.nay.redhat.com/pub/rhel/released/RHEL-6/6.3/Server/x86_64/os/ --debug
Tue, 31 Jul 2012 06:59:35 DEBUG    Launched with command line:
/usr/sbin/virt-install --name cache --ram 1024 --vcpu=1 --disk path=/var/lib/libvirt/images/cache.img,size=6,cache=unsafe --location http://tree.englab.nay.redhat.com/pub/rhel/released/RHEL-6/6.3/Server/x86_64/os/ --debug
Tue, 31 Jul 2012 06:59:35 DEBUG    Requesting libvirt URI default
Tue, 31 Jul 2012 06:59:35 DEBUG    Received libvirt URI qemu:///system
Tue, 31 Jul 2012 06:59:35 DEBUG    Requesting virt method 'default', hv type 'default'.
Tue, 31 Jul 2012 06:59:35 DEBUG    Received virt method 'hvm'
Tue, 31 Jul 2012 06:59:35 DEBUG    Hypervisor name is 'kvm'
Tue, 31 Jul 2012 06:59:36 DEBUG    DISPLAY is set: graphics defaulting to VNC.
Tue, 31 Jul 2012 06:59:36 DEBUG    --graphics compat generated: vnc
Tue, 31 Jul 2012 06:59:37 DEBUG    Path '/var/lib/libvirt/images' is target for pool 'default'. Creating volume 'cache.img'.
Tue, 31 Jul 2012 06:59:37 DEBUG    Path '/var/lib/libvirt/images' is target for pool 'default'. Creating volume 'cache.img'.
Tue, 31 Jul 2012 06:59:37 ERROR    Error with storage parameters: Unknown cache mode 'unsafe'
Tue, 31 Jul 2012 06:59:37 DEBUG    Traceback (most recent call last):
  File "/usr/sbin/virt-install", line 137, in get_disk
    dev, size = cli.parse_disk(guest, diskopts)
  File "/usr/lib/python2.6/site-packages/virtinst/cli.py", line 1574, in parse_disk
    set_param("driver_cache", "cache")
  File "/usr/lib/python2.6/site-packages/virtinst/cli.py", line 1124, in _set_param
    setattr(inst, paramname, val)
  File "/usr/lib/python2.6/site-packages/virtinst/XMLBuilderDomain.py", line 309, in new_setter
    fset(self, val, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/virtinst/VirtualDisk.py", line 850, in _set_driver_cache
    raise ValueError(_("Unknown cache mode '%s'" % val))
ValueError: Unknown cache mode 'unsafe'


Actually results:
As above.

Expected results:
virt-install should contain cache mode "directsync" and "unsafe".

Additional info:
1. refer to man of virsh attach-disk:
# man virsh
...
       attach-disk domain-id source target [--driver driver] [--subdriver subdriver]
       [--cache cache] [--type type] [--mode mode] [--persistent] [--sourcetype
       soucetype] [--serial serial] [--shareable] [--rawio] [--address address]
       [--multifunction]
...
           cache can be one of "default", "none", "writethrough", "writeback", "directsync" or
           "unsafe". 
...

2. results of libvirt-0.9.13-3.el6 of cache mode:
# virsh attach-disk guest /var/lib/libvirt/images/disk5.img vdf --cache unsafe
# virsh dumpxml guest
...
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='unsafe'/>
      <source dev='/var/lib/libvirt/images/disk5.img'/>
      <target dev='vdf' bus='virtio'/>
    </disk>
...

# virsh attach-disk guest /var/lib/libvirt/images/disk6.img vdg --cache directsync
error: Failed to attach disk
error: unsupported configuration: disk cache mode 'directsync' is not supported by this QEMU

# virsh dumpxml guest
...
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='directsync'/>
      <source dev='/var/lib/libvirt/images/disk6.img'/>
      <target dev='vdg' bus='virtio'/>
    </disk>
...

Comment 2 Dave Allan 2012-08-01 16:01:05 UTC

*** This bug has been marked as a duplicate of bug 844907 ***

Comment 3 Martin Millnert 2015-02-12 09:56:11 UTC
Created attachment 990838 [details]
Patch to add support for cache=unsafe, directsync

This bug has been *incorrectly* marked as duplicate of 844907.

This RFE/bug reports regards   **virt-install**, bug 844907 regards **virt-manager** - these are two distinct and unique programs.

This bug is *not* resolved in rhel 7.

The two cache modes unsafe and directsync are still missing on virt-install (virt-install-0.10.0-20.el7.noarch).

I've supplied a patch against the installed code of virtinstall-0.10.0-20.el7.noarch (located in /usr/share/virt-manager/ )

Tested and works for me:
[root@localhost bin]# grep --color=auto cache /etc/libvirt/qemu/ft-qcow-directsync-test.xml 
      <driver name='qemu' type='qcow2' cache='directsync' io='native'/>
[root@localhost bin]# grep --color=auto cache /etc/libvirt/qemu/ft-qcow-unsafe-test.xml 
      <driver name='qemu' type='qcow2' cache='unsafe' io='native'/>

BR,
Martin Millnert

Comment 4 Martin Millnert 2015-02-12 10:15:48 UTC
Created attachment 990842 [details]
Patch to add support for cache=unsafe, directsync (v2)

Resubmitting the patch to add support for cache=[unsafe|directsync], this time in proper order.

Comment 5 Giuseppe Scrivano 2015-02-12 13:06:14 UTC
Thanks for the patch, this feature will be present in RHEL-7.1 as virt-manager was rebased on top of the upstream version 1.1.10 which already has this feature.

Comment 6 zhoujunqin 2015-02-13 06:28:21 UTC
Try to test with the two cache mode: unsafe and directsync on RHEL-7.1.
packages:
virt-manager-common-1.1.0-12.el7.noarch
virt-install-1.1.0-12.el7.noarch
virt-manager-1.1.0-12.el7.noarch

From virt-manager GUI checking:

1.Launch virt-manager: #virt-manager
2.Double-click a vm and click the Run button in the Virtual Machine Details window.
3.Click the Hardware tab.
4.Click Add Hardware button
5.Select Storage in Hardware type droplist and click Forward.
6.Select managed or other existing storage and fill out the Location of  Block device(partition), eg: /dev/sda3.
7.Select vitual disk in Device type then click Forward.
8.Click Finish button.
9.Reboot vm and check Hardware tab.
10.loop upper steps with all options of cache mode: default, none, writeback, writethrough, unsafe, directsync

Result: All cache modes work well.

From virt-install cmd checking:

1. Check virt-install man page:
# man virt-install
...
         cache
             The cache mode to be used. The host pagecache provides cache memory.  The cache value can be 'none', 'writethrough', or
             'writeback'.  'writethrough' provides read caching. 'writeback' provides read and write caching.
...

Result: cannot find unsafe, directsync mode.

2. Try to install guest with the two cache mode:
2.1 cache=unsafe
#  virt-install --name cache-unsafe --ram 1024 --vcpu=1 --disk path=/var/lib/libvirt/images/cache-unsafe.img,size=6,cache=unsafe --location /var/lib/libvirt/images/RHEL-6.6-20140926.0-Server-x86_64-dvd1.iso

Starting install...
Retrieving file .treeinfo...                                                                                         | 5.4 kB  00:00:00     
Retrieving file vmlinuz...                                                                                           | 7.9 MB  00:00:00     
...
Result: Installation finished with no error.

# grep --color=auto cache /etc/libvirt/qemu/cache-unsafe.xml 
  virsh edit cache-unsafe
  <name>cache-unsafe</name>
      <driver name='qemu' type='raw' cache='unsafe'/>
      <source file='/var/lib/libvirt/images/cache-unsafe.img'/>


2.2 cache=directsync

# virt-install --name cache-directsync --ram 1024 --vcpu=1 --disk path=/var/lib/libvirt/images/cache-directsync.img,size=6,cache=directsync --location /var/lib/libvirt/images/RHEL-6.6-20140926.0-Server-x86_64-dvd1.iso

Starting install...
Retrieving file .treeinfo...                                                                                         | 5.4 kB  00:00:00     
Retrieving file vmlinuz...                                                                                           | 7.9 MB  00:00:00  
...
Result: Installation finished with no error.

# grep --color=auto cache /etc/libvirt/qemu/cache-directsync.xml
  virsh edit cache-directsync
  <name>cache-directsync</name>
      <driver name='qemu' type='raw' cache='directsync'/>
      <source file='/var/lib/libvirt/images/cache-directsync.img'/>


As a result, the two cache mode works well for virt-manager and virt-install cmd, so Giuseppe Scrivano, i think we should add them to virt-install man page, and will we file a bug to track this manual issue, please help check it, thanks.

Comment 7 Giuseppe Scrivano 2015-02-13 08:52:49 UTC
thanks to have noticed that.

I have proposed a patch to fix it: https://www.redhat.com/archives/virt-tools-list/2015-February/msg00034.html