Bug 1049529
| Summary: | virsh mishandles inactive configuration on device hot(un)plug commands | |||
|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Peter Krempa <pkrempa> | |
| Component: | libvirt | Assignee: | Peter Krempa <pkrempa> | |
| Status: | CLOSED CURRENTRELEASE | QA Contact: | Virtualization Bugs <virt-bugs> | |
| Severity: | medium | Docs Contact: | ||
| Priority: | medium | |||
| Version: | 7.0 | CC: | acathrow, bili, codong, cwei, dyuan, gsun, jmiao, lsu, mzhan, pkrempa, weizhan, xuzhang | |
| Target Milestone: | rc | |||
| Target Release: | --- | |||
| Hardware: | Unspecified | |||
| OS: | Unspecified | |||
| Whiteboard: | ||||
| Fixed In Version: | libvirt-1.1.1-18.el7 | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | ||
| Clone Of: | 921398 | |||
| : | 1125194 (view as bug list) | Environment: | ||
| Last Closed: | 2014-06-13 10:33:15 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: | ||||
| Bug Depends On: | 921398 | |||
| Bug Blocks: | 921407, 1125194 | |||
|
Description
Peter Krempa
2014-01-07 17:08:50 UTC
Fixed upstream:
commit f9d06ebcef9faffc085bab68968b8bb78f49f2d0
Author: Peter Krempa <pkrempa>
Date: Tue Jan 7 17:58:47 2014 +0100
virsh: Use inactive definition when removing disk from config
https://bugzilla.redhat.com/show_bug.cgi?id=1049529
The 'detach-disk' command in virsh used the active XML definition of a
domain even when attempting to remove a disk from the config only. If
the disk was only in the inactive definition the operation failed. Fix
this by using the inactive XML in case that only the config is affected.
commit 0bb64df1fcbf8248d8b71c44c8c882ae7b17d846
Author: Peter Krempa <pkrempa>
Date: Tue Jan 7 16:44:02 2014 +0100
virsh: Don't use legacy API if --current is used on device hot(un)plug
https://bugzilla.redhat.com/show_bug.cgi?id=1049529
The legacy virDomainAttachDevice and virDomainDetachDevice operate only
on active domains. When a user specified --current flag with an inactive
domain the old API was used and reported an error. Fix it by calling the
new API if --current is specified explicitly.
pkgs libvirt-1.1.1-18.el7.x86_64 qemu-kvm-rhev-1.5.3-30.el7.x86_64 kernel-3.10.0-64.el7.x86_64 steps: scenario 1: attach/detach with --config when domain is running 1. attach with --config when domain is running # qemu-img create /tmp/aa.img 10M Formatting '/tmp/aa.img', fmt=raw size=10485760 # virsh list Id Name State ---------------------------------------------------- 2 kvm-rhel6.5-x86_64-qcow2-virtio running # virsh attach-disk kvm-rhel6.5-x86_64-qcow2-virtio /tmp/aa.img vdd --config Disk attached successfully # virsh domblklist kvm-rhel6.5-x86_64-qcow2-virtio Target Source ------------------------------------------------ vda /var/lib/libvirt/images/kvm-rhel6.5-x86_64-qcow2.img # virsh domblklist kvm-rhel6.5-x86_64-qcow2-virtio --inactive Target Source ------------------------------------------------ vda /var/lib/libvirt/images/kvm-rhel6.5-x86_64-qcow2.img vdd /tmp/aa.img 2. detach with --config when domain is running # virsh detach-disk kvm-rhel6.5-x86_64-qcow2-virtio vdd --config Disk detached successfully # virsh domblklist kvm-rhel6.5-x86_64-qcow2-virtio Target Source ------------------------------------------------ vda /var/lib/libvirt/images/kvm-rhel6.5-x86_64-qcow2.img # virsh domblklist kvm-rhel6.5-x86_64-qcow2-virtio --inactive Target Source ------------------------------------------------ vda /var/lib/libvirt/images/kvm-rhel6.5-x86_64-qcow2.img --config works with running domain now. scenario 2: attach/detach with --current # virsh attach-disk kvm-rhel6.5-x86_64-qcow2-virtio /tmp/aa.img vdd error: Failed to attach disk error: Requested operation is not valid: cannot do live update a device on inactive domain seems here by default is --live if not given flags, maybe by default should be --current here which will work like follow as --current specific given (@pkrempa, is it worth a fix?) # virsh attach-disk kvm-rhel6.5-x86_64-qcow2-virtio /tmp/aa.img vdd --current Disk attached successfully # virsh domblklist kvm-rhel6.5-x86_64-qcow2-virtio Target Source ------------------------------------------------ vda /var/lib/libvirt/images/kvm-rhel6.5-x86_64-qcow2.img vdd /tmp/aa.img # virsh detach-disk kvm-rhel6.5-x86_64-qcow2-virtio vdd error: Failed to detach disk error: Requested operation is not valid: cannot do live update a device on inactive domain same here as default flag is not --current # virsh detach-disk kvm-rhel6.5-x86_64-qcow2-virtio vdd --current Disk detached successfully # virsh domblklist kvm-rhel6.5-x86_64-qcow2-virtio Target Source ------------------------------------------------ vda /var/lib/libvirt/images/kvm-rhel6.5-x86_64-qcow2.img Hi Peter, Could you help check the default flag problem raised in scenario 2, if it not worth a fix, then I'll mark this as verified, thx! Hi Wayne, (In reply to Wayne Sun from comment #4) ... > scenario 2: > attach/detach with --current > # virsh attach-disk kvm-rhel6.5-x86_64-qcow2-virtio /tmp/aa.img vdd > error: Failed to attach disk > error: Requested operation is not valid: cannot do live update a device on > inactive domain > > seems here by default is --live if not given flags, maybe by default should > be --current here which will work like follow as --current specific given > (@pkrempa, is it worth a fix?) This is correct according to the man page for the hotplug APIs: If --live is specified, affect a running domain. If --config is specified, affect the next startup of a persistent domain. If --current is specified, affect the current domain state. Both --live and --config flags may be given, but --current is exclusive. When no flag is specified legacy API is used whose behavior depends on the hypervisor driver. > > Hi Peter, > > Could you help check the default flag problem raised in scenario 2, if it > not worth a fix, then I'll mark this as verified, thx! (In reply to Peter Krempa from comment #5) > Hi Wayne, > > > (In reply to Wayne Sun from comment #4) > > ... > > > > > seems here by default is --live if not given flags, maybe by default should > > be --current here which will work like follow as --current specific given > > (@pkrempa, is it worth a fix?) > > This is correct according to the man page for the hotplug APIs: > > If --live is specified, affect a running domain. If --config is specified, > affect the next startup of a persistent domain. If --current is specified, > affect the current domain state. Both --live and --config flags may be > given, but --current is exclusive. When no flag is specified legacy API is > used whose behavior depends on the hypervisor driver. > > Got it, thx for explain this. Forget to add the --print-xml test in last comment, so added it here: 1. non-exist domain # virsh attach-disk fake_non_exist /tmp/aa.img vdd --print-xml <disk type='file'> <source file='/tmp/aa.img'/> <target dev='vdd'/> </disk> 2. with exist domain # virsh attach-disk kvm-rhel6.5-x86_64-qcow2-virtio /tmp/aa.img vdd --print-xml <disk type='file'> <source file='/tmp/aa.img'/> <target dev='vdd'/> </disk> it's working as expected, so mark verified. 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. |