[PATCH] ACL: Add 'Action' property to KVM_{IPHeaders, Hdr8021}Filter
by Eduardo Lima (Etrunko)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1311872160 10800
# Node ID 4d837e60bb82daa73bba8e13bbab9041fc7632ee
# Parent 277b56b3863b5f81a3faa18aeb7b9951b963b489
ACL: Add 'Action' property to KVM_{IPHeaders,Hdr8021}Filter
This property should be defined in the CIM_FilterEntryBase parent class
(would also apply to 'Direction' and 'Priority' properties), considering
the fact that, according to libvirt documentation, the 'action' attribute
of a rule is mandatory. For reference please check:
http://libvirt.org/formatnwfilter.html#nwfelemsRules
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
diff --git a/schema/FilterEntry.mof b/schema/FilterEntry.mof
--- a/schema/FilterEntry.mof
+++ b/schema/FilterEntry.mof
@@ -2,6 +2,14 @@
[Provider("cmpi::Virt_FilterEntry")]
class KVM_Hdr8021Filter : CIM_Hdr8021Filter
{
+ [Description (
+ "This defines whether the action should be to forward or "
+ "deny traffic meeting the match condition specified in "
+ "this filter." ),
+ ValueMap { "1", "2" },
+ Values { "Permit", "Deny" }]
+ uint16 Action;
+
[Description("This defines whether the Filter is used for input, "
"output, or both input and output filtering. All values are "
"used with respect to the interface for which the Filter "
@@ -32,6 +40,14 @@
[Provider("cmpi::Virt_FilterEntry")]
class KVM_IPHeadersFilter : CIM_IPHeadersFilter
{
+ [Description (
+ "This defines whether the action should be to forward or "
+ "deny traffic meeting the match condition specified in "
+ "this filter." ),
+ ValueMap { "1", "2" },
+ Values { "Permit", "Deny" }]
+ uint16 Action;
+
[Description("This defines whether the Filter is used for input, "
"output, or both input and output filtering. All values are "
"used with respect to the interface for which the Filter "
diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c
--- a/src/Virt_FilterEntry.c
+++ b/src/Virt_FilterEntry.c
@@ -159,6 +159,19 @@
return priority;
}
+static int convert_action(const char *s)
+{
+ enum {NONE=0, ACCEPT, DENY} action = NONE;
+
+ if (s != NULL) {
+ if (STREQC(s, "accept"))
+ action = ACCEPT;
+ else if (STREQC(s, "drop") || STREQC(s, "reject"))
+ action = DENY;
+ }
+ return action;
+}
+
static CMPIInstance *convert_mac_rule_to_instance(
struct acl_rule *rule,
const CMPIBroker *broker,
@@ -169,7 +182,7 @@
CMPIInstance *inst = NULL;
const char *sys_name = NULL;
const char *sys_ccname = NULL;
- int direction, priority = 0;
+ int action, direction, priority = 0;
unsigned int bytes[48];
unsigned int size = 0;
CMPIArray *array = NULL;
@@ -203,6 +216,9 @@
CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars);
CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars);
+ action = convert_action(rule->action);
+ CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16);
+
direction = convert_direction(rule->direction);
CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16);
@@ -259,7 +275,7 @@
CMPIInstance *inst = NULL;
const char *sys_name = NULL;
const char *sys_ccname = NULL;
- int direction, priority = 0;
+ int action, direction, priority = 0;
unsigned int bytes[48];
unsigned int size = 0;
unsigned int n = 0;
@@ -293,6 +309,9 @@
CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars);
CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars);
+ action = convert_action(rule->action);
+ CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16);
+
direction = convert_direction(rule->direction);
CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16);
13 years, 3 months
Better to Add Code to check "End of line" character in schema file
by Wayne Xia
When I try add new class to libvirt-cim, I found that if the "end of
line" character use the windows format(\t\n), then the rpm making would
succeed, but the pegasus would not find the correct .so file, indeed
pegasus seems to linked to a wrong file.
It takes me a long time to find the reason, so I think it is better to
add some scripts to check this, or show a warning for it.
--
Best Regards
Wayne Xia
mail:xiawenc@linux.vnet.ibm.com
tel:86-010-82450803
13 years, 3 months
[PATCH] VirtualSystemManagementService: Fix yet another possible leak
by Eduardo Lima (Etrunko)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1314112289 10800
# Node ID 277b56b3863b5f81a3faa18aeb7b9951b963b489
# Parent a346baf140d64177a9dc1066677c307ee6518236
VirtualSystemManagementService: Fix yet another possible leak
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -1377,7 +1377,11 @@
if (tmp == NULL)
return false;
- memcpy(tmp, *list, sizeof(*tmp) * cur);
+ if (*list) {
+ memcpy(tmp, *list, sizeof(*tmp) * cur);
+ free(*list);
+ }
+
*list = tmp;
return true;
13 years, 3 months
[PATCH] (#2) Workaround to fix race condition around libvirt init
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1314719316 25200
# Node ID c54aafd0b2c6414f91b96bc30e2f148bb78d5c59
# Parent 277b56b3863b5f81a3faa18aeb7b9951b963b489
(#2) Workaround to fix race condition around libvirt init.
This patch fixes the race condition caused when mutiple
threads try to start VMs at the same time. This patch
also fixes the issue of incorrect mem allocation for
VSSD property - emulator.
#2: included Edurdo's patch for make_space
took care of coding guidelines.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c
--- a/libxkutil/misc_util.c
+++ b/libxkutil/misc_util.c
@@ -28,6 +28,7 @@
#include <stdbool.h>
#include <stdarg.h>
#include <unistd.h>
+#include <pthread.h>
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
@@ -45,6 +46,9 @@
#include "misc_util.h"
#include "cs_util.h"
+static pthread_mutex_t libvirt_mutex = PTHREAD_MUTEX_INITIALIZER;
+/* libvirt library not initialized */
+static int libvirt_initialized = 0;
#define URI_ENV "HYPURI"
@@ -114,11 +118,15 @@
CU_DEBUG("Connecting to libvirt with uri `%s'", uri);
+ pthread_mutex_lock(&libvirt_mutex);
+
if (is_read_only())
conn = virConnectOpenReadOnly(uri);
else
conn = virConnectOpen(uri);
+ pthread_mutex_unlock(&libvirt_mutex);
+
if (!conn) {
CU_DEBUG("Unable to connect to `%s'", uri);
return NULL;
@@ -530,7 +538,19 @@
bool libvirt_cim_init(void)
{
- return virInitialize() == 0;
+ int ret = 0;
+
+ /* double-check lock pattern used for performance reasons */
+ if (libvirt_initialized == 0) {
+ pthread_mutex_lock(&libvirt_mutex);
+ if (libvirt_initialized == 0) {
+ ret = virInitialize();
+ if (ret == 0)
+ libvirt_initialized = 1;
+ }
+ pthread_mutex_unlock(&libvirt_mutex);
+ }
+ return (ret == 0);
}
bool check_refs_pfx_match(const CMPIObjectPath *refa,
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -188,6 +188,24 @@
return 1;
}
+static bool make_space(struct virt_device **list, int cur, int new)
+{
+ struct virt_device *tmp;
+
+ tmp = calloc(cur + new, sizeof(*tmp));
+ if (tmp == NULL)
+ return false;
+
+ if (*list) {
+ memcpy(tmp, *list, sizeof(*tmp) * cur);
+ free(*list);
+ }
+
+ *list = tmp;
+
+ return true;
+}
+
static bool fv_set_emulator(struct domain *domain,
const char *emu)
{
@@ -198,6 +216,11 @@
if (emu == NULL)
return true;
+ if (!make_space(&domain->dev_emu, 0, 1)) {
+ CU_DEBUG("Failed to alloc disk list");
+ return false;
+ }
+
cleanup_virt_device(domain->dev_emu);
domain->dev_emu->type = CIM_RES_TYPE_EMU;
@@ -1369,24 +1392,6 @@
return msg;
}
-static bool make_space(struct virt_device **list, int cur, int new)
-{
- struct virt_device *tmp;
-
- tmp = calloc(cur + new, sizeof(*tmp));
- if (tmp == NULL)
- return false;
-
- if (*list) {
- memcpy(tmp, *list, sizeof(*tmp) * cur);
- free(*list);
- }
-
- *list = tmp;
-
- return true;
-}
-
static char *add_device_nodup(struct virt_device *dev,
struct virt_device *list,
int max,
13 years, 3 months
[PATCH] DO NOT PUSH UPSTREAM
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1314380301 25200
# Node ID 73e7bb11410f3c10d3b0b61678531314262f09b7
# Parent 2984ede9c082bab48b3494ef4b9f5561fadef2ad
DO NOT PUSH UPSTREAM
This is the workaround that was given to zGryphon
team to prevent unloading of idle providers.
There is a bug in libvirt that needs to be fixed.
That fix will be the actual fix for this problem
that cause segfault when those providers are unloaded
that make a call to virConnectOpen.
This patch is being put on mailing list just for
archiving reasons. It should not be pushed upstream.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff --git a/libcmpiutil.h b/libcmpiutil.h
--- a/libcmpiutil.h
+++ b/libcmpiutil.h
@@ -508,7 +508,16 @@
static CMPIStatus pn##Cleanup(CMPIInstanceMI *mi, \
const CMPIContext *c, \
CMPIBoolean terminating) \
- { RETURN_UNSUPPORTED(); }
+ { \
+ if (terminating) \
+ { \
+ return (CMPIStatus) {CMPI_RC_OK, NULL}; \
+ } \
+ else \
+ { \
+ return (CMPIStatus) {CMPI_RC_NEVER_UNLOAD, NULL}; \
+ } \
+ }
#define DEFAULT_IND_CLEANUP(pn) \
static CMPIStatus pn##IndicationCleanup(CMPIIndicationMI *mi, \
diff --git a/libcmpiutil.spec.in b/libcmpiutil.spec.in
--- a/libcmpiutil.spec.in
+++ b/libcmpiutil.spec.in
@@ -3,7 +3,7 @@
Summary: CMPI Utility Library
Name: libcmpiutil
Version: @PACKAGE_VERSION@
-Release: 1%{?dist}%{?extra_release}
+Release: 2%{?dist}%{?extra_release}
License: LGPLv2+
Group: System Environment/Libraries
Source: libcmpiutil-%{version}.tar.gz
13 years, 3 months
[PATCH] Workaround to fix race condition around libvirt init
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1314379933 25200
# Node ID a42b68361ed9cb4f7d6f15de5b58ccc68e88ef38
# Parent a346baf140d64177a9dc1066677c307ee6518236
Workaround to fix race condition around libvirt init.
This patch fixes the race condition caused when mutiple
threads try to start a VM. This patch also fixes the issue
of incorrect mem allocation for VSSD property - emulator.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c
--- a/libxkutil/misc_util.c
+++ b/libxkutil/misc_util.c
@@ -28,6 +28,7 @@
#include <stdbool.h>
#include <stdarg.h>
#include <unistd.h>
+#include <pthread.h>
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
@@ -45,6 +46,9 @@
#include "misc_util.h"
#include "cs_util.h"
+static pthread_mutex_t libvirt_mutex = PTHREAD_MUTEX_INITIALIZER;
+/* libvirt library not initialized */
+static int libvirt_initialized = 0;
#define URI_ENV "HYPURI"
@@ -114,11 +118,15 @@
CU_DEBUG("Connecting to libvirt with uri `%s'", uri);
+ pthread_mutex_lock(&libvirt_mutex);
+
if (is_read_only())
conn = virConnectOpenReadOnly(uri);
else
conn = virConnectOpen(uri);
+ pthread_mutex_unlock(&libvirt_mutex);
+
if (!conn) {
CU_DEBUG("Unable to connect to `%s'", uri);
return NULL;
@@ -530,7 +538,19 @@
bool libvirt_cim_init(void)
{
- return virInitialize() == 0;
+ int ret=0;
+
+ /* double-check lock pattern used for performance reasons */
+ if (0 == libvirt_initialized) {
+ pthread_mutex_lock(&libvirt_mutex);
+ if (0 == libvirt_initialized) {
+ ret = virInitialize();
+ if (ret == 0)
+ libvirt_initialized=1;
+ }
+ pthread_mutex_unlock(&libvirt_mutex);
+ }
+ return (ret == 0);
}
bool check_refs_pfx_match(const CMPIObjectPath *refa,
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -188,6 +188,20 @@
return 1;
}
+static bool make_space(struct virt_device **list, int cur, int new)
+{
+ struct virt_device *tmp;
+
+ tmp = calloc(cur + new, sizeof(*tmp));
+ if (tmp == NULL)
+ return false;
+
+ memcpy(tmp, *list, sizeof(*tmp) * cur);
+ *list = tmp;
+
+ return true;
+}
+
static bool fv_set_emulator(struct domain *domain,
const char *emu)
{
@@ -198,6 +212,11 @@
if (emu == NULL)
return true;
+ if (!make_space(&domain->dev_emu, 0, 1)) {
+ CU_DEBUG("Failed to alloc disk list");
+ return false;
+ }
+
cleanup_virt_device(domain->dev_emu);
domain->dev_emu->type = CIM_RES_TYPE_EMU;
@@ -1369,20 +1388,6 @@
return msg;
}
-static bool make_space(struct virt_device **list, int cur, int new)
-{
- struct virt_device *tmp;
-
- tmp = calloc(cur + new, sizeof(*tmp));
- if (tmp == NULL)
- return false;
-
- memcpy(tmp, *list, sizeof(*tmp) * cur);
- *list = tmp;
-
- return true;
-}
-
static char *add_device_nodup(struct virt_device *dev,
struct virt_device *list,
int max,
13 years, 3 months
[PATCH] (#2) VirtualSystemManagementService: Fixing potential null dereferences
by Eduardo Lima (Etrunko)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1312918075 10800
# Node ID a346baf140d64177a9dc1066677c307ee6518236
# Parent 90ba6e1f899ea3ec47bc175e86bd245983e9375f
VirtualSystemManagementService: Fixing potential null dereferences
As reported in https://bugzilla.redhat.com/show_bug.cgi?id=728245
line 1048 - Comparing "path" to null implies that "path" might be null.
line 1057 - Dereferencing null variable "path".
line 1088 - Comparing "port" to null implies that "port" might be null.
line 1094 - Dereferencing null variable "port".
Changes since #1
- Removed free calls, incorporated at revision 1130.
- Avoid NULL dereference in parse_sdl_address as well.
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -1047,9 +1047,10 @@
ret = 1;
- out:
- CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s",
- *path, *port);
+ out:
+ if (path && port)
+ CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s",
+ *path, *port);
free(tmp_path);
free(tmp_port);
@@ -1097,8 +1098,9 @@
ret = 1;
out:
- CU_DEBUG("Exiting parse_sdl_address, display is %s, xauth is %s",
- *display, *xauth);
+ if (display && xauth)
+ CU_DEBUG("Exiting parse_sdl_address, display is %s, xauth is %s",
+ *display, *xauth);
free(tmp_display);
free(tmp_xauth);
@@ -1137,8 +1139,9 @@
ret = 1;
out:
- CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s",
- *ip, *port);
+ if (ip && port)
+ CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s",
+ *ip, *port);
free(tmp_ip);
free(tmp_port);
13 years, 4 months
[PATCH] device_parsing: Fixing potential leaks
by Eduardo Lima (Etrunko)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1313075262 10800
# Node ID c0f20dbefb8fd73c278a619bbbd2efb567da07d4
# Parent 2b1b79a72ab0288d649399118dffce26fd05e066
device_parsing: Fixing potential leaks
As reported in https://bugzilla.redhat.com/show_bug.cgi?id=728245
line 106 - Function cleanup_virt_device does not free its parameter dev (this
causes a lot of Coverity Resource leak warnings).
In future use cases, please consider using cleanup_virt_devices function
instead of cleanup_virt_device if the virt_device structure is allocated
dynamically.
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
@@ -829,12 +829,10 @@
if (ret <= 0)
return ret;
- mdev = malloc(sizeof(*mdev));
+ mdev = calloc(1, sizeof(*mdev));
if (mdev == NULL)
return 0;
- memset(mdev, 0, sizeof(*mdev));
-
/* We could get one or two memory devices back, depending on
* if there is a currentMemory tag or not. Coalesce these
* into a single device to return
@@ -870,12 +868,10 @@
if (ret <= 0)
return ret;
- proc_dev = malloc(sizeof(*proc_dev));
+ proc_dev = calloc(1, sizeof(*proc_dev));
if (proc_dev == NULL)
return 0;
- memset(proc_dev, 0, sizeof(*proc_dev));
-
proc_dev->type = CIM_RES_TYPE_PROC;
proc_dev->id = strdup("proc");
proc_dev->dev.vcpu.quantity = proc_devs[0].dev.vcpu.quantity;
@@ -1031,8 +1027,6 @@
xmlNode **nodes = nsv->nodeTab;
xmlNode *child;
- memset(dominfo, 0, sizeof(*dominfo));
-
dominfo->typestr = get_attr_value(nodes[0], "type");
for (child = nodes[0]->children; child != NULL; child = child->next) {
@@ -1098,7 +1092,7 @@
int ret;
CU_DEBUG("In get_dominfo_from_xml");
- *dominfo = malloc(sizeof(**dominfo));
+ *dominfo = calloc(1, sizeof(**dominfo));
if (*dominfo == NULL)
return 0;
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -832,7 +832,7 @@
dominfo->dev_input = dev;
break;
default:
- cleanup_virt_device(dev);
+ cleanup_virt_devices(&dev, 1);
goto out;
}
diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c
--- a/src/Virt_AppliedFilterList.c
+++ b/src/Virt_AppliedFilterList.c
@@ -516,7 +516,7 @@
free(net_name);
cleanup_filter(filter);
- cleanup_virt_device(device);
+ cleanup_virt_devices(&device, 1);
virDomainFree(dom);
virConnectClose(conn);
@@ -626,7 +626,7 @@
free(net_name);
cleanup_filter(filter);
- cleanup_virt_device(device);
+ cleanup_virt_devices(&device, 1);
virDomainFree(dom);
virConnectClose(conn);
diff --git a/src/Virt_Device.c b/src/Virt_Device.c
--- a/src/Virt_Device.c
+++ b/src/Virt_Device.c
@@ -700,14 +700,15 @@
}
for (i = 0; i < count; i++) {
- if (STREQC(device, list[i].id))
+ if (STREQC(device, list[i].id)) {
dev = virt_device_dup(&list[i]);
+ break;
+ }
- cleanup_virt_device(&list[i]);
}
+ cleanup_virt_devices(&list, count);
out:
- free(list);
return dev;
}
@@ -785,7 +786,7 @@
&tmp_list);
}
- cleanup_virt_device(dev);
+ cleanup_virt_devices(&dev, 1);
*_inst = tmp_list.list[0];
diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c
--- a/src/Virt_RASD.c
+++ b/src/Virt_RASD.c
@@ -664,7 +664,7 @@
char *host = NULL;
char *devid = NULL;
virConnectPtr conn = NULL;
- struct virt_device *dev;
+ struct virt_device *dev = NULL;
conn = connect_by_classname(broker, CLASSNAME(reference), &s);
if (conn == NULL) {
@@ -700,8 +700,8 @@
"Failed to set instance properties");
else
*_inst = inst;
-
- cleanup_virt_device(dev);
+
+ cleanup_virt_devices(&dev, 1);
out:
virConnectClose(conn);
@@ -863,10 +863,7 @@
tmp_dev->id = strdup("proc");
- for (i = 0; i < count; i++)
- cleanup_virt_device(&devs[i]);
-
- free(devs);
+ cleanup_virt_devices(&devs, count);
devs = tmp_dev;
count = 1;
}
@@ -877,9 +874,6 @@
CMPI_RC_ERR_FAILED,
"Failed to get domain name");
- for (i = 0; i < count; i++)
- cleanup_virt_device(&devs[i]);
-
goto out;
}
@@ -893,12 +887,10 @@
properties);
if (dev)
inst_list_add(list, dev);
-
- cleanup_virt_device(&devs[i]);
}
out:
- free(devs);
+ cleanup_virt_devices(&devs, count);
return s;
}
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -200,12 +200,6 @@
cleanup_virt_device(domain->dev_emu);
- domain->dev_emu = calloc(1, sizeof(*domain->dev_emu));
- if (domain->dev_emu == NULL) {
- CU_DEBUG("Failed to allocate default emulator device");
- return false;
- }
-
domain->dev_emu->type = CIM_RES_TYPE_EMU;
domain->dev_emu->dev.emu.path = strdup(emu);
domain->dev_emu->id = strdup("emulator");
13 years, 4 months
which vols added to storage pool during refresh?
by Gareth S Bestor
We're looking at a problem when we have a libvirt pool defined, below
[root@xnl2192 ~]# virsh pool-dumpxml ScsiPool-host2
<pool type='scsi'>
<name>ScsiPool-host2</name>
<uuid>f2ea1882-881f-9f49-838d-39e070f68002</uuid>
<capacity>136583315456</capacity>
<allocation>136583315456</allocation>
<available>0</available>
<source>
<adapter name='host2'/>
</source>
<target>
<path>/dev/disk/by-id</path>
<permissions>
<mode>0700</mode>
<owner>-1</owner>
<group>-1</group>
</permissions>
</target>
</pool>
As you can see, this pool maps to /dev/disk/by-id. There may be a large
number of actual volume entries in /dev/disk/by-id, however it appears
only a distinct subset of them are actually added into the libvirt pool
when you do a pool-refresh. What does libvirt check when determining
which, and whether or not, to add one of these volume into the vol-list?
In particular, we have a case when one specific volume in /dev/disk/by-id
is *not* added into the pool, and no amount of pool-refresh makes a
difference. We did notice that if you remove all the sym links in
/dev/disk/by-id and do a pool-refresh, that libvirt re-scans the bus,
recreates the links in /dev/disk/by-id, and adds (some of) the volumes
back into the vol-list. But not this one problematic vol, so clearly there
is something about this vol that libvirt doesnt like and why it is
(deliberately?) not added to the pool.
What checks, etc does libvirt make against vols when determining whether
to add them to a pool?
- G
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, 4 months
Patches for Virt_SettingsDefineCapabilities: incorrect Default ValueRole, strstr() misuse
by Gareth S Bestor
# HG changeset patch
# User Gareth S. Bestor <bestor(a)us.ibm.com>
# Date 1313162799 25200
# Node ID 39c85f57c94fa36c681d4e9caa6e14617dcc7e60
# Parent 8b4f6d69f40904ced24f7948f04f89e770e37bce
Patches for Virt_SettingsDefineCapabilities: incorrect Default ValueRole,
strstr() misuse
- 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.
Signed-off-by: Gareth S. Bestor <bestor(a)us.ibm.com>
diff -r 8b4f6d69f409 -r 39c85f57c94f src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c Mon Aug 08 11:40:09 2011
-0700
+++ b/src/Virt_SettingsDefineCapabilities.c Fri Aug 12 08:26:39 2011
-0700
@@ -2054,19 +2054,22 @@
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;
+ else {
+ CU_DEBUG("Unknown RASD type: `%s'", iid);
+ goto out;
+ }
CMSetProperty(ref_inst, "ValueRole",
(CMPIValue *)&valuerole, CMPI_uint16);
13 years, 4 months