From: Xu Wang <cngesaint(a)gmail.com>
Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/device_parsing.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 43174c1..a0ef407 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -2412,6 +2412,49 @@ static void duplicate_device_address(struct device_address *to,
const struct dev
cleanup_device_address(to);
}
+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;
@@ -2442,6 +2485,7 @@ struct virt_device *virt_device_dup(struct virt_device *_dev)
dev->dev.net.reservation = _dev->dev.net.reservation;
dev->dev.net.limit = _dev->dev.net.limit;
duplicate_device_address(&dev->dev.net.address,
&_dev->dev.net.address);
+ 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);
@@ -2456,25 +2500,32 @@ struct virt_device *virt_device_dup(struct virt_device *_dev)
dev->dev.disk.readonly = _dev->dev.disk.readonly;
dev->dev.disk.shareable = _dev->dev.disk.shareable;
duplicate_device_address(&dev->dev.disk.address,
&_dev->dev.disk.address);
+ 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.8.3.1