[PATCH] Added support for disk driver
by Sharad Mishra
# 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);
13 years, 7 months
[PATCH #2] Add VNC autoport support. Updated patch to resolve compilation issues, and omit the port property if =1 and only set autoport=yes
by Chip Vincent
# HG changeset patch
# User Chip Vincent <cvincent(a)us.ibm.com>
# Date 1300756004 14400
# Node ID ee92bc70899ca4dd6f169c89edc4d374163f3b4f
# Parent 1ac08805bf69fd5e09db234f61860f986f29e0b9
Add VNC autoport support. Updated patch to resolve compilation issues, and omit the port property if =1 and only set autoport=yes.
Signed-off-by: Chip Vincent <cvincent(a)us.ibm.com>
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -405,7 +405,11 @@
if (STREQC(dev->type, "sdl"))
goto out;
- xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port);
+ if (STREQC(dev->port, "-1"))
+ xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes");
+ else
+ 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);
13 years, 7 months
[PATCH] Add VNC autoport support
by Chip Vincent
# HG changeset patch
# User Chip Vincent <cvincent(a)us.ibm.com>
# Date 1300734383 14400
# Node ID 505a9e36438d02c8b580a0ac103e6b8ab0b5cda4
# Parent 1ac08805bf69fd5e09db234f61860f986f29e0b9
Add VNC autoport support
Signed-off-by: Chip Vincent <cvincent(a)us.ibm.com>
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -406,6 +406,12 @@
goto out;
xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port);
+
+ if(dev->port == "-1")
+ xmlNewProp(tmp, BAD_CAST "autoport" BAD_CAST "yes")
+ else
+ xmlNewProp(tmp, BAD_CAST "autoport" BAD_CAST "no")
+
xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host);
xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap);
13 years, 7 months
[PATCH] Add support for Pegasus OOP grouping
by Chip Vincent
# HG changeset patch
# User Chip Vincent <cvincent(a)us.ibm.com>
# Date 1300235494 14400
# Node ID 6cdfba0135e08b8b5878075dff77b5e03107c614
# Parent eea958fbf1d965bc1053850f59df4005e64093ac
Add support for Pegasus OOP grouping
Update Pegasus ProviderModule registration to include support for ModuleGroupProperty. This will allow all libvirt-cim provider to load into a single process when the CIMOM is configured to run providers outside the CIMOM process.
Signed-off-by: Chip Vincent <cvincent(a)us.ibm.com>
diff --git a/provider-register.sh b/provider-register.sh
--- a/provider-register.sh
+++ b/provider-register.sh
@@ -32,6 +32,43 @@
return 1
}
+pegasus_version()
+{
+ CIMSERVER=`pegasus_path cimserver`
+ if test $? != 0
+ then
+ echo "Error: cimserver not found" >&2
+ return 1
+ fi
+
+ VERSION=`$CIMSERVER --version`
+ if test $? != 0
+ then
+ echo "Error: could not determine cimserver version" >&2
+ return 1
+ fi
+
+ echo $VERSION
+ return 0
+}
+
+compare_version()
+{
+ source=`echo "$1" | awk -F. '{printf("%02d%02d%02d\n", $1,$2,$3); }'`
+ target=`echo "$2" | awk -F. '{printf("%02d%02d%02d\n", $1,$2,$3); }'`
+
+ if test $source \< $target
+ then
+ chatter $source " < " $target
+ echo "true"
+ return 0
+ else
+ chatter $source " >= " $target
+ echo "false"
+ return 1
+ fi
+}
+
pegasus_transform()
{
OUTFILE=$1
@@ -49,10 +86,15 @@
# produce ProviderModules
echo > $OUTFILE
- chatter "Processing provider modules:" $PROVIDERMODULES
- for pm in $PROVIDERMODULES
- do
- cat >> $OUTFILE <<EOFPM
+ version=`pegasus_version`
+ chatter "cimserver version is " $version
+ if compare_version "$version" "2.11.0"
+ then
+ chatter "Processing provider modules (w/o ModuleGroupName):" \
+ $PROVIDERMODULES
+ for pm in $PROVIDERMODULES
+ do
+ cat >> $OUTFILE <<EOFPM
instance of PG_ProviderModule
{
Name = "$pm";
@@ -65,7 +107,29 @@
EOFPM
done
+
+ else
+ chatter "Processing provider modules (w/ ModuleGroupName):" \
+ $PROVIDERMODULES
+ for pm in $PROVIDERMODULES
+ do
+ cat >> $OUTFILE <<EOFPM
+instance of PG_ProviderModule
+{
+ Name = "$pm";
+ Location = "$pm";
+ Vendor = "SBLIM";
+ Version = "2.0.0";
+ InterfaceType = "CMPI";
+ InterfaceVersion = "2.0.0";
+ ModuleGroupName = "libvirt-cim";
+};
+
+EOFPM
+ done
+ fi
+
# produce Providers
set -- $PROVIDERS
while test x$1 != x
@@ -170,6 +234,7 @@
myregs=
mofmode=1
namespace=$1
+ version=`pegasus_version`
shift
while test x$1 != x
@@ -206,7 +271,7 @@
if pegasus_transform $_REGFILENAME $namespace $myregs
then
- chatter Registering providers with $state cimserver
+ chatter Registering providers with $state cimserver '('$version')'
$CIMMOF -uc -I $mofpath -n $namespace $mymofs &&
$CIMMOF -uc -n root/PG_Interop $_REGFILENAME
else
13 years, 7 months
[PATCH] Add SystemCreationClassName and CreationClassName for SwitchService
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1300209608 25200
# Node ID 5e06c520e09e7bada9b851a46c78bb96b947614c
# Parent c5239e6e1fef9bfd74e0adca2da5f15e9fe2e734
Add SystemCreationClassName and CreationClassName for SwitchService
Added above two properties to SwitchService provider.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_Device.c
--- a/src/Virt_Device.c Mon Mar 14 08:04:37 2011 -0700
+++ b/src/Virt_Device.c Tue Mar 15 10:20:08 2011 -0700
@@ -77,7 +77,7 @@
return 0;
str = CMNewString(broker, dev->mac, &s);
- if ((s.rc = CMPI_RC_OK) || (CMIsNullObject(str)))
+ if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(str)))
return 0;
CMSetArrayElementAt(array, 0, &str, CMPI_string);
diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_HostSystem.c
--- a/src/Virt_HostSystem.c Mon Mar 14 08:04:37 2011 -0700
+++ b/src/Virt_HostSystem.c Tue Mar 15 10:20:08 2011 -0700
@@ -101,7 +101,7 @@
char hostname[256] = {0};
op = CMGetObjectPath(instance, &s);
- if ((s.rc == CMPI_RC_OK) || !CMIsNullObject(op)) {
+ if ((s.rc == CMPI_RC_OK) && !CMIsNullObject(op)) {
CMSetProperty(instance, "CreationClassName",
(CMPIValue *)CLASSNAME(op), CMPI_chars);
}
@@ -109,6 +109,7 @@
if (get_fqdn(hostname, sizeof(hostname)) != 0)
strcpy(hostname, "unknown");
+ CU_DEBUG("hostname is %s", hostname);
CMSetProperty(instance, "Name",
(CMPIValue *)hostname, CMPI_chars);
diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c Mon Mar 14 08:04:37 2011 -0700
+++ b/src/Virt_SettingsDefineCapabilities.c Tue Mar 15 10:20:08 2011 -0700
@@ -1598,7 +1598,7 @@
}
str = CMNewString(_BROKER, dev_path, &s);
- if ((s.rc = CMPI_RC_OK) || (CMIsNullObject(str))) {
+ if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(str))) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Unable to create new string");
diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_SwitchService.c
--- a/src/Virt_SwitchService.c Mon Mar 14 08:04:37 2011 -0700
+++ b/src/Virt_SwitchService.c Tue Mar 15 10:20:08 2011 -0700
@@ -34,6 +34,7 @@
#include "misc_util.h"
#include "config.h"
+#include "Virt_HostSystem.h"
#define MAX_LEN 512
#define CMD "/sbin/ifconfig -a | /bin/grep eth | /bin/awk '{print$1}'"
@@ -149,6 +150,41 @@
return arr;
}
+static CMPIStatus set_inst_properties(const CMPIBroker *broker,
+ const CMPIContext *context,
+ const CMPIObjectPath *reference,
+ CMPIInstance *inst)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ const char *name = NULL;
+ const char *ccname = NULL;
+
+ s = get_host_system_properties(&name,
+ &ccname,
+ reference,
+ broker,
+ context);
+ if (s.rc != CMPI_RC_OK) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get host attributes");
+ goto out;
+ }
+
+ CMSetProperty(inst, "Name",
+ (CMPIValue *)"Switch Virtualization Capabilities",
+ CMPI_chars);
+
+ CMSetProperty(inst, "SystemName",
+ (CMPIValue *)name, CMPI_chars);
+
+ CMSetProperty(inst, "SystemCreationClassName",
+ (CMPIValue *)ccname, CMPI_chars);
+
+ out:
+ return s;
+}
+
static CMPIStatus get_switchservice(const CMPIObjectPath *reference,
CMPIInstance **_inst,
const CMPIBroker *broker,
@@ -188,10 +224,12 @@
goto out;
}
- CMSetProperty(inst, "Name",
- (CMPIValue *)"Switch Virtualization Capabilities",
- CMPI_chars);
-
+ s = set_inst_properties(broker, context, reference, inst);
+ if (s.rc != CMPI_RC_OK) {
+ CU_DEBUG("Failed to set instance properties");
+ goto out;
+ }
+
if_list = run_command(CMD, &count, &s);
if (if_list == 0) {
CU_DEBUG("Failed to get network interfaces");
13 years, 7 months
[PATCH] Fixing NullPointerException
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1299548081 28800
# Node ID eea958fbf1d965bc1053850f59df4005e64093ac
# Parent 32ec4dfd813c449501f70e2419cd6f17eee5c673
Fixing NullPointerException
While reading the output of lldptool command the read buffer was going beyond the allocated size and was reading garbage. Added a check to make sure it doesn't go beyond the allocated size.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r 32ec4dfd813c -r eea958fbf1d9 src/Virt_SwitchService.c
--- a/src/Virt_SwitchService.c Wed Mar 02 10:09:34 2011 -0800
+++ b/src/Virt_SwitchService.c Mon Mar 07 17:34:41 2011 -0800
@@ -48,7 +48,8 @@
const char *searchStr[] = {" supported forwarding mode: "
"(0x40) reflective relay",
" supported capabilities: "
- "(0x07) RTE ECP VDP"};
+ "(0x07) RTE ECP VDP",
+ NULL};
int matched = 0;
// Run lldptool command to find vsi support.
13 years, 8 months
[PATCH] Query switch to find its vsi capabilities
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1299082247 28800
# Node ID 134137bc4f2505fc3576b312b8ef2c63a510fa68
# Parent 432922275bea75a769cf058209bdb81198f3b360
Query switch to find its vsi capabilities.
This patch adds a new 'SwitchService' provider that will query the switch to check if it supports VSI.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r 432922275bea -r 134137bc4f25 Makefile.am
--- a/Makefile.am Fri Jan 21 15:59:27 2011 -0500
+++ b/Makefile.am Wed Mar 02 08:10:47 2011 -0800
@@ -28,6 +28,7 @@
schema/ElementConformsToProfile.mof \
schema/ComputerSystemIndication.mof \
schema/ResourceAllocationSettingDataIndication.mof \
+ schema/SwitchService.mof \
schema/ComputerSystemMigrationIndication.mof \
schema/Virt_ResourceAllocationSettingData.mof \
schema/ResourceAllocationSettingData.mof \
@@ -108,6 +109,7 @@
schema/HostedResourcePool.registration \
schema/ComputerSystemIndication.registration \
schema/ResourceAllocationSettingDataIndication.registration \
+ schema/SwitchService.registration \
schema/ComputerSystemMigrationIndication.registration \
schema/ResourceAllocationSettingData.registration \
schema/ResourcePoolConfigurationService.registration \
diff -r 432922275bea -r 134137bc4f25 schema/SwitchService.mof
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/schema/SwitchService.mof Wed Mar 02 08:10:47 2011 -0800
@@ -0,0 +1,27 @@
+// Copyright IBM Corp. 2011
+
+[Provider("cmpi::Virt_SwitchService")]
+class Xen_SwitchService : CIM_SwitchService
+{
+ [Description("Flag to determine if VSI is supported on the switch")]
+ boolean IsVSISupported;
+
+};
+
+[Provider("cmpi::Virt_SwitchService")]
+class KVM_SwitchService : CIM_SwitchService
+{
+ [Description("Flag to determine if VSI is supported on the switch")]
+ boolean IsVSISupported;
+
+};
+
+[Provider("cmpi::Virt_SwitchService")]
+class LXC_SwitchService : CIM_SwitchService
+{
+ [Description("Flag to determine if VSI is supported on the switch")]
+ boolean IsVSISupported;
+
+};
+
+
diff -r 432922275bea -r 134137bc4f25 schema/SwitchService.registration
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/schema/SwitchService.registration Wed Mar 02 08:10:47 2011 -0800
@@ -0,0 +1,6 @@
+# Copyright IBM Corp. 2011
+# Classname Namespace ProviderName ProviderModule ProviderTypes
+Xen_SwitchService root/virt Virt_SwitchService Virt_SwitchService instance
+KVM_SwitchService root/virt Virt_SwitchService Virt_SwitchService instance
+LXC_SwitchService root/virt Virt_SwitchService Virt_SwitchService instance
+
diff -r 432922275bea -r 134137bc4f25 src/Makefile.am
--- a/src/Makefile.am Fri Jan 21 15:59:27 2011 -0500
+++ b/src/Makefile.am Wed Mar 02 08:10:47 2011 -0800
@@ -49,6 +49,7 @@
libVirt_SystemDevice.la \
libVirt_ComputerSystemIndication.la \
libVirt_ResourceAllocationSettingDataIndication.la \
+ libVirt_SwitchService.la \
libVirt_ComputerSystemMigrationIndication.la \
libVirt_VirtualSystemManagementCapabilities.la \
libVirt_AllocationCapabilities.la \
@@ -91,6 +92,10 @@
libVirt_ResourceAllocationSettingDataIndication_la_SOURCES = Virt_ResourceAllocationSettingDataIndication.c
libVirt_ResourceAllocationSettingDataIndication_la_LIBADD = -lVirt_ComputerSystem
+libVirt_SwitchService_la_DEPENDENCIES = libVirt_ComputerSystem.la
+libVirt_SwitchService_la_SOURCES = Virt_SwitchService.c
+libVirt_SwitchService_la_LIBADD = -lVirt_ComputerSystem
+
libVirt_ComputerSystemMigrationIndication_la_DEPENDENCIES = libVirt_ComputerSystem.la
libVirt_ComputerSystemMigrationIndication_la_SOURCES = Virt_ComputerSystemMigrationIndication.c
libVirt_ComputerSystemMigrationIndication_la_LIBADD = -lVirt_ComputerSystem
diff -r 432922275bea -r 134137bc4f25 src/Virt_SwitchService.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Virt_SwitchService.c Wed Mar 02 08:10:47 2011 -0800
@@ -0,0 +1,297 @@
+/*
+ * Copyright IBM Corp. 2011
+ *
+ * Authors:
+ * Sharad Mishra <snmishra(a)us.ibm.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdbool.h>
+#include <errno.h>
+
+#include <cmpidt.h>
+#include <cmpift.h>
+#include <cmpimacs.h>
+
+#include <libcmpiutil/libcmpiutil.h>
+#include <libcmpiutil/std_instance.h>
+
+#include "misc_util.h"
+#include "config.h"
+
+#define MAX_LEN 512
+#define CMD "/sbin/ifconfig -a | /bin/grep eth | /bin/awk '{print$1}'"
+
+const static CMPIBroker *_BROKER;
+
+static CMPIStatus check_vsi_support(char *command)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ char buff[MAX_LEN];
+ FILE *stream = NULL;
+ const char *searchStr[] = {" supported forwarding mode: "
+ "(0x40) reflective relay",
+ " supported capabilities: "
+ "(0x07) RTE ECP VDP"};
+ int matched = 0;
+
+ // Run lldptool command to find vsi support.
+ stream = popen(command, "r");
+ if (stream == NULL) {
+ CU_DEBUG("Failed to open pipe to read vsi support");
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "Failed to open pipe");
+ goto out;
+ }
+
+ // Read the output of the command.
+ while (fgets(buff, MAX_LEN, stream) != NULL) {
+ int i = 0;
+ while (searchStr[i] != NULL) {
+ int len = strlen(searchStr[i]);
+ /* Read value which is stored in 'buff' has newline
+ at the end, we remove it for comparison. */
+ if (strncmp(buff, searchStr[i], (len - 1)) == 0) {
+ /* 'matched' flag is incremented each time
+ we find that read string (output of lldptool
+ command) and searchStrings are same. */
+ matched++;
+ break;
+ }
+ i++;
+ }
+ /* All the search strings were found in the output of this
+ command. */
+ if (matched == 2) {
+ cu_statusf(_BROKER, &s, CMPI_RC_OK, "VSI supported");
+ goto out;;
+ }
+ }
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No VSI Support found");
+
+ out:
+ pclose(stream);
+ return s;
+}
+
+static char **run_command(char *func, int *len, CMPIStatus *s) {
+
+ char buff[MAX_LEN];
+ FILE *stream = NULL;
+ char **arr = NULL;
+ char *string = NULL;
+ int i = 0;
+
+ // run the command.
+ stream = popen(func, "r");
+ if (stream == NULL) {
+ CU_DEBUG("Failed to open pipe to run command");
+ cu_statusf(_BROKER, s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "Failed to open pipe");
+ return NULL;
+ }
+
+ // read output of command.
+ while (fgets(buff, MAX_LEN, stream) != NULL) {
+ int len = strlen(buff) - 1;
+ char **tmp_list = NULL;
+
+ // dynamically increase size as more interfaces are found.
+ tmp_list = (char **)realloc(arr,
+ (i + 1) *
+ sizeof(char *));
+ if (tmp_list == NULL) {
+ CU_DEBUG("Failed to allocate memory");
+ cu_statusf(_BROKER, s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "Failed to realloc");
+ return NULL;
+ }
+
+ arr = tmp_list;
+
+ string = calloc(len, sizeof(char));
+ if (string == NULL) {
+ CU_DEBUG("Failed to allocate memory");
+ cu_statusf(_BROKER, s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "Failed to calloc");
+ return NULL;
+ }
+ strncpy(string, buff, len);
+ arr[i] = string;
+ i++;
+ }
+
+ pclose(stream);
+ *len = i;
+ return arr;
+}
+
+static CMPIStatus get_switchservice(const CMPIObjectPath *reference,
+ CMPIInstance **_inst,
+ const CMPIBroker *broker,
+ const CMPIContext *context,
+ bool is_get_inst)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *inst = NULL;
+ virConnectPtr conn = NULL;
+ bool vsi = false;
+ int count = 0;
+ int i;
+ char **if_list;
+ char cmd[MAX_LEN];
+
+ *_inst = NULL;
+ conn = connect_by_classname(broker, CLASSNAME(reference), &s);
+ if (conn == NULL) {
+ if (is_get_inst)
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance");
+
+ return s;
+ }
+
+ inst = get_typed_instance(broker,
+ pfx_from_conn(conn),
+ "SwitchService",
+ NAMESPACE(reference));
+
+ if (inst == NULL) {
+ CU_DEBUG("Failed to get typed instance");
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_FAILED,
+ "Failed to create instance");
+ goto out;
+ }
+
+ CMSetProperty(inst, "Name",
+ (CMPIValue *)"Switch Virtualization Capabilities",
+ CMPI_chars);
+
+ if_list = run_command(CMD, &count, &s);
+ if (if_list == 0) {
+ CU_DEBUG("Failed to get network interfaces");
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_FAILED,
+ "Failed to get network interfaces");
+ goto out;
+ }
+
+ CU_DEBUG("Found %d interfaces", count);
+
+
+ for (i=0; i<count; i++) {
+ sprintf(cmd, "lldptool -i %s -t -V evbcfg", if_list[i]);
+ CU_DEBUG("running command %s ...", cmd);
+ s = check_vsi_support(cmd);
+ if (s.rc == CMPI_RC_OK) {
+ vsi = true;
+ break;
+ }
+ else
+ vsi = false;
+ }
+
+ CMSetProperty(inst, "IsVSISupported", (CMPIValue *)&vsi, CMPI_boolean);
+ s.rc = CMPI_RC_OK;
+
+ out:
+ virConnectClose(conn);
+ *_inst = inst;
+
+ return s;
+
+}
+
+static CMPIStatus return_switchservice(const CMPIContext *context,
+ const CMPIObjectPath *reference,
+ const CMPIResult *results,
+ bool name_only,
+ bool is_get_inst)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *inst;
+
+ s = get_switchservice(reference, &inst, _BROKER, context, is_get_inst);
+ if (s.rc != CMPI_RC_OK || inst == NULL)
+ goto out;
+
+ if (name_only)
+ cu_return_instance_name(results, inst);
+ else
+ CMReturnInstance(results, inst);
+ out:
+ return s;
+}
+
+static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *ref)
+{
+ return return_switchservice(context, ref, results, true, false);
+}
+
+static CMPIStatus EnumInstances(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *ref,
+ const char **properties)
+{
+
+ return return_switchservice(context, ref, results, false, false);
+}
+
+static CMPIStatus GetInstance(CMPIInstanceMI *self,
+ const CMPIContext *context,
+ const CMPIResult *results,
+ const CMPIObjectPath *ref,
+ const char **properties)
+{
+ return return_switchservice(context, ref, results, false, true);
+}
+
+DEFAULT_CI();
+DEFAULT_MI();
+DEFAULT_DI();
+DEFAULT_EQ();
+DEFAULT_INST_CLEANUP();
+
+STD_InstanceMIStub(,
+ Virt_SwitchService,
+ _BROKER,
+ libvirt_cim_init());
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-set-style: "K&R"
+ * tab-width: 8
+ * c-basic-offset: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
+
13 years, 8 months
[PATCH] Auto refresh StoragePools
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1299089374 28800
# Node ID 1a894e2ab420ffb16d21d8ffa8c9850bea58b31c
# Parent 7a2ce3106321ac1729aeff2b9e42fb2e75da9295
Auto refresh StoragePools
This patch refreshes storage pool after volumes have been created or deleted from this pool. This patch also refreshes the pool before enumerating them.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r 7a2ce3106321 -r 1a894e2ab420 libxkutil/pool_parsing.c
--- a/libxkutil/pool_parsing.c Mon Feb 28 05:57:22 2011 -0800
+++ b/libxkutil/pool_parsing.c Wed Mar 02 10:09:34 2011 -0800
@@ -400,6 +400,9 @@
goto out;
}
+ if ((virStoragePoolRefresh(ptr, 0)) == -1)
+ CU_DEBUG("Unable to refresh storage pool");
+
path = virStorageVolGetPath(vptr);
if (path == NULL) {
CU_DEBUG("Unable to get storage volume path");
@@ -420,9 +423,11 @@
int res_type)
{
int ret = 0;
+ virStorageVolPtr ptr;
+ virStoragePoolPtr pool_ptr;
if (res_type == CIM_RES_TYPE_IMAGE) {
- virStorageVolPtr ptr = virStorageVolLookupByPath(conn, rname);
+ ptr = virStorageVolLookupByPath(conn, rname);
if (ptr == NULL) {
CU_DEBUG("Storage volume %s is not defined", rname);
goto out;
@@ -432,6 +437,16 @@
if (ret != 0) {
CU_DEBUG("Unable to delete storage volume %s", rname);
} else {
+ pool_ptr = virStoragePoolLookupByVolume(ptr);
+ if (pool_ptr == NULL) {
+ CU_DEBUG("Unable to get storage pool "
+ "from volume");
+ } else {
+ ret = virStoragePoolRefresh(pool_ptr, 0);
+ if (ret != 0)
+ CU_DEBUG("Unable to refresh storage "
+ "pool");
+ }
ret = 1;
}
diff -r 7a2ce3106321 -r 1a894e2ab420 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c Mon Feb 28 05:57:22 2011 -0800
+++ b/src/Virt_DevicePool.c Wed Mar 02 10:09:34 2011 -0800
@@ -182,6 +182,10 @@
goto out;
}
+ if ((virStoragePoolRefresh(pool, 0)) == -1)
+ CU_DEBUG("Unable to refresh storage pool");
+
+
if (virStoragePoolGetInfo(pool, &info) == -1) {
CU_DEBUG("Failed to get info for pool `%s'", _pool->tag);
goto out;
13 years, 8 months