Bug 735909

Summary: RFE: Allow to attach hostdev persistently
Product: Red Hat Enterprise Linux 7 Reporter: yuping zhang <yupzhang>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.0CC: ajia, bili, dallan, dyuan, lsu, mzhan, rwu, weizhan
Target Milestone: rcKeywords: FutureFeature
Target Release: 7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-11-06 06:13:41 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description yuping zhang 2011-09-06 06:44:33 UTC
Description of problem:
Run virsh attach-device with --persistent option,it returns error with "persistent attach of device is not supported"

Version-Release number of selected component (if applicable):
libvirt-0.9.4-7.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1.Start a kvm guest
2.Prepare a pci-device xml as following:
# cat host.xml
<hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
              <address domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
      </source>
</hostdev>

3.# virsh attach-device rhel5u6 host.xml --persistent
error: Failed to attach device from host.xml
error: unsupported configuration: persistent attach of device is not supported

Actual results:
As steps 3,attach-device doesn't support --persistent option

Expected results:
# virsh help attach-device
  NAME
    attach-device - attach device from an XML file

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

  DESCRIPTION
    Attach device from an XML<file>.

  OPTIONS
    [--domain]<string>   domain name, id or uuid
    [--file]<string>   XML file
    --persistent     persist device attachment

attach-device with --persistent option works well

Additional info:
There is a bug 599325 about this issue,it closed duplicate of bug 598792 which has been verified with libvirt-0.9.1-1.el6.
So I file a new one only for command attach-device.

Comment 2 Alex Jia 2011-09-06 07:14:27 UTC
In fact, for qemu driver, the function qemuDomainAttachDeviceConfig only supports VIR_DOMAIN_DEVICE_DISK, VIR_DOMAIN_DEVICE_NET and VIR_DOMAIN_DEVICE_LEASE device types, when dev->type is VIR_DOMAIN_DEVICE_HOSTDEV, 'default' branch will be hit.

As document said, if attach-device supports --persistent option, the following codes should add 'VIR_DOMAIN_DEVICE_HOSTDEV' branch and implementation.

* src/qemu/qemu_driver.c:

static int
qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
                             virDomainDeviceDefPtr dev)
{
......
    switch (dev->type) {
    case VIR_DOMAIN_DEVICE_DISK:
        disk = dev->data.disk;
......
    case VIR_DOMAIN_DEVICE_NET:
        net = dev->data.net;
......
    case VIR_DOMAIN_DEVICE_LEASE:
        lease = dev->data.lease;
......
    default:
         qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                         _("persistent attach of device is not supported"));
......
}


Alex

Comment 3 Osier Yang 2011-09-15 09:32:58 UTC
This shouldn't be a bug, but a PFE. I change the title.

Comment 7 Dave Allan 2012-10-29 15:10:53 UTC
Guannan, if this is already implemented, go ahead and close it as CURRENTRELEASE.

Comment 8 Gunannan Ren 2012-11-06 06:13:41 UTC
This feature has been implemented with --config option.

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


commit edb6fc3a7f0de4a4881862287b412b66b8153768
Author: Laine Stump <laine>
Date:   Wed Mar 7 16:05:34 2012 -0500

    qemu: support persistent hotplug of <hostdev> devices
    
    For some reason, although live hotplug of <hostdev> devices is
    supported, persistent hotplug is not. This patch adds the proper
    VIR_DOMAIN_DEVICE_HOSTDEV cases to the switches in
    qemuDomainAttachDeviceConfig and qemuDomainDetachDeviceConfig.