[PATCH] [TEST] Fix console tty define in LXCXML class
by yunguol@cn.ibm.com
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1216707638 25200
# Node ID 83b3723d0ca969293e28326198a52ada74a8b753
# Parent 3703b7be5a107c67e901546978e974546b3d5562
[TEST] Fix console tty define in LXCXML class
Modified console define as: <console tty='/dev/ptmx'/> instead of <console>/dev/ptmx</console>
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 3703b7be5a10 -r 83b3723d0ca9 suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Jul 16 07:23:32 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon Jul 21 23:20:38 2008 -0700
@@ -710,10 +710,10 @@
os = self.get_node('/domain/os')
self.add_sub_node(os, 'init', os_init)
- def _devices(self, tty):
+ def _devices(self, tty_set):
devices = self.get_node('/domain/devices')
- interface = self.add_sub_node(devices, 'console', tty)
+ interface = self.add_sub_node(devices, 'console', tty = tty_set)
def create_lxc_file(self, ip, lxc_file):
try:
16 years, 5 months
[PATCH] Add ReferenceConfiguration support to VSMS
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1216672093 25200
# Node ID 427e74d2c45881820ee33b8b6cdeb9cff57a68c0
# Parent 542f77ab01389702ff1358f04b0d55c8f052067a
Add ReferenceConfiguration support to VSMS
This accomplishes that goal by doing a full get_dominfo() instead of
a blank dominfo alloc in the event that the client passed in a
ReferenceConfiguration object path.
Also fix a few unchecked calloc() calls while touching them. Also
make sure we're only ever editing the first memory or processor device
in the list, during the domain building process.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 542f77ab0138 -r 427e74d2c458 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Mon Jul 21 09:02:26 2008 -0700
+++ b/src/Virt_VirtualSystemManagementService.c Mon Jul 21 13:28:13 2008 -0700
@@ -68,24 +68,34 @@
static CMPIStatus define_system_parse_args(const CMPIArgs *argsin,
CMPIInstance **sys,
const char *ns,
- CMPIArray **res)
+ CMPIArray **res,
+ CMPIObjectPath **refconf)
{
- CMPIStatus s = {CMPI_RC_ERR_FAILED, NULL};
+ CMPIStatus s = {CMPI_RC_OK, NULL};
if (cu_get_inst_arg(argsin, "SystemSettings", sys) != CMPI_RC_OK) {
CU_DEBUG("No SystemSettings string argument");
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_INVALID_PARAMETER,
+ "Missing argument `SystemSettings'");
goto out;
}
if (cu_get_array_arg(argsin, "ResourceSettings", res) !=
CMPI_RC_OK) {
CU_DEBUG("Failed to get array arg");
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_INVALID_PARAMETER,
+ "Missing argument `ResourceSettings'");
goto out;
}
- cu_statusf(_BROKER, &s,
- CMPI_RC_OK,
- "");
+ if (cu_get_ref_arg(argsin, "ReferenceConfiguration", refconf) !=
+ CMPI_RC_OK) {
+ CU_DEBUG("Did not get ReferenceConfiguration arg");
+ *refconf = NULL;
+ goto out;
+ }
out:
return s;
}
@@ -565,6 +575,20 @@
return msg;
}
+static bool make_space(struct virt_device **list, int cur, int new)
+{
+ struct virt_device *tmp;
+
+ tmp = calloc(cur + new, sizeof(*tmp));
+ if (tmp == NULL)
+ return false;
+
+ memcpy(tmp, *list, sizeof(*tmp) * cur);
+ *list = tmp;
+
+ return true;
+}
+
static const char *classify_resources(CMPIArray *resources,
const char *ns,
struct domain *domain)
@@ -573,17 +597,21 @@
uint16_t type;
int count;
- domain->dev_disk_ct = domain->dev_net_ct = 0;
- domain->dev_vcpu_ct = domain->dev_mem_ct = 0;
-
count = CMGetArrayCount(resources, NULL);
if (count < 1)
return "No resources specified";
- domain->dev_disk = calloc(count, sizeof(struct virt_device));
- domain->dev_vcpu = calloc(count, sizeof(struct virt_device));
- domain->dev_mem = calloc(count, sizeof(struct virt_device));
- domain->dev_net = calloc(count, sizeof(struct virt_device));
+ if (!make_space(&domain->dev_disk, domain->dev_disk_ct, count))
+ return "Failed to alloc disk list";
+
+ if (!make_space(&domain->dev_vcpu, domain->dev_vcpu_ct, count))
+ return "Failed to alloc vcpu list";
+
+ if (!make_space(&domain->dev_mem, domain->dev_mem_ct, count))
+ return "Failed to alloc mem list";
+
+ if (!make_space(&domain->dev_net, domain->dev_net_ct, count))
+ return "Failed to alloc net list";
for (i = 0; i < count; i++) {
CMPIObjectPath *op;
@@ -605,27 +633,29 @@
CMPI_RC_OK)
return "Unable to determine resource type";
- if (type == CIM_RES_TYPE_PROC)
+ if (type == CIM_RES_TYPE_PROC) {
+ domain->dev_vcpu_ct = 1;
msg = rasd_to_vdev(inst,
domain,
- &domain->dev_vcpu[domain->dev_vcpu_ct++],
+ &domain->dev_vcpu[0],
ns);
- else if (type == CIM_RES_TYPE_MEM)
+ } else if (type == CIM_RES_TYPE_MEM) {
+ domain->dev_mem_ct = 1;
msg = rasd_to_vdev(inst,
domain,
- &domain->dev_mem[domain->dev_mem_ct++],
+ &domain->dev_mem[0],
ns);
- else if (type == CIM_RES_TYPE_DISK)
+ } else if (type == CIM_RES_TYPE_DISK) {
msg = rasd_to_vdev(inst,
domain,
&domain->dev_disk[domain->dev_disk_ct++],
ns);
- else if (type == CIM_RES_TYPE_NET)
+ } else if (type == CIM_RES_TYPE_NET) {
msg = rasd_to_vdev(inst,
domain,
&domain->dev_net[domain->dev_net_ct++],
ns);
-
+ }
if (msg != NULL)
return msg;
@@ -722,23 +752,125 @@
return s;
}
+static CMPIStatus match_prefixes(const CMPIObjectPath *a,
+ const CMPIObjectPath *b)
+{
+ char *pfx1;
+ char *pfx2;
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+
+ pfx1 = class_prefix_name(CLASSNAME(a));
+ pfx2 = class_prefix_name(CLASSNAME(b));
+
+ if ((pfx1 == NULL) || (pfx2 == NULL)) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable compare ReferenceConfiguration prefix");
+ goto out;
+ }
+
+ if (!STREQ(pfx1, pfx2)) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_INVALID_CLASS,
+ "ReferenceConfiguration domain is not compatible");
+ goto out;
+ }
+ out:
+ free(pfx1);
+ free(pfx2);
+
+ return s;
+}
+
+static CMPIStatus get_reference_domain(struct domain **domain,
+ const CMPIObjectPath *ref,
+ const CMPIObjectPath *refconf)
+{
+ virConnectPtr conn = NULL;
+ virDomainPtr dom = NULL;
+ const char *name;
+ CMPIStatus s;
+ int ret;
+
+ s = match_prefixes(ref, refconf);
+ if (s.rc != CMPI_RC_OK)
+ return s;
+
+ conn = connect_by_classname(_BROKER, CLASSNAME(refconf), &s);
+ if (conn == NULL) {
+ if (s.rc != CMPI_RC_OK)
+ return s;
+ else {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to connect to libvirt");
+ return s;
+ }
+ }
+
+ if (cu_get_str_path(refconf, "Name", &name) != CMPI_RC_OK) {
+ CU_DEBUG("Missing Name parameter");
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_INVALID_PARAMETER,
+ "Missing `Name' from ReferenceConfiguration");
+ goto out;
+ }
+
+ CU_DEBUG("Referenced domain: %s", name);
+
+ dom = virDomainLookupByName(conn, name);
+ if (dom == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "Referenced domain `%s' does not exist", name);
+ goto out;
+ }
+
+ ret = get_dominfo(dom, domain);
+ if (ret == 0) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Error getting referenced configuration");
+ goto out;
+ }
+
+ /* Scrub the unique bits out of the reference domain config */
+ free((*domain)->name);
+ (*domain)->name = NULL;
+ free((*domain)->uuid);
+ (*domain)->uuid = NULL;
+
+ out:
+ virDomainFree(dom);
+ virConnectClose(conn);
+
+ return s;
+}
+
static CMPIInstance *create_system(CMPIInstance *vssd,
CMPIArray *resources,
const CMPIObjectPath *ref,
+ const CMPIObjectPath *refconf,
CMPIStatus *s)
{
CMPIInstance *inst = NULL;
char *xml = NULL;
const char *msg = NULL;
- struct domain *domain;
+ struct domain *domain = NULL;
- domain = calloc(1, sizeof(*domain));
- if (domain == NULL) {
- cu_statusf(_BROKER, s,
- CMPI_RC_ERR_FAILED,
- "Failed to allocate memory");
- goto out;
+ if (refconf != NULL) {
+ *s = get_reference_domain(&domain, ref, refconf);
+ if (s->rc != CMPI_RC_OK)
+ goto out;
+ } else {
+ domain = calloc(1, sizeof(*domain));
+ if (domain == NULL) {
+ cu_statusf(_BROKER, s,
+ CMPI_RC_ERR_FAILED,
+ "Failed to allocate memory");
+ goto out;
+ }
}
if (!vssd_to_domain(vssd, domain)) {
@@ -795,6 +927,7 @@
const CMPIArgs *argsin,
CMPIArgs *argsout)
{
+ CMPIObjectPath *refconf;
CMPIInstance *vssd;
CMPIInstance *sys;
CMPIArray *res;
@@ -802,11 +935,15 @@
CU_DEBUG("DefineSystem");
- s = define_system_parse_args(argsin, &vssd, NAMESPACE(reference), &res);
+ s = define_system_parse_args(argsin,
+ &vssd,
+ NAMESPACE(reference),
+ &res,
+ &refconf);
if (s.rc != CMPI_RC_OK)
goto out;
- sys = create_system(vssd, res, reference, &s);
+ sys = create_system(vssd, res, reference, refconf, &s);
if (sys == NULL)
goto out;
16 years, 5 months
[PATCH] (#2) Add CMSetObjectPath macro
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1216656146 25200
# Node ID 6e310fe7bde3d3a43740b1d2a155c8503b25bcc7
# Parent ec88dc805bcdc63d30b866e3e527208fa684e274
(#2) Add CMSetObjectPath macro.
This is a work around. SFCB currently doesn't implement CMSetObjectPath, so the VSMS provider seg faults.
Updates:
-Place CMSetObjectPath define in misc_util.h
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r ec88dc805bcd -r 6e310fe7bde3 libxkutil/misc_util.h
--- a/libxkutil/misc_util.h Wed Jul 09 13:48:14 2008 -0700
+++ b/libxkutil/misc_util.h Mon Jul 21 09:02:26 2008 -0700
@@ -33,6 +33,12 @@
#include <libcmpiutil/libcmpiutil.h>
#include <libcmpiutil/std_association.h>
+
+#undef CMSetObjectPath
+#define CMSetObjectPath(i,p) do { \
+ if (i->ft->setObjectPath != NULL) \
+ i->ft->setObjectPath(i, p); \
+ } while (0);
/* Check if the provider is reponsible for the given class:
* e.g. Xen is running on the system and KVM_... is asked for,
16 years, 5 months
[PATCH] [TEST] Fix potiential false positive in CS 02
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1215718772 25200
# Node ID 0a4bc49a1fbde309070f8cc4c8631cf4a5ad9c68
# Parent c09b0a978a6621139eb355079994ba3eb2847779
[TEST] Fix potiential false positive in CS 02.
Also make it so that the test skips if domain_list() returns anything > 0.
This test used to be a Xen only test, so the test was only being run if there were no other guests besides Dom0. However, CS EnumInstances treats Dom0 as any other guest, so it only makes sense to run this test on KVM and LXC.
If computersystem.enumerate() encounters an exception, raise an exception so that the calling test case fail appropriately. We could return FAIL in this case, but raising an exception is more descriptive. Also, other tests that call computersystem.enumerate() don't need to be modified because the number of arguments returned doesn't change.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r c09b0a978a66 -r 0a4bc49a1fbd suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py Thu Jul 10 11:48:13 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py Thu Jul 10 12:39:32 2008 -0700
@@ -27,7 +27,7 @@
from XenKvmLib import computersystem
from VirtLib import live
from VirtLib import utils
-from CimTest.Globals import logger
+from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
from CimTest.Globals import do_main
from CimTest.ReturnCodes import PASS, FAIL, SKIP
@@ -35,7 +35,7 @@
def clean_system(host, virt):
l = live.domain_list(host, virt)
- if len(l) > 1:
+ if len(l) > 0:
return False
else:
return True
@@ -43,19 +43,31 @@
@do_main(sup_types)
def main():
options = main.options
- if not clean_system(options.ip, options.virt):
+
+ rc = clean_system(options.ip, options.virt)
+
+ if options.virt == "Xen" or options.virt == "XenFV" and rc is True:
+ logger.error("System has no Dom0 defined; check system health")
+ return FAIL
+ elif rc is False:
logger.error("System has defined domains; unable to run")
return SKIP
- status = PASS
+ cn = "%s_ComputerSystem" % options.virt
- cs = computersystem.enumerate(options.ip, options.virt)
+ try:
+ cs = computersystem.enumerate(options.ip, options.virt)
- if cs.__class__ == str:
- logger.error("Got error instead of empty list: %s" % cs)
+ except Exception, details:
+ logger.error(CIM_ERROR_ENUMERATE, cn)
+ logger.error(details)
+ return FAIL
+
+ if len(cs) != 0:
+ logger.error("%s returned %d instead of empty list" % (cn, len(cs)))
status = FAIL
- return status
+ return PASS
if __name__ == "__main__":
sys.exit(main())
diff -r c09b0a978a66 -r 0a4bc49a1fbd suites/libvirt-cim/lib/XenKvmLib/computersystem.py
--- a/suites/libvirt-cim/lib/XenKvmLib/computersystem.py Thu Jul 10 11:48:13 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/computersystem.py Thu Jul 10 12:39:32 2008 -0700
@@ -85,7 +85,7 @@
try:
instances = conn.EnumerateInstances(classname)
except pywbem.CIMError, arg:
- print arg[1]
+ raise Exception(arg[1])
return []
list = []
16 years, 5 months
[PATCH] [TEST] Enabling 02_reverse.py with XenFV, KVM, LXC and modified logicaldevices.py to work for all virt types
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1216384179 25200
# Node ID f8f6995ce08915d738d82600b15559c81fc40095
# Parent 3703b7be5a107c67e901546978e974546b3d5562
[TEST] Enabling 02_reverse.py with XenFV, KVM, LXC and modified logicaldevices.py to work for all virt types.
Changes:
-------
1) Removed unnecessary import statements.
2) Updated verify_proc_values, verify_mem_values, verify_net_values, verify_disk_values function of logicaldevices to work with all virt types.
3) Used verify_proc_values, verify_mem_values, verify_net_values, verify_disk_values fn.
4) Removed conf_file(), clean_up_restore(), get_or_bail(), print_error(), init_list(), get_spec_fields_list(), assoc_values() fns.
5) Removed global status variable.
6) Added verify_eafp_values(), init_pllist(), create_diskpool_conf() fn.
7) Included create_diskpool_conf(), cleanup_restore() fn.
Tested on KVM on rpm, KVM current sources, LXC, XenFV, Xen.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 3703b7be5a10 -r f8f6995ce089 suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py Wed Jul 16 07:23:32 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py Fri Jul 18 05:29:39 2008 -0700
@@ -20,9 +20,8 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-
# This tc is used to verify the classname, InstanceID and certian prop are
-# are appropriately set for the domains when verified using the
+# appropriately set for the domains when verified using the
# Xen_ElementAllocatedFromPool asscoiation.
#
# Example command for LogicalDisk w.r.t to Xen_ElementAllocatedFromPool \
@@ -47,111 +46,80 @@
import sys
import os
-from distutils.file_util import move_file
import pywbem
-from VirtLib import utils
-from VirtLib import live
-from XenKvmLib import assoc
-from XenKvmLib import enumclass
-from CimTest import Globals
-from CimTest.Globals import do_main
-from CimTest.ReturnCodes import PASS, FAIL, SKIP
-from XenKvmLib.test_xml import testxml_bridge
-from XenKvmLib.test_doms import test_domain_function, destroy_and_undefine_all
-from VirtLib.live import network_by_bridge
+from XenKvmLib.assoc import Associators
+from XenKvmLib.vxml import get_class
+from CimTest.Globals import do_main, logger, CIM_ERROR_ASSOCIATORS
+from CimTest.ReturnCodes import PASS, FAIL
+from XenKvmLib.test_doms import destroy_and_undefine_all
+from XenKvmLib.classes import get_typed_class
+from XenKvmLib.common_util import create_diskpool_conf, cleanup_restore
+from XenKvmLib.logicaldevices import verify_proc_values, verify_mem_values, \
+verify_net_values, verify_disk_values
-sup_types = ['Xen']
+sup_types = ['Xen' , 'KVM', 'XenFV', 'LXC']
-status = PASS
-test_dom = "hd_domain"
+test_dom = "eafp_domain"
test_mac = "00:11:22:33:44:aa"
test_mem = 128
test_vcpus = 4
-test_disk = "xvdb"
-test_dpath = "foo"
-disk_file = '/tmp/diskpool.conf'
-back_disk_file = disk_file + "." + "02_reverse"
-diskid = "%s/%s" % ("DiskPool", test_dpath)
-memid = "%s/%s" % ("MemoryPool", 0)
-procid = "%s/%s" % ("ProcessorPool", 0)
-def conf_file():
- """
- Creating diskpool.conf file.
- """
- try:
- f = open(disk_file, 'w')
- f.write('%s %s' % (test_dpath, '/'))
- f.close()
- except Exception,detail:
- Globals.logger.error("Exception: %s", detail)
- status = SKIP
- sys.exit(status)
+def init_pllist(virt, vsxml, diskid):
+ keys = {
+ 'MemoryPool' : 'MemoryPool/0',
+ }
+ if virt != 'LXC':
+ virt_network = vsxml.xml_get_net_network()
+ keys['DiskPool'] = diskid
+ keys['ProcessorPool'] = 'ProcessorPool/0'
+ keys['NetworkPool'] = 'NetworkPool/%s' %virt_network
-def clean_up_restore(ip):
- """
- Restoring back the original diskpool.conf
- file.
- """
- try:
- if os.path.exists(back_disk_file):
- os.remove(disk_file)
- move_file(back_disk_file, disk_file)
- except Exception, detail:
- Globals.logger.error("Exception: %s", detail)
- status = SKIP
- ret = test_domain_function(test_dom, ip, \
- cmd = "destroy")
- sys.exit(status)
-
+ pllist = { }
+ for cn, k in keys.iteritems():
+ cn = get_typed_class(virt, cn)
+ pllist[cn] = k
-def get_or_bail(ip, id, pool_class):
- """
- Getinstance for the CLass and return instance on success, otherwise
- exit after cleanup_restore and destroying the guest.
- """
- key_list = { 'InstanceID' : id }
- try:
- instance = enumclass.getInstance(ip, pool_class, key_list)
- except Exception, detail:
- Globals.logger.error(Globals.CIM_ERROR_GETINSTANCE, '%s', pool_class)
- Globals.logger.error("Exception: %s", detail)
- clean_up_restore(ip)
- status = FAIL
- ret = test_domain_function(test_dom, ip, \
- cmd = "destroy")
- sys.exit(status)
- return instance
+ return pllist
-def print_error(field, ret_val, req_val):
- Globals.logger.error("%s Mismatch", field)
- Globals.logger.error("Returned %s instead of %s", ret_val, req_val)
+def eafp_list(virt, test_disk):
+ mcn = get_typed_class(virt, "Memory")
+ mem = {
+ 'SystemName' : test_dom,
+ 'CreationClassName' : mcn,
+ 'DeviceID' : "%s/%s" % (test_dom, "mem"),
+ 'NumberOfBlocks' : test_mem * 1024
+ }
-def init_list(ip, disk, mem, net, proc):
- """
- Creating the lists that will be used for comparisons.
- """
+ eaf_values = { mcn : mem }
- pllist = {
- "Xen_DiskPool" : disk.InstanceID, \
- "Xen_MemoryPool" : mem.InstanceID, \
- "Xen_NetworkPool" : net.InstanceID, \
- "Xen_ProcessorPool": proc.InstanceID
- }
- cllist = [
- "Xen_LogicalDisk", \
- "Xen_Memory", \
- "Xen_NetworkPort", \
- "Xen_Processor"
- ]
- prop_list = ["%s/%s" % (test_dom, test_disk), test_disk, \
- "%s/%s" % (test_dom, "mem"), test_mem, \
- "%s/%s" % (test_dom, test_mac), test_mac
- ]
- proc_prop = []
- for i in range(test_vcpus):
- proc_prop.append("%s/%s" % (test_dom, i))
- return pllist, cllist, prop_list, proc_prop
+ if virt != 'LXC':
+ dcn = get_typed_class(virt, "LogicalDisk")
+ pcn = get_typed_class(virt, "Processor")
+ ncn = get_typed_class(virt, "NetworkPort")
+
+ disk = {
+ 'SystemName' : test_dom,
+ 'CreationClassName' : dcn,
+ 'DeviceID' : "%s/%s" % (test_dom, test_disk),
+ 'Name' : test_disk
+ }
+ proc = {
+ 'SystemName' : test_dom,
+ 'CreationClassName' : pcn,
+ 'DeviceID' : None
+ }
+ net = {
+ 'SystemName' : test_dom,
+ 'CreationClassName' : ncn,
+ 'DeviceID' : "%s/%s" % (test_dom, test_mac),
+ 'NetworkAddresses' : test_mac
+ }
+
+ eaf_values[pcn] = proc
+ eaf_values[dcn] = disk
+ eaf_values[ncn] = net
+
+ return eaf_values
def get_inst_for_dom(assoc_val):
list = []
@@ -162,196 +130,87 @@ def get_inst_for_dom(assoc_val):
return list
-def get_spec_fields_list(inst_list, field_name):
- global status
- specific_fields = { }
- if (len(inst_list)) != 1:
- Globals.logger.error("Got %s record for Memory/Network/LogicalDisk instead of \
-1", len(inst_list))
- status = FAIL
- return
-# verifying the Name field for LogicalDisk
- try:
- if inst_list[0]['CreationClassName'] != 'Xen_Memory':
- field_value = inst_list[0][field_name]
- if field_name == 'NetworkAddresses':
-# For network we NetworkAddresses is a list of addresses, since we
-# are assigning only one address we are taking field_value[0]
- field_value = field_value[0]
- else:
- field_value = ((int(inst_list[0]['NumberOfBlocks'])*4096)/1024)
- specific_fields = {
- "field_name" : field_name,\
- "field_value" : field_value
- }
- except Exception, detail:
- Globals.logger.error("Exception in get_spec_fields_list(): %s", detail)
- status = FAIL
- return specific_fields
+def verify_eafp_values(server, virt, in_pllist, test_disk):
+ # Looping through the in_pllist to get association for various pools.
+ eafp_values = eafp_list(virt, test_disk)
+ an = get_typed_class(virt, "ElementAllocatedFromPool")
+ for cn, instid in sorted(in_pllist.iteritems()):
+ try:
+ assoc_info = Associators(server, an, cn, virt, InstanceID = instid)
+ assoc_inst_list = get_inst_for_dom(assoc_info)
+ if len(assoc_inst_list) < 1 :
+ logger.error("'%s' with '%s' did not return any records for"
+ " domain: '%s'", an, cn, test_dom)
+ return FAIL
-def assoc_values(assoc_list, field , list, index, specific_fields_list=""):
- """
- Verifying the records retruned by the associations.
- """
- global status
- if field == "CreationClassName":
- for i in range(len(assoc_list)):
- if assoc_list[i][field] != list[index]:
- print_error(field, assoc_list[i][field], list[index])
+ assoc_eafp_info = assoc_inst_list[0]
+ CCName = assoc_eafp_info['CreationClassName']
+ if CCName == get_typed_class(virt, 'Processor'):
+ if len(assoc_inst_list) != test_vcpus:
+ logger.error("'%s' should have returned '%i' Processor"
+ " details, got '%i'", an, test_vcpus,
+ len(assoc_inst_list))
+ return FAIL
+ for i in range(test_vcpus):
+ eafp_values[CCName]['DeviceID'] = "%s/%s" % (test_dom,i)
+ status = verify_proc_values(assoc_inst_list[i],
+ eafp_values, virt)
+ elif CCName == get_typed_class(virt, 'NetworkPort'):
+ status = verify_net_values(assoc_eafp_info, eafp_values, virt)
+ elif CCName == get_typed_class(virt, 'LogicalDisk'):
+ status = verify_disk_values(assoc_eafp_info, eafp_values, virt)
+ elif CCName == get_typed_class(virt, 'Memory'):
+ status = verify_mem_values(assoc_eafp_info, eafp_values, virt)
+ else:
status = FAIL
if status != PASS:
break
- elif field == "DeviceID":
- if assoc_list[0]['CreationClassName'] == 'Xen_Processor':
-# Verifying the list of DeviceId returned by the association
-# against the list created intially .
- for i in range(len(list)):
- if assoc_list[i]['DeviceID'] != list[i]:
- print_error(field, assoc_list[i]['DeviceID'], list[i])
- status = FAIL
- else:
-# Except for Xen_Processor, we get only once record for a domain for
-# other classes.
- if assoc_list[0]['DeviceID'] != list[index]:
- print_error(field, assoc_list[0]['DeviceID'] , list[index])
- status = FAIL
- else:
- # other specific fields verification
- if assoc_list[0]['CreationClassName'] != 'Xen_Processor':
- spec_field_name = specific_fields_list['field_name']
- spec_field_value = specific_fields_list['field_value']
- if spec_field_value != list[index]:
- print_error(field, spec_field_value, list[index])
- status = FAIL
-
+ except Exception, detail:
+ logger.error(CIM_ERROR_ASSOCIATORS, an)
+ logger.error("Exception: %s", detail)
+ status = FAIL
+ return status
@do_main(sup_types)
def main():
options = main.options
- global status
loop = 0
server = options.ip
- destroy_and_undefine_all(options.ip)
- test_xml, bridge = testxml_bridge(test_dom, mem = test_mem, vcpus = test_vcpus, \
- mac = test_mac, disk = test_disk, server = options.ip)
- if bridge == None:
- Globals.logger.error("Unable to find virtual bridge")
- return SKIP
+ virt = options.virt
+ if virt == 'Xen':
+ test_disk = 'xvdb'
+ else:
+ test_disk = 'hda'
- if test_xml == None:
- Globals.logger.error("Guest xml was not created properly")
+ # Getting the VS list and deleting the test_dom if it already exists.
+ destroy_and_undefine_all(server)
+ virt_type = get_class(virt)
+ if virt == 'LXC':
+ vsxml = virt_type(test_dom, vcpus = test_vcpus)
+ else:
+ vsxml = virt_type(test_dom, mem = test_mem, vcpus = test_vcpus,
+ mac = test_mac, disk = test_disk)
+
+ # Verify DiskPool on machine
+ status, diskid = create_diskpool_conf(server, virt)
+ if status != PASS:
+ return status
+
+ ret = vsxml.create(server)
+ if not ret:
+ logger.error("Failed to Create the dom: '%s'", test_dom)
return FAIL
- virt_network = network_by_bridge(bridge, server)
- if virt_network == None:
- Globals.logger.error("No virtual network found for bridge %s", bridge)
- return SKIP
+ # Get pool list against which the EAFP should be queried
+ pllist = init_pllist(virt, vsxml, diskid)
- ret = test_domain_function(test_xml, server, cmd = "create")
- if not ret:
- Globals.logger.error("Failed to Create the dom: %s", test_dom)
- return FAIL
+
+ status = verify_eafp_values(server, virt, pllist, test_disk)
+ vsxml.destroy(server)
+ cleanup_restore(server, virt)
+ return status
- # Taking care of already existing diskconf file
- # Creating diskpool.conf if it does not exist
- # Otherwise backing up the prev file and create new one.
- os.system("rm -f %s" % back_disk_file )
- if not (os.path.exists(disk_file)):
- conf_file()
- else:
- move_file(disk_file, back_disk_file)
- conf_file()
- try :
- disk = get_or_bail(server, id=diskid, \
- pool_class=enumclass.Xen_DiskPool)
- mem = get_or_bail(server, id = memid, \
- pool_class=enumclass.Xen_MemoryPool)
- netid = "%s/%s" % ("NetworkPool", virt_network)
- net = get_or_bail(server, id = netid, \
- pool_class=enumclass.Xen_NetworkPool)
- proc = get_or_bail(server, id = procid, \
- pool_class=enumclass.Xen_ProcessorPool)
-
- except Exception, detail:
- Globals.logger.error("Exception: %s", detail)
- clean_up_restore(server)
- status = FAIL
- ret = test_domain_function(test_dom, server, \
- cmd = "destroy")
- return status
-
- pllist, cllist, prop_list, proc_prop = init_list(server, disk, mem, net, proc)
-
-# Looping through the pllist to get association for various pools.
- for cn, instid in sorted(pllist.items()):
- try:
- assoc_info = assoc.Associators(server, \
- "Xen_ElementAllocatedFromPool", \
- cn, \
- InstanceID = instid)
-# Verifying the Creation Class name for all the records returned for each
-# pool class queried
- inst_list = get_inst_for_dom(assoc_info)
- if (len(inst_list)) == 0:
- Globals.logger.error("Association did not return any records for \
-the specified domain: %s", test_dom)
- status = FAIL
- break
-
- assoc_values(assoc_list=inst_list, field="CreationClassName", \
- list=cllist, \
- index=loop)
-# verifying the DeviceID
- if inst_list[0]['CreationClassName'] == 'Xen_Processor':
-# The DeviceID for the processor varies from 0 to (vcpu - 1 )
- list_index = 0
- assoc_values(assoc_list=inst_list, field="DeviceID", \
- list=proc_prop, \
- index=list_index)
- else:
-# For LogicalDisk, Memory and NetworkPort
- if inst_list[0]['CreationClassName'] == 'Xen_LogicalDisk':
- list_index = 0
- elif inst_list[0]['CreationClassName'] == 'Xen_Memory':
- list_index = 2
- else:
- list_index = 4 # NetworkPort
- assoc_values(assoc_list=inst_list, field="DeviceID", \
- list=prop_list, \
- index=list_index)
- if inst_list[0]['CreationClassName'] == 'Xen_LogicalDisk':
-# verifying the Name field for LogicalDisk
- specific_fields = get_spec_fields_list(inst_list,field_name="Name")
- list_index = 1
- elif inst_list[0]['CreationClassName'] == 'Xen_Memory':
-# verifying the NumberOfBlocks allocated for Memory
- specific_fields = get_spec_fields_list(inst_list,field_name="NumberOfBlocks")
- list_index = 3
- else:
-# verifying the NetworkAddresses for the NetworkPort
- specific_fields = get_spec_fields_list(inst_list,field_name="NetworkAddresses")
- list_index = 5 # NetworkPort
- assoc_values(assoc_list=inst_list, field="Other", \
- list=prop_list, \
- index=list_index, \
- specific_fields_list=specific_fields)
- if status != PASS:
- break
- else:
-# The loop variable is used to index the cllist to verify the creationclassname
- loop = loop + 1
- except Exception, detail:
- Globals.logger.error(Globals.CIM_ERROR_ASSOCIATORS, \
- 'Xen_ElementAllocatedFromPool')
- Globals.logger.error("Exception: %s", detail)
- clean_up_restore(server)
- status = FAIL
-
- ret = test_domain_function(test_dom, server, \
- cmd = "destroy")
- clean_up_restore(server)
- return status
if __name__ == "__main__":
sys.exit(main())
diff -r 3703b7be5a10 -r f8f6995ce089 suites/libvirt-cim/lib/XenKvmLib/logicaldevices.py
--- a/suites/libvirt-cim/lib/XenKvmLib/logicaldevices.py Wed Jul 16 07:23:32 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/logicaldevices.py Fri Jul 18 05:29:39 2008 -0700
@@ -23,6 +23,7 @@ import os
import os
from CimTest.Globals import logger
from CimTest.ReturnCodes import PASS, FAIL, SKIP
+from XenKvmLib.vxml import get_typed_class
# The list_values that is passed should be of the type ..
# disk = {
@@ -53,8 +54,9 @@ def spec_err(fieldvalue, field_list, fie
logger.error("%s Mismatch", fieldname)
logger.error("Returned %s instead of %s", fieldvalue, field_list[fieldname])
-def verify_proc_values(assoc_info, list_values):
- proc_values = list_values['Xen_Processor']
+def verify_proc_values(assoc_info, list_values, virt='Xen'):
+ cn = get_typed_class(virt, 'Processor')
+ proc_values = list_values[cn]
if assoc_info['CreationClassName'] != proc_values['CreationClassName']:
field_err(assoc_info, proc_values, fieldname = 'CreationClassName')
return FAIL
@@ -67,8 +69,9 @@ def verify_proc_values(assoc_info, list_
return FAIL
return PASS
-def verify_mem_values(assoc_info, list_values):
- mem_values = list_values['Xen_Memory']
+def verify_mem_values(assoc_info, list_values, virt='Xen'):
+ cn = get_typed_class(virt, 'Memory')
+ mem_values = list_values[cn]
if assoc_info['CreationClassName'] != mem_values['CreationClassName']:
field_err(assoc_info, mem_values, fieldname = 'CreationClassName')
return FAIL
@@ -85,8 +88,9 @@ def verify_mem_values(assoc_info, list_v
return FAIL
return PASS
-def verify_net_values(assoc_info, list_values):
- net_values = list_values['Xen_NetworkPort']
+def verify_net_values(assoc_info, list_values, virt='Xen'):
+ cn = get_typed_class(virt, 'NetworkPort')
+ net_values = list_values[cn]
if assoc_info['CreationClassName'] != net_values['CreationClassName']:
field_err(assoc_info, net_values, fieldname = 'CreationClassName')
return FAIL
@@ -97,16 +101,17 @@ def verify_net_values(assoc_info, list_v
if sysname != net_values['SystemName']:
spec_err(sysname, net_values, fieldname = 'SystemName')
return FAIL
-# We are assinging only one mac address and hence we expect only one
-# address in the list
+ # We are assinging only one mac address and hence we expect only one
+ # address in the list
netadd = assoc_info['NetworkAddresses'][0]
if netadd != net_values['NetworkAddresses']:
spec_err(netadd, net_values, fieldname = 'NetworkAddresses')
return FAIL
return PASS
-def verify_disk_values(assoc_info, list_values):
- disk_values = list_values['Xen_LogicalDisk']
+def verify_disk_values(assoc_info, list_values, virt='Xen'):
+ cn = get_typed_class(virt, 'LogicalDisk')
+ disk_values = list_values[cn]
if assoc_info['CreationClassName'] != disk_values['CreationClassName']:
field_err(assoc_info, disk_values, fieldname = 'CreationClassName')
return FAIL
16 years, 5 months
[PATCH] Add CMSetObjectPath macro
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1216418936 25200
# Node ID abbc6e3b451614f7bd2965f95d70b6695ad25968
# Parent ec88dc805bcdc63d30b866e3e527208fa684e274
Add CMSetObjectPath macro.
This is a work around. SFCB currently doesn't implement CMSetObjectPath, so the VSMS provider seg faults.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r ec88dc805bcd -r abbc6e3b4516 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Wed Jul 09 13:48:14 2008 -0700
+++ b/src/Virt_VirtualSystemManagementService.c Fri Jul 18 15:08:56 2008 -0700
@@ -58,6 +58,12 @@
#define DEFAULT_XEN_WEIGHT 1024
const static CMPIBroker *_BROKER;
+
+#undef CMSetObjectPath
+#define CMSetObjectPath(i,p) do { \
+ if (i->ft->setObjectPath != NULL) \
+ i->ft->setObjectPath(i, p); \
+ } while (0);
enum ResourceAction {
RESOURCE_ADD,
16 years, 5 months
Look for offical realease of libvirt-cim
by 072021096
Hi, everyone
Because I am at school,so I can not log on to the FTP of libvirt.org, so I can not get the offical realease of libvirt-cim, and I can only get the versions with bugs, is there another way to get a offical realease tarball libvirt-cim?
Thank you all respectful engineers for your previous kind reply and you really help me solve a lot problems!
Best Wishes!
Sean_Ggz from China
16 years, 5 months
problem for
by 072021096
Hi,everyone
I got another problem, When i compile the libvirt-cim, it said that i have not installed libcmpiutil package, but i have installed infact. maybe i have to install the libcmpiutil-devel but i can not find it in the libvirt.org website, and other resources are all rpm for fc9, i uses centOS. so, what should i do!
Thank you all!
Best wishes!
Sean_Ggz
16 years, 5 months
[PATCH] [TEST] Fix potiential false positive in AC 01
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1215715693 25200
# Node ID c09b0a978a6621139eb355079994ba3eb2847779
# Parent 502dddef8c34eeb85b571df0ee97f0ee0676861b
[TEST] Fix potiential false positive in AC 01.
This test needs to verify enum of AC returns the same number of instances as the number of instances returned by enum of MemoryPool + ProcessorPool + DiskPool + NetworkPool.
Also, cleaned up the logic to verify that the ResourceType and the InstanceIDs of the AC instances match the Pool instances they're describing.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 502dddef8c34 -r c09b0a978a66 suites/libvirt-cim/cimtest/AllocationCapabilities/01_enum.py
--- a/suites/libvirt-cim/cimtest/AllocationCapabilities/01_enum.py Tue Jul 01 14:12:48 2008 -0700
+++ b/suites/libvirt-cim/cimtest/AllocationCapabilities/01_enum.py Thu Jul 10 11:48:13 2008 -0700
@@ -22,6 +22,7 @@
#
import sys
+from VirtLib.live import virsh_version
from XenKvmLib import enumclass
from CimTest.Globals import do_main
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, platform_sup
@@ -32,48 +33,52 @@
def main():
options = main.options
+ cn = 'AllocationCapabilities'
+
pools = {}
pt = ['MemoryPool', 'ProcessorPool', 'DiskPool', 'NetworkPool']
try:
- key_list = ["InstanceID"]
- ac = enumclass.enumerate(options.ip,
- "AllocationCapabilities",
- key_list,
- options.virt)
- pools['MemoryPool'] = enumclass.enumerate(options.ip,
- "MemoryPool",
- key_list,
- options.virt)
- pools['ProcessorPool'] = enumclass.enumerate(options.ip,
- "ProcessorPool",
- key_list,
- options.virt)
- pools['DiskPool'] = enumclass.enumerate(options.ip,
- "DiskPool",
- key_list,
- options.virt)
- pools['NetworkPool'] = enumclass.enumerate(options.ip,
- "NetworkPool",
- key_list,
- options.virt)
- except Exception:
- logger.error(CIM_ERROR_ENUMERATE, '%s_AllocationCapabilities' % options.virt)
+ key = ["InstanceID"]
+ ac = enumclass.enumerate(options.ip, cn, key, options.virt)
+
+ for p in pt:
+ enum_list = enumclass.enumerate(options.ip, p, key, options.virt)
+
+ if len(enum_list) < 1:
+ # If libvirt version >= 0.4.1, libvirt-cim uses libvirt's
+ # disk pool support instead of creating its own diskpool.
+ # In this case, it's possible for a disk pool to not exist.
+ libvirt_version = virsh_version(options.ip, options.virt)
+ if p == "DiskPool" and libvirt_version >= '0.4.1':
+ continue
+
+ logger.error("%s did not return any instances" % p)
+ return FAIL
+
+ for pool in enum_list:
+ pools[pool.InstanceID] = pool
+
+ except Exception, details:
+ logger.error(CIM_ERROR_ENUMERATE, cn)
+ logger.error(details)
return FAIL
- acset = set([(x.InstanceID, x.ResourceType) for x in ac])
- poolset = set()
- for pl in pools.values():
- for x in pl:
- poolset.add((x.InstanceID, x.ResourceType))
+ if len(ac) != len(pools):
+ logger.error("%s returned %s instances, expected %s" % (cn, len(ac),
+ len(pools)))
+ return FAIL
- if len(acset) != len(poolset):
- logger.error(
- 'AllocationCapabilities return %i instances, excepted %i'
- % (ac_size, pool_size))
- return FAIL
- zeroset = acset - poolset
- if len(zeroset) != 0:
- logger.error('AC is inconsistent with pools')
+ try:
+ for inst in ac:
+ id = inst.InstanceID
+ if pools[id].ResourceType != inst.ResourceType:
+ logger.error("%s ResourceType %s, Pool ResourceType %s" % (cn,
+ inst.ResourceType, pools[id].ResourceType))
+ return FAIL
+
+ except Exception, details:
+ logger.error("%s returned instance with unexpected InstanceID %s" % (cn,
+ details))
return FAIL
return PASS
16 years, 5 months
[PATCH] Persist RequestedState in infostore
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1216390592 25200
# Node ID 18eab14c82590e3a31ec1fa2f789173061ddca97
# Parent ec88dc805bcdc63d30b866e3e527208fa684e274
Persist RequestedState in infostore
This allows the ComputerSystem object to correctly expose the state last
requested in addition to the actual current state.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r ec88dc805bcd -r 18eab14c8259 src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c Wed Jul 09 13:48:14 2008 -0700
+++ b/src/Virt_ComputerSystem.c Fri Jul 18 07:16:32 2008 -0700
@@ -237,9 +237,11 @@
int ret;
uint16_t cim_state;
uint16_t health_state;
+ uint16_t req_state;
uint16_t op_status;
CMPIArray *array;
CMPIStatus s;
+ struct infostore_ctx *infostore = NULL;
ret = virDomainGetInfo(dom, &info);
if (ret != 0)
@@ -262,6 +264,17 @@
CMSetProperty(instance, "OperationalStatus",
(CMPIValue *)&array, CMPI_uint16A);
+
+ infostore = infostore_open(dom);
+ if (infostore != NULL)
+ req_state = (uint16_t)infostore_get_u64(infostore, "reqstate");
+ else
+ req_state = CIM_STATE_UNKNOWN;
+
+ CMSetProperty(instance, "RequestedState",
+ (CMPIValue *)&req_state, CMPI_uint16);
+
+ infostore_close(infostore);
return 1;
}
@@ -809,6 +822,7 @@
virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
virDomainInfo info;
+ struct infostore_ctx *infostore = NULL;
conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
if (conn == NULL)
@@ -843,6 +857,12 @@
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_NOT_SUPPORTED,
"State not supported");
+
+ infostore = infostore_open(dom);
+ if (infostore != NULL) {
+ infostore_set_u64(infostore, "reqstate", (uint64_t)state);
+ infostore_close(infostore);
+ }
out:
virDomainFree(dom);
16 years, 5 months