Failed to create a KVM guest with real image
by Guo Lian Yun
Hi,
I try to create a domain with real image in VT machine with RedHat 5 host
system, but report error with following:
virsh # start kvm
libvir: QEMU error : internal error QEMU quit during console startup
error: Failed to start domain kvm
Here is the xml config.
<domain
type="kvm"><name>kvm</name><uuid>66cd875c-62ab-11dd-b113-0011259da336</uuid><os><type>hvm</type></os><memory>131072</memory><vcpu>1</vcpu><on_poweroff>destroy</on_poweroff><on_reboot>restart</on_reboot><on_crash>destroy</on_crash><devices><emulator>/usr/bin/qemu</emulator><disk
device="disk" type="file"><source
file="/var/lib/xen/images/sles10.img"/><target
dev="hda"/></disk><interface type="network"><mac
address="11:22:33:aa:bb:cc"/><source
network="default"/></interface></devices></domain>
Who knows why this fails for me?
Thanks!
Best,
Regards
Daisy (运国莲)
VSM Team, China Systems & Technology Labs (CSTL)
E-mail: yunguol(a)cn.ibm.com
TEL: (86)-21-60922403
Building 10, 399 Ke Yuan Rd, Pudong Shanghai, 201203
16 years, 4 months
[PATCH] Make infostore compare the UUID of the domain to the one stored in the
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1217871367 25200
# Node ID 91cffef5e2cbb19f956e2969aacfd3fdab0d30b7
# Parent 3386917656ad569e226a846eea28793ecd852d0b
Make infostore compare the UUID of the domain to the one stored in the
store file, and if different, ignore all the information therein.
This should make sure that if a domain is undefined and redefined with
the same name, using other libvirt tools, the settings previously persisted
by the providers will not be used for the new domain.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 3386917656ad -r 91cffef5e2cb libxkutil/infostore.c
--- a/libxkutil/infostore.c Mon Aug 04 10:28:30 2008 -0700
+++ b/libxkutil/infostore.c Mon Aug 04 10:36:07 2008 -0700
@@ -24,6 +24,7 @@
#include <unistd.h>
#include <inttypes.h>
#include <sys/file.h>
+#include <string.h>
#include <libvirt/libvirt.h>
#include <libxml/parser.h>
@@ -164,7 +165,7 @@
return size >= 0;
}
-struct infostore_ctx *infostore_open(virDomainPtr dom)
+static struct infostore_ctx *_infostore_open(virDomainPtr dom)
{
struct infostore_ctx *isc;
struct stat s;
@@ -228,6 +229,58 @@
free(filename);
return NULL;
+}
+
+static struct infostore_ctx *delete_and_open(virDomainPtr dom)
+{
+ char *filename = NULL;
+
+ filename = make_filename(dom);
+ if (filename == NULL) {
+ CU_DEBUG("Failed to make filename for domain");
+ return NULL;
+ }
+
+ if (unlink(filename) != 0) {
+ CU_DEBUG("Unable to delete %s: %m", filename);
+ } else {
+ CU_DEBUG("Deleted %s", filename);
+ }
+
+ free(filename);
+
+ return _infostore_open(dom);
+}
+
+struct infostore_ctx *infostore_open(virDomainPtr dom)
+{
+ struct infostore_ctx *isc;
+ char uuid[VIR_UUID_STRING_BUFLEN];
+ char *_uuid = NULL;
+
+ isc = _infostore_open(dom);
+ if (isc == NULL)
+ return NULL;
+
+ if (virDomainGetUUIDString(dom, uuid) != 0) {
+ CU_DEBUG("Failed to get UUID string for comparison");
+ infostore_close(isc);
+ isc = delete_and_open(dom);
+ return isc;
+ }
+
+ _uuid = infostore_get_str(isc, "uuid");
+ if (_uuid == NULL)
+ goto out;
+
+ if (!STREQ(uuid, _uuid)) {
+ infostore_close(isc);
+ isc = delete_and_open(dom);
+ }
+ out:
+ free(_uuid);
+ infostore_set_str(isc, "uuid", uuid);
+ return isc;
}
void infostore_close(struct infostore_ctx *ctx)
16 years, 4 months
[PATCH] Fix UUID string buffer length in a couple of spots
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1217861057 25200
# Node ID 7ecbef9e2146cb2937c2cff27be0f2e4c75ea1cc
# Parent fed521ebbf7d0b64a90036252f9e6c765d8b3105
Fix UUID string buffer length in a couple of spots
Thanks to Jim Fehlig for pointing this out.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r fed521ebbf7d -r 7ecbef9e2146 src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Thu Jul 31 07:25:33 2008 -0700
+++ b/src/Virt_VSMigrationService.c Mon Aug 04 07:44:17 2008 -0700
@@ -78,7 +78,7 @@
char *ref_ns;
char *host;
uint16_t type;
- char uuid[33];
+ char uuid[VIR_UUID_STRING_BUFLEN];
};
static CMPIStatus get_msd(const CMPIObjectPath *ref,
diff -r fed521ebbf7d -r 7ecbef9e2146 src/Virt_VirtualSystemSnapshotService.c
--- a/src/Virt_VirtualSystemSnapshotService.c Thu Jul 31 07:25:33 2008 -0700
+++ b/src/Virt_VirtualSystemSnapshotService.c Mon Aug 04 07:44:17 2008 -0700
@@ -51,7 +51,7 @@
struct snap_context {
CMPIContext *context;
char *domain;
- char uuid[33];
+ char uuid[VIR_UUID_STRING_BUFLEN];
char *save_path;
char *ref_ns;
char *ref_cn;
16 years, 4 months
[PATCH] Fix memory corruption in Virt_VSMigrationService
by Jim Fehlig
# HG changeset patch
# User Jim Fehlig <jfehlig(a)novell.com>
# Date 1217630619 21600
# Node ID dc93425ad702b45d013a53d6e237066201207999
# Parent dbdf9a5fce21e33d23d280e48bae1912fd5f3a0d
Fix memory corruption in Virt_VSMigrationService
According to uuid_unparse(3), the out param needs to accommodate
37 bytes. This patch expands the uuid field of migration_job
structure to 37 bytes.
Signed-off-by: Jim Fehlig <jfehlig(a)novell.com>
diff -r dbdf9a5fce21 -r dc93425ad702 src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Thu Jul 31 07:20:19 2008 -0700
+++ b/src/Virt_VSMigrationService.c Fri Aug 01 16:43:39 2008 -0600
@@ -78,7 +78,7 @@ struct migration_job {
char *ref_ns;
char *host;
uint16_t type;
- char uuid[33];
+ char uuid[37];
};
static CMPIStatus get_msd(const CMPIObjectPath *ref,
16 years, 4 months
[PATCH] [TEST] Fixing the missing status value for 23_suspend_suspend.py, 32_start_reboot.py, 33_suspend_reboot.py, 35_start_reset.py
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1217853560 25200
# Node ID afd9b3b300da23a72118942133d7791c0987573a
# Parent 6773c2717b6d2a1ccc3143a27bc2209dabc81e4b
[TEST] Fixing the missing status value for 23_suspend_suspend.py, 32_start_reboot.py, 33_suspend_reboot.py, 35_start_reset.py.
1) This is a followup patch for the patchset "Changes to common_util.py library and test cases affected changes."
2) Fixing the missing status value which was missed in the previous patch.
Tested on KVM with current sources ONLY.
PS: APPLY "Changes to common_util.py library and test cases affected changes." PATCH BEFORE THIS PATCHSET.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 6773c2717b6d -r afd9b3b300da suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py Mon Aug 04 05:08:10 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py Mon Aug 04 05:39:20 2008 -0700
@@ -94,12 +94,10 @@
break
status, dom_cs = poll_for_state_change(server, virt, default_dom, en_state,
- timeout=30)
- if status != PASS:
- break
-
- if dom_cs.RequestedState != rq_state:
- logger.error("RequestedState for dom '%s' is not set as expected.",
+ timeout=30)
+ if status != PASS or dom_cs.RequestedState != rq_state:
+ status = FAIL
+ logger.error("Attributes for dom '%s' is not set as expected.",
default_dom)
break
diff -r 6773c2717b6d -r afd9b3b300da suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py Mon Aug 04 05:08:10 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py Mon Aug 04 05:39:20 2008 -0700
@@ -94,11 +94,10 @@
status, dom_cs = poll_for_state_change(server, virt, default_dom, en_state,
timeout=10)
- if status != PASS:
- break
-
- if dom_cs.RequestedState != rq_state:
- logger.error("RequestedState for dom '%s' is not set as expected.",
+
+ if status != PASS or dom_cs.RequestedState != rq_state:
+ status = FAIL
+ logger.error("Attributes for dom '%s' is not set as expected.",
default_dom)
break
diff -r 6773c2717b6d -r afd9b3b300da suites/libvirt-cim/cimtest/ComputerSystem/33_suspend_reboot.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/33_suspend_reboot.py Mon Aug 04 05:08:10 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/33_suspend_reboot.py Mon Aug 04 05:39:20 2008 -0700
@@ -101,11 +101,9 @@
status, dom_cs = poll_for_state_change(server, virt, default_dom, en_state,
timeout=10)
- if status != PASS:
- break
-
- if dom_cs.RequestedState != rq_state:
- logger.error("RequestedState for dom '%s' is not set as expected.",
+ if status != PASS or dom_cs.RequestedState != rq_state:
+ status = FAIL
+ logger.error("Attributes for dom '%s' is not set as expected.",
default_dom)
break
diff -r 6773c2717b6d -r afd9b3b300da suites/libvirt-cim/cimtest/ComputerSystem/35_start_reset.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/35_start_reset.py Mon Aug 04 05:08:10 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/35_start_reset.py Mon Aug 04 05:39:20 2008 -0700
@@ -95,11 +95,10 @@
status, dom_cs = poll_for_state_change(server, virt, default_dom, en_state,
timeout=30)
- if status != PASS:
- break
- if dom_cs.RequestedState != rq_state:
- logger.error("RequestedState for dom '%s' is not set as expected.",
+ if status != PASS or dom_cs.RequestedState != rq_state:
+ status = FAIL
+ logger.error("Attributes for dom '%s' is not set as expected.",
default_dom)
break
16 years, 4 months
[PATCH] [TEST] Fixing the 40_RSC_start.py tc
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1217851690 25200
# Node ID 6773c2717b6d2a1ccc3143a27bc2209dabc81e4b
# Parent 56ae86dadb4d67ebcfce703e3895c7fb8a118c58
[TEST] Fixing the 40_RSC_start.py tc.
1) Used poll_for_state_change() to verify the poll and verify the EnabledState and RequestedState value.
2) Removed the invalid bug nos.
3) Removed check_attributes().
4) Adding create_netpool_conf(), destroy_netpool() since the VSMS now requires networkpool.
5) Used destroy_and_undefine_domain() to undefine and destroy the VS.
The changes are verified with KVM on current sources.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 56ae86dadb4d -r 6773c2717b6d suites/libvirt-cim/cimtest/ComputerSystem/40_RSC_start.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/40_RSC_start.py Sun Aug 03 23:22:49 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/40_RSC_start.py Mon Aug 04 05:08:10 2008 -0700
@@ -36,60 +36,49 @@
import sys
import pywbem
from VirtLib import utils
-from XenKvmLib.test_doms import undefine_test_domain
+from XenKvmLib.test_doms import destroy_and_undefine_domain
from XenKvmLib.common_util import *
from CimTest.Globals import logger
from CimTest.Globals import do_main
-from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
+from CimTest.ReturnCodes import PASS, FAIL
sup_types = ['Xen', 'KVM', 'XenFV']
-bug = "00001"
-bug_req_state = "00002"
-default_dom = 'test_domain'
+default_dom = 'cs_test_domain'
REQUESTED_STATE = 2
TIME = "00000000000000.000000:000"
-
-def check_attributes(domain_name, ip, virt):
- rc, cs = get_cs_instance(domain_name, ip, virt)
- if rc != 0:
- return rc
-
- if cs.RequestedState != REQUESTED_STATE:
- logger.error("RequestedState should be %d not %d",
- REQUESTED_STATE, cs.RequestedState)
- return FAIL
-
- if cs.EnabledState != REQUESTED_STATE:
- logger.error("EnabledState should be %d not %d",
- REQUESTED_STATE, cs.EnabledState)
- return FAIL
-
- return PASS
@do_main(sup_types)
def main():
options = main.options
+ server = options.ip
+ virt = options.virt
status = FAIL
+ status, test_network = create_netpool_conf(server, virt, False)
+ if status != PASS:
+ return FAIL
+
try:
- rc = create_using_definesystem(default_dom, options.ip,
- virt=options.virt)
+ rc = create_using_definesystem(default_dom, server,
+ virt=virt)
if rc != 0:
- raise Exception("DefineSystem() failed to create domain: %s" %
+ status = FAIL
+ raise Exception("DefineSystem() failed to create domain: '%s'" %
default_dom)
- rc = call_request_state_change(default_dom, options.ip,
- REQUESTED_STATE, TIME, options.virt)
+ rc = call_request_state_change(default_dom, server,
+ REQUESTED_STATE, TIME, virt)
if rc != 0:
- status = XFAIL_RC(bug)
+ status = FAIL
raise Exception("RequestedStateChange() could not be used to start"
" domain: '%s'" % default_dom)
+ status, dom_cs = poll_for_state_change(server, virt, default_dom,
+ REQUESTED_STATE, timeout=10)
- rc = check_attributes(default_dom, options.ip, options.virt)
- if rc != 0:
- status = XFAIL_RC(bug_req_state)
+ if status != PASS or dom_cs.RequestedState != REQUESTED_STATE:
+ status = FAIL
raise Exception("Attributes were not set as expected for "
"domain: '%s'" % default_dom)
else:
@@ -98,8 +87,8 @@
except Exception, detail:
logger.error("Exception: %s", detail)
- undefine_test_domain(default_dom, options.ip, options.virt)
-
+ destroy_netpool(server, virt, test_network)
+ destroy_and_undefine_domain(default_dom, server, virt)
return status
if __name__ == "__main__":
16 years, 4 months
[PATCH] [TEST] Modify CSI test to support modified and deleted indications
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1217543970 25200
# Node ID a0f1042dd8dd0b685aa755e1cedbbd7cdd71bbfc
# Parent 837943c970641071e55637386d9ac30df5d41e4b
[TEST] Modify CSI test to support modified and deleted indications.
This may fail on KVM with the following error message: "CIM_ERR_FAILED: Invalid state transition." Will follow up on this issue.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 837943c97064 -r a0f1042dd8dd suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py
--- a/suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py Thu Jul 31 15:35:35 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py Thu Jul 31 15:39:30 2008 -0700
@@ -24,91 +24,163 @@
import os
import signal
import time
+from pywbem.cim_obj import CIMInstanceName
from CimTest.Globals import logger
from CimTest.Globals import do_main
from CimTest.ReturnCodes import PASS, FAIL
-from XenKvmLib.common_util import create_using_definesystem
-from XenKvmLib.test_doms import undefine_test_domain
+from XenKvmLib.common_util import create_using_definesystem, \
+ call_request_state_change
+from XenKvmLib.test_doms import destroy_and_undefine_domain
from XenKvmLib.classes import get_typed_class
from XenKvmLib.indication_tester import CIMIndicationSubscription
from XenKvmLib.vxml import set_default
+from XenKvmLib.vsms import get_vsms_class
SUPPORTED_TYPES = ['Xen', 'XenFV', 'KVM']
test_dom = "domU"
+REQ_STATE = 2
+TIME = "00000000000000.000000:000"
+
+def sub_ind(ip, virt):
+ dict = set_default(ip)
+ ind_names = {"define" : 'ComputerSystemCreatedIndication',
+ "start" : 'ComputerSystemModifiedIndication',
+ "destroy" : 'ComputerSystemDeletedIndication'
+ }
+
+ sub_list = {}
+ port = 5
+
+ for ind, iname in ind_names.iteritems():
+ ind_name = get_typed_class(virt, iname)
+
+ sub_name = "Test%s" % ind_name
+ port += 1
+
+ sub = CIMIndicationSubscription(sub_name, ind_name,
+ dict['default_ns'],
+ dict['default_print_ind'],
+ dict['default_sysname'],
+ port)
+ sub.subscribe(dict['default_url'], dict['default_auth'])
+ logger.info("Watching for %s" % iname)
+ ind_names[ind] = ind_name
+ sub_list[ind] = sub
+
+ return sub_list, ind_names, dict
+
+def gen_ind(test_dom, ip, vtype, ind):
+ if ind == "define":
+ return create_using_definesystem(test_dom, ip, virt=vtype)
+
+ elif ind == "start":
+ rc = call_request_state_change(test_dom, ip, REQ_STATE, TIME, vtype)
+ if rc != 0:
+ logger.error("Failed to start domain: %s" % test_dom)
+ return FAIL
+ return PASS
+
+ elif ind == "destroy":
+ service = get_vsms_class(vtype)(ip)
+ try:
+ classname = get_typed_class(vtype, 'ComputerSystem')
+ cs_ref = CIMInstanceName(classname, keybindings = {
+ 'Name':test_dom,
+ 'CreationClassName':classname})
+ service.DestroySystem(AffectedSystem=cs_ref)
+ except Exception, details:
+ logger.error('Unknow exception happened')
+ logger.error(details)
+ return FAIL
+ return PASS
+
+ return FAIL
+
+def handle_request(sub, ind_name):
+ sub.server.handle_request()
+ if len(sub.server.indications) == 0:
+ logger.error("No valid indications received")
+ return FAIL
+ elif str(sub.server.indications[0]) != ind_name:
+ logger.error("Received indication %s instead of %s" % \
+ (str(sub.server.indications[0])), ind_name)
+ return FAIL
+
+ return PASS
+
+def poll_for_ind(pid):
+ for i in range(0, 20):
+ pw = os.waitpid(pid, os.WNOHANG)
+
+ # If pid exits, waitpid returns [pid, return_code]
+ # If pid is still running, waitpid returns [0, 0]
+ # Only return a success if waitpid returns the expected pid
+ # and the return code is 0.
+ if pw[0] == pid and pw[1] == 0:
+ logger.info("Great, got indication successfuly")
+ status = PASS
+ break
+ elif pw[1] == 0 and i < 19:
+ if i % 10 == 0:
+ logger.info("In child process, waiting for indication")
+ time.sleep(1)
+ else:
+ # Time is up and waitpid never returned the expected pid
+ if pw[0] != pid:
+ logger.error("Waited too long for indication")
+ os.kill(pid, signal.SIGKILL)
+ else:
+ logger.error("Received indication error: %d" % pw[1])
+
+ status = FAIL
+ break
+
+ return status
@do_main(SUPPORTED_TYPES)
def main():
options = main.options
status = FAIL
- dict = set_default(options.ip)
- indication_name = get_typed_class(options.virt,
- 'ComputerSystemCreatedIndication')
-
- sub = CIMIndicationSubscription(dict['default_name'], indication_name,
- dict['default_ns'],
- dict['default_print_ind'],
- dict['default_sysname'])
- sub.subscribe(dict['default_url'], dict['default_auth'])
- logger.info("Watching for %s" % indication_name)
-
- try:
- pid = os.fork()
- if pid == 0:
- sub.server.handle_request()
- if len(sub.server.indications) == 0:
- logger.error("No valid indications received")
- os._exit(1)
- elif str(sub.server.indications[0]) != indication_name:
- logger.error("Received indication %s instead of %s" % \
- (indication_name, str(sub.server.indications[0])))
- os._exit(2)
+ sub_list, ind_names, dict = sub_ind(options.ip, options.virt)
+
+ ind_list = ["define", "start", "destroy"]
+
+ for ind in ind_list:
+ sub = sub_list[ind]
+ ind_name = ind_names[ind]
+
+ try:
+ pid = os.fork()
+ if pid == 0:
+ status = handle_request(sub, ind_name)
+ if status != PASS:
+ os._exit(1)
+
+ os._exit(0)
else:
- os._exit(0)
- else:
- status = create_using_definesystem(test_dom, options.ip, None, None,
- options.virt)
- if status != PASS:
- sub.unsubscribe(dict['default_auth'])
- logger.info("Cancelling subscription for %s" % indication_name)
- os.kill(pid, signal.SIGKILL)
- return status
+ try:
+ status = gen_ind(test_dom, options.ip, options.virt, ind)
+ if status != PASS:
+ os.kill(pid, signal.SIGKILL)
+ return FAIL
- status = FAIL
- for i in range(0,100):
- pw = os.waitpid(pid, os.WNOHANG)
+ status = poll_for_ind(pid)
+ except Exception, details:
+ logger.error("Exception: %s" % details)
+ os.kill(pid, signal.SIGKILL)
+ return FAIL
- # If pid exits, waitpid returns [pid, return_code]
- # If pid is still running, waitpid returns [0, 0]
- # Only return a success if waitpid returns the expected pid
- # and the return code is 0.
- if pw[0] == pid and pw[1] == 0:
- logger.info("Great, got indication successfuly")
- status = PASS
- break
- elif pw[1] == 0 and i < 99:
- if i % 10 == 0:
- logger.info("In child process, waiting for indication")
- time.sleep(1)
- else:
- status = FAIL
-
- # Time is up and waitpid never returned the expected pid
- if pw[0] != pid:
- logger.error("Waited too long for indication")
- os.kill(pid, signal.SIGKILL)
- else:
- logger.error("Received indication error: %d" % pw[1])
- break
+ except Exception, details:
+ logger.error("Exception: %s" % details)
+ return FAIL
- except Exception, details:
- logger.error("Unknown exception happened")
- logger.error(details)
-
- sub.unsubscribe(dict['default_auth'])
- logger.info("Cancelling subscription for %s" % indication_name)
- undefine_test_domain(test_dom, options.ip, options.virt)
+ for ind, sub in sub_list.iteritems():
+ sub.unsubscribe(dict['default_auth'])
+ logger.info("Cancelling subscription for %s" % ind_names[ind])
+
+ destroy_and_undefine_domain(test_dom, options.ip, options.virt)
return status
16 years, 4 months
[PATCH] [TEST] Add test for DiskRASD size parameter
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1217005489 25200
# Node ID 3c80ea156a3c45bc321f9c465ba7692c011ab2e0
# Parent 2972728363defd7c9a7683ebfa85a4dfc8225e32
[TEST] Add test for DiskRASD size parameter
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 2972728363de -r 3c80ea156a3c suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py Fri Jul 25 10:04:49 2008 -0700
@@ -0,0 +1,127 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+# Dan Smith <danms(a)us.ibm.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+sup_types = ['Xen', 'XenFV', 'KVM']
+default_dom = "diskrasd_test"
+
+import sys
+
+from CimTest.ReturnCodes import FAIL, PASS
+from CimTest.Globals import do_main
+from CimTest.Globals import logger
+from VirtLib import utils
+from XenKvmLib.test_doms import undefine_test_domain
+from XenKvmLib.common_util import create_using_definesystem
+from XenKvmLib import vsms
+from XenKvmLib import enumclass
+
+def make_image(ip, size):
+ s, fn = utils.run_remote(ip, "mktemp")
+ if s != 0:
+ return None
+
+ s, _ = utils.run_remote(ip,
+ "dd if=/dev/zero of=%s bs=1 count=%i" % (fn, size))
+ if s != 0:
+ return None
+
+ return fn
+
+def kill_image(ip, name):
+ s, _ = utils.run_remote(ip, "rm -f %s" % name)
+
+ return s == 0
+
+def check_rasd_size(rasd, size):
+ if rasd["AllocationUnits"] != "Bytes":
+ logger.error("AllocationUnits != Bytes?")
+ return FAIL
+
+ try:
+ cim_size = int(rasd["VirtualQuantity"])
+ except Exception, e:
+ logger.error("Failed to get DiskRASD size: %s" % e)
+ return FAIL
+
+ if cim_size != size:
+ logger.error("CIM reports %i bytes, but should be %i bytes" % (cim_size,
+ size))
+ return FAIL
+ else:
+ logger.info("Verified %i bytes" % cim_size)
+ return PASS
+
+def test_rasd(options, temp, test_size):
+ vssd_class = vsms.get_vssd_class(options.virt)
+ vssd = vssd_class(name=default_dom, virt=options.virt)
+
+ drasd_class = vsms.get_dasd_class(options.virt)
+ drasd = drasd_class("hda", temp, default_dom)
+
+ mrasd_class = vsms.get_masd_class(options.virt)
+ mrasd = mrasd_class(32, default_dom)
+
+ params = {
+ "vssd" : vssd.mof(),
+ "rasd" : [drasd.mof(), mrasd.mof()]
+ }
+
+ create_using_definesystem(default_dom,
+ options.ip,
+ params=params,
+ virt=options.virt)
+
+ rasds = enumclass.enumerate_inst(options.ip, drasd_class, options.virt)
+
+ status = FAIL
+ for rasd in rasds:
+ if rasd["Address"] == temp:
+ status = check_rasd_size(rasd, test_size)
+ break
+
+ return status
+
+@do_main(sup_types)
+def main():
+ options = main.options
+
+ test_size = 123 << 10
+
+ temp = make_image(options.ip, test_size)
+ if not temp:
+ logger.error("Unable to create a temporary disk image")
+ return FAIL
+
+ logger.info("Created temp disk %s of size %i bytes" % (temp, test_size))
+
+ try:
+ status = test_rasd(options, temp, test_size)
+ except Exception, e:
+ logger.error("Failed to test RASD: %s" % e)
+
+ undefine_test_domain(default_dom, options.ip, options.virt)
+ kill_image(options.ip, temp)
+
+ return status
+
+if __name__ == "__main__":
+ sys.exit(main())
16 years, 4 months
[PATCH] [TEST] #3 Update SettingsDefineCapabilities.01 to return less valeus in pool related function
by yunguol@cn.ibm.com
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1217569031 25200
# Node ID bc7f9edeaa5ff372bf79e5ed699654a2a1aa26a3
# Parent a289fb981e70e916ed1f0bbf1b7ba579e96502c6
[TEST] #3 Update SettingsDefineCapabilities.01 to return less valeus in pool related function
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r a289fb981e70 -r bc7f9edeaa5f suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py
--- a/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py Wed Jul 30 20:01:53 2008 -0700
+++ b/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py Thu Jul 31 22:37:11 2008 -0700
@@ -63,7 +63,7 @@
CIM_ERROR_GETINSTANCE, CIM_ERROR_ASSOCIATORS
from XenKvmLib.classes import get_typed_class
from XenKvmLib.common_util import cleanup_restore, create_diskpool_conf, \
-create_netpool_conf
+create_netpool_conf, destroy_netpool
from XenKvmLib.common_util import print_field_error
platform_sup = ['Xen', 'KVM', 'XenFV', 'LXC']
@@ -87,21 +87,21 @@
return instance
-def init_list(virt, dpool, npool, mpool, ppool):
+def init_list(virt, pool):
"""
Creating the lists that will be used for comparisons.
"""
-
+
if virt == 'LXC':
- instlist = [ mpool.InstanceID ]
+ instlist = [ pool[1].InstanceID ]
cllist = [ get_typed_class(virt, "MemResourceAllocationSettingData") ]
rtype = { get_typed_class(virt, "MemResourceAllocationSettingData") : 4 }
else:
instlist = [
- dpool.InstanceID,
- mpool.InstanceID,
- npool.InstanceID,
- ppool.InstanceID
+ pool[0].InstanceID,
+ pool[1].InstanceID,
+ pool[2].InstanceID,
+ pool[3].InstanceID
]
cllist = [
get_typed_class(virt, "DiskResourceAllocationSettingData"),
@@ -130,10 +130,11 @@
def get_pool_details(virt, server):
dpool = npool = mpool = ppool = None
+ pool_set = []
try :
status, diskid = create_diskpool_conf(server, virt)
if status != PASS:
- return status, dpool, npool, mpool, ppool
+ return status, pool_set, None
dpool = get_pool_info(virt, server, diskid, poolname="DiskPool")
mpool = get_pool_info(virt, server, memid, poolname= "MemoryPool")
@@ -141,16 +142,23 @@
status, test_network = create_netpool_conf(server, virt)
if status != PASS:
- return status, dpool, npool, mpool, ppool
+ return status, pool_set, test_network
netid = "%s/%s" % ("NetworkPool", test_network)
npool = get_pool_info(virt, server, netid, poolname= "NetworkPool")
-
+ if dpool.InstanceID == None or mpool.InstanceID == None \
+ or npool.InstanceID == None or ppool.InstanceID == None:
+ logger.error("Get pool None")
+ cleanup_restore(server, virt)
+ destroy_netpool(server, virt, test_network)
+ return FAIL
+ else:
+ pool_set = [dpool, mpool, ppool, npool]
except Exception, detail:
logger.error("Exception: %s", detail)
- return FAIL, dpool, npool, mpool, ppool
+ return FAIL, pool_set, test_network
- return PASS, dpool, npool, mpool, ppool
+ return PASS, pool_set, test_network
def verify_rasd_fields(loop, assoc_info, cllist, rtype, rangelist):
for inst in assoc_info:
@@ -164,10 +172,9 @@
return PASS
-def verify_sdc_with_ac(virt, server, dpool, npool, mpool, ppool):
+def verify_sdc_with_ac(virt, server, pool):
loop = 0
- instlist, cllist, rtype, rangelist = init_list(virt, dpool, npool, mpool,
- ppool)
+ instlist, cllist, rtype, rangelist = init_list(virt, pool)
assoc_cname = get_typed_class(virt, "SettingsDefineCapabilities")
cn = get_typed_class(virt, "AllocationCapabilities")
for instid in sorted(instlist):
@@ -200,14 +207,15 @@
server = options.ip
virt = options.virt
- status, dpool, npool, mpool, ppool = get_pool_details(virt, server)
- if status != PASS or dpool.InstanceID == None or mpool.InstanceID == None \
- or npool.InstanceID == None or ppool.InstanceID == None:
+ status, pool, test_network = get_pool_details(virt, server)
+ if status != PASS:
cleanup_restore(server, virt)
+ destroy_netpool(server, virt, test_network)
return FAIL
- status = verify_sdc_with_ac(virt, server, dpool, npool, mpool, ppool)
+ status = verify_sdc_with_ac(virt, server, pool)
cleanup_restore(server, virt)
+ destroy_netpool(server, virt, test_network)
return status
if __name__ == "__main__":
16 years, 4 months