[PATCH] Redirect stdout & stderr when run as out-of-process provider
by Chip Vincent
# HG changeset patch
# User Chip Vincent <cvincent(a)us.ibm.com>
# Date 1316557881 14400
# Node ID 4d95f2e9f2d8eac1565307def96bd158f5dcf160
# Parent db809376d763493849c2a19f587969eaec619b75
Redirect stdout & stderr when run as out-of-process provider
When a provider is loaded in-process by Pegasus, messages sent to
stdout and stderr are suppressed. However, when loaded out-of-process,
those same messages appear on the console. This happens excessively when
libvirt-cim LXC_ and XEN_ classes are enumerated and libvirt sends
"libvir: error : no connection driver available for..." messages to stderr.
In development, this can sometimes prevent console usage. Until a fix is
made to Pegasus, we'll suppress console output during provider initialization
when run in out-of-process mode.
Signed-off-by: Chip Vincent <cvincent(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
@@ -29,6 +29,7 @@
#include <stdarg.h>
#include <unistd.h>
#include <pthread.h>
+#include <errno.h>
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
@@ -540,6 +541,17 @@
{
int ret = 0;
+ /* The tog-pegasus out-of-process provider feature does not
+ * redirect stdout and stderr, so it's done here to prevent
+ * any messages from taking over the console. One example is
+ * verbose connection failures sent to stdout by libvirt. */
+ if (strstr(program_invocation_short_name, "cimprovagt") != NULL) {
+ CU_DEBUG("Redirecting stdout and stderr");
+
+ stdout = freopen("/dev/null", "a", stdout);
+ stderr = freopen("/dev/null", "a", stderr);
+ }
+
/* double-check lock pattern used for performance reasons */
if (libvirt_initialized == 0) {
pthread_mutex_lock(&libvirt_mutex);
12 years, 11 months
[PATCH] (#2) Return migration job status in CIM_ConcreteJob.ErrorCode
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1316721127 25200
# Node ID 859a175208e057acfe6980332abbfa8ca6075f67
# Parent db809376d763493849c2a19f587969eaec619b75
(#2) Return migration job status in CIM_ConcreteJob.ErrorCode
This patch returns migration job status using the ErrorCode
property. A successful migration returns 0 and a non-zero
value is returned on failed migration.
#2: Changed success return from CMPI_RC_OK to 0.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r db809376d763 -r 859a175208e0 src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Thu Jul 28 13:56:00 2011 -0300
+++ b/src/Virt_VSMigrationService.c Thu Sep 22 12:52:07 2011 -0700
@@ -930,6 +930,7 @@
static void migrate_job_set_state(struct migration_job *job,
uint16_t state,
+ int error_code,
const char *status)
{
CMPIInstance *inst;
@@ -953,10 +954,13 @@
CMSetProperty(inst, "JobState",
(CMPIValue *)&state, CMPI_uint16);
+ CMSetProperty(inst, "ErrorCode",
+ (CMPIValue *)&error_code, CMPI_uint16);
CMSetProperty(inst, "Status",
(CMPIValue *)status, CMPI_chars);
- CU_DEBUG("Modifying job %s (%i:%s)", job->uuid, state, status);
+ CU_DEBUG("Modifying job %s (%i:%s) Error Code is %i",
+ job->uuid, state, status, error_code);
s = CBModifyInstance(_BROKER, job->context, op, inst, NULL);
if (s.rc != CMPI_RC_OK)
@@ -1279,7 +1283,7 @@
CBAttachThread(_BROKER, job->context);
CU_DEBUG("Migration Job %s started", job->uuid);
- migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, "Running");
+ migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, 0, "Running");
s = migrate_vs(job);
@@ -1287,10 +1291,12 @@
if (s.rc != CMPI_RC_OK)
migrate_job_set_state(job,
CIM_JOBSTATE_COMPLETE,
+ s.rc,
CMGetCharPtr(s.msg));
else
migrate_job_set_state(job,
CIM_JOBSTATE_COMPLETE,
+ 0,
"Completed");
raise_deleted_ind(job);
12 years, 11 months
[PATCH] Return migration job status in CIM_ConcreteJob.ErrorCode
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1316716303 25200
# Node ID 5a025903b3dec8d8d5f35e7117be67f095d5fe21
# Parent fb09136deb494008eb3aacee420ad74da7d7c294
Return migration job status in CIM_ConcreteJob.ErrorCode
This patch returns migration job status using the ErrorCode
property. A successful migration returns 0 and a non-zero
value is returned on failed migration.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r fb09136deb49 -r 5a025903b3de src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Tue Aug 30 08:48:36 2011 -0700
+++ b/src/Virt_VSMigrationService.c Thu Sep 22 11:31:43 2011 -0700
@@ -930,6 +930,7 @@
static void migrate_job_set_state(struct migration_job *job,
uint16_t state,
+ int error_code,
const char *status)
{
CMPIInstance *inst;
@@ -953,10 +954,13 @@
CMSetProperty(inst, "JobState",
(CMPIValue *)&state, CMPI_uint16);
+ CMSetProperty(inst, "ErrorCode",
+ (CMPIValue *)&error_code, CMPI_uint16);
CMSetProperty(inst, "Status",
(CMPIValue *)status, CMPI_chars);
- CU_DEBUG("Modifying job %s (%i:%s)", job->uuid, state, status);
+ CU_DEBUG("Modifying job %s (%i:%s) Error Code is %i",
+ job->uuid, state, status, error_code);
s = CBModifyInstance(_BROKER, job->context, op, inst, NULL);
if (s.rc != CMPI_RC_OK)
@@ -1279,7 +1283,7 @@
CBAttachThread(_BROKER, job->context);
CU_DEBUG("Migration Job %s started", job->uuid);
- migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, "Running");
+ migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, 0, "Running");
s = migrate_vs(job);
@@ -1287,10 +1291,12 @@
if (s.rc != CMPI_RC_OK)
migrate_job_set_state(job,
CIM_JOBSTATE_COMPLETE,
+ s.rc,
CMGetCharPtr(s.msg));
else
migrate_job_set_state(job,
CIM_JOBSTATE_COMPLETE,
+ s.rc,
"Completed");
raise_deleted_ind(job);
12 years, 11 months
libvirt-cim migrating to git
by Chip Vincent
libvirt-cim community,
We'll be migrating the libvirt-cim source tree from hg to git in the
very near future. Once complete, we'll keep the hg tree up for a while,
but updates will only be made to the git tree. The intention of this
migration is simply to be more consistent with other projects many of us
work on, which, of course, uses git.
I'm in the process now of doing some test migrations locally to ensure
the tools work properly. If everything goes well, I hope everything up
and running on libvirt.org sometime next week. I'll send a note to the
once the docs are updated and the git tree is accessible, and another
down the road sunsetting the hg tree.
--
Chip Vincent
Open Virtualization
IBM Linux Technology Center
cvincent(a)linux.vnet.ibm.com
12 years, 11 months
[PATCH] VirtualSystemManagementService: Always update domain device information
by Eduardo Lima (Etrunko)
src/Virt_VirtualSystemManagementService.c | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1316551891 10800
# Node ID 25c6de6ebf094bf602e95ddf01dd39a6c5c1804a
# Parent 9a59a56e226f3f800ff7214b81ab5f2fe6362fcc
VirtualSystemManagementService: Always update domain device information
I noticed that a call to ModifyResourceSettings was causing devices description
to be lost. It happens that there was an explicit check in the code that
resulted in the device information to be updated only if the specified domain
was running.
This patch removes that block and now the resulting domain xml after the
ModifyResourceSettings call will keep the device information.
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
@@ -2349,15 +2349,6 @@
update_dominfo(dominfo, refcn);
- if (!domain_online(dom)) {
- CU_DEBUG("VS `%s' not online; skipping dynamic update",
- dominfo->name);
- cu_statusf(_BROKER, &s,
- CMPI_RC_OK,
- "");
- goto out;
- }
-
CU_DEBUG("Doing dynamic device update for `%s'", dominfo->name);
if (func(dom, dev) == 0) {
12 years, 11 months
[PATCH] Fix the problem that libvirt-cim can't find cdrom device that do not have disk
by Wayne Xia
# HG changeset patch
# User Wayne Xia <xiawenc(a)linux.vnet.ibm.com>
# Date 1316154275 -28800
# Node ID 04b73e1cdc3087a390b9790c13b42ebacbc5d5ba
# Parent fb09136deb494008eb3aacee420ad74da7d7c294
Fix the problem that libvirt-cim can't find cdrom device that do not have disk
This patch would allow define a system with a empty CDROM device, and allow method modify
resource settings to insert ISO files into an empty CDROM device.
Examples:
InvokeMethod(ModifyResourceSettings):
ResourceSettings: ['instance of KVM_DiskResourceAllocationSettingData {\nResourceType = 17;\nInstanceID = "test/hdc";\nEmulatedType = 1;\nVirtualDevice = "hdc";\nAddress = "";\n};']
InvokeMethod(ModifyResourceSettings):
ResourceSettings: ['instance of KVM_DiskResourceAllocationSettingData {\nResourceType = 17;\nInstanceID = "test/hdc";\nEmulatedType = 1;\nVirtualDevice = "hdc";\nAddress = "/var/lib/libvirt/images/test-disk.iso";\n};']
Note that the Address property should be set to "", not None(not set), to tell that user want
an ejection.
Signed-off-by: Wayne Xia <xiawenc(a)linux.vnet.ibm.com>
diff -r fb09136deb49 -r 04b73e1cdc30 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Tue Aug 30 08:48:36 2011 -0700
+++ b/libxkutil/device_parsing.c Fri Sep 16 14:24:35 2011 +0800
@@ -287,6 +287,12 @@
ddev->shareable = true;
}
}
+
+ if ((XSTREQ(ddev->device, "cdrom")) && (ddev->source == NULL)) {
+ ddev->source = strdup("");
+ ddev->disk_type = DISK_FILE;
+ }
+
if ((ddev->source == NULL) || (ddev->virtual_dev == NULL))
goto err;
diff -r fb09136deb49 -r 04b73e1cdc30 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Tue Aug 30 08:48:36 2011 -0700
+++ b/libxkutil/xmlgen.c Fri Sep 16 14:24:35 2011 +0800
@@ -110,10 +110,15 @@
xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST dev->cache);
}
- tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL);
- if (tmp == NULL)
- return XML_ERROR;
- xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source);
+ if ((XSTREQ(dev->device, "cdrom")) &&
+ (XSTREQ(dev->source, ""))) {
+ /* do nothing */
+ } else {
+ tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source);
+ }
tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL);
if (tmp == NULL)
diff -r fb09136deb49 -r 04b73e1cdc30 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Tue Aug 30 08:48:36 2011 -0700
+++ b/src/Virt_VirtualSystemManagementService.c Fri Sep 16 14:24:35 2011 +0800
@@ -879,6 +879,12 @@
dev->dev.disk.device = strdup("disk");
else if (type == VIRT_DISK_TYPE_CDROM) {
dev->dev.disk.device = strdup("cdrom");
+ if ((XSTREQ(dev->dev.disk.source, "/dev/null")) ||
+ (XSTREQ(dev->dev.disk.source, ""))) {
+ dev->dev.disk.disk_type = DISK_FILE;
+ free(dev->dev.disk.source);
+ dev->dev.disk.source = strdup("");
+ }
if (dev->dev.disk.disk_type == DISK_UNKNOWN)
dev->dev.disk.disk_type = DISK_PHY;
}
12 years, 11 months
[PATCH]
by Wayne Xia
# HG changeset patch
# User Wayne Xia <xiawenc(a)linux.vnet.ibm.com>
# Date 1316154275 -28800
# Node ID c30c9a42eb741aacbd00bf4f67775ea1542978f5
# Parent db809376d763493849c2a19f587969eaec619b75
#2 Fix the problem that libvirt-cim can't find cdrom device that do not have disk
This patch would allow define a system with an empty CDROM device, and allow method modify
resource settings to insert ISO files into an empty CDROM device.
Examples:
InvokeMethod(ModifyResourceSettings):
ResourceSettings: ['instance of KVM_DiskResourceAllocationSettingData {\nResourceType = 17;\nInstanceID = "test/hdc";\nEmulatedType = 1;\nVirtualDevice = "hdc";\nAddress = "";\n};']
InvokeMethod(ModifyResourceSettings):
ResourceSettings: ['instance of KVM_DiskResourceAllocationSettingData {\nResourceType = 17;\nInstanceID = "test/hdc";\nEmulatedType = 1;\nVirtualDevice = "hdc";\nAddress = "/var/lib/libvirt/images/test-disk.iso";\n};']
Note that the Address property should be set to "", not None(not set), to tell that user want
an ejection.
#2 Add comments that saying what the code does, and improved some codes to avoid doing duplicated things.
Signed-off-by: Wayne Xia <xiawenc(a)linux.vnet.ibm.com>
diff -r db809376d763 -r c30c9a42eb74 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Thu Jul 28 13:56:00 2011 -0300
+++ b/libxkutil/device_parsing.c Fri Sep 16 14:24:35 2011 +0800
@@ -287,6 +287,13 @@
ddev->shareable = true;
}
}
+
+ /* handle the situation that a cdrom device have no disk in it, no ISO file */
+ if ((XSTREQ(ddev->device, "cdrom")) && (ddev->source == NULL)) {
+ ddev->source = strdup("");
+ ddev->disk_type = DISK_FILE;
+ }
+
if ((ddev->source == NULL) || (ddev->virtual_dev == NULL))
goto err;
diff -r db809376d763 -r c30c9a42eb74 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Thu Jul 28 13:56:00 2011 -0300
+++ b/libxkutil/xmlgen.c Fri Sep 16 14:24:35 2011 +0800
@@ -110,10 +110,18 @@
xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST dev->cache);
}
- tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL);
- if (tmp == NULL)
- return XML_ERROR;
- xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source);
+ if ((XSTREQ(dev->device, "cdrom")) &&
+ (XSTREQ(dev->source, ""))) {
+ /* This is the situation that user defined a cdrom device without
+ disk in it, so skip generating a line saying "source", for that
+ xml defination for libvirt should not have this defined in this
+ situation. */
+ } else {
+ tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source);
+ }
tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL);
if (tmp == NULL)
diff -r db809376d763 -r c30c9a42eb74 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Thu Jul 28 13:56:00 2011 -0300
+++ b/src/Virt_VirtualSystemManagementService.c Fri Sep 16 14:24:35 2011 +0800
@@ -879,6 +879,17 @@
dev->dev.disk.device = strdup("disk");
else if (type == VIRT_DISK_TYPE_CDROM) {
dev->dev.disk.device = strdup("cdrom");
+ /* following code is for the case that user defined cdrom device
+ without disk in it, or a empty disk "" */
+ if (XSTREQ(dev->dev.disk.source, "")) {
+ dev->dev.disk.disk_type = DISK_FILE;
+ }
+ if (XSTREQ(dev->dev.disk.source, "/dev/null")) {
+ dev->dev.disk.disk_type = DISK_FILE;
+ free(dev->dev.disk.source);
+ dev->dev.disk.source = strdup("");
+ }
+
if (dev->dev.disk.disk_type == DISK_UNKNOWN)
dev->dev.disk.disk_type = DISK_PHY;
}
12 years, 11 months
[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);
12 years, 11 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
12 years, 12 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