# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1205154179 -3600
# Node ID 581efd4f29eb6a9aa321cf54dbcf6f35f59055f9
# Parent 1aaf26015bb83a1b2433073c2ec5886cf828d9e6
move VIRT_DEV_foo types to CIM_RES_TYPE_foo
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r 1aaf26015bb8 -r 581efd4f29eb libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Mon Mar 10 13:09:14 2008 +0100
+++ b/libxkutil/device_parsing.c Mon Mar 10 14:02:59 2008 +0100
@@ -81,13 +81,13 @@ void cleanup_virt_device(struct virt_dev
if (dev == NULL)
return; /* free()-like semantics */
- if (dev->type == VIRT_DEV_DISK)
+ if (dev->type == CIM_RES_TYPE_DISK)
cleanup_disk_device(&dev->dev.disk);
- else if (dev->type == VIRT_DEV_NET)
+ else if (dev->type == CIM_RES_TYPE_NET)
cleanup_net_device(&dev->dev.net);
- else if (dev->type == VIRT_DEV_EMU)
+ else if (dev->type == CIM_RES_TYPE_EMU)
cleanup_emu_device(&dev->dev.emu);
- else if (dev->type == VIRT_DEV_GRAPHICS)
+ else if (dev->type == CIM_RES_TYPE_GRAPHICS)
cleanup_graphics_device(&dev->dev.graphics);
free(dev->id);
@@ -181,7 +181,7 @@ static int parse_disk_device(xmlNode *dn
if ((ddev->source == NULL) || (ddev->virtual_dev == NULL))
goto err;
- vdev->type = VIRT_DEV_DISK;
+ vdev->type = CIM_RES_TYPE_DISK;
vdev->id = strdup(ddev->virtual_dev);
*vdevs = vdev;
@@ -248,7 +248,7 @@ static int parse_net_device(xmlNode *ino
}
}
- vdev->type = VIRT_DEV_NET;
+ vdev->type = CIM_RES_TYPE_NET;
vdev->id = strdup(ndev->mac);
*vdevs = vdev;
@@ -286,7 +286,7 @@ static int parse_vcpu_device(xmlNode *no
cdev->number = i;
- vdev->type = VIRT_DEV_VCPU;
+ vdev->type = CIM_RES_TYPE_PROC;
if (asprintf(&vdev->id, "%i", i) == -1)
vdev->id = NULL;
}
@@ -315,7 +315,7 @@ static int parse_emu_device(xmlNode *nod
if (edev->path != NULL)
goto err;
- vdev->type = VIRT_DEV_EMU;
+ vdev->type = CIM_RES_TYPE_EMU;
*vdevs = vdev;
@@ -376,7 +376,7 @@ static int parse_graphics_device(xmlNode
if ((gdev->type == NULL) || (gdev->port == NULL))
goto err;
- vdev->type = VIRT_DEV_GRAPHICS;
+ vdev->type = CIM_RES_TYPE_GRAPHICS;
*vdevs = vdev;
@@ -411,17 +411,17 @@ static int do_parse(xmlNodeSet *nsv, int
int (*do_real_parse)(xmlNode *, struct virt_device **) = NULL;
/* point to correct parser function according to type */
- if (type == VIRT_DEV_NET)
+ if (type == CIM_RES_TYPE_NET)
do_real_parse = &parse_net_device;
- else if (type == VIRT_DEV_DISK)
+ else if (type == CIM_RES_TYPE_DISK)
do_real_parse = &parse_disk_device;
- else if (type == VIRT_DEV_VCPU)
+ else if (type == CIM_RES_TYPE_PROC)
do_real_parse = parse_vcpu_device;
- else if (type == VIRT_DEV_EMU)
+ else if (type == CIM_RES_TYPE_EMU)
do_real_parse = parse_emu_device;
- else if (type == VIRT_DEV_MEM)
+ else if (type == CIM_RES_TYPE_MEM)
do_real_parse = parse_mem_device;
- else if (type == VIRT_DEV_GRAPHICS)
+ else if (type == CIM_RES_TYPE_GRAPHICS)
do_real_parse = parse_graphics_device;
else
goto out;
@@ -479,17 +479,17 @@ static int parse_devices(const char *xml
xmlXPathObject *xpathObj;
xmlChar *xpathstr;
- if (type == VIRT_DEV_NET)
+ if (type == CIM_RES_TYPE_NET)
xpathstr = NET_XPATH;
- else if (type == VIRT_DEV_DISK)
+ else if (type == CIM_RES_TYPE_DISK)
xpathstr = DISK_XPATH;
- else if (type == VIRT_DEV_VCPU)
+ else if (type == CIM_RES_TYPE_PROC)
xpathstr = VCPU_XPATH;
- else if (type == VIRT_DEV_EMU)
+ else if (type == CIM_RES_TYPE_EMU)
xpathstr = EMU_XPATH;
- else if (type == VIRT_DEV_MEM)
+ else if (type == CIM_RES_TYPE_MEM)
xpathstr = MEM_XPATH;
- else if (type == VIRT_DEV_GRAPHICS)
+ else if (type == CIM_RES_TYPE_GRAPHICS)
xpathstr = GRAPHICS_XPATH;
else
goto err1;
@@ -535,24 +535,24 @@ struct virt_device *virt_device_dup(stru
dev->type = _dev->type;
dev->id = strdup(_dev->id);
- if (dev->type == VIRT_DEV_NET) {
+ if (dev->type == CIM_RES_TYPE_NET) {
DUP_FIELD(dev, _dev, dev.net.mac);
DUP_FIELD(dev, _dev, dev.net.type);
DUP_FIELD(dev, _dev, dev.net.source);
- } else if (dev->type == VIRT_DEV_DISK) {
+ } else if (dev->type == CIM_RES_TYPE_DISK) {
DUP_FIELD(dev, _dev, dev.disk.type);
DUP_FIELD(dev, _dev, dev.disk.device);
DUP_FIELD(dev, _dev, dev.disk.driver);
DUP_FIELD(dev, _dev, dev.disk.source);
DUP_FIELD(dev, _dev, dev.disk.virtual_dev);
- } else if (dev->type == VIRT_DEV_MEM) {
+ } else if (dev->type == CIM_RES_TYPE_MEM) {
dev->dev.mem.size = _dev->dev.mem.size;
dev->dev.mem.maxsize = _dev->dev.mem.maxsize;
- } else if (dev->type == VIRT_DEV_VCPU) {
+ } else if (dev->type == CIM_RES_TYPE_PROC) {
dev->dev.vcpu.number = _dev->dev.vcpu.number;
- } else if (dev->type == VIRT_DEV_EMU) {
+ } else if (dev->type == CIM_RES_TYPE_EMU) {
DUP_FIELD(dev, _dev, dev.emu.path);
- } else if (dev->type == VIRT_DEV_GRAPHICS) {
+ } else if (dev->type == CIM_RES_TYPE_GRAPHICS) {
DUP_FIELD(dev, _dev, dev.graphics.type);
DUP_FIELD(dev, _dev, dev.graphics.port);
}
@@ -566,7 +566,7 @@ static int _get_mem_device(const char *x
struct virt_device *mdev = NULL;
int ret;
- ret = parse_devices(xml, &mdevs, VIRT_DEV_MEM);
+ ret = parse_devices(xml, &mdevs, CIM_RES_TYPE_MEM);
if (ret <= 0)
return ret;
@@ -592,7 +592,7 @@ static int _get_mem_device(const char *x
mdev->dev.mem.maxsize = mdev->dev.mem.size;
}
- mdev->type = VIRT_DEV_MEM;
+ mdev->type = CIM_RES_TYPE_MEM;
mdev->id = strdup("mem");
*list = mdev;
@@ -610,7 +610,7 @@ int get_devices(virDomainPtr dom, struct
if (xml == NULL)
return 0;
- if (type == VIRT_DEV_MEM)
+ if (type == CIM_RES_TYPE_MEM)
ret = _get_mem_device(xml, list);
else
ret = parse_devices(xml, list, type);
@@ -775,19 +775,19 @@ int get_dominfo_from_xml(const char *xml
if (ret == 0)
goto err;
- parse_devices(xml, &(*dominfo)->dev_emu, VIRT_DEV_EMU);
- parse_devices(xml, &(*dominfo)->dev_graphics, VIRT_DEV_GRAPHICS);
+ parse_devices(xml, &(*dominfo)->dev_emu, CIM_RES_TYPE_EMU);
+ parse_devices(xml, &(*dominfo)->dev_graphics, CIM_RES_TYPE_GRAPHICS);
(*dominfo)->dev_mem_ct = _get_mem_device(xml, &(*dominfo)->dev_mem);
(*dominfo)->dev_net_ct = parse_devices(xml,
&(*dominfo)->dev_net,
- VIRT_DEV_NET);
+ CIM_RES_TYPE_NET);
(*dominfo)->dev_disk_ct = parse_devices(xml,
&(*dominfo)->dev_disk,
- VIRT_DEV_DISK);
+ CIM_RES_TYPE_DISK);
(*dominfo)->dev_vcpu_ct = parse_devices(xml,
&(*dominfo)->dev_vcpu,
- VIRT_DEV_VCPU);
+ CIM_RES_TYPE_PROC);
return ret;
@@ -933,10 +933,10 @@ static int change_vcpus(virDomainPtr dom
int attach_device(virDomainPtr dom, struct virt_device *dev)
{
- if ((dev->type == VIRT_DEV_NET) ||
- (dev->type == VIRT_DEV_DISK))
+ if ((dev->type == CIM_RES_TYPE_NET) ||
+ (dev->type == CIM_RES_TYPE_DISK))
return _change_device(dom, dev, true);
- else if (dev->type == VIRT_DEV_VCPU)
+ else if (dev->type == CIM_RES_TYPE_PROC)
return change_vcpus(dom, 1);
CU_DEBUG("Unhandled device type %i", dev->type);
@@ -946,10 +946,10 @@ int attach_device(virDomainPtr dom, stru
int detach_device(virDomainPtr dom, struct virt_device *dev)
{
- if ((dev->type == VIRT_DEV_NET) ||
- (dev->type == VIRT_DEV_DISK))
+ if ((dev->type == CIM_RES_TYPE_NET) ||
+ (dev->type == CIM_RES_TYPE_DISK))
return _change_device(dom, dev, false);
- else if (dev->type == VIRT_DEV_VCPU)
+ else if (dev->type == CIM_RES_TYPE_PROC)
return change_vcpus(dom, -1);
CU_DEBUG("Unhandled device type %i", dev->type);
@@ -959,7 +959,7 @@ int detach_device(virDomainPtr dom, stru
int change_device(virDomainPtr dom, struct virt_device *dev)
{
- if (dev->type == VIRT_DEV_MEM)
+ if (dev->type == CIM_RES_TYPE_MEM)
return change_memory(dom, dev);
CU_DEBUG("Unhandled device type %i", dev->type);
diff -r 1aaf26015bb8 -r 581efd4f29eb libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h Mon Mar 10 13:09:14 2008 +0100
+++ b/libxkutil/device_parsing.h Mon Mar 10 14:02:59 2008 +0100
@@ -63,15 +63,7 @@ struct graphics_device {
};
struct virt_device {
- enum {
- VIRT_DEV_NET = CIM_RES_TYPE_NET,
- VIRT_DEV_DISK = CIM_RES_TYPE_DISK,
- VIRT_DEV_MEM = CIM_RES_TYPE_MEM,
- VIRT_DEV_VCPU = CIM_RES_TYPE_PROC,
- VIRT_DEV_UNKNOWN = CIM_RES_TYPE_UNKNOWN,
- VIRT_DEV_EMU,
- VIRT_DEV_GRAPHICS,
- } type;
+ uint16_t type;
union {
struct disk_device disk;
struct net_device net;
diff -r 1aaf26015bb8 -r 581efd4f29eb libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Mon Mar 10 13:09:14 2008 +0100
+++ b/libxkutil/xmlgen.c Mon Mar 10 14:02:59 2008 +0100
@@ -322,10 +322,10 @@ static bool concat_devxml(char **xml,
int i;
for (i = 0; i < count; i++) {
- /* Deleted devices are marked as VIRT_DEV_UNKNOWN
+ /* Deleted devices are marked as CIM_RES_TYPE_UNKNOWN
* and should be skipped
*/
- if (list[i].type != VIRT_DEV_UNKNOWN)
+ if (list[i].type != CIM_RES_TYPE_UNKNOWN)
func(&_xml, &list[i]);
}
@@ -342,22 +342,22 @@ char *device_to_xml(struct virt_device *
bool (*func)(char **, struct virt_device *);
switch (type) {
- case VIRT_DEV_DISK:
+ case CIM_RES_TYPE_DISK:
func = disk_to_xml;
break;
- case VIRT_DEV_VCPU:
+ case CIM_RES_TYPE_PROC:
func = vcpu_to_xml;
break;
- case VIRT_DEV_NET:
+ case CIM_RES_TYPE_NET:
func = net_to_xml;
break;
- case VIRT_DEV_MEM:
+ case CIM_RES_TYPE_MEM:
func = mem_to_xml;
break;
- case VIRT_DEV_EMU:
+ case CIM_RES_TYPE_EMU:
func = emu_to_xml;
break;
- case VIRT_DEV_GRAPHICS:
+ case CIM_RES_TYPE_GRAPHICS:
func = graphics_to_xml;
break;
default:
diff -r 1aaf26015bb8 -r 581efd4f29eb src/svpc_types.h
--- a/src/svpc_types.h Mon Mar 10 13:09:14 2008 +0100
+++ b/src/svpc_types.h Mon Mar 10 14:02:59 2008 +0100
@@ -27,6 +27,8 @@
#define CIM_RES_TYPE_MEM 4
#define CIM_RES_TYPE_NET 10
#define CIM_RES_TYPE_DISK 17
+#define CIM_RES_TYPE_EMU 1
+#define CIM_RES_TYPE_GRAPHICS 24
#define CIM_RES_TYPE_UNKNOWN 1000
#define CIM_VSSD_RECOVERY_NONE 2