[PATCH] Pool names with space do not get parsed properly
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1317836416 25200
# Node ID 8f5d112e4aea945d09c6120c6cea2817592d08aa
# Parent 1f93220799a57477a6b1e04a90e8ffe797d85581
Pool names with space do not get parsed properly.
This patch fixes the issue where a disk pool with space in its
name does not get parsed correctly.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r 1f93220799a5 -r 8f5d112e4aea src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c Fri Sep 16 14:24:35 2011 +0800
+++ b/src/Virt_DevicePool.c Wed Oct 05 10:40:16 2011 -0700
@@ -1281,7 +1281,7 @@
goto out;
}
- ret = sscanf(id, "%*[^/]/%as", &poolid);
+ ret = sscanf(id, "%*[^/]/%a[^\n]", &poolid);
if (ret != 1) {
cu_statusf(broker, &s,
CMPI_RC_ERR_NOT_FOUND,
13 years, 2 months
[PATCH] VirtualSystemManagementService: Avoid extra connection to libvirt
by Eduardo Lima (Etrunko)
src/Virt_VirtualSystemManagementService.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1317242639 10800
# Node ID e02b7fef37d7f1f6a18d68991dc1409eef8905ec
# Parent 942e9fa22bcb2681884cb39e1dcfc459c67ce197
VirtualSystemManagementService: Avoid extra connection to libvirt
Function update_device_info() has been called in after a creating a connection
to libvirt, while the itself creates a new connection. Moving the function call
a few lines above adresses this issue.
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
@@ -2331,6 +2331,8 @@
return s;
}
+ update_dominfo(dominfo, refcn);
+
conn = connect_by_classname(_BROKER, refcn, &s);
if (conn == NULL) {
CU_DEBUG("Failed to connect");
@@ -2347,8 +2349,6 @@
goto out;
}
- update_dominfo(dominfo, refcn);
-
if (!domain_online(dom)) {
CU_DEBUG("VS `%s' not online; skipping dynamic update",
dominfo->name);
13 years, 2 months
Tyrel Datwyler is out of the office.
by Tyrel Datwyler
I will be out of the office starting 10/11/2011 and will not return until
10/17/2011.
During this time I will have limited access to email. In case of urgent
issues please contact my back up David Heller.
13 years, 2 months
[PATCH] (#2) 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 afee8d9b7214884ab74690b3ca9fd3d4f139f455
# 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 afee8d9b7214 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 afee8d9b7214 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 afee8d9b7214 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;
}
13 years, 2 months
[PATCH] device_parsing: Small code cleanup
by Eduardo Lima (Etrunko)
libxkutil/device_parsing.c | 72 ++++++++++++++++++++++++++-------------------
1 files changed, 42 insertions(+), 30 deletions(-)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1317238828 10800
# Node ID 4e1f0b6dc5e512d98b8258c2c68ac5b1f28e83b6
# Parent 2448b5a111e723902603ed5430aa0f0b1972732d
device_parsing: Small code cleanup
Use the specific device parsing function as parameter in do_parse() instead
of checking for the device type in both caller and callee.
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
@@ -49,6 +49,9 @@
#define MAX(a,b) (((a)>(b))?(a):(b))
+/* Device parse function */
+typedef int (*dev_parse_func_t)(xmlNode *, struct virt_device **);
+
static void cleanup_disk_device(struct disk_device *dev)
{
free(dev->type);
@@ -669,32 +672,15 @@
return true;
}
-static int do_parse(xmlNodeSet *nsv, int type, struct virt_device **l)
+
+static int do_parse(xmlNodeSet *nsv, dev_parse_func_t do_real_parse,
+ struct virt_device **l)
{
int devidx;
int lstidx = 0;
int count = 0;
struct virt_device *list = NULL;
xmlNode **dev_nodes = NULL;
- int (*do_real_parse)(xmlNode *, struct virt_device **) = NULL;
-
- /* point to correct parser function according to type */
- if (type == CIM_RES_TYPE_NET)
- do_real_parse = &parse_net_device;
- else if (type == CIM_RES_TYPE_DISK)
- do_real_parse = &parse_disk_device;
- else if (type == CIM_RES_TYPE_PROC)
- do_real_parse = parse_vcpu_device;
- else if (type == CIM_RES_TYPE_EMU)
- do_real_parse = parse_emu_device;
- else if (type == CIM_RES_TYPE_MEM)
- do_real_parse = parse_mem_device;
- else if (type == CIM_RES_TYPE_GRAPHICS)
- do_real_parse = parse_graphics_device;
- else if (type == CIM_RES_TYPE_INPUT)
- do_real_parse = parse_input_device;
- else
- goto out;
if (nsv == NULL)
goto out;
@@ -743,29 +729,55 @@
{
int len = 0;
int count = 0;
+ dev_parse_func_t func = NULL;
- CU_DEBUG("In parse_deviceso - type is %d", type);
xmlDoc *xmldoc;
xmlXPathContext *xpathCtx;
xmlXPathObject *xpathObj;
xmlChar *xpathstr;
- if (type == CIM_RES_TYPE_NET)
+ CU_DEBUG("In parse_devices - type is %d", type);
+
+ switch (type) {
+ case CIM_RES_TYPE_NET:
xpathstr = NET_XPATH;
- else if (type == CIM_RES_TYPE_DISK)
+ func = &parse_net_device;
+ break;
+
+ case CIM_RES_TYPE_DISK:
xpathstr = DISK_XPATH;
- else if (type == CIM_RES_TYPE_PROC)
+ func = &parse_disk_device;
+ break;
+
+ case CIM_RES_TYPE_PROC:
xpathstr = VCPU_XPATH;
- else if (type == CIM_RES_TYPE_EMU)
+ func = &parse_vcpu_device;
+ break;
+
+ case CIM_RES_TYPE_EMU:
xpathstr = EMU_XPATH;
- else if (type == CIM_RES_TYPE_MEM)
+ func = &parse_emu_device;
+ break;
+
+ case CIM_RES_TYPE_MEM:
xpathstr = MEM_XPATH;
- else if (type == CIM_RES_TYPE_GRAPHICS)
+ func = &parse_mem_device;
+ break;
+
+ case CIM_RES_TYPE_GRAPHICS:
xpathstr = GRAPHICS_XPATH;
- else if (type == CIM_RES_TYPE_INPUT)
+ func = &parse_graphics_device;
+ break;
+
+ case CIM_RES_TYPE_INPUT:
xpathstr = INPUT_XPATH;
- else
+ func = &parse_input_device;
+ break;
+
+ default:
+ CU_DEBUG("Unrecognized device type. Returning.");
goto err1;
+ };
len = strlen(xml) + 1;
@@ -780,7 +792,7 @@
== NULL)
goto err3;
- count = do_parse(xpathObj->nodesetval, type, _list);
+ count = do_parse(xpathObj->nodesetval, func, _list);
xmlSetGenericErrorFunc(NULL, NULL);
xmlXPathFreeObject(xpathObj);
13 years, 2 months
[PATCH] device_parsing: Use default values for vnc graphics device
by Eduardo Lima (Etrunko)
libxkutil/device_parsing.c | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1317234028 10800
# Node ID 2313e472149a557143228949878f946278d0dd3a
# Parent adc78792781448aca7a1356bd253cbdd689839cb
device_parsing: Use default values for vnc graphics device
This patch fixes the behavior where libvirt-cim loses the graphics device
description after a call to ModifyResourceSettings method. Actually it has
nothing to do with the fact that the domain is running or not. What happens is
that if somehow we can't read either 'listen' or 'port' attributes, the
function will fail and return immediately, skipping the device inclusion.
The default values are based on the ones found in the default_graphics_device
function in src/Virt_VirtualSystemManagementService.c.
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
@@ -527,6 +527,17 @@
return 0;
}
+static char *get_attr_value_default(xmlNode *node, char *attrname,
+ const char *default_value)
+{
+ char *ret = get_attr_value(node, attrname);
+
+ if (ret == NULL && default_value != NULL)
+ ret = strdup(default_value);
+
+ return ret;
+}
+
static int parse_graphics_device(xmlNode *node, struct virt_device **vdevs)
{
struct virt_device *vdev = NULL;
@@ -547,13 +558,18 @@
CU_DEBUG("graphics device type = %s", gdev->type);
if (STREQC(gdev->type, "vnc")) {
- gdev->dev.vnc.port = get_attr_value(node, "port");
- gdev->dev.vnc.host = get_attr_value(node, "listen");
+ gdev->dev.vnc.port = get_attr_value_default(node, "port",
+ "-1");
+ gdev->dev.vnc.host = get_attr_value_default(node, "listen",
+ "127.0.0.1");
gdev->dev.vnc.keymap = get_attr_value(node, "keymap");
gdev->dev.vnc.passwd = get_attr_value(node, "passwd");
-
- if (gdev->dev.vnc.port == NULL || gdev->dev.vnc.host == NULL)
+
+ if (gdev->dev.vnc.port == NULL || gdev->dev.vnc.host == NULL) {
+ CU_DEBUG("Error vnc port '%p' host '%p'",
+ gdev->dev.vnc.port, gdev->dev.vnc.host);
goto err;
+ }
}
else if (STREQC(gdev->type, "sdl")) {
gdev->dev.sdl.display = get_attr_value(node, "display");
13 years, 2 months