This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 963638 - virsh attach-device with --config should not take effect before reboot
virsh attach-device with --config should not take effect before reboot
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.0
x86_64 Linux
medium Severity medium
: rc
: ---
Assigned To: Peter Krempa
Virtualization Bugs
:
Depends On:
Blocks: 963661
  Show dependency treegraph
 
Reported: 2013-05-16 06:03 EDT by Hu Jianwei
Modified: 2014-06-17 20:50 EDT (History)
7 users (show)

See Also:
Fixed In Version: libvirt-1.1.0-1.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 963661 (view as bug list)
Environment:
Last Closed: 2014-06-13 06:05:12 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Hu Jianwei 2013-05-16 06:03:20 EDT
Description of problem:
attach-device with --config should not take effect before reboot

Version-Release number of selected component (if applicable):
libvirt-1.0.5-2.el7.x86_64
qemu-kvm-1.4.0-4.el7.x86_64
kernel-3.9.0-0.55.el7.x86_64

How reproducible:
100%

Steps:

1. Define a domain and start it.
[root@hujianweitest ~]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 9     rhel7                          running

2.Prepare a xml.
[root@hujianweitest ~]# cat usb_bus.xml
<hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
      <address bus='1' device='5'/>
      </source>
    </hostdev>

3. In guest, to check the usb device.
[root@hujianweitest ~]# virsh console rhel7
Connected to domain rhel7
Escape character is ^]

[root@localhost ~]# lsusb
Bus 001 Device 002: ID 08e6:4433 Gemplus GemPC433-Swap
Bus 001 Device 003: ID 0409:55aa NEC Corp. Hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
[root@localhost ~]#

4. Attach usb device to the guest using attach-device with --config.
[root@hujianweitest ~]# virsh attach-device rhel7 usb_bus.xml --config
Device attached successfully

5. In guest, to check the usb device again.
[root@hujianweitest ~]# virsh console rhel7
Connected to domain rhel7
Escape character is ^]

[root@localhost ~]# lsusb
Bus 001 Device 002: ID 08e6:4433 Gemplus GemPC433-Swap
Bus 001 Device 003: ID 0409:55aa NEC Corp. Hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 000: ID 148f:3370 Ralink Technology, Corp. RT3370 Wireless Adapter
[root@localhost ~]#

6. Destroy and restart the guest, and to check the usb device.
[root@hujianweitest ~]# virsh destroy rhel7
Domain rhel7 destroyed

[root@hujianweitest ~]# virsh start rhel7
Domain rhel7 started

[root@hujianweitest ~]# virsh console rhel7
Connected to domain rhel7
Escape character is ^]

[root@localhost ~]# lsusb
Bus 001 Device 002: ID 08e6:4433 Gemplus GemPC433-Swap
Bus 001 Device 003: ID 0409:55aa NEC Corp. Hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 148f:3370 Ralink Technology, Corp. RT3370 Wireless Adapter
[root@localhost ~]#
[root@hujianweitest ~]#

Actual results:
After step 5, the assigned device is listed in guest.
[root@hujianweitest ~]# virsh dumpxml rhel7 | grep -A 5 hostdev
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <address bus='1' device='5'/>
      </source>
      <alias name='hostdev0'/>
    </hostdev>

Expected results:
After step 5:
--config will affect next boot, the assigned device should appear until we restart the guest.
[root@hujianweitest ~]# virsh help attach-device
  NAME
    attach-device - attach device from an XML file

  SYNOPSIS
    attach-device <domain> <file> [--config]

  DESCRIPTION
    Attach device from an XML <file>.

  OPTIONS
    [--domain] <string>  domain name, id or uuid
    [--file] <string>  XML file
    --config         affect next boot
Comment 2 Peter Krempa 2013-06-03 08:24:32 EDT
Fixed upstream by:

commit 33e300229cf30c6efc7411d3b5d45c2050129fc1
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Tue May 28 11:07:33 2013 +0200

    virsh-domain: Add --live, --config, --current logic to cmdAttachInterface
    
    Use the approach established in commit
    69ce3ffa8d431e9810607c6e00b7cfcc481b491d to improve this function too.

commit 37772499e050b7c9d3f136d8c2e07b67e8ff26d6
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Tue May 28 11:07:33 2013 +0200

    virsh-domain: Add --live, --config, --current logic to cmdAttachDisk
    
    Use the approach established in commit
    69ce3ffa8d431e9810607c6e00b7cfcc481b491d to improve this function too.

commit f81c95b31f1c1cc95cb7e52cf8af98cbd624e0c1
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Tue May 28 11:07:33 2013 +0200

    virsh-domain: Add --live, --config, --current logic to cmdAttachDevice
    
    Use the approach established in commit
    69ce3ffa8d431e9810607c6e00b7cfcc481b491d to improve this function too.

v1.0.6-5-g33e3002
Comment 3 EricLee 2013-07-03 03:09:30 EDT
This bug verified pass in libvirt-1.1.0-1.el7, steps as bug description. --config working fine:

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 9     rhel7                          running

2.Prepare a xml.
# cat usb_bus.xml
<hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
      <address bus='1' device='9'/>
      </source>
    </hostdev>

3. In guest, to check the usb device.
# lsusb
Bus 001 Device 002: ID 08e6:4433 Gemplus GemPC433-Swap
Bus 001 Device 003: ID 0409:55aa NEC Corp. Hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

4. Attach usb device to the guest using attach-device with --config.
# virsh attach-device rhel7 usb_bus.xml --config
Device attached successfully

5. In guest, to check the usb device again.
# lsusb
Bus 001 Device 002: ID 08e6:4433 Gemplus GemPC433-Swap
Bus 001 Device 003: ID 0409:55aa NEC Corp. Hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

There is no pluged usb to guest.

6. Destroy and restart the guest, and to check the usb device.
# virsh destroy rhel7
Domain rhel7 destroyed

# virsh start rhel7
Domain rhel7 started

# lsusb
Bus 001 Device 002: ID 08e6:4433 Gemplus GemPC433-Swap
Bus 001 Device 003: ID 0409:55aa NEC Corp. Hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 148f:3370 Ralink Technology, Corp. RT3370 Wireless Adapter

After restart guest, there it is.

Working well.

Setting VERIFIED.
Comment 4 Ludek Smid 2014-06-13 06:05:12 EDT
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.