]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
pci: virPCIDeviceListAddCopy API
authorLaine Stump <laine@laine.org>
Tue, 25 Jun 2013 01:27:52 +0000 (21:27 -0400)
committerLaine Stump <laine@laine.org>
Tue, 25 Jun 2013 22:11:10 +0000 (18:11 -0400)
Make a copy of the device and add the copy to the
list. (virPCIDeviceListAdd() adds the original object to the list
instead).

src/libvirt_private.syms
src/util/virpci.c
src/util/virpci.h

index 4c5f5a33e55e9b07741c27399066ef2ba5d280ba..795e011bde0a50523901a14ed564b18a3d2ccd15 100644 (file)
@@ -1709,6 +1709,7 @@ virPCIDeviceGetUnbindFromStub;
 virPCIDeviceGetUsedBy;
 virPCIDeviceIsAssignable;
 virPCIDeviceListAdd;
+virPCIDeviceListAddCopy;
 virPCIDeviceListCount;
 virPCIDeviceListDel;
 virPCIDeviceListFind;
index 2d18e6625bcfca21a8f912a759b8105799a5d643..a64e41070f12b59c91ec99ba5d93a04fe4f44d90 100644 (file)
@@ -1705,6 +1705,23 @@ virPCIDeviceListAdd(virPCIDeviceListPtr list,
     return 0;
 }
 
+
+/* virPCIDeviceListAddCopy - add a *copy* of the device to this list */
+int
+virPCIDeviceListAddCopy(virPCIDeviceListPtr list, virPCIDevicePtr dev)
+{
+    virPCIDevicePtr copy = virPCIDeviceCopy(dev);
+
+    if (!copy)
+        return -1;
+    if (virPCIDeviceListAdd(list, copy) < 0) {
+        virPCIDeviceFree(copy);
+        return -1;
+    }
+    return 0;
+}
+
+
 virPCIDevicePtr
 virPCIDeviceListGet(virPCIDeviceListPtr list,
                     int idx)
index fe474e2c48aa87b6b5a7d01327b709f7358bc29f..b56b89b7b3e8ecd18c99fea9fd8b0f98739ca229 100644 (file)
@@ -83,6 +83,7 @@ void virPCIDeviceReattachInit(virPCIDevice *dev);
 virPCIDeviceListPtr virPCIDeviceListNew(void);
 int  virPCIDeviceListAdd(virPCIDeviceListPtr list,
                          virPCIDevicePtr dev);
+int virPCIDeviceListAddCopy(virPCIDeviceListPtr list, virPCIDevicePtr dev);
 virPCIDevicePtr virPCIDeviceListGet(virPCIDeviceListPtr list,
                                     int idx);
 int virPCIDeviceListCount(virPCIDeviceListPtr list);