Hide Forgot
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.
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
This shouldn't be a bug, but a PFE. I change the title.
Guannan, if this is already implemented, go ahead and close it as CURRENTRELEASE.
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.