Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/device_parsing.c | 51 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 21d2ef3..2b713de 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -2242,6 +2242,49 @@ static int parse_devices(const char *xml, struct virt_device
**_list, int type)
return count;
}
+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_name = NULL;
+ new_node->next = NULL;
+
+ if (head == NULL) {
+ head = new_node;
+ } else {
+ new_node->next = head;
+ head = new_node;
+ }
+
+ new_node->id = others->id;
+ DUP_FIELD(new_node, others, name);
+ DUP_FIELD(new_node, others, value);
+ new_node->parent_id = others->parent_id;
+ DUP_FIELD(new_node, others, parent_name);
+ 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;
@@ -2271,6 +2314,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);
@@ -2284,25 +2328,32 @@ 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);
} else if (dev->type == CIM_RES_TYPE_CONSOLE) {
console_device_dup(&dev->dev.console,
&_dev->dev.console);
+ dev->dev.console.others = dup_others(_dev->dev.console.others);
}
return dev;
}
--
1.7.1