From cvincent at linux.vnet.ibm.com Fri Apr 1 12:50:13 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Fri, 01 Apr 2011 08:50:13 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] Conditionally fail if VSI hardware not available In-Reply-To: References: Message-ID: <4D95CA05.400@linux.vnet.ibm.com> VirtualSystemManagementService - 28_definesystem_with_vsi_profile.py: XFAIL ERROR - Got CIM error CIM_ERR_FAILED: Unable to start domain: internal error interface eth1 does not exist with return code 1 ERROR - Unable to start VM *** Is VSI support available on this host? *** InvokeMethod(RequestStateChange): CIM_ERR_FAILED: Unable to start domain: internal error interface eth1 does not exist +1 On 03/31/2011 04:51 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1301604632 25200 > # Node ID c1d9565fff50d8aaa7990088b16a8364f563187a > # Parent 6d7dab79f4e8806aea65cb413c4f193cdbfc4f40 > [TEST] Conditionally fail if VSI hardware not available. > > This test requires VSI capable hardware to run successfully. > On non-vsi hosts, the test was failing, changed it to fail > conditionally now giving detailed cause of failure. > > Signed-off-by: Sharad Mishra > > diff -r 6d7dab79f4e8 -r c1d9565fff50 suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py Thu Mar 31 13:40:51 2011 -0700 > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py Thu Mar 31 13:50:32 2011 -0700 > @@ -179,29 +179,34 @@ > try: > rasd_list = get_rasd_list(server, virt, vsi_defaults, nrasd_cn) > if len(rasd_list)< 1: > + status = FAIL > raise Exception("Unable to get template RASDs for %s" % test_dom) > > cxml = get_class(virt)(test_dom) > cxml.set_res_settings(rasd_list) > ret = cxml.cim_define(server) > if not ret: > + status = FAIL > raise Exception("Unable to define guest %s" % test_dom) > > status = cxml.cim_start(server) > if status != PASS: > - raise Exception("Unable to start %s" % test_dom) > + status = XFAIL > + raise Exception("Unable to start VM " > + "*** Is VSI support available on this host? ***") > > status, inst = get_net_inst(server, nrasd_cn, test_dom) > if status != PASS: > + status = FAIL > raise Exception("Failed to get net interface for %s" % test_dom) > > status = verify_net_rasd(server, virt, vsi_defaults, inst) > if status != PASS: > + status = FAIL > logger.error("Failed to verify net interface for %s", test_dom) > > except Exception, details: > logger.error(details) > - status = FAIL > > cxml.cim_destroy(server) > cxml.undefine(server) > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Fri Apr 1 12:50:27 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Fri, 01 Apr 2011 08:50:27 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] Fix HostSystem/01_enum.py test In-Reply-To: <434ee28b0c8000175c81.1301599531@elm3a148.beaverton.ibm.com> References: <434ee28b0c8000175c81.1301599531@elm3a148.beaverton.ibm.com> Message-ID: <4D95CA13.4030900@linux.vnet.ibm.com> +1 On 03/31/2011 03:25 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1301597899 25200 > # Node ID 434ee28b0c8000175c81ea7291d7bcf01756cfdd > # Parent e71cf5aa81f77498c18ad7d870a41ed9760d3c06 > [TEST] Fix HostSystem/01_enum.py test > > This test was not taking into account the localhost discovered by sblim providers. > > Signed-off-by: Sharad Mishra > > diff -r e71cf5aa81f7 -r 434ee28b0c80 suites/libvirt-cim/cimtest/HostSystem/01_enum.py > --- a/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Mon Mar 07 17:40:29 2011 -0800 > +++ b/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Thu Mar 31 11:58:19 2011 -0700 > @@ -55,8 +55,12 @@ > > if ret == PASS: > if len(hs) != 0: > - logger.error("Unexpected instance returned") > - return FAIL > + if hs[0].CreationClassName != name or hs[0].Name != host: > + logger.error("Exp %s, got %s", name, hs[0].CreationClassName) > + logger.error("Exp %s, got %s", host, hs[0].Name) > + return FAIL > + else: > + return PASS > else: > if linux_cs.CreationClassName != 'Linux_ComputerSystem'\ > or linux_cs.Name != host: > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Fri Apr 1 12:51:47 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Fri, 01 Apr 2011 08:51:47 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] Fixing testcase to account for different libvirt error string In-Reply-To: <6d7dab79f4e8806aea65.1301604155@elm3a148.beaverton.ibm.com> References: <6d7dab79f4e8806aea65.1301604155@elm3a148.beaverton.ibm.com> Message-ID: <4D95CA63.40605@linux.vnet.ibm.com> +1. Are changes needed in libvirt-cim to handle this case? That is, will a change in libvirt return codes break libvirt-cim? On 03/31/2011 04:42 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1301604051 25200 > # Node ID 6d7dab79f4e8806aea65cb413c4f193cdbfc4f40 > # Parent f0a7eee4cbe06cc4f618770ac149218a1bddb171 > [TEST] Fixing testcase to account for different libvirt error string. > > Noticed that this test was failing on some libvirt versions between > 0.7.0 and 0.8.7 because libvirt was returning new error message. Latest > libvirt (0.8.7-5) is back to using error string from libvirt versions > prior to 0.7.0. > > Signed-off-by: Sharad Mishra > > diff -r f0a7eee4cbe0 -r 6d7dab79f4e8 suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py Thu Mar 31 12:32:11 2011 -0700 > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py Thu Mar 31 13:40:51 2011 -0700 > @@ -125,10 +125,17 @@ > if not ret: > status = verify_error(exp_rc, exp_desc, cxml) > if status != PASS: > - raise Exception('Defing domain with invalid %s name %s' > - ' gave unexpected rc code %s and ' > - 'description:\n %s'% (nettype, field, > - cxml.err_rc, cxml.err_desc)) > + # There are few libvirt version between 0.7.0 > + # and 0.8.7 which give following error. > + status = verify_error(exp_rc, > + 'No Network bridge name specified', > + cxml) > + if status != PASS: > + raise Exception('Defining domain with invalid %s' > + ' name %s gave unexpected rc code' > + ' %s and description:\n' > + ' %s'% (nettype, field, > + cxml.err_rc, cxml.err_desc)) > continue > ret = cxml.cim_start(options.ip) > if ret: > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Fri Apr 1 12:52:41 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Fri, 01 Apr 2011 08:52:41 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] Removing redundant test In-Reply-To: <4bcde13186e6c9985efc.1301605708@elm3a148.beaverton.ibm.com> References: <4bcde13186e6c9985efc.1301605708@elm3a148.beaverton.ibm.com> Message-ID: <4D95CA99.4040404@linux.vnet.ibm.com> +1 On 03/31/2011 05:08 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1301605604 25200 > # Node ID 4bcde13186e6c9985efc3a11f050c76cf3daf3fa > # Parent c1d9565fff50d8aaa7990088b16a8364f563187a > [TEST] Removing redundant test. > > This test is no longer needed as libvirt-cim does not > check for duplicate mac addresses. This check is now > done by libvirt. > > Signed-off-by: Sharad Mishra > > diff -r c1d9565fff50 -r 4bcde13186e6 suites/libvirt-cim/cimtest/VirtualSystemManagementService/23_verify_duplicate_mac_err.py > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/23_verify_duplicate_mac_err.py Thu Mar 31 13:50:32 2011 -0700 > +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 > @@ -1,156 +0,0 @@ > -#!/usr/bin/python > -# > -# Copyright 2009 IBM Corp. > -# > -# Authors: > -# Yogananth subramanian > -# > -# 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 > -# > -# This testcase verifies definig network interface with conflicting MAC > -# > - > -from sys import exit > -from random import randint > -from pywbem import CIM_ERR_FAILED > -from XenKvmLib.vsms_util import add_net_res > -from XenKvmLib.vsms import get_vsms_class, get_nasd_class > -from XenKvmLib.vxml import get_class > -from CimTest.Globals import logger > -from CimTest.ReturnCodes import FAIL, PASS, SKIP > -from XenKvmLib.const import default_network_name, do_main > -from XenKvmLib.common_util import create_netpool_conf, destroy_netpool > -from XenKvmLib.classes import get_typed_class > -from XenKvmLib.enumclass import GetInstance, EnumNames > -from XenKvmLib.const import get_provider_version > - > -sup_types = ['Xen', 'KVM', 'XenFV'] > -default_dom = 'net_domain1' > -test_dom = 'brgtest_domain2' > -nmac = '99:aa:bb:cc:ee:ff' > -ntype = 'network' > -npool_name = default_network_name + str(randint(1, 100)) > -exp_rc = CIM_ERR_FAILED > -exp_desc = "Conflicting MAC Addresses" > - > -dup_mac_rev = 929 > - > -def cleanup_env(ip, virt, npool_name, cxml): > - cxml.cim_destroy(ip) > - cxml.undefine(ip) > - destroy_netpool(ip, virt, npool_name) > - > -def start_dom(cxml,ip,dom): > - ret = cxml.cim_define(ip) > - if not ret: > - status = cxml.verify_error_msg(exp_rc, exp_desc) > - if status != PASS: > - raise Exception("Got unexpected rc code %s and description %s" > - % (cxml.err_rc, cxml.err_desc)) > - return FAIL > - ret = cxml.cim_start(ip) > - if ret: > - status = cxml.verify_error_msg(exp_rc, exp_desc) > - cxml.undefine(ip) > - if status != PASS: > - raise Exception("Got unexpected rc code %s and description %s" > - % (cxml.err_rc, cxml.err_desc)) > - return FAIL > - return PASS > - > - at do_main(sup_types) > -def main(): > - options = main.options > - > - rev, changeset = get_provider_version(options.virt, options.ip) > - if rev< dup_mac_rev: > - logger.error("Test only valid with provider version> %d", dup_mac_rev) > - return SKIP > - > - status, net_name = create_netpool_conf(options.ip, options.virt, > - use_existing=False, > - net_name=npool_name) > - if status != PASS: > - logger.error('Unable to create network pool') > - return FAIL > - cxml = get_class(options.virt)(default_dom, mac=nmac, > - ntype=ntype, net_name=npool_name) > - try: > - status = start_dom(cxml, options.ip, default_dom) > - if status == FAIL: > - raise Exception("Starting %s domain failed, got unexpeceted rc" > - "code %s and description %s" % (default_dom, > - cxml.err_rc, cxml.err_desc)) > - > - except Exception, details: > - logger.error(details) > - destroy_netpool(options.ip, options.virt, net_name) > - return FAIL > - > - sxml = get_class(options.virt)(test_dom, mac=nmac, > - ntype=ntype, net_name=npool_name) > - try: > - status = start_dom(sxml, options.ip, test_dom) > - > - if status == PASS: > - sxml.cim_destroy(options.ip) > - sxml.undefine(options.ip) > - raise Exception("Was able to create two domains with" > - "Conflicting MAC Addresses") > - > - service = get_vsms_class(options.virt)(options.ip) > - classname = get_typed_class(options.virt, 'VirtualSystemSettingData') > - netpool = EnumNames(options.ip, classname) > - > - if options.virt == "XenFV": > - prefix = "Xen" > - else: > - prefix = options.virt > - > - inst_id = '%s:%s' % (prefix, default_dom) > - vssd_ref = None > - for i in range(0, len(netpool)): > - ret_pool = netpool[i].keybindings['InstanceID'] > - if ret_pool == inst_id: > - vssd_ref = netpool[i] > - break > - if vssd_ref == None: > - raise Exception("Failed to get vssd_ref for '%s'"% default_dom) > - > - nasd = get_nasd_class(options.virt)(type=ntype, mac=nmac, > - name=default_dom, > - virt_net=npool_name) > - net_attr = { 'ntype' : ntype, > - 'net_name' : npool_name, > - 'nmac' : nmac > - } > - > - ret = add_net_res(options.ip, service, options.virt, cxml, > - vssd_ref, nasd, net_attr) > - if ret == PASS: > - raise Exception("AddRS should NOT return OK with duplicate MAC") > - else: > - status = PASS > - > - except Exception, details: > - logger.error(details) > - status = FAIL > - > - cleanup_env(options.ip, options.virt, npool_name, cxml) > - return status > - > -if __name__ == "__main__": > - exit(main()) > - > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From snmishra at us.ibm.com Fri Apr 1 13:52:34 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Fri, 1 Apr 2011 06:52:34 -0700 Subject: [Libvirt-cim] [PATCH] [TEST] Fixing testcase to account for different libvirt error string In-Reply-To: <4D95CA63.40605@linux.vnet.ibm.com> References: <6d7dab79f4e8806aea65.1301604155@elm3a148.beaverton.ibm.com> <4D95CA63.40605@linux.vnet.ibm.com> Message-ID: Chip, Return code is not the issue. It is the error message that had changed. This test compares the error message with the expected error message. Since libvirt-cim does not care about the actual error message, we are okay there. Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces at redhat.com wrote on 04/01/2011 05:51:47 AM: > Chip Vincent > Sent by: libvirt-cim-bounces at redhat.com > > 04/01/11 05:51 AM > > Please respond to > cvincent at linux.vnet.ibm.com; Please respond to > List for discussion and development of libvirt CIM > > To > > libvirt-cim at redhat.com > > cc > > Subject > > Re: [Libvirt-cim] [PATCH] [TEST] Fixing testcase to account for > different libvirt error string > > +1. Are changes needed in libvirt-cim to handle this case? That is, will > a change in libvirt return codes break libvirt-cim? > > On 03/31/2011 04:42 PM, Sharad Mishra wrote: > > # HG changeset patch > > # User Sharad Mishra > > # Date 1301604051 25200 > > # Node ID 6d7dab79f4e8806aea65cb413c4f193cdbfc4f40 > > # Parent f0a7eee4cbe06cc4f618770ac149218a1bddb171 > > [TEST] Fixing testcase to account for different libvirt error string. > > > > Noticed that this test was failing on some libvirt versions between > > 0.7.0 and 0.8.7 because libvirt was returning new error message. Latest > > libvirt (0.8.7-5) is back to using error string from libvirt versions > > prior to 0.7.0. > > > > Signed-off-by: Sharad Mishra > > > > diff -r f0a7eee4cbe0 -r 6d7dab79f4e8 suites/libvirt-cim/cimtest/ > VirtualSystemManagementService/19_definenetwork_ers.py > > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > 19_definenetwork_ers.py Thu Mar 31 12:32:11 2011 -0700 > > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > 19_definenetwork_ers.py Thu Mar 31 13:40:51 2011 -0700 > > @@ -125,10 +125,17 @@ > > if not ret: > > status = verify_error(exp_rc, exp_desc, cxml) > > if status != PASS: > > - raise Exception('Defing domain with > invalid %s name %s' > > - ' gave unexpected rc code %s and ' > > - 'description:\n %s'% > (nettype, field, > > - cxml.err_rc, cxml.err_desc)) > > + # There are few libvirt version between 0.7.0 > > + # and 0.8.7 which give following error. > > + status = verify_error(exp_rc, > > + 'No Network bridge > name specified', > > + cxml) > > + if status != PASS: > > + raise Exception('Defining domain with > invalid %s' > > + ' name %s gave > unexpected rc code' > > + ' %s and description:\n' > > + ' %s'% (nettype, field, > > + cxml.err_rc, cxml.err_desc)) > > continue > > ret = cxml.cim_start(options.ip) > > if ret: > > > > _______________________________________________ > > Libvirt-cim mailing list > > Libvirt-cim at redhat.com > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > -- > Chip Vincent > Open Virtualization > IBM Linux Technology Center > cvincent at linux.vnet.ibm.com > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From cvincent at linux.vnet.ibm.com Fri Apr 1 18:55:08 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Fri, 01 Apr 2011 14:55:08 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] Fixing testcase to account for different libvirt error string In-Reply-To: References: <6d7dab79f4e8806aea65.1301604155@elm3a148.beaverton.ibm.com> <4D95CA63.40605@linux.vnet.ibm.com> Message-ID: <4D961F8C.9040506@linux.vnet.ibm.com> Excellent, Thank you. On 04/01/2011 09:52 AM, Sharad Mishra wrote: > Chip, > > Return code is not the issue. It is the error message that had changed. > This test compares the error message with the expected error message. > Since libvirt-cim does not care about the actual error message, we are > okay there. > > Sharad Mishra > Open Virtualization > Linux Technology Center > IBM > > libvirt-cim-bounces at redhat.com wrote on 04/01/2011 05:51:47 AM: > > > Chip Vincent > > Sent by: libvirt-cim-bounces at redhat.com > > > > 04/01/11 05:51 AM > > > > Please respond to > > cvincent at linux.vnet.ibm.com; Please respond to > > List for discussion and development of libvirt CIM > > > > > To > > > > libvirt-cim at redhat.com > > > > cc > > > > Subject > > > > Re: [Libvirt-cim] [PATCH] [TEST] Fixing testcase to account for > > different libvirt error string > > > > +1. Are changes needed in libvirt-cim to handle this case? That is, will > > a change in libvirt return codes break libvirt-cim? > > > > On 03/31/2011 04:42 PM, Sharad Mishra wrote: > > > # HG changeset patch > > > # User Sharad Mishra > > > # Date 1301604051 25200 > > > # Node ID 6d7dab79f4e8806aea65cb413c4f193cdbfc4f40 > > > # Parent f0a7eee4cbe06cc4f618770ac149218a1bddb171 > > > [TEST] Fixing testcase to account for different libvirt error string. > > > > > > Noticed that this test was failing on some libvirt versions between > > > 0.7.0 and 0.8.7 because libvirt was returning new error message. Latest > > > libvirt (0.8.7-5) is back to using error string from libvirt versions > > > prior to 0.7.0. > > > > > > Signed-off-by: Sharad Mishra > > > > > > diff -r f0a7eee4cbe0 -r 6d7dab79f4e8 suites/libvirt-cim/cimtest/ > > VirtualSystemManagementService/19_definenetwork_ers.py > > > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > > 19_definenetwork_ers.py Thu Mar 31 12:32:11 2011 -0700 > > > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > > 19_definenetwork_ers.py Thu Mar 31 13:40:51 2011 -0700 > > > @@ -125,10 +125,17 @@ > > > if not ret: > > > status = verify_error(exp_rc, exp_desc, cxml) > > > if status != PASS: > > > - raise Exception('Defing domain with > > invalid %s name %s' > > > - ' gave unexpected rc code %s and ' > > > - 'description:\n %s'% > > (nettype, field, > > > - cxml.err_rc, cxml.err_desc)) > > > + # There are few libvirt version between 0.7.0 > > > + # and 0.8.7 which give following error. > > > + status = verify_error(exp_rc, > > > + 'No Network bridge > > name specified', > > > + cxml) > > > + if status != PASS: > > > + raise Exception('Defining domain with > > invalid %s' > > > + ' name %s gave > > unexpected rc code' > > > + ' %s and description:\n' > > > + ' %s'% (nettype, field, > > > + cxml.err_rc, cxml.err_desc)) > > > continue > > > ret = cxml.cim_start(options.ip) > > > if ret: > > > > > > _______________________________________________ > > > Libvirt-cim mailing list > > > Libvirt-cim at redhat.com > > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > > > -- > > Chip Vincent > > Open Virtualization > > IBM Linux Technology Center > > cvincent at linux.vnet.ibm.com > > > > _______________________________________________ > > Libvirt-cim mailing list > > Libvirt-cim at redhat.com > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From snmishra at us.ibm.com Mon Apr 4 19:16:52 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Mon, 04 Apr 2011 12:16:52 -0700 Subject: [Libvirt-cim] [PATCH] [TEST] Proc RASD should not be null Message-ID: <3a5abef07035297549e3.1301944612@elm3b197.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1301944448 25200 # Node ID 3a5abef07035297549e34542e7789bd4488a9e86 # Parent a68509f68d565c55afa4d89942b55eb10374b32e [TEST] Proc RASD should not be null. This test was failing on libvirt 0.8 and higher as it did not like an empty proc rasd. Signed-off-by: Sharad Mishra diff -r a68509f68d56 -r 3a5abef07035 suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Thu Mar 31 14:06:44 2011 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Mon Apr 04 12:14:08 2011 -0700 @@ -55,8 +55,6 @@ rasd['Limit'] = Uint64(value) rasd['AllocationUnits'] = units rasd_list[mrasd_cn] = inst_to_mof(rasd) - else: - rasd_list[rasd.classname] = None if rasd_list[mrasd_cn] is None: logger.error("Unable to get template MemRASD") From snmishra at us.ibm.com Mon Apr 4 19:46:51 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Mon, 04 Apr 2011 12:46:51 -0700 Subject: [Libvirt-cim] [PATCH] [TEST] Conditionally fail this test if QEMU command 'device_add' fails Message-ID: <96ef3d9cdb65d32f54fc.1301946411@elm3b197.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1301946359 25200 # Node ID 96ef3d9cdb65d32f54fce85d5c154cd84466ea24 # Parent 4d2dc8ffbd280bf988c7fa9c9bc08d87785dec72 [TEST] Conditionally fail this test if QEMU command 'device_add' fails. This test will fail if hotplugging is not supported. Signed-off-by: Sharad Mishra diff -r 4d2dc8ffbd28 -r 96ef3d9cdb65 suites/libvirt-cim/cimtest/VirtualSystemManagementService/30_dynamic_disk_mod.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/30_dynamic_disk_mod.py Mon Apr 04 12:42:52 2011 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/30_dynamic_disk_mod.py Mon Apr 04 12:45:59 2011 -0700 @@ -28,7 +28,7 @@ from XenKvmLib.classes import get_typed_class from CimTest.Globals import logger from XenKvmLib.const import do_main -from CimTest.ReturnCodes import FAIL, PASS +from CimTest.ReturnCodes import FAIL, PASS, XFAIL from XenKvmLib import vsms_util sup_types = ['Xen', 'KVM', 'XenFV'] @@ -72,7 +72,7 @@ status = vsms_util.add_disk_res(options.ip, service, cxml, vssd_ref, dasd, disk_attr) if status != PASS: - return FAIL + return XFAIL dasd = vsms.get_dasd_class(options.virt)(dev='vdc', instanceid='rstest_domain/vda', source='/home/rss.iso', From cvincent at linux.vnet.ibm.com Tue Apr 5 14:35:51 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 05 Apr 2011 10:35:51 -0400 Subject: [Libvirt-cim] [PATCH] Add support for console/serial grahpics devices Message-ID: <18793660dbc8f0755062.1302014151@oc0840652111.ibm.com> # HG changeset patch # User Chip Vincent # Date 1301520765 14400 # Node ID 18793660dbc8f0755062a7f90902379288501f4c # Parent a521a11eeec4b41399ca954ab17b874a708eb4b3 Add support for console/serial grahpics devices Add support for Graphics RASD ResourceSubType = console | serial. This includes support for allowing more than a single graphics RASD instance. Instances can be created externally or during DefineSystem. No changes to current level of hotswapping. Signed-off-by: Chip Vincent diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -40,7 +40,8 @@ #define NET_XPATH (xmlChar *)"/domain/devices/interface" #define EMU_XPATH (xmlChar *)"/domain/devices/emulator" #define MEM_XPATH (xmlChar *)"/domain/memory | /domain/currentMemory" -#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics" +#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ + "/domain/devices/console | /domain/devices/serial" #define INPUT_XPATH (xmlChar *)"/domain/devices/input" #define DEFAULT_BRIDGE "xenbr0" @@ -501,6 +502,7 @@ { struct virt_device *vdev = NULL; struct graphics_device *gdev = NULL; + xmlNode *child = NULL; vdev = calloc(1, sizeof(*vdev)); if (vdev == NULL) @@ -509,24 +511,51 @@ gdev = &(vdev->dev.graphics); gdev->type = get_attr_value(node, "type"); - gdev->port = get_attr_value(node, "port"); - gdev->host = get_attr_value(node, "listen"); - gdev->keymap = get_attr_value(node, "keymap"); - if (gdev->type == NULL) goto err; + CU_DEBUG("graphics device type = %s", gdev->type); + if (STREQC(gdev->type, "vnc")) { - if (gdev->port == NULL) + gdev->port = get_attr_value(node, "port"); + gdev->host = get_attr_value(node, "listen"); + gdev->keymap = get_attr_value(node, "keymap"); + + if (gdev->port == NULL || gdev->host == NULL) + goto err; + } + else if (STREQC(gdev->type, "pty")) { + if (node->name == NULL) goto err; - if (gdev->host == NULL) - goto err; + /* Change type to serial, console, etc. It will be converted back + in xmlgen.c */ + free(gdev->type); + gdev->type = strdup((char *)node->name); + + for (child = node->children; child != NULL; + child = child->next) { + if (XSTREQ(child->name, "source")) + gdev->host = get_attr_value(child, "path"); + else if (XSTREQ(child->name, "target")) + gdev->port = get_attr_value(child, "port"); + } + } + else { + CU_DEBUG("Unknown graphics type %s", gdev->type); + goto err; } vdev->type = CIM_RES_TYPE_GRAPHICS; vdev->id = strdup("graphics"); + /* FIXME: IDs should be unique, but that breaks existing tests. + ret = asprintf(&vdev->id, "graphics:%s", gdev->type); + if(ret == -1) { + CU_DEBUG("Failed to create graphics is string"); + goto err; + } */ + *vdevs = vdev; return 1; diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -401,43 +401,92 @@ return NULL; } +static const char *graphics_vnc_xml(xmlNodePtr root, + struct graphics_device *dev) +{ + xmlNodePtr tmp = NULL; + + tmp = xmlNewChild(root, NULL, BAD_CAST "graphics", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); + + if (STREQC(dev->type, "sdl")) + return NULL; + + if (dev->port) { + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); + if (STREQC(dev->port, "-1")) + xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes"); + else + xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no"); + } + + if (dev->host) + xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host); + + if (dev->passwd) + xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST dev->passwd); + + if (dev->keymap) + xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap); + + return NULL; +} + +static const char *graphics_pty_xml(xmlNodePtr root, + struct graphics_device *dev) +{ + xmlNodePtr pty = NULL; + xmlNodePtr tmp = NULL; + + pty = xmlNewChild(root, NULL, BAD_CAST dev->type, NULL); + if (pty == NULL) + return XML_ERROR; + + xmlNewProp(pty, BAD_CAST "type", BAD_CAST "pty"); + + tmp = xmlNewChild(pty, NULL, BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + + if(dev->host) + xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev->host); + + tmp = xmlNewChild(pty, NULL, BAD_CAST "target", NULL); + if (tmp == NULL) + return XML_ERROR; + + if(dev->port) + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); + + return NULL; +} + static const char *graphics_xml(xmlNodePtr root, struct domain *dominfo) { + const char *msg = NULL; int i; for (i = 0; i < dominfo->dev_graphics_ct; i++) { - xmlNodePtr tmp; struct virt_device *_dev = &dominfo->dev_graphics[i]; if (_dev->type == CIM_RES_TYPE_UNKNOWN) continue; 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); - - if (STREQC(dev->type, "sdl")) - goto out; - - if (STREQC(dev->port, "-1")) - xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes"); - else { - xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no"); - 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); - - if (dev->passwd != NULL) - xmlNewProp(tmp, - BAD_CAST "passwd", - BAD_CAST dev->passwd); + if (STREQC(dev->type, "vnc") || STREQC(dev->type, "sdl")) + msg = graphics_vnc_xml(root, dev); + else if (STREQC(dev->type, "console") || STREQC(dev->type, "serial")) + msg = graphics_pty_xml(root, dev); + else + continue; + + if(msg != NULL) + return msg; } - out: return NULL; } diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -216,8 +216,10 @@ ] class Xen_GraphicsResourceAllocationSettingData : Xen_ResourceAllocationSettingData { - [Description ("VNC Address. IPv4 in a.b.c.d:port or" - "IPv6 in [ip]:port format")] + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType " + "is 'console', this is a character device path in " + "path:port format (e.g., '/dev/pts/3:0'\)")] string Address; [Description ("Keyboard keymapping")] @@ -235,8 +237,10 @@ ] class KVM_GraphicsResourceAllocationSettingData : KVM_ResourceAllocationSettingData { - [Description ("VNC Address. IPv4 in a.b.c.d:port or" - "IPv6 in [ip]:port format")] + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType " + "is 'console', this is a character device path in " + "path:port format (e.g., '/dev/pts/3:0'\)")] string Address; [Description ("Keyboard keymapping")] @@ -254,8 +258,10 @@ ] class LXC_GraphicsResourceAllocationSettingData : LXC_ResourceAllocationSettingData { - [Description ("VNC Address. IPv4 in a.b.c.d:port or" - "IPv6 in [ip]:port format")] + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType " + "is 'console', this is a character device path in " + "path:port format (e.g., '/dev/pts/3:0'\)")] string Address; [Description ("Keyboard keymapping")] diff --git a/src/Virt_Device.c b/src/Virt_Device.c --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -189,14 +189,13 @@ int rc; char *vp_str = NULL; - if (STREQC(dev->type, "vnc")) + if (STREQC(dev->type, "sdl")) + rc = asprintf(&vp_str, "%s", dev->type); + else rc = asprintf(&vp_str, "%s/%s:%s", dev->type, dev->host, dev->port); - else - rc = asprintf(&vp_str, "%s", dev->type); - if (rc == -1) return 0; diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -421,44 +421,56 @@ CMSetProperty(inst, "ResourceSubType", (CMPIValue *)dev->dev.graphics.type, CMPI_chars); - if (STREQC(dev->dev.graphics.type, "vnc")) { + if (STREQC(dev->dev.graphics.type, "sdl")) + rc = asprintf(&addr_str, "%s", dev->dev.graphics.type); + else { rc = asprintf(&addr_str, "%s:%s", dev->dev.graphics.host, dev->dev.graphics.port); - if (rc == -1) + } + + CU_DEBUG("graphics Address = %s", addr_str); + + if (rc == -1) + goto out; + + CMSetProperty(inst, "Address", + (CMPIValue *)addr_str, CMPI_chars); + + if (STREQC(dev->dev.graphics.type, "vnc")) { + CMSetProperty(inst, "KeyMap", + (CMPIValue *)dev->dev.graphics.keymap, CMPI_chars); + + conn = connect_by_classname(_BROKER, classname, &s); + if (conn == NULL) goto out; - CMSetProperty(inst, "Address", - (CMPIValue *)addr_str, CMPI_chars); + dom = virDomainLookupByName(conn, name); + if (dom == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "Domain %s not found", + name); + goto out; + } - CMSetProperty(inst, "KeyMap", - (CMPIValue *)dev->dev.graphics.keymap, CMPI_chars); + infostore = infostore_open(dom); + if (infostore != NULL) + has_passwd = infostore_get_bool(infostore, + "has_vnc_passwd"); + + if (has_passwd) { + CU_DEBUG("has password"); + CMSetProperty(inst, "Password", + (CMPIValue *)"********", CMPI_chars); + } + + infostore_close(infostore); + + /* FIXME: Populate the IsIPv6Only */ } - conn = connect_by_classname(_BROKER, classname, &s); - if (conn == NULL) - goto out; - - dom = virDomainLookupByName(conn, name); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "Domain %s not found", - name); - goto out; - } - - infostore = infostore_open(dom); - if (infostore != NULL) - has_passwd = infostore_get_bool(infostore, "has_vnc_passwd"); - - if (has_passwd) - CMSetProperty(inst, "Password", - (CMPIValue *)"********", CMPI_chars); - - infostore_close(infostore); - out: free(addr_str); virDomainFree(dom); diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c +++ b/src/Virt_SettingsDefineCapabilities.c @@ -1694,10 +1694,9 @@ inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_GRAPHICS, DEVICE_RASD); CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); - + CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars); + if (STREQC(type, "vnc")) { - CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars); - CMSetProperty(inst, "KeyMap", (CMPIValue *)"en-us", CMPI_chars); } diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -405,7 +405,7 @@ static bool add_default_devs(struct domain *domain) { - if (domain->dev_graphics_ct != 1) { + if (domain->dev_graphics_ct < 1) { if (!default_graphics_device(domain)) return false; } @@ -1027,6 +1027,38 @@ return NULL; } +static int parse_console_address(const char *id, + char **path, + char **port) +{ + int ret; + char *tmp_path = NULL; + char *tmp_port = NULL; + + CU_DEBUG("Entering parse_console_address, address is %s", id); + + ret = sscanf(id, "%a[^:]:%as", &tmp_path, &tmp_port); + + if (ret != 2) { + ret = 0; + goto out; + } + + if (path) + *path = strdup(tmp_path); + + if (port) + *port = strdup(tmp_port); + + ret = 1; + + out: + CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", + *path, *port); + + return ret; +} + static int parse_vnc_address(const char *id, char **ip, char **port) @@ -1059,8 +1091,6 @@ out: CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", *ip, *port); - free(tmp_ip); - free(tmp_port); return ret; } @@ -1068,9 +1098,8 @@ static const char *graphics_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev) { - const char *val; + const char *val = NULL; const char *msg = NULL; - const char *keymap; bool ipv6 = false; int ret; @@ -1080,36 +1109,67 @@ } dev->dev.graphics.type = strdup(val); + CU_DEBUG("graphics type = %s", dev->dev.graphics.type); + /* FIXME: Add logic to prevent address:port collisions */ - if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { - CU_DEBUG("no graphics port defined, giving default"); - if (cu_get_bool_prop(inst, "IsIPv6Only", &ipv6) != CMPI_RC_OK) - ipv6 = false; - if (ipv6) - dev->dev.graphics.host = strdup("[::1]"); - else - dev->dev.graphics.host = strdup("127.0.0.1"); - dev->dev.graphics.port = strdup("-1"); - } else { - ret = parse_vnc_address(val, - &dev->dev.graphics.host, - &dev->dev.graphics.port); + if (STREQC(dev->dev.graphics.type, "vnc")) { + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { + CU_DEBUG("graphics Address empty, using default"); + + if (cu_get_bool_prop(inst, "IsIPV6Only", &ipv6) != CMPI_RC_OK) + ipv6 = false; + + if(ipv6) + val = "[::1]:-1"; + else + val = "127.0.0.1:-1"; + } + + ret = parse_vnc_address(val, + &dev->dev.graphics.host, + &dev->dev.graphics.port); if (ret != 1) { msg = "GraphicsRASD field Address not valid"; goto out; } + + if (cu_get_str_prop(inst, "KeyMap", &val) != CMPI_RC_OK) + dev->dev.graphics.keymap = strdup("en-us"); + else + dev->dev.graphics.keymap = strdup(val); + + if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { + CU_DEBUG("vnc password is not set"); + dev->dev.graphics.passwd = NULL; + } else { + CU_DEBUG("vnc password is set"); + dev->dev.graphics.passwd = strdup(val); + } } - - if (cu_get_str_prop(inst, "KeyMap", &keymap) != CMPI_RC_OK) - keymap = "en-us"; - - dev->dev.graphics.keymap = strdup(keymap); - - if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { - dev->dev.graphics.passwd = NULL; - } else { - dev->dev.graphics.passwd = strdup(val); - } + else if (STREQC(dev->dev.graphics.type, "console") || + STREQC(dev->dev.graphics.type, "serial")) { + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { + CU_DEBUG("graphics Address empty, using default"); + val = "/dev/pts/0:0"; + } + + ret = parse_console_address(val, + &dev->dev.graphics.host, + &dev->dev.graphics.port); + if (ret != 1) { + msg = "GraphicsRASD field Address not valid"; + goto out; + } + } else { + CU_DEBUG("Unsupported graphics type %s", dev->dev.graphics.type); + msg = "Unsupported graphics type"; + goto out; + } + + CU_DEBUG("graphics = %s:%s:%s", + dev->dev.graphics.type, + dev->dev.graphics.host, + dev->dev.graphics.port); out: return msg; @@ -1250,6 +1310,9 @@ "DiskResourceAllocationSettingData in a single " "guest"; + if (dev->type == CIM_RES_TYPE_GRAPHICS) + continue; + if (STREQC(ptr->id, dev->id)) { CU_DEBUG("Overriding device %s from refconf", ptr->id); cleanup_virt_device(ptr); @@ -1358,11 +1421,19 @@ ncount, &domain->dev_net_ct); } else if (type == CIM_RES_TYPE_GRAPHICS) { - domain->dev_graphics_ct = 1; + struct virt_device dev; + int ncount = count + domain->dev_graphics_ct; + + memset(&dev, 0, sizeof(dev)); msg = rasd_to_vdev(inst, domain, - &domain->dev_graphics[0], + &dev, ns); + if (msg == NULL) + msg = add_device_nodup(&dev, + domain->dev_graphics, + ncount, + &domain->dev_graphics_ct); } else if (type == CIM_RES_TYPE_INPUT) { domain->dev_input_ct = 1; msg = rasd_to_vdev(inst, @@ -2318,13 +2389,6 @@ goto out; } - if ((type == CIM_RES_TYPE_GRAPHICS) && (*count > 0)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "A resource already exists for type %" PRIu16, type); - goto out; - } - list = realloc(*_list, ((*count)+1)*sizeof(struct virt_device)); if (list == NULL) { /* No memory */ From snmishra at us.ibm.com Wed Apr 6 19:19:16 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Wed, 6 Apr 2011 12:19:16 -0700 Subject: [Libvirt-cim] [PATCH] Add support for console/serial grahpics devices In-Reply-To: <18793660dbc8f0755062.1302014151@oc0840652111.ibm.com> References: <18793660dbc8f0755062.1302014151@oc0840652111.ibm.com> Message-ID: Chip, My comments are inline below at 2 places. There are few lines in this patch that are longer than 80 characters, please correct them. Thanks, Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces at redhat.com wrote on 04/05/2011 07:35:51 AM: > Chip Vincent > Sent by: libvirt-cim-bounces at redhat.com > > 04/05/2011 07:35 AM > > Please respond to > List for discussion and development of libvirt CIM > > To > > libvirt-cim at redhat.com > > cc > > Subject > > [Libvirt-cim] [PATCH] Add support for console/serial grahpics devices > > # HG changeset patch > # User Chip Vincent > # Date 1301520765 14400 > # Node ID 18793660dbc8f0755062a7f90902379288501f4c > # Parent a521a11eeec4b41399ca954ab17b874a708eb4b3 > Add support for console/serial grahpics devices > > Add support for Graphics RASD ResourceSubType = console | serial. > This includes support for > allowing more than a single graphics RASD instance. Instances can be > created externally or > during DefineSystem. No changes to current level of hotswapping. > > Signed-off-by: Chip Vincent > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -40,7 +40,8 @@ > #define NET_XPATH (xmlChar *)"/domain/devices/interface" > #define EMU_XPATH (xmlChar *)"/domain/devices/emulator" > #define MEM_XPATH (xmlChar *)"/domain/memory | /domain/currentMemory" > -#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics" > +#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ > + "/domain/devices/console | /domain/devices/serial" > #define INPUT_XPATH (xmlChar *)"/domain/devices/input" > > #define DEFAULT_BRIDGE "xenbr0" > @@ -501,6 +502,7 @@ > { > struct virt_device *vdev = NULL; > struct graphics_device *gdev = NULL; > + xmlNode *child = NULL; > > vdev = calloc(1, sizeof(*vdev)); > if (vdev == NULL) > @@ -509,24 +511,51 @@ > gdev = &(vdev->dev.graphics); > > gdev->type = get_attr_value(node, "type"); > - gdev->port = get_attr_value(node, "port"); > - gdev->host = get_attr_value(node, "listen"); > - gdev->keymap = get_attr_value(node, "keymap"); > - > if (gdev->type == NULL) > goto err; > > + CU_DEBUG("graphics device type = %s", gdev->type); > + > if (STREQC(gdev->type, "vnc")) { > - if (gdev->port == NULL) > + gdev->port = get_attr_value(node, "port"); > + gdev->host = get_attr_value(node, "listen"); > + gdev->keymap = get_attr_value(node, "keymap"); > + > + if (gdev->port == NULL || gdev->host == NULL) > + goto err; > + } > + else if (STREQC(gdev->type, "pty")) { > + if (node->name == NULL) > goto err; > > - if (gdev->host == NULL) > - goto err; > + /* Change type to serial, console, etc. It will be > converted back > + in xmlgen.c */ > + free(gdev->type); > + gdev->type = strdup((char *)node->name); > + > + for (child = node->children; child != NULL; > + child = child->next) { > + if (XSTREQ(child->name, "source")) > + gdev->host = get_attr_value(child, "path"); > + else if (XSTREQ(child->name, "target")) > + gdev->port = get_attr_value(child, "port"); > + } > + } > + else { > + CU_DEBUG("Unknown graphics type %s", gdev->type); > + goto err; > } > > vdev->type = CIM_RES_TYPE_GRAPHICS; > vdev->id = strdup("graphics"); > > + /* FIXME: IDs should be unique, but that breaks existing tests. > + ret = asprintf(&vdev->id, "graphics:%s", gdev->type); > + if(ret == -1) { > + CU_DEBUG("Failed to create graphics is string"); > + goto err; > + } */ > + > *vdevs = vdev; > > return 1; > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -401,43 +401,92 @@ > return NULL; > } > > +static const char *graphics_vnc_xml(xmlNodePtr root, > + struct graphics_device *dev) > +{ > + xmlNodePtr tmp = NULL; > + > + tmp = xmlNewChild(root, NULL, BAD_CAST "graphics", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + > + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); > + > + if (STREQC(dev->type, "sdl")) > + return NULL; > + > + if (dev->port) { > + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); > + if (STREQC(dev->port, "-1")) > + xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes"); > + else > + xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no"); > + } > + > + if (dev->host) > + xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host); > + > + if (dev->passwd) > + xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST dev-> passwd); > + > + if (dev->keymap) > + xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev-> keymap); > + > + return NULL; > +} > + > +static const char *graphics_pty_xml(xmlNodePtr root, > + struct graphics_device *dev) > +{ > + xmlNodePtr pty = NULL; > + xmlNodePtr tmp = NULL; > + > + pty = xmlNewChild(root, NULL, BAD_CAST dev->type, NULL); > + if (pty == NULL) > + return XML_ERROR; > + > + xmlNewProp(pty, BAD_CAST "type", BAD_CAST "pty"); > + > + tmp = xmlNewChild(pty, NULL, BAD_CAST "source", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + > + if(dev->host) > + xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev->host); > + > + tmp = xmlNewChild(pty, NULL, BAD_CAST "target", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + > + if(dev->port) > + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); > + > + return NULL; > +} > + > static const char *graphics_xml(xmlNodePtr root, struct domain *dominfo) > { > + const char *msg = NULL; > int i; > > for (i = 0; i < dominfo->dev_graphics_ct; i++) { > - xmlNodePtr tmp; > struct virt_device *_dev = &dominfo->dev_graphics[i]; > if (_dev->type == CIM_RES_TYPE_UNKNOWN) > continue; > > 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); > - > - if (STREQC(dev->type, "sdl")) > - goto out; > - > - if (STREQC(dev->port, "-1")) > - xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes"); > - else { > - xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no"); > - 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); > - > - if (dev->passwd != NULL) > - xmlNewProp(tmp, > - BAD_CAST "passwd", > - BAD_CAST dev->passwd); > + if (STREQC(dev->type, "vnc") || STREQC(dev->type, "sdl")) > + msg = graphics_vnc_xml(root, dev); > + else if (STREQC(dev->type, "console") || STREQC > (dev->type, "serial")) > + msg = graphics_pty_xml(root, dev); > + else > + continue; > + > + if(msg != NULL) > + return msg; > } > > - out: > return NULL; > } > > diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ > ResourceAllocationSettingData.mof > --- a/schema/ResourceAllocationSettingData.mof > +++ b/schema/ResourceAllocationSettingData.mof > @@ -216,8 +216,10 @@ > ] > class Xen_GraphicsResourceAllocationSettingData : > Xen_ResourceAllocationSettingData > { > - [Description ("VNC Address. IPv4 in a.b.c.d:port or" > - "IPv6 in [ip]:port format")] > + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " > + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If > ResourceSubType " > + "is 'console', this is a character device path in " > + "path:port format (e.g., '/dev/pts/3:0'\)")] > string Address; > > [Description ("Keyboard keymapping")] > @@ -235,8 +237,10 @@ > ] > class KVM_GraphicsResourceAllocationSettingData : > KVM_ResourceAllocationSettingData > { > - [Description ("VNC Address. IPv4 in a.b.c.d:port or" > - "IPv6 in [ip]:port format")] > + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " > + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If > ResourceSubType " > + "is 'console', this is a character device path in " > + "path:port format (e.g., '/dev/pts/3:0'\)")] > string Address; > > [Description ("Keyboard keymapping")] > @@ -254,8 +258,10 @@ > ] > class LXC_GraphicsResourceAllocationSettingData : > LXC_ResourceAllocationSettingData > { > - [Description ("VNC Address. IPv4 in a.b.c.d:port or" > - "IPv6 in [ip]:port format")] > + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " > + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If > ResourceSubType " > + "is 'console', this is a character device path in " > + "path:port format (e.g., '/dev/pts/3:0'\)")] > string Address; > > [Description ("Keyboard keymapping")] > diff --git a/src/Virt_Device.c b/src/Virt_Device.c > --- a/src/Virt_Device.c > +++ b/src/Virt_Device.c > @@ -189,14 +189,13 @@ > int rc; > char *vp_str = NULL; > > - if (STREQC(dev->type, "vnc")) > + if (STREQC(dev->type, "sdl")) > + rc = asprintf(&vp_str, "%s", dev->type); > + else > rc = asprintf(&vp_str, "%s/%s:%s", > dev->type, > dev->host, > dev->port); > - else > - rc = asprintf(&vp_str, "%s", dev->type); > - > if (rc == -1) > return 0; > > diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c > --- a/src/Virt_RASD.c > +++ b/src/Virt_RASD.c > @@ -421,44 +421,56 @@ > CMSetProperty(inst, "ResourceSubType", > (CMPIValue *)dev->dev.graphics.type, CMPI_chars); > > - if (STREQC(dev->dev.graphics.type, "vnc")) { > + if (STREQC(dev->dev.graphics.type, "sdl")) > + rc = asprintf(&addr_str, "%s", dev->dev.graphics.type); > + else { > rc = asprintf(&addr_str, > "%s:%s", > dev->dev.graphics.host, > dev->dev.graphics.port); > - if (rc == -1) > + } > + > + CU_DEBUG("graphics Address = %s", addr_str); > + > + if (rc == -1) > + goto out; > + > + CMSetProperty(inst, "Address", > + (CMPIValue *)addr_str, CMPI_chars); > + > + if (STREQC(dev->dev.graphics.type, "vnc")) { > + CMSetProperty(inst, "KeyMap", > + (CMPIValue *)dev->dev.graphics.keymap, > CMPI_chars); > + > + conn = connect_by_classname(_BROKER, classname, &s); > + if (conn == NULL) > goto out; > > - CMSetProperty(inst, "Address", > - (CMPIValue *)addr_str, CMPI_chars); > + dom = virDomainLookupByName(conn, name); > + if (dom == NULL) { > + cu_statusf(_BROKER, &s, > + CMPI_RC_ERR_NOT_FOUND, > + "Domain %s not found", > + name); > + goto out; > + } > > - CMSetProperty(inst, "KeyMap", > - (CMPIValue *)dev->dev.graphics.keymap, > CMPI_chars); > + infostore = infostore_open(dom); > + if (infostore != NULL) > + has_passwd = infostore_get_bool(infostore, > + "has_vnc_passwd"); > + > + if (has_passwd) { > + CU_DEBUG("has password"); Password is being set to "*****". According to libvirt.org, password should appear in clear text. I am not seeing password attribute in libvirt xml even when password is being passed to libvirt-cim. Here is the libvirt xml generated - I was expecting something like this - Libvirt-cim log indicates that code knew about password but lost it somewhere - device_parsing.c(517): graphics device type = vnc Virt_RASD.c(433): graphics Address = 127.0.0.1:5910 misc_util.c(75): Connecting to libvirt with uri `qemu:///system' infostore.c(89): Path is /etc/libvirt/cim/QEMU_test_kvmredsap_dom Virt_RASD.c(464): has password > + CMSetProperty(inst, "Password", > + (CMPIValue *)"********", CMPI_chars); > + } > + > + infostore_close(infostore); > + > + /* FIXME: Populate the IsIPv6Only */ > } > > - conn = connect_by_classname(_BROKER, classname, &s); > - if (conn == NULL) > - goto out; > - > - dom = virDomainLookupByName(conn, name); > - if (dom == NULL) { > - cu_statusf(_BROKER, &s, > - CMPI_RC_ERR_NOT_FOUND, > - "Domain %s not found", > - name); > - goto out; > - } > - > - infostore = infostore_open(dom); > - if (infostore != NULL) > - has_passwd = infostore_get_bool(infostore, "has_vnc_passwd"); > - > - if (has_passwd) > - CMSetProperty(inst, "Password", > - (CMPIValue *)"********", CMPI_chars); > - > - infostore_close(infostore); > - > out: > free(addr_str); > virDomainFree(dom); > diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/ > Virt_SettingsDefineCapabilities.c > --- a/src/Virt_SettingsDefineCapabilities.c > +++ b/src/Virt_SettingsDefineCapabilities.c > @@ -1694,10 +1694,9 @@ > inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_GRAPHICS, DEVICE_RASD); > > CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); > - > + CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars); > + > if (STREQC(type, "vnc")) { > - CMSetProperty(inst, "Address", (CMPIValue *)addr, > CMPI_chars); > - > CMSetProperty(inst, "KeyMap", (CMPIValue *)"en-us", > CMPI_chars); > } > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/ > Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -405,7 +405,7 @@ > > static bool add_default_devs(struct domain *domain) > { > - if (domain->dev_graphics_ct != 1) { > + if (domain->dev_graphics_ct < 1) { > if (!default_graphics_device(domain)) > return false; > } > @@ -1027,6 +1027,38 @@ > return NULL; > } > > +static int parse_console_address(const char *id, > + char **path, > + char **port) > +{ > + int ret; > + char *tmp_path = NULL; > + char *tmp_port = NULL; > + > + CU_DEBUG("Entering parse_console_address, address is %s", id); > + > + ret = sscanf(id, "%a[^:]:%as", &tmp_path, &tmp_port); > + > + if (ret != 2) { > + ret = 0; > + goto out; > + } > + > + if (path) > + *path = strdup(tmp_path); > + > + if (port) > + *port = strdup(tmp_port); > + > + ret = 1; > + > + out: > + CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", > + *path, *port); > + > + return ret; > +} > + > static int parse_vnc_address(const char *id, > char **ip, > char **port) > @@ -1059,8 +1091,6 @@ > > out: > CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", > *ip, *port); > - free(tmp_ip); > - free(tmp_port); > > return ret; > } > @@ -1068,9 +1098,8 @@ > static const char *graphics_rasd_to_vdev(CMPIInstance *inst, > struct virt_device *dev) > { > - const char *val; > + const char *val = NULL; > const char *msg = NULL; > - const char *keymap; > bool ipv6 = false; > int ret; > > @@ -1080,36 +1109,67 @@ > } > dev->dev.graphics.type = strdup(val); > > + CU_DEBUG("graphics type = %s", dev->dev.graphics.type); > + If graphics type is "sdl", then the logic below leads to error message that "sdl" is unsupported > /* FIXME: Add logic to prevent address:port collisions */ > - if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > - CU_DEBUG("no graphics port defined, giving default"); > - if (cu_get_bool_prop(inst, "IsIPv6Only", &ipv6) != > CMPI_RC_OK) > - ipv6 = false; > - if (ipv6) > - dev->dev.graphics.host = strdup("[::1]"); > - else > - dev->dev.graphics.host = strdup("127.0.0.1"); > - dev->dev.graphics.port = strdup("-1"); > - } else { > - ret = parse_vnc_address(val, > - &dev->dev.graphics.host, > - &dev->dev.graphics.port); > + if (STREQC(dev->dev.graphics.type, "vnc")) { > + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > + CU_DEBUG("graphics Address empty, using default"); > + > + if (cu_get_bool_prop(inst, "IsIPV6Only", > &ipv6) != CMPI_RC_OK) > + ipv6 = false; > + > + if(ipv6) > + val = "[::1]:-1"; > + else > + val = "127.0.0.1:-1"; > + } > + > + ret = parse_vnc_address(val, > + &dev->dev.graphics.host, > + &dev->dev.graphics.port); > if (ret != 1) { > msg = "GraphicsRASD field Address not valid"; > goto out; > } > + > + if (cu_get_str_prop(inst, "KeyMap", &val) != CMPI_RC_OK) > + dev->dev.graphics.keymap = strdup("en-us"); > + else > + dev->dev.graphics.keymap = strdup(val); > + > + if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { > + CU_DEBUG("vnc password is not set"); > + dev->dev.graphics.passwd = NULL; > + } else { > + CU_DEBUG("vnc password is set"); > + dev->dev.graphics.passwd = strdup(val); > + } > } > - > - if (cu_get_str_prop(inst, "KeyMap", &keymap) != CMPI_RC_OK) > - keymap = "en-us"; > - > - dev->dev.graphics.keymap = strdup(keymap); > - > - if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { > - dev->dev.graphics.passwd = NULL; > - } else { > - dev->dev.graphics.passwd = strdup(val); > - } > + else if (STREQC(dev->dev.graphics.type, "console") || > + STREQC(dev->dev.graphics.type, "serial")) { > + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > + CU_DEBUG("graphics Address empty, using default"); > + val = "/dev/pts/0:0"; > + } > + > + ret = parse_console_address(val, > + &dev->dev.graphics.host, > + &dev->dev.graphics.port); > + if (ret != 1) { > + msg = "GraphicsRASD field Address not valid"; > + goto out; > + } > + } else { > + CU_DEBUG("Unsupported graphics type %s", > dev->dev.graphics.type); > + msg = "Unsupported graphics type"; > + goto out; > + } > + > + CU_DEBUG("graphics = %s:%s:%s", > + dev->dev.graphics.type, > + dev->dev.graphics.host, > + dev->dev.graphics.port); > > out: > return msg; > @@ -1250,6 +1310,9 @@ > "DiskResourceAllocationSettingData > in a single " > "guest"; > > + if (dev->type == CIM_RES_TYPE_GRAPHICS) > + continue; > + > if (STREQC(ptr->id, dev->id)) { > CU_DEBUG("Overriding device %s from > refconf", ptr->id); > cleanup_virt_device(ptr); > @@ -1358,11 +1421,19 @@ > ncount, > &domain-> dev_net_ct); > } else if (type == CIM_RES_TYPE_GRAPHICS) { > - domain->dev_graphics_ct = 1; > + struct virt_device dev; > + int ncount = count + domain->dev_graphics_ct; > + > + memset(&dev, 0, sizeof(dev)); > msg = rasd_to_vdev(inst, > domain, > - &domain->dev_graphics[0], > + &dev, > ns); > + if (msg == NULL) > + msg = add_device_nodup(&dev, > + domain-> dev_graphics, > + ncount, > + > &domain->dev_graphics_ct); > } else if (type == CIM_RES_TYPE_INPUT) { > domain->dev_input_ct = 1; > msg = rasd_to_vdev(inst, > @@ -2318,13 +2389,6 @@ > goto out; > } > > - if ((type == CIM_RES_TYPE_GRAPHICS) && (*count > 0)) { > - cu_statusf(_BROKER, &s, > - CMPI_RC_ERR_FAILED, > - "A resource already exists for type %" > PRIu16, type); > - goto out; > - } > - > list = realloc(*_list, ((*count)+1)*sizeof(struct virt_device)); > if (list == NULL) { > /* No memory */ > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From cvincent at linux.vnet.ibm.com Thu Apr 7 00:46:23 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 06 Apr 2011 20:46:23 -0400 Subject: [Libvirt-cim] [PATCH] Add support for console/serial grahpics devices In-Reply-To: References: <18793660dbc8f0755062.1302014151@oc0840652111.ibm.com> Message-ID: <4D9D095F.8080602@linux.vnet.ibm.com> Thanks for the comments. My responses below. On 04/06/2011 03:19 PM, Sharad Mishra wrote: > Chip, > > My comments are inline below at 2 places. > There are few lines in this patch that are longer than 80 characters, > please correct them. > > Thanks, > Sharad Mishra > Open Virtualization > Linux Technology Center > IBM > > libvirt-cim-bounces at redhat.com wrote on 04/05/2011 07:35:51 AM: > > > Chip Vincent > > Sent by: libvirt-cim-bounces at redhat.com > > > > + infostore = infostore_open(dom); > > + if (infostore != NULL) > > + has_passwd = infostore_get_bool(infostore, > > + "has_vnc_passwd"); > > + > > + if (has_passwd) { > > + CU_DEBUG("has password"); > > Password is being set to "*****". According to libvirt.org, password > should appear in clear text. > I am not seeing password attribute in libvirt xml even when password is > being passed to libvirt-cim. Here is the libvirt xml generated - > > keymap='en-us'/> > > I was expecting something like this - > > passwd="test0all" keymap="en-us"/> > > Libvirt-cim log indicates that code knew about password but lost it > somewhere - > > device_parsing.c(517): graphics device type = vnc > Virt_RASD.c(433): graphics Address = 127.0.0.1:5910 > misc_util.c(75): Connecting to libvirt with uri `qemu:///system' > infostore.c(89): Path is /etc/libvirt/cim/QEMU_test_kvmredsap_dom > Virt_RASD.c(464): has password > The password is only clear text when the CIM instance is created and passed to libvirt. Once the password is set, it cannot be fetched (except by a secure libvirt connection, I think). The only was to change the password today is delete the instance (or XML) and recreate with a new password. That is why the existence of a password is determine via an attribute in the libvirt-cim data store. NOTE: This is the original logic and was not changed in this patch, just re-factored to be contained within the "vnc" code path. > > @@ -1068,9 +1098,8 @@ > > static const char *graphics_rasd_to_vdev(CMPIInstance *inst, > > struct virt_device *dev) > > { > > - const char *val; > > + const char *val = NULL; > > const char *msg = NULL; > > - const char *keymap; > > bool ipv6 = false; > > int ret; > > > > @@ -1080,36 +1109,67 @@ > > } > > dev->dev.graphics.type = strdup(val); > > > > + CU_DEBUG("graphics type = %s", dev->dev.graphics.type); > > + > > If graphics type is "sdl", then the logic below leads to error message > that "sdl" is unsupported The original code only handled vnc connections and would incorrectly create other ResourceSubTypes, such as 'sdl'. For example, the original code would create sdl objects with a internet address in the XML and pass to libvirt, which would then reject the device. Since sdl did not appear to be full supported, I added it to the explicitly not supported list. We have other code that "tolerates" sdl, but more work is needed to ensure complete support. I'll defer this work to another bug/patch. > > > /* FIXME: Add logic to prevent address:port collisions */ > > - if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > > - CU_DEBUG("no graphics port defined, giving default"); > > - if (cu_get_bool_prop(inst, "IsIPv6Only", &ipv6) != > > CMPI_RC_OK) > > - ipv6 = false; > > - if (ipv6) > > - dev->dev.graphics.host = strdup("[::1]"); > > - else > > - dev->dev.graphics.host = strdup("127.0.0.1"); > > - dev->dev.graphics.port = strdup("-1"); > > - } else { > > - ret = parse_vnc_address(val, > > - &dev->dev.graphics.host, > > - &dev->dev.graphics.port); > > + if (STREQC(dev->dev.graphics.type, "vnc")) { > > + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > > + CU_DEBUG("graphics Address empty, using default"); > > + > > + if (cu_get_bool_prop(inst, "IsIPV6Only", > > &ipv6) != CMPI_RC_OK) > > + ipv6 = false; > > + > > + if(ipv6) > > + val = "[::1]:-1"; > > + else > > + val = "127.0.0.1:-1"; > > + } > > + > > + ret = parse_vnc_address(val, > > + &dev->dev.graphics.host, > > + &dev->dev.graphics.port); > > if (ret != 1) { > > msg = "GraphicsRASD field Address not valid"; > > goto out; > > } > > + > > + if (cu_get_str_prop(inst, "KeyMap", &val) != CMPI_RC_OK) > > + dev->dev.graphics.keymap = strdup("en-us"); > > + else > > + dev->dev.graphics.keymap = strdup(val); > > + > > + if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { > > + CU_DEBUG("vnc password is not set"); > > + dev->dev.graphics.passwd = NULL; > > + } else { > > + CU_DEBUG("vnc password is set"); > > + dev->dev.graphics.passwd = strdup(val); > > + } > > } > > - > > - if (cu_get_str_prop(inst, "KeyMap", &keymap) != CMPI_RC_OK) > > - keymap = "en-us"; > > - > > - dev->dev.graphics.keymap = strdup(keymap); > > - > > - if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { > > - dev->dev.graphics.passwd = NULL; > > - } else { > > - dev->dev.graphics.passwd = strdup(val); > > - } > > + else if (STREQC(dev->dev.graphics.type, "console") || > > + STREQC(dev->dev.graphics.type, "serial")) { > > + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > > + CU_DEBUG("graphics Address empty, using default"); > > + val = "/dev/pts/0:0"; > > + } > > + > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim If there are no other issues, I'll resolve the line-length issues before pushing. Agreed? -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From snmishra at us.ibm.com Thu Apr 7 14:02:04 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 7 Apr 2011 07:02:04 -0700 Subject: [Libvirt-cim] [PATCH] Add support for console/serial grahpics devices In-Reply-To: <4D9D095F.8080602@linux.vnet.ibm.com> References: <18793660dbc8f0755062.1302014151@oc0840652111.ibm.com> <4D9D095F.8080602@linux.vnet.ibm.com> Message-ID: Chip, Can you open new bugs to fix "sdl" support and "password" issues ? Regards, Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces at redhat.com wrote on 04/06/2011 05:46:23 PM: > Chip Vincent > Sent by: libvirt-cim-bounces at redhat.com > > 04/06/2011 05:46 PM > > Please respond to > cvincent at linux.vnet.ibm.com; Please respond to > List for discussion and development of libvirt CIM > > To > > libvirt-cim at redhat.com > > cc > > Subject > > Re: [Libvirt-cim] [PATCH] Add support for console/serial grahpics devices > > Thanks for the comments. My responses below. > > On 04/06/2011 03:19 PM, Sharad Mishra wrote: > > Chip, > > > > My comments are inline below at 2 places. > > There are few lines in this patch that are longer than 80 characters, > > please correct them. > > > > Thanks, > > Sharad Mishra > > Open Virtualization > > Linux Technology Center > > IBM > > > > libvirt-cim-bounces at redhat.com wrote on 04/05/2011 07:35:51 AM: > > > > > Chip Vincent > > > Sent by: libvirt-cim-bounces at redhat.com > > > > > > + infostore = infostore_open(dom); > > > + if (infostore != NULL) > > > + has_passwd = infostore_get_bool(infostore, > > > + "has_vnc_passwd"); > > > + > > > + if (has_passwd) { > > > + CU_DEBUG("has password"); > > > > Password is being set to "*****". According to libvirt.org, password > > should appear in clear text. > > I am not seeing password attribute in libvirt xml even when password is > > being passed to libvirt-cim. Here is the libvirt xml generated - > > > > > keymap='en-us'/> > > > > I was expecting something like this - > > > > > passwd="test0all" keymap="en-us"/> > > > > Libvirt-cim log indicates that code knew about password but lost it > > somewhere - > > > > device_parsing.c(517): graphics device type = vnc > > Virt_RASD.c(433): graphics Address = 127.0.0.1:5910 > > misc_util.c(75): Connecting to libvirt with uri `qemu:///system' > > infostore.c(89): Path is /etc/libvirt/cim/QEMU_test_kvmredsap_dom > > Virt_RASD.c(464): has password > > > > The password is only clear text when the CIM instance is created and > passed to libvirt. Once the password is set, it cannot be fetched > (except by a secure libvirt connection, I think). The only was to change > the password today is delete the instance (or XML) and recreate with a > new password. That is why the existence of a password is determine via > an attribute in the libvirt-cim data store. > > NOTE: This is the original logic and was not changed in this patch, just > re-factored to be contained within the "vnc" code path. > > > > > @@ -1068,9 +1098,8 @@ > > > static const char *graphics_rasd_to_vdev(CMPIInstance *inst, > > > struct virt_device *dev) > > > { > > > - const char *val; > > > + const char *val = NULL; > > > const char *msg = NULL; > > > - const char *keymap; > > > bool ipv6 = false; > > > int ret; > > > > > > @@ -1080,36 +1109,67 @@ > > > } > > > dev->dev.graphics.type = strdup(val); > > > > > > + CU_DEBUG("graphics type = %s", dev->dev.graphics.type); > > > + > > > > If graphics type is "sdl", then the logic below leads to error message > > that "sdl" is unsupported > > The original code only handled vnc connections and would incorrectly > create other ResourceSubTypes, such as 'sdl'. For example, the original > code would create sdl objects with a internet address in the XML and > pass to libvirt, which would then reject the device. Since sdl did not > appear to be full supported, I added it to the explicitly not supported > list. We have other code that "tolerates" sdl, but more work is needed > to ensure complete support. I'll defer this work to another bug/patch. > > > > > > /* FIXME: Add logic to prevent address:port collisions */ > > > - if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > > > - CU_DEBUG("no graphics port defined, giving default"); > > > - if (cu_get_bool_prop(inst, "IsIPv6Only", &ipv6) != > > > CMPI_RC_OK) > > > - ipv6 = false; > > > - if (ipv6) > > > - dev->dev.graphics.host = strdup("[::1]"); > > > - else > > > - dev->dev.graphics.host = strdup("127.0.0.1"); > > > - dev->dev.graphics.port = strdup("-1"); > > > - } else { > > > - ret = parse_vnc_address(val, > > > - &dev->dev.graphics.host, > > > - &dev->dev.graphics.port); > > > + if (STREQC(dev->dev.graphics.type, "vnc")) { > > > + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > > > + CU_DEBUG("graphics Address empty, using default"); > > > + > > > + if (cu_get_bool_prop(inst, "IsIPV6Only", > > > &ipv6) != CMPI_RC_OK) > > > + ipv6 = false; > > > + > > > + if(ipv6) > > > + val = "[::1]:-1"; > > > + else > > > + val = "127.0.0.1:-1"; > > > + } > > > + > > > + ret = parse_vnc_address(val, > > > + &dev->dev.graphics.host, > > > + &dev->dev.graphics.port); > > > if (ret != 1) { > > > msg = "GraphicsRASD field Address not valid"; > > > goto out; > > > } > > > + > > > + if (cu_get_str_prop(inst, "KeyMap", &val) != CMPI_RC_OK) > > > + dev->dev.graphics.keymap = strdup("en-us"); > > > + else > > > + dev->dev.graphics.keymap = strdup(val); > > > + > > > + if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { > > > + CU_DEBUG("vnc password is not set"); > > > + dev->dev.graphics.passwd = NULL; > > > + } else { > > > + CU_DEBUG("vnc password is set"); > > > + dev->dev.graphics.passwd = strdup(val); > > > + } > > > } > > > - > > > - if (cu_get_str_prop(inst, "KeyMap", &keymap) != CMPI_RC_OK) > > > - keymap = "en-us"; > > > - > > > - dev->dev.graphics.keymap = strdup(keymap); > > > - > > > - if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { > > > - dev->dev.graphics.passwd = NULL; > > > - } else { > > > - dev->dev.graphics.passwd = strdup(val); > > > - } > > > + else if (STREQC(dev->dev.graphics.type, "console") || > > > + STREQC(dev->dev.graphics.type, "serial")) { > > > + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > > > + CU_DEBUG("graphics Address empty, using default"); > > > + val = "/dev/pts/0:0"; > > > + } > > > + > > > > _______________________________________________ > > Libvirt-cim mailing list > > Libvirt-cim at redhat.com > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > If there are no other issues, I'll resolve the line-length issues before > pushing. Agreed? > > -- > Chip Vincent > Open Virtualization > IBM Linux Technology Center > cvincent at linux.vnet.ibm.com > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From cvincent at linux.vnet.ibm.com Thu Apr 7 17:27:19 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 07 Apr 2011 13:27:19 -0400 Subject: [Libvirt-cim] [PATCH] Add support for console/serial grahpics devices In-Reply-To: References: <18793660dbc8f0755062.1302014151@oc0840652111.ibm.com> <4D9D095F.8080602@linux.vnet.ibm.com> Message-ID: <4D9DF3F7.6000703@linux.vnet.ibm.com> Opened bug to add end-to-end support for sdl. The password logic is working as designed (password is not saved by libvirt-cim, but does show a password has been set). On 04/07/2011 10:02 AM, Sharad Mishra wrote: > Chip, > > Can you open new bugs to fix "sdl" support and "password" issues ? > > Regards, > Sharad Mishra > Open Virtualization > Linux Technology Center > IBM > > libvirt-cim-bounces at redhat.com wrote on 04/06/2011 05:46:23 PM: > > > Chip Vincent > > Sent by: libvirt-cim-bounces at redhat.com > > > > 04/06/2011 05:46 PM > > > > Please respond to > > cvincent at linux.vnet.ibm.com; Please respond to > > List for discussion and development of libvirt CIM > > > > > To > > > > libvirt-cim at redhat.com > > > > cc > > > > Subject > > > > Re: [Libvirt-cim] [PATCH] Add support for console/serial grahpics devices > > > > Thanks for the comments. My responses below. > > > > On 04/06/2011 03:19 PM, Sharad Mishra wrote: > > > Chip, > > > > > > My comments are inline below at 2 places. > > > There are few lines in this patch that are longer than 80 characters, > > > please correct them. > > > > > > Thanks, > > > Sharad Mishra > > > Open Virtualization > > > Linux Technology Center > > > IBM > > > > > > libvirt-cim-bounces at redhat.com wrote on 04/05/2011 07:35:51 AM: > > > > > > > Chip Vincent > > > > Sent by: libvirt-cim-bounces at redhat.com > > > > > > > > + infostore = infostore_open(dom); > > > > + if (infostore != NULL) > > > > + has_passwd = infostore_get_bool(infostore, > > > > + "has_vnc_passwd"); > > > > + > > > > + if (has_passwd) { > > > > + CU_DEBUG("has password"); > > > > > > Password is being set to "*****". According to libvirt.org, password > > > should appear in clear text. > > > I am not seeing password attribute in libvirt xml even when password is > > > being passed to libvirt-cim. Here is the libvirt xml generated - > > > > > > > > keymap='en-us'/> > > > > > > I was expecting something like this - > > > > > > > > passwd="test0all" keymap="en-us"/> > > > > > > Libvirt-cim log indicates that code knew about password but lost it > > > somewhere - > > > > > > device_parsing.c(517): graphics device type = vnc > > > Virt_RASD.c(433): graphics Address = 127.0.0.1:5910 > > > misc_util.c(75): Connecting to libvirt with uri `qemu:///system' > > > infostore.c(89): Path is /etc/libvirt/cim/QEMU_test_kvmredsap_dom > > > Virt_RASD.c(464): has password > > > > > > > The password is only clear text when the CIM instance is created and > > passed to libvirt. Once the password is set, it cannot be fetched > > (except by a secure libvirt connection, I think). The only was to change > > the password today is delete the instance (or XML) and recreate with a > > new password. That is why the existence of a password is determine via > > an attribute in the libvirt-cim data store. > > > > NOTE: This is the original logic and was not changed in this patch, just > > re-factored to be contained within the "vnc" code path. > > > > > > > > @@ -1068,9 +1098,8 @@ > > > > static const char *graphics_rasd_to_vdev(CMPIInstance *inst, > > > > struct virt_device *dev) > > > > { > > > > - const char *val; > > > > + const char *val = NULL; > > > > const char *msg = NULL; > > > > - const char *keymap; > > > > bool ipv6 = false; > > > > int ret; > > > > > > > > @@ -1080,36 +1109,67 @@ > > > > } > > > > dev->dev.graphics.type = strdup(val); > > > > > > > > + CU_DEBUG("graphics type = %s", dev->dev.graphics.type); > > > > + > > > > > > If graphics type is "sdl", then the logic below leads to error message > > > that "sdl" is unsupported > > > > The original code only handled vnc connections and would incorrectly > > create other ResourceSubTypes, such as 'sdl'. For example, the original > > code would create sdl objects with a internet address in the XML and > > pass to libvirt, which would then reject the device. Since sdl did not > > appear to be full supported, I added it to the explicitly not supported > > list. We have other code that "tolerates" sdl, but more work is needed > > to ensure complete support. I'll defer this work to another bug/patch. > > > > > > > > > /* FIXME: Add logic to prevent address:port collisions */ > > > > - if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > > > > - CU_DEBUG("no graphics port defined, giving default"); > > > > - if (cu_get_bool_prop(inst, "IsIPv6Only", &ipv6) != > > > > CMPI_RC_OK) > > > > - ipv6 = false; > > > > - if (ipv6) > > > > - dev->dev.graphics.host = strdup("[::1]"); > > > > - else > > > > - dev->dev.graphics.host = strdup("127.0.0.1"); > > > > - dev->dev.graphics.port = strdup("-1"); > > > > - } else { > > > > - ret = parse_vnc_address(val, > > > > - &dev->dev.graphics.host, > > > > - &dev->dev.graphics.port); > > > > + if (STREQC(dev->dev.graphics.type, "vnc")) { > > > > + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > > > > + CU_DEBUG("graphics Address empty, using default"); > > > > + > > > > + if (cu_get_bool_prop(inst, "IsIPV6Only", > > > > &ipv6) != CMPI_RC_OK) > > > > + ipv6 = false; > > > > + > > > > + if(ipv6) > > > > + val = "[::1]:-1"; > > > > + else > > > > + val = "127.0.0.1:-1"; > > > > + } > > > > + > > > > + ret = parse_vnc_address(val, > > > > + &dev->dev.graphics.host, > > > > + &dev->dev.graphics.port); > > > > if (ret != 1) { > > > > msg = "GraphicsRASD field Address not valid"; > > > > goto out; > > > > } > > > > + > > > > + if (cu_get_str_prop(inst, "KeyMap", &val) != CMPI_RC_OK) > > > > + dev->dev.graphics.keymap = strdup("en-us"); > > > > + else > > > > + dev->dev.graphics.keymap = strdup(val); > > > > + > > > > + if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { > > > > + CU_DEBUG("vnc password is not set"); > > > > + dev->dev.graphics.passwd = NULL; > > > > + } else { > > > > + CU_DEBUG("vnc password is set"); > > > > + dev->dev.graphics.passwd = strdup(val); > > > > + } > > > > } > > > > - > > > > - if (cu_get_str_prop(inst, "KeyMap", &keymap) != CMPI_RC_OK) > > > > - keymap = "en-us"; > > > > - > > > > - dev->dev.graphics.keymap = strdup(keymap); > > > > - > > > > - if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { > > > > - dev->dev.graphics.passwd = NULL; > > > > - } else { > > > > - dev->dev.graphics.passwd = strdup(val); > > > > - } > > > > + else if (STREQC(dev->dev.graphics.type, "console") || > > > > + STREQC(dev->dev.graphics.type, "serial")) { > > > > + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > > > > + CU_DEBUG("graphics Address empty, using default"); > > > > + val = "/dev/pts/0:0"; > > > > + } > > > > + > > > > > > _______________________________________________ > > > Libvirt-cim mailing list > > > Libvirt-cim at redhat.com > > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > > > If there are no other issues, I'll resolve the line-length issues before > > pushing. Agreed? > > > > -- > > Chip Vincent > > Open Virtualization > > IBM Linux Technology Center > > cvincent at linux.vnet.ibm.com > > > > _______________________________________________ > > Libvirt-cim mailing list > > Libvirt-cim at redhat.com > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Thu Apr 7 21:57:28 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 07 Apr 2011 17:57:28 -0400 Subject: [Libvirt-cim] [PATCH] (#2) Add support for console/serial grahpics devices Message-ID: <5f1131a99b0846f0e960.1302213448@oc0840652111.ibm.com> # HG changeset patch # User Chip Vincent # Date 1301520765 14400 # Node ID 5f1131a99b0846f0e960b4a0f643056b7559fcab # Parent a521a11eeec4b41399ca954ab17b874a708eb4b3 (#2) Add support for console/serial grahpics devices Add support for Graphics RASD ResourceSubType = console | serial. This includes support for allowing more than a single graphics RASD instance. Instances can be created externally or during DefineSystem. No changes to current level of hotswapping. Signed-off-by: Chip Vincent diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -40,7 +40,8 @@ #define NET_XPATH (xmlChar *)"/domain/devices/interface" #define EMU_XPATH (xmlChar *)"/domain/devices/emulator" #define MEM_XPATH (xmlChar *)"/domain/memory | /domain/currentMemory" -#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics" +#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ + "/domain/devices/console | /domain/devices/serial" #define INPUT_XPATH (xmlChar *)"/domain/devices/input" #define DEFAULT_BRIDGE "xenbr0" @@ -501,6 +502,7 @@ { struct virt_device *vdev = NULL; struct graphics_device *gdev = NULL; + xmlNode *child = NULL; vdev = calloc(1, sizeof(*vdev)); if (vdev == NULL) @@ -509,24 +511,51 @@ gdev = &(vdev->dev.graphics); gdev->type = get_attr_value(node, "type"); - gdev->port = get_attr_value(node, "port"); - gdev->host = get_attr_value(node, "listen"); - gdev->keymap = get_attr_value(node, "keymap"); - if (gdev->type == NULL) goto err; + CU_DEBUG("graphics device type = %s", gdev->type); + if (STREQC(gdev->type, "vnc")) { - if (gdev->port == NULL) + gdev->port = get_attr_value(node, "port"); + gdev->host = get_attr_value(node, "listen"); + gdev->keymap = get_attr_value(node, "keymap"); + + if (gdev->port == NULL || gdev->host == NULL) + goto err; + } + else if (STREQC(gdev->type, "pty")) { + if (node->name == NULL) goto err; - if (gdev->host == NULL) - goto err; + /* Change type to serial, console, etc. It will be converted + * back in xmlgen.c */ + free(gdev->type); + gdev->type = strdup((char *)node->name); + + for (child = node->children; child != NULL; + child = child->next) { + if (XSTREQ(child->name, "source")) + gdev->host = get_attr_value(child, "path"); + else if (XSTREQ(child->name, "target")) + gdev->port = get_attr_value(child, "port"); + } + } + else { + CU_DEBUG("Unknown graphics type %s", gdev->type); + goto err; } vdev->type = CIM_RES_TYPE_GRAPHICS; vdev->id = strdup("graphics"); + /* FIXME: IDs should be unique, but that breaks existing tests. + ret = asprintf(&vdev->id, "graphics:%s", gdev->type); + if(ret == -1) { + CU_DEBUG("Failed to create graphics is string"); + goto err; + } */ + *vdevs = vdev; return 1; diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -401,43 +401,93 @@ return NULL; } +static const char *graphics_vnc_xml(xmlNodePtr root, + struct graphics_device *dev) +{ + xmlNodePtr tmp = NULL; + + tmp = xmlNewChild(root, NULL, BAD_CAST "graphics", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); + + if (STREQC(dev->type, "sdl")) + return NULL; + + if (dev->port) { + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); + if (STREQC(dev->port, "-1")) + xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes"); + else + xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no"); + } + + if (dev->host) + xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host); + + if (dev->passwd) + xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST dev->passwd); + + if (dev->keymap) + xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap); + + return NULL; +} + +static const char *graphics_pty_xml(xmlNodePtr root, + struct graphics_device *dev) +{ + xmlNodePtr pty = NULL; + xmlNodePtr tmp = NULL; + + pty = xmlNewChild(root, NULL, BAD_CAST dev->type, NULL); + if (pty == NULL) + return XML_ERROR; + + xmlNewProp(pty, BAD_CAST "type", BAD_CAST "pty"); + + tmp = xmlNewChild(pty, NULL, BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + + if(dev->host) + xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev->host); + + tmp = xmlNewChild(pty, NULL, BAD_CAST "target", NULL); + if (tmp == NULL) + return XML_ERROR; + + if(dev->port) + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); + + return NULL; +} + static const char *graphics_xml(xmlNodePtr root, struct domain *dominfo) { + const char *msg = NULL; int i; for (i = 0; i < dominfo->dev_graphics_ct; i++) { - xmlNodePtr tmp; struct virt_device *_dev = &dominfo->dev_graphics[i]; if (_dev->type == CIM_RES_TYPE_UNKNOWN) continue; 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); - - if (STREQC(dev->type, "sdl")) - goto out; - - if (STREQC(dev->port, "-1")) - xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes"); - else { - xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no"); - 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); - - if (dev->passwd != NULL) - xmlNewProp(tmp, - BAD_CAST "passwd", - BAD_CAST dev->passwd); + if (STREQC(dev->type, "vnc") || STREQC(dev->type, "sdl")) + msg = graphics_vnc_xml(root, dev); + else if (STREQC(dev->type, "console") || + STREQC(dev->type, "serial")) + msg = graphics_pty_xml(root, dev); + else + continue; + + if(msg != NULL) + return msg; } - out: return NULL; } diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -216,8 +216,10 @@ ] class Xen_GraphicsResourceAllocationSettingData : Xen_ResourceAllocationSettingData { - [Description ("VNC Address. IPv4 in a.b.c.d:port or" - "IPv6 in [ip]:port format")] + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType " + "is 'console', this is a character device path in " + "path:port format (e.g., '/dev/pts/3:0'\)")] string Address; [Description ("Keyboard keymapping")] @@ -235,8 +237,10 @@ ] class KVM_GraphicsResourceAllocationSettingData : KVM_ResourceAllocationSettingData { - [Description ("VNC Address. IPv4 in a.b.c.d:port or" - "IPv6 in [ip]:port format")] + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType " + "is 'console', this is a character device path in " + "path:port format (e.g., '/dev/pts/3:0'\)")] string Address; [Description ("Keyboard keymapping")] @@ -254,8 +258,10 @@ ] class LXC_GraphicsResourceAllocationSettingData : LXC_ResourceAllocationSettingData { - [Description ("VNC Address. IPv4 in a.b.c.d:port or" - "IPv6 in [ip]:port format")] + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType " + "is 'console', this is a character device path in " + "path:port format (e.g., '/dev/pts/3:0'\)")] string Address; [Description ("Keyboard keymapping")] diff --git a/src/Virt_Device.c b/src/Virt_Device.c --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -189,14 +189,13 @@ int rc; char *vp_str = NULL; - if (STREQC(dev->type, "vnc")) + if (STREQC(dev->type, "sdl")) + rc = asprintf(&vp_str, "%s", dev->type); + else rc = asprintf(&vp_str, "%s/%s:%s", dev->type, dev->host, dev->port); - else - rc = asprintf(&vp_str, "%s", dev->type); - if (rc == -1) return 0; diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -421,44 +421,56 @@ CMSetProperty(inst, "ResourceSubType", (CMPIValue *)dev->dev.graphics.type, CMPI_chars); - if (STREQC(dev->dev.graphics.type, "vnc")) { + if (STREQC(dev->dev.graphics.type, "sdl")) + rc = asprintf(&addr_str, "%s", dev->dev.graphics.type); + else { rc = asprintf(&addr_str, "%s:%s", dev->dev.graphics.host, dev->dev.graphics.port); - if (rc == -1) + } + + CU_DEBUG("graphics Address = %s", addr_str); + + if (rc == -1) + goto out; + + CMSetProperty(inst, "Address", + (CMPIValue *)addr_str, CMPI_chars); + + if (STREQC(dev->dev.graphics.type, "vnc")) { + CMSetProperty(inst, "KeyMap", + (CMPIValue *)dev->dev.graphics.keymap, CMPI_chars); + + conn = connect_by_classname(_BROKER, classname, &s); + if (conn == NULL) goto out; - CMSetProperty(inst, "Address", - (CMPIValue *)addr_str, CMPI_chars); + dom = virDomainLookupByName(conn, name); + if (dom == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "Domain %s not found", + name); + goto out; + } - CMSetProperty(inst, "KeyMap", - (CMPIValue *)dev->dev.graphics.keymap, CMPI_chars); + infostore = infostore_open(dom); + if (infostore != NULL) + has_passwd = infostore_get_bool(infostore, + "has_vnc_passwd"); + + if (has_passwd) { + CU_DEBUG("has password"); + CMSetProperty(inst, "Password", + (CMPIValue *)"********", CMPI_chars); + } + + infostore_close(infostore); + + /* FIXME: Populate the IsIPv6Only */ } - conn = connect_by_classname(_BROKER, classname, &s); - if (conn == NULL) - goto out; - - dom = virDomainLookupByName(conn, name); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "Domain %s not found", - name); - goto out; - } - - infostore = infostore_open(dom); - if (infostore != NULL) - has_passwd = infostore_get_bool(infostore, "has_vnc_passwd"); - - if (has_passwd) - CMSetProperty(inst, "Password", - (CMPIValue *)"********", CMPI_chars); - - infostore_close(infostore); - out: free(addr_str); virDomainFree(dom); diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c +++ b/src/Virt_SettingsDefineCapabilities.c @@ -1694,10 +1694,9 @@ inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_GRAPHICS, DEVICE_RASD); CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); - + CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars); + if (STREQC(type, "vnc")) { - CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars); - CMSetProperty(inst, "KeyMap", (CMPIValue *)"en-us", CMPI_chars); } diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -405,7 +405,7 @@ static bool add_default_devs(struct domain *domain) { - if (domain->dev_graphics_ct != 1) { + if (domain->dev_graphics_ct < 1) { if (!default_graphics_device(domain)) return false; } @@ -1027,6 +1027,38 @@ return NULL; } +static int parse_console_address(const char *id, + char **path, + char **port) +{ + int ret; + char *tmp_path = NULL; + char *tmp_port = NULL; + + CU_DEBUG("Entering parse_console_address, address is %s", id); + + ret = sscanf(id, "%a[^:]:%as", &tmp_path, &tmp_port); + + if (ret != 2) { + ret = 0; + goto out; + } + + if (path) + *path = strdup(tmp_path); + + if (port) + *port = strdup(tmp_port); + + ret = 1; + + out: + CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", + *path, *port); + + return ret; +} + static int parse_vnc_address(const char *id, char **ip, char **port) @@ -1058,9 +1090,8 @@ ret = 1; out: - CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", *ip, *port); - free(tmp_ip); - free(tmp_port); + CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", + *ip, *port); return ret; } @@ -1068,9 +1099,8 @@ static const char *graphics_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev) { - const char *val; + const char *val = NULL; const char *msg = NULL; - const char *keymap; bool ipv6 = false; int ret; @@ -1080,36 +1110,69 @@ } dev->dev.graphics.type = strdup(val); + CU_DEBUG("graphics type = %s", dev->dev.graphics.type); + /* FIXME: Add logic to prevent address:port collisions */ - if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { - CU_DEBUG("no graphics port defined, giving default"); - if (cu_get_bool_prop(inst, "IsIPv6Only", &ipv6) != CMPI_RC_OK) - ipv6 = false; - if (ipv6) - dev->dev.graphics.host = strdup("[::1]"); - else - dev->dev.graphics.host = strdup("127.0.0.1"); - dev->dev.graphics.port = strdup("-1"); - } else { - ret = parse_vnc_address(val, - &dev->dev.graphics.host, - &dev->dev.graphics.port); + if (STREQC(dev->dev.graphics.type, "vnc")) { + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { + CU_DEBUG("graphics Address empty, using default"); + + if (cu_get_bool_prop(inst, "IsIPV6Only", &ipv6) != + CMPI_RC_OK) + ipv6 = false; + + if(ipv6) + val = "[::1]:-1"; + else + val = "127.0.0.1:-1"; + } + + ret = parse_vnc_address(val, + &dev->dev.graphics.host, + &dev->dev.graphics.port); if (ret != 1) { msg = "GraphicsRASD field Address not valid"; goto out; } + + if (cu_get_str_prop(inst, "KeyMap", &val) != CMPI_RC_OK) + dev->dev.graphics.keymap = strdup("en-us"); + else + dev->dev.graphics.keymap = strdup(val); + + if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { + CU_DEBUG("vnc password is not set"); + dev->dev.graphics.passwd = NULL; + } else { + CU_DEBUG("vnc password is set"); + dev->dev.graphics.passwd = strdup(val); + } } - - if (cu_get_str_prop(inst, "KeyMap", &keymap) != CMPI_RC_OK) - keymap = "en-us"; - - dev->dev.graphics.keymap = strdup(keymap); - - if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { - dev->dev.graphics.passwd = NULL; - } else { - dev->dev.graphics.passwd = strdup(val); - } + else if (STREQC(dev->dev.graphics.type, "console") || + STREQC(dev->dev.graphics.type, "serial")) { + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { + CU_DEBUG("graphics Address empty, using default"); + val = "/dev/pts/0:0"; + } + + ret = parse_console_address(val, + &dev->dev.graphics.host, + &dev->dev.graphics.port); + if (ret != 1) { + msg = "GraphicsRASD field Address not valid"; + goto out; + } + } else { + CU_DEBUG("Unsupported graphics type %s", + dev->dev.graphics.type); + msg = "Unsupported graphics type"; + goto out; + } + + CU_DEBUG("graphics = %s:%s:%s", + dev->dev.graphics.type, + dev->dev.graphics.host, + dev->dev.graphics.port); out: return msg; @@ -1250,6 +1313,9 @@ "DiskResourceAllocationSettingData in a single " "guest"; + if (dev->type == CIM_RES_TYPE_GRAPHICS) + continue; + if (STREQC(ptr->id, dev->id)) { CU_DEBUG("Overriding device %s from refconf", ptr->id); cleanup_virt_device(ptr); @@ -1358,11 +1424,19 @@ ncount, &domain->dev_net_ct); } else if (type == CIM_RES_TYPE_GRAPHICS) { - domain->dev_graphics_ct = 1; + struct virt_device dev; + int ncount = count + domain->dev_graphics_ct; + + memset(&dev, 0, sizeof(dev)); msg = rasd_to_vdev(inst, domain, - &domain->dev_graphics[0], + &dev, ns); + if (msg == NULL) + msg = add_device_nodup(&dev, + domain->dev_graphics, + ncount, + &domain->dev_graphics_ct); } else if (type == CIM_RES_TYPE_INPUT) { domain->dev_input_ct = 1; msg = rasd_to_vdev(inst, @@ -2318,13 +2392,6 @@ goto out; } - if ((type == CIM_RES_TYPE_GRAPHICS) && (*count > 0)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "A resource already exists for type %" PRIu16, type); - goto out; - } - list = realloc(*_list, ((*count)+1)*sizeof(struct virt_device)); if (list == NULL) { /* No memory */ From snmishra at us.ibm.com Thu Apr 7 22:44:50 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 7 Apr 2011 15:44:50 -0700 Subject: [Libvirt-cim] [PATCH] (#2) Add support for console/serial grahpics devices In-Reply-To: <5f1131a99b0846f0e960.1302213448@oc0840652111.ibm.com> References: <5f1131a99b0846f0e960.1302213448@oc0840652111.ibm.com> Message-ID: +1 Thanks Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces at redhat.com wrote on 04/07/2011 02:57:28 PM: > Chip Vincent > Sent by: libvirt-cim-bounces at redhat.com > > 04/07/2011 02:57 PM > > Please respond to > List for discussion and development of libvirt CIM > > To > > libvirt-cim at redhat.com > > cc > > Subject > > [Libvirt-cim] [PATCH] (#2) Add support for console/serial grahpics devices > > # HG changeset patch > # User Chip Vincent > # Date 1301520765 14400 > # Node ID 5f1131a99b0846f0e960b4a0f643056b7559fcab > # Parent a521a11eeec4b41399ca954ab17b874a708eb4b3 > (#2) Add support for console/serial grahpics devices > > Add support for Graphics RASD ResourceSubType = console | serial. > This includes > support for allowing more than a single graphics RASD instance. Instances can > be created externally or during DefineSystem. No changes to current level of > hotswapping. > > Signed-off-by: Chip Vincent > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -40,7 +40,8 @@ > #define NET_XPATH (xmlChar *)"/domain/devices/interface" > #define EMU_XPATH (xmlChar *)"/domain/devices/emulator" > #define MEM_XPATH (xmlChar *)"/domain/memory | /domain/currentMemory" > -#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics" > +#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ > + "/domain/devices/console | /domain/devices/serial" > #define INPUT_XPATH (xmlChar *)"/domain/devices/input" > > #define DEFAULT_BRIDGE "xenbr0" > @@ -501,6 +502,7 @@ > { > struct virt_device *vdev = NULL; > struct graphics_device *gdev = NULL; > + xmlNode *child = NULL; > > vdev = calloc(1, sizeof(*vdev)); > if (vdev == NULL) > @@ -509,24 +511,51 @@ > gdev = &(vdev->dev.graphics); > > gdev->type = get_attr_value(node, "type"); > - gdev->port = get_attr_value(node, "port"); > - gdev->host = get_attr_value(node, "listen"); > - gdev->keymap = get_attr_value(node, "keymap"); > - > if (gdev->type == NULL) > goto err; > > + CU_DEBUG("graphics device type = %s", gdev->type); > + > if (STREQC(gdev->type, "vnc")) { > - if (gdev->port == NULL) > + gdev->port = get_attr_value(node, "port"); > + gdev->host = get_attr_value(node, "listen"); > + gdev->keymap = get_attr_value(node, "keymap"); > + > + if (gdev->port == NULL || gdev->host == NULL) > + goto err; > + } > + else if (STREQC(gdev->type, "pty")) { > + if (node->name == NULL) > goto err; > > - if (gdev->host == NULL) > - goto err; > + /* Change type to serial, console, etc. It will be converted > + * back in xmlgen.c */ > + free(gdev->type); > + gdev->type = strdup((char *)node->name); > + > + for (child = node->children; child != NULL; > + child = child->next) { > + if (XSTREQ(child->name, "source")) > + gdev->host = get_attr_value(child, "path"); > + else if (XSTREQ(child->name, "target")) > + gdev->port = get_attr_value(child, "port"); > + } > + } > + else { > + CU_DEBUG("Unknown graphics type %s", gdev->type); > + goto err; > } > > vdev->type = CIM_RES_TYPE_GRAPHICS; > vdev->id = strdup("graphics"); > > + /* FIXME: IDs should be unique, but that breaks existing tests. > + ret = asprintf(&vdev->id, "graphics:%s", gdev->type); > + if(ret == -1) { > + CU_DEBUG("Failed to create graphics is string"); > + goto err; > + } */ > + > *vdevs = vdev; > > return 1; > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -401,43 +401,93 @@ > return NULL; > } > > +static const char *graphics_vnc_xml(xmlNodePtr root, > + struct graphics_device *dev) > +{ > + xmlNodePtr tmp = NULL; > + > + tmp = xmlNewChild(root, NULL, BAD_CAST "graphics", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + > + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); > + > + if (STREQC(dev->type, "sdl")) > + return NULL; > + > + if (dev->port) { > + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); > + if (STREQC(dev->port, "-1")) > + xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes"); > + else > + xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no"); > + } > + > + if (dev->host) > + xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host); > + > + if (dev->passwd) > + xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST dev-> passwd); > + > + if (dev->keymap) > + xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev-> keymap); > + > + return NULL; > +} > + > +static const char *graphics_pty_xml(xmlNodePtr root, > + struct graphics_device *dev) > +{ > + xmlNodePtr pty = NULL; > + xmlNodePtr tmp = NULL; > + > + pty = xmlNewChild(root, NULL, BAD_CAST dev->type, NULL); > + if (pty == NULL) > + return XML_ERROR; > + > + xmlNewProp(pty, BAD_CAST "type", BAD_CAST "pty"); > + > + tmp = xmlNewChild(pty, NULL, BAD_CAST "source", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + > + if(dev->host) > + xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev->host); > + > + tmp = xmlNewChild(pty, NULL, BAD_CAST "target", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + > + if(dev->port) > + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); > + > + return NULL; > +} > + > static const char *graphics_xml(xmlNodePtr root, struct domain *dominfo) > { > + const char *msg = NULL; > int i; > > for (i = 0; i < dominfo->dev_graphics_ct; i++) { > - xmlNodePtr tmp; > struct virt_device *_dev = &dominfo->dev_graphics[i]; > if (_dev->type == CIM_RES_TYPE_UNKNOWN) > continue; > > 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); > - > - if (STREQC(dev->type, "sdl")) > - goto out; > - > - if (STREQC(dev->port, "-1")) > - xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes"); > - else { > - xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no"); > - 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); > - > - if (dev->passwd != NULL) > - xmlNewProp(tmp, > - BAD_CAST "passwd", > - BAD_CAST dev->passwd); > + if (STREQC(dev->type, "vnc") || STREQC(dev->type, "sdl")) > + msg = graphics_vnc_xml(root, dev); > + else if (STREQC(dev->type, "console") || > + STREQC(dev->type, "serial")) > + msg = graphics_pty_xml(root, dev); > + else > + continue; > + > + if(msg != NULL) > + return msg; > } > > - out: > return NULL; > } > > diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ > ResourceAllocationSettingData.mof > --- a/schema/ResourceAllocationSettingData.mof > +++ b/schema/ResourceAllocationSettingData.mof > @@ -216,8 +216,10 @@ > ] > class Xen_GraphicsResourceAllocationSettingData : > Xen_ResourceAllocationSettingData > { > - [Description ("VNC Address. IPv4 in a.b.c.d:port or" > - "IPv6 in [ip]:port format")] > + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " > + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If > ResourceSubType " > + "is 'console', this is a character device path in " > + "path:port format (e.g., '/dev/pts/3:0'\)")] > string Address; > > [Description ("Keyboard keymapping")] > @@ -235,8 +237,10 @@ > ] > class KVM_GraphicsResourceAllocationSettingData : > KVM_ResourceAllocationSettingData > { > - [Description ("VNC Address. IPv4 in a.b.c.d:port or" > - "IPv6 in [ip]:port format")] > + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " > + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If > ResourceSubType " > + "is 'console', this is a character device path in " > + "path:port format (e.g., '/dev/pts/3:0'\)")] > string Address; > > [Description ("Keyboard keymapping")] > @@ -254,8 +258,10 @@ > ] > class LXC_GraphicsResourceAllocationSettingData : > LXC_ResourceAllocationSettingData > { > - [Description ("VNC Address. IPv4 in a.b.c.d:port or" > - "IPv6 in [ip]:port format")] > + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " > + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If > ResourceSubType " > + "is 'console', this is a character device path in " > + "path:port format (e.g., '/dev/pts/3:0'\)")] > string Address; > > [Description ("Keyboard keymapping")] > diff --git a/src/Virt_Device.c b/src/Virt_Device.c > --- a/src/Virt_Device.c > +++ b/src/Virt_Device.c > @@ -189,14 +189,13 @@ > int rc; > char *vp_str = NULL; > > - if (STREQC(dev->type, "vnc")) > + if (STREQC(dev->type, "sdl")) > + rc = asprintf(&vp_str, "%s", dev->type); > + else > rc = asprintf(&vp_str, "%s/%s:%s", > dev->type, > dev->host, > dev->port); > - else > - rc = asprintf(&vp_str, "%s", dev->type); > - > if (rc == -1) > return 0; > > diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c > --- a/src/Virt_RASD.c > +++ b/src/Virt_RASD.c > @@ -421,44 +421,56 @@ > CMSetProperty(inst, "ResourceSubType", > (CMPIValue *)dev->dev.graphics.type, CMPI_chars); > > - if (STREQC(dev->dev.graphics.type, "vnc")) { > + if (STREQC(dev->dev.graphics.type, "sdl")) > + rc = asprintf(&addr_str, "%s", dev->dev.graphics.type); > + else { > rc = asprintf(&addr_str, > "%s:%s", > dev->dev.graphics.host, > dev->dev.graphics.port); > - if (rc == -1) > + } > + > + CU_DEBUG("graphics Address = %s", addr_str); > + > + if (rc == -1) > + goto out; > + > + CMSetProperty(inst, "Address", > + (CMPIValue *)addr_str, CMPI_chars); > + > + if (STREQC(dev->dev.graphics.type, "vnc")) { > + CMSetProperty(inst, "KeyMap", > + (CMPIValue *)dev->dev.graphics.keymap, > CMPI_chars); > + > + conn = connect_by_classname(_BROKER, classname, &s); > + if (conn == NULL) > goto out; > > - CMSetProperty(inst, "Address", > - (CMPIValue *)addr_str, CMPI_chars); > + dom = virDomainLookupByName(conn, name); > + if (dom == NULL) { > + cu_statusf(_BROKER, &s, > + CMPI_RC_ERR_NOT_FOUND, > + "Domain %s not found", > + name); > + goto out; > + } > > - CMSetProperty(inst, "KeyMap", > - (CMPIValue *)dev->dev.graphics.keymap, > CMPI_chars); > + infostore = infostore_open(dom); > + if (infostore != NULL) > + has_passwd = infostore_get_bool(infostore, > + "has_vnc_passwd"); > + > + if (has_passwd) { > + CU_DEBUG("has password"); > + CMSetProperty(inst, "Password", > + (CMPIValue *)"********", CMPI_chars); > + } > + > + infostore_close(infostore); > + > + /* FIXME: Populate the IsIPv6Only */ > } > > - conn = connect_by_classname(_BROKER, classname, &s); > - if (conn == NULL) > - goto out; > - > - dom = virDomainLookupByName(conn, name); > - if (dom == NULL) { > - cu_statusf(_BROKER, &s, > - CMPI_RC_ERR_NOT_FOUND, > - "Domain %s not found", > - name); > - goto out; > - } > - > - infostore = infostore_open(dom); > - if (infostore != NULL) > - has_passwd = infostore_get_bool(infostore, "has_vnc_passwd"); > - > - if (has_passwd) > - CMSetProperty(inst, "Password", > - (CMPIValue *)"********", CMPI_chars); > - > - infostore_close(infostore); > - > out: > free(addr_str); > virDomainFree(dom); > diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/ > Virt_SettingsDefineCapabilities.c > --- a/src/Virt_SettingsDefineCapabilities.c > +++ b/src/Virt_SettingsDefineCapabilities.c > @@ -1694,10 +1694,9 @@ > inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_GRAPHICS, DEVICE_RASD); > > CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); > - > + CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars); > + > if (STREQC(type, "vnc")) { > - CMSetProperty(inst, "Address", (CMPIValue *)addr, > CMPI_chars); > - > CMSetProperty(inst, "KeyMap", (CMPIValue *)"en-us", > CMPI_chars); > } > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/ > Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -405,7 +405,7 @@ > > static bool add_default_devs(struct domain *domain) > { > - if (domain->dev_graphics_ct != 1) { > + if (domain->dev_graphics_ct < 1) { > if (!default_graphics_device(domain)) > return false; > } > @@ -1027,6 +1027,38 @@ > return NULL; > } > > +static int parse_console_address(const char *id, > + char **path, > + char **port) > +{ > + int ret; > + char *tmp_path = NULL; > + char *tmp_port = NULL; > + > + CU_DEBUG("Entering parse_console_address, address is %s", id); > + > + ret = sscanf(id, "%a[^:]:%as", &tmp_path, &tmp_port); > + > + if (ret != 2) { > + ret = 0; > + goto out; > + } > + > + if (path) > + *path = strdup(tmp_path); > + > + if (port) > + *port = strdup(tmp_port); > + > + ret = 1; > + > + out: > + CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", > + *path, *port); > + > + return ret; > +} > + > static int parse_vnc_address(const char *id, > char **ip, > char **port) > @@ -1058,9 +1090,8 @@ > ret = 1; > > out: > - CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", > *ip, *port); > - free(tmp_ip); > - free(tmp_port); > + CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", > + *ip, *port); > > return ret; > } > @@ -1068,9 +1099,8 @@ > static const char *graphics_rasd_to_vdev(CMPIInstance *inst, > struct virt_device *dev) > { > - const char *val; > + const char *val = NULL; > const char *msg = NULL; > - const char *keymap; > bool ipv6 = false; > int ret; > > @@ -1080,36 +1110,69 @@ > } > dev->dev.graphics.type = strdup(val); > > + CU_DEBUG("graphics type = %s", dev->dev.graphics.type); > + > /* FIXME: Add logic to prevent address:port collisions */ > - if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > - CU_DEBUG("no graphics port defined, giving default"); > - if (cu_get_bool_prop(inst, "IsIPv6Only", &ipv6) != > CMPI_RC_OK) > - ipv6 = false; > - if (ipv6) > - dev->dev.graphics.host = strdup("[::1]"); > - else > - dev->dev.graphics.host = strdup("127.0.0.1"); > - dev->dev.graphics.port = strdup("-1"); > - } else { > - ret = parse_vnc_address(val, > - &dev->dev.graphics.host, > - &dev->dev.graphics.port); > + if (STREQC(dev->dev.graphics.type, "vnc")) { > + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > + CU_DEBUG("graphics Address empty, using default"); > + > + if (cu_get_bool_prop(inst, "IsIPV6Only", &ipv6) != > + CMPI_RC_OK) > + ipv6 = false; > + > + if(ipv6) > + val = "[::1]:-1"; > + else > + val = "127.0.0.1:-1"; > + } > + > + ret = parse_vnc_address(val, > + &dev->dev.graphics.host, > + &dev->dev.graphics.port); > if (ret != 1) { > msg = "GraphicsRASD field Address not valid"; > goto out; > } > + > + if (cu_get_str_prop(inst, "KeyMap", &val) != CMPI_RC_OK) > + dev->dev.graphics.keymap = strdup("en-us"); > + else > + dev->dev.graphics.keymap = strdup(val); > + > + if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { > + CU_DEBUG("vnc password is not set"); > + dev->dev.graphics.passwd = NULL; > + } else { > + CU_DEBUG("vnc password is set"); > + dev->dev.graphics.passwd = strdup(val); > + } > } > - > - if (cu_get_str_prop(inst, "KeyMap", &keymap) != CMPI_RC_OK) > - keymap = "en-us"; > - > - dev->dev.graphics.keymap = strdup(keymap); > - > - if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { > - dev->dev.graphics.passwd = NULL; > - } else { > - dev->dev.graphics.passwd = strdup(val); > - } > + else if (STREQC(dev->dev.graphics.type, "console") || > + STREQC(dev->dev.graphics.type, "serial")) { > + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { > + CU_DEBUG("graphics Address empty, using default"); > + val = "/dev/pts/0:0"; > + } > + > + ret = parse_console_address(val, > + &dev->dev.graphics.host, > + &dev->dev.graphics.port); > + if (ret != 1) { > + msg = "GraphicsRASD field Address not valid"; > + goto out; > + } > + } else { > + CU_DEBUG("Unsupported graphics type %s", > + dev->dev.graphics.type); > + msg = "Unsupported graphics type"; > + goto out; > + } > + > + CU_DEBUG("graphics = %s:%s:%s", > + dev->dev.graphics.type, > + dev->dev.graphics.host, > + dev->dev.graphics.port); > > out: > return msg; > @@ -1250,6 +1313,9 @@ > "DiskResourceAllocationSettingData > in a single " > "guest"; > > + if (dev->type == CIM_RES_TYPE_GRAPHICS) > + continue; > + > if (STREQC(ptr->id, dev->id)) { > CU_DEBUG("Overriding device %s from > refconf", ptr->id); > cleanup_virt_device(ptr); > @@ -1358,11 +1424,19 @@ > ncount, > &domain-> dev_net_ct); > } else if (type == CIM_RES_TYPE_GRAPHICS) { > - domain->dev_graphics_ct = 1; > + struct virt_device dev; > + int ncount = count + domain->dev_graphics_ct; > + > + memset(&dev, 0, sizeof(dev)); > msg = rasd_to_vdev(inst, > domain, > - &domain->dev_graphics[0], > + &dev, > ns); > + if (msg == NULL) > + msg = add_device_nodup(&dev, > + domain->dev_graphics, > + ncount, > + &domain-> dev_graphics_ct); > } else if (type == CIM_RES_TYPE_INPUT) { > domain->dev_input_ct = 1; > msg = rasd_to_vdev(inst, > @@ -2318,13 +2392,6 @@ > goto out; > } > > - if ((type == CIM_RES_TYPE_GRAPHICS) && (*count > 0)) { > - cu_statusf(_BROKER, &s, > - CMPI_RC_ERR_FAILED, > - "A resource already exists for type %" > PRIu16, type); > - goto out; > - } > - > list = realloc(*_list, ((*count)+1)*sizeof(struct virt_device)); > if (list == NULL) { > /* No memory */ > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From cvincent at linux.vnet.ibm.com Fri Apr 8 00:39:47 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 07 Apr 2011 20:39:47 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] Proc RASD should not be null In-Reply-To: <3a5abef07035297549e3.1301944612@elm3b197.beaverton.ibm.com> References: <3a5abef07035297549e3.1301944612@elm3b197.beaverton.ibm.com> Message-ID: <4D9E5953.2020501@linux.vnet.ibm.com> VirtualSystemManagementService - 11_define_memrasdunits.py: PASS +1 On 04/04/2011 03:16 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1301944448 25200 > # Node ID 3a5abef07035297549e34542e7789bd4488a9e86 > # Parent a68509f68d565c55afa4d89942b55eb10374b32e > [TEST] Proc RASD should not be null. > > This test was failing on libvirt 0.8 and higher as it did not like an empty proc rasd. > > Signed-off-by: Sharad Mishra > > diff -r a68509f68d56 -r 3a5abef07035 suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Thu Mar 31 14:06:44 2011 -0700 > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Mon Apr 04 12:14:08 2011 -0700 > @@ -55,8 +55,6 @@ > rasd['Limit'] = Uint64(value) > rasd['AllocationUnits'] = units > rasd_list[mrasd_cn] = inst_to_mof(rasd) > - else: > - rasd_list[rasd.classname] = None > > if rasd_list[mrasd_cn] is None: > logger.error("Unable to get template MemRASD") > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Fri Apr 8 00:52:22 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 07 Apr 2011 20:52:22 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] Conditionally fail this test if QEMU command 'device_add' fails In-Reply-To: <96ef3d9cdb65d32f54fc.1301946411@elm3b197.beaverton.ibm.com> References: <96ef3d9cdb65d32f54fc.1301946411@elm3b197.beaverton.ibm.com> Message-ID: <4D9E5C46.4090605@linux.vnet.ibm.com> +1. The code change looks correct, but this test always fails on my system. Basically, I get an out-of-memory error from deep down within cimtest. I'll try to reproduce on another system and open a defect to track, if needed. On 04/04/2011 03:46 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1301946359 25200 > # Node ID 96ef3d9cdb65d32f54fce85d5c154cd84466ea24 > # Parent 4d2dc8ffbd280bf988c7fa9c9bc08d87785dec72 > [TEST] Conditionally fail this test if QEMU command 'device_add' fails. > > This test will fail if hotplugging is not supported. > > Signed-off-by: Sharad Mishra > > diff -r 4d2dc8ffbd28 -r 96ef3d9cdb65 suites/libvirt-cim/cimtest/VirtualSystemManagementService/30_dynamic_disk_mod.py > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/30_dynamic_disk_mod.py Mon Apr 04 12:42:52 2011 -0700 > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/30_dynamic_disk_mod.py Mon Apr 04 12:45:59 2011 -0700 > @@ -28,7 +28,7 @@ > from XenKvmLib.classes import get_typed_class > from CimTest.Globals import logger > from XenKvmLib.const import do_main > -from CimTest.ReturnCodes import FAIL, PASS > +from CimTest.ReturnCodes import FAIL, PASS, XFAIL > from XenKvmLib import vsms_util > > sup_types = ['Xen', 'KVM', 'XenFV'] > @@ -72,7 +72,7 @@ > status = vsms_util.add_disk_res(options.ip, service, cxml, vssd_ref, > dasd, disk_attr) > if status != PASS: > - return FAIL > + return XFAIL > dasd = vsms.get_dasd_class(options.virt)(dev='vdc', > instanceid='rstest_domain/vda', > source='/home/rss.iso', > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From snmishra at us.ibm.com Thu Apr 14 17:01:34 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 14 Apr 2011 10:01:34 -0700 Subject: [Libvirt-cim] [PATCH] Add support for StoragePool autostart Message-ID: # HG changeset patch # User Sharad Mishra # Date 1302722853 25200 # Node ID b1695aa081851829a25a8210bef8de0348c7b089 # Parent a521a11eeec4b41399ca954ab17b874a708eb4b3 Add support for StoragePool autostart. This patch adds support to set autostart on StoragePools Signed-off-by: Sharad Mishra diff -r a521a11eeec4 -r b1695aa08185 libxkutil/pool_parsing.c --- a/libxkutil/pool_parsing.c Wed Mar 23 09:32:46 2011 -0700 +++ b/libxkutil/pool_parsing.c Wed Apr 13 12:27:33 2011 -0700 @@ -241,6 +241,7 @@ const xmlChar *xpathstr = (xmlChar *)"/pool"; const char *name; + CU_DEBUG("Pool XML : %s", xml); len = strlen(xml) + 1; if ((xmldoc = xmlParseMemory(xml, len)) == NULL) @@ -277,11 +278,11 @@ return ret; } -int define_pool(virConnectPtr conn, const char *xml, int res_type) +int define_pool(virConnectPtr conn, const char *xml, struct virt_pool *pool) { int ret = 1; - if (res_type == CIM_RES_TYPE_NET) { + if (pool->type == CIM_RES_TYPE_NET) { virNetworkPtr ptr = virNetworkDefineXML(conn, xml); if (ptr == NULL) { CU_DEBUG("Unable to define virtual network"); @@ -297,7 +298,7 @@ } virNetworkFree(ptr); - } else if (res_type == CIM_RES_TYPE_DISK) { + } else if (pool->type == CIM_RES_TYPE_DISK) { #if VIR_USE_LIBVIRT_STORAGE virStoragePoolPtr ptr = virStoragePoolDefineXML(conn, xml, 0); if (ptr == NULL) { @@ -313,6 +314,11 @@ CU_DEBUG("Unable to undefine storage pool"); } + if (pool->pool_info.disk.autostart == 1) { + if (virStoragePoolSetAutostart(ptr, 1) != 0) + CU_DEBUG("Unable to set autostart for pool"); + } + virStoragePoolFree(ptr); #endif } diff -r a521a11eeec4 -r b1695aa08185 libxkutil/pool_parsing.h --- a/libxkutil/pool_parsing.h Wed Mar 23 09:32:46 2011 -0700 +++ b/libxkutil/pool_parsing.h Wed Apr 13 12:27:33 2011 -0700 @@ -53,6 +53,7 @@ char *adapter; char *port_name; char *node_name; + uint16_t autostart; }; struct virt_pool { @@ -89,7 +90,7 @@ int get_pool_from_xml(const char *xml, struct virt_pool *pool, int type); char *get_disk_pool_type(uint16_t type); -int define_pool(virConnectPtr conn, const char *xml, int res_type); +int define_pool(virConnectPtr conn, const char *xml, struct virt_pool *pool); int destroy_pool(virConnectPtr conn, const char *name, int res_type); char *create_resource(virConnectPtr conn, const char *pname, diff -r a521a11eeec4 -r b1695aa08185 schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof Wed Mar 23 09:32:46 2011 -0700 +++ b/schema/ResourceAllocationSettingData.mof Wed Apr 13 12:27:33 2011 -0700 @@ -350,6 +350,7 @@ Values {"Unknown", "Directory, File System, Network File System, " "Disk, ISCSI, Logical, SCSI Host Bus Adapter"}] uint16 Type; + uint16 Autostart; string Path; string DevicePaths[]; string Host; @@ -369,6 +370,7 @@ Values {"Unknown", "Directory, File System, Network File System, " "Disk, ISCSI, Logical, SCSI Host Bus Adapter"}] uint16 Type; + uint16 Autostart; string Path; string DevicePaths[]; string Host; @@ -388,6 +390,7 @@ Values {"Unknown", "Directory, File System, Network File System, " "Disk, ISCSI, Logical, SCSI Host Bus Adapter"}] uint16 Type; + uint16 Autostart; string Path; string DevicePaths[]; string Host; diff -r a521a11eeec4 -r b1695aa08185 src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Wed Mar 23 09:32:46 2011 -0700 +++ b/src/Virt_DevicePool.c Wed Apr 13 12:27:33 2011 -0700 @@ -101,6 +101,8 @@ if (xml == NULL) return 0; + CU_DEBUG("pool xml is %s", xml); + *pool = malloc(sizeof(**pool)); if (*pool == NULL) { ret = 0; @@ -175,6 +177,8 @@ uint16_t type; struct virt_pool *pool_vals = NULL; const char *pool_str = NULL; + uint16_t autostart; + int start; pool = virStoragePoolLookupByName(conn, _pool->tag); if (pool == NULL) { @@ -215,6 +219,17 @@ CMPI_chars); } + if (virStoragePoolGetAutostart(pool, &start) == -1) { + CU_DEBUG("Failed to read if %s StoragePool is set for " + "Autostart", _pool->tag); + goto out; + } + + autostart = start; + + CMSetProperty(inst, "Autostart", + (CMPIValue *)&autostart, CMPI_uint16); + result = true; out: virStoragePoolFree(pool); diff -r a521a11eeec4 -r b1695aa08185 src/Virt_ResourcePoolConfigurationService.c --- a/src/Virt_ResourcePoolConfigurationService.c Wed Mar 23 09:32:46 2011 -0700 +++ b/src/Virt_ResourcePoolConfigurationService.c Wed Apr 13 12:27:33 2011 -0700 @@ -150,6 +150,7 @@ pool->pool_info.disk.adapter = NULL; pool->pool_info.disk.port_name = NULL; pool->pool_info.disk.node_name = NULL; + pool->pool_info.disk.autostart = 0; } static char *get_dev_paths(CMPIInstance *inst, @@ -289,6 +290,7 @@ const char *val = NULL; const char *msg = NULL; uint16_t type; + uint16_t autostart; if (cu_get_u16_prop(inst, "Type", &type) != CMPI_RC_OK) return "Missing `Type' property"; @@ -326,6 +328,14 @@ pool->pool_info.disk.path = strdup(val); + if (cu_get_u16_prop(inst, "Autostart", &autostart) != CMPI_RC_OK) { + CU_DEBUG("Failed to get Autostart, defaulting " + "to no autostart"); + autostart = 0; + } + + pool->pool_info.disk.autostart = autostart; + out: return msg; @@ -440,7 +450,7 @@ static CMPIInstance *connect_and_create(char *xml, const CMPIObjectPath *ref, const char *id, - int res_type, + struct virt_pool *pool, CMPIStatus *s) { virConnectPtr conn; @@ -452,7 +462,7 @@ return NULL; } - if (define_pool(conn, xml, res_type) == 0) { + if (define_pool(conn, xml, pool) == 0) { virt_set_status(_BROKER, s, CMPI_RC_ERR_FAILED, conn, @@ -544,7 +554,7 @@ CU_DEBUG("Pool XML:\n%s", xml); - inst = connect_and_create(xml, reference, full_id, pool->type, &s); + inst = connect_and_create(xml, reference, full_id, pool, &s); if (s.rc != CMPI_RC_OK) goto out; diff -r a521a11eeec4 -r b1695aa08185 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Wed Mar 23 09:32:46 2011 -0700 +++ b/src/Virt_SettingsDefineCapabilities.c Wed Apr 13 12:27:33 2011 -0700 @@ -1521,19 +1521,24 @@ DISK_POOL_SCSI}; int pool_types = 7; int i; + uint16_t autostart; switch (template_type) { case SDC_RASD_MIN: id = "Minimum"; + autostart = 0; break; case SDC_RASD_MAX: id = "Maximum"; + autostart = 1; break; case SDC_RASD_INC: id = "Increment"; + autostart = 1; break; case SDC_RASD_DEF: id = "Default"; + autostart = 0; break; default: cu_statusf(_BROKER, &s, @@ -1633,6 +1638,8 @@ CMSetProperty(inst, "Type", (CMPIValue *)&type[i], CMPI_uint16); CMSetProperty(inst, "Path", (CMPIValue *)path, CMPI_chars); + CMSetProperty(inst, "Autostart", (CMPIValue *)&autostart, + CMPI_uint16); inst_list_add(list, inst); } From snmishra at us.ibm.com Thu Apr 14 17:36:21 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 14 Apr 2011 10:36:21 -0700 Subject: [Libvirt-cim] [PATCH] [TEST] New test to test DiskPool autostart Message-ID: <1872aaa2378208e3359c.1302802581@elm3a148.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1302802477 25200 # Node ID 1872aaa2378208e3359c7a32d809d78102506797 # Parent 327294d1f3df451ec317e670580e7c60619c8b02 [TEST] New test to test DiskPool autostart. Feature to Autostart DiskPool was added to libvirt-cim. This cimtest tests that feature. Signed-off-by: Sharad Mishra diff -r 327294d1f3df -r 1872aaa23782 suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py Thu Apr 14 10:34:37 2011 -0700 @@ -0,0 +1,118 @@ +#!/usr/bin/python +# +# Copyright 2011 IBM Corp. +# +# Authors: +# Sharad Mishra +# +# +# 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 +# +# -Date: 04.14.2011 + +import sys +from pywbem import cim_types +from CimTest.Globals import logger +from XenKvmLib.xm_virt_util import virsh_version +from CimTest.ReturnCodes import FAIL, PASS, SKIP +from XenKvmLib.const import do_main, platform_sup +from XenKvmLib.classes import get_typed_class +from XenKvmLib.common_util import destroy_diskpool +from XenKvmLib.pool import create_pool, verify_pool, undefine_diskpool +from XenKvmLib.const import get_provider_version +from VirtLib import utils + +disk_pool_autostart_support=1087 + +def verify_autostart(server, key): + cmd = "virsh pool-info %s 2>/dev/null" % key + s, disk_xml = utils.run_remote(server, cmd) + if s != 0: + logger.error("Encountered error running command : %s", cmd) + return FAIL + + disk = disk_xml.translate(None, ' ') + val = disk.find("Autostart:yes") + if val == -1: + logger.error("Pool is NOT set to Autostart"); + return FAIL + + return PASS + + + at do_main(platform_sup) +def main(): + options = main.options + server = options.ip + virt = options.virt + + dp_types = { } + + libvirt_version = virsh_version(server, virt) + if libvirt_version < "0.4.1": + logger.info("Storage pool creation support is available in Libvirt " + "version >= 0.4.1 , hence skipping the test....") + return SKIP + + curr_cim_rev, changeset = get_provider_version(virt, server) + if curr_cim_rev < disk_pool_autostart_support: + logger.info("DiskPool Autostart support available in libvirt-cim" + " version >= %s, hence skipping this test...", + disk_pool_autostart_support) + return SKIP + + status = FAIL + pool_attr = None + key = 'DISK_POOL_DIR' + value = 1 + try: + logger.info("Verifying '%s'.....", key) + test_pool = key + pool_attr = { "Path" : "/var/lib/libvirt/images", + "Autostart" : cim_types.Uint16(1) } + + status = create_pool(server, virt, test_pool, pool_attr, + mode_type=value, pool_type= "DiskPool") + + if status != PASS: + raise Exception("Failed to create '%s' type diskpool '%s'" \ + % (key, test_pool)) + + status = verify_autostart(server, key) + if status != PASS: + destroy_diskpool(server, virt, test_pool) + undefine_diskpool(server, virt, test_pool) + raise Exception("Error in diskpool verification") + + status = destroy_diskpool(server, virt, test_pool) + if status != PASS: + raise Exception("Unable to destroy diskpool '%s'" \ + % test_pool) + + status = undefine_diskpool(server, virt, test_pool) + if status != PASS: + raise Exception("Unable to undefine diskpool '%s'" \ + % test_pool) + + status = PASS + + except Exception, details: + status = FAIL + logger.error("Exception details: %s", details) + + return status + +if __name__ == "__main__": + sys.exit(main()) From snmishra at us.ibm.com Thu Apr 14 18:42:57 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 14 Apr 2011 11:42:57 -0700 Subject: [Libvirt-cim] [PATCH] [TEST] Updating test case to remove check for "Reserved" value Message-ID: <4c8e0c673d796ae7a5e1.1302806577@elm3a148.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1302806505 25200 # Node ID 4c8e0c673d796ae7a5e17ee771d935e449b77bce # Parent 1872aaa2378208e3359c7a32d809d78102506797 [TEST] Updating test case to remove check for "Reserved" value. This test creates a DiskPool and gets its pool info. Then reads it again using association. There is a delay in reading the two values and at times it is seen the these values change by few bytes. This patch will check for all StoragePool attributes except "Reserved". Signed-off-by: Sharad Mishra diff -r 1872aaa23782 -r 4c8e0c673d79 suites/libvirt-cim/cimtest/ElementConforms/01_forward.py --- a/suites/libvirt-cim/cimtest/ElementConforms/01_forward.py Thu Apr 14 10:34:37 2011 -0700 +++ b/suites/libvirt-cim/cimtest/ElementConforms/01_forward.py Thu Apr 14 11:41:45 2011 -0700 @@ -99,7 +99,16 @@ elements = managed_ele_values[cn] for ele in elements: - if assoc_val.items() == ele.items(): + val1=assoc_val.items() + # "Reserved" is the second attribute. + # remove it. + del val1[1] + val2=ele.items() + # "Reserved" is the second attribute. + # remove it. + del val2[1] + # Now compare without "Reserved" + if val1 == val2: return PASS except Exception, details: From cvincent at linux.vnet.ibm.com Mon Apr 25 14:48:02 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Mon, 25 Apr 2011 10:48:02 -0400 Subject: [Libvirt-cim] [PATCH] Add support for StoragePool autostart In-Reply-To: References: Message-ID: <4DB589A2.20101@linux.vnet.ibm.com> +1 On 04/14/2011 01:01 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1302722853 25200 > # Node ID b1695aa081851829a25a8210bef8de0348c7b089 > # Parent a521a11eeec4b41399ca954ab17b874a708eb4b3 > Add support for StoragePool autostart. > > This patch adds support to set autostart on StoragePools > > Signed-off-by: Sharad Mishra > > diff -r a521a11eeec4 -r b1695aa08185 libxkutil/pool_parsing.c > --- a/libxkutil/pool_parsing.c Wed Mar 23 09:32:46 2011 -0700 > +++ b/libxkutil/pool_parsing.c Wed Apr 13 12:27:33 2011 -0700 > @@ -241,6 +241,7 @@ > const xmlChar *xpathstr = (xmlChar *)"/pool"; > const char *name; > > + CU_DEBUG("Pool XML : %s", xml); > len = strlen(xml) + 1; > > if ((xmldoc = xmlParseMemory(xml, len)) == NULL) > @@ -277,11 +278,11 @@ > return ret; > } > > -int define_pool(virConnectPtr conn, const char *xml, int res_type) > +int define_pool(virConnectPtr conn, const char *xml, struct virt_pool *pool) > { > int ret = 1; > > - if (res_type == CIM_RES_TYPE_NET) { > + if (pool->type == CIM_RES_TYPE_NET) { > virNetworkPtr ptr = virNetworkDefineXML(conn, xml); > if (ptr == NULL) { > CU_DEBUG("Unable to define virtual network"); > @@ -297,7 +298,7 @@ > } > > virNetworkFree(ptr); > - } else if (res_type == CIM_RES_TYPE_DISK) { > + } else if (pool->type == CIM_RES_TYPE_DISK) { > #if VIR_USE_LIBVIRT_STORAGE > virStoragePoolPtr ptr = virStoragePoolDefineXML(conn, xml, 0); > if (ptr == NULL) { > @@ -313,6 +314,11 @@ > CU_DEBUG("Unable to undefine storage pool"); > } > > + if (pool->pool_info.disk.autostart == 1) { > + if (virStoragePoolSetAutostart(ptr, 1) != 0) > + CU_DEBUG("Unable to set autostart for pool"); > + } > + > virStoragePoolFree(ptr); > #endif > } > diff -r a521a11eeec4 -r b1695aa08185 libxkutil/pool_parsing.h > --- a/libxkutil/pool_parsing.h Wed Mar 23 09:32:46 2011 -0700 > +++ b/libxkutil/pool_parsing.h Wed Apr 13 12:27:33 2011 -0700 > @@ -53,6 +53,7 @@ > char *adapter; > char *port_name; > char *node_name; > + uint16_t autostart; > }; > > struct virt_pool { > @@ -89,7 +90,7 @@ > int get_pool_from_xml(const char *xml, struct virt_pool *pool, int type); > char *get_disk_pool_type(uint16_t type); > > -int define_pool(virConnectPtr conn, const char *xml, int res_type); > +int define_pool(virConnectPtr conn, const char *xml, struct virt_pool *pool); > int destroy_pool(virConnectPtr conn, const char *name, int res_type); > > char *create_resource(virConnectPtr conn, const char *pname, > diff -r a521a11eeec4 -r b1695aa08185 schema/ResourceAllocationSettingData.mof > --- a/schema/ResourceAllocationSettingData.mof Wed Mar 23 09:32:46 2011 -0700 > +++ b/schema/ResourceAllocationSettingData.mof Wed Apr 13 12:27:33 2011 -0700 > @@ -350,6 +350,7 @@ > Values {"Unknown", "Directory, File System, Network File System, " > "Disk, ISCSI, Logical, SCSI Host Bus Adapter"}] > uint16 Type; > + uint16 Autostart; > string Path; > string DevicePaths[]; > string Host; > @@ -369,6 +370,7 @@ > Values {"Unknown", "Directory, File System, Network File System, " > "Disk, ISCSI, Logical, SCSI Host Bus Adapter"}] > uint16 Type; > + uint16 Autostart; > string Path; > string DevicePaths[]; > string Host; > @@ -388,6 +390,7 @@ > Values {"Unknown", "Directory, File System, Network File System, " > "Disk, ISCSI, Logical, SCSI Host Bus Adapter"}] > uint16 Type; > + uint16 Autostart; > string Path; > string DevicePaths[]; > string Host; > diff -r a521a11eeec4 -r b1695aa08185 src/Virt_DevicePool.c > --- a/src/Virt_DevicePool.c Wed Mar 23 09:32:46 2011 -0700 > +++ b/src/Virt_DevicePool.c Wed Apr 13 12:27:33 2011 -0700 > @@ -101,6 +101,8 @@ > if (xml == NULL) > return 0; > > + CU_DEBUG("pool xml is %s", xml); > + > *pool = malloc(sizeof(**pool)); > if (*pool == NULL) { > ret = 0; > @@ -175,6 +177,8 @@ > uint16_t type; > struct virt_pool *pool_vals = NULL; > const char *pool_str = NULL; > + uint16_t autostart; > + int start; > > pool = virStoragePoolLookupByName(conn, _pool->tag); > if (pool == NULL) { > @@ -215,6 +219,17 @@ > CMPI_chars); > } > > + if (virStoragePoolGetAutostart(pool,&start) == -1) { > + CU_DEBUG("Failed to read if %s StoragePool is set for " > + "Autostart", _pool->tag); > + goto out; > + } > + > + autostart = start; > + > + CMSetProperty(inst, "Autostart", > + (CMPIValue *)&autostart, CMPI_uint16); > + > result = true; > out: > virStoragePoolFree(pool); > diff -r a521a11eeec4 -r b1695aa08185 src/Virt_ResourcePoolConfigurationService.c > --- a/src/Virt_ResourcePoolConfigurationService.c Wed Mar 23 09:32:46 2011 -0700 > +++ b/src/Virt_ResourcePoolConfigurationService.c Wed Apr 13 12:27:33 2011 -0700 > @@ -150,6 +150,7 @@ > pool->pool_info.disk.adapter = NULL; > pool->pool_info.disk.port_name = NULL; > pool->pool_info.disk.node_name = NULL; > + pool->pool_info.disk.autostart = 0; > } > > static char *get_dev_paths(CMPIInstance *inst, > @@ -289,6 +290,7 @@ > const char *val = NULL; > const char *msg = NULL; > uint16_t type; > + uint16_t autostart; > > if (cu_get_u16_prop(inst, "Type",&type) != CMPI_RC_OK) > return "Missing `Type' property"; > @@ -326,6 +328,14 @@ > > pool->pool_info.disk.path = strdup(val); > > + if (cu_get_u16_prop(inst, "Autostart",&autostart) != CMPI_RC_OK) { > + CU_DEBUG("Failed to get Autostart, defaulting " > + "to no autostart"); > + autostart = 0; > + } > + > + pool->pool_info.disk.autostart = autostart; > + > out: > return msg; > > @@ -440,7 +450,7 @@ > static CMPIInstance *connect_and_create(char *xml, > const CMPIObjectPath *ref, > const char *id, > - int res_type, > + struct virt_pool *pool, > CMPIStatus *s) > { > virConnectPtr conn; > @@ -452,7 +462,7 @@ > return NULL; > } > > - if (define_pool(conn, xml, res_type) == 0) { > + if (define_pool(conn, xml, pool) == 0) { > virt_set_status(_BROKER, s, > CMPI_RC_ERR_FAILED, > conn, > @@ -544,7 +554,7 @@ > > CU_DEBUG("Pool XML:\n%s", xml); > > - inst = connect_and_create(xml, reference, full_id, pool->type,&s); > + inst = connect_and_create(xml, reference, full_id, pool,&s); > if (s.rc != CMPI_RC_OK) > goto out; > > diff -r a521a11eeec4 -r b1695aa08185 src/Virt_SettingsDefineCapabilities.c > --- a/src/Virt_SettingsDefineCapabilities.c Wed Mar 23 09:32:46 2011 -0700 > +++ b/src/Virt_SettingsDefineCapabilities.c Wed Apr 13 12:27:33 2011 -0700 > @@ -1521,19 +1521,24 @@ > DISK_POOL_SCSI}; > int pool_types = 7; > int i; > + uint16_t autostart; > > switch (template_type) { > case SDC_RASD_MIN: > id = "Minimum"; > + autostart = 0; > break; > case SDC_RASD_MAX: > id = "Maximum"; > + autostart = 1; > break; > case SDC_RASD_INC: > id = "Increment"; > + autostart = 1; > break; > case SDC_RASD_DEF: > id = "Default"; > + autostart = 0; > break; > default: > cu_statusf(_BROKER,&s, > @@ -1633,6 +1638,8 @@ > > CMSetProperty(inst, "Type", (CMPIValue *)&type[i], CMPI_uint16); > CMSetProperty(inst, "Path", (CMPIValue *)path, CMPI_chars); > + CMSetProperty(inst, "Autostart", (CMPIValue *)&autostart, > + CMPI_uint16); > > inst_list_add(list, inst); > } > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Thu Apr 28 23:51:13 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 28 Apr 2011 19:51:13 -0400 Subject: [Libvirt-cim] [PATCH] Fix UUID in migration job lifecycle indications Message-ID: <454ce8f30a13881cc6f5.1304034673@oc0840652111.ibm.com> # HG changeset patch # User Chip Vincent # Date 1304034351 14400 # Node ID 454ce8f30a13881cc6f5206d8e8e6f42a2ff8621 # Parent 8b428df21c360d1eaedba7157b0dfd429d2db121 Fix UUID in migration job lifecycle indications. Fixed the logic that fetches a VM UUID and adds it to the migration job's InstanceIdentifier property. Siged-off-by: Chip Vincent diff --git a/src/Virt_VSMigrationService.c b/src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c +++ b/src/Virt_VSMigrationService.c @@ -812,15 +812,20 @@ CMPIInstance *ind = NULL; CMPIInstance *prev_inst = NULL; const char *pfx = NULL; + virConnectPtr conn = NULL; virDomainPtr dom = NULL; char uuid[VIR_UUID_STRING_BUFLEN]; CMPIDateTime *timestamp = NULL; + conn = connect_by_classname(_BROKER, job->ref_cn, s); + if(conn == NULL) + goto out; + ind_name = ind_type_to_name(ind_type); CU_DEBUG("Creating indication."); - pfx = pfx_from_conn(job->conn); + pfx = pfx_from_conn(conn); ind = get_typed_instance(broker, pfx, @@ -832,13 +837,15 @@ goto out; } - dom = virDomainLookupByName(job->conn, job->domain); - if(dom == NULL) { - CU_DEBUG("Failed to connect to domain %s", job->domain); + timestamp = CMNewDateTime(broker, s); + CMSetProperty(ind, "IndicationTime", + (CMPIValue *)×tamp, CMPI_dateTime); + + dom = virDomainLookupByName(conn, job->domain); + if (dom == NULL) goto out; - } - if(virDomainGetUUIDString(dom, uuid) != 0) { + if (virDomainGetUUIDString(dom, &uuid[0]) != 0) { CU_DEBUG("Failed to get UUID from domain name"); goto out; } @@ -846,10 +853,6 @@ CMSetProperty(ind, "IndicationIdentifier", (CMPIValue *)uuid, CMPI_chars); - timestamp = CMNewDateTime(broker, s); - CMSetProperty(ind, "IndicationTime", - (CMPIValue *)×tamp, CMPI_dateTime); - if (ind_type == MIG_MODIFIED) { /* Need to copy job inst before attaching as PreviousInstance because otherwise the changes we are about to make to job @@ -867,6 +870,7 @@ out: virDomainFree(dom); + virConnectClose(conn); return ind; }