# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1300902032 25200
# Node ID 1818f2324144b0a0fa21b1eea1a7dabac1a5eb7f
# Parent 62c565a5f71453b02cfcd1317e4a186f2ac1c519
Added support for disk driver.
With this patch libvirt-cim allows a user to pass disk driver information.
Currently a libvirt-cim XML looks like -
<disk type='file' device='disk'>
<source file='/dev/shm/vhostmd0'/>
<target dev='vdX' bus='virtio'/>
<readonly/>
</disk>
with this patch a user can optionally add driver properties to look like -
<disk type='file' device='disk'>
<driver name='qemu' cache='none'/>
<source file='/dev/shm/vhostmd0'/>
<target dev='vdX' bus='virtio'/>
<readonly/>
</disk>
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -53,6 +53,7 @@
free(dev->type);
free(dev->device);
free(dev->driver);
+ free(dev->driver_type);
free(dev->cache);
free(dev->source);
free(dev->virtual_dev);
@@ -242,6 +243,7 @@
ddev->driver = get_attr_value(child, "name");
if (ddev->driver == NULL)
goto err;
+ ddev->driver_type = get_attr_value(child, "type");
ddev->cache = get_attr_value(child, "cache");
} else if (XSTREQ(child->name, "source")) {
ddev->source = get_attr_value(child, "file");
@@ -741,6 +743,7 @@
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.driver_type);
DUP_FIELD(dev, _dev, dev.disk.cache);
DUP_FIELD(dev, _dev, dev.disk.source);
DUP_FIELD(dev, _dev, dev.disk.virtual_dev);
diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h
+++ b/libxkutil/device_parsing.h
@@ -47,6 +47,7 @@
char *type;
char *device;
char *driver;
+ char *driver_type;
char *source;
char *virtual_dev;
enum {DISK_UNKNOWN, DISK_PHY, DISK_FILE, DISK_FS} disk_type;
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -50,7 +50,20 @@
if (disk == NULL)
return XML_ERROR;
xmlNewProp(disk, BAD_CAST "type", BAD_CAST "block");
- xmlNewProp(disk, BAD_CAST "device", BAD_CAST dev->device);
+ if (dev->device)
+ xmlNewProp(disk, BAD_CAST "device", BAD_CAST dev->device);
+
+ if (dev->driver) {
+ tmp = xmlNewChild(disk, NULL, BAD_CAST "driver", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "name", BAD_CAST dev->driver);
+ if (dev->driver_type)
+ xmlNewProp(tmp, BAD_CAST "type",
+ BAD_CAST dev->driver_type);
+ if (dev->cache)
+ xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST
dev->cache);
+ }
tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL);
if (tmp == NULL)
@@ -82,14 +95,18 @@
if (disk == NULL)
return XML_ERROR;
xmlNewProp(disk, BAD_CAST "type", BAD_CAST "file");
- xmlNewProp(disk, BAD_CAST "device", BAD_CAST dev->device);
+ if (dev->device)
+ xmlNewProp(disk, BAD_CAST "device", BAD_CAST dev->device);
- tmp = xmlNewChild(disk, NULL, BAD_CAST "driver", NULL);
- if (tmp == NULL)
- return XML_ERROR;
- if(dev->driver != NULL) {
+ if (dev->driver) {
+ tmp = xmlNewChild(disk, NULL, BAD_CAST "driver", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
xmlNewProp(tmp, BAD_CAST "name", BAD_CAST dev->driver);
- if(dev->cache != NULL)
+ if (dev->driver_type)
+ xmlNewProp(tmp, BAD_CAST "type",
+ BAD_CAST dev->driver_type);
+ if (dev->cache)
xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST
dev->cache);
}
@@ -411,7 +428,6 @@
xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST
"no");
xmlNewProp(tmp, BAD_CAST "port", BAD_CAST
dev->port);
}
-
xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host);
xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap);
diff --git a/schema/ResourceAllocationSettingData.mof
b/schema/ResourceAllocationSettingData.mof
--- a/schema/ResourceAllocationSettingData.mof
+++ b/schema/ResourceAllocationSettingData.mof
@@ -20,9 +20,14 @@
[Description ("readonly mode for disk")]
boolean readonly;
+ [Description ("Primary backend driver name")]
+ string DriverName;
+
+ [Description ("Optional subtype backend driver")]
+ string DriverType;
+
[Description ("cache setting for device")]
- string cache;
-
+ string DriverCache;
};
[Description ("KVM virtual disk configuration"),
@@ -45,8 +50,14 @@
[Description ("readonly mode for disk")]
boolean readonly;
+ [Description ("Primary backend driver name")]
+ string DriverName;
+
+ [Description ("Optional subtype backend driver")]
+ string DriverType;
+
[Description ("cache setting for device")]
- string cache;
+ string DriverCache;
};
[Description ("LXC virtual disk configuration"),
diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c
--- a/src/Virt_RASD.c
+++ b/src/Virt_RASD.c
@@ -281,9 +281,21 @@
(CMPIValue *)&(dev->dev.disk.readonly),
CMPI_boolean);
+ if(dev->dev.disk.driver)
+ CMSetProperty(inst,
+ "DriverName",
+ (CMPIValue *)dev->dev.disk.driver,
+ CMPI_chars);
+
+ if(dev->dev.disk.driver_type)
+ CMSetProperty(inst,
+ "DriverType",
+ (CMPIValue *)dev->dev.disk.driver_type,
+ CMPI_chars);
+
if(dev->dev.disk.cache)
CMSetProperty(inst,
- "cache",
+ "DriverCache",
(CMPIValue *)dev->dev.disk.cache,
CMPI_chars);
diff --git a/src/Virt_VirtualSystemManagementService.c
b/src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -882,8 +882,20 @@
else
dev->dev.disk.bus_type = strdup(val);
+ free(dev->dev.disk.driver);
+ if (cu_get_str_prop(inst, "DriverName", &val) != CMPI_RC_OK)
+ dev->dev.disk.driver = NULL;
+ else
+ dev->dev.disk.driver = strdup(val);
+
+ free(dev->dev.disk.driver_type);
+ if (cu_get_str_prop(inst, "DriverType", &val) != CMPI_RC_OK)
+ dev->dev.disk.driver_type = NULL;
+ else
+ dev->dev.disk.driver_type = strdup(val);
+
free(dev->dev.disk.cache);
- if (cu_get_str_prop(inst, "cache", &val) != CMPI_RC_OK)
+ if (cu_get_str_prop(inst, "DriverCache", &val) != CMPI_RC_OK)
dev->dev.disk.cache = NULL;
else
dev->dev.disk.cache = strdup(val);