# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1297878704 28800
# Node ID a1bb536dcf5ca836a2b09d7682134c88a4fbeb6e
# Parent 5217c96d817d3d330898df26dd4262b9c26abc21
Add support for deactivation of disk caching.
This patch adds support to deactivate caching of disk devices.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r 5217c96d817d -r a1bb536dcf5c libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Wed Feb 16 06:48:11 2011 -0800
+++ b/libxkutil/device_parsing.c Wed Feb 16 09:51:44 2011 -0800
@@ -53,6 +53,7 @@
free(dev->type);
free(dev->device);
free(dev->driver);
+ free(dev->cache);
free(dev->source);
free(dev->virtual_dev);
free(dev->bus_type);
@@ -241,6 +242,7 @@
ddev->driver = get_attr_value(child, "name");
if (ddev->driver == NULL)
goto err;
+ ddev->cache = get_attr_value(child, "cache");
} else if (XSTREQ(child->name, "source")) {
ddev->source = get_attr_value(child, "file");
if (ddev->source) {
@@ -739,6 +741,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.cache);
DUP_FIELD(dev, _dev, dev.disk.source);
DUP_FIELD(dev, _dev, dev.disk.virtual_dev);
DUP_FIELD(dev, _dev, dev.disk.bus_type);
diff -r 5217c96d817d -r a1bb536dcf5c libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h Wed Feb 16 06:48:11 2011 -0800
+++ b/libxkutil/device_parsing.h Wed Feb 16 09:51:44 2011 -0800
@@ -53,6 +53,7 @@
bool readonly;
bool shareable;
char *bus_type;
+ char *cache;
};
struct net_device {
diff -r 5217c96d817d -r a1bb536dcf5c libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Wed Feb 16 06:48:11 2011 -0800
+++ b/libxkutil/xmlgen.c Wed Feb 16 09:51:44 2011 -0800
@@ -84,6 +84,15 @@
xmlNewProp(disk, BAD_CAST "type", BAD_CAST "file");
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) {
+ xmlNewProp(tmp, BAD_CAST "name", BAD_CAST dev->driver);
+ if(dev->cache != NULL)
+ xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST
dev->cache);
+ }
+
tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL);
if (tmp == NULL)
return XML_ERROR;
diff -r 5217c96d817d -r a1bb536dcf5c schema/ResourceAllocationSettingData.mof
--- a/schema/ResourceAllocationSettingData.mof Wed Feb 16 06:48:11 2011 -0800
+++ b/schema/ResourceAllocationSettingData.mof Wed Feb 16 09:51:44 2011 -0800
@@ -20,6 +20,9 @@
[Description ("readonly mode for disk")]
boolean readonly;
+ [Description ("cache setting for device")]
+ string cache;
+
};
[Description ("KVM virtual disk configuration"),
@@ -41,6 +44,9 @@
[Description ("readonly mode for disk")]
boolean readonly;
+
+ [Description ("cache setting for device")]
+ string cache;
};
[Description ("LXC virtual disk configuration"),
diff -r 5217c96d817d -r a1bb536dcf5c src/Virt_RASD.c
--- a/src/Virt_RASD.c Wed Feb 16 06:48:11 2011 -0800
+++ b/src/Virt_RASD.c Wed Feb 16 09:51:44 2011 -0800
@@ -281,6 +281,12 @@
(CMPIValue *)&(dev->dev.disk.readonly),
CMPI_boolean);
+ if(dev->dev.disk.cache)
+ CMSetProperty(inst,
+ "cache",
+ (CMPIValue *)dev->dev.disk.cache,
+ CMPI_chars);
+
return s;
}
diff -r 5217c96d817d -r a1bb536dcf5c src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c Wed Feb 16 06:48:11 2011 -0800
+++ b/src/Virt_SettingsDefineCapabilities.c Wed Feb 16 09:51:44 2011 -0800
@@ -853,6 +853,7 @@
uint64_t disk_size,
uint16_t emu_type,
bool readonly,
+ const char *cache,
struct inst_list *list)
{
const char *dev;
@@ -899,6 +900,10 @@
if(readonly)
CMSetProperty(inst, "readonly",
(CMPIValue *)&readonly, CMPI_boolean);
+
+ if(cache != NULL)
+ CMSetProperty(inst, "cache",
+ (CMPIValue *)cache, CMPI_chars);
}
inst_list_add(list, inst);
@@ -920,6 +925,7 @@
const char *dev_str = NULL;
char *id_str = NULL;
bool readonly = true;
+ const char *cache = "none";
if (emu_type == VIRT_DISK_TYPE_CDROM)
dev_str = "CDROM";
@@ -966,6 +972,7 @@
vol_size,
emu_type,
readonly,
+ cache,
list);
}
} else if (STREQ(pfx, "KVM")) {
@@ -976,6 +983,7 @@
vol_size,
emu_type,
readonly,
+ cache,
list);
} else if (!STREQ(pfx, "LXC")){
@@ -1050,6 +1058,7 @@
int type = 0;
bool ret;
bool readonly = true;
+ const char *cache = "none";
CMPIStatus s = {CMPI_RC_OK, NULL};
@@ -1101,6 +1110,7 @@
disk_size,
emu_type,
readonly,
+ cache,
list);
if (s.rc != CMPI_RC_OK)
goto out;
@@ -1121,6 +1131,7 @@
disk_size,
emu_type,
readonly,
+ cache,
list);
}
@@ -1247,6 +1258,7 @@
int ret;
uint16_t emu_type = 0;
bool readonly = false;
+ const char *cache = "none";
ret = virStorageVolGetInfo(volume_ptr, &vol_info);
if (ret == -1) {
@@ -1304,6 +1316,7 @@
vol_size,
emu_type,
readonly,
+ cache,
list);
}
} else if (STREQ(pfx, "KVM")) {
@@ -1314,6 +1327,7 @@
vol_size,
emu_type,
readonly,
+ cache,
list);
} else {
cu_statusf(_BROKER, &s,
diff -r 5217c96d817d -r a1bb536dcf5c src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Wed Feb 16 06:48:11 2011 -0800
+++ b/src/Virt_VirtualSystemManagementService.c Wed Feb 16 09:51:44 2011 -0800
@@ -878,6 +878,12 @@
dev->dev.disk.bus_type = NULL;
else
dev->dev.disk.bus_type = strdup(val);
+
+ free(dev->dev.disk.cache);
+ if (cu_get_str_prop(inst, "cache", &val) != CMPI_RC_OK)
+ dev->dev.disk.cache = NULL;
+ else
+ dev->dev.disk.cache = strdup(val);
free(dev->id);
dev->id = strdup(dev->dev.disk.virtual_dev);