[PATCH] Make xmlgen.c use libxml2 instead of hacking it out manually
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1228236226 28800
# Node ID c34ae7c0ded8870aeba40a0798ac31f1ea2c5bbd
# Parent 6e8a488cf67b47efb618c28aa2a9104d5b0e1b91
Make xmlgen.c use libxml2 instead of hacking it out manually
Now that our XML generation is getting complex enough, I think it's worth
using libxml2 to build a proper DOM tree and XML string.
Note that due to the invasiveness of this patch, it's almost unreadable. It
may be easier to review after it's applied to the tree. Also, it deserves
some serious review and testing for correctness and error-handling abilities.
Comments on this approach are welcome too, of course.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 6e8a488cf67b -r c34ae7c0ded8 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Mon Dec 01 10:00:45 2008 -0800
+++ b/libxkutil/xmlgen.c Tue Dec 02 08:43:46 2008 -0800
@@ -24,6 +24,8 @@
#include <inttypes.h>
#include <uuid/uuid.h>
+#include <libxml/tree.h>
+
#include "xmlgen.h"
#ifndef TEST
@@ -32,487 +34,378 @@
#include "cmpimacs.h"
#endif
-static char *__tag_attr(struct kv *attrs, int count)
+#define XML_ERROR "Failed to allocate XML memory"
+
+typedef const char *(*devfn_t)(xmlNodePtr node, struct domain *dominfo);
+
+static char *disk_block_xml(xmlNodePtr root, struct disk_device *dev)
{
- char *result = strdup("");
- char *new = NULL;
- int i;
- int size = 0;
+ xmlNodePtr disk;
+ xmlNodePtr tmp;
- for (i = 0; i < count; i++) {
- char *tmp;
- int ret;
+ disk = xmlNewChild(root, NULL, BAD_CAST "disk", NULL);
+ if (disk == NULL)
+ return XML_ERROR;
+ xmlNewProp(disk, BAD_CAST "type", BAD_CAST "block");
+ xmlNewProp(disk, BAD_CAST "device", BAD_CAST dev->device);
- ret = asprintf(&new, " %s='%s'",
- attrs[i].key, attrs[i].val);
+ tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST dev->source);
- if (ret == -1)
- goto err;
+ tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST dev->virtual_dev);
- size += strlen(new) + 1;
- tmp = realloc(result, size);
- if (tmp == NULL)
- goto err;
+ if (dev->readonly)
+ xmlNewChild(disk, NULL, BAD_CAST "readonly", NULL);
- result = tmp;
-
- strcat(result, new);
- free(new);
- }
-
- return result;
-
- err:
- free(result);
- return NULL;
-}
-
-static char *tagify(char *tagname, char *content, struct kv *attrs, int count)
-{
- char *result;
- int ret;
- char *opentag;
-
- if (count)
- opentag = __tag_attr(attrs, count);
- else
- opentag = strdup("");
-
- if (content)
- ret = asprintf(&result,
- "<%s%s>%s</%s>",
- tagname, opentag, content, tagname);
- else
- ret = asprintf(&result,
- "<%s%s/>", tagname, opentag);
- if (ret == -1)
- result = NULL;
-
- free(opentag);
-
- return result;
-}
-
-static int astrcat(char **dest, char *source)
-{
- char *tmp;
- int ret;
-
- if (*dest) {
- ret = asprintf(&tmp, "%s%s", *dest, source);
- if (ret == -1)
- return 0;
- } else {
- tmp = strdup(source);
- }
-
- free(*dest);
-
- *dest = tmp;
-
- return 1;
-}
-
-static char *disk_block_xml(struct disk_device *dev)
-{
- char *xml;
- int ret;
-
- ret = asprintf(&xml,
- "<disk type='block' device='%s'>\n"
- " <source dev='%s'/>\n"
- " <target dev='%s'/>\n"
- "%s"
- "%s"
- "</disk>\n",
- dev->device,
- dev->source,
- dev->virtual_dev,
- dev->readonly ? "<readonly/>\n" : "",
- dev->shareable ? "<shareable/>\n" : "");
- if (ret == -1)
- xml = NULL;
-
- return xml;
-}
-
-static char *disk_file_xml(struct disk_device *dev)
-{
- char *xml;
- int ret;
-
- ret = asprintf(&xml,
- "<disk type='file' device='%s'>\n"
- " <source file='%s'/>\n"
- " <target dev='%s'/>\n"
- "%s"
- "%s"
- "</disk>\n",
- dev->device,
- dev->source,
- dev->virtual_dev,
- dev->readonly ? "<readonly/>" : "",
- dev->shareable ? "<shareable/>" : "");
- if (ret == -1)
- xml = NULL;
-
- return xml;
-}
-
-static char *disk_fs_xml(struct disk_device *dev)
-{
- char *xml;
- int ret;
-
- ret = asprintf(&xml,
- "<filesystem type='mount'>\n"
- " <source dir='%s'/>\n"
- " <target dir='%s'/>\n"
- "</filesystem>\n",
- dev->source,
- dev->virtual_dev);
- if (ret == -1)
- xml = NULL;
-
- return xml;
-}
-
-static bool disk_to_xml(char **xml, struct virt_device *dev)
-{
- char *_xml = NULL;
- struct disk_device *disk = &dev->dev.disk;
-
- if (disk->disk_type == DISK_PHY)
- _xml = disk_block_xml(disk);
- else if (disk->disk_type == DISK_FILE)
- /* If it's not a block device, we assume a file,
- which should be a reasonable fail-safe */
- _xml = disk_file_xml(disk);
- else if (disk->disk_type == DISK_FS)
- _xml = disk_fs_xml(disk);
- else
- return false;
-
- astrcat(xml, _xml);
- free(_xml);
-
- return true;
-}
-
-static bool bridge_net_to_xml(char **xml, struct virt_device *dev)
-{
- int ret;
- char *_xml;
- char *script = "vif-bridge";
- struct net_device *net = &dev->dev.net;
-
- if (net->source == NULL)
- ret = asprintf(&_xml,
- "<interface type='%s'>\n"
- " <mac address='%s'/>\n"
- " <script path='%s'/>\n"
- "</interface>\n",
- net->type,
- net->mac,
- script);
- else
- ret = asprintf(&_xml,
- "<interface type='%s'>\n"
- " <source bridge='%s'/>\n"
- " <mac address='%s'/>\n"
- " <script path='%s'/>\n"
- "</interface>\n",
- net->type,
- net->source,
- net->mac,
- script);
-
- if (ret == -1)
- return false;
- else
- astrcat(xml, _xml);
-
- free(_xml);
-
- return true;
-}
-
-static bool network_net_to_xml(char **xml, struct virt_device *dev)
-{
- int ret;
- char *_xml;
- struct net_device *net = &dev->dev.net;
-
- if (net->source == NULL)
- ret = asprintf(&_xml,
- "<interface type='%s'>\n"
- " <mac address='%s'/>\n"
- "</interface>\n",
- net->type,
- net->mac);
- else
- ret = asprintf(&_xml,
- "<interface type='%s'>\n"
- " <mac address='%s'/>\n"
- " <source network='%s'/>\n"
- "</interface>\n",
- net->type,
- net->mac,
- net->source);
- if (ret == -1)
- return false;
- else
- astrcat(xml, _xml);
-
- free(_xml);
-
- return true;
-}
-
-static bool user_net_to_xml(char **xml, struct virt_device *dev)
-{
- int ret;
- char *_xml;
- struct net_device *net = &dev->dev.net;
-
- ret = asprintf(&_xml,
- "<interface type='%s'>\n"
- " <mac address='%s'/>\n"
- "</interface>\n",
- net->type,
- net->mac);
- if (ret == -1)
- return false;
- else
- astrcat(xml, _xml);
-
- free(_xml);
-
- return true;
-}
-
-static bool net_to_xml(char **xml, struct virt_device *dev)
-{
- if (STREQ(dev->dev.net.type, "network"))
- return network_net_to_xml(xml, dev);
- else if (STREQ(dev->dev.net.type, "bridge"))
- return bridge_net_to_xml(xml, dev);
- else if (STREQ(dev->dev.net.type, "user"))
- return user_net_to_xml(xml, dev);
- else
- return false;
-}
-
-static bool vcpu_to_xml(char **xml, struct virt_device *dev)
-{
- int ret;
- char *_xml;
-
- ret = asprintf(&_xml, "<vcpu>%" PRIu64 "</vcpu>\n",
- dev->dev.vcpu.quantity);
- if (ret == -1)
- return false;
- else
- astrcat(xml, _xml);
-
- return true;
-}
-
-static bool mem_to_xml(char **xml, struct virt_device *dev)
-{
- int ret;
- char *_xml;
- struct mem_device *mem = &dev->dev.mem;
-
- ret = asprintf(&_xml,
- "<currentMemory>%" PRIu64 "</currentMemory>\n"
- "<memory>%" PRIu64 "</memory>\n",
- mem->size,
- mem->maxsize);
-
-
- if (ret == -1)
- return false;
- else
- astrcat(xml, _xml);
-
- free(_xml);
-
- return true;
-}
-
-static bool emu_to_xml(char **xml, struct virt_device *dev)
-{
- int ret;
- char *_xml;
- struct emu_device *emu = &dev->dev.emu;
-
- ret = asprintf(&_xml,
- "<emulator>%s</emulator>\n",
- emu->path);
- if (ret == -1)
- return false;
- else
- astrcat(xml, _xml);
-
- free(_xml);
-
- return true;
-}
-
-static bool graphics_to_xml(char **xml, struct virt_device *dev)
-{
- int ret;
- char *_xml;
- struct graphics_device *graphics = &dev->dev.graphics;
-
- ret = asprintf(&_xml,
- "<graphics type='%s' port='%s' "
- "listen='%s' keymap='%s'/>\n",
- graphics->type,
- graphics->port,
- graphics->host != NULL ? graphics->host : "127.0.0.1",
- graphics->keymap != NULL ? graphics->keymap : "en-us");
- if (ret == -1)
- return false;
- else
- astrcat(xml, _xml);
-
- free(_xml);
-
- return true;
-}
-
-static bool input_to_xml(char **xml, struct virt_device *dev)
-{
- int ret;
- char *_xml;
- struct input_device *input = &dev->dev.input;
-
- ret = asprintf(&_xml,
- "<input type='%s' bus='%s'/>\n",
- input->type != NULL ? input->type: "mouse",
- input->bus != NULL ? input->bus : "ps2");
- if (ret == -1)
- return false;
- else
- astrcat(xml, _xml);
-
- free(_xml);
-
- return true;
-}
-
-static bool concat_devxml(char **xml,
- struct virt_device *list,
- int count,
- bool (*func)(char **, struct virt_device *))
-{
- char *_xml = NULL;
- int i;
-
- for (i = 0; i < count; i++) {
- /* Deleted devices are marked as CIM_RES_TYPE_UNKNOWN
- * and should be skipped
- */
- if (list[i].type != CIM_RES_TYPE_UNKNOWN)
- func(&_xml, &list[i]);
- }
-
- if (_xml != NULL)
- astrcat(xml, _xml);
- free(_xml);
-
- return true;
-}
-
-char *device_to_xml(struct virt_device *dev)
-{
- char *xml = NULL;
- int type = dev->type;
- bool (*func)(char **, struct virt_device *);
-
- switch (type) {
- case CIM_RES_TYPE_DISK:
- func = disk_to_xml;
- break;
- case CIM_RES_TYPE_PROC:
- func = vcpu_to_xml;
- break;
- case CIM_RES_TYPE_NET:
- func = net_to_xml;
- break;
- case CIM_RES_TYPE_MEM:
- func = mem_to_xml;
- break;
- case CIM_RES_TYPE_EMU:
- func = emu_to_xml;
- break;
- case CIM_RES_TYPE_GRAPHICS:
- func = graphics_to_xml;
- break;
- case CIM_RES_TYPE_INPUT:
- func = input_to_xml;
- break;
- default:
- return NULL;
- }
-
- if (concat_devxml(&xml, dev, 1, func))
- return xml;
-
- free(xml);
+ if (dev->shareable)
+ xmlNewChild(disk, NULL, BAD_CAST "shareable", NULL);
return NULL;
}
-static char *system_xml(struct domain *domain)
+static const char *disk_file_xml(xmlNodePtr root, struct disk_device *dev)
{
- int ret;
- char *bl = NULL;
- char *bl_args = NULL;
- char *xml;
+ xmlNodePtr disk;
+ xmlNodePtr tmp;
- if (domain->bootloader)
- bl = tagify("bootloader",
- domain->bootloader,
- NULL,
- 0);
- if (domain->bootloader_args)
- bl_args = tagify("bootloader_args",
- domain->bootloader_args,
- NULL,
- 0);
+ disk = xmlNewChild(root, NULL, BAD_CAST "disk", NULL);
+ if (disk == NULL)
+ return XML_ERROR;
+ xmlNewProp(disk, BAD_CAST "type", BAD_CAST "file");
+ xmlNewProp(disk, BAD_CAST "device", BAD_CAST dev->device);
- ret = asprintf(&xml,
- "<name>%s</name>\n"
- "%s\n"
- "%s\n"
- "<on_poweroff>%s</on_poweroff>\n"
- "<on_crash>%s</on_crash>\n",
- domain->name,
- bl ? bl : "",
- bl_args ? bl_args : "",
- vssd_recovery_action_str(domain->on_poweroff),
- vssd_recovery_action_str(domain->on_crash));
- if (ret == -1)
- xml = NULL;
+ tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source);
- free(bl);
- free(bl_args);
+ tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST dev->virtual_dev);
- return xml;
+ if (dev->readonly)
+ xmlNewChild(disk, NULL, BAD_CAST "readonly", NULL);
+
+ if (dev->shareable)
+ xmlNewChild(disk, NULL, BAD_CAST "shareable", NULL);
+
+
+ return NULL;
}
-static char *_xenpv_os_xml(struct domain *domain)
+static const char *disk_fs_xml(xmlNodePtr root, struct disk_device *dev)
+{
+ xmlNodePtr fs;
+ xmlNodePtr tmp;
+
+ fs = xmlNewChild(root, NULL, BAD_CAST "filesystem", NULL);
+ if (fs == NULL)
+ return XML_ERROR;
+
+ tmp = xmlNewChild(fs, NULL, BAD_CAST "source", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "dir", BAD_CAST dev->source);
+
+ tmp = xmlNewChild(fs, NULL, BAD_CAST "target", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "dir", BAD_CAST dev->virtual_dev);
+
+ return NULL;
+}
+
+static const char *disk_xml(xmlNodePtr root, struct domain *dominfo)
+{
+ int i;
+ const char *msg = NULL;;
+
+ for (i = 0; (i < dominfo->dev_disk_ct) && (msg == NULL); i++) {
+ struct disk_device *disk = &dominfo->dev_disk[i].dev.disk;
+ CU_DEBUG("Disk: %i %s %s",
+ disk->disk_type,
+ disk->source,
+ disk->virtual_dev);
+ if (disk->disk_type == DISK_PHY)
+ msg = disk_block_xml(root, disk);
+ else if (disk->disk_type == DISK_FILE)
+ /* If it's not a block device, we assume a file,
+ which should be a reasonable fail-safe */
+ msg = disk_file_xml(root, disk);
+ else if (disk->disk_type == DISK_FS)
+ msg = disk_fs_xml(root, disk);
+ else
+ msg = "Unknown disk type";
+ }
+
+ return msg;
+}
+
+static const char *bridge_net_to_xml(xmlNodePtr root, struct net_device *dev)
+{
+ const char *script = "vif-bridge";
+ xmlNodePtr nic;
+ xmlNodePtr tmp;
+
+ nic = xmlNewChild(root, NULL, BAD_CAST "interface", NULL);
+ if (nic == NULL)
+ return XML_ERROR;
+ xmlNewProp(nic, BAD_CAST "type", BAD_CAST dev->type);
+
+ tmp = xmlNewChild(nic, NULL, BAD_CAST "mac", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "address", BAD_CAST dev->mac);
+
+ tmp = xmlNewChild(nic, NULL, BAD_CAST "script", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "path", BAD_CAST script);
+
+ if (dev->source != NULL) {
+ tmp = xmlNewChild(nic, NULL, BAD_CAST "source", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "bridge", BAD_CAST dev->source);
+ }
+
+ return NULL;
+}
+
+static const char *network_net_to_xml(xmlNodePtr root, struct net_device *dev)
+{
+ xmlNodePtr nic;
+ xmlNodePtr tmp;
+
+ nic = xmlNewChild(root, NULL, BAD_CAST "interface", NULL);
+ if (nic == NULL)
+ return XML_ERROR;
+ xmlNewProp(nic, BAD_CAST "type", BAD_CAST dev->type);
+
+ tmp = xmlNewChild(nic, NULL, BAD_CAST "mac", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "address", BAD_CAST dev->mac);
+
+ if (dev->source != NULL) {
+ tmp = xmlNewChild(nic, NULL, BAD_CAST "source", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "network", BAD_CAST dev->source);
+ }
+
+ return NULL;
+}
+
+static const char *user_net_to_xml(xmlNodePtr root, struct net_device *dev)
+{
+ xmlNodePtr nic;
+ xmlNodePtr tmp;
+
+ nic = xmlNewChild(root, NULL, BAD_CAST "interface", NULL);
+ if (nic == NULL)
+ return XML_ERROR;
+ xmlNewProp(nic, BAD_CAST "type", BAD_CAST dev->type);
+
+ tmp = xmlNewChild(nic, NULL, BAD_CAST "mac", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "address", BAD_CAST dev->mac);
+
+ return NULL;
+}
+
+static const char *net_xml(xmlNodePtr root, struct domain *dominfo)
+{
+ int i;
+ const char *msg = NULL;
+
+ for (i = 0; (i < dominfo->dev_net_ct) && (msg == NULL); i++) {
+ struct virt_device *dev = &dominfo->dev_net[i];
+ struct net_device *net = &dev->dev.net;
+
+ if (STREQ(dev->dev.net.type, "network"))
+ msg = network_net_to_xml(root, net);
+ else if (STREQ(dev->dev.net.type, "bridge"))
+ msg = bridge_net_to_xml(root, net);
+ else if (STREQ(dev->dev.net.type, "user"))
+ msg = user_net_to_xml(root, net);
+ else
+ msg = "Unknown interface type";
+ }
+
+ return msg;
+}
+
+static const char *vcpu_xml(xmlNodePtr root, struct domain *dominfo)
+{
+ struct vcpu_device *vcpu;
+ xmlNodePtr tmp;
+ int ret;
+ char *string = NULL;
+
+ if (dominfo->dev_vcpu == NULL)
+ return NULL;
+
+ vcpu = &dominfo->dev_vcpu[0].dev.vcpu;
+
+ ret = asprintf(&string, "%" PRIu64, vcpu->quantity);
+ if (ret == -1)
+ return XML_ERROR;
+
+ tmp = xmlNewChild(root, NULL, BAD_CAST "vcpu", BAD_CAST string);
+ free(string);
+
+ if (tmp == NULL)
+ return XML_ERROR;
+ else
+ return NULL;
+}
+
+static const char *mem_xml(xmlNodePtr root, struct domain *dominfo)
+{
+ struct mem_device *mem;
+ xmlNodePtr tmp = NULL;
+ int ret;
+ char *string = NULL;
+
+ if (dominfo->dev_mem == NULL)
+ return NULL;
+
+ mem = &dominfo->dev_mem[0].dev.mem;
+
+ ret = asprintf(&string, "%" PRIu64, mem->size);
+ if (ret == -1)
+ goto out;
+ tmp = xmlNewChild(root,
+ NULL,
+ BAD_CAST "currentMemory",
+ BAD_CAST string);
+
+ free(string);
+ tmp = NULL;
+
+ ret = asprintf(&string, "%" PRIu64, mem->maxsize);
+ if (ret == -1)
+ goto out;
+ tmp = xmlNewChild(root,
+ NULL,
+ BAD_CAST "memory",
+ BAD_CAST string);
+
+ free(string);
+ out:
+ if (tmp == NULL)
+ return XML_ERROR;
+ else
+ return NULL;
+}
+
+static const char *emu_xml(xmlNodePtr root, struct domain *dominfo)
+{
+ struct emu_device *emu;
+ xmlNodePtr tmp;
+
+ if (dominfo->dev_emu == NULL)
+ return NULL;
+
+ emu = &dominfo->dev_emu->dev.emu;
+ tmp = xmlNewChild(root, NULL, BAD_CAST "emulator", BAD_CAST emu->path);
+ if (tmp == NULL)
+ return XML_ERROR;
+
+ return NULL;
+}
+
+static const char *graphics_xml(xmlNodePtr root, struct domain *dominfo)
+{
+ int i;
+
+ for (i = 0; i < dominfo->dev_graphics_ct; i++) {
+ xmlNodePtr tmp;
+ struct virt_device *_dev = &dominfo->dev_graphics[i];
+ struct graphics_device *dev = &_dev->dev.graphics;
+
+ tmp = xmlNewChild(root, NULL, BAD_CAST "graphics", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+
+ xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type);
+ 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);
+ }
+
+ return NULL;
+}
+
+static const char *input_xml(xmlNodePtr root, struct domain *dominfo)
+{
+ int i;
+
+ for (i = 0; i < dominfo->dev_input_ct; i++) {
+ xmlNodePtr tmp;
+ struct virt_device *_dev = &dominfo->dev_input[i];
+ struct input_device *dev = &_dev->dev.input;
+
+ tmp = xmlNewChild(root, NULL, BAD_CAST "input", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+
+ xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type);
+ xmlNewProp(tmp, BAD_CAST "bus", BAD_CAST dev->bus);
+ }
+
+ return NULL;
+}
+
+static char *system_xml(xmlNodePtr root, struct domain *domain)
+{
+ xmlNodePtr tmp;
+
+ tmp = xmlNewChild(root, NULL, BAD_CAST "name", BAD_CAST domain->name);
+
+ if (domain->bootloader) {
+ xmlNodePtr bl;
+
+ bl = xmlNewChild(root,
+ NULL,
+ BAD_CAST "bootloader",
+ BAD_CAST domain->bootloader);
+ }
+
+ if (domain->bootloader_args) {
+ xmlNodePtr bl_args;
+
+ bl_args = xmlNewChild(root,
+ NULL,
+ BAD_CAST "bootloader_args",
+ BAD_CAST domain->bootloader_args);
+ }
+
+ tmp = xmlNewChild(root,
+ NULL,
+ BAD_CAST "on_poweroff",
+ BAD_CAST vssd_recovery_action_str(domain->on_poweroff));
+
+ tmp = xmlNewChild(root,
+ NULL,
+ BAD_CAST "on_crash",
+ BAD_CAST vssd_recovery_action_str(domain->on_crash));
+
+ return NULL;
+}
+
+static char *_xenpv_os_xml(xmlNodePtr root, struct domain *domain)
{
struct pv_os_info *os = &domain->os_info.pv;
- int ret;
- char *xml;
- char *type = NULL;
- char *kernel = NULL;
- char *initrd = NULL;
- char *cmdline = NULL;
+ xmlNodePtr tmp;
if (os->type == NULL)
os->type = strdup("linux");
@@ -520,42 +413,29 @@
if (os->kernel == NULL)
os->kernel = strdup("/dev/null");
- type = tagify("type", os->type, NULL, 0);
- kernel = tagify("kernel", os->kernel, NULL, 0);
- initrd = tagify("initrd", os->initrd, NULL, 0);
- cmdline = tagify("cmdline", os->cmdline, NULL, 0);
+ tmp = xmlNewChild(root, NULL, BAD_CAST "type", BAD_CAST os->type);
+ if (tmp == NULL)
+ return XML_ERROR;
- ret = asprintf(&xml,
- "<os>\n"
- " %s\n"
- " %s\n"
- " %s\n"
- " %s\n"
- "</os>\n",
- type,
- kernel,
- initrd,
- cmdline);
- if (ret == -1)
- xml = NULL;
+ tmp = xmlNewChild(root, NULL, BAD_CAST "kernel", BAD_CAST os->kernel);
+ if (tmp == NULL)
+ return XML_ERROR;
- free(type);
- free(kernel);
- free(initrd);
- free(cmdline);
+ tmp = xmlNewChild(root, NULL, BAD_CAST "initrd", BAD_CAST os->initrd);
+ if (tmp == NULL)
+ return XML_ERROR;
- return xml;
+ tmp = xmlNewChild(root, NULL, BAD_CAST "cmdline", BAD_CAST os->cmdline);
+ if (tmp == NULL)
+ return XML_ERROR;
+
+ return NULL;
}
-static char *_xenfv_os_xml(struct domain *domain)
+static char *_xenfv_os_xml(xmlNodePtr root, struct domain *domain)
{
struct fv_os_info *os = &domain->os_info.fv;
- int ret;
- char *xml;
- char *type;
- char *loader;
- char *boot;
- struct kv bootattr = {"dev", NULL};
+ xmlNodePtr tmp;
if (os->type == NULL)
os->type = strdup("hvm");
@@ -566,44 +446,30 @@
if (os->boot == NULL)
os->boot = strdup("hd");
- type = tagify("type", os->type, NULL, 0);
- loader = tagify("loader", os->loader, NULL, 0);
+ tmp = xmlNewChild(root, NULL, BAD_CAST "type", BAD_CAST os->type);
+ if (tmp == NULL)
+ return XML_ERROR;
- bootattr.val = os->boot;
- boot = tagify("boot", NULL, &bootattr, 1);
+ tmp = xmlNewChild(root, NULL, BAD_CAST "loader", BAD_CAST os->loader);
+ if (tmp == NULL)
+ return XML_ERROR;
- ret = asprintf(&xml,
- "<os>\n"
- " %s\n"
- " %s\n"
- " %s\n"
- "</os>\n"
- "<features>\n"
- " <pae/>\n"
- " <acpi/>\n"
- " <apic/>\n"
- "</features>\n",
- type,
- loader,
- boot);
- if (ret == -1)
- xml = NULL;
+ tmp = xmlNewChild(root, NULL, BAD_CAST "boot", BAD_CAST os->boot);
+ if (tmp == NULL)
+ return XML_ERROR;
- free(type);
- free(loader);
- free(boot);
+ tmp = xmlNewChild(root, NULL, BAD_CAST "features", NULL);
+ xmlNewChild(tmp, NULL, BAD_CAST "pae", NULL);
+ xmlNewChild(tmp, NULL, BAD_CAST "acpi", NULL);
+ xmlNewChild(tmp, NULL, BAD_CAST "apic", NULL);
- return xml;
+ return NULL;
}
-static char *_kvm_os_xml(struct domain *domain)
+static char *_kvm_os_xml(xmlNodePtr root, struct domain *domain)
{
struct fv_os_info *os = &domain->os_info.fv;
- int ret;
- char *xml;
- char *type;
- char *boot;
- struct kv bootattr = {"dev", NULL};
+ xmlNodePtr tmp;
if (os->type == NULL)
os->type = strdup("hvm");
@@ -611,84 +477,162 @@
if (os->boot == NULL)
os->boot = strdup("hd");
- type = tagify("type", os->type, NULL, 0);
+ tmp = xmlNewChild(root, NULL, BAD_CAST "type", BAD_CAST os->type);
+ if (tmp == NULL)
+ return XML_ERROR;
- bootattr.val = os->boot;
- boot = tagify("boot", NULL, &bootattr, 1);
+ tmp = xmlNewChild(root, NULL, BAD_CAST "boot", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+ xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST os->boot);
- ret = asprintf(&xml,
- "<os>\n"
- " %s\n"
- " %s\n"
- "</os>\n",
- type,
- boot);
- if (ret == -1)
- xml = NULL;
+ return NULL;
+}
- free(type);
- free(boot);
+static char *_lxc_os_xml(xmlNodePtr root, struct domain *domain)
+{
+ struct lxc_os_info *os = &domain->os_info.lxc;
+ xmlNodePtr tmp;
+
+ if (os->type == NULL)
+ os->type = strdup("exe");
+
+ tmp = xmlNewChild(root, NULL, BAD_CAST "init", BAD_CAST os->init);
+ if (tmp == NULL)
+ return XML_ERROR;
+
+ tmp = xmlNewChild(root, NULL, BAD_CAST "type", BAD_CAST os->type);
+ if (tmp == NULL)
+ return XML_ERROR;
+
+ return NULL;
+}
+
+static char *os_xml(xmlNodePtr root, struct domain *domain)
+{
+ xmlNodePtr os;
+
+ os = xmlNewChild(root, NULL, BAD_CAST "os", NULL);
+ if (os == NULL)
+ return "Failed to allocate XML memory";
+
+ if (domain->type == DOMAIN_XENPV)
+ return _xenpv_os_xml(os, domain);
+ else if (domain->type == DOMAIN_XENFV)
+ return _xenfv_os_xml(os, domain);
+ else if (domain->type == DOMAIN_KVM)
+ return _kvm_os_xml(os, domain);
+ else if (domain->type == DOMAIN_LXC)
+ return _lxc_os_xml(os, domain);
+ else
+ return "Unsupported domain type";
+}
+
+char *device_to_xml(struct virt_device *dev)
+{
+ char *xml = NULL;
+ int type = dev->type;
+ xmlDocPtr doc = NULL;
+ xmlNodePtr root = NULL;
+ xmlChar *_xml = NULL;
+ int xml_size;
+ const char *msg;
+ struct domain *dominfo;
+ devfn_t func;
+
+ dominfo = calloc(1, sizeof(*dominfo));
+ if (dominfo == NULL)
+ return NULL;
+
+ doc = xmlNewDoc(BAD_CAST "1.0");
+ if (doc == NULL)
+ goto out;
+ root = xmlNewNode(NULL, BAD_CAST "tmp");
+ if (root == NULL)
+ goto out;
+
+ switch (type) {
+ case CIM_RES_TYPE_DISK:
+ func = disk_xml;
+ dominfo->dev_disk_ct = 1;
+ dominfo->dev_disk = dev;
+ break;
+ case CIM_RES_TYPE_PROC:
+ func = vcpu_xml;
+ dominfo->dev_vcpu_ct = 1;
+ dominfo->dev_vcpu = dev;
+ break;
+ case CIM_RES_TYPE_NET:
+ func = net_xml;
+ dominfo->dev_net_ct = 1;
+ dominfo->dev_vcpu = dev;
+ break;
+ case CIM_RES_TYPE_MEM:
+ func = mem_xml;
+ dominfo->dev_mem_ct = 1;
+ dominfo->dev_mem = dev;
+ break;
+ case CIM_RES_TYPE_EMU:
+ func = emu_xml;
+ dominfo->dev_emu = dev;
+ break;
+ case CIM_RES_TYPE_GRAPHICS:
+ func = graphics_xml;
+ dominfo->dev_graphics_ct = 1;
+ dominfo->dev_graphics = dev;
+ break;
+ case CIM_RES_TYPE_INPUT:
+ func = input_xml;
+ dominfo->dev_input_ct = 1;
+ dominfo->dev_input = dev;
+ break;
+ default:
+ return NULL;
+ }
+
+ msg = func(root, dominfo);
+ if (msg != NULL) {
+ CU_DEBUG("Failed to create device XML: %s", msg);
+ goto out;
+ }
+
+ xmlDocSetRootElement(doc, root->children);
+
+ xmlDocDumpFormatMemory(doc, &_xml, &xml_size, 1);
+ xml = strdup((char *)_xml);
+ xmlFree(_xml);
+ out:
+ CU_DEBUG("Created Device XML:\n%s\n", xml);
+
+ cleanup_dominfo(&dominfo);
+ xmlFreeNode(root);
+ xmlFreeDoc(doc);
return xml;
}
-static char *_lxc_os_xml(struct domain *domain)
-{
- struct lxc_os_info *os = &domain->os_info.lxc;
- int ret;
- char *xml = NULL;
-
- if (os->type == NULL)
- os->type = strdup("exe");
-
- ret = asprintf(&xml,
- "<os>\n"
- " <init>%s</init>\n"
- " <type>%s</type>\n"
- "</os>\n",
- os->init,
- os->type);
- if (ret == -1)
- xml = NULL;
-
- return xml;
-}
-
-static char *os_xml(struct domain *domain)
-{
- if (domain->type == DOMAIN_XENPV)
- return _xenpv_os_xml(domain);
- else if (domain->type == DOMAIN_XENFV)
- return _xenfv_os_xml(domain);
- else if (domain->type == DOMAIN_KVM)
- return _kvm_os_xml(domain);
- else if (domain->type == DOMAIN_LXC)
- return _lxc_os_xml(domain);
- else
- return strdup("<!-- unsupported domain type -->\n");
-}
-
-static int console_xml(struct domain *dominfo,
- char **xml)
-{
- if (dominfo->type == DOMAIN_LXC) {
- astrcat(xml, "<console type='pty'/>\n");
- }
-
- return 0;
-}
char *system_to_xml(struct domain *dominfo)
{
- char *devxml = strdup("");
- char *sysdevxml = strdup("");
- char *sysxml = NULL;
- char *osxml = NULL;
+ xmlDocPtr doc = NULL;
+ xmlNodePtr root = NULL;
+ xmlNodePtr devices = NULL;
+ xmlChar *_xml = NULL;
char *xml = NULL;
- int ret;
+ int xml_len;
uint8_t uuid[16];
char uuidstr[37];
const char *domtype;
+ const char *msg = XML_ERROR;
+ int i;
+ devfn_t device_handlers[] = {
+ &disk_xml,
+ &net_xml,
+ &input_xml,
+ &graphics_xml,
+ &emu_xml,
+ NULL
+ };
if ((dominfo->type == DOMAIN_XENPV) || (dominfo->type == DOMAIN_XENFV))
domtype = "xen";
@@ -708,70 +652,92 @@
uuid_unparse(uuid, uuidstr);
}
- concat_devxml(&devxml,
- dominfo->dev_net,
- dominfo->dev_net_ct,
- net_to_xml);
- concat_devxml(&devxml,
- dominfo->dev_disk,
- dominfo->dev_disk_ct,
- disk_to_xml);
+ CU_DEBUG("foo");
+ doc = xmlNewDoc(BAD_CAST "1.0");
+ if (doc == NULL)
+ goto out;
- if (dominfo->dev_emu)
- concat_devxml(&devxml,
- dominfo->dev_emu,
- 1,
- emu_to_xml);
+ CU_DEBUG("foo");
+ root = xmlNewNode(NULL, BAD_CAST "domain");
+ if (root == NULL)
+ goto out;
- if (dominfo->dev_graphics)
- concat_devxml(&devxml,
- dominfo->dev_graphics,
- dominfo->dev_graphics_ct,
- graphics_to_xml);
+ CU_DEBUG("foo");
+ if (xmlNewProp(root, BAD_CAST "type", BAD_CAST domtype) == NULL)
+ goto out;
- if (dominfo->dev_input)
- concat_devxml(&devxml,
- dominfo->dev_input,
- dominfo->dev_input_ct,
- input_to_xml);
+ CU_DEBUG("foo");
+ xmlDocSetRootElement(doc, root);
- console_xml(dominfo, &devxml);
+ CU_DEBUG("foo");
+ msg = system_xml(root, dominfo);
+ if (msg != NULL)
+ goto out;
- concat_devxml(&sysdevxml,
- dominfo->dev_mem,
- dominfo->dev_mem_ct,
- mem_to_xml);
- concat_devxml(&sysdevxml,
- dominfo->dev_vcpu,
- dominfo->dev_vcpu_ct,
- vcpu_to_xml);
+ CU_DEBUG("foo");
+ msg = os_xml(root, dominfo);
+ if (msg != NULL)
+ goto out;
- sysxml = system_xml(dominfo);
- osxml = os_xml(dominfo);
+ CU_DEBUG("foo");
+ msg = mem_xml(root, dominfo);
+ if (msg != NULL)
+ goto out;
- ret = asprintf(&xml,
- "<domain type='%s'>\n"
- "<uuid>%s</uuid>\n"
- "%s"
- "%s"
- "%s"
- "<devices>\n"
- "%s"
- "</devices>\n"
- "</domain>\n",
- domtype,
- uuidstr,
- sysxml,
- osxml,
- sysdevxml,
- devxml);
- if (ret == -1)
- xml = NULL;
+ CU_DEBUG("foo");
+ msg = vcpu_xml(root, dominfo);
+ if (msg != NULL)
+ goto out;
- free(devxml);
- free(sysdevxml);
- free(osxml);
- free(sysxml);
+ CU_DEBUG("foo");
+ devices = xmlNewChild(root, NULL, BAD_CAST "devices", NULL);
+ if (devices == NULL) {
+ msg = XML_ERROR;
+ goto out;
+ }
+
+ CU_DEBUG("foo");
+ for (i = 0; device_handlers[i] != NULL; i++) {
+ devfn_t fn = device_handlers[i];
+
+ msg = fn(devices, dominfo);
+ if (msg != NULL)
+ goto out;
+ }
+
+ CU_DEBUG("foo");
+ msg = XML_ERROR;
+ if (dominfo->type == DOMAIN_LXC) {
+ xmlNodePtr cons;
+
+ cons = xmlNewChild(devices, NULL, BAD_CAST "console", NULL);
+ if (cons == NULL)
+ goto out;
+
+ if (xmlNewProp(cons, BAD_CAST "type", BAD_CAST "pty") == NULL)
+ goto out;
+ }
+
+ CU_DEBUG("Generating XML");
+ xmlDocDumpFormatMemory(doc, &_xml, &xml_len, 1);
+ if (_xml == NULL)
+ goto out;
+
+ xml = strdup((char *)_xml);
+ if (xml == NULL)
+ msg = "Out of memory generating XML";
+ else
+ msg = NULL;
+
+ xmlFree(_xml);
+ out:
+ if (msg != NULL) {
+ CU_DEBUG("Failed to create XML: %s", msg);
+ } else {
+ CU_DEBUG("Created System XML:\n%s\n", xml);
+ }
+
+ xmlFreeDoc(doc);
return xml;
}
16 years
[PATCH] [TEST] Convert define() to use cim_define() for the last two tc
by yunguol@cn.ibm.com
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1228282396 28800
# Node ID 041a82bdf3abf65105f735a13fab054b23133761
# Parent 70ecd9e8867cc277b31f4703e73b5dba7ad53128
[TEST] Convert define() to use cim_define() for the last two tc
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 70ecd9e8867c -r 041a82bdf3ab suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py
--- a/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Tue Dec 02 21:33:16 2008 -0800
@@ -91,7 +91,7 @@
virt_xml = get_class(virt)
cxml = virt_xml(test_dom)
- ret = cxml.define(server)
+ ret = cxml.cim_define(server)
if not ret:
logger.error("ERROR: Failed to Define the dom: %s" % test_dom)
return status
diff -r 70ecd9e8867c -r 041a82bdf3ab suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py
--- a/suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py Tue Dec 02 21:33:16 2008 -0800
@@ -139,7 +139,7 @@
conn = assoc.myWBEMConnection('http://%s' % options.ip, (CIM_USER, CIM_PASS), CIM_NS)
virt_xml = vxml.get_class(options.virt)
cxml = virt_xml(test_dom)
- ret = cxml.define(options.ip)
+ ret = cxml.cim_define(options.ip)
if not ret:
logger.error('Unable to define domain %s' % test_dom)
return FAIL
16 years
[PATCH] [TEST] Convert define() to use cim_define() for other tc
by yunguol@cn.ibm.com
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1228282179 28800
# Node ID fd9b6294d6a044c2b0e45526a364a13adaa68e73
# Parent 70ecd9e8867cc277b31f4703e73b5dba7ad53128
[TEST] Convert define() to use cim_define() for other tc
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/NetworkPort/02_np_gi_errors.py
--- a/suites/libvirt-cim/cimtest/NetworkPort/02_np_gi_errors.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/NetworkPort/02_np_gi_errors.py Tue Dec 02 21:29:39 2008 -0800
@@ -245,7 +245,7 @@
test_mac = "00:11:22:33:44:55"
vsxml = get_class(options.virt)(test_dom, mac=test_mac)
- ret = vsxml.define(options.ip)
+ ret = vsxml.cim_define(options.ip)
if ret != 1:
logger.error("Define domain failed!")
return SKIP
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/NetworkPort/03_user_netport.py
--- a/suites/libvirt-cim/cimtest/NetworkPort/03_user_netport.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/NetworkPort/03_user_netport.py Tue Dec 02 21:29:39 2008 -0800
@@ -43,7 +43,7 @@
def main():
options = main.options
cxml = KVMXML(test_dom, mac = test_mac, ntype='user')
- ret = cxml.define(options.ip)
+ ret = cxml.cim_define(options.ip)
if not ret:
logger.error('Unable to define domain %s' % test_dom)
return FAIL
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/Processor/01_processor.py
--- a/suites/libvirt-cim/cimtest/Processor/01_processor.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/Processor/01_processor.py Tue Dec 02 21:29:39 2008 -0800
@@ -44,7 +44,7 @@
options = main.options
status = PASS
vsxml = get_class(options.virt)(test_dom, vcpus=test_vcpus)
- vsxml.define(options.ip)
+ vsxml.cim_define(options.ip)
vsxml.start(options.ip)
# Processor instance enumerate need the domain to be active
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/Processor/03_proc_gi_errs.py
--- a/suites/libvirt-cim/cimtest/Processor/03_proc_gi_errs.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/Processor/03_proc_gi_errs.py Tue Dec 02 21:29:39 2008 -0800
@@ -179,7 +179,7 @@
# Getting the VS list and deleting the test_dom if it already exists.
destroy_and_undefine_all(options.ip)
vsxml = get_class(options.virt)(test_dom, vcpus=test_vcpus)
- vsxml.define(options.ip)
+ vsxml.cim_define(options.ip)
ret = vsxml.start(options.ip)
if not ret:
logger.error("Failed to Create the dom: %s", test_dom)
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py
--- a/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py Tue Dec 02 21:29:39 2008 -0800
@@ -144,7 +144,7 @@
disk = test_disk)
bridge = vsxml.set_vbridge(server, default_network_name)
try:
- ret = vsxml.define(options.ip)
+ ret = vsxml.cim_define(options.ip)
if not ret:
logger.error("Failed to Define the domain: %s", test_dom)
return FAIL
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py
--- a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py Tue Dec 02 21:29:39 2008 -0800
@@ -58,7 +58,7 @@
mac = test_mac, disk = test_disk,
ntype = 'network', net_name = test_npool)
try:
- ret = vsxml.define(server)
+ ret = vsxml.cim_define(server)
if not ret:
logger.error("Failed to Define the domain: %s", test_dom)
return FAIL, vsxml, test_disk
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/VSSD/01_enum.py
--- a/suites/libvirt-cim/cimtest/VSSD/01_enum.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/VSSD/01_enum.py Tue Dec 02 21:29:39 2008 -0800
@@ -47,7 +47,7 @@
destroy_and_undefine_all(options.ip)
vsxml = get_class(options.virt)(test_dom)
- ret = vsxml.define(options.ip)
+ ret = vsxml.cim_define(options.ip)
if not ret :
logger.error("error while create of VS")
status = FAIL
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/VSSD/03_vssd_gi_errs.py
--- a/suites/libvirt-cim/cimtest/VSSD/03_vssd_gi_errs.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/VSSD/03_vssd_gi_errs.py Tue Dec 02 21:29:39 2008 -0800
@@ -92,7 +92,7 @@
else:
VSType = options.virt
vsxml = get_class(options.virt)(test_dom)
- ret = vsxml.define(options.ip)
+ ret = vsxml.cim_define(options.ip)
if not ret :
logger.error("error while define of VS")
return FAIL
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/VirtualSystemManagementService/02_destroysystem.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/02_destroysystem.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/02_destroysystem.py Tue Dec 02 21:29:39 2008 -0800
@@ -45,7 +45,7 @@
service = vsms.get_vsms_class(options.virt)(options.ip)
cxml = vxml.get_class(options.virt)(default_dom)
- ret = cxml.define(options.ip)
+ ret = cxml.cim_define(options.ip)
if not ret:
logger.error("Failed to define the dom: %s", default_dom)
return FAIL
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/VirtualSystemManagementService/06_addresource.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/06_addresource.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/06_addresource.py Tue Dec 02 21:29:39 2008 -0800
@@ -99,7 +99,7 @@
#Each time through, define guest using a default XML
cxml.undefine(options.ip)
cxml = vxml.get_class(options.virt)(default_dom)
- ret = cxml.define(options.ip)
+ ret = cxml.cim_define(options.ip)
if not ret:
logger.error("Failed to define the dom: %s", default_dom)
cleanup_env(options.ip, options.virt, cxml, net_name)
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/VirtualSystemManagementService/07_addresource_neg.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/07_addresource_neg.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/07_addresource_neg.py Tue Dec 02 21:29:39 2008 -0800
@@ -53,7 +53,7 @@
status = PASS
rc = -1
try:
- cxml.define(options.ip)
+ cxml.cim_define(options.ip)
bad_inst = 'instance of what ever { dd = 3; //\ ]&'
ret = service.AddResourceSettings(AffectedConfiguration=vssd_ref,
ResourceSettings=[bad_inst])
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py Tue Dec 02 21:29:39 2008 -0800
@@ -75,7 +75,7 @@
#Each time through, define guest using a default XML
cxml.undefine(options.ip)
cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu)
- ret = cxml.define(options.ip)
+ ret = cxml.cim_define(options.ip)
if not ret:
logger.error("Failed to define the dom: %s", default_dom)
cleanup_env(options.ip, options.virt, cxml)
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/VirtualSystemMigrationService/02_host_migrate_type.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemMigrationService/02_host_migrate_type.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/VirtualSystemMigrationService/02_host_migrate_type.py Tue Dec 02 21:29:39 2008 -0800
@@ -44,7 +44,7 @@
try:
virt_xml = vxml.get_class(virt)
cxml = virt_xml(guest_name)
- cxml.define(ip)
+ cxml.cim_define(ip)
except Exception:
logger.error("Error define domain %s" % guest_name)
cxml.undefine(ip)
diff -r 70ecd9e8867c -r fd9b6294d6a0 suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/01_forward.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/01_forward.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/01_forward.py Tue Dec 02 21:29:39 2008 -0800
@@ -131,7 +131,7 @@
else:
cxml = virt_xml(test_dom, vcpus = test_vcpus, \
mac = test_mac, disk = test_disk)
- ret = cxml.define(options.ip)
+ ret = cxml.cim_define(options.ip)
if not ret:
logger.error("Failed to define the dom: %s", test_dom)
return FAIL
16 years
Xen on Pegasus Test Run Summary for Dec 02 2008
by Guo Lian Yun
=================================================
Xen on Pegasus Test Run Summary for Dec 02 2008
=================================================
Distro: Red Hat Enterprise Linux Server release 5.2 Beta (Tikanga)
Kernel: 2.6.18-88.el5xen
libvirt: 0.3.3
Hypervisor: Xen 3.1.0
CIMOM: Pegasus 2.7.0
Libvirt-cim revision: 772
Libvirt-cim changeset: 6e8a488cf67b
Cimtest revision: 513
Cimtest changeset: 5fb94ae83ed1
=================================================
FAIL : 3
XFAIL : 0
SKIP : 2
PASS : 134
-----------------
Total : 139
=================================================
FAIL Test Summary:
HostSystem - 02_hostsystem_to_rasd.py: FAIL
LogicalDisk - 02_nodevs.py: FAIL
VSSD - 04_vssd_to_rasd.py: FAIL
=================================================
SKIP Test Summary:
ComputerSystem - 02_nosystems.py: SKIP
NetworkPort - 03_user_netport.py: SKIP
=================================================
Full report:
--------------------------------------------------------------------
AllocationCapabilities - 01_enum.py: PASS
--------------------------------------------------------------------
AllocationCapabilities - 02_alloccap_gi_errs.py: PASS
--------------------------------------------------------------------
ComputerSystem - 01_enum.py: PASS
--------------------------------------------------------------------
ComputerSystem - 02_nosystems.py: SKIP
--------------------------------------------------------------------
ComputerSystem - 03_defineVS.py: PASS
--------------------------------------------------------------------
ComputerSystem - 04_defineStartVS.py: PASS
--------------------------------------------------------------------
ComputerSystem - 05_activate_defined_start.py: PASS
--------------------------------------------------------------------
ComputerSystem - 06_paused_active_suspend.py: PASS
--------------------------------------------------------------------
ComputerSystem - 22_define_suspend.py: PASS
--------------------------------------------------------------------
ComputerSystem - 23_suspend_suspend.py: PASS
--------------------------------------------------------------------
ComputerSystem - 27_define_suspend_errs.py: PASS
--------------------------------------------------------------------
ComputerSystem - 32_start_reboot.py: PASS
--------------------------------------------------------------------
ComputerSystem - 33_suspend_reboot.py: PASS
--------------------------------------------------------------------
ComputerSystem - 35_start_reset.py: PASS
--------------------------------------------------------------------
ComputerSystem - 40_RSC_start.py: PASS
--------------------------------------------------------------------
ComputerSystem - 41_cs_to_settingdefinestate.py: PASS
--------------------------------------------------------------------
ComputerSystem - 42_cs_gi_errs.py: PASS
--------------------------------------------------------------------
ComputerSystemIndication - 01_created_indication.py: PASS
--------------------------------------------------------------------
ElementAllocatedFromPool - 01_forward.py: PASS
--------------------------------------------------------------------
ElementAllocatedFromPool - 02_reverse.py: PASS
--------------------------------------------------------------------
ElementAllocatedFromPool - 03_reverse_errs.py: PASS
--------------------------------------------------------------------
ElementAllocatedFromPool - 04_forward_errs.py: PASS
--------------------------------------------------------------------
ElementCapabilities - 01_forward.py: PASS
--------------------------------------------------------------------
ElementCapabilities - 02_reverse.py: PASS
--------------------------------------------------------------------
ElementCapabilities - 03_forward_errs.py: PASS
--------------------------------------------------------------------
ElementCapabilities - 04_reverse_errs.py: PASS
--------------------------------------------------------------------
ElementCapabilities - 05_hostsystem_cap.py: PASS
--------------------------------------------------------------------
ElementConforms - 01_forward.py: PASS
--------------------------------------------------------------------
ElementConforms - 02_reverse.py: PASS
--------------------------------------------------------------------
ElementConforms - 03_ectp_fwd_errs.py: PASS
--------------------------------------------------------------------
ElementConforms - 04_ectp_rev_errs.py: PASS
--------------------------------------------------------------------
ElementSettingData - 01_forward.py: PASS
--------------------------------------------------------------------
ElementSettingData - 03_esd_assoc_with_rasd_errs.py: PASS
--------------------------------------------------------------------
EnabledLogicalElementCapabilities - 01_enum.py: PASS
--------------------------------------------------------------------
EnabledLogicalElementCapabilities - 02_elecap_gi_errs.py: PASS
--------------------------------------------------------------------
HostSystem - 01_enum.py: PASS
--------------------------------------------------------------------
HostSystem - 02_hostsystem_to_rasd.py: FAIL
ERROR - InstanceID Mismatch
ERROR - Returned CrossClass_GuestDom/mouse:xen instead of
CrossClass_GuestDom/mouse:ps2
ERROR - Mistmatching association values
CIM_ERR_INVALID_CLASS: Linux_ComputerSystem
--------------------------------------------------------------------
HostSystem - 03_hs_to_settdefcap.py: PASS
--------------------------------------------------------------------
HostSystem - 04_hs_to_EAPF.py: PASS
--------------------------------------------------------------------
HostSystem - 05_hs_gi_errs.py: PASS
--------------------------------------------------------------------
HostSystem - 06_hs_to_vsms.py: PASS
--------------------------------------------------------------------
HostedDependency - 01_forward.py: PASS
--------------------------------------------------------------------
HostedDependency - 02_reverse.py: PASS
--------------------------------------------------------------------
HostedDependency - 03_enabledstate.py: PASS
--------------------------------------------------------------------
HostedDependency - 04_reverse_errs.py: PASS
--------------------------------------------------------------------
HostedResourcePool - 01_forward.py: PASS
--------------------------------------------------------------------
HostedResourcePool - 02_reverse.py: PASS
--------------------------------------------------------------------
HostedResourcePool - 03_forward_errs.py: PASS
--------------------------------------------------------------------
HostedResourcePool - 04_reverse_errs.py: PASS
--------------------------------------------------------------------
HostedService - 01_forward.py: PASS
--------------------------------------------------------------------
HostedService - 02_reverse.py: PASS
--------------------------------------------------------------------
HostedService - 03_forward_errs.py: PASS
--------------------------------------------------------------------
HostedService - 04_reverse_errs.py: PASS
--------------------------------------------------------------------
LogicalDisk - 01_disk.py: PASS
--------------------------------------------------------------------
LogicalDisk - 02_nodevs.py: FAIL
ERROR - CIMError : (6, u'CIM_ERR_NOT_FOUND: No such instance
(test_domain).')
Traceback (most recent call last):
File "./lib/XenKvmLib/const.py", line 129, in do_try
File "02_nodevs.py", line 54, in main
if not clean_system(options.ip, options.virt):
File "02_nodevs.py", line 42, in clean_system
l = enumclass.EnumInstances(host, cs)
File "./lib/XenKvmLib/enumclass.py", line 108, in EnumInstances
File "./lib/XenKvmLib/enumclass.py", line 44, in __init__
CIMError: (6, u'CIM_ERR_NOT_FOUND: No such instance (test_domain).')
ERROR - None
--------------------------------------------------------------------
LogicalDisk - 03_ld_gi_errs.py: PASS
--------------------------------------------------------------------
Memory - 01_memory.py: PASS
--------------------------------------------------------------------
Memory - 02_defgetmem.py: PASS
--------------------------------------------------------------------
Memory - 03_mem_gi_errs.py: PASS
--------------------------------------------------------------------
NetworkPort - 01_netport.py: PASS
--------------------------------------------------------------------
NetworkPort - 02_np_gi_errors.py: PASS
--------------------------------------------------------------------
NetworkPort - 03_user_netport.py: SKIP
--------------------------------------------------------------------
Processor - 01_processor.py: PASS
--------------------------------------------------------------------
Processor - 02_definesys_get_procs.py: PASS
--------------------------------------------------------------------
Processor - 03_proc_gi_errs.py: PASS
--------------------------------------------------------------------
Profile - 01_enum.py: PASS
--------------------------------------------------------------------
Profile - 02_profile_to_elec.py: PASS
--------------------------------------------------------------------
Profile - 03_rprofile_gi_errs.py: PASS
--------------------------------------------------------------------
RASD - 01_verify_rasd_fields.py: PASS
--------------------------------------------------------------------
RASD - 02_enum.py: PASS
--------------------------------------------------------------------
RASD - 03_rasd_errs.py: PASS
--------------------------------------------------------------------
RASD - 04_disk_rasd_size.py: PASS
--------------------------------------------------------------------
RedirectionService - 01_enum_crs.py: PASS
--------------------------------------------------------------------
RedirectionService - 02_enum_crscap.py: PASS
--------------------------------------------------------------------
ReferencedProfile - 01_verify_refprof.py: PASS
--------------------------------------------------------------------
ReferencedProfile - 02_refprofile_errs.py: PASS
--------------------------------------------------------------------
ResourceAllocationFromPool - 01_forward.py: PASS
--------------------------------------------------------------------
ResourceAllocationFromPool - 02_reverse.py: PASS
--------------------------------------------------------------------
ResourceAllocationFromPool - 03_forward_errs.py: PASS
--------------------------------------------------------------------
ResourceAllocationFromPool - 04_reverse_errs.py: PASS
--------------------------------------------------------------------
ResourceAllocationFromPool - 05_RAPF_err.py: PASS
--------------------------------------------------------------------
ResourcePool - 01_enum.py: PASS
--------------------------------------------------------------------
ResourcePool - 02_rp_gi_errors.py: PASS
--------------------------------------------------------------------
ResourcePoolConfigurationCapabilities - 01_enum.py: PASS
--------------------------------------------------------------------
ResourcePoolConfigurationCapabilities - 02_rpcc_gi_errs.py: PASS
--------------------------------------------------------------------
ResourcePoolConfigurationService - 01_enum.py: PASS
--------------------------------------------------------------------
ResourcePoolConfigurationService - 02_rcps_gi_errors.py: PASS
--------------------------------------------------------------------
ResourcePoolConfigurationService - 03_CreateResourcePool.py: PASS
--------------------------------------------------------------------
ResourcePoolConfigurationService - 04_CreateChildResourcePool.py: PASS
--------------------------------------------------------------------
ResourcePoolConfigurationService - 05_AddResourcesToResourcePool.py: PASS
--------------------------------------------------------------------
ResourcePoolConfigurationService - 06_RemoveResourcesFromResourcePool.py:
PASS
--------------------------------------------------------------------
ResourcePoolConfigurationService - 07_DeleteResourcePool.py: PASS
--------------------------------------------------------------------
SettingsDefine - 01_forward.py: PASS
--------------------------------------------------------------------
SettingsDefine - 02_reverse.py: PASS
--------------------------------------------------------------------
SettingsDefine - 03_sds_fwd_errs.py: PASS
--------------------------------------------------------------------
SettingsDefine - 04_sds_rev_errs.py: PASS
--------------------------------------------------------------------
SettingsDefineCapabilities - 01_forward.py: PASS
--------------------------------------------------------------------
SettingsDefineCapabilities - 03_forward_errs.py: PASS
--------------------------------------------------------------------
SettingsDefineCapabilities - 04_forward_vsmsdata.py: PASS
--------------------------------------------------------------------
SettingsDefineCapabilities - 05_reverse_vsmcap.py: PASS
--------------------------------------------------------------------
SystemDevice - 01_forward.py: PASS
--------------------------------------------------------------------
SystemDevice - 02_reverse.py: PASS
--------------------------------------------------------------------
SystemDevice - 03_fwderrs.py: PASS
--------------------------------------------------------------------
VSSD - 01_enum.py: PASS
--------------------------------------------------------------------
VSSD - 02_bootldr.py: PASS
--------------------------------------------------------------------
VSSD - 03_vssd_gi_errs.py: PASS
--------------------------------------------------------------------
VSSD - 04_vssd_to_rasd.py: FAIL
ERROR - InstanceID Mismatch
ERROR - Returned VSSDC_dom/mouse:xen instead of
VSSDC_dom/mouse:ps2
ERROR - Mistmatching Xen_InputResourceAllocationSettingData
values
--------------------------------------------------------------------
VirtualSystemManagementCapabilities - 01_enum.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementCapabilities - 02_vsmcap_gi_errs.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 01_definesystem_name.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 02_destroysystem.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 03_definesystem_ess.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 04_definesystem_ers.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 05_destroysystem_neg.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 06_addresource.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 07_addresource_neg.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 08_modifyresource.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 09_procrasd_persist.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 10_hv_version.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 11_define_memrasdunits.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 12_referenced_config.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 13_refconfig_additional_devs.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 14_define_sys_disk.py: PASS
--------------------------------------------------------------------
VirtualSystemManagementService - 15_mod_system_settings.py: PASS
--------------------------------------------------------------------
VirtualSystemMigrationCapabilities - 01_enum.py: PASS
--------------------------------------------------------------------
VirtualSystemMigrationCapabilities - 02_vsmc_gi_errs.py: PASS
--------------------------------------------------------------------
VirtualSystemMigrationService - 01_migratable_host.py: PASS
--------------------------------------------------------------------
VirtualSystemMigrationService - 02_host_migrate_type.py: PASS
--------------------------------------------------------------------
VirtualSystemMigrationService - 05_migratable_host_errs.py: PASS
--------------------------------------------------------------------
VirtualSystemMigrationSettingData - 01_enum.py: PASS
--------------------------------------------------------------------
VirtualSystemMigrationSettingData - 02_vsmsd_gi_errs.py: PASS
--------------------------------------------------------------------
VirtualSystemSettingDataComponent - 01_forward.py: PASS
--------------------------------------------------------------------
VirtualSystemSettingDataComponent - 02_reverse.py: PASS
--------------------------------------------------------------------
VirtualSystemSettingDataComponent - 03_vssdc_fwd_errs.py: PASS
--------------------------------------------------------------------
VirtualSystemSettingDataComponent - 04_vssdc_rev_errs.py: PASS
--------------------------------------------------------------------
VirtualSystemSnapshotService - 01_enum.py: PASS
--------------------------------------------------------------------
VirtualSystemSnapshotService - 02_vs_sservice_gi_errs.py: PASS
--------------------------------------------------------------------
VirtualSystemSnapshotServiceCapabilities - 01_enum.py: PASS
--------------------------------------------------------------------
VirtualSystemSnapshotServiceCapabilities - 02_vs_sservicecap_gi_errs.py:
PASS
--------------------------------------------------------------------
16 years
[PATCH] [TEST] Convert define() to use cim_define()
by yunguol@cn.ibm.com
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1228273337 28800
# Node ID 03f56f4d1b8d46e20c03817a0f791a821c51bfdd
# Parent 70ecd9e8867cc277b31f4703e73b5dba7ad53128
[TEST] Convert define() to use cim_define()
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 70ecd9e8867c -r 03f56f4d1b8d suites/libvirt-cim/cimtest/ComputerSystem/04_defineStartVS.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/04_defineStartVS.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/04_defineStartVS.py Tue Dec 02 19:02:17 2008 -0800
@@ -48,7 +48,7 @@
enabState = 0
cxml = vxml.get_class(options.virt)(test_dom)
- cxml.define(options.ip)
+ cxml.cim_define(options.ip)
ret = cxml.start(options.ip)
if not ret :
diff -r 70ecd9e8867c -r 03f56f4d1b8d suites/libvirt-cim/cimtest/ComputerSystem/42_cs_gi_errs.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/42_cs_gi_errs.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/42_cs_gi_errs.py Tue Dec 02 19:02:17 2008 -0800
@@ -102,7 +102,7 @@
inst_ccname = classname = get_typed_class(options.virt, 'ComputerSystem')
inst_name = 'ETdomain'
cxml = vxml.get_class(options.virt)(inst_name)
- ret = cxml.define(options.ip)
+ ret = cxml.cim_define(options.ip)
if not ret:
logger.error(VIRSH_ERROR_DEFINE % inst_name)
return FAIL
diff -r 70ecd9e8867c -r 03f56f4d1b8d suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py Tue Dec 02 19:02:17 2008 -0800
@@ -185,7 +185,7 @@
vsxml = virt_type (test_dom, vcpus = test_vcpus, mac = test_mac,
disk = test_disk)
- ret = vsxml.define(options.ip)
+ ret = vsxml.cim_define(options.ip)
if not ret:
logger.error("Failed to define the dom: %s", test_dom)
return FAIL
diff -r 70ecd9e8867c -r 03f56f4d1b8d suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py Tue Dec 02 19:02:17 2008 -0800
@@ -502,7 +502,7 @@
disk = test_disk)
bridge = vsxml.set_vbridge(options.ip, default_network_name)
- ret = vsxml.define(options.ip)
+ ret = vsxml.cim_define(options.ip)
if not ret:
logger.error("Failed to define the dom: %s", test_dom)
return FAIL
diff -r 70ecd9e8867c -r 03f56f4d1b8d suites/libvirt-cim/cimtest/EnabledLogicalElementCapabilities/02_elecap_gi_errs.py
--- a/suites/libvirt-cim/cimtest/EnabledLogicalElementCapabilities/02_elecap_gi_errs.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/EnabledLogicalElementCapabilities/02_elecap_gi_errs.py Tue Dec 02 19:02:17 2008 -0800
@@ -92,7 +92,7 @@
else:
test_dom = "qemu"
vsxml = get_class(options.virt)(test_dom)
- ret = vsxml.define(options.ip)
+ ret = vsxml.cim_define(options.ip)
if not ret:
logger.error("Failed to Define the dom: %s", test_dom)
return FAIL
diff -r 70ecd9e8867c -r 03f56f4d1b8d suites/libvirt-cim/cimtest/HostedDependency/01_forward.py
--- a/suites/libvirt-cim/cimtest/HostedDependency/01_forward.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/HostedDependency/01_forward.py Tue Dec 02 19:02:17 2008 -0800
@@ -72,7 +72,7 @@
cxml = virtxml(test_dom)
else:
cxml = virtxml(test_dom, mac = test_mac)
- ret = cxml.define(server)
+ ret = cxml.cim_define(server)
if not ret:
logger.error("Failed to define the dom: %s", test_dom)
status = FAIL
diff -r 70ecd9e8867c -r 03f56f4d1b8d suites/libvirt-cim/cimtest/Memory/03_mem_gi_errs.py
--- a/suites/libvirt-cim/cimtest/Memory/03_mem_gi_errs.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/Memory/03_mem_gi_errs.py Tue Dec 02 19:02:17 2008 -0800
@@ -177,7 +177,7 @@
# Getting the VS list and deleting the test_dom if it already exists.
destroy_and_undefine_all(options.ip)
vsxml = get_class(options.virt)(test_dom, test_mem)
- ret = vsxml.define(options.ip)
+ ret = vsxml.cim_define(options.ip)
if not ret:
logger.error("Failed to Create the dom: %s", test_dom)
return FAIL
16 years
[PATCH] [TEST] Use full_hostname() instead of hostname()
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1228253331 28800
# Node ID ec1b901cf22d440a8461abfe633e8a634ee112ce
# Parent 70ecd9e8867cc277b31f4703e73b5dba7ad53128
[TEST] Use full_hostname() instead of hostname()
This mirrors what the providers use to get the hostname of the system.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 70ecd9e8867c -r ec1b901cf22d suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py
--- a/suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py Tue Dec 02 13:28:51 2008 -0800
@@ -80,7 +80,8 @@
import sys
import pywbem
-from VirtLib import utils, live
+from VirtLib import utils
+from VirtLib.live import full_hostname
from XenKvmLib import assoc
from XenKvmLib import vxml
from XenKvmLib.classes import get_typed_class
@@ -146,7 +147,7 @@
hs = get_typed_class(options.virt, "HostSystem")
cs = get_typed_class(options.virt, "ComputerSystem")
- host_name = live.hostname(options.ip)
+ host_name = full_hostname(options.ip)
host_name_val = [
'CreationClassName', hs, \
'Name', host_name
diff -r 70ecd9e8867c -r ec1b901cf22d suites/libvirt-cim/cimtest/HostSystem/01_enum.py
--- a/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Tue Dec 02 13:28:51 2008 -0800
@@ -28,7 +28,7 @@
import sys
from XenKvmLib import enumclass
from XenKvmLib.classes import get_typed_class
-from VirtLib import live
+from VirtLib.live import full_hostname
from VirtLib import utils
from XenKvmLib.common_util import check_sblim
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
@@ -40,7 +40,7 @@
@do_main(SUPPORTED_TYPES)
def main():
options = main.options
- host = live.hostname(options.ip)
+ host = full_hostname(options.ip)
status = FAIL
keys = ['Name', 'CreationClassName']
diff -r 70ecd9e8867c -r ec1b901cf22d suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py
--- a/suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py Mon Dec 01 22:15:38 2008 -0800
+++ b/suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py Tue Dec 02 13:28:51 2008 -0800
@@ -40,7 +40,7 @@
# Feb 13 2008
import sys
-from VirtLib import live
+from VirtLib.live import full_hostname
from XenKvmLib.common_util import get_host_info
from XenKvmLib.assoc import Associators
from XenKvmLib.vxml import XenXML, KVMXML, get_class
@@ -98,7 +98,7 @@
def get_hostsys(server, virt="Xen"):
status = PASS
- host = live.hostname(server)
+ host = full_hostname(server)
try:
status, host_inst = get_host_info(server, virt)
16 years
[PATCH] [TEST] Add branch to AC for expected pool length
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1228258522 28800
# Node ID 04ee80afcbcb711111d990c771c4427dae2a0256
# Parent ec1b901cf22d440a8461abfe633e8a634ee112ce
[TEST] Add branch to AC for expected pool length.
Also, change the layout of the test so that the flow makes a little more sense.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r ec1b901cf22d -r 04ee80afcbcb suites/libvirt-cim/cimtest/AllocationCapabilities/01_enum.py
--- a/suites/libvirt-cim/cimtest/AllocationCapabilities/01_enum.py Tue Dec 02 13:28:51 2008 -0800
+++ b/suites/libvirt-cim/cimtest/AllocationCapabilities/01_enum.py Tue Dec 02 14:55:22 2008 -0800
@@ -27,28 +27,35 @@
import sys
from XenKvmLib.enumclass import EnumInstances
-from XenKvmLib.const import do_main, platform_sup
+from XenKvmLib.const import do_main, platform_sup, get_provider_version
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
from CimTest.ReturnCodes import PASS, FAIL
from XenKvmLib.common_util import cleanup_restore
from XenKvmLib.classes import get_typed_class
sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
+input_graphics_pool_rev = 757
-def enum_pools_and_ac(ip, ac_cn, p_names):
+def enum_pools(ip, ac_cn, virt):
+ pt = [get_typed_class(virt, 'MemoryPool'),
+ get_typed_class(virt, 'ProcessorPool'),
+ get_typed_class(virt, 'DiskPool'),
+ get_typed_class(virt, 'NetworkPool')]
+
+ curr_cim_rev, changeset = get_provider_version(virt, ip)
+ if curr_cim_rev >= input_graphics_pool_rev:
+ pt.append(get_typed_class(virt, 'GraphicsPool'))
+ pt.append(get_typed_class(virt, 'InputPool'))
+
pools = {}
- ac = []
try:
- ac = EnumInstances(ip, ac_cn)
-
- for p_cn in p_names:
+ for p_cn in pt:
enum_list = EnumInstances(ip, p_cn)
if len(enum_list) < 1:
- logger.error("%s did not return any instances" % p_cn)
- return pools, ac
+ raise Exception("%s did not return any instances" % p_cn)
for pool in enum_list:
pools[pool.InstanceID] = pool
@@ -56,12 +63,13 @@
except Exception, details:
logger.error(CIM_ERROR_ENUMERATE, ac_cn)
logger.error(details)
- return pools, ac
+ return pools, FAIL
- if len(ac) != len(pools):
- logger.error("%s returned %s instances, expected %s" % (ac_cn, len(ac),
- len(pools)))
- return pools, ac
+ if len(pools) < len(pt):
+ logger.error("%d pools returned, exp at least %d", len(pools), len(pt))
+ return pools, FAIL
+
+ return pools, PASS
def compare_pool_to_ac(ac, pools, cn):
try:
@@ -84,17 +92,21 @@
options = main.options
cn = get_typed_class(options.virt, 'AllocationCapabilities')
- pt = [get_typed_class(options.virt, 'MemoryPool'),
- get_typed_class(options.virt, 'ProcessorPool'),
- get_typed_class(options.virt, 'DiskPool'),
- get_typed_class(options.virt, 'NetworkPool'),
- get_typed_class(options.virt, 'GraphicsPool'),
- get_typed_class(options.virt, 'InputPool')]
- pools, ac = enum_pools_and_ac(options.ip, cn, pt)
- if len(pools) < 4:
- logger.error("Only %d pools returned, expected at least 4" % len(pools))
- cleanup_restore(options.ip, options.virt)
+ try:
+ ac = EnumInstances(options.ip, cn)
+
+ except Exception, details:
+ logger.error(CIM_ERROR_ENUMERATE, cn)
+ logger.error(details)
+ return FAIL
+
+ pools, status = enum_pools(options.ip, cn, options.virt)
+ if status != PASS:
+ return status
+
+ if len(ac) != len(pools):
+ logger.error("%d %s insts != %d pool insts" % (len(ac), cn, len(pools)))
return FAIL
status = compare_pool_to_ac(ac, pools, cn)
16 years
[PATCH] [Test] Fix ElementConforms/02_reverse.py with sblim-cmpi-base provider installed
by yunguol@cn.ibm.com
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1228203734 28800
# Node ID 5bd7b6bf455d719006acfb15c3b0bc4859d3f296
# Parent 5fb94ae83ed121d3b0ce54bde7e30175c2df6f70
[Test] Fix ElementConforms/02_reverse.py with sblim-cmpi-base provider installed
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 5fb94ae83ed1 -r 5bd7b6bf455d suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py
--- a/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Wed Nov 26 19:06:58 2008 -0800
+++ b/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Mon Dec 01 23:42:14 2008 -0800
@@ -159,12 +159,13 @@
if status != PASS:
cxml.undefine(server)
return status
-
- status = verify_profile(profs[0], exp_list[cn])
- if status != PASS:
- logger.error("Verification of profile instance failed")
- cxml.undefine(server)
- return FAIL
+
+ if cn != 'Linux_ComputerSystem':
+ status = verify_profile(profs[0], exp_list[cn])
+ if status != PASS:
+ logger.error("Verification of profile instance failed")
+ cxml.undefine(server)
+ return FAIL
except Exception, detail:
logger.error(CIM_ERROR_ASSOCIATORS, an)
16 years
[PATCH] Catch unimplemented sentinel of GetMaxVcpus and be less stupid
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1228245240 28800
# Node ID 03af2846604b1fdc8d1d7fa3aef737f727b0414b
# Parent c9a0e8c2f4e85f9bbdbe1857ac5689e8a8efc909
Catch unimplemented sentinel of GetMaxVcpus and be less stupid
Currently, we stuff the result of GetMaxVcpus into a u64 directly. Since
that function can return -1 for unimplemented (as it does for LXC), we end
up with a ridiculously large number of vcpus as the maximum.
Assuming nothing can run with less than 1 cpu, I think it's a safe default
for this case.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r c9a0e8c2f4e8 -r 03af2846604b src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c Mon Dec 01 13:01:42 2008 -0800
+++ b/src/Virt_SettingsDefineCapabilities.c Tue Dec 02 11:14:00 2008 -0800
@@ -342,6 +342,7 @@
{
bool ret = false;
virConnectPtr conn;
+ int max;
conn = connect_by_classname(_BROKER, CLASSNAME(ref), s);
if (conn == NULL) {
@@ -351,8 +352,14 @@
goto out;
}
- *num_procs = virConnectGetMaxVcpus(conn, NULL);
- CU_DEBUG("libvirt says %d max vcpus", *num_procs);
+ max = virConnectGetMaxVcpus(conn, NULL);
+ if (max == -1) {
+ CU_DEBUG("GetMaxVcpus not supported, assuming 1");
+ *num_procs = 1;
+ } else {
+ *num_procs = max;
+ CU_DEBUG("libvirt says %d max vcpus", *num_procs);
+ }
ret = true;
out:
16 years
[PATCH] [TEST] XFAIL VSSD/04_vssd_to_rasd.py because that libvirt allows the user to specify a mouse with "xen" bus type for LXC
by yunguol@cn.ibm.com
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1227756090 28800
# Node ID 5c0fd365bb73286f3fd447939bb75ed5fb68aba9
# Parent 8807a94aa58a411d8596e717674c91c937881247
[TEST] XFAIL VSSD/04_vssd_to_rasd.py because that libvirt allows the user to specify a mouse with "xen" bus type for LXC
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 8807a94aa58a -r 5c0fd365bb73 suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py
--- a/suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py Mon Nov 24 22:08:51 2008 -0800
+++ b/suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py Wed Nov 26 19:21:30 2008 -0800
@@ -46,7 +46,7 @@
from XenKvmLib import enumclass
from CimTest.Globals import logger, CIM_ERROR_ASSOCIATORS, CIM_ERROR_ENUMERATE
from XenKvmLib.const import do_main
-from CimTest.ReturnCodes import PASS, FAIL
+from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
from XenKvmLib.test_doms import destroy_and_undefine_all
from XenKvmLib import assoc
from XenKvmLib.vxml import get_class
@@ -57,6 +57,7 @@
rasd_init_list, verify_inputrasd_values
from XenKvmLib.const import default_network_name
+libvirt_bug = "00009"
sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
test_dom = "VSSDC_dom"
@@ -193,6 +194,8 @@
status = verify_displayrasd_values(rasd_instance, displayrasd)
elif 'InputResourceAllocationSettingData' in CCName:
status = verify_inputrasd_values(rasd_instance, inputrasd)
+ if status != PASS and virt== 'LXC':
+ return XFAIL_RC(libvirt_bug)
else:
status = FAIL
if status != PASS:
16 years