Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/device_parsing.c | 49 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index e0d11e4..9eabd48 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -1569,6 +1569,48 @@ static int parse_devices(const char *xml, struct virt_device
**_list, int type)
(d)->f = strdup((s)->f); \
} while (0);
+static struct others *dup_others(struct others *others)
+{
+ struct others *new_node = NULL;
+ struct others *head = NULL;
+
+ if (others == NULL) {
+ return NULL;
+ }
+
+ while (others) {
+ new_node = calloc(1, sizeof(*new_node));
+ if (new_node == NULL) {
+ CU_DEBUG("calloc failed.");
+ goto err;
+ }
+
+ new_node->name = NULL;
+ new_node->value = NULL;
+ new_node->parent = NULL;
+ new_node->next = NULL;
+
+ if (head == NULL) {
+ head = new_node;
+ } else {
+ new_node->next = head;
+ head = new_node;
+ }
+
+ DUP_FIELD(new_node, others, name);
+ DUP_FIELD(new_node, others, value);
+ DUP_FIELD(new_node, others, parent);
+ new_node->type = others->type;
+
+ others = others->next;
+ }
+
+ return head;
+err:
+ cleanup_others(head);
+ return NULL;
+}
+
struct virt_device *virt_device_dup(struct virt_device *_dev)
{
struct virt_device *dev;
@@ -1598,6 +1640,7 @@ struct virt_device *virt_device_dup(struct virt_device *_dev)
DUP_FIELD(dev, _dev, dev.net.vsi.profile_id);
dev->dev.net.reservation = _dev->dev.net.reservation;
dev->dev.net.limit = _dev->dev.net.limit;
+ dev->dev.net.others = dup_others(_dev->dev.net.others);
} else if (dev->type == CIM_RES_TYPE_DISK) {
DUP_FIELD(dev, _dev, dev.disk.type);
DUP_FIELD(dev, _dev, dev.disk.device);
@@ -1611,22 +1654,28 @@ struct virt_device *virt_device_dup(struct virt_device *_dev)
dev->dev.disk.disk_type = _dev->dev.disk.disk_type;
dev->dev.disk.readonly = _dev->dev.disk.readonly;
dev->dev.disk.shareable = _dev->dev.disk.shareable;
+ dev->dev.disk.others = dup_others(_dev->dev.disk.others);
} else if (dev->type == CIM_RES_TYPE_MEM) {
dev->dev.mem.size = _dev->dev.mem.size;
dev->dev.mem.maxsize = _dev->dev.mem.maxsize;
+ dev->dev.mem.others = dup_others(_dev->dev.mem.others);
} else if (dev->type == CIM_RES_TYPE_PROC) {
dev->dev.vcpu.quantity = _dev->dev.vcpu.quantity;
+ dev->dev.vcpu.others = dup_others(_dev->dev.vcpu.others);
} else if (dev->type == CIM_RES_TYPE_EMU) {
DUP_FIELD(dev, _dev, dev.emu.path);
+ dev->dev.emu.others = dup_others(_dev->dev.emu.others);
} else if (dev->type == CIM_RES_TYPE_GRAPHICS) {
DUP_FIELD(dev, _dev, dev.graphics.type);
DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.host);
DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.port);
DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.keymap);
DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.passwd);
+ dev->dev.graphics.others = dup_others(_dev->dev.graphics.others);
} else if (dev->type == CIM_RES_TYPE_INPUT) {
DUP_FIELD(dev, _dev, dev.input.type);
DUP_FIELD(dev, _dev, dev.input.bus);
+ dev->dev.input.others = dup_others(_dev->dev.input.others);
}
return dev;
--
1.7.1