Bug 662908

Summary: virsh attach-disk doesn't work well for xenpv guest
Product: Red Hat Enterprise Linux 5 Reporter: koka xiong <kxiong>
Component: libvirtAssignee: Osier Yang <jyang>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 5.7CC: berrange, dallan, dyuan, eblake, gren, hjiang, jyang, llim, mjenner, virt-maint, weizhan, xen-maint, yoyzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.8.2-18.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-06-09 15:36:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description koka xiong 2010-12-14 06:42:31 UTC
Description of problem:
run virsh attach-disk xenpv /var/lib/xen/foo.img  xvdb --driver tap --subdriver raw --type aio  --mode readonly --sourcetype file
It output
error: Failed to attach disk
error: Requested operation is not valid: Xm driver only supports modifying persistent config

Version-Release number of selected component (if applicable):
libvirt-python-0.8.2-15.el5
libvirt-0.8.2-15.el5
kernel-xen-2.6.18-236.el5
kernel-2.6.18-236.el5

How reproducible:
always

Steps to Reproduce:
1.qemu-img create -f raw  foo.img 10M
2.Start a xenpv guest
3.Run virsh attach-disk xenpv /var/lib/xen/foo.img  xvdb --driver tap --subdriver raw --type aio  --mode readonly --persistent --sourcetype file

  
Actual results:
It output
error: Failed to attach disk
error: Requested operation is not valid: Xm driver only supports modifying persistent config

Expected results:
By virt-manager,I can successfully attach the disk.

Additional info:

Comment 1 koka xiong 2010-12-14 08:10:44 UTC
run virsh attach-disk xenpv /var/lib/xen/foo.img  xvdb 
also output the following error:
error: Failed to attach disk
error: Requested operation is not valid: Xm driver only supports modifying
persistent config

Comment 2 Daniel Berrangé 2010-12-14 11:44:58 UTC
Are you sure the guest was still running when you invoked 'attach-disk'? I somewhat suspect it was not, because it it was running this would have been handled by 'XenD' rather than 'Xm'.

Comment 3 koka xiong 2010-12-15 01:26:56 UTC
yes,the guest is running when I invoked attach-disk

If I attach the disk by virt-manager,I can attach disk successfully.

but by the virsh attach-disk command,it can't work well.

Comment 4 Osier Yang 2010-12-15 01:35:33 UTC
so, that should be some problem in virsh, please keep your machine, I'd like to have a look, thanks.

- Osier

Comment 5 koka xiong 2010-12-15 08:29:19 UTC
run virsh detach-device rhel5.5 hotplug_nic.xml has the same problem
error: Failed to detach device from hotplug_nic.xml
error: Requested operation is not valid: Xm driver only supports modifying persistent config

Comment 6 Osier Yang 2010-12-15 13:32:37 UTC
Actually attach-device also will be failed sometimes, that's caused by "domainAttachDevice" of "xenDaemonDriver" will be failed, so the code goes on invoking "domainAttachDevice" of "xenXMDriver".

And it's a little surprised that "domainAttachDevice" of "xenDaemonDriver" invokes "reConfigureDevice", attaching device will be failed when it trys
to invoke "reConfigureDevice", and will be success if not. I'm still curious
why it sometime invokes "reConfigureDevice", sometimes not. Will it detect
it later.


[root@dhcp-93-194 ~]# cat /var/log/xen/xend.log
[2010-12-15 08:19:00 xend 4182] DEBUG (blkif:27) exception looking up device number for xvdb: [Errno 2] No such file or directory: '/dev/xvdb'
[2010-12-15 08:19:00 xend 4182] ERROR (SrvBase:88) Request device_configure failed.
Traceback (most recent call last):
  File "/usr/lib64/python2.4/site-packages/xen/web/SrvBase.py", line 85, in perform
    return op_method(op, req)
  File "/usr/lib64/python2.4/site-packages/xen/xend/server/SrvDomain.py", line 186, in op_device_configure
    req)
  File "/usr/lib64/python2.4/site-packages/xen/xend/server/SrvDomain.py", line 158, in call
    return FormFn(fn, args)(req.args)
  File "/usr/lib64/python2.4/site-packages/xen/xend/Args.py", line 166, in __call__
    return self.call_with_form_args(self.fn, fargs, xargs=xargs)
  File "/usr/lib64/python2.4/site-packages/xen/xend/Args.py", line 138, in call_with_form_args
    return fn(*params, **keys)
  File "/usr/lib64/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 2754, in device_configure
    self.reconfigureDevice(deviceClass, devid, dev_config)
  File "/usr/lib64/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 1526, in reconfigureDevice
    return self.getDeviceController(deviceClass).reconfigureDevice(
  File "/usr/lib64/python2.4/site-packages/xen/xend/server/blkif.py", line 126, in reconfigureDevice
    raise VmError('Refusing to reconfigure device %s:%d to %s' %
VmError: Refusing to reconfigure device vbd:51728 to ['vbd', ['dev', 'xvdb'], ['uname', 'phy:/var/lib/xen/foo.img'], ['mode', 'w']]

Comment 7 Osier Yang 2010-12-16 12:12:03 UTC
if the target device already exists, xend driver will update the existed device config, IMHO this should be prevented, as we already provide "update device" API there. If this idea is fine, I'd like post patch upstream.

- Osier

Comment 8 Osier Yang 2011-02-01 05:07:17 UTC
patch was posted to upstream 1 month ago:
http://www.redhat.com/archives/libvir-list/2010-December/msg00816.html

but no feedback, will resend it.

Comment 9 Osier Yang 2011-02-12 06:32:51 UTC
patch pushed into upstream:

http://www.redhat.com/archives/libvir-list/2011-February/msg00217.html

Comment 10 Osier Yang 2011-02-17 03:34:59 UTC
http://post-office.corp.redhat.com/archives/rhvirt-patches/2011-February/msg01075.html

patch posted internally. move to POST

Comment 13 weizhang 2011-04-07 03:38:15 UTC
I test it on 
libvirt-0.8.2-18.el5
xen-libs-3.0.3-127.el5
xen-3.0.3-127.el5

The problem seems still exist. So I reopen this bug.

Comment 14 Huming Jiang 2011-06-01 09:18:06 UTC
Could reproduce this bug on the following components of rh5.6:
xen-libs-3.0.3-120.el5
kernel-xen-2.6.18-238.el5
libvirt-0.8.2-15.el5
xen-3.0.3-120.el5

Steps:
1.qemu-img create -f raw  foo.img 10M
Formatting 'foo.img', fmt=raw, size=10240 kB

2.Start a guest

3.#virsh attach-disk a foo.img  xvdb --driver tap --subdriver raw --type aio --mode readonly --persistent --sourcetype file
error: Failed to attach disk
error: Requested operation is not valid: Xm driver only supports modifying persistent config

4.# virsh attach-disk a foo.img xvdb
error: Failed to attach disk
error: Requested operation is not valid: Xm driver only supports modifying persistent config

Comment 15 zhanghaiyan 2011-06-09 03:38:34 UTC
Osier, this bug still can reproduce this bug on libvirt-0.8.2-20.el5, could you please take a look ?
# virsh attach-disk xenpv foo.img xvdb
error: Failed to attach disk
error: Requested operation is not valid: Xm driver only supports modifying persistent config