File 232cf2a4-libxl-hostdev-config.patch of Package libvirt

commit 232cf2a45c0e0fcc42cad21efd03df8e6fe6f246
Author: Chunyan Liu <cyliu@suse.com>
Date:   Tue Jul 15 13:03:14 2014 +0800

    libxl: add HOSTDEV type in libxlDomainDetachDeviceConfig
    
    Missing HOSTDEV type in libxlDomainDetachDeviceConfig. Add it.
    
    Signed-off-by: Chunyan Liu <cyliu@suse.com>

Index: libvirt-1.2.5/src/libxl/libxl_driver.c
===================================================================
--- libvirt-1.2.5.orig/src/libxl/libxl_driver.c
+++ libvirt-1.2.5/src/libxl/libxl_driver.c
@@ -2990,7 +2990,8 @@ static int
 libxlDomainDetachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
 {
     virDomainDiskDefPtr disk, detach;
-    int ret = -1;
+    virDomainHostdevDefPtr hostdev, det_hostdev;
+    int idx;
 
     switch (dev->type) {
         case VIR_DOMAIN_DEVICE_DISK:
@@ -2998,18 +2999,30 @@ libxlDomainDetachDeviceConfig(virDomainD
             if (!(detach = virDomainDiskRemoveByName(vmdef, disk->dst))) {
                 virReportError(VIR_ERR_INVALID_ARG,
                                _("no target device %s"), disk->dst);
-                break;
+                return -1;
             }
             virDomainDiskDefFree(detach);
-            ret = 0;
             break;
+
+        case VIR_DOMAIN_DEVICE_HOSTDEV: {
+            hostdev = dev->data.hostdev;
+            if ((idx = virDomainHostdevFind(vmdef, hostdev, &det_hostdev)) < 0) {
+                virReportError(VIR_ERR_INVALID_ARG, "%s",
+                               _("device not present in domain configuration"));
+                return -1;
+            }
+            virDomainHostdevRemove(vmdef, idx);
+            virDomainHostdevDefFree(det_hostdev);
+            break;
+        }
+
         default:
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("persistent detach of device is not supported"));
-            break;
+            return -1;
     }
 
-    return ret;
+    return 0;
 }
 
 static int