[PATCH] Fix crash when creating ACL filter lists
by Chip Vincent
# HG changeset patch
# User Chip Vincent <cvincent(a)us.ibm.com>
# Date 1311193039 14400
# Node ID c4fae0f5cc8f21f0d66077df7693158c10633ece
# Parent 6056961c3c5347d3b8375039767d7bc78fa97eb5
Fix crash when creating ACL filter lists
Specifically, AppliedFilterList and NestedFilterList CreateInstance().
For AppliedFilterList:
The Antecedent and Dependent were backwards and the provider would crash
since no libvirt connection was made before calling get_filter_by_name().
Also added some additional error checking in acl_parsing.c. It appears
libvirt w/ qemu does not support dynamic updating of virtual net devices
in 0.8.1 so CreateInstance() will still fail (but not crash) in that
version. Looking for alternatives to provide dynamic support and will post
in a follow-on patch.
For NestedFilterList:
The code was trying to extract the 'Name' property from the instance reference,
rather than the Antecedent and Dependent properties. Also fixed an issue
when creating the filter XML.
NOTE: I'm still seeing sparatic cores in various providers when doing
'deep' or 'broad' associators calls (not using the -ac). However, there is no
indication that bug is tied to this feature. For example, I cannot get the
ACL providers to crash when using 'wbemcli ai -ac'.
Signed-off-by: Chip Vincent <cvincent(a)us.ibm.com>
diff --git a/libxkutil/acl_parsing.c b/libxkutil/acl_parsing.c
--- a/libxkutil/acl_parsing.c
+++ b/libxkutil/acl_parsing.c
@@ -429,6 +429,7 @@
int get_filter_from_xml(const char *xml, struct acl_filter **filter)
{
xmlDoc *xmldoc = NULL;
+ int ret = 0;
if (xml == NULL || filter == NULL)
return 0;
@@ -440,15 +441,19 @@
goto err;
*filter = malloc(sizeof(**filter));
+ if (*filter == NULL)
+ goto err;
memset(*filter, 0, sizeof(**filter));
parse_acl_filter(xmldoc->children, *filter);
+ ret = 1;
+
err:
xmlSetGenericErrorFunc(NULL, NULL);
xmlFreeDoc(xmldoc);
- return 1;
+ return ret;
}
int get_filter_by_name(
@@ -464,6 +469,8 @@
return 0;
vfilter = virNWFilterLookupByName(conn, name);
+ if (vfilter == NULL)
+ return 0;
xml = virNWFilterGetXMLDesc(vfilter, 0);
@@ -472,9 +479,7 @@
if (xml == NULL)
return 0;
- get_filter_from_xml(xml, filter);
-
- return 1;
+ return get_filter_from_xml(xml, filter);
#else
return 0;
#endif
@@ -493,6 +498,8 @@
return 0;
vfilter = virNWFilterLookupByUUIDString(conn, uuid);
+ if (vfilter == NULL)
+ return 0;
xml = virNWFilterGetXMLDesc(vfilter, 0);
@@ -581,31 +588,27 @@
int update_filter(virConnectPtr conn, struct acl_filter *filter)
{
- if (delete_filter(conn, filter) == 0 ||
- create_filter(conn, filter) == 0)
- return 0;
-
- return 1;
+ return create_filter(conn, filter);
}
int delete_filter(virConnectPtr conn, struct acl_filter *filter)
{
#if LIBVIR_VERSION_NUMBER > 8000
+ int ret = 0;
virNWFilterPtr vfilter = NULL;
if (filter == NULL)
return 0;
- vfilter = virNWFilterLookupByUUIDString(conn, filter->uuid);
+ vfilter = virNWFilterLookupByName(conn, filter->name);
if (vfilter == NULL)
return 0;
- if (virNWFilterUndefine(vfilter) != 0) {
- virNWFilterFree(vfilter);
- return 0;
- }
+ ret = virNWFilterUndefine(vfilter);
- return 1;
+ virNWFilterFree(vfilter);
+
+ return ret == 0 ? 1 : 0;
#else
return 0;
#endif
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -1375,14 +1375,16 @@
if (xmlNewProp(root, BAD_CAST "name", BAD_CAST filter->name) == NULL)
goto out;
- if (filter->chain != NULL)
+ if (filter->chain != NULL) {
if (xmlNewProp(root, BAD_CAST "chain",
BAD_CAST filter->chain) == NULL)
goto out;
+ }
if (filter->uuid != NULL) {
- tmp = xmlNewChild(root, NULL, BAD_CAST "uuid", NULL);
- if (xmlNewProp(tmp, NULL, BAD_CAST filter->uuid) == NULL)
+ tmp = xmlNewChild(root, NULL, BAD_CAST "uuid",
+ BAD_CAST filter->uuid);
+ if (tmp == NULL)
goto out;
}
@@ -1406,7 +1408,7 @@
msg = NULL; /* no errors */
out:
- CU_DEBUG("Filter XML: %s", msg);
+ CU_DEBUG("Filter XML: %s", xml);
xmlFreeNode(root);
diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c
--- a/src/Virt_AppliedFilterList.c
+++ b/src/Virt_AppliedFilterList.c
@@ -30,6 +30,7 @@
#include "acl_parsing.h"
#include "misc_util.h"
#include "cs_util.h"
+#include "xmlgen.h"
#include "Virt_Device.h"
#include "Virt_FilterList.h"
@@ -111,20 +112,14 @@
VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
int ret = 0;
- /** device_to_xml() is not exported, so this function needs
- * to be moved
- */
-
- /* xml = device_to_xml(dev); */
-
+ xml = device_to_xml(dev);
if (xml == NULL) {
CU_DEBUG("Failed to get XML for device '%s'", dev->id);
goto out;
}
if (virDomainUpdateDeviceFlags(dom, xml, flags) != 0) {
- CU_DEBUG("Failed to dynamically update device:");
- CU_DEBUG("%s", xml);
+ CU_DEBUG("Failed to dynamically update device");
goto out;
}
@@ -430,6 +425,10 @@
virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
+ conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s);
+ if (conn == NULL)
+ goto out;
+
CU_DEBUG("Reference = %s", REF2STR(reference));
if (cu_get_ref_prop(instance, "Antecedent",
@@ -440,18 +439,13 @@
goto out;
}
- if (cu_get_str_path(reference, "Name", &filter_name) != CMPI_RC_OK) {
+ CU_DEBUG("Antecedent = %s", REF2STR(antecedent));
+
+ if (cu_get_str_path(antecedent, "DeviceID",
+ &device_name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Unable to get Antecedent.Name property");
- goto out;
- }
-
- get_filter_by_name(conn, filter_name, &filter);
- if (filter == NULL) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Antecedent.Name object does not exist");
+ "Unable to get Antecedent.DeviceID property");
goto out;
}
@@ -463,15 +457,23 @@
goto out;
}
- if (cu_get_str_path(reference, "DeviceID",
- &device_name) != CMPI_RC_OK) {
+ CU_DEBUG("Dependent = %s", REF2STR(dependent));
+
+ if (cu_get_str_path(dependent, "Name",
+ &filter_name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Unable to get Dependent.DeviceID property");
+ "Unable to get Dependent.Name property");
goto out;
}
- CU_DEBUG("DeviceID = %s", device_name);
+ get_filter_by_name(conn, filter_name, &filter);
+ if (filter == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Antecedent.Name object does not exist");
+ goto out;
+ }
if (parse_fq_devid(device_name, &domain_name, &net_name) == 0) {
CU_DEBUG("Failed to parse devid");
@@ -539,6 +541,10 @@
virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
+ conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s);
+ if (conn == NULL)
+ goto out;
+
CU_DEBUG("Reference = %s", REF2STR(reference));
if (cu_get_ref_path(reference, "Antecedent",
@@ -549,18 +555,11 @@
goto out;
}
- if (cu_get_str_path(reference, "Name", &filter_name) != CMPI_RC_OK) {
+ if (cu_get_str_path(reference, "DeviceID",
+ &device_name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Unable to get Antecedent.Name property");
- goto out;
- }
-
- get_filter_by_name(conn, filter_name, &filter);
- if (filter == NULL) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Antecedent.Name object does not exist");
+ "Unable to get Antecedent.DeviceID property");
goto out;
}
@@ -572,15 +571,21 @@
goto out;
}
- if (cu_get_str_path(reference, "DeviceID",
- &device_name) != CMPI_RC_OK) {
+ if (cu_get_str_path(reference, "Name",
+ &filter_name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Unable to get Dependent.DeviceID property");
+ "Unable to get Dependent.Name property");
goto out;
}
- CU_DEBUG("DeviceID = %s", device_name);
+ get_filter_by_name(conn, filter_name, &filter);
+ if (filter == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Antecedent.Name object does not exist");
+ goto out;
+ }
if (parse_fq_devid(device_name, &domain_name, &net_name) == 0) {
CU_DEBUG("Failed to parse devid");
diff --git a/src/Virt_FilterList.c b/src/Virt_FilterList.c
--- a/src/Virt_FilterList.c
+++ b/src/Virt_FilterList.c
@@ -269,6 +269,8 @@
CMPIInstance *_instance = NULL;
virConnectPtr conn = NULL;
+ CU_DEBUG("Reference = %s", REF2STR(reference));
+
/**Get Name from instance rather than reference since keys
* are set by this provider, not the client.
*/
@@ -335,6 +337,8 @@
struct acl_filter *filter = NULL;
virConnectPtr conn = NULL;
+ CU_DEBUG("Reference = %s", REF2STR(reference));
+
if (cu_get_str_path(reference, "Name", &name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_NOT_FOUND,
diff --git a/src/Virt_NestedFilterList.c b/src/Virt_NestedFilterList.c
--- a/src/Virt_NestedFilterList.c
+++ b/src/Virt_NestedFilterList.c
@@ -323,13 +323,17 @@
goto out;
}
- if (cu_get_str_path(reference, "Name", &parent_name) != CMPI_RC_OK) {
+ CU_DEBUG("Antecedent = %s", REF2STR(antecedent));
+
+ if (cu_get_str_path(antecedent, "Name", &parent_name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Unable to get Antecedent.Name property");
goto out;
}
+ CU_DEBUG("Antecedent.Name = %s", parent_name);
+
get_filter_by_name(conn, parent_name, &parent_filter);
if (parent_filter == NULL) {
cu_statusf(_BROKER, &s,
@@ -346,13 +350,17 @@
goto out;
}
- if (cu_get_str_path(reference, "Name", &child_name) != CMPI_RC_OK) {
+ CU_DEBUG("Dependent = %s", REF2STR(dependent));
+
+ if (cu_get_str_path(dependent, "Name", &child_name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Unable to get Dependent.Name property");
goto out;
}
+ CU_DEBUG("Dependent.Name = %s", child_name);
+
get_filter_by_name(conn, child_name, &child_filter);
if (child_filter == NULL) {
cu_statusf(_BROKER, &s,
@@ -368,6 +376,9 @@
goto out;
}
+ CU_DEBUG("filter appended, parent_filter->name = %s",
+ parent_filter->name);
+
if (update_filter(conn, parent_filter) == 0) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
13 years, 4 months
[PATCH] Remove has_vnc_passwd key from infostore
by Eduardo Lima (Etrunko)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1311192727 10800
# Node ID 9746544f39f508bb08b0c7ea71153dbbceda8dd9
# Parent 6056961c3c5347d3b8375039767d7bc78fa97eb5
Remove has_vnc_passwd key from infostore
The logic is not necessary anymore since we return the vnc password
in every call to retrieve a domain XML. Also fix some other places
where this field was not handled properly.
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -809,6 +809,7 @@
DUP_FIELD(dev, _dev, dev.graphics.port);
DUP_FIELD(dev, _dev, dev.graphics.host);
DUP_FIELD(dev, _dev, dev.graphics.keymap);
+ DUP_FIELD(dev, _dev, dev.graphics.passwd);
} else if (dev->type == CIM_RES_TYPE_INPUT) {
DUP_FIELD(dev, _dev, dev.input.type);
DUP_FIELD(dev, _dev, dev.input.bus);
@@ -889,7 +890,7 @@
char *xml;
int ret;
- xml = virDomainGetXMLDesc(dom, 0);
+ xml = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_SECURE);
if (xml == NULL)
return 0;
diff --git a/src/Virt_ComputerSystem.c b/src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c
+++ b/src/Virt_ComputerSystem.c
@@ -920,7 +920,7 @@
return s;
}
- xml = virDomainGetXMLDesc(dom, 0);
+ xml = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_SECURE);
if (xml == NULL) {
CU_DEBUG("Unable to retrieve domain XML");
virt_set_status(_BROKER, &s,
diff --git a/src/Virt_ComputerSystemIndication.c b/src/Virt_ComputerSystemIndication.c
--- a/src/Virt_ComputerSystemIndication.c
+++ b/src/Virt_ComputerSystemIndication.c
@@ -151,7 +151,7 @@
}
(*dom_xml_list)[i].xml = virDomainGetXMLDesc(dom_ptr_list[i],
- 0);
+ VIR_DOMAIN_XML_SECURE);
if ((*dom_xml_list)[i].xml == NULL) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c
--- a/src/Virt_RASD.c
+++ b/src/Virt_RASD.c
@@ -420,8 +420,6 @@
CMPIStatus s = {CMPI_RC_OK, NULL};
virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
- struct infostore_ctx *infostore = NULL;
- bool has_passwd = false;
CMSetProperty(inst, "ResourceSubType",
(CMPIValue *)dev->dev.graphics.type, CMPI_chars);
@@ -460,19 +458,12 @@
goto out;
}
- infostore = infostore_open(dom);
- if (infostore != NULL)
- has_passwd = infostore_get_bool(infostore,
- "has_vnc_passwd");
-
- if (has_passwd) {
+ if (dev->dev.graphics.passwd && strlen(dev->dev.graphics.passwd)) {
CU_DEBUG("has password");
CMSetProperty(inst, "Password",
(CMPIValue *)"********", CMPI_chars);
}
- infostore_close(infostore);
-
/* FIXME: Populate the IsIPv6Only */
}
diff --git a/src/Virt_VSMigrationService.c b/src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c
+++ b/src/Virt_VSMigrationService.c
@@ -1060,7 +1060,7 @@
{
CMPIStatus s = {CMPI_RC_OK, NULL};
- *xml = virDomainGetXMLDesc(dom, 0);
+ *xml = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_SECURE);
if (*xml == NULL) {
virt_set_status(_BROKER, &s,
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -373,6 +373,7 @@
domain->dev_graphics->dev.graphics.port = strdup("-1");
domain->dev_graphics->dev.graphics.host = strdup("127.0.0.1");
domain->dev_graphics->dev.graphics.keymap = strdup("en-us");
+ domain->dev_graphics->dev.graphics.passwd = NULL;
domain->dev_graphics_ct = 1;
return true;
@@ -1543,14 +1544,6 @@
infostore_set_u64(ctx, "weight", dev->dev.vcpu.weight);
infostore_set_u64(ctx, "limit", dev->dev.vcpu.limit);
- dev = dominfo->dev_graphics;
- if(dev != NULL){
- if (dev->dev.graphics.passwd != NULL)
- infostore_set_bool(ctx, "has_vnc_passwd", true);
- else
- infostore_set_bool(ctx, "has_vnc_passwd", false);
- }
-
out:
infostore_close(ctx);
13 years, 4 months
[PATCH] (#2)Set PoolID for CIM_DiskResourceAllocationSettingData
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1311169386 25200
# Node ID 7cb42b369d3776c9d727402ba0198eea573d0d40
# Parent 6056961c3c5347d3b8375039767d7bc78fa97eb5
(#2)Set PoolID for CIM_DiskResourceAllocationSettingData.
PoolID wasn't getting set for DiskResourceAllocationSettingData. PoolID
for DiskResourceAllocationSettingData is set by appending "DiskPool"
to the Storage Pool name.
#2: Added "const" to const char* virStoragePoolGetName at line 286.
Signed-off-by: Sharad Mishra<snmishra(a)us.ibm.com>
diff -r 6056961c3c53 -r 7cb42b369d37 src/Virt_RASD.c
--- a/src/Virt_RASD.c Tue Jul 19 16:46:19 2011 -0300
+++ b/src/Virt_RASD.c Wed Jul 20 06:43:06 2011 -0700
@@ -234,6 +234,7 @@
uint64_t cap = 0;
uint16_t type;
CMPIStatus s = {CMPI_RC_OK, NULL};
+ char *poolid = NULL;
get_vol_size(broker, ref, dev->dev.disk.source, &cap);
@@ -253,6 +254,55 @@
(CMPIValue *)dev->dev.disk.source,
CMPI_chars);
+ virConnectPtr conn = connect_by_classname(broker, CLASSNAME(ref), &s);
+ if (conn == NULL) {
+ virt_set_status(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ conn,
+ "Could not get connection to hypervisor");
+ goto cont;
+ }
+
+ virStorageVolPtr vol = virStorageVolLookupByPath(conn,
+ dev->dev.disk.source);
+ if (vol == NULL) {
+ virt_set_status(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ conn,
+ "Failed to get StorageVolPtr");
+ goto cont;
+ }
+
+ virStoragePoolPtr pool = virStoragePoolLookupByVolume(vol);
+ if (pool == NULL) {
+ virt_set_status(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ conn,
+ "Failed to get StoragePoolPtr");
+ goto cont;
+ }
+
+ const char *pool_name = virStoragePoolGetName(pool);
+ if (pool_name == NULL) {
+ virt_set_status(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ conn,
+ "Failed to get Pool name for volume");
+ goto cont;
+ }
+
+ int ret = asprintf(&poolid, "DiskPool/%s", pool_name);
+
+ if (ret == -1) {
+ CU_DEBUG("Failed to get disk poolid");
+ goto cont;
+ }
+
+ CMSetProperty(inst,
+ "PoolID",
+ (CMPIValue *)poolid,
+ CMPI_chars);
+ cont:
CMSetProperty(inst,
"BusType",
(CMPIValue *)dev->dev.disk.bus_type,
13 years, 4 months
[PATCH] libxkutil: More meaningful log message
by Eduardo Lima (Etrunko)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1311104779 10800
# Node ID 43f9834c98a030ada1d69693d119cdc6367cf284
# Parent 3c90a88a5199a4ed931a4a76097cff8f55deae41
libxkutil: More meaningful log message
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c
--- a/libxkutil/misc_util.c
+++ b/libxkutil/misc_util.c
@@ -73,14 +73,14 @@
ret = config_read_file(&conf, LIBVIRTCIM_CONF);
if (ret == CONFIG_FALSE) {
- CU_DEBUG("Error reading config file at liine %d: '%s'\n",
+ CU_DEBUG("Error reading config file at line %d: '%s'\n",
conf.error_line, conf.error_text);
goto out;
}
ret = config_lookup_bool(&conf, readonly_str, &readonly);
if (ret == CONFIG_FALSE) {
- CU_DEBUG("Error: '%s' not found in config file\n",
+ CU_DEBUG("'%s' not found in config file, assuming false\n",
readonly_str);
goto out;
}
13 years, 4 months
[PATCH] Add source host and directory for netfs diskpool
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1310766822 25200
# Node ID f064a20fba355fa2fbaa2bc914fa2189712223f6
# Parent 0563cf6502d4cd10418001d88c0c60b269370b3e
Add source host and directory for netfs diskpool.
Added new properties to populate the source host and
directory being used for netfs diskpool.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r 0563cf6502d4 -r f064a20fba35 schema/DiskPool.mof
--- a/schema/DiskPool.mof Fri Jul 15 09:03:55 2011 -0700
+++ b/schema/DiskPool.mof Fri Jul 15 14:53:42 2011 -0700
@@ -5,6 +5,9 @@
{
[Description("Path this storage pool represents")]
string Path;
+ uint16 Autostart;
+ string Host;
+ string SourceDirectory;
};
@@ -13,6 +16,9 @@
{
[Description("Path this storage pool represents")]
string Path;
+ uint16 Autostart;
+ string Host;
+ string SourceDirectory;
};
@@ -21,6 +27,9 @@
{
[Description("Path this storage pool represents")]
string Path;
+ uint16 Autostart;
+ string Host;
+ string SourceDirectory;
};
diff -r 0563cf6502d4 -r f064a20fba35 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c Fri Jul 15 09:03:55 2011 -0700
+++ b/src/Virt_DevicePool.c Fri Jul 15 14:53:42 2011 -0700
@@ -213,6 +213,19 @@
CMSetProperty(inst, "Path",
(CMPIValue *)pool_str, CMPI_chars);
}
+ if (pool_vals->pool_info.disk.host != NULL) {
+ pool_str = strdup(pool_vals->pool_info.disk.host);
+
+ CMSetProperty(inst, "Host",
+ (CMPIValue *)pool_str, CMPI_chars);
+ }
+ if (pool_vals->pool_info.disk.src_dir != NULL) {
+ pool_str = strdup(pool_vals->pool_info.disk.src_dir);
+
+ CMSetProperty(inst, "SourceDirectory",
+ (CMPIValue *)pool_str, CMPI_chars);
+ }
+
type = pool_vals->pool_info.disk.pool_type;
CMSetProperty(inst, "OtherResourceType",
(CMPIValue *)get_disk_pool_type(type),
13 years, 4 months
[PATCH] Set PoolID for CIM_DiskResourceAllocationSettingData
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1311012637 25200
# Node ID d1f131ad4cf75263d8178ebb89ad9dada3997280
# Parent e8c1cdd5c9cbe887286ef169d8ff525cc9035485
Set PoolID for CIM_DiskResourceAllocationSettingData.
PoolID wasn't getting set for DiskResourceAllocationSettingData. PoolID
for DiskResourceAllocationSettingData is set by appending "DiskPool"
to the Storage Pool name.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r e8c1cdd5c9cb -r d1f131ad4cf7 src/Virt_RASD.c
--- a/src/Virt_RASD.c Sun Jul 17 12:37:31 2011 -0700
+++ b/src/Virt_RASD.c Mon Jul 18 11:10:37 2011 -0700
@@ -234,6 +234,7 @@
uint64_t cap = 0;
uint16_t type;
CMPIStatus s = {CMPI_RC_OK, NULL};
+ char *poolid = NULL;
get_vol_size(broker, ref, dev->dev.disk.source, &cap);
@@ -253,6 +254,55 @@
(CMPIValue *)dev->dev.disk.source,
CMPI_chars);
+ virConnectPtr conn = connect_by_classname(broker, CLASSNAME(ref), &s);
+ if (conn == NULL) {
+ virt_set_status(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ conn,
+ "Could not get connection to hypervisor");
+ goto cont;
+ }
+
+ virStorageVolPtr vol = virStorageVolLookupByPath(conn,
+ dev->dev.disk.source);
+ if (vol == NULL) {
+ virt_set_status(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ conn,
+ "Failed to get StorageVolPtr");
+ goto cont;
+ }
+
+ virStoragePoolPtr pool = virStoragePoolLookupByVolume(vol);
+ if (pool == NULL) {
+ virt_set_status(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ conn,
+ "Failed to get StoragePoolPtr");
+ goto cont;
+ }
+
+ char *pool_name = virStoragePoolGetName(pool);
+ if (pool_name == NULL) {
+ virt_set_status(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ conn,
+ "Failed to get Pool name for volume");
+ goto cont;
+ }
+
+ int ret = asprintf(&poolid, "DiskPool/%s", pool_name);
+
+ if (ret == -1) {
+ CU_DEBUG("Failed to get disk poolid");
+ goto cont;
+ }
+
+ CMSetProperty(inst,
+ "PoolID",
+ (CMPIValue *)poolid,
+ CMPI_chars);
+ cont:
CMSetProperty(inst,
"BusType",
(CMPIValue *)dev->dev.disk.bus_type,
13 years, 4 months
[PATCH] Set PoolID for CIM_NetResourceAllocationSettingData
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1310931451 25200
# Node ID e8c1cdd5c9cbe887286ef169d8ff525cc9035485
# Parent 0563cf6502d4cd10418001d88c0c60b269370b3e
Set PoolID for CIM_NetResourceAllocationSettingData.
PoolID wasn't getting set for NETResourceAllocationSettingData. PoolID
for NETResourceAllocationSettingData is set by appending "NetworkPool"
to the network name.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r 0563cf6502d4 -r e8c1cdd5c9cb libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Fri Jul 15 09:03:55 2011 -0700
+++ b/libxkutil/device_parsing.c Sun Jul 17 12:37:31 2011 -0700
@@ -372,8 +372,16 @@
if (ndev->source != NULL)
continue;
ndev->source = get_attr_value(child, "network");
- if (ndev->source != NULL)
+ if (ndev->source != NULL) {
+ int ret = asprintf(&ndev->poolid,
+ "NetworkPool/%s",
+ ndev->source);
+ if (ret == -1) {
+ CU_DEBUG("Failed to get network"
+ " poolid");
+ }
continue;
+ }
ndev->source = get_attr_value(child, "dev");
ndev->net_mode = get_attr_value(child, "mode");
if ((ndev->source != NULL) && (ndev->net_mode != NULL))
diff -r 0563cf6502d4 -r e8c1cdd5c9cb libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h Fri Jul 15 09:03:55 2011 -0700
+++ b/libxkutil/device_parsing.h Sun Jul 17 12:37:31 2011 -0700
@@ -61,6 +61,7 @@
char *type;
char *mac;
char *source;
+ char *poolid;
char *model;
char *device;
char *net_mode;
diff -r 0563cf6502d4 -r e8c1cdd5c9cb src/Virt_RASD.c
--- a/src/Virt_RASD.c Fri Jul 15 09:03:55 2011 -0700
+++ b/src/Virt_RASD.c Sun Jul 17 12:37:31 2011 -0700
@@ -401,6 +401,12 @@
(CMPIValue *)dev->dev.net.model,
CMPI_chars);
+ if (dev->dev.net.poolid != NULL)
+ CMSetProperty(inst,
+ "PoolID",
+ (CMPIValue *)dev->dev.net.poolid,
+ CMPI_chars);
+
return s;
}
13 years, 4 months
[PATCH v2 2/2] Add SDL graphic device support
by Wayne Xia
# HG changeset patch
# User Wayne Xia <xiawenc(a)linux.vnet.ibm.com>
# Date 1311161825 -28800
# Node ID 4c47a4b500e86abe2bb6461fdaaf2fe5d2e1d861
# Parent 0c52e4f6c421cc2e168197a82a9333d4ce369655
add sdl frame buffer support.
Now libvirt still supports sdl frame buffer, and it may take three
parameters: display,xauth,fullscreen. This patch enable the libvirt-cim
to accept these configuration and pass them in XML define to let
libvirt know about it.Exposed interface could be found in the file
ResourceAllocationSettingData.mof.
https://bugzilla.linux.ibm.com/show_bug.cgi?id=71347
diff -r 0c52e4f6c421 -r 4c47a4b500e8 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Wed Jul 20 18:03:54 2011 +0800
+++ b/libxkutil/device_parsing.c Wed Jul 20 19:37:05 2011 +0800
@@ -530,6 +530,11 @@
if (gdev->dev.vnc.port == NULL || gdev->dev.vnc.host
== NULL)
goto err;
}
+ else if (STREQC(gdev->type, "sdl")) {
+ gdev->dev.sdl.display = get_attr_value(node, "display");
+ gdev->dev.sdl.xauth = get_attr_value(node, "xauth");
+ gdev->dev.sdl.fullscreen = get_attr_value(node,
"fullscreen");
+ }
else if (STREQC(gdev->type, "pty")) {
if (node->name == NULL)
goto err;
diff -r 0c52e4f6c421 -r 4c47a4b500e8 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Wed Jul 20 18:03:54 2011 +0800
+++ b/libxkutil/xmlgen.c Wed Jul 20 19:37:05 2011 +0800
@@ -421,8 +421,21 @@
xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type);
- if (STREQC(dev->type, "sdl"))
- return NULL;
+ if (STREQC(dev->type, "sdl")) {
+ if (dev->dev.sdl.display) {
+ xmlNewProp(tmp, BAD_CAST "display",
+ BAD_CAST dev->dev.sdl.display);
+ }
+ if (dev->dev.sdl.xauth) {
+ xmlNewProp(tmp, BAD_CAST "xauth",
+ BAD_CAST dev->dev.sdl.xauth);
+ }
+ if (dev->dev.sdl.fullscreen) {
+ xmlNewProp(tmp, BAD_CAST "fullscreen",
+ BAD_CAST dev->dev.sdl.fullscreen);
+ }
+ return NULL;
+ }
if (dev->dev.vnc.port) {
xmlNewProp(tmp, BAD_CAST "port", BAD_CAST
dev->dev.vnc.port);
diff -r 0c52e4f6c421 -r 4c47a4b500e8
schema/ResourceAllocationSettingData.mof
--- a/schema/ResourceAllocationSettingData.mof Wed Jul 20 18:03:54 2011
+0800
+++ b/schema/ResourceAllocationSettingData.mof Wed Jul 20 19:37:05 2011
+0800
@@ -219,7 +219,9 @@
[Description ("If ResourceSubType is 'vnc', this is a VNC Address. "
"IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If
ResourceSubType "
"is 'console', this is a character device path in "
- "path:port format (e.g., '/dev/pts/3:0'\)")]
+ "path:port format (e.g., '/dev/pts/3:0'\) "
+ "if ResourceSubType is 'sdl', this is a combination of its
params as "
+ "xauth:display (e.g., '/root/.Xauthority::0'\)")]
string Address;
[Description ("Keyboard keymapping")]
@@ -228,7 +230,8 @@
[Description ("VNC password")]
string Password;
- [Description ("Is IPv6 only addressing is to be used")]
+ [Description ("Is IPv6 only addressing is to be used."
+ "if ResourceSubType is 'sdl', this means whether sdl is fullscreen")]
boolean IsIPv6Only;
};
diff -r 0c52e4f6c421 -r 4c47a4b500e8
src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Wed Jul 20 18:03:54 2011
+0800
+++ b/src/Virt_VirtualSystemManagementService.c Wed Jul 20 19:37:05 2011
+0800
@@ -1059,6 +1059,52 @@
return ret;
}
+static int parse_sdl_address(const char *id,
+ char **display,
+ char **xauth)
+{
+ int ret;
+ char *tmp_display = NULL;
+ char *tmp_xauth = NULL;
+
+ CU_DEBUG("Entering parse_sdl_address, address is %s", id);
+
+ ret = sscanf(id, "%a[^:]:%as", &tmp_xauth, &tmp_display);
+
+ if (ret <= 0) {
+ ret = sscanf(id, ":%as", &tmp_display);
+ if (ret <= 0) {
+ if (STREQC(id, ":")) {
+ /* do nothing, it is empty */
+ }
+ else {
+ ret = 0;
+ goto out;
+ }
+ }
+ }
+
+ if (display) {
+ if (tmp_display == NULL)
+ *display = NULL;
+ else
+ *display = strdup(tmp_display);
+ }
+ if (xauth) {
+ if (tmp_xauth == NULL)
+ *xauth = NULL;
+ else
+ *xauth = strdup(tmp_xauth);
+ }
+ ret = 1;
+
+ out:
+ CU_DEBUG("Exiting parse_sdl_address, display is %s, xauth is %s",
+ *display, *xauth);
+
+ return ret;
+}
+
static int parse_vnc_address(const char *id,
char **ip,
char **port)
@@ -1162,6 +1208,30 @@
msg = "GraphicsRASD field Address not valid";
goto out;
}
+ }
+ else if (STREQC(dev->dev.graphics.type, "sdl")) {
+ if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) {
+ CU_DEBUG("sdl graphics Address empty, using
default");
+ dev->dev.graphics.dev.sdl.display = NULL;
+ dev->dev.graphics.dev.sdl.xauth = NULL;
+ }
+ else {
+ ret = parse_sdl_address(val,
+
&dev->dev.graphics.dev.sdl.display,
+ &dev->dev.graphics.dev.sdl.xauth);
+ if (ret != 1) {
+ msg = "GraphicsRASD sdl Address not
valid";
+ goto out;
+ }
+ }
+ dev->dev.graphics.dev.sdl.fullscreen = NULL;
+ if (cu_get_bool_prop(inst, "IsIPV6Only", &ipv6) ==
+ CMPI_RC_OK) {
+ if (ipv6)
+
dev->dev.graphics.dev.sdl.fullscreen = strdup("yes");
+ else
+
dev->dev.graphics.dev.sdl.fullscreen = strdup("no");
+ }
} else {
CU_DEBUG("Unsupported graphics type %s",
dev->dev.graphics.type);
@@ -1170,7 +1240,8 @@
}
free(dev->id);
- if (STREQC(dev->dev.graphics.type, "vnc"))
+ if ((STREQC(dev->dev.graphics.type, "vnc"))||
+ (STREQC(dev->dev.graphics.type, "sdl")))
ret = asprintf(&dev->id, "%s", dev->dev.graphics.type);
else
ret = asprintf(&dev->id, "%s:%s",
13 years, 4 months
Patch(es) for Virt_SettingsDefineCapabilities: incorrect Default ValueRole, strstr() misuse
by Gareth S Bestor
Please find below a patch to Virt_SettingsDefineCapabilities.c to fix a
couple issues I found:
- The CIM_AllocationCapabilities for 'Default' RASDs have the incorrect
ValueRole. per DSP1043 "Allocation Capabilities Profile", Section 10.5
"CIM_SettingsDefineCapabilities – Default" the ValueRole should be 0
("Default")
- Fixed mistake with usage of strstr() swapping the arguments; should be:
char *strstr(const char *haystack, const char *needle);
This may not have mattered before when both strings were always exactly
same or didnt match, but now for new 'Point' instances the instanceid has
a prefix. [Thnx Sharad for catching this]
Please excuse the fact the patch is not in the correct format - I am still
setting up my mercurial to correctly format and post patches, thnx.
# User Dr. Gareth S. Bestor <bestor(a)us.ibm.com>
#
diff -r 395f2d684c10 src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c Tue Jul 05 15:52:31 2011
-0300
+++ b/src/Virt_SettingsDefineCapabilities.c Mon Jul 18 04:11:35 2011
-0700
@@ -2054,20 +2188,21 @@
goto out;
}
- if (strstr("Default", iid) != NULL)
+ if (strstr(iid, "Default") != NULL) {
valuerange = SDC_RANGE_POINT;
- else if (strstr("Increment", iid) != NULL)
+ valuerole = SDC_ROLE_DEFAULT;
+ }
+ else if (strstr(iid, "Point") != NULL)
+ valuerange = SDC_RANGE_POINT;
+ else if (strstr(iid, "Increment") != NULL)
valuerange = SDC_RANGE_INC;
- else if (strstr("Maximum", iid) != NULL)
+ else if (strstr(iid, "Maximum") != NULL)
valuerange = SDC_RANGE_MAX;
- else if (strstr("Minimum", iid) != NULL)
+ else if (strstr(iid, "Minimum") != NULL)
valuerange = SDC_RANGE_MIN;
else
CU_DEBUG("Unknown default RASD type: `%s'", iid);
- if (valuerange == SDC_RANGE_POINT)
- valuerole = SDC_ROLE_DEFAULT;
-
CMSetProperty(ref_inst, "ValueRole",
(CMPIValue *)&valuerole, CMPI_uint16);
CMSetProperty(ref_inst, "ValueRange",
Dr. Gareth S. Bestor
IBM Senior Software Engineer
Systems & Technology Group - Systems Management Standards
971-285-6375 (mobile)
bestor(a)us.ibm.com
13 years, 5 months
[PATCH] libxkutil: Handle vnc password when retrieving domain XML
by Eduardo Lima (Etrunko)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1310998420 10800
# Node ID 3c90a88a5199a4ed931a4a76097cff8f55deae41
# Parent 3ac0556ffdf12015839ebafe035547cea5b715f5
libxkutil: Handle vnc password when retrieving domain XML
Whenever a call for ModifyResourceSettings was issued, the XML for the
domain was requested, parsed, the property had its value changed and then
XML was updated with the new value.
It occurs that we need to specify the VIR_DOMAIN_XML_SECURE flag to retrieve
full domain info, including sensitive fields, such as passwords. This patch
fixes the problem for vnc password, which was not handled in the XML parsing
code.
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -525,6 +525,7 @@
gdev->port = get_attr_value(node, "port");
gdev->host = get_attr_value(node, "listen");
gdev->keymap = get_attr_value(node, "keymap");
+ gdev->passwd = get_attr_value(node, "passwd");
if (gdev->port == NULL || gdev->host == NULL)
goto err;
@@ -1127,7 +1128,7 @@
char *xml;
int ret;
int start;
- xml = virDomainGetXMLDesc(dom, 0);
+ xml = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_SECURE);
if (xml == NULL)
return 0;
13 years, 5 months