[libvirt-users] virsh attach-disk with cache=none and io=native for raw devices (online)

Hello, I see there is an option with virsh attach-disk to set the cache to "none" for raw devices, but I can't find how to attach the disk with io=native (needed for performance reasons). The goal is to attach a disk online, directly with the proper performance settings. I know I can set this in virt-manager, but then I have to restart the VM to apply the change, so this is an offline operation. With virsh edit, I guess I also would have to restart the VM... -- Frido Roose Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Thu, Apr 05, 2012 at 11:36:55AM +0200, Frido Roose wrote:
Hello,
I see there is an option with virsh attach-disk to set the cache to "none" for raw devices, but I can't find how to attach the disk with io=native (needed for performance reasons). The goal is to attach a disk online, directly with the proper performance settings.
virsh attach-disk is just a wrapper around the more general command virsh attach-device. So if there's stuff you can't set with attach-disk, you can always pass the complete XML to attach-device to set everything Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Thursday 5 April 2012 at 11:40, Daniel P. Berrange wrote:
On Thu, Apr 05, 2012 at 11:36:55AM +0200, Frido Roose wrote:
Hello,
I see there is an option with virsh attach-disk to set the cache to "none" for raw devices, but I can't find how to attach the disk with io=native (needed for performance reasons). The goal is to attach a disk online, directly with the proper performance settings.
virsh attach-disk is just a wrapper around the more general command virsh attach-device. So if there's stuff you can't set with attach-disk, you can always pass the complete XML to attach-device to set everything
Thanks for the tip... I made a little shell script that allows me to hot-add a device with cache=none and io=native, similar to attack-disk, and it seems to work! Best regards, Frido Roose # cat virsh-attach-disk.sh #!/bin/bash VM=$1 VDX=$2 DEV=$3 if [ -z "$VDX" ] then # try to find out next available vdx device echo "Usage: $0 <vmname> <vdx> <dev>" exit 1 fi XMLFILE=/tmp/virsh-attach-disk.$$.xml echo " <disk type='block' device='disk'> <driver name='qemu' type='raw' cache='none' io='native'/> <source dev='$DEV'/> <target dev='$VDX' bus='virtio'/> </disk> " >$XMLFILE echo "About to add the following disk config:" cat $XMLFILE echo echo " # virsh attach-device $VM $XMLFILE --persistent" echo echo -n "Apply? [y/n] " read answer if [ "$answer" == "y" -o "$answer" == "Y" ] then virsh attach-device $VM $XMLFILE --persistent else echo "Aborted!" fi rm -f $XMLFILE
participants (2)
-
Daniel P. Berrange
-
Frido Roose