From mihajlov at linux.vnet.ibm.com Mon Sep 2 15:34:39 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Mon, 02 Sep 2013 17:34:39 +0200 Subject: [Libvirt-cim] [PATCH 0/3] Address 'cimtest' issues In-Reply-To: <1376000202-20533-1-git-send-email-jferlan@redhat.com> References: <1376000202-20533-1-git-send-email-jferlan@redhat.com> Message-ID: <5224B00F.4030907@linux.vnet.ibm.com> On 08/09/2013 12:16 AM, John Ferlan wrote: > These patches resolve some issues with test logging and there's one test > fix that I've had just hanging around that I figure I'd put out there since > there was some activity. > > John Ferlan (3): > Allow adding bridged network for running domain > Remove extranous or unnecessary parameter from error messages > Ensure get_provider_version() returns strings as expected > > .../cimtest/Profile/03_rprofile_gi_errs.py | 2 +- > suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py | 2 +- > .../cimtest/ResourcePool/02_rp_gi_errors.py | 2 +- > .../22_addmulti_brg_interface.py | 9 +++++++-- > suites/libvirt-cim/lib/XenKvmLib/const.py | 2 +- > suites/libvirt-cim/lib/XenKvmLib/vsms_util.py | 23 +++++++++++++++++----- > 6 files changed, 29 insertions(+), 11 deletions(-) > I gave the patches a try. The first patch works for me, and turns an XFAIL into a PASS. I didn't see the other errors occur for me, but your changes look reasonable. If there are no objections from others: go ahead and commit. Tested-by: Viktor Mihajlovski -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Wed Sep 4 16:00:40 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 04 Sep 2013 12:00:40 -0400 Subject: [Libvirt-cim] [PATCH 0/3] Address 'cimtest' issues In-Reply-To: <1376000202-20533-1-git-send-email-jferlan@redhat.com> References: <1376000202-20533-1-git-send-email-jferlan@redhat.com> Message-ID: <52275928.5030704@redhat.com> On 08/08/2013 06:16 PM, John Ferlan wrote: > These patches resolve some issues with test logging and there's one test > fix that I've had just hanging around that I figure I'd put out there since > there was some activity. > > John Ferlan (3): > Allow adding bridged network for running domain > Remove extranous or unnecessary parameter from error messages > Ensure get_provider_version() returns strings as expected > > .../cimtest/Profile/03_rprofile_gi_errs.py | 2 +- > suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py | 2 +- > .../cimtest/ResourcePool/02_rp_gi_errors.py | 2 +- > .../22_addmulti_brg_interface.py | 9 +++++++-- > suites/libvirt-cim/lib/XenKvmLib/const.py | 2 +- > suites/libvirt-cim/lib/XenKvmLib/vsms_util.py | 23 +++++++++++++++++----- > 6 files changed, 29 insertions(+), 11 deletions(-) > These are now pushed. John From jferlan at redhat.com Wed Sep 4 17:21:22 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 04 Sep 2013 13:21:22 -0400 Subject: [Libvirt-cim] [PATCH] build: Don't use /bin/sh unconditionally In-Reply-To: <1377864740-28778-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1377864740-28778-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <52276C12.9010803@redhat.com> On 08/30/2013 08:12 AM, Viktor Mihajlovski wrote: > provider-register.sh implicitly assumes that the shell has bash-like > capabilities. On systems like Ubuntu this is not the case leading > to a make postinstall failure when used with Pegasus. > Changing the script shebang to /bin/bash to make this explicit. > Further replace occurrences of sh to $(SHELL) in the Makefile > invocations of provider-register.sh. > > Signed-off-by: Viktor Mihajlovski > --- > > May not be relevant as libvirt-cim/pegasus isn't part of Debian-ish distros > as far as I am aware of. But it is a constant source of annoyance... > > Makefile.am | 18 +++++++++--------- > provider-register.sh | 2 +- > 2 files changed, 10 insertions(+), 10 deletions(-) > ACK Seems reasonable to me... John From mihajlov at linux.vnet.ibm.com Thu Sep 5 14:25:40 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 5 Sep 2013 16:25:40 +0200 Subject: [Libvirt-cim] [PATCH 2/2] cimtest: Don't generate graphics for s390 In-Reply-To: <1378391140-21815-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378391140-21815-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378391140-21815-3-git-send-email-mihajlov@linux.vnet.ibm.com> Make sure we're not trying to generate a graphics device on s390 which fails every testcase starting a domain. For this purpose a new utility function has been provided to query the hypervisor node's CPU model. Signed-off-by: Viktor Mihajlovski --- suites/libvirt-cim/lib/XenKvmLib/vxml.py | 5 +++-- suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/suites/libvirt-cim/lib/XenKvmLib/vxml.py b/suites/libvirt-cim/lib/XenKvmLib/vxml.py index 82ab501..74c4f23 100644 --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py @@ -41,7 +41,7 @@ from time import sleep from VirtLib import utils, live from XenKvmLib.xm_virt_util import get_bridge_from_network_xml, bootloader, \ - net_list + net_list, host_cpu_model from XenKvmLib.test_doms import set_uuid, viruuid from XenKvmLib import vsms from XenKvmLib import const @@ -650,7 +650,8 @@ class VirtCIM: curr_cim_rev, changeset = get_provider_version(self.virt, ip) if curr_cim_rev >= vsms_graphics_sup: - if self.gasd is not None: + if self.gasd is not None and \ + not str(host_cpu_model(ip, self.virt)).startswith('s390'): res_settings.append(str(self.gasd)) if curr_cim_rev >= vsms_inputdev_sup: diff --git a/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py b/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py index 7749fb7..33edd6a 100644 --- a/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py +++ b/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py @@ -417,3 +417,10 @@ def network_macs(ip, vs_name): return ret +def host_cpu_model(server, virt="KVM"): + cmd = "virsh -c %s nodeinfo 2>/dev/null | grep 'CPU model'" % virt2uri(virt) + ret, out = utils.run_remote(server, cmd) + if ret != 0: + return None + left, right = out.split(':') + return right.strip() -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Sep 5 14:25:38 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 5 Sep 2013 16:25:38 +0200 Subject: [Libvirt-cim] [PATCH 0/2] Make cimtest more s390-friendly Message-ID: <1378391140-21815-1-git-send-email-mihajlov@linux.vnet.ibm.com> cimtest currently doesn't work too well on s390 systems, the two main areas of failure are the attempt to define systems with IDE hard drivers and VGA graphics, both not supported on this host type. Changing from IDE to virtio disks fixed a lot of the test FAILs with no adverse impacts to the x86 runs on our systems at least. It would be nice if somebody could verify this. Further, we do not add the graphics RASD to the default guest definition if the hypervisor host is an s390 system. In principle, we could have removed the graphics RASD altogether, because libvirt-cim will define a default graphics device for x86 but since it is only a small change, it seems safer to do it this way. Thilo Boehm (1): cimtest: Use vda instead of hda for disk RASDs Viktor Mihajlovski (1): cimtest: Don't generate graphics for s390 .../cimtest/ElementAllocatedFromPool/01_forward.py | 2 +- .../cimtest/ElementAllocatedFromPool/02_reverse.py | 2 +- .../ElementAllocatedFromPool/03_reverse_errs.py | 2 +- .../ElementAllocatedFromPool/04_forward_errs.py | 2 +- .../cimtest/HostedAccessPoint/01_forward.py | 2 +- .../cimtest/HostedAccessPoint/02_reverse.py | 2 +- .../02_guest_add_mod_rem_rasd_ind.py | 2 +- .../cimtest/ServiceAccessBySAP/01_forward.py | 2 +- .../cimtest/ServiceAccessBySAP/02_reverse.py | 2 +- .../cimtest/SettingsDefine/01_forward.py | 2 +- .../cimtest/SettingsDefine/02_reverse.py | 2 +- .../cimtest/SettingsDefine/03_sds_fwd_errs.py | 2 +- .../cimtest/SettingsDefine/04_sds_rev_errs.py | 2 +- .../libvirt-cim/cimtest/SystemDevice/01_forward.py | 2 +- .../libvirt-cim/cimtest/SystemDevice/03_fwderrs.py | 2 +- suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py | 2 +- .../13_refconfig_additional_devs.py | 2 +- .../14_define_sys_disk.py | 2 +- .../30_dynamic_disk_mod.py | 2 +- .../02_reverse.py | 2 +- .../03_vssdc_fwd_errs.py | 2 +- suites/libvirt-cim/lib/XenKvmLib/const.py | 2 +- suites/libvirt-cim/lib/XenKvmLib/vsms.py | 2 +- suites/libvirt-cim/lib/XenKvmLib/vxml.py | 5 +++-- suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py | 7 +++++++ 25 files changed, 33 insertions(+), 25 deletions(-) -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Sep 5 14:25:39 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 5 Sep 2013 16:25:39 +0200 Subject: [Libvirt-cim] [PATCH 1/2] cimtest: Use vda instead of hda for disk RASDs In-Reply-To: <1378391140-21815-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378391140-21815-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378391140-21815-2-git-send-email-mihajlov@linux.vnet.ibm.com> From: Thilo Boehm Running cimtest against a s390 host will fail almost every testcase involving a disk definition in a domain. This is because the testcase instantiate IDE disk drives implicitly by using hdx as disk identifiers. Changing the testcases to use virtio disks will enable s390 domains to be started, while the testcases will still function under x86. Signed-off-by: Thilo Boehm Signed-off-by: Viktor Mihajlovski --- .../cimtest/ElementAllocatedFromPool/01_forward.py | 2 +- .../cimtest/ElementAllocatedFromPool/02_reverse.py | 2 +- .../ElementAllocatedFromPool/03_reverse_errs.py | 2 +- .../ElementAllocatedFromPool/04_forward_errs.py | 2 +- .../cimtest/HostedAccessPoint/01_forward.py | 2 +- .../cimtest/HostedAccessPoint/02_reverse.py | 2 +- .../02_guest_add_mod_rem_rasd_ind.py | 2 +- .../cimtest/ServiceAccessBySAP/01_forward.py | 2 +- .../cimtest/ServiceAccessBySAP/02_reverse.py | 2 +- .../cimtest/SettingsDefine/01_forward.py | 2 +- .../cimtest/SettingsDefine/02_reverse.py | 2 +- .../cimtest/SettingsDefine/03_sds_fwd_errs.py | 2 +- .../cimtest/SettingsDefine/04_sds_rev_errs.py | 2 +- .../libvirt-cim/cimtest/SystemDevice/01_forward.py | 2 +- .../libvirt-cim/cimtest/SystemDevice/03_fwderrs.py | 2 +- suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py | 2 +- .../13_refconfig_additional_devs.py | 2 +- .../14_define_sys_disk.py | 2 +- .../30_dynamic_disk_mod.py | 2 +- .../02_reverse.py | 2 +- .../03_vssdc_fwd_errs.py | 2 +- suites/libvirt-cim/lib/XenKvmLib/const.py | 2 +- suites/libvirt-cim/lib/XenKvmLib/vsms.py | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/01_forward.py b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/01_forward.py index f7503dd..82b12a5 100755 --- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/01_forward.py +++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/01_forward.py @@ -146,7 +146,7 @@ def main(): if virt == 'Xen': test_disk = 'xvda' else: - test_disk = 'hda' + test_disk = 'vda' # Getting the VS list and deleting the test_dom if it already exists. destroy_and_undefine_all(server) diff --git a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py index e682f11..30367cd 100644 --- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py +++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/02_reverse.py @@ -176,7 +176,7 @@ def main(): if virt == 'Xen': test_disk = 'xvdb' else: - test_disk = 'hda' + test_disk = 'vda' # Getting the VS list and deleting the test_dom if it already exists. virt_type = get_class(virt) diff --git a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py index bb273b8..7787c1d 100644 --- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py +++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py @@ -180,7 +180,7 @@ def main(): if virt == "Xen": test_disk = "xvda" else: - test_disk = "hda" + test_disk = "vda" virt_type = get_class(virt) vsxml = virt_type (test_dom, vcpus = test_vcpus, mac = test_mac, disk = test_disk) diff --git a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py index 3281942..fc1dcf7 100644 --- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py +++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py @@ -496,7 +496,7 @@ def main(): if virt == "Xen": test_disk = "xvda" else: - test_disk = "hda" + test_disk = "vda" destroy_and_undefine_all(options.ip) vsxml = get_class(virt)(test_dom, vcpus = test_vcpus, mac = test_mac, disk = test_disk) diff --git a/suites/libvirt-cim/cimtest/HostedAccessPoint/01_forward.py b/suites/libvirt-cim/cimtest/HostedAccessPoint/01_forward.py index 8493ed7..9ffd0fd 100644 --- a/suites/libvirt-cim/cimtest/HostedAccessPoint/01_forward.py +++ b/suites/libvirt-cim/cimtest/HostedAccessPoint/01_forward.py @@ -41,7 +41,7 @@ def setup_env(server, virt): if virt == 'Xen': test_disk = 'xvda' else: - test_disk = 'hda' + test_disk = 'vda' virt_xml = get_class(virt) if virt == 'LXC': diff --git a/suites/libvirt-cim/cimtest/HostedAccessPoint/02_reverse.py b/suites/libvirt-cim/cimtest/HostedAccessPoint/02_reverse.py index 74850ed..2d6daf1 100644 --- a/suites/libvirt-cim/cimtest/HostedAccessPoint/02_reverse.py +++ b/suites/libvirt-cim/cimtest/HostedAccessPoint/02_reverse.py @@ -41,7 +41,7 @@ def setup_env(server, virt): if virt == 'Xen': test_disk = 'xvda' else: - test_disk = 'hda' + test_disk = 'vda' virt_xml = get_class(virt) if virt == 'LXC': diff --git a/suites/libvirt-cim/cimtest/RASDIndications/02_guest_add_mod_rem_rasd_ind.py b/suites/libvirt-cim/cimtest/RASDIndications/02_guest_add_mod_rem_rasd_ind.py index 329c7b4..6d513bd 100644 --- a/suites/libvirt-cim/cimtest/RASDIndications/02_guest_add_mod_rem_rasd_ind.py +++ b/suites/libvirt-cim/cimtest/RASDIndications/02_guest_add_mod_rem_rasd_ind.py @@ -151,7 +151,7 @@ def main(): ndpath = cxml.secondary_disk_path if virt == 'KVM': - nddev = 'hdb' + nddev = 'vdb' else: nddev = 'xvdb' diff --git a/suites/libvirt-cim/cimtest/ServiceAccessBySAP/01_forward.py b/suites/libvirt-cim/cimtest/ServiceAccessBySAP/01_forward.py index 525e05f..4840522 100644 --- a/suites/libvirt-cim/cimtest/ServiceAccessBySAP/01_forward.py +++ b/suites/libvirt-cim/cimtest/ServiceAccessBySAP/01_forward.py @@ -43,7 +43,7 @@ def setup_env(server, virt): if virt == 'Xen': test_disk = 'xvda' else: - test_disk = 'hda' + test_disk = 'vda' virt_xml = get_class(virt) diff --git a/suites/libvirt-cim/cimtest/ServiceAccessBySAP/02_reverse.py b/suites/libvirt-cim/cimtest/ServiceAccessBySAP/02_reverse.py index 1c1c913..14c0db1 100644 --- a/suites/libvirt-cim/cimtest/ServiceAccessBySAP/02_reverse.py +++ b/suites/libvirt-cim/cimtest/ServiceAccessBySAP/02_reverse.py @@ -42,7 +42,7 @@ def setup_env(server, virt): if virt == 'Xen': test_disk = 'xvda' else: - test_disk = 'hda' + test_disk = 'vda' virt_xml = get_class(virt) diff --git a/suites/libvirt-cim/cimtest/SettingsDefine/01_forward.py b/suites/libvirt-cim/cimtest/SettingsDefine/01_forward.py index 850f3ce..5850090 100755 --- a/suites/libvirt-cim/cimtest/SettingsDefine/01_forward.py +++ b/suites/libvirt-cim/cimtest/SettingsDefine/01_forward.py @@ -45,7 +45,7 @@ def setup_env(server, virt): if virt == 'Xen': test_disk = 'xvda' else: - test_disk = 'hda' + test_disk = 'vda' virt_xml = get_class(virt) if virt == 'LXC': cxml = virt_xml(test_dom) diff --git a/suites/libvirt-cim/cimtest/SettingsDefine/02_reverse.py b/suites/libvirt-cim/cimtest/SettingsDefine/02_reverse.py index fdae709..1917113 100644 --- a/suites/libvirt-cim/cimtest/SettingsDefine/02_reverse.py +++ b/suites/libvirt-cim/cimtest/SettingsDefine/02_reverse.py @@ -70,7 +70,7 @@ def setup_env(server, virt): if virt == 'Xen': test_disk = 'xvdb' else: - test_disk = 'hdb' + test_disk = 'vdb' virt_xml = get_class(virt) if virt == 'LXC': cxml = virt_xml(test_dom) diff --git a/suites/libvirt-cim/cimtest/SettingsDefine/03_sds_fwd_errs.py b/suites/libvirt-cim/cimtest/SettingsDefine/03_sds_fwd_errs.py index 58b9cbc..d4f7c89 100644 --- a/suites/libvirt-cim/cimtest/SettingsDefine/03_sds_fwd_errs.py +++ b/suites/libvirt-cim/cimtest/SettingsDefine/03_sds_fwd_errs.py @@ -211,7 +211,7 @@ def main(): if options.virt == 'Xen': test_disk = 'xvda' else: - test_disk = 'hda' + test_disk = 'vda' virt_xml = vxml.get_class(options.virt) if options.virt == 'LXC': diff --git a/suites/libvirt-cim/cimtest/SettingsDefine/04_sds_rev_errs.py b/suites/libvirt-cim/cimtest/SettingsDefine/04_sds_rev_errs.py index 43484e9..fdd0086 100644 --- a/suites/libvirt-cim/cimtest/SettingsDefine/04_sds_rev_errs.py +++ b/suites/libvirt-cim/cimtest/SettingsDefine/04_sds_rev_errs.py @@ -101,7 +101,7 @@ def main(): if options.virt == 'Xen': test_disk = 'xvda' else: - test_disk = 'hda' + test_disk = 'vda' virt_xml = vxml.get_class(options.virt) if options.virt == 'LXC': diff --git a/suites/libvirt-cim/cimtest/SystemDevice/01_forward.py b/suites/libvirt-cim/cimtest/SystemDevice/01_forward.py index 330c6fb..15a4ff5 100644 --- a/suites/libvirt-cim/cimtest/SystemDevice/01_forward.py +++ b/suites/libvirt-cim/cimtest/SystemDevice/01_forward.py @@ -52,7 +52,7 @@ def main(): elif virt == 'LXC': test_disk = '/tmp' else: - test_disk = 'hdb' + test_disk = 'vdb' status = PASS virt_xml = vxml.get_class(virt) diff --git a/suites/libvirt-cim/cimtest/SystemDevice/03_fwderrs.py b/suites/libvirt-cim/cimtest/SystemDevice/03_fwderrs.py index 0e7e167..e48bcf5 100644 --- a/suites/libvirt-cim/cimtest/SystemDevice/03_fwderrs.py +++ b/suites/libvirt-cim/cimtest/SystemDevice/03_fwderrs.py @@ -60,7 +60,7 @@ def main(): if options.virt == 'Xen': test_disk = 'xvda' else: - test_disk = 'hda' + test_disk = 'vda' status = PASS virt_xml = vxml.get_class(options.virt) diff --git a/suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py b/suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py index 4d24b39..04b0b6e 100755 --- a/suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py +++ b/suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py @@ -214,7 +214,7 @@ def main(): if virt == "LXC": test_disk = "/tmp" else: - test_disk = "hda" + test_disk = "vda" status, vsxml = setup_env(virt) if status != PASS: diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/13_refconfig_additional_devs.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/13_refconfig_additional_devs.py index a47db8f..5e9e780 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/13_refconfig_additional_devs.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/13_refconfig_additional_devs.py @@ -125,7 +125,7 @@ def main(): test_disk = 'xvdb' disk_path = Xen_secondary_disk_path else: - test_disk = 'hdb' + test_disk = 'vdb' disk_path = KVM_secondary_disk_path cxml2 = virt_xml(test_dom2, mac=mac2, diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py index 294c275..4adabbd 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py @@ -67,7 +67,7 @@ def get_rasd_list(ip, virt, addr, disk_type): if virt == 'Xen': test_disk = 'xvda' else: - test_disk = 'hda' + test_disk = 'vda' for rasd in rasds: if rasd.classname == drasd_cn: diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/30_dynamic_disk_mod.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/30_dynamic_disk_mod.py index 8e6a3ae..5d81a21 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/30_dynamic_disk_mod.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/30_dynamic_disk_mod.py @@ -39,7 +39,7 @@ def main(): options = main.options if options.virt == 'KVM': - nddev = 'vda' + nddev = 'vdb' else: nddev = 'xvdb' diff --git a/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/02_reverse.py b/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/02_reverse.py index 0624b1d..3a13b2a 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/02_reverse.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/02_reverse.py @@ -159,7 +159,7 @@ def main(): elif options.virt == "LXC": test_disk = "/tmp" else: - test_disk = "hdb" + test_disk = "vdb" virt_xml = vxml.get_class(options.virt) if options.virt == 'LXC': diff --git a/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/03_vssdc_fwd_errs.py b/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/03_vssdc_fwd_errs.py index 492a55f..52f8c48 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/03_vssdc_fwd_errs.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/03_vssdc_fwd_errs.py @@ -105,7 +105,7 @@ def main(): if virt == "Xen": test_disk = "xvda" else: - test_disk = "hda" + test_disk = "vda" virt_xml = vxml.get_class(virt) if virt == 'LXC': diff --git a/suites/libvirt-cim/lib/XenKvmLib/const.py b/suites/libvirt-cim/lib/XenKvmLib/const.py index 6701d36..1d655d0 100755 --- a/suites/libvirt-cim/lib/XenKvmLib/const.py +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py @@ -86,7 +86,7 @@ Xen_default_mac = '88:22:33:aa:bb:cc' KVM_default_emulator = '/usr/bin/qemu-system-x86_64' KVM_disk_path = os.path.join(_image_dir, 'default-kvm-dimage') KVM_secondary_disk_path = os.path.join(_image_dir, 'default-kvm-dimage.2ND') -KVM_default_disk_dev = 'hda' +KVM_default_disk_dev = 'vda' KVM_default_cdrom_dev = 'hdc' KVM_default_mac = '88:22:33:aa:bb:cc' diff --git a/suites/libvirt-cim/lib/XenKvmLib/vsms.py b/suites/libvirt-cim/lib/XenKvmLib/vsms.py index 03cbe30..d7f33f9 100755 --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py @@ -339,7 +339,7 @@ def default_vssd_rasd_str(dom_name='test_domain', class_dasd = get_dasd_class(virt) if virt == 'KVM': - disk_dev = 'hda' + disk_dev = 'vda' disk_source = const.KVM_disk_path elif virt == 'XenFV': disk_dev = 'hda' -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Sep 5 15:36:34 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 5 Sep 2013 17:36:34 +0200 Subject: [Libvirt-cim] [PATCH 0/8] Support for full function consoles Message-ID: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> Motivation: the current libvirt-cim support for consoles is very limited in that it doesn't allow to specify the target and source types supported by libvirt. Having full support of the libvirt console feature is however mandatory for architectures like s390. The current implementation using a Graphics_RASD to represent consoles cannot easily be extended without breaking the existing implementation (or without being entirely unusable). Therefore a new RASD class is added to represent consoles in the model. Since there's no SVPC resource type for a console we use the combination of ResourceType = 1 (Other) and OtherResourceType = "console" for the new RASD instances. In order to be backward compatible, the only console type supported by older libvirt-cim versions (target type 'pty') will still be returned as Graphics_RASD. In the long run, this should be deprecated. Thilo Boehm (6): schema: Add CIM_ResourceAllocationSettingData for console resources schema: New SVPC types for chardev/consoles libxkutil: Console Support RASD: Provider Support for Console RASDs VSMS: Support for domains with console devices VSMS: add default console Viktor Mihajlovski (2): VSMS: Set resource types for default devices Device: CIM_LogicalDevice for consoles libxkutil/device_parsing.c | 316 ++++++++++++++++++- libxkutil/device_parsing.h | 43 ++- libxkutil/xmlgen.c | 191 +++++++++++- schema/ResourceAllocationSettingData.mof | 247 ++++++++++++++- schema/ResourceAllocationSettingData.registration | 5 +- src/Virt_Device.c | 33 ++ src/Virt_RASD.c | 148 ++++++++- src/Virt_VirtualSystemManagementService.c | 336 +++++++++++++++++++-- src/svpc_types.h | 102 ++++++- 9 files changed, 1384 insertions(+), 37 deletions(-) -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Sep 5 15:36:35 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 5 Sep 2013 17:36:35 +0200 Subject: [Libvirt-cim] [PATCH 1/8] VSMS: Set resource types for default devices In-Reply-To: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378395402-9422-2-git-send-email-mihajlov@linux.vnet.ibm.com> The default graphics and input devices were built without their resource types being set correctly. This has not hurted yet. Future changes will however require that the device resource type is matching the actual device type. Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- src/Virt_VirtualSystemManagementService.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 79dec73..6629b35 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -581,6 +581,7 @@ static bool default_graphics_device(struct domain *domain) return false; } + domain->dev_graphics->type = CIM_RES_TYPE_GRAPHICS; domain->dev_graphics->dev.graphics.type = strdup("vnc"); domain->dev_graphics->dev.graphics.dev.vnc.port = strdup("-1"); domain->dev_graphics->dev.graphics.dev.vnc.host = strdup("127.0.0.1"); @@ -609,6 +610,7 @@ static bool default_input_device(struct domain *domain) return false; } + domain->dev_input->type = CIM_RES_TYPE_INPUT; domain->dev_input->dev.input.type = strdup("mouse"); if (domain->type == DOMAIN_XENPV) { -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Sep 5 15:36:36 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 5 Sep 2013 17:36:36 +0200 Subject: [Libvirt-cim] [PATCH 2/8] schema: Add CIM_ResourceAllocationSettingData for console resources In-Reply-To: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378395402-9422-3-git-send-email-mihajlov@linux.vnet.ibm.com> From: Thilo Boehm Representing console devices was very limited with the previous approach using a special graphical display. For instance it was not possible to define different target types (serial, virtio, sclp) nor to exploit all source types (pty, file, tcp, ...) available in libvirt. With the following new RASD classes it is possible to define real console resources: KVM_ConsoleResouceAllocationSettingData Xen_ConsoleResouceAllocationSettingData LXC_ConsoleResouceAllocationSettingData Signed-off-by: Thilo Boehm Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- schema/ResourceAllocationSettingData.mof | 247 ++++++++++++++++++++- schema/ResourceAllocationSettingData.registration | 5 +- 2 files changed, 250 insertions(+), 2 deletions(-) diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index 871ab04..8974d83 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2007 +// Copyright IBM Corp. 2007, 2013 [Description ("Xen virtual disk configuration"), Provider("cmpi::Virt_RASD") @@ -445,3 +445,248 @@ class KVM_StorageVolumeResourceAllocationSettingData : KVM_ResourceAllocationSet string AllocationUnits; }; +[Description ("KVM virtual character device"), + Provider("cmpi::Virt_RASD") +] +class KVM_CharacterResourceAllocationSettingData : KVM_ResourceAllocationSettingData +{ + [Description ("The type of resource in the source/host environment."), + ValueMap {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, + Values {"null", "vc", "pty", "dev", "file", "pipe", + "stdio", "udp", "tcp", "unix", "spicevmc"}, + ModelCorrespondence {"KVM_CharacterResourceAllocationSettingData.SourcePath", + "KVM_CharacterResourceAllocationSettingData.ConnectURL", + "KVM_CharacterResourceAllocationSettingData.BindURL"}] + uint16 SourceType; + + [Description ("If SourceType=4 ('file'),this is the full qualified file path. " + "The file is opened and all data sent to the character device " + "is written to the file. " + "If SourceType=2 ('pty'),this is the full qualified Pseudo TTY path. " + "A Pseudo TTY is allocated using /dev/ptmx. " + "If SourceType=3 ('dev'), this is the full qualified file path " + "to the underlying phsical character device. The device types must " + "match, eg the emulated serial port should only be connected to a " + "host serial port - don't connect a serial port to a parallel port. " + "If SourceType=5 ('pipe'), this is the full qualified file path " + "of a named pipe."), + ModelCorrespondence {"KVM_CharacterResourceAllocationSettingData.SourceType"}] + string SourcePath; + + [Description ("This URL describes the connection to a remote or local location " + "where the character devices acts as a client." + "To use a literal IPv6 address in the URI, the literal address should be " + "enclosed in '[' and ']' characters. " + "If SourceType=7 ('udp'), this is defines a udp remote host and port connection " + "to send packages. That the character device acts as a UDP netconsole service, " + "sending and receiving packets, the BindURL property must also be defined. " + "This is a lossy service. " + "Only 'udp' is valid for the protocol part of the URI. " + "Format of the URL: ://:. e.g. udp://0.0.0.0:2245 " + "If SourceType=8 ('tcp'), this is defines a remote host and port connection. " + "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. " + "Format of the URL: ://:. e.g. raw://[3ffe:2a00:100:7031::1]:2245 " + "If SourceType=9 ('unix'), this is defined the full qualified file path " + "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. " + "Format of the URL: file://. " + "e.g. file:///tmp/console-out"), + ModelCorrespondence {"KVM_CharacterResourceAllocationSettingData.SourceType"}] + string ConnectURL; + + [Description ("This URL describes the connection to a remote or local location " + "where the character devices acts as a server. " + "To use a literal IPv6 address in the URI, the literal address should be " + "enclosed in '[' and ']' characters. " + "If SourceType=7 ('udp'), this is defines a udp remote host and port connection " + "to receive packages. That the character device acts as a UDP netconsole service, " + "sending and receiving packets, the ConnectURL property must also be defined. " + "This is a lossy service. " + "Only 'udp' is valid for the protocol part of the URI. " + "Format of the URL: ://:. e.g. udp://0.0.0.0:2245 " + "If SourceType=8 ('tcp'), this is defines a remote host and port connection. " + "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. " + "Format of the URL: ://:. e.g. raw://[3ffe:2a00:100:7031::1]:2245 " + "If SourceType=9 ('unix'), this is defined the full qualified file path " + "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. " + "Format of the URL: file://. " + "e.g. file:///tmp/console-in"), + ModelCorrespondence {"KVM_CharacterResourceAllocationSettingData.SourceType"}] + string BindURL; +}; + + +[Description ("KVM virtual console device. It is identified by: " + "CIM_ResourceAllocationSettingData.ResourceType=1 ( 'Other' ) and " + "CIM_ResourceAllocationSettingData.OtherResourceType='console'"), + Provider("cmpi::Virt_RASD") +] +class KVM_ConsoleResourceAllocationSettingData : KVM_CharacterResourceAllocationSettingData +{ + [Description ("The type of the console in the target/guest environment.")] + string TargetType; +}; + + + +[Description ("Xen virtual character device"), + Provider("cmpi::Virt_RASD") +] +class Xen_CharacterResourceAllocationSettingData : Xen_ResourceAllocationSettingData +{ + [Description ("The type of resource in the source/host environment."), + ValueMap {"0","1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, + Values {"null", "vc", "pty", "dev", "file", "pipe", + "stdio", "udp", "tcp", "unix", "spicevmc"}, + ModelCorrespondence {"Xen_CharacterResourceAllocationSettingData.SourcePath", + "Xen_CharacterResourceAllocationSettingData.ConnectURL", + "Xen_CharacterResourceAllocationSettingData.BindURL"}] + uint16 SourceType; + + [Description ("If SourceType=4 ('file'),this is the full qualified file path. " + "The file is opened and all data sent to the character device " + "is written to the file. " + "If SourceType=2 ('pty'),this is the full qualified Pseudo TTY path. " + "A Pseudo TTY is allocated using /dev/ptmx. " + "If SourceType=3 ('dev'), this is the full qualified file path " + "to the underlying phsical character device. The device types must " + "match, eg the emulated serial port should only be connected to a " + "host serial port - don't connect a serial port to a parallel port. " + "If SourceType=5 ('pipe'), this is the full qualified file path " + "of a named pipe."), + ModelCorrespondence {"Xen_CharacterResourceAllocationSettingData.SourceType"}] + string SourcePath; + + [Description ("This URL describes the connection to a remote or local location " + "where the character devices acts as a client." + "To use a literal IPv6 address in the URI, the literal address should be " + "enclosed in '[' and ']' characters. " + "If SourceType=7 ('udp'), this is defines a udp remote host and port connection " + "to send packages. That the character device acts as a UDP netconsole service, " + "sending and receiving packets, the BindURL property must also be defined. " + "This is a lossy service. " + "Only 'udp' is valid for the protocol part of the URI. " + "Format of the URL: ://:. e.g. udp://0.0.0.0:2245 " + "If SourceType=8 ('tcp'), this is defines a remote host and port connection. " + "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. " + "Format of the URL: ://:. e.g. raw://[3ffe:2a00:100:7031::1]:2245 " + "If SourceType=9 ('unix'), this is defined the full qualified file path " + "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. " + "Format of the URL: file://. " + "e.g. file:///tmp/console-out"), + ModelCorrespondence {"Xen_CharacterResourceAllocationSettingData.SourceType"}] + string ConnectURL; + + [Description ("This URL describes the connection to a remote or local location " + "where the character devices acts as a server. " + "To use a literal IPv6 address in the URI, the literal address should be " + "enclosed in '[' and ']' characters. " + "If SourceType=7 ('udp'), this is defines a udp remote host and port connection " + "to receive packages. That the character device acts as a UDP netconsole service, " + "sending and receiving packets, the ConnectURL property must also be defined. " + "This is a lossy service. " + "Only 'udp' is valid for the protocol part of the URI. " + "Format of the URL: ://:. e.g. udp://0.0.0.0:2245 " + "If SourceType=8 ('tcp'), this is defines a remote host and port connection. " + "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. " + "Format of the URL: ://:. e.g. raw://[3ffe:2a00:100:7031::1]:2245 " + "If SourceType=9 ('unix'), this is defined the full qualified file path " + "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. " + "Format of the URL: file://. " + "e.g. file:///tmp/console-in"), + ModelCorrespondence {"Xen_CharacterResourceAllocationSettingData.SourceType"}] + string BindURL; +}; + + +[Description ("Xen virtual console device. It is identified by: " + "CIM_ResourceAllocationSettingData.ResourceType=1 ( 'Other' ) and " + "CIM_ResourceAllocationSettingData.OtherResourceType='console'"), + Provider("cmpi::Virt_RASD") +] +class Xen_ConsoleResourceAllocationSettingData : Xen_CharacterResourceAllocationSettingData +{ + [Description ( "The type of the console in the target/guest environment.")] + string TargetType; +}; + +[Description ("LXC virtual character device"), + Provider("cmpi::Virt_RASD") +] +class LXC_CharacterResourceAllocationSettingData : LXC_ResourceAllocationSettingData +{ + [Description ("The type of resource in the source/host environment."), + ValueMap {"0","1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, + Values {"null", "vc", "pty", "dev", "file", "pipe", + "stdio", "udp", "tcp", "unix", "spicevmc"}, + ModelCorrespondence {"LXC_CharacterResourceAllocationSettingData.SourcePath", + "LXC_CharacterResourceAllocationSettingData.ConnectURL", + "LXC_CharacterResourceAllocationSettingData.BindURL"}] + uint16 SourceType; + + [Description ("If SourceType=4 ('file'),this is the full qualified file path. " + "The file is opened and all data sent to the character device " + "is written to the file. " + "If SourceType=2 ('pty'),this is the full qualified Pseudo TTY path. " + "A Pseudo TTY is allocated using /dev/ptmx. " + "If SourceType=3 ('dev'), this is the full qualified file path " + "to the underlying phsical character device. The device types must " + "match, eg the emulated serial port should only be connected to a " + "host serial port - don't connect a serial port to a parallel port. " + "If SourceType=5 ('pipe'), this is the full qualified file path " + "of a named pipe."), + ModelCorrespondence {"LXC_CharacterResourceAllocationSettingData.SourceType"}] + string SourcePath; + + [Description ("This URL describes the connection to a remote or local location " + "where the character devices acts as a client." + "To use a literal IPv6 address in the URI, the literal address should be " + "enclosed in '[' and ']' characters. " + "If SourceType=7 ('udp'), this is defines a udp remote host and port connection " + "to send packages. That the character device acts as a UDP netconsole service, " + "sending and receiving packets, the BindURL property must also be defined. " + "This is a lossy service. " + "Only 'udp' is valid for the protocol part of the URI. " + "Format of the URL: ://:. e.g. udp://0.0.0.0:2245 " + "If SourceType=8 ('tcp'), this is defines a remote host and port connection. " + "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. " + "Format of the URL: ://:. e.g. raw://[3ffe:2a00:100:7031::1]:2245 " + "If SourceType=9 ('unix'), this is defined the full qualified file path " + "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. " + "Format of the URL: file://. " + "e.g. file:///tmp/console-out"), + ModelCorrespondence {"LXC_CharacterResourceAllocationSettingData.SourceType"}] + string ConnectURL; + + [Description ("This URL describes the connection to a remote or local location " + "where the character devices acts as a server. " + "To use a literal IPv6 address in the URI, the literal address should be " + "enclosed in '[' and ']' characters. " + "If SourceType=7 ('udp'), this is defines a udp remote host and port connection " + "to receive packages. That the character device acts as a UDP netconsole service, " + "sending and receiving packets, the ConnectURL property must also be defined. " + "This is a lossy service. " + "Only 'udp' is valid for the protocol part of the URI. " + "Format of the URL: ://:. e.g. udp://0.0.0.0:2245 " + "If SourceType=8 ('tcp'), this is defines a remote host and port connection. " + "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. " + "Format of the URL: ://:. e.g. raw://[3ffe:2a00:100:7031::1]:2245 " + "If SourceType=9 ('unix'), this is defined the full qualified file path " + "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. " + "Format of the URL: file://. " + "e.g. file:///tmp/console-in"), + ModelCorrespondence {"LXC_CharacterResourceAllocationSettingData.SourceType"}] + string BindURL; +}; + + +[Description ("LXC virtual console device. It is identified by: " + "CIM_ResourceAllocationSettingData.ResourceType=1 ( 'Other' ) and " + "CIM_ResourceAllocationSettingData.OtherResourceType='console'"), + Provider("cmpi::Virt_RASD") +] +class LXC_ConsoleResourceAllocationSettingData : LXC_CharacterResourceAllocationSettingData +{ + [Description ("The type of the console in the target/guest environment.")] + string TargetType; +}; + diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration index 2747f91..b969bfe 100644 --- a/schema/ResourceAllocationSettingData.registration +++ b/schema/ResourceAllocationSettingData.registration @@ -1,4 +1,4 @@ -# Copyright IBM Corp. 2007 +# Copyright IBM Corp. 2007, 2013 # Classname Namespace ProviderName ProviderModule ProviderTypes Xen_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance @@ -6,14 +6,17 @@ Xen_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +Xen_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Sep 5 15:36:39 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 5 Sep 2013 17:36:39 +0200 Subject: [Libvirt-cim] [PATCH 5/8] RASD: Provider Support for Console RASDs In-Reply-To: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378395402-9422-6-git-send-email-mihajlov@linux.vnet.ibm.com> From: Thilo Boehm Instance support for console RASDs. The ResourceType of the returned instances is is '1' (Other) and the OtherResourceType is 'console'. Implemented CIM operations: enumerate instances enumerate instance names get instance Signed-off-by: Thilo Boehm Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- src/Virt_RASD.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 147 insertions(+), 1 deletion(-) diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index 150ccd3..7d72831 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007, 2013 * * Authors: * Dan Smith @@ -662,6 +662,142 @@ static CMPIStatus set_graphics_rasd_params(const struct virt_device *dev, return s; } +static char* _build_console_url(const char *protocol, + const char *host, + const char *port) +{ + char* result = NULL; + + if (NULL == host) + goto out; + + if (STREQC("file", protocol)) { + /* The host string contains the file name. + Even if the file name does not start with a '/' + it is treated by libvirt as a full qualified path. + */ + if ('/' == host[0]) { + if (asprintf(&result, "file://%s", host) < 0) + result = NULL; + goto out; + } else { + if (asprintf(&result, "file:///%s", host) < 0) + result = NULL; + goto out; + } + } + /* The assumption is that the host does not contain a port. + If the host string contains a ':', + the host is treated as an IPv6 address. + */ + if (NULL == strchr(host, ':')) { + if (NULL == port) { + if (asprintf(&result,"%s://%s", protocol, host) < 0) + result = NULL; + goto out; + } else { + if (asprintf(&result,"%s://%s:%s", protocol, + host,port) < 0) + result = NULL; + goto out; + } + } + out: + return result; +} + + +static CMPIStatus set_console_rasd_params(const struct virt_device *vdev, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + const struct console_device *cdev = NULL; + char* tmp = NULL; + + cdev = &vdev->dev.console; + + CMSetProperty(inst, "OtherResourceType", "console", CMPI_chars); + CMSetProperty(inst, "SourceType", + (CMPIValue *)&cdev->source_type, CMPI_uint16); + CMSetProperty(inst, "TargetType", + (CMPIValue *)cdev->target_type, CMPI_chars); + + switch (cdev->source_type) { + case CIM_CHARDEV_SOURCE_TYPE_PTY: + CMSetProperty(inst, "SourcePath", + (CMPIValue *)cdev->source_dev.pty.path, + CMPI_chars); + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + CMSetProperty(inst, "SourcePath", + (CMPIValue *)cdev->source_dev.dev.path, + CMPI_chars); + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + CMSetProperty(inst, "SourcePath", + (CMPIValue *)cdev->source_dev.file.path, + CMPI_chars); + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + CMSetProperty(inst, "SourcePath", + (CMPIValue *)cdev->source_dev.pipe.path, + CMPI_chars); + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + tmp = _build_console_url("file", + cdev->source_dev.unixsock.path, NULL); + if (STREQC(cdev->source_dev.unixsock.mode, "bind")) + CMSetProperty(inst, "BindURL", + (CMPIValue *)tmp, CMPI_chars); + + if (STREQC(cdev->source_dev.unixsock.mode, "connect")) + CMSetProperty(inst, "ConnectURL", + (CMPIValue *)tmp, CMPI_chars); + + free(tmp); + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + tmp = _build_console_url("udp", + cdev->source_dev.udp.bind_host, + cdev->source_dev.udp.bind_service); + CMSetProperty(inst, "BindURL", + (CMPIValue *)tmp, CMPI_chars); + free(tmp); + + tmp = _build_console_url("udp", + cdev->source_dev.udp.connect_host, + cdev->source_dev.udp.connect_service); + CMSetProperty(inst, "ConnectURL", (CMPIValue *)tmp, CMPI_chars); + free(tmp); + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + tmp = _build_console_url(cdev->source_dev.tcp.protocol, + cdev->source_dev.tcp.host, + cdev->source_dev.tcp.service); + if (STREQC(cdev->source_dev.tcp.mode, "bind")) + CMSetProperty(inst, "BindURL", + (CMPIValue *)tmp, CMPI_chars); + + if (STREQC(cdev->source_dev.tcp.mode, "connect")) + CMSetProperty(inst, "ConnectURL", + (CMPIValue *)tmp, CMPI_chars); + + free(tmp); + break; + + default: + /* Nothing to do for : + CIM_CHARDEV_SOURCE_TYPE_STDIO + CIM_CHARDEV_SOURCE_TYPE_NULL + CIM_CHARDEV_SOURCE_TYPE_VC + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC + */ + break; + } + + return s; +} + static CMPIStatus set_input_rasd_params(const struct virt_device *dev, CMPIInstance *inst) { @@ -721,6 +857,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, } else if (dev->type == CIM_RES_TYPE_GRAPHICS) { type = CIM_RES_TYPE_GRAPHICS; base = "GraphicsResourceAllocationSettingData"; + } else if (dev->type == CIM_RES_TYPE_CONSOLE) { + type = CIM_RES_TYPE_OTHER; + base = "ConsoleResourceAllocationSettingData"; } else if (dev->type == CIM_RES_TYPE_INPUT) { type = CIM_RES_TYPE_INPUT; base = "InputResourceAllocationSettingData"; @@ -777,6 +916,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, s = set_graphics_rasd_params(dev, inst, host, CLASSNAME(ref)); } else if (dev->type == CIM_RES_TYPE_INPUT) { s = set_input_rasd_params(dev, inst); + } else if (dev->type == CIM_RES_TYPE_CONSOLE) { + s = set_console_rasd_params(dev, inst); } /* FIXME: Put the HostResource in place */ @@ -909,6 +1050,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) *type = CIM_RES_TYPE_INPUT; else if (STREQ(base, "StorageVolumeResourceAllocationSettingData")) *type = CIM_RES_TYPE_IMAGE; + else if (STREQ(base, "ConsoleResourceAllocationSettingData")) + *type = CIM_RES_TYPE_CONSOLE; else goto out; @@ -940,6 +1083,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) case CIM_RES_TYPE_GRAPHICS: *classname = "GraphicsResourceAllocationSettingData"; break; + case CIM_RES_TYPE_CONSOLE: + *classname = "ConsoleResourceAllocationSettingData"; + break; case CIM_RES_TYPE_INPUT: *classname = "InputResourceAllocationSettingData"; break; -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Sep 5 15:36:37 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 5 Sep 2013 17:36:37 +0200 Subject: [Libvirt-cim] [PATCH 3/8] schema: New SVPC types for chardev/consoles In-Reply-To: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378395402-9422-4-git-send-email-mihajlov@linux.vnet.ibm.com> From: Thilo Boehm C definitions for the console source types, defining the representation of the consoles in the hypervisor host. Includes mapping from and to string representations. Signed-off-by: Thilo Boehm Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- src/svpc_types.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/src/svpc_types.h b/src/svpc_types.h index 99dd56f..2e4d73f 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007, 2013 * * Authors: * Dan Smith @@ -167,5 +167,100 @@ enum CIM_op_status { CIM_OP_STATUS_POWER_MODE = 18, }; +/* emum for the Character device Source resource types */ +enum CIM_chardev_source_type { + CIM_CHARDEV_SOURCE_TYPE_NULL = 0, + CIM_CHARDEV_SOURCE_TYPE_VC = 1, + CIM_CHARDEV_SOURCE_TYPE_PTY = 2, + CIM_CHARDEV_SOURCE_TYPE_DEV = 3, + CIM_CHARDEV_SOURCE_TYPE_FILE = 4, + CIM_CHARDEV_SOURCE_TYPE_PIPE = 5, + CIM_CHARDEV_SOURCE_TYPE_STDIO = 6, + CIM_CHARDEV_SOURCE_TYPE_UDP = 7, + CIM_CHARDEV_SOURCE_TYPE_TCP = 8, + CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK = 9, + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC = 10, + /* please insert new source types above */ + CIM_CHARDEV_SOURCE_TYPE_INVALIDTYPE, + CIM_CHARDEV_SOURCE_TYPE_UNKNOWN = 32768, +}; + +static inline int chardev_source_type_StrToID(const char *type_str) +{ + int rc = CIM_CHARDEV_SOURCE_TYPE_UNKNOWN; + + if (type_str == NULL) + return rc; + + if (STREQC(type_str, "null")) + rc = CIM_CHARDEV_SOURCE_TYPE_NULL; + else if (STREQC(type_str, "vc")) + rc = CIM_CHARDEV_SOURCE_TYPE_VC; + else if (STREQC(type_str, "pty")) + rc = CIM_CHARDEV_SOURCE_TYPE_PTY; + else if (STREQC(type_str, "dev")) + rc = CIM_CHARDEV_SOURCE_TYPE_DEV; + else if (STREQC(type_str, "file")) + rc = CIM_CHARDEV_SOURCE_TYPE_FILE; + else if (STREQC(type_str, "pipe")) + rc = CIM_CHARDEV_SOURCE_TYPE_PIPE; + else if (STREQC(type_str, "stdio")) + rc = CIM_CHARDEV_SOURCE_TYPE_STDIO; + else if (STREQC(type_str, "udp")) + rc = CIM_CHARDEV_SOURCE_TYPE_UDP; + else if (STREQC(type_str, "tcp")) + rc = CIM_CHARDEV_SOURCE_TYPE_TCP; + else if (STREQC(type_str, "unix")) + rc = CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK; + else if (STREQC(type_str, "spicevmc")) + rc = CIM_CHARDEV_SOURCE_TYPE_SPICEVMC; + + return rc; +} + +static inline const char* chardev_source_type_IDToStr(int type) +{ + char *type_str = NULL; + + switch (type) + { + case CIM_CHARDEV_SOURCE_TYPE_NULL: + type_str = "null"; + break; + case CIM_CHARDEV_SOURCE_TYPE_VC: + type_str = "vc"; + break; + case CIM_CHARDEV_SOURCE_TYPE_PTY: + type_str = "pty"; + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + type_str = "dev"; + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + type_str = "file"; + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + type_str = "pipe"; + break; + case CIM_CHARDEV_SOURCE_TYPE_STDIO: + type_str = "stdio"; + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + type_str = "udp"; + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + type_str = "tcp"; + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + type_str = "unix"; + break; + case CIM_CHARDEV_SOURCE_TYPE_SPICEVMC: + type_str = "spicevmc"; + break; + default: + break; + } + return type_str; +} #endif -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Sep 5 15:36:40 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 5 Sep 2013 17:36:40 +0200 Subject: [Libvirt-cim] [PATCH 6/8] Device: CIM_LogicalDevice for consoles In-Reply-To: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378395402-9422-7-git-send-email-mihajlov@linux.vnet.ibm.com> Extended the Virt_Device provider to return DisplayController devices for the consoles found. This mainly for the purpose of consistency with the other RASD types. Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- src/Virt_Device.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/Virt_Device.c b/src/Virt_Device.c index c3b515c..aa47276 100644 --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -251,6 +251,34 @@ static CMPIInstance *graphics_instance(const CMPIBroker *broker, return inst; } +static CMPIInstance *console_instance(const CMPIBroker *broker, + struct console_device *dev, + const virDomainPtr dom, + const char *ns) +{ + CMPIInstance *inst; + virConnectPtr conn; + const char *ctype; + + conn = virDomainGetConnect(dom); + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "DisplayController", + ns, + true); + + if (inst == NULL) { + CU_DEBUG("Failed to get instance for DisplayController"); + return NULL; + } + + ctype = chardev_source_type_IDToStr(dev->source_type); + CMSetProperty(inst, "VideoProcessor", + (CMPIValue *)ctype, CMPI_chars); + + return inst; +} + int get_input_dev_caption(const char *type, const char *bus, char **cap) @@ -483,6 +511,11 @@ static bool device_instances(const CMPIBroker *broker, &dev->dev.graphics, dom, ns); + else if (dev->type == CIM_RES_TYPE_CONSOLE) + instance = console_instance(broker, + &dev->dev.console, + dom, + ns); else if (dev->type == CIM_RES_TYPE_INPUT) instance = input_instance(broker, &dev->dev.input, -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Sep 5 15:36:38 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 5 Sep 2013 17:36:38 +0200 Subject: [Libvirt-cim] [PATCH 4/8] libxkutil: Console Support In-Reply-To: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378395402-9422-5-git-send-email-mihajlov@linux.vnet.ibm.com> From: Thilo Boehm Added data types for the representation of console devices and their source type specific properties. Further, implemented libvirt XML parsing and generation of console device XML. Signed-off-by: Thilo Boehm Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- libxkutil/device_parsing.c | 316 ++++++++++++++++++++++++++++++++++++++++++-- libxkutil/device_parsing.h | 43 +++++- libxkutil/xmlgen.c | 191 +++++++++++++++++++++++++- src/svpc_types.h | 5 +- 4 files changed, 543 insertions(+), 12 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index fa9f998..06acbac 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007, 2013 * * Authors: * Dan Smith @@ -41,6 +41,11 @@ #define NET_XPATH (xmlChar *)"/domain/devices/interface" #define EMU_XPATH (xmlChar *)"/domain/devices/emulator" #define MEM_XPATH (xmlChar *)"/domain/memory | /domain/currentMemory" +#define CONSOLE_XPATH (xmlChar *)"/domain/devices/console" +/* + * To be backward compatible, serial and console is + * still part of the graphics. + */ #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ "/domain/devices/console | /domain/devices/serial" #define INPUT_XPATH (xmlChar *)"/domain/devices/input" @@ -50,6 +55,11 @@ #define MAX(a,b) (((a)>(b))?(a):(b)) +#define DUP_FIELD(d, s, f) do { \ + if ((s)->f != NULL) \ + (d)->f = strdup((s)->f); \ + } while (0); + /* Device parse function */ typedef int (*dev_parse_func_t)(xmlNode *, struct virt_device **); @@ -133,6 +143,140 @@ static void cleanup_graphics_device(struct graphics_device *dev) free(dev->type); } +static void cleanup_path_device(struct path_device *dev) +{ + if (dev == NULL) + return; + + free(dev->path); + +} + +static void cleanup_unixsock_device(struct unixsock_device *dev) +{ + if (dev == NULL) + return; + + free(dev->path); + free(dev->mode); + +} + +static void cleanup_tcp_device(struct tcp_device *dev) +{ + if (dev == NULL) + return; + + free(dev->mode); + free(dev->protocol); + free(dev->host); + free(dev->service); + +} + +static void cleanup_udp_device(struct udp_device *dev) +{ + if (dev == NULL) + return; + + free(dev->bind_host); + free(dev->bind_service); + free(dev->connect_host); + free(dev->connect_service); +}; + +static void cleanup_console_device(struct console_device *dev) +{ + if (dev == NULL) + return; + + switch (dev->source_type) + { + case CIM_CHARDEV_SOURCE_TYPE_PTY: + cleanup_path_device(&dev->source_dev.pty); + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + cleanup_path_device(&dev->source_dev.dev); + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + cleanup_path_device(&dev->source_dev.file); + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + cleanup_path_device(&dev->source_dev.pipe); + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + cleanup_unixsock_device(&dev->source_dev.unixsock); + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + cleanup_udp_device(&dev->source_dev.udp); + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + cleanup_tcp_device(&dev->source_dev.tcp); + break; + default: + /* Nothing to do for : + CIM_CHARDEV_SOURCE_TYPE_STDIO + CIM_CHARDEV_SOURCE_TYPE_NULL + CIM_CHARDEV_SOURCE_TYPE_VC + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC + */ + break; + } + + dev->source_type = 0; + free(dev->target_type); + memset(&dev->source_dev, 0, sizeof(dev->source_dev)); +}; + +static void console_device_dup(struct console_device *t, + struct console_device *s) +{ + cleanup_console_device(t); + + t->source_type = s->source_type; + DUP_FIELD(t, s, target_type); + + switch (s->source_type) + { + case CIM_CHARDEV_SOURCE_TYPE_PTY: + DUP_FIELD(t, s, source_dev.pty.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + DUP_FIELD(t, s, source_dev.dev.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + DUP_FIELD(t, s, source_dev.file.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + DUP_FIELD(t, s, source_dev.pipe.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + DUP_FIELD(t, s, source_dev.unixsock.path); + DUP_FIELD(t, s, source_dev.unixsock.mode); + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + DUP_FIELD(t, s, source_dev.udp.bind_host); + DUP_FIELD(t, s, source_dev.udp.bind_service); + DUP_FIELD(t, s, source_dev.udp.connect_host); + DUP_FIELD(t, s, source_dev.udp.connect_service); + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + DUP_FIELD(t, s, source_dev.tcp.mode); + DUP_FIELD(t, s, source_dev.tcp.protocol); + DUP_FIELD(t, s, source_dev.tcp.host); + DUP_FIELD(t, s, source_dev.tcp.service); + break; + default: + /* Nothing to do for : + CIM_CHARDEV_SOURCE_TYPE_STDIO + CIM_CHARDEV_SOURCE_TYPE_NULL + CIM_CHARDEV_SOURCE_TYPE_VC + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC + */ + break; + } +} + static void cleanup_input_device(struct input_device *dev) { if (dev == NULL) @@ -157,6 +301,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_graphics_device(&dev->dev.graphics); else if (dev->type == CIM_RES_TYPE_INPUT) cleanup_input_device(&dev->dev.input); + else if (dev->type == CIM_RES_TYPE_CONSOLE) + cleanup_console_device(&dev->dev.console); free(dev->id); @@ -613,6 +759,140 @@ static char *get_attr_value_default(xmlNode *node, char *attrname, return ret; } +static int parse_console_device(xmlNode *node, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct console_device *cdev = NULL; + char *source_type_str = NULL; + char *target_port_ID = NULL; + char *udp_source_mode = NULL; + + xmlNode *child = NULL; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.console); + + source_type_str = get_attr_value(node, "type"); + if (source_type_str == NULL) + goto err; + CU_DEBUG("console device type = %s", source_type_str); + + cdev->source_type = chardev_source_type_StrToID(source_type_str); + if (cdev->source_type == CIM_CHARDEV_SOURCE_TYPE_UNKNOWN) + goto err; + + CU_DEBUG("console device type ID = %d", cdev->source_type); + free(source_type_str); + + for (child = node->children; child != NULL; child = child->next) { + if (XSTREQ(child->name, "target")) { + cdev->target_type = get_attr_value(child, "type"); + CU_DEBUG("Console device target type = '%s'", + cdev->target_type); + target_port_ID = get_attr_value(child, "port"); + if (target_port_ID == NULL) + goto err; + } + + if (XSTREQ(child->name, "source")) { + switch (cdev->source_type) + { + case CIM_CHARDEV_SOURCE_TYPE_PTY: + cdev->source_dev.pty.path = + get_attr_value(child, "path"); + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + cdev->source_dev.dev.path = + get_attr_value(child, "path"); + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + cdev->source_dev.file.path = + get_attr_value(child, "path"); + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + cdev->source_dev.pipe.path = + get_attr_value(child, "path"); + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + cdev->source_dev.unixsock.mode = + get_attr_value(child, "mode"); + cdev->source_dev.unixsock.path = + get_attr_value(child, "path"); + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + udp_source_mode = get_attr_value(child, "mode"); + if (udp_source_mode == NULL) + goto err; + if (STREQC(udp_source_mode, "bind")) { + cdev->source_dev.udp.bind_host = + get_attr_value(child, "host"); + cdev->source_dev.udp.bind_service = + get_attr_value(child, "service"); + } + else if (STREQC(udp_source_mode, "connect")) { + cdev->source_dev.udp.connect_host = + get_attr_value(child, "host"); + cdev->source_dev.udp.connect_service = + get_attr_value(child, "service"); + } + else { + CU_DEBUG("unknown udp mode: %s", + udp_source_mode); + goto err; + } + free(udp_source_mode); + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + cdev->source_dev.tcp.mode = + get_attr_value(child, "mode"); + cdev->source_dev.tcp.host = + get_attr_value(child, "host"); + cdev->source_dev.tcp.service = + get_attr_value(child, "service"); + break; + + default: + /* Nothing to do for : + CIM_CHARDEV_SOURCE_TYPE_STDIO + CIM_CHARDEV_SOURCE_TYPE_NULL + CIM_CHARDEV_SOURCE_TYPE_VC + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC + */ + break; + } + } + if ((cdev->source_type == CIM_CHARDEV_SOURCE_TYPE_TCP) + && XSTREQ(child->name, "protocol")) { + cdev->source_dev.tcp.protocol = + get_attr_value(child, "type"); + } + } + + vdev->type = CIM_RES_TYPE_CONSOLE; + + if (-1 == asprintf(&vdev->id, "charconsole:%s", target_port_ID)) { + CU_DEBUG("Failed to create charconsole id string"); + goto err; + } + + *vdevs = vdev; + free(target_port_ID); + + return 1; + + err: + free(source_type_str); + free(target_port_ID); + free(udp_source_mode); + cleanup_console_device(cdev); + free(vdev); + + return 0; +} + static int parse_graphics_device(xmlNode *node, struct virt_device **vdevs) { struct virt_device *vdev = NULL; @@ -664,8 +944,20 @@ static int parse_graphics_device(xmlNode *node, struct virt_device **vdevs) child = child->next) { if (XSTREQ(child->name, "source")) gdev->dev.vnc.host = get_attr_value(child, "path"); - else if (XSTREQ(child->name, "target")) - gdev->dev.vnc.port = get_attr_value(child, "port"); + else if (XSTREQ(child->name, "target")) { + gdev->dev.vnc.port = + get_attr_value(child, "port"); + /* The graphics pty console can only be a + virtio console. If 'type' is not set in the + xml, the default of libvirt is virtio.*/ + char *t_type = get_attr_value(child, "type"); + if (t_type != NULL && !STREQC(t_type, "virtio")) { + CU_DEBUG("Not a pty-virtio graphics console"); + free(t_type); + goto err; + } + free(t_type); + } } } else { @@ -841,6 +1133,11 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_graphics_device; break; + case CIM_RES_TYPE_CONSOLE: + xpathstr = CONSOLE_XPATH; + func = &parse_console_device; + break; + case CIM_RES_TYPE_INPUT: xpathstr = INPUT_XPATH; func = &parse_input_device; @@ -876,11 +1173,6 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) return count; } -#define DUP_FIELD(d, s, f) do { \ - if ((s)->f != NULL) \ - (d)->f = strdup((s)->f); \ - } while (0); - struct virt_device *virt_device_dup(struct virt_device *_dev) { struct virt_device *dev; @@ -939,8 +1231,10 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_INPUT) { DUP_FIELD(dev, _dev, dev.input.type); DUP_FIELD(dev, _dev, dev.input.bus); + } else if (dev->type == CIM_RES_TYPE_CONSOLE) { + console_device_dup(&dev->dev.console, + &_dev->dev.console); } - return dev; } @@ -1299,6 +1593,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_graphics_ct = parse_devices(xml, &(*dominfo)->dev_graphics, CIM_RES_TYPE_GRAPHICS); + (*dominfo)->dev_console_ct = parse_devices(xml, + &(*dominfo)->dev_console, + CIM_RES_TYPE_CONSOLE); (*dominfo)->dev_input_ct = parse_devices(xml, &(*dominfo)->dev_input, CIM_RES_TYPE_INPUT); @@ -1396,6 +1693,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_vcpu, dom->dev_vcpu_ct); cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); + cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); free(dom); diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 14e49b8..2803d6a 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007, 2013 * * Authors: * Dan Smith @@ -111,6 +111,43 @@ struct graphics_device { } dev; }; +struct path_device { + char *path; +}; + +struct unixsock_device { + char *path; + char *mode; +}; + +struct tcp_device { + char *mode; + char *protocol; + char *host; + char *service; +}; + +struct udp_device { + char *bind_host; + char *bind_service; + char *connect_host; + char *connect_service; +}; + +struct console_device { + uint16_t source_type; + union { + struct path_device file; + struct path_device pty; + struct path_device dev; + struct path_device pipe; + struct unixsock_device unixsock; + struct tcp_device tcp; + struct udp_device udp; + } source_dev; + char *target_type; +}; + struct input_device { char *type; char *bus; @@ -125,6 +162,7 @@ struct virt_device { struct vcpu_device vcpu; struct emu_device emu; struct graphics_device graphics; + struct console_device console; struct input_device input; } dev; char *id; @@ -182,6 +220,9 @@ struct domain { struct virt_device *dev_graphics; int dev_graphics_ct; + struct virt_device *dev_console; + int dev_console_ct; + struct virt_device *dev_emu; struct virt_device *dev_input; diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 2ca2341..45bfb04 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007, 2013 * * Authors: * Dan Smith @@ -42,6 +42,189 @@ typedef const char *(*devfn_t)(xmlNodePtr node, struct domain *dominfo); typedef const char *(*poolfn_t)(xmlNodePtr node, struct virt_pool *pool); typedef const char *(*resfn_t)(xmlNodePtr node, struct virt_pool_res *res); +static int _count_graphics_console_definitions(struct domain *dominfo) +{ + int i; + int num = 0; + + for (i = 0; i < dominfo->dev_graphics_ct; i++) { + struct virt_device *_dev = &dominfo->dev_graphics[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct graphics_device *dev = &_dev->dev.graphics; + + if (STREQC(dev->type, "console")) { + num++; + } + } + CU_DEBUG("Found %d console defintions in graphics devices.",num); + return num; + +} + +static const char *console_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + xmlNodePtr console; + xmlNodePtr tmp; + int num_graphics_consol_def = 0; + int num_suppressed_console_def = 0; + + num_graphics_consol_def = _count_graphics_console_definitions(dominfo); + + for (i = 0; i < dominfo->dev_console_ct; i++) { + struct virt_device *_dev = &dominfo->dev_console[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct console_device *cdev = &_dev->dev.console; + + /* Due to backward compatibility, the graphics device handling + is still parsing consoles: + source = pty, target = virtio (which is the default target) + But the console device handling processes these kind of + consoles too. This would lead to a duplication of these + default consoles in the domain xml definition. + This code prevents the console handling of writing xml for + duplicate pty/virtio consoles which are written by the + graphics device handling. */ + if (cdev->source_type == CIM_CHARDEV_SOURCE_TYPE_PTY && + (cdev->target_type == NULL || + STREQC(cdev->target_type, "virtio"))) { + if (num_suppressed_console_def < + num_graphics_consol_def) { + num_suppressed_console_def++; + continue; + } + } + + console = xmlNewChild(root, NULL, BAD_CAST "console", NULL); + if (console == NULL) + return XML_ERROR; + + xmlNewProp(console, BAD_CAST "type", + BAD_CAST + chardev_source_type_IDToStr(cdev->source_type)); + + switch (cdev->source_type) { + case CIM_CHARDEV_SOURCE_TYPE_PTY: + /* The path property is not mandatory */ + if (cdev->source_dev.pty.path) { + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "path", + BAD_CAST cdev->source_dev.pty.path); + } + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "path", + BAD_CAST cdev->source_dev.dev.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "path", + BAD_CAST cdev->source_dev.file.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "path", + BAD_CAST cdev->source_dev.pipe.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "mode", + BAD_CAST cdev->source_dev.unixsock.mode); + xmlNewProp(tmp, BAD_CAST "path", + BAD_CAST cdev->source_dev.unixsock.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "mode", BAD_CAST "bind"); + xmlNewProp(tmp, BAD_CAST "host", + BAD_CAST cdev->source_dev.udp.bind_host); + /* The service property is not mandatory */ + if (cdev->source_dev.udp.bind_service) + xmlNewProp(tmp, BAD_CAST "service", + BAD_CAST + cdev->source_dev.udp.bind_service); + + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "mode", BAD_CAST "connect"); + xmlNewProp(tmp, BAD_CAST "host", + BAD_CAST cdev->source_dev.udp.connect_host); + /* The service property is not mandatory */ + if (cdev->source_dev.udp.connect_service) + xmlNewProp(tmp, BAD_CAST "service", + BAD_CAST + cdev->source_dev.udp.connect_service); + + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "mode", + BAD_CAST cdev->source_dev.tcp.mode); + xmlNewProp(tmp, BAD_CAST "host", + BAD_CAST cdev->source_dev.tcp.host); + if (cdev->source_dev.tcp.service) + xmlNewProp(tmp, BAD_CAST "service", + BAD_CAST + cdev->source_dev.tcp.service); + if (cdev->source_dev.tcp.protocol) { + tmp = xmlNewChild(console, NULL, + BAD_CAST "protocol", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "type", + BAD_CAST cdev->source_dev.tcp.protocol); + } + break; + default: + /* Nothing to do for : + CIM_CHARDEV_SOURCE_TYPE_STDIO + CIM_CHARDEV_SOURCE_TYPE_NULL + CIM_CHARDEV_SOURCE_TYPE_VC + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC + */ + break; + } + + if (cdev->target_type) { + tmp = xmlNewChild(console, NULL, + BAD_CAST "target", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "type", + BAD_CAST cdev->target_type); + } + } + return NULL; +} + static char *disk_block_xml(xmlNodePtr root, struct disk_device *dev) { xmlNodePtr disk; @@ -977,6 +1160,11 @@ char *device_to_xml(struct virt_device *_dev) dominfo->dev_graphics_ct = 1; dominfo->dev_graphics = dev; break; + case CIM_RES_TYPE_CONSOLE: + func = console_xml; + dominfo->dev_console_ct = 1; + dominfo->dev_console = dev; + break; case CIM_RES_TYPE_INPUT: func = input_xml; dominfo->dev_input_ct = 1; @@ -1017,6 +1205,7 @@ char *system_to_xml(struct domain *dominfo) &disk_xml, &net_xml, &input_xml, + &console_xml, &graphics_xml, &emu_xml, NULL diff --git a/src/svpc_types.h b/src/svpc_types.h index 2e4d73f..0f46a86 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -25,6 +25,7 @@ #define CIM_OPERATIONAL_STATUS 2 #define CIM_RES_TYPE_ALL 0 +#define CIM_RES_TYPE_OTHER 1 #define CIM_RES_TYPE_PROC 3 #define CIM_RES_TYPE_MEM 4 #define CIM_RES_TYPE_NET 10 @@ -34,8 +35,9 @@ #define CIM_RES_TYPE_INPUT 13 #define CIM_RES_TYPE_UNKNOWN 1000 #define CIM_RES_TYPE_IMAGE 32768 +#define CIM_RES_TYPE_CONSOLE 32769 -#define CIM_RES_TYPE_COUNT 6 +#define CIM_RES_TYPE_COUNT 7 const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, @@ -43,6 +45,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = CIM_RES_TYPE_PROC, CIM_RES_TYPE_GRAPHICS, CIM_RES_TYPE_INPUT, + CIM_RES_TYPE_CONSOLE, }; #define CIM_VSSD_RECOVERY_NONE 2 -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Sep 5 15:36:42 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 5 Sep 2013 17:36:42 +0200 Subject: [Libvirt-cim] [PATCH 8/8] VSMS: add default console In-Reply-To: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378395402-9422-9-git-send-email-mihajlov@linux.vnet.ibm.com> From: Thilo Boehm A new function to add a default console has been added. As with the default graphics and default input device, the default device generation is optional and depends on the domain type and architecture. Initially, we only create an s390 console, which is necessary to define a runnable guest. Signed-off-by: Thilo Boehm Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- src/Virt_VirtualSystemManagementService.c | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index cd6ca9d..f835b47 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -592,6 +592,38 @@ static bool default_graphics_device(struct domain *domain) return true; } +static bool default_console_device(struct domain *domain) +{ + /* currently only taking care for s390 guests */ + if ((domain->type == DOMAIN_KVM || domain->type == DOMAIN_QEMU) && + domain->os_info.fv.arch != NULL && + (XSTREQ(domain->os_info.fv.arch, "s390") || + XSTREQ(domain->os_info.fv.arch, "s390x" ))) { + char * consoletype = NULL; + if (domain->os_info.fv.machine != NULL && + XSTREQ(domain->os_info.fv.machine, "s390-ccw-virtio")) { + consoletype = "sclp"; + } else { + consoletype = "virtio"; + } + free(domain->dev_console); + domain->dev_console = calloc(1, sizeof(*domain->dev_console)); + if (domain->dev_console == NULL) { + CU_DEBUG("Failed to allocate default console device."); + return false; + } + CU_DEBUG("Defining default console device for s390."); + domain->dev_console->type = CIM_RES_TYPE_CONSOLE; + domain->dev_console->dev.console.source_type = + CIM_CHARDEV_SOURCE_TYPE_PTY; + domain->dev_console->dev.console.target_type = + strdup(consoletype); + domain->dev_console_ct = 1; + } + + return true; +} + static bool default_input_device(struct domain *domain) { if (domain->type == DOMAIN_LXC) @@ -628,6 +660,8 @@ static bool add_default_devs(struct domain *domain) { if (domain->dev_graphics_ct < 1 && domain->dev_console_ct < 1) { + if (!default_console_device(domain)) + return false; if (!default_graphics_device(domain)) return false; } -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Thu Sep 5 15:36:41 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 5 Sep 2013 17:36:41 +0200 Subject: [Libvirt-cim] [PATCH 7/8] VSMS: Support for domains with console devices In-Reply-To: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378395402-9422-8-git-send-email-mihajlov@linux.vnet.ibm.com> From: Thilo Boehm An instance of KVM_ConsoleResourceAllocationSettingData can be added to domain specification for VSMS DefineSystem() to define a console for a domain. A console definition can not be modified or deleted. It only can be added at system definition and deleted at system deletion. If a KVM_ConsoleRASD is specified on a system definition, no default graphics adapter definition is done. Signed-off-by: Thilo Boehm Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- src/Virt_VirtualSystemManagementService.c | 300 +++++++++++++++++++++++++++-- 1 file changed, 279 insertions(+), 21 deletions(-) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 6629b35..cd6ca9d 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007, 2013 * * Authors: * Dan Smith @@ -626,7 +626,8 @@ static bool default_input_device(struct domain *domain) static bool add_default_devs(struct domain *domain) { - if (domain->dev_graphics_ct < 1) { + if (domain->dev_graphics_ct < 1 && + domain->dev_console_ct < 1) { if (!default_graphics_device(domain)) return false; } @@ -1339,47 +1340,284 @@ static int parse_sdl_address(const char *id, return ret; } -static int parse_vnc_address(const char *id, - char **ip, - char **port) +static int parse_ip_address(const char *id, + char **ip, + char **port) { int ret; char *tmp_ip = NULL; char *tmp_port = NULL; - CU_DEBUG("Entering parse_vnc_address, address is %s", id); + CU_DEBUG("Entering parse_ip_address, address is %s", id); if (strstr(id, "[") != NULL) { /* its an ipv6 address */ ret = sscanf(id, "%a[^]]]:%as", &tmp_ip, &tmp_port); + tmp_ip = realloc(tmp_ip, strlen(tmp_ip) + 2); strcat(tmp_ip, "]"); } else { ret = sscanf(id, "%a[^:]:%as", &tmp_ip, &tmp_port); } - if (ret != 2) { + /* ret == 2: address and port, ret == 1: address only */ + if (ret < 1) { ret = 0; goto out; } - if (ip) + if (ip) { *ip = strdup(tmp_ip); + CU_DEBUG("IP = '%s'",*ip); + } - if (port) + if (port && tmp_port) { *port = strdup(tmp_port); - - ret = 1; + CU_DEBUG("Port = '%s'",*port); + } out: - if (ip && port) - CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", - *ip, *port); - free(tmp_ip); free(tmp_port); return ret; } +static bool parse_console_url(const char *url, + char **protocol, + char **host, + char **port) +{ + bool success = false; + char *tmp_protocol = NULL; + char *tmp_address = NULL; + + CU_DEBUG("Entering parse_console_url:'%s'", url); + + if (sscanf(url,"%a[^:]://%as", &tmp_protocol, &tmp_address) != 2) + goto out; + + if (parse_ip_address(tmp_address, host, port) < 1) + goto out; + + if (protocol) { + *protocol = strdup(tmp_protocol); + CU_DEBUG("Protocol = '%s'", *protocol); + } + + success = true; + + out: + free(tmp_protocol); + free(tmp_address); + + return success; +} + +static const char *_unixsock_console_rasd_to_vdev(CMPIInstance *inst, + struct console_device *cdev) +{ + const char *val = NULL; + const char *val2 = NULL; + char* protocol = NULL; + + cdev->source_dev.unixsock.mode = NULL; + if (cu_get_str_prop(inst,"ConnectURL", &val) == CMPI_RC_OK) { + CU_DEBUG("ConnectURL = '%s'", val); + cdev->source_dev.unixsock.mode = strdup("connect"); + } + + if (cu_get_str_prop(inst, "BindURL", &val2) == CMPI_RC_OK) { + if (cdev->source_dev.unixsock.mode != NULL) + return "ConsoleRASD: Only ConnectURL or BindURL are allowed for " + "UNIX domain socket client/server."; + CU_DEBUG("BindURL = '%s'", val2); + cdev->source_dev.unixsock.mode = strdup("bind"); + val = val2; + } + + if (val) { + if (!parse_console_url(val, &protocol, &cdev->source_dev.unixsock.path, NULL)) + return "ConsoleRASD: Invalid ConnectURL or BindURL for " + "UNIX domain socket client/server."; + + if (!STREQC("file", protocol)) { + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'",protocol); + free(protocol); + return "ConsoleRASD: Protocol 'file' was not specified for " + "ConnectURL or BindURL for UNIX domain socket client/server."; + } + free(protocol); + } else + return "ConsoleRASD: ConnectURL or BindURL not specified for " + "UNIX domain socket client/server."; + + return NULL; +} + +static const char *_udp_console_rasd_to_vdev(CMPIInstance *inst, + struct console_device *cdev) +{ + const char *val = NULL; + char* protocol = NULL; + + if (cu_get_str_prop(inst, "ConnectURL", &val) != CMPI_RC_OK) + return "ConsoleRASD: ConnectURL not specified for UDP network console."; + + if (!parse_console_url(val, &protocol, + &cdev->source_dev.udp.connect_host, + &cdev->source_dev.udp.connect_service)) + return "ConsoleRASD: Invalid ConnectURL specified for UDP network console."; + + if (!STREQC("udp" ,protocol)) { + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'",protocol); + free(protocol); + return "ConsoleRASD: Protocol 'udp' was not specified at " + "ConnectURL for UDP network console."; + } + + free(protocol); + + if (cu_get_str_prop(inst, "BindURL", &val) != CMPI_RC_OK) + return "ConsoleRASD: BindURL not specified for UDP network console."; + + if (!parse_console_url(val,&protocol, + &cdev->source_dev.udp.bind_host, + &cdev->source_dev.udp.bind_service)) + return "ConsoleRASD: Invalid BindURL specified for UDP network console."; + + if (!STREQC("udp", protocol)) { + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'",protocol); + free(protocol); + return "ConsoleRASD: Protocol 'udp' was not specified at BindURL " + "for UDP network console."; + } + + free(protocol); + return NULL; +} + +static const char *_tcp_console_rasd_to_vdev(CMPIInstance *inst, + struct console_device *cdev) +{ + const char *val = NULL; + const char *val2 = NULL; + + cdev->source_dev.tcp.mode = NULL; + if (cu_get_str_prop(inst, "ConnectURL", &val) == CMPI_RC_OK) { + CU_DEBUG("ConnectURL = '%s'",val); + cdev->source_dev.tcp.mode = strdup("connect"); + } + + if (cu_get_str_prop(inst, "BindURL", &val2) == CMPI_RC_OK) { + if (cdev->source_dev.tcp.mode != NULL) + return "ConsoleRASD: Only ConnectURL or BindURL are allowed for " + "TCP client/server console."; + CU_DEBUG("BindURL = '%s'",val2); + cdev->source_dev.tcp.mode = strdup("bind"); + val = val2; + } + + if (val) { + if (!parse_console_url(val, + &cdev->source_dev.tcp.protocol, + &cdev->source_dev.tcp.host, + &cdev->source_dev.tcp.service)) + return "ConsoleRASD: Invalid ConnectURL or BindURL for " + "TCP client/server console."; + if (cdev->source_dev.tcp.service == NULL) + return "ConsoleRASD: Missing TCP port for TCP client/server console."; + } else + return "ConsoleRASD: ConnectURL or BindURL not specified for " + "TCP client/server console."; + + if (STREQC("udp",cdev->source_dev.tcp.protocol)) { + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'", cdev->source_dev.tcp.protocol); + return "ConsoleRASD: Invalid protocol 'udp' was specified at " + "TCP client/server console."; + } + + if (STREQC("file", cdev->source_dev.tcp.protocol)) { + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'",cdev->source_dev.tcp.protocol); + return "ConsoleRASD: Invalid protocol 'file' was specified at " + "TCP client/server console."; + } + + return NULL; +} + +static const char *console_rasd_to_vdev(CMPIInstance *inst, + struct virt_device *dev) +{ + int rc = 0; + const char *msg = NULL; + const char *val = NULL; + struct console_device *cdev = &dev->dev.console; + uint16_t tmp; + + rc = cu_get_u16_prop(inst, "SourceType", &tmp); + if (rc != CMPI_RC_OK) + return "ConsoleRASD: SourceType field not specified."; + + if (tmp < 0 || tmp >= CIM_CHARDEV_SOURCE_TYPE_INVALIDTYPE) + return "ConsoleRASD: Invalid SourceType value"; + + cdev->source_type = tmp; + CU_DEBUG("Processeing SourceType: %d", cdev->source_type); + + /* property not required */ + if (cu_get_str_prop(inst, "TargetType", &val) == CMPI_RC_OK) + cdev->target_type = strdup(val); + CU_DEBUG("TargetType is '%s'", cdev->target_type); + + switch (cdev->source_type) { + case CIM_CHARDEV_SOURCE_TYPE_PTY: + /* property not required */ + if (cu_get_str_prop(inst, "SourcePath", &val) == CMPI_RC_OK) + cdev->source_dev.pty.path = strdup(val); + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + if (cu_get_str_prop(inst, "SourcePath", &val) != CMPI_RC_OK) + return "ConsoleRASD: SourcePath not specified for Host device proxy."; + cdev->source_dev.dev.path = strdup(val); + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + if (cu_get_str_prop(inst, "SourcePath", &val) != CMPI_RC_OK) + return "ConsoleRASD: SourcePath not specified for Device logfile."; + cdev->source_dev.file.path = strdup(val); + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + if (cu_get_str_prop(inst, "SourcePath", &val) != CMPI_RC_OK) + return "ConsoleRASD: SourcePath not specified for Named pipe."; + cdev->source_dev.pipe.path = strdup(val); + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + msg = _unixsock_console_rasd_to_vdev(inst, cdev); + if (msg != NULL) + return msg; + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + msg = _udp_console_rasd_to_vdev(inst, cdev); + if (msg != NULL) + return msg; + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + msg = _tcp_console_rasd_to_vdev(inst, cdev); + if (msg != NULL) + return msg; + break; + + default: + /* Nothing to do for : + CIM_CHARDEV_SOURCE_TYPE_STDIO + CIM_CHARDEV_SOURCE_TYPE_NULL + CIM_CHARDEV_SOURCE_TYPE_VC + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC + */ + break; + } + + return NULL; +} + static const char *graphics_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev) { @@ -1411,10 +1649,10 @@ static const char *graphics_rasd_to_vdev(CMPIInstance *inst, val = "127.0.0.1:-1"; } - ret = parse_vnc_address(val, + ret = parse_ip_address(val, &dev->dev.graphics.dev.vnc.host, &dev->dev.graphics.dev.vnc.port); - if (ret != 1) { + if (ret != 2) { msg = "GraphicsRASD field Address not valid"; goto out; } @@ -1540,6 +1778,8 @@ static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, return proc_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_GRAPHICS) { return graphics_rasd_to_vdev(inst, dev); + } else if (type == CIM_RES_TYPE_CONSOLE) { + return console_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_INPUT) { return input_rasd_to_vdev(inst, dev); } @@ -1601,7 +1841,7 @@ static const char *rasd_to_vdev(CMPIInstance *inst, return msg; } -static char *add_device_nodup(struct virt_device *dev, +static const char *add_device_nodup(struct virt_device *dev, struct virt_device *list, int max, int *index) @@ -1663,6 +1903,9 @@ static const char *classify_resources(CMPIArray *resources, if (!make_space(&domain->dev_graphics, domain->dev_graphics_ct, count)) return "Failed to alloc graphics list"; + if (!make_space(&domain->dev_console, domain->dev_console_ct, count)) + return "Failed to alloc console list"; + if (!make_space(&domain->dev_input, domain->dev_input_ct, count)) return "Failed to alloc input list"; @@ -1765,6 +2008,14 @@ static const char *classify_resources(CMPIArray *resources, domain->dev_graphics, gcount, &domain->dev_graphics_ct); + } else if (type == CIM_RES_TYPE_CONSOLE) { + msg = rasd_to_vdev(inst, + domain, + &domain->dev_console[domain->dev_console_ct], + ns, + p_error); + if (msg == NULL) + domain->dev_console_ct+=1; } else if (type == CIM_RES_TYPE_INPUT) { domain->dev_input_ct = 1; msg = rasd_to_vdev(inst, @@ -2570,6 +2821,9 @@ static struct virt_device **find_list(struct domain *dominfo, } else if (type == CIM_RES_TYPE_GRAPHICS) { list = &dominfo->dev_graphics; *count = &dominfo->dev_graphics_ct; + } else if (type == CIM_RES_TYPE_CONSOLE) { + list = &dominfo->dev_console; + *count = &dominfo->dev_console_ct; } else if (type == CIM_RES_TYPE_INPUT) { list = &dominfo->dev_input; *count = &dominfo->dev_input_ct; @@ -2693,7 +2947,8 @@ static CMPIStatus resource_del(struct domain *dominfo, if (STREQ(dev->id, devid)) { if ((type == CIM_RES_TYPE_GRAPHICS) || - (type == CIM_RES_TYPE_INPUT)) + (type == CIM_RES_TYPE_CONSOLE) || + (type == CIM_RES_TYPE_INPUT)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else { s = _resource_dynamic(dominfo, @@ -2774,7 +3029,9 @@ static CMPIStatus resource_add(struct domain *dominfo, goto out; } - if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT)) { + if ((type == CIM_RES_TYPE_GRAPHICS) || + (type == CIM_RES_TYPE_INPUT) || + (type == CIM_RES_TYPE_CONSOLE)) { (*count)++; cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); goto out; @@ -2850,7 +3107,8 @@ static CMPIStatus resource_mod(struct domain *dominfo, } if ((type == CIM_RES_TYPE_GRAPHICS) || - (type == CIM_RES_TYPE_INPUT)) + (type == CIM_RES_TYPE_INPUT) || + (type == CIM_RES_TYPE_CONSOLE)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else { #if LIBVIR_VERSION_NUMBER < 9000 -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Fri Sep 6 12:09:55 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 6 Sep 2013 14:09:55 +0200 Subject: [Libvirt-cim] [PATCH 1/2] libxkutil: Plug memory leaks in device parsing In-Reply-To: <1378469396-31284-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378469396-31284-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378469396-31284-2-git-send-email-mihajlov@linux.vnet.ibm.com> Fixed a number of memory leaks detected while running xml_parse_test under valgrind. Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- libxkutil/device_parsing.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index 06acbac..59186a3 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -105,6 +105,8 @@ static void cleanup_net_device(struct net_device *dev) free(dev->device); free(dev->net_mode); free(dev->filter_ref); + free(dev->poolid); + cleanup_vsi_device(&dev->vsi); } static void cleanup_emu_device(struct emu_device *dev) @@ -712,6 +714,8 @@ static int parse_mem_device(xmlNode *node, struct virt_device **vdevs) struct virt_device *vdev = NULL; struct mem_device *mdev = NULL; char *content = NULL; + char *tmpval = NULL; + int ret = 0; vdev = calloc(1, sizeof(*vdev)); if (vdev == NULL) @@ -725,27 +729,25 @@ static int parse_mem_device(xmlNode *node, struct virt_device **vdevs) sscanf(content, "%" PRIu64, &mdev->size); else if (XSTREQ(node->name, "memory")) { sscanf(content, "%" PRIu64, &mdev->maxsize); - content = get_attr_value(node, "dumpCore"); - if (content && XSTREQ(content, "on")) { + tmpval = get_attr_value(node, "dumpCore"); + if (tmpval && XSTREQ(tmpval, "on")) { mdev->dumpCore = MEM_DUMP_CORE_ON; - } else if (content && XSTREQ(content, "off")) { + } else if (tmpval && XSTREQ(content, "off")) { mdev->dumpCore = MEM_DUMP_CORE_OFF; } else { mdev->dumpCore = MEM_DUMP_CORE_NOT_SET; } } - free(content); - *vdevs = vdev; - - return 1; + ret = 1; err: free(content); + free(tmpval); free(vdev); - return 0; + return ret; } static char *get_attr_value_default(xmlNode *node, char *attrname, @@ -1079,7 +1081,10 @@ static int do_parse(xmlNodeSet *nsv, dev_parse_func_t do_real_parse, } out: - *l = list; + if (list) { + free(*l); + *l = list; + } return lstidx; } @@ -1497,7 +1502,7 @@ static int parse_features(struct domain *dominfo, xmlNode *features) static void set_action(int *val, xmlNode *child) { - const char *action = (char *)xmlNodeGetContent(child); + char *action = (char *)xmlNodeGetContent(child); if (action == NULL) *val = CIM_VSSD_RECOVERY_NONE; @@ -1509,6 +1514,8 @@ static void set_action(int *val, xmlNode *child) *val = CIM_VSSD_RECOVERY_RESTART; else *val = CIM_VSSD_RECOVERY_NONE; + + xmlFree(action); } static int parse_domain(xmlNodeSet *nsv, struct domain *dominfo) @@ -1663,9 +1670,11 @@ void cleanup_dominfo(struct domain **dominfo) dom = *dominfo; free(dom->name); + free(dom->typestr); free(dom->uuid); free(dom->bootloader); free(dom->bootloader_args); + free(dom->clock); if (dom->type == DOMAIN_XENPV) { free(dom->os_info.pv.type); @@ -1687,6 +1696,7 @@ void cleanup_dominfo(struct domain **dominfo) CU_DEBUG("Unknown domain type %i", dom->type); } + cleanup_virt_devices(&dom->dev_emu, 1); cleanup_virt_devices(&dom->dev_mem, dom->dev_mem_ct); cleanup_virt_devices(&dom->dev_net, dom->dev_net_ct); cleanup_virt_devices(&dom->dev_disk, dom->dev_disk_ct); -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Fri Sep 6 12:09:54 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 6 Sep 2013 14:09:54 +0200 Subject: [Libvirt-cim] [PATCH 0/2] Remove memory leaks in XML device parsing Message-ID: <1378469396-31284-1-git-send-email-mihajlov@linux.vnet.ibm.com> Discovered a few leaks in device_parsing.c running xml_parse_test under valgrind. The series applies on master as well as on top of the last series I sent out. Viktor Mihajlovski (2): libxkutil: Plug memory leaks in device parsing xml_parse_test: Call cleanup_dominfo before exiting libxkutil/device_parsing.c | 30 ++++++++++++++++++++---------- libxkutil/xml_parse_test.c | 2 ++ 2 files changed, 22 insertions(+), 10 deletions(-) -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Fri Sep 6 12:09:56 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 6 Sep 2013 14:09:56 +0200 Subject: [Libvirt-cim] [PATCH 2/2] xml_parse_test: Call cleanup_dominfo before exiting In-Reply-To: <1378469396-31284-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378469396-31284-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378469396-31284-3-git-send-email-mihajlov@linux.vnet.ibm.com> This avoids misleading valgrind output running xml_parse_test. Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- libxkutil/xml_parse_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libxkutil/xml_parse_test.c b/libxkutil/xml_parse_test.c index af5e508..374bcf6 100644 --- a/libxkutil/xml_parse_test.c +++ b/libxkutil/xml_parse_test.c @@ -521,6 +521,8 @@ int main(int argc, char **argv) return 4; } + cleanup_dominfo(&dominfo); + return 0; } -- 1.7.9.5 From jferlan at redhat.com Fri Sep 6 13:46:18 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 6 Sep 2013 09:46:18 -0400 Subject: [Libvirt-cim] [PATCH] REDSAP: Fix double exception possibilty Message-ID: <1378475178-27179-1-git-send-email-jferlan@redhat.com> Test failed with the following: -------------------------------------------------------------------- KVMRedirectionSAP - 01_enum_KVMredSAP.py: FAIL ERROR - Failed to enumerate the class of KVM_KVMRedirectionSAP ERROR - Exception details: Got more than one record for: test_kvmredsap_dom ERROR - Exception details: 'ElementName' Value Mismatch, Expected 5988:-1, Got 5988:0 ERROR - Exception: Failed to verify information for the defined dom:test_kvmredsap_dom -------------------------------------------------------------------- There are two exceptions listed because the 'enum_redsap()' method was perusing a list, finding a match, declaring success, and continuing to peruse the list. Then found another match declared an exception and returned with status = PASS. The caller just checked the status before continuing. This patch doesn't resolve the underlying cause, but does avoid the call to 'verify_redsap_values()' which will also fail... --- NOTE: I was able to reproduce the initial exception if I run this test very quickly two times in succession. I debated adding a 'sleep(5)' (or similar) prior to the end of the test to ensure whatever teardown was not occurring in a timely manner (by the networking code) could happen, but I believe that wouldn't necessarily fix the problem - just make it less likely to happen. The resource in question is a specific port in the underlying VNC technology. That code may have built in 'safeguards' to help with throttling, e.g. reuse a recently used port thus make it unreliable for the test to rely on getting the "first" port. Since the test isn't designed to run twice in a row, I don't think it's a real issue... .../libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/suites/libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py b/suites/libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py index 6001405..af9b5c6 100644 --- a/suites/libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py +++ b/suites/libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py @@ -50,7 +50,7 @@ test_dom = 'test_kvmredsap_dom' def enum_redsap(server, virt, classname): redsap_insts = { } - status = FAIL + status = PASS try: redsap_list = EnumInstances(server, classname) @@ -58,11 +58,11 @@ def enum_redsap(server, virt, classname): if redsap.SystemName == test_dom: if redsap.Classname not in redsap_insts.keys(): redsap_insts[redsap.Classname] = redsap - status = PASS else: raise Exception("Got more than one record for: %s" \ % test_dom) except Exception, details: + status = FAIL logger.error(CIM_ERROR_ENUMERATE, classname) logger.error("Exception details: %s", details) @@ -139,7 +139,7 @@ def main(): raise Exception("Failed to verify information for the defined "\ "dom:%s" % test_dom) - # For now verifying KVMRedirectoinSAP only for a defined LXC guest. + # For now verifying KVMRedirectionSAP only for a defined LXC guest. # Once complete Graphics support for LXC is in, we need to verify the # KVMRedirectionSAP for a running guest. if virt == 'LXC': @@ -150,10 +150,10 @@ def main(): status = vsxml.cim_start(server) if not ret: raise Exception("Failed to start the dom: %s" % test_dom) + action_start = True status, redsap_inst = enum_redsap(server, virt, classname) if status != PASS: - action_start = True raise Exception("Failed to get information for running dom:%s" \ % test_dom) @@ -162,7 +162,6 @@ def main(): status = verify_redsap_values(val_list, redsap_inst, classname) if status != PASS: - action_start = True raise Exception("Failed to verify information for running dom:%s" \ % test_dom) -- 1.8.3.1 From jferlan at redhat.com Fri Sep 6 14:02:51 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 06 Sep 2013 10:02:51 -0400 Subject: [Libvirt-cim] [PATCH] build: Don't use /bin/sh unconditionally In-Reply-To: <1377864740-28778-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1377864740-28778-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <5229E08B.4040608@redhat.com> On 08/30/2013 08:12 AM, Viktor Mihajlovski wrote: > provider-register.sh implicitly assumes that the shell has bash-like > capabilities. On systems like Ubuntu this is not the case leading > to a make postinstall failure when used with Pegasus. > Changing the script shebang to /bin/bash to make this explicit. > Further replace occurrences of sh to $(SHELL) in the Makefile > invocations of provider-register.sh. > > Signed-off-by: Viktor Mihajlovski > --- > > May not be relevant as libvirt-cim/pegasus isn't part of Debian-ish distros > as far as I am aware of. But it is a constant source of annoyance... > > Makefile.am | 18 +++++++++--------- > provider-register.sh | 2 +- > 2 files changed, 10 insertions(+), 10 deletions(-) > FYI: Pushed John From jferlan at redhat.com Fri Sep 6 14:29:46 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 06 Sep 2013 10:29:46 -0400 Subject: [Libvirt-cim] [PATCH 0/2] Make cimtest more s390-friendly In-Reply-To: <1378391140-21815-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378391140-21815-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <5229E6DA.4030809@redhat.com> On 09/05/2013 10:25 AM, Viktor Mihajlovski wrote: > cimtest currently doesn't work too well on s390 systems, > the two main areas of failure are the attempt to > define systems with IDE hard drivers and VGA graphics, > both not supported on this host type. > > Changing from IDE to virtio disks fixed a lot of the > test FAILs with no adverse impacts to the x86 runs > on our systems at least. It would be nice if somebody > could verify this. > > Further, we do not add the graphics RASD to the default > guest definition if the hypervisor host is an s390 > system. In principle, we could have removed the graphics > RASD altogether, because libvirt-cim will define a > default graphics device for x86 but since it is only a > small change, it seems safer to do it this way. > > Thilo Boehm (1): > cimtest: Use vda instead of hda for disk RASDs > > Viktor Mihajlovski (1): > cimtest: Don't generate graphics for s390 > > .../cimtest/ElementAllocatedFromPool/01_forward.py | 2 +- > .../cimtest/ElementAllocatedFromPool/02_reverse.py | 2 +- > .../ElementAllocatedFromPool/03_reverse_errs.py | 2 +- > .../ElementAllocatedFromPool/04_forward_errs.py | 2 +- > .../cimtest/HostedAccessPoint/01_forward.py | 2 +- > .../cimtest/HostedAccessPoint/02_reverse.py | 2 +- > .../02_guest_add_mod_rem_rasd_ind.py | 2 +- > .../cimtest/ServiceAccessBySAP/01_forward.py | 2 +- > .../cimtest/ServiceAccessBySAP/02_reverse.py | 2 +- > .../cimtest/SettingsDefine/01_forward.py | 2 +- > .../cimtest/SettingsDefine/02_reverse.py | 2 +- > .../cimtest/SettingsDefine/03_sds_fwd_errs.py | 2 +- > .../cimtest/SettingsDefine/04_sds_rev_errs.py | 2 +- > .../libvirt-cim/cimtest/SystemDevice/01_forward.py | 2 +- > .../libvirt-cim/cimtest/SystemDevice/03_fwderrs.py | 2 +- > suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py | 2 +- > .../13_refconfig_additional_devs.py | 2 +- > .../14_define_sys_disk.py | 2 +- > .../30_dynamic_disk_mod.py | 2 +- > .../02_reverse.py | 2 +- > .../03_vssdc_fwd_errs.py | 2 +- > suites/libvirt-cim/lib/XenKvmLib/const.py | 2 +- > suites/libvirt-cim/lib/XenKvmLib/vsms.py | 2 +- > suites/libvirt-cim/lib/XenKvmLib/vxml.py | 5 +++-- > suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py | 7 +++++++ > 25 files changed, 33 insertions(+), 25 deletions(-) > I ran this on my Fedora19 environment without issues - seems reasonable to me. Hopefully others can 'git am' the changes and run/test as well. I'd venture to guess that the defaults these tests have chosen haven't been changed in quite a while and could use a few adjustments here and there to account for more recent changes... ACK, John From mihajlov at linux.vnet.ibm.com Mon Sep 9 11:12:52 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Mon, 09 Sep 2013 13:12:52 +0200 Subject: [Libvirt-cim] [PATCH] REDSAP: Fix double exception possibilty In-Reply-To: <1378475178-27179-1-git-send-email-jferlan@redhat.com> References: <1378475178-27179-1-git-send-email-jferlan@redhat.com> Message-ID: <522DAD34.1010000@linux.vnet.ibm.com> On 09/06/2013 03:46 PM, John Ferlan wrote: > Test failed with the following: > > -------------------------------------------------------------------- > KVMRedirectionSAP - 01_enum_KVMredSAP.py: FAIL > ERROR - Failed to enumerate the class of KVM_KVMRedirectionSAP > ERROR - Exception details: Got more than one record for: test_kvmredsap_dom > ERROR - Exception details: 'ElementName' Value Mismatch, Expected 5988:-1, Got 5988:0 > ERROR - Exception: Failed to verify information for the defined dom:test_kvmredsap_dom > -------------------------------------------------------------------- > > There are two exceptions listed because the 'enum_redsap()' method was > perusing a list, finding a match, declaring success, and continuing to > peruse the list. Then found another match declared an exception and returned > with status = PASS. > > The caller just checked the status before continuing. > > This patch doesn't resolve the underlying cause, but does avoid the call to > 'verify_redsap_values()' which will also fail... > --- > > NOTE: I was able to reproduce the initial exception if I run this test > very quickly two times in succession. I debated adding a 'sleep(5)' (or > similar) prior to the end of the test to ensure whatever teardown was > not occurring in a timely manner (by the networking code) could happen, > but I believe that wouldn't necessarily fix the problem - just make it > less likely to happen. The resource in question is a specific port in the > underlying VNC technology. That code may have built in 'safeguards' to help > with throttling, e.g. reuse a recently used port thus make it unreliable for > the test to rely on getting the "first" port. Since the test isn't designed > to run twice in a row, I don't think it's a real issue... > > .../libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > The patch fixes the previously incorrect error handling, so I would suggest to push it anyway. The failure doesn't seem to happen because of a lingering socket but rather becasue the guest wasn't destroyed and/or undefined (returned port is 0). Did this failure ever reoccur *after* you have applied your change? -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Mon Sep 9 12:46:56 2013 From: jferlan at redhat.com (John Ferlan) Date: Mon, 09 Sep 2013 08:46:56 -0400 Subject: [Libvirt-cim] [PATCH] REDSAP: Fix double exception possibilty In-Reply-To: <522DAD34.1010000@linux.vnet.ibm.com> References: <1378475178-27179-1-git-send-email-jferlan@redhat.com> <522DAD34.1010000@linux.vnet.ibm.com> Message-ID: <522DC340.6070508@redhat.com> On 09/09/2013 07:12 AM, Viktor Mihajlovski wrote: > On 09/06/2013 03:46 PM, John Ferlan wrote: >> Test failed with the following: >> >> -------------------------------------------------------------------- >> KVMRedirectionSAP - 01_enum_KVMredSAP.py: FAIL >> ERROR - Failed to enumerate the class of KVM_KVMRedirectionSAP >> ERROR - Exception details: Got more than one record for: >> test_kvmredsap_dom >> ERROR - Exception details: 'ElementName' Value Mismatch, >> Expected 5988:-1, Got 5988:0 >> ERROR - Exception: Failed to verify information for the >> defined dom:test_kvmredsap_dom >> -------------------------------------------------------------------- >> >> There are two exceptions listed because the 'enum_redsap()' method was >> perusing a list, finding a match, declaring success, and continuing to >> peruse the list. Then found another match declared an exception and >> returned >> with status = PASS. >> >> The caller just checked the status before continuing. >> >> This patch doesn't resolve the underlying cause, but does avoid the >> call to >> 'verify_redsap_values()' which will also fail... >> --- >> >> NOTE: I was able to reproduce the initial exception if I run this test >> very quickly two times in succession. I debated adding a 'sleep(5)' (or >> similar) prior to the end of the test to ensure whatever teardown was >> not occurring in a timely manner (by the networking code) could happen, >> but I believe that wouldn't necessarily fix the problem - just make it >> less likely to happen. The resource in question is a specific port in the >> underlying VNC technology. That code may have built in 'safeguards' to >> help >> with throttling, e.g. reuse a recently used port thus make it >> unreliable for >> the test to rely on getting the "first" port. Since the test isn't >> designed >> to run twice in a row, I don't think it's a real issue... >> >> .../libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py | 9 >> ++++----- >> 1 file changed, 4 insertions(+), 5 deletions(-) >> > The patch fixes the previously incorrect error handling, so I would > suggest to push it anyway. > The failure doesn't seem to happen because of a lingering socket but > rather becasue the guest wasn't destroyed and/or undefined (returned > port is 0). Did this failure ever reoccur *after* you have applied your > change? > > Yes - unfortunately. Although not very repeatable. Sometimes running twice in a row works and sometimes it doesn't. Chasing after those kind of timing problems is never easy. When I worked my way through the API's, I ended up in the VNC port allocation routines - I think get_vnc_sessions() - but I was never quite sure exactly where the fault was and chasing it seemed to be a too time consuming task. John From mihajlov at linux.vnet.ibm.com Mon Sep 9 13:55:31 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Mon, 09 Sep 2013 15:55:31 +0200 Subject: [Libvirt-cim] [PATCH] REDSAP: Fix double exception possibilty In-Reply-To: <522DC340.6070508@redhat.com> References: <1378475178-27179-1-git-send-email-jferlan@redhat.com> <522DAD34.1010000@linux.vnet.ibm.com> <522DC340.6070508@redhat.com> Message-ID: <522DD353.2040300@linux.vnet.ibm.com> On 09/09/2013 02:46 PM, John Ferlan wrote: >> > > Yes - unfortunately. Although not very repeatable. Sometimes running > twice in a row works and sometimes it doesn't. Chasing after those > kind of timing problems is never easy. When I worked my way through the > API's, I ended up in the VNC port allocation routines - I think > get_vnc_sessions() - but I was never quite sure exactly where the fault > was and chasing it seemed to be a too time consuming task. > it still looks to me as if there was a "dangling" running domain. This here looks suspicious ... status = vsxml.cim_start(server) if not ret: raise Exception("Failed to start the dom: %s" % test_dom) and looks as if could trigger a false error condition, resulting in an undestroyed test doamain, should probably be ret = vsxml.cim_start(server) -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Mon Sep 9 14:02:08 2013 From: jferlan at redhat.com (John Ferlan) Date: Mon, 09 Sep 2013 10:02:08 -0400 Subject: [Libvirt-cim] [PATCH 0/8] Support for full function consoles In-Reply-To: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <522DD4E0.5030401@redhat.com> On 09/05/2013 11:36 AM, Viktor Mihajlovski wrote: > Motivation: the current libvirt-cim support for consoles is > very limited in that it doesn't allow to specify the target > and source types supported by libvirt. Having full support > of the libvirt console feature is however mandatory for > architectures like s390. > > The current implementation using a Graphics_RASD to represent > consoles cannot easily be extended without breaking the existing > implementation (or without being entirely unusable). > > Therefore a new RASD class is added to represent consoles in > the model. Since there's no SVPC resource type for a console > we use the combination of ResourceType = 1 (Other) and > OtherResourceType = "console" for the new RASD instances. > > In order to be backward compatible, the only console type supported > by older libvirt-cim versions (target type 'pty') will still > be returned as Graphics_RASD. In the long run, this should be > deprecated. > > Thilo Boehm (6): > schema: Add CIM_ResourceAllocationSettingData for console resources > schema: New SVPC types for chardev/consoles > libxkutil: Console Support > RASD: Provider Support for Console RASDs > VSMS: Support for domains with console devices > VSMS: add default console > > Viktor Mihajlovski (2): > VSMS: Set resource types for default devices > Device: CIM_LogicalDevice for consoles > > libxkutil/device_parsing.c | 316 ++++++++++++++++++- > libxkutil/device_parsing.h | 43 ++- > libxkutil/xmlgen.c | 191 +++++++++++- > schema/ResourceAllocationSettingData.mof | 247 ++++++++++++++- > schema/ResourceAllocationSettingData.registration | 5 +- > src/Virt_Device.c | 33 ++ > src/Virt_RASD.c | 148 ++++++++- > src/Virt_VirtualSystemManagementService.c | 336 +++++++++++++++++++-- > src/svpc_types.h | 102 ++++++- > 9 files changed, 1384 insertions(+), 37 deletions(-) > Not quite sure where it is, but there is a bug somewhere in patches 2->5 as the cimtest 'RASD' for '03_rasd_errs.py' fails to find/add the console device. The error message is "Expected 7 RASDs, got 6". I also think there's an ordering problem. If I add the patches 1 at a time, patch #2 will cause the same cimtest to return 0 (zero) RASD's (as found through debugging the cimtest test) if patches 3 and 4 are applied. I decided to try an experiment to see if I could narrow things down. The experiment was add each patch 1 at a time, then add patch 2 to the set. 1,3 -> Returns found 6, then add patch 2 and returns found 0 RASD's 1,3,4 -> Returns found 6, then add patch 2 and returns found 0 RASD's 1,3,4,5 -> Returns found 6, then add patch 2 and returns expected 7 found 6 At the very least patch 2 needs to go after patch 5 or be merged with patch 5 since it seems that's where the connection/implementation occurs. I didn't dig deep into that test to try and figure out why the console device was "missing". John From jferlan at redhat.com Mon Sep 9 14:04:49 2013 From: jferlan at redhat.com (John Ferlan) Date: Mon, 09 Sep 2013 10:04:49 -0400 Subject: [Libvirt-cim] [PATCH] REDSAP: Fix double exception possibilty In-Reply-To: <522DD353.2040300@linux.vnet.ibm.com> References: <1378475178-27179-1-git-send-email-jferlan@redhat.com> <522DAD34.1010000@linux.vnet.ibm.com> <522DC340.6070508@redhat.com> <522DD353.2040300@linux.vnet.ibm.com> Message-ID: <522DD581.3010809@redhat.com> On 09/09/2013 09:55 AM, Viktor Mihajlovski wrote: > On 09/09/2013 02:46 PM, John Ferlan wrote: >>> >> >> Yes - unfortunately. Although not very repeatable. Sometimes running >> twice in a row works and sometimes it doesn't. Chasing after those >> kind of timing problems is never easy. When I worked my way through the >> API's, I ended up in the VNC port allocation routines - I think >> get_vnc_sessions() - but I was never quite sure exactly where the fault >> was and chasing it seemed to be a too time consuming task. >> > it still looks to me as if there was a "dangling" running domain. This here > looks suspicious ... > > status = vsxml.cim_start(server) > if not ret: > raise Exception("Failed to start the dom: %s" % test_dom) > > and looks as if could trigger a false error condition, resulting in an > undestroyed test doamain, should probably be > > ret = vsxml.cim_start(server) > > > Yep - that's what I first saw... I just happened to try a bit of "extended testing" and tripped across the anomoly that I saw. John From mihajlov at linux.vnet.ibm.com Tue Sep 10 09:35:01 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Tue, 10 Sep 2013 11:35:01 +0200 Subject: [Libvirt-cim] [PATCH 0/8] Support for full function consoles In-Reply-To: <522DD4E0.5030401@redhat.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <522DD4E0.5030401@redhat.com> Message-ID: <522EE7C5.6040808@linux.vnet.ibm.com> On 09/09/2013 04:02 PM, John Ferlan wrote: > > Not quite sure where it is, but there is a bug somewhere in patches > 2->5 as the cimtest 'RASD' for '03_rasd_errs.py' fails to find/add > the console device. The error message is "Expected 7 RASDs, got 6". > > I also think there's an ordering problem. If I add the patches 1 > at a time, patch #2 will cause the same cimtest to return 0 (zero) > RASD's (as found through debugging the cimtest test) if patches > 3 and 4 are applied. > > I decided to try an experiment to see if I could narrow things down. > The experiment was add each patch 1 at a time, then add patch 2 to the > set. > > 1,3 -> Returns found 6, then add patch 2 and returns found 0 RASD's > 1,3,4 -> Returns found 6, then add patch 2 and returns found 0 RASD's > 1,3,4,5 -> Returns found 6, then add patch 2 and returns expected 7 found 6 > > At the very least patch 2 needs to go after patch 5 or be merged with > patch 5 since it seems that's where the connection/implementation occurs. > > I didn't dig deep into that test to try and figure out why the console > device was "missing". > Strange, I have not seen this 6/7 message. This means that the test domain has less RASD types than RASD types found on the system. Can it be that you have some domain already defined before you run cimtest? This might explain the behavior (but would be a bug in cimtest). As for the patch grouping, it was meant to make the patches more readable rather than to be technically necessary. In fact, the provider patches (5,6,7) and the MOF/schemal patch (2) must go together. I can squash them in a V2, but this could in my opinion wait until I get more feedback. Could you do me a favor and apply this here, rerun the RASD test group and paste the resulting cimtest.log from the RASD directory? Thanks! -- diff --git a/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py b/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py index d582ffb..024b0ae 100644 --- a/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py +++ b/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py @@ -68,9 +68,11 @@ def init_rasd_list(virt, ip, guest_name): logger.error("Unable to parse InstanceID: %s" % rasd.InstanceID) return rasd_insts, FAIL + logger.info("RASD found %s for %s", rasd.Classname, guest) if guest == guest_name: rasd_insts[rasd.Classname] = rasd - + + logger.info("Expected %d RASDs, got %d", len(rasds), len(rasd_insts)) if len(rasds) != len(rasd_insts): logger.error("Expected %d RASDs, got %d", len(rasds), len(rasd_insts)) return rasd_insts, FAIL Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Tue Sep 10 16:02:07 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 10 Sep 2013 12:02:07 -0400 Subject: [Libvirt-cim] [PATCH 0/8] Support for full function consoles In-Reply-To: <522EE7C5.6040808@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <522DD4E0.5030401@redhat.com> <522EE7C5.6040808@linux.vnet.ibm.com> Message-ID: <522F427F.2070903@redhat.com> On 09/10/2013 05:35 AM, Viktor Mihajlovski wrote: > On 09/09/2013 04:02 PM, John Ferlan wrote: <... snip ...> > Strange, I have not seen this 6/7 message. This means that the test > domain has less RASD types than RASD types found on the system. > Can it be that you have some domain already defined before you run > cimtest? This might explain the behavior (but would be a bug in > cimtest). Sure I have other domains defined already on the test system, one of them is running. It's strange that the only domain to not get a console rasd is the test domain. I did find a bug in the 03*.py code - if there's an error from init_rasd_list, the code returns without undefining the domain. The fix would be: rasds, status = init_rasd_list(virt, options.ip, test_dom) if status != PASS: logger.error("Unable to build rasd instance list") + vsxml.undefine(server) return status But doing that still does not resolve the problem. > > As for the patch grouping, it was meant to make the patches more > readable rather than to be technically necessary. In fact, the provider > patches (5,6,7) and the MOF/schemal patch (2) must go together. > I can squash them in a V2, but this could in my opinion wait until > I get more feedback. That's fine - just want to make sure that at each stage of patch application that we have functioning code. Makes the git bisect much easier when/if there are problems... > > Could you do me a favor and apply this here, rerun the RASD test group > and paste the resulting cimtest.log from the RASD directory? Thanks! > For whatever reason logger.info didn't spit out the messages, so I changed using to logger.error... I also added a printing of rasds and rasds_inst -------------------------------------------------------------------- RASD - 03_rasd_errs.py: FAIL ERROR - RASD found KVM_InputResourceAllocationSettingData for if18lcl ERROR - RASD found KVM_InputResourceAllocationSettingData for if18lcl ERROR - RASD found KVM_InputResourceAllocationSettingData for VSSDC_dom ERROR - RASD found KVM_InputResourceAllocationSettingData for rh70-alpha3 ERROR - RASD found KVM_InputResourceAllocationSettingData for rh70-alpha3 ERROR - RASD found KVM_InputResourceAllocationSettingData for if18net ERROR - RASD found KVM_InputResourceAllocationSettingData for rh64 ERROR - RASD found KVM_InputResourceAllocationSettingData for rh64 ERROR - RASD found KVM_InputResourceAllocationSettingData for if18nopool ERROR - RASD found KVM_InputResourceAllocationSettingData for if18nopool ERROR - RASD found KVM_InputResourceAllocationSettingData for f18 ERROR - RASD found KVM_InputResourceAllocationSettingData for f18 ERROR - RASD found KVM_ProcResourceAllocationSettingData for if18lcl ERROR - RASD found KVM_ProcResourceAllocationSettingData for VSSDC_dom ERROR - RASD found KVM_ProcResourceAllocationSettingData for rhel65-f18 ERROR - RASD found KVM_ProcResourceAllocationSettingData for rh70-alpha3 ERROR - RASD found KVM_ProcResourceAllocationSettingData for if18net ERROR - RASD found KVM_ProcResourceAllocationSettingData for rh64 ERROR - RASD found KVM_ProcResourceAllocationSettingData for if18nopool ERROR - RASD found KVM_ProcResourceAllocationSettingData for f18 ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for if18lcl ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for rhel65-f18 ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for rh70-alpha3 ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for if18net ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for rh64 ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for if18nopool ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for f18 ERROR - RASD found KVM_DiskResourceAllocationSettingData for if18lcl ERROR - RASD found KVM_DiskResourceAllocationSettingData for VSSDC_dom ERROR - RASD found KVM_DiskResourceAllocationSettingData for rhel65-f18 ERROR - RASD found KVM_DiskResourceAllocationSettingData for rhel65-f18 ERROR - RASD found KVM_DiskResourceAllocationSettingData for rh70-alpha3 ERROR - RASD found KVM_DiskResourceAllocationSettingData for if18net ERROR - RASD found KVM_DiskResourceAllocationSettingData for rh64 ERROR - RASD found KVM_DiskResourceAllocationSettingData for f18 ERROR - RASD found KVM_DiskResourceAllocationSettingData for f18 ERROR - RASD found KVM_MemResourceAllocationSettingData for if18lcl ERROR - RASD found KVM_MemResourceAllocationSettingData for VSSDC_dom ERROR - RASD found KVM_MemResourceAllocationSettingData for rhel65-f18 ERROR - RASD found KVM_MemResourceAllocationSettingData for rh70-alpha3 ERROR - RASD found KVM_MemResourceAllocationSettingData for if18net ERROR - RASD found KVM_MemResourceAllocationSettingData for rh64 ERROR - RASD found KVM_MemResourceAllocationSettingData for if18nopool ERROR - RASD found KVM_MemResourceAllocationSettingData for f18 ERROR - RASD found KVM_NetResourceAllocationSettingData for if18lcl ERROR - RASD found KVM_NetResourceAllocationSettingData for VSSDC_dom ERROR - RASD found KVM_NetResourceAllocationSettingData for rhel65-f18 ERROR - RASD found KVM_NetResourceAllocationSettingData for rh70-alpha3 ERROR - RASD found KVM_NetResourceAllocationSettingData for if18net ERROR - RASD found KVM_NetResourceAllocationSettingData for rh64 ERROR - RASD found KVM_NetResourceAllocationSettingData for if18nopool ERROR - RASD found KVM_NetResourceAllocationSettingData for f18 ERROR - RASD found KVM_GraphicsResourceAllocationSettingData for if18lcl ERROR - RASD found KVM_GraphicsResourceAllocationSettingData for if18lcl ERROR - RASD found KVM_GraphicsResourceAllocationSettingData for VSSDC_dom ERROR - RASD found KVM_GraphicsResourceAllocationSettingData for rhel65-f18 ERROR - RASD found KVM_GraphicsResourceAllocationSettingData for rh70-alpha3 ERROR - RASD found KVM_GraphicsResourceAllocationSettingData for rh70-alpha3 ERROR - RASD found KVM_GraphicsResourceAllocationSettingData for if18net ERROR - RASD found KVM_GraphicsResourceAllocationSettingData for if18net ERROR - RASD found KVM_GraphicsResourceAllocationSettingData for rh64 ERROR - RASD found KVM_GraphicsResourceAllocationSettingData for rh64 ERROR - RASD found KVM_GraphicsResourceAllocationSettingData for if18nopool ERROR - RASD found KVM_GraphicsResourceAllocationSettingData for if18nopool ERROR - RASD found KVM_GraphicsResourceAllocationSettingData for f18 ERROR - expected 7 RASDs, got 6 ERROR - Expected 7 RASDs, got 6 ERROR - Unable to build rasd instance list rasds has: KVM_InputResourceAllocationSettingData KVM_ProcResourceAllocationSettingData KVM_ConsoleResourceAllocationSettingData KVM_DiskResourceAllocationSettingData KVM_MemResourceAllocationSettingData KVM_NetResourceAllocationSettingData KVM_GraphicsResourceAllocationSettingData rasd_insts has: KVM_DiskResourceAllocationSettingData KVM_ProcResourceAllocationSettingData KVM_MemResourceAllocationSettingData KVM_NetResourceAllocationSettingData KVM_InputResourceAllocationSettingData KVM_GraphicsResourceAllocationSettingData -------------------------------------------------------------------- From mihajlov at linux.vnet.ibm.com Tue Sep 10 16:21:45 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Tue, 10 Sep 2013 18:21:45 +0200 Subject: [Libvirt-cim] [PATCH 0/8] Support for full function consoles In-Reply-To: <522F427F.2070903@redhat.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <522DD4E0.5030401@redhat.com> <522EE7C5.6040808@linux.vnet.ibm.com> <522F427F.2070903@redhat.com> Message-ID: <522F4719.2090005@linux.vnet.ibm.com> On 09/10/2013 06:02 PM, John Ferlan wrote: >> cimtest). > > Sure I have other domains defined already on the test system, one of > them is running. It's strange that the only domain to not get a console > rasd is the test domain. that's actually to be expected, since the testsuite doesn't yet contain support for test domains with a console, I am currently testing a patch that will change this > > I did find a bug in the 03*.py code - if there's an error from > init_rasd_list, the code returns without undefining the domain. > The fix would be: > > rasds, status = init_rasd_list(virt, options.ip, test_dom) > if status != PASS: > logger.error("Unable to build rasd instance list") > + vsxml.undefine(server) > return status > > But doing that still does not resolve the problem. > nice finding, for the rest see below > For whatever reason logger.info didn't spit out the messages, so I changed > using to logger.error... I also added a printing of rasds and rasds_inst logger.info doesn't write to the console, only into suites/libvirt-cim/cimtest/$TESTGROUP/cimtest.log > > > -------------------------------------------------------------------- > RASD - 03_rasd_errs.py: FAIL > ERROR - RASD found KVM_InputResourceAllocationSettingData for if18lcl > ERROR - RASD found KVM_InputResourceAllocationSettingData for if18lcl > ERROR - RASD found KVM_InputResourceAllocationSettingData for VSSDC_dom > ERROR - RASD found KVM_InputResourceAllocationSettingData for rh70-alpha3 > ERROR - RASD found KVM_InputResourceAllocationSettingData for rh70-alpha3 > ERROR - RASD found KVM_InputResourceAllocationSettingData for if18net > ERROR - RASD found KVM_InputResourceAllocationSettingData for rh64 > ERROR - RASD found KVM_InputResourceAllocationSettingData for rh64 > ERROR - RASD found KVM_InputResourceAllocationSettingData for if18nopool > ERROR - RASD found KVM_InputResourceAllocationSettingData for if18nopool > ERROR - RASD found KVM_InputResourceAllocationSettingData for f18 > ERROR - RASD found KVM_InputResourceAllocationSettingData for f18 > ERROR - RASD found KVM_ProcResourceAllocationSettingData for if18lcl > ERROR - RASD found KVM_ProcResourceAllocationSettingData for VSSDC_dom > ERROR - RASD found KVM_ProcResourceAllocationSettingData for rhel65-f18 > ERROR - RASD found KVM_ProcResourceAllocationSettingData for rh70-alpha3 > ERROR - RASD found KVM_ProcResourceAllocationSettingData for if18net > ERROR - RASD found KVM_ProcResourceAllocationSettingData for rh64 > ERROR - RASD found KVM_ProcResourceAllocationSettingData for if18nopool > ERROR - RASD found KVM_ProcResourceAllocationSettingData for f18 > ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for if18lcl > ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for rhel65-f18 > ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for rh70-alpha3 > ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for if18net > ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for rh64 > ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for if18nopool > ERROR - RASD found KVM_ConsoleResourceAllocationSettingData for f18 the domains above do have a serial or console definition and therefore show up in the first RASD enumeration ... as I have pointed out before, the VSSC_dom is plainly defined without a console by the testsuite, so it is perfectly correct for it not to show up above. Which means that the 03_xxx testcase is broken, as it should check whether the domain has the RASDs that are to be expected instead of a RASD of each type discovered on the system. Will try to fix this as well in the cimtest patch I'm working on -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Tue Sep 10 19:44:59 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 10 Sep 2013 15:44:59 -0400 Subject: [Libvirt-cim] [PATCH 0/8] Support for full function consoles In-Reply-To: <522F4719.2090005@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <522DD4E0.5030401@redhat.com> <522EE7C5.6040808@linux.vnet.ibm.com> <522F427F.2070903@redhat.com> <522F4719.2090005@linux.vnet.ibm.com> Message-ID: <522F76BB.4090401@redhat.com> On 09/10/2013 12:21 PM, Viktor Mihajlovski wrote: > as I have pointed out before, the VSSC_dom > is plainly defined without a console by the testsuite, so it is perfectly correct > for it not to show up above. > Which means that the 03_xxx testcase is broken, as it should check whether the > domain has the RASDs that are to be expected instead of a RASD of each type > discovered on the system. Will try to fix this as well in the cimtest patch > I'm working on > So essentially the following test is completely bogus as it's not testing anything other than a domain having all types of available RASDs in the environment: if len(rasds) != len(rasd_insts): logger.error("Expected %d RASDs, got %d", len(rasds), len(rasd_insts)) return rasd_insts, FAIL If anything what it should be doing is if (len(rasds_insts == 0): logger.error("Found 0 RASDs for %s", guest_name) return rasd_insts, FAIL Not quite sure how one would determine how many are expected though without knowing a bit more about the definition of the guest. John From jferlan at redhat.com Tue Sep 10 19:46:50 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 10 Sep 2013 15:46:50 -0400 Subject: [Libvirt-cim] [PATCH 1/8] VSMS: Set resource types for default devices In-Reply-To: <1378395402-9422-2-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378395402-9422-2-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <522F772A.7030600@redhat.com> On 09/05/2013 11:36 AM, Viktor Mihajlovski wrote: > The default graphics and input devices were built without their > resource types being set correctly. This has not hurted yet. > Future changes will however require that the device resource > type is matching the actual device type. > > Signed-off-by: Viktor Mihajlovski > Reviewed-by: Boris Fiuczynski > --- > src/Virt_VirtualSystemManagementService.c | 2 ++ > 1 file changed, 2 insertions(+) > ACK John From jferlan at redhat.com Tue Sep 10 19:51:10 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 10 Sep 2013 15:51:10 -0400 Subject: [Libvirt-cim] [PATCH 2/8] schema: Add CIM_ResourceAllocationSettingData for console resources In-Reply-To: <1378395402-9422-3-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378395402-9422-3-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <522F782E.1010405@redhat.com> On 09/05/2013 11:36 AM, Viktor Mihajlovski wrote: > From: Thilo Boehm > > Representing console devices was very limited with the previous > approach using a special graphical display. For instance it > was not possible to define different target types (serial, virtio, > sclp) nor to exploit all source types (pty, file, tcp, ...) > available in libvirt. > > With the following new RASD classes it is possible to define > real console resources: > KVM_ConsoleResouceAllocationSettingData > Xen_ConsoleResouceAllocationSettingData > LXC_ConsoleResouceAllocationSettingData > > Signed-off-by: Thilo Boehm > Signed-off-by: Viktor Mihajlovski > Reviewed-by: Boris Fiuczynski > --- > schema/ResourceAllocationSettingData.mof | 247 ++++++++++++++++++++- > schema/ResourceAllocationSettingData.registration | 5 +- > 2 files changed, 250 insertions(+), 2 deletions(-) > ACK, but I will squash this with patch 5 when I push - I also will remove an empty line at the end of the .mof file as 'git am' complained. Cranky tools! John From jferlan at redhat.com Tue Sep 10 20:16:51 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 10 Sep 2013 16:16:51 -0400 Subject: [Libvirt-cim] [PATCH 3/8] schema: New SVPC types for chardev/consoles In-Reply-To: <1378395402-9422-4-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378395402-9422-4-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <522F7E33.1040907@redhat.com> On 09/05/2013 11:36 AM, Viktor Mihajlovski wrote: > From: Thilo Boehm > > C definitions for the console source types, defining the representation > of the consoles in the hypervisor host. Includes mapping from and to > string representations. > > Signed-off-by: Thilo Boehm > Signed-off-by: Viktor Mihajlovski > Reviewed-by: Boris Fiuczynski > --- > src/svpc_types.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 96 insertions(+), 1 deletion(-) > ACK John From jferlan at redhat.com Tue Sep 10 21:11:54 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 10 Sep 2013 17:11:54 -0400 Subject: [Libvirt-cim] [PATCH 5/8] RASD: Provider Support for Console RASDs In-Reply-To: <1378395402-9422-6-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378395402-9422-6-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <522F8B1A.206@redhat.com> On 09/05/2013 11:36 AM, Viktor Mihajlovski wrote: > From: Thilo Boehm > > Instance support for console RASDs. > > The ResourceType of the returned instances is is '1' (Other) and the > OtherResourceType is 'console'. > > Implemented CIM operations: > enumerate instances > enumerate instance names > get instance > > Signed-off-by: Thilo Boehm > Signed-off-by: Viktor Mihajlovski > Reviewed-by: Boris Fiuczynski > --- > src/Virt_RASD.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 147 insertions(+), 1 deletion(-) > > diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c > index 150ccd3..7d72831 100644 > --- a/src/Virt_RASD.c > +++ b/src/Virt_RASD.c > @@ -1,5 +1,5 @@ > /* > - * Copyright IBM Corp. 2007 > + * Copyright IBM Corp. 2007, 2013 > * > * Authors: > * Dan Smith > @@ -662,6 +662,142 @@ static CMPIStatus set_graphics_rasd_params(const struct virt_device *dev, > return s; > } > > +static char* _build_console_url(const char *protocol, > + const char *host, > + const char *port) > +{ > + char* result = NULL; > + > + if (NULL == host) > + goto out; > + > + if (STREQC("file", protocol)) { > + /* The host string contains the file name. > + Even if the file name does not start with a '/' > + it is treated by libvirt as a full qualified path. > + */ > + if ('/' == host[0]) { > + if (asprintf(&result, "file://%s", host) < 0) > + result = NULL; > + goto out; > + } else { > + if (asprintf(&result, "file:///%s", host) < 0) > + result = NULL; > + goto out; > + } > + } > + /* The assumption is that the host does not contain a port. > + If the host string contains a ':', > + the host is treated as an IPv6 address. > + */ > + if (NULL == strchr(host, ':')) { > + if (NULL == port) { > + if (asprintf(&result,"%s://%s", protocol, host) < 0) > + result = NULL; > + goto out; > + } else { > + if (asprintf(&result,"%s://%s:%s", protocol, > + host,port) < 0) > + result = NULL; > + goto out; > + } > + } > + out: > + return result; > +} > + > + > +static CMPIStatus set_console_rasd_params(const struct virt_device *vdev, > + CMPIInstance *inst) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + const struct console_device *cdev = NULL; > + char* tmp = NULL; > + > + cdev = &vdev->dev.console; > + > + CMSetProperty(inst, "OtherResourceType", "console", CMPI_chars); > + CMSetProperty(inst, "SourceType", > + (CMPIValue *)&cdev->source_type, CMPI_uint16); > + CMSetProperty(inst, "TargetType", > + (CMPIValue *)cdev->target_type, CMPI_chars); > + Since libxkutil/parse_console_device() didn't do any error checking w/r/t a NULL return on get_attr_value() calls, we could get into a lot of trouble here, but again par for the course in libvirt-cim! > + switch (cdev->source_type) { > + case CIM_CHARDEV_SOURCE_TYPE_PTY: > + CMSetProperty(inst, "SourcePath", > + (CMPIValue *)cdev->source_dev.pty.path, > + CMPI_chars); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_DEV: > + CMSetProperty(inst, "SourcePath", > + (CMPIValue *)cdev->source_dev.dev.path, > + CMPI_chars); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_FILE: > + CMSetProperty(inst, "SourcePath", > + (CMPIValue *)cdev->source_dev.file.path, > + CMPI_chars); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_PIPE: > + CMSetProperty(inst, "SourcePath", > + (CMPIValue *)cdev->source_dev.pipe.path, > + CMPI_chars); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: > + tmp = _build_console_url("file", > + cdev->source_dev.unixsock.path, NULL); > + if (STREQC(cdev->source_dev.unixsock.mode, "bind")) > + CMSetProperty(inst, "BindURL", > + (CMPIValue *)tmp, CMPI_chars); > + > + if (STREQC(cdev->source_dev.unixsock.mode, "connect")) > + CMSetProperty(inst, "ConnectURL", > + (CMPIValue *)tmp, CMPI_chars); > + > + free(tmp); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UDP: > + tmp = _build_console_url("udp", > + cdev->source_dev.udp.bind_host, > + cdev->source_dev.udp.bind_service); Since 'tmp' can be NULL, could there be any negative repercussion in the following? > + CMSetProperty(inst, "BindURL", > + (CMPIValue *)tmp, CMPI_chars); > + free(tmp); > + > + tmp = _build_console_url("udp", > + cdev->source_dev.udp.connect_host, > + cdev->source_dev.udp.connect_service); Same here > + CMSetProperty(inst, "ConnectURL", (CMPIValue *)tmp, CMPI_chars); > + free(tmp); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_TCP: > + tmp = _build_console_url(cdev->source_dev.tcp.protocol, > + cdev->source_dev.tcp.host, > + cdev->source_dev.tcp.service); > + if (STREQC(cdev->source_dev.tcp.mode, "bind")) Again > + CMSetProperty(inst, "BindURL", > + (CMPIValue *)tmp, CMPI_chars); > + > + if (STREQC(cdev->source_dev.tcp.mode, "connect")) Again let me know if there's anything that needs to be done/checked and I can squash it in... John > + CMSetProperty(inst, "ConnectURL", > + (CMPIValue *)tmp, CMPI_chars); > + > + free(tmp); > + break; > + > + default: > + /* Nothing to do for : > + CIM_CHARDEV_SOURCE_TYPE_STDIO > + CIM_CHARDEV_SOURCE_TYPE_NULL > + CIM_CHARDEV_SOURCE_TYPE_VC > + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC > + */ > + break; > + } > + > + return s; > +} > + > static CMPIStatus set_input_rasd_params(const struct virt_device *dev, > CMPIInstance *inst) > { > @@ -721,6 +857,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, > } else if (dev->type == CIM_RES_TYPE_GRAPHICS) { > type = CIM_RES_TYPE_GRAPHICS; > base = "GraphicsResourceAllocationSettingData"; > + } else if (dev->type == CIM_RES_TYPE_CONSOLE) { > + type = CIM_RES_TYPE_OTHER; > + base = "ConsoleResourceAllocationSettingData"; > } else if (dev->type == CIM_RES_TYPE_INPUT) { > type = CIM_RES_TYPE_INPUT; > base = "InputResourceAllocationSettingData"; > @@ -777,6 +916,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, > s = set_graphics_rasd_params(dev, inst, host, CLASSNAME(ref)); > } else if (dev->type == CIM_RES_TYPE_INPUT) { > s = set_input_rasd_params(dev, inst); > + } else if (dev->type == CIM_RES_TYPE_CONSOLE) { > + s = set_console_rasd_params(dev, inst); > } > > /* FIXME: Put the HostResource in place */ > @@ -909,6 +1050,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) > *type = CIM_RES_TYPE_INPUT; > else if (STREQ(base, "StorageVolumeResourceAllocationSettingData")) > *type = CIM_RES_TYPE_IMAGE; > + else if (STREQ(base, "ConsoleResourceAllocationSettingData")) > + *type = CIM_RES_TYPE_CONSOLE; > else > goto out; > > @@ -940,6 +1083,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) > case CIM_RES_TYPE_GRAPHICS: > *classname = "GraphicsResourceAllocationSettingData"; > break; > + case CIM_RES_TYPE_CONSOLE: > + *classname = "ConsoleResourceAllocationSettingData"; > + break; > case CIM_RES_TYPE_INPUT: > *classname = "InputResourceAllocationSettingData"; > break; > From jferlan at redhat.com Tue Sep 10 21:15:16 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 10 Sep 2013 17:15:16 -0400 Subject: [Libvirt-cim] [PATCH 6/8] Device: CIM_LogicalDevice for consoles In-Reply-To: <1378395402-9422-7-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378395402-9422-7-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <522F8BE4.7090600@redhat.com> On 09/05/2013 11:36 AM, Viktor Mihajlovski wrote: > Extended the Virt_Device provider to return DisplayController > devices for the consoles found. This mainly for the purpose of > consistency with the other RASD types. > > Signed-off-by: Viktor Mihajlovski > Reviewed-by: Boris Fiuczynski > --- > src/Virt_Device.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > ACK John From jferlan at redhat.com Tue Sep 10 20:38:27 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 10 Sep 2013 16:38:27 -0400 Subject: [Libvirt-cim] [PATCH 4/8] libxkutil: Console Support In-Reply-To: <1378395402-9422-5-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378395402-9422-5-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <522F8343.301@redhat.com> On 09/05/2013 11:36 AM, Viktor Mihajlovski wrote: > From: Thilo Boehm > > Added data types for the representation of console devices and their > source type specific properties. > Further, implemented libvirt XML parsing and generation of console > device XML. > > Signed-off-by: Thilo Boehm > Signed-off-by: Viktor Mihajlovski > Reviewed-by: Boris Fiuczynski > --- > libxkutil/device_parsing.c | 316 ++++++++++++++++++++++++++++++++++++++++++-- > libxkutil/device_parsing.h | 43 +++++- > libxkutil/xmlgen.c | 191 +++++++++++++++++++++++++- > src/svpc_types.h | 5 +- > 4 files changed, 543 insertions(+), 12 deletions(-) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index fa9f998..06acbac 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -1,5 +1,5 @@ > /* > - * Copyright IBM Corp. 2007 > + * Copyright IBM Corp. 2007, 2013 > * > * Authors: > * Dan Smith > @@ -41,6 +41,11 @@ > #define NET_XPATH (xmlChar *)"/domain/devices/interface" > #define EMU_XPATH (xmlChar *)"/domain/devices/emulator" > #define MEM_XPATH (xmlChar *)"/domain/memory | /domain/currentMemory" > +#define CONSOLE_XPATH (xmlChar *)"/domain/devices/console" > +/* > + * To be backward compatible, serial and console is > + * still part of the graphics. > + */ > #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ > "/domain/devices/console | /domain/devices/serial" > #define INPUT_XPATH (xmlChar *)"/domain/devices/input" > @@ -50,6 +55,11 @@ > > #define MAX(a,b) (((a)>(b))?(a):(b)) > > +#define DUP_FIELD(d, s, f) do { \ > + if ((s)->f != NULL) \ > + (d)->f = strdup((s)->f); \ > + } while (0); > + > /* Device parse function */ > typedef int (*dev_parse_func_t)(xmlNode *, struct virt_device **); > > @@ -133,6 +143,140 @@ static void cleanup_graphics_device(struct graphics_device *dev) > free(dev->type); > } > > +static void cleanup_path_device(struct path_device *dev) > +{ > + if (dev == NULL) > + return; > + > + free(dev->path); > + > +} > + > +static void cleanup_unixsock_device(struct unixsock_device *dev) > +{ > + if (dev == NULL) > + return; > + > + free(dev->path); > + free(dev->mode); > + > +} > + > +static void cleanup_tcp_device(struct tcp_device *dev) > +{ > + if (dev == NULL) > + return; > + > + free(dev->mode); > + free(dev->protocol); > + free(dev->host); > + free(dev->service); > + > +} > + > +static void cleanup_udp_device(struct udp_device *dev) > +{ > + if (dev == NULL) > + return; > + > + free(dev->bind_host); > + free(dev->bind_service); > + free(dev->connect_host); > + free(dev->connect_service); > +}; > + > +static void cleanup_console_device(struct console_device *dev) > +{ > + if (dev == NULL) > + return; > + > + switch (dev->source_type) > + { > + case CIM_CHARDEV_SOURCE_TYPE_PTY: > + cleanup_path_device(&dev->source_dev.pty); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_DEV: > + cleanup_path_device(&dev->source_dev.dev); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_FILE: > + cleanup_path_device(&dev->source_dev.file); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_PIPE: > + cleanup_path_device(&dev->source_dev.pipe); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: > + cleanup_unixsock_device(&dev->source_dev.unixsock); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UDP: > + cleanup_udp_device(&dev->source_dev.udp); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_TCP: > + cleanup_tcp_device(&dev->source_dev.tcp); > + break; > + default: > + /* Nothing to do for : > + CIM_CHARDEV_SOURCE_TYPE_STDIO > + CIM_CHARDEV_SOURCE_TYPE_NULL > + CIM_CHARDEV_SOURCE_TYPE_VC > + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC > + */ > + break; > + } > + > + dev->source_type = 0; > + free(dev->target_type); > + memset(&dev->source_dev, 0, sizeof(dev->source_dev)); > +}; > + > +static void console_device_dup(struct console_device *t, > + struct console_device *s) > +{ > + cleanup_console_device(t); > + > + t->source_type = s->source_type; > + DUP_FIELD(t, s, target_type); > + > + switch (s->source_type) > + { > + case CIM_CHARDEV_SOURCE_TYPE_PTY: > + DUP_FIELD(t, s, source_dev.pty.path); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_DEV: > + DUP_FIELD(t, s, source_dev.dev.path); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_FILE: > + DUP_FIELD(t, s, source_dev.file.path); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_PIPE: > + DUP_FIELD(t, s, source_dev.pipe.path); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: > + DUP_FIELD(t, s, source_dev.unixsock.path); > + DUP_FIELD(t, s, source_dev.unixsock.mode); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UDP: > + DUP_FIELD(t, s, source_dev.udp.bind_host); > + DUP_FIELD(t, s, source_dev.udp.bind_service); > + DUP_FIELD(t, s, source_dev.udp.connect_host); > + DUP_FIELD(t, s, source_dev.udp.connect_service); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_TCP: > + DUP_FIELD(t, s, source_dev.tcp.mode); > + DUP_FIELD(t, s, source_dev.tcp.protocol); > + DUP_FIELD(t, s, source_dev.tcp.host); > + DUP_FIELD(t, s, source_dev.tcp.service); > + break; > + default: > + /* Nothing to do for : > + CIM_CHARDEV_SOURCE_TYPE_STDIO > + CIM_CHARDEV_SOURCE_TYPE_NULL > + CIM_CHARDEV_SOURCE_TYPE_VC > + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC > + */ > + break; > + } > +} > + > static void cleanup_input_device(struct input_device *dev) > { > if (dev == NULL) > @@ -157,6 +301,8 @@ void cleanup_virt_device(struct virt_device *dev) > cleanup_graphics_device(&dev->dev.graphics); > else if (dev->type == CIM_RES_TYPE_INPUT) > cleanup_input_device(&dev->dev.input); > + else if (dev->type == CIM_RES_TYPE_CONSOLE) > + cleanup_console_device(&dev->dev.console); > > free(dev->id); > > @@ -613,6 +759,140 @@ static char *get_attr_value_default(xmlNode *node, char *attrname, > return ret; > } > > +static int parse_console_device(xmlNode *node, struct virt_device **vdevs) > +{ > + struct virt_device *vdev = NULL; > + struct console_device *cdev = NULL; > + char *source_type_str = NULL; > + char *target_port_ID = NULL; > + char *udp_source_mode = NULL; > + > + xmlNode *child = NULL; > + > + vdev = calloc(1, sizeof(*vdev)); > + if (vdev == NULL) > + goto err; > + > + cdev = &(vdev->dev.console); > + > + source_type_str = get_attr_value(node, "type"); > + if (source_type_str == NULL) > + goto err; > + CU_DEBUG("console device type = %s", source_type_str); > + > + cdev->source_type = chardev_source_type_StrToID(source_type_str); > + if (cdev->source_type == CIM_CHARDEV_SOURCE_TYPE_UNKNOWN) > + goto err; > + > + CU_DEBUG("console device type ID = %d", cdev->source_type); > + free(source_type_str); This is free()'d again in err:, so we get a Coverity complaint about a double free. You need a "source_type_str = NULL;" here. > + > + for (child = node->children; child != NULL; child = child->next) { > + if (XSTREQ(child->name, "target")) { > + cdev->target_type = get_attr_value(child, "type"); > + CU_DEBUG("Console device target type = '%s'", > + cdev->target_type); If get_attr_value() returns NULL in cdev->target_type, then your CU_DEBUG() isn't going to be happy. > + target_port_ID = get_attr_value(child, "port"); > + if (target_port_ID == NULL) > + goto err; > + } > + > + if (XSTREQ(child->name, "source")) { > + switch (cdev->source_type) > + { > + case CIM_CHARDEV_SOURCE_TYPE_PTY: > + cdev->source_dev.pty.path = > + get_attr_value(child, "path"); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_DEV: > + cdev->source_dev.dev.path = > + get_attr_value(child, "path"); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_FILE: > + cdev->source_dev.file.path = > + get_attr_value(child, "path"); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_PIPE: > + cdev->source_dev.pipe.path = > + get_attr_value(child, "path"); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: > + cdev->source_dev.unixsock.mode = > + get_attr_value(child, "mode"); > + cdev->source_dev.unixsock.path = > + get_attr_value(child, "path"); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UDP: > + udp_source_mode = get_attr_value(child, "mode"); > + if (udp_source_mode == NULL) > + goto err; > + if (STREQC(udp_source_mode, "bind")) { > + cdev->source_dev.udp.bind_host = > + get_attr_value(child, "host"); > + cdev->source_dev.udp.bind_service = > + get_attr_value(child, "service"); > + } > + else if (STREQC(udp_source_mode, "connect")) { > + cdev->source_dev.udp.connect_host = > + get_attr_value(child, "host"); > + cdev->source_dev.udp.connect_service = > + get_attr_value(child, "service"); > + } > + else { > + CU_DEBUG("unknown udp mode: %s", > + udp_source_mode); > + goto err; > + } > + free(udp_source_mode); This is free()'d again in err:, so we get a Coverity complaint about a double free. You'll need a udp_source_mode = NULL; here. > + break; > + case CIM_CHARDEV_SOURCE_TYPE_TCP: > + cdev->source_dev.tcp.mode = > + get_attr_value(child, "mode"); > + cdev->source_dev.tcp.host = > + get_attr_value(child, "host"); > + cdev->source_dev.tcp.service = > + get_attr_value(child, "service"); > + break; > + > + default: > + /* Nothing to do for : > + CIM_CHARDEV_SOURCE_TYPE_STDIO > + CIM_CHARDEV_SOURCE_TYPE_NULL > + CIM_CHARDEV_SOURCE_TYPE_VC > + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC > + */ > + break; > + } > + } Not a whole lot of NULL error checking in any of the get_attr_value() calls, but that seems to be par for the course in the libvirt-cim code. The rest seemed fine to me. I can squash in the above listed changes before pushing unless you really want to make a v2. John > + if ((cdev->source_type == CIM_CHARDEV_SOURCE_TYPE_TCP) > + && XSTREQ(child->name, "protocol")) { > + cdev->source_dev.tcp.protocol = > + get_attr_value(child, "type"); > + } > + } > + > + vdev->type = CIM_RES_TYPE_CONSOLE; > + > + if (-1 == asprintf(&vdev->id, "charconsole:%s", target_port_ID)) { > + CU_DEBUG("Failed to create charconsole id string"); > + goto err; > + } > + > + *vdevs = vdev; > + free(target_port_ID); > + > + return 1; > + > + err: > + free(source_type_str); > + free(target_port_ID); > + free(udp_source_mode); > + cleanup_console_device(cdev); > + free(vdev); > + > + return 0; > +} > + > static int parse_graphics_device(xmlNode *node, struct virt_device **vdevs) > { > struct virt_device *vdev = NULL; > @@ -664,8 +944,20 @@ static int parse_graphics_device(xmlNode *node, struct virt_device **vdevs) > child = child->next) { > if (XSTREQ(child->name, "source")) > gdev->dev.vnc.host = get_attr_value(child, "path"); > - else if (XSTREQ(child->name, "target")) > - gdev->dev.vnc.port = get_attr_value(child, "port"); > + else if (XSTREQ(child->name, "target")) { > + gdev->dev.vnc.port = > + get_attr_value(child, "port"); > + /* The graphics pty console can only be a > + virtio console. If 'type' is not set in the > + xml, the default of libvirt is virtio.*/ > + char *t_type = get_attr_value(child, "type"); > + if (t_type != NULL && !STREQC(t_type, "virtio")) { > + CU_DEBUG("Not a pty-virtio graphics console"); > + free(t_type); > + goto err; > + } > + free(t_type); > + } > } > } > else { > @@ -841,6 +1133,11 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) > func = &parse_graphics_device; > break; > > + case CIM_RES_TYPE_CONSOLE: > + xpathstr = CONSOLE_XPATH; > + func = &parse_console_device; > + break; > + > case CIM_RES_TYPE_INPUT: > xpathstr = INPUT_XPATH; > func = &parse_input_device; > @@ -876,11 +1173,6 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) > return count; > } > > -#define DUP_FIELD(d, s, f) do { \ > - if ((s)->f != NULL) \ > - (d)->f = strdup((s)->f); \ > - } while (0); > - > struct virt_device *virt_device_dup(struct virt_device *_dev) > { > struct virt_device *dev; > @@ -939,8 +1231,10 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) > } else if (dev->type == CIM_RES_TYPE_INPUT) { > DUP_FIELD(dev, _dev, dev.input.type); > DUP_FIELD(dev, _dev, dev.input.bus); > + } else if (dev->type == CIM_RES_TYPE_CONSOLE) { > + console_device_dup(&dev->dev.console, > + &_dev->dev.console); > } > - > return dev; > } > > @@ -1299,6 +1593,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) > (*dominfo)->dev_graphics_ct = parse_devices(xml, > &(*dominfo)->dev_graphics, > CIM_RES_TYPE_GRAPHICS); > + (*dominfo)->dev_console_ct = parse_devices(xml, > + &(*dominfo)->dev_console, > + CIM_RES_TYPE_CONSOLE); > (*dominfo)->dev_input_ct = parse_devices(xml, > &(*dominfo)->dev_input, > CIM_RES_TYPE_INPUT); > @@ -1396,6 +1693,7 @@ void cleanup_dominfo(struct domain **dominfo) > cleanup_virt_devices(&dom->dev_vcpu, dom->dev_vcpu_ct); > cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); > cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); > + cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); > > free(dom); > > diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h > index 14e49b8..2803d6a 100644 > --- a/libxkutil/device_parsing.h > +++ b/libxkutil/device_parsing.h > @@ -1,5 +1,5 @@ > /* > - * Copyright IBM Corp. 2007 > + * Copyright IBM Corp. 2007, 2013 > * > * Authors: > * Dan Smith > @@ -111,6 +111,43 @@ struct graphics_device { > } dev; > }; > > +struct path_device { > + char *path; > +}; > + > +struct unixsock_device { > + char *path; > + char *mode; > +}; > + > +struct tcp_device { > + char *mode; > + char *protocol; > + char *host; > + char *service; > +}; > + > +struct udp_device { > + char *bind_host; > + char *bind_service; > + char *connect_host; > + char *connect_service; > +}; > + > +struct console_device { > + uint16_t source_type; > + union { > + struct path_device file; > + struct path_device pty; > + struct path_device dev; > + struct path_device pipe; > + struct unixsock_device unixsock; > + struct tcp_device tcp; > + struct udp_device udp; > + } source_dev; > + char *target_type; > +}; > + > struct input_device { > char *type; > char *bus; > @@ -125,6 +162,7 @@ struct virt_device { > struct vcpu_device vcpu; > struct emu_device emu; > struct graphics_device graphics; > + struct console_device console; > struct input_device input; > } dev; > char *id; > @@ -182,6 +220,9 @@ struct domain { > struct virt_device *dev_graphics; > int dev_graphics_ct; > > + struct virt_device *dev_console; > + int dev_console_ct; > + > struct virt_device *dev_emu; > > struct virt_device *dev_input; > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > index 2ca2341..45bfb04 100644 > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -1,5 +1,5 @@ > /* > - * Copyright IBM Corp. 2007 > + * Copyright IBM Corp. 2007, 2013 > * > * Authors: > * Dan Smith > @@ -42,6 +42,189 @@ typedef const char *(*devfn_t)(xmlNodePtr node, struct domain *dominfo); > typedef const char *(*poolfn_t)(xmlNodePtr node, struct virt_pool *pool); > typedef const char *(*resfn_t)(xmlNodePtr node, struct virt_pool_res *res); > > +static int _count_graphics_console_definitions(struct domain *dominfo) > +{ > + int i; > + int num = 0; > + > + for (i = 0; i < dominfo->dev_graphics_ct; i++) { > + struct virt_device *_dev = &dominfo->dev_graphics[i]; > + if (_dev->type == CIM_RES_TYPE_UNKNOWN) > + continue; > + > + struct graphics_device *dev = &_dev->dev.graphics; > + > + if (STREQC(dev->type, "console")) { > + num++; > + } > + } > + CU_DEBUG("Found %d console defintions in graphics devices.",num); > + return num; > + > +} > + > +static const char *console_xml(xmlNodePtr root, struct domain *dominfo) > +{ > + int i; > + xmlNodePtr console; > + xmlNodePtr tmp; > + int num_graphics_consol_def = 0; > + int num_suppressed_console_def = 0; > + > + num_graphics_consol_def = _count_graphics_console_definitions(dominfo); > + > + for (i = 0; i < dominfo->dev_console_ct; i++) { > + struct virt_device *_dev = &dominfo->dev_console[i]; > + if (_dev->type == CIM_RES_TYPE_UNKNOWN) > + continue; > + > + struct console_device *cdev = &_dev->dev.console; > + > + /* Due to backward compatibility, the graphics device handling > + is still parsing consoles: > + source = pty, target = virtio (which is the default target) > + But the console device handling processes these kind of > + consoles too. This would lead to a duplication of these > + default consoles in the domain xml definition. > + This code prevents the console handling of writing xml for > + duplicate pty/virtio consoles which are written by the > + graphics device handling. */ > + if (cdev->source_type == CIM_CHARDEV_SOURCE_TYPE_PTY && > + (cdev->target_type == NULL || > + STREQC(cdev->target_type, "virtio"))) { > + if (num_suppressed_console_def < > + num_graphics_consol_def) { > + num_suppressed_console_def++; > + continue; > + } > + } > + > + console = xmlNewChild(root, NULL, BAD_CAST "console", NULL); > + if (console == NULL) > + return XML_ERROR; > + > + xmlNewProp(console, BAD_CAST "type", > + BAD_CAST > + chardev_source_type_IDToStr(cdev->source_type)); > + > + switch (cdev->source_type) { > + case CIM_CHARDEV_SOURCE_TYPE_PTY: > + /* The path property is not mandatory */ > + if (cdev->source_dev.pty.path) { > + tmp = xmlNewChild(console, NULL, > + BAD_CAST "source", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + xmlNewProp(tmp, BAD_CAST "path", > + BAD_CAST cdev->source_dev.pty.path); > + } > + break; > + case CIM_CHARDEV_SOURCE_TYPE_DEV: > + tmp = xmlNewChild(console, NULL, > + BAD_CAST "source", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + xmlNewProp(tmp, BAD_CAST "path", > + BAD_CAST cdev->source_dev.dev.path); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_FILE: > + tmp = xmlNewChild(console, NULL, > + BAD_CAST "source", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + xmlNewProp(tmp, BAD_CAST "path", > + BAD_CAST cdev->source_dev.file.path); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_PIPE: > + tmp = xmlNewChild(console, NULL, > + BAD_CAST "source", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + xmlNewProp(tmp, BAD_CAST "path", > + BAD_CAST cdev->source_dev.pipe.path); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: > + tmp = xmlNewChild(console, NULL, > + BAD_CAST "source", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + xmlNewProp(tmp, BAD_CAST "mode", > + BAD_CAST cdev->source_dev.unixsock.mode); > + xmlNewProp(tmp, BAD_CAST "path", > + BAD_CAST cdev->source_dev.unixsock.path); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UDP: > + tmp = xmlNewChild(console, NULL, > + BAD_CAST "source", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + xmlNewProp(tmp, BAD_CAST "mode", BAD_CAST "bind"); > + xmlNewProp(tmp, BAD_CAST "host", > + BAD_CAST cdev->source_dev.udp.bind_host); > + /* The service property is not mandatory */ > + if (cdev->source_dev.udp.bind_service) > + xmlNewProp(tmp, BAD_CAST "service", > + BAD_CAST > + cdev->source_dev.udp.bind_service); > + > + tmp = xmlNewChild(console, NULL, > + BAD_CAST "source", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + xmlNewProp(tmp, BAD_CAST "mode", BAD_CAST "connect"); > + xmlNewProp(tmp, BAD_CAST "host", > + BAD_CAST cdev->source_dev.udp.connect_host); > + /* The service property is not mandatory */ > + if (cdev->source_dev.udp.connect_service) > + xmlNewProp(tmp, BAD_CAST "service", > + BAD_CAST > + cdev->source_dev.udp.connect_service); > + > + break; > + case CIM_CHARDEV_SOURCE_TYPE_TCP: > + tmp = xmlNewChild(console, NULL, > + BAD_CAST "source", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + xmlNewProp(tmp, BAD_CAST "mode", > + BAD_CAST cdev->source_dev.tcp.mode); > + xmlNewProp(tmp, BAD_CAST "host", > + BAD_CAST cdev->source_dev.tcp.host); > + if (cdev->source_dev.tcp.service) > + xmlNewProp(tmp, BAD_CAST "service", > + BAD_CAST > + cdev->source_dev.tcp.service); > + if (cdev->source_dev.tcp.protocol) { > + tmp = xmlNewChild(console, NULL, > + BAD_CAST "protocol", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + xmlNewProp(tmp, BAD_CAST "type", > + BAD_CAST cdev->source_dev.tcp.protocol); > + } > + break; > + default: > + /* Nothing to do for : > + CIM_CHARDEV_SOURCE_TYPE_STDIO > + CIM_CHARDEV_SOURCE_TYPE_NULL > + CIM_CHARDEV_SOURCE_TYPE_VC > + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC > + */ > + break; > + } > + > + if (cdev->target_type) { > + tmp = xmlNewChild(console, NULL, > + BAD_CAST "target", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + xmlNewProp(tmp, BAD_CAST "type", > + BAD_CAST cdev->target_type); > + } > + } > + return NULL; > +} > + > static char *disk_block_xml(xmlNodePtr root, struct disk_device *dev) > { > xmlNodePtr disk; > @@ -977,6 +1160,11 @@ char *device_to_xml(struct virt_device *_dev) > dominfo->dev_graphics_ct = 1; > dominfo->dev_graphics = dev; > break; > + case CIM_RES_TYPE_CONSOLE: > + func = console_xml; > + dominfo->dev_console_ct = 1; > + dominfo->dev_console = dev; > + break; > case CIM_RES_TYPE_INPUT: > func = input_xml; > dominfo->dev_input_ct = 1; > @@ -1017,6 +1205,7 @@ char *system_to_xml(struct domain *dominfo) > &disk_xml, > &net_xml, > &input_xml, > + &console_xml, > &graphics_xml, > &emu_xml, > NULL > diff --git a/src/svpc_types.h b/src/svpc_types.h > index 2e4d73f..0f46a86 100644 > --- a/src/svpc_types.h > +++ b/src/svpc_types.h > @@ -25,6 +25,7 @@ > #define CIM_OPERATIONAL_STATUS 2 > > #define CIM_RES_TYPE_ALL 0 > +#define CIM_RES_TYPE_OTHER 1 > #define CIM_RES_TYPE_PROC 3 > #define CIM_RES_TYPE_MEM 4 > #define CIM_RES_TYPE_NET 10 > @@ -34,8 +35,9 @@ > #define CIM_RES_TYPE_INPUT 13 > #define CIM_RES_TYPE_UNKNOWN 1000 > #define CIM_RES_TYPE_IMAGE 32768 > +#define CIM_RES_TYPE_CONSOLE 32769 > > -#define CIM_RES_TYPE_COUNT 6 > +#define CIM_RES_TYPE_COUNT 7 > const static int cim_res_types[CIM_RES_TYPE_COUNT] = > {CIM_RES_TYPE_NET, > CIM_RES_TYPE_DISK, > @@ -43,6 +45,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = > CIM_RES_TYPE_PROC, > CIM_RES_TYPE_GRAPHICS, > CIM_RES_TYPE_INPUT, > + CIM_RES_TYPE_CONSOLE, > }; > > #define CIM_VSSD_RECOVERY_NONE 2 > From jferlan at redhat.com Tue Sep 10 22:05:25 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 10 Sep 2013 18:05:25 -0400 Subject: [Libvirt-cim] [PATCH 7/8] VSMS: Support for domains with console devices In-Reply-To: <1378395402-9422-8-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378395402-9422-8-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <522F97A5.5060700@redhat.com> On 09/05/2013 11:36 AM, Viktor Mihajlovski wrote: > From: Thilo Boehm > > An instance of KVM_ConsoleResourceAllocationSettingData can be added to > domain specification for VSMS DefineSystem() to define a console for a domain. > A console definition can not be modified or deleted. > It only can be added at system definition and deleted at system deletion. > If a KVM_ConsoleRASD is specified on a system definition, > no default graphics adapter definition is done. > > Signed-off-by: Thilo Boehm > Signed-off-by: Viktor Mihajlovski > Reviewed-by: Boris Fiuczynski > --- > src/Virt_VirtualSystemManagementService.c | 300 +++++++++++++++++++++++++++-- > 1 file changed, 279 insertions(+), 21 deletions(-) > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > index 6629b35..cd6ca9d 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -1,5 +1,5 @@ > /* > - * Copyright IBM Corp. 2007 > + * Copyright IBM Corp. 2007, 2013 > * > * Authors: > * Dan Smith > @@ -626,7 +626,8 @@ static bool default_input_device(struct domain *domain) > > static bool add_default_devs(struct domain *domain) > { > - if (domain->dev_graphics_ct < 1) { > + if (domain->dev_graphics_ct < 1 && > + domain->dev_console_ct < 1) { > if (!default_graphics_device(domain)) > return false; > } > @@ -1339,47 +1340,284 @@ static int parse_sdl_address(const char *id, > return ret; > } > > -static int parse_vnc_address(const char *id, > - char **ip, > - char **port) > +static int parse_ip_address(const char *id, > + char **ip, > + char **port) > { > int ret; > char *tmp_ip = NULL; > char *tmp_port = NULL; > > - CU_DEBUG("Entering parse_vnc_address, address is %s", id); > + CU_DEBUG("Entering parse_ip_address, address is %s", id); > if (strstr(id, "[") != NULL) { > /* its an ipv6 address */ > ret = sscanf(id, "%a[^]]]:%as", &tmp_ip, &tmp_port); > + tmp_ip = realloc(tmp_ip, strlen(tmp_ip) + 2); What if tmp_ip == NULL? This one needs to be checked... > strcat(tmp_ip, "]"); > } else { > ret = sscanf(id, "%a[^:]:%as", &tmp_ip, &tmp_port); > } > > - if (ret != 2) { > + /* ret == 2: address and port, ret == 1: address only */ > + if (ret < 1) { > ret = 0; > goto out; > } > > - if (ip) > + if (ip) { > *ip = strdup(tmp_ip); > + CU_DEBUG("IP = '%s'",*ip); strdup() could return NULL, although I suppose it's only important for debugging... > + } > > - if (port) > + if (port && tmp_port) { > *port = strdup(tmp_port); > - > - ret = 1; > + CU_DEBUG("Port = '%s'",*port); Again - strdup() could return NULL > + } > > out: > - if (ip && port) > - CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", > - *ip, *port); > - > free(tmp_ip); > free(tmp_port); > > return ret; > } > > +static bool parse_console_url(const char *url, > + char **protocol, > + char **host, > + char **port) > +{ > + bool success = false; > + char *tmp_protocol = NULL; > + char *tmp_address = NULL; > + > + CU_DEBUG("Entering parse_console_url:'%s'", url); > + > + if (sscanf(url,"%a[^:]://%as", &tmp_protocol, &tmp_address) != 2) > + goto out; > + > + if (parse_ip_address(tmp_address, host, port) < 1) > + goto out; > + > + if (protocol) { > + *protocol = strdup(tmp_protocol); > + CU_DEBUG("Protocol = '%s'", *protocol); strdup() failure again > + } > + > + success = true; > + > + out: > + free(tmp_protocol); > + free(tmp_address); > + > + return success; > +} > + > +static const char *_unixsock_console_rasd_to_vdev(CMPIInstance *inst, > + struct console_device *cdev) > +{ > + const char *val = NULL; > + const char *val2 = NULL; > + char* protocol = NULL; > + > + cdev->source_dev.unixsock.mode = NULL; > + if (cu_get_str_prop(inst,"ConnectURL", &val) == CMPI_RC_OK) { > + CU_DEBUG("ConnectURL = '%s'", val); > + cdev->source_dev.unixsock.mode = strdup("connect"); > + } > + > + if (cu_get_str_prop(inst, "BindURL", &val2) == CMPI_RC_OK) { > + if (cdev->source_dev.unixsock.mode != NULL) > + return "ConsoleRASD: Only ConnectURL or BindURL are allowed for " > + "UNIX domain socket client/server."; Not quite sure I understand the above check - are you checking that both Connect and Bind aren't being used? Then perhaps the message should state - cannot supply both ConnectURL and BindURL. Of course the above strdup() could fail, but that's a different issue... > + CU_DEBUG("BindURL = '%s'", val2); > + cdev->source_dev.unixsock.mode = strdup("bind"); > + val = val2; > + } > + > + if (val) { > + if (!parse_console_url(val, &protocol, &cdev->source_dev.unixsock.path, NULL)) > + return "ConsoleRASD: Invalid ConnectURL or BindURL for " > + "UNIX domain socket client/server."; > + > + if (!STREQC("file", protocol)) { > + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'",protocol); > + free(protocol); > + return "ConsoleRASD: Protocol 'file' was not specified for " > + "ConnectURL or BindURL for UNIX domain socket client/server."; > + } > + free(protocol); > + } else Prefer to see "} else {" as it's cleaner and no one mistakenly adds a line eventually. BTW: We could get here if strdup() fails... > + return "ConsoleRASD: ConnectURL or BindURL not specified for " > + "UNIX domain socket client/server."; > + > + return NULL; > +} > + > +static const char *_udp_console_rasd_to_vdev(CMPIInstance *inst, > + struct console_device *cdev) > +{ > + const char *val = NULL; > + char* protocol = NULL; > + > + if (cu_get_str_prop(inst, "ConnectURL", &val) != CMPI_RC_OK) > + return "ConsoleRASD: ConnectURL not specified for UDP network console."; > + > + if (!parse_console_url(val, &protocol, > + &cdev->source_dev.udp.connect_host, > + &cdev->source_dev.udp.connect_service)) > + return "ConsoleRASD: Invalid ConnectURL specified for UDP network console."; > + > + if (!STREQC("udp" ,protocol)) { > + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'",protocol); > + free(protocol); > + return "ConsoleRASD: Protocol 'udp' was not specified at " > + "ConnectURL for UDP network console."; > + } > + > + free(protocol); > + > + if (cu_get_str_prop(inst, "BindURL", &val) != CMPI_RC_OK) > + return "ConsoleRASD: BindURL not specified for UDP network console."; > + > + if (!parse_console_url(val,&protocol, > + &cdev->source_dev.udp.bind_host, > + &cdev->source_dev.udp.bind_service)) > + return "ConsoleRASD: Invalid BindURL specified for UDP network console."; > + > + if (!STREQC("udp", protocol)) { > + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'",protocol); > + free(protocol); > + return "ConsoleRASD: Protocol 'udp' was not specified at BindURL " > + "for UDP network console."; > + } > + > + free(protocol); > + return NULL; > +} > + > +static const char *_tcp_console_rasd_to_vdev(CMPIInstance *inst, > + struct console_device *cdev) > +{ > + const char *val = NULL; > + const char *val2 = NULL; > + > + cdev->source_dev.tcp.mode = NULL; > + if (cu_get_str_prop(inst, "ConnectURL", &val) == CMPI_RC_OK) { > + CU_DEBUG("ConnectURL = '%s'",val); > + cdev->source_dev.tcp.mode = strdup("connect"); > + } > + > + if (cu_get_str_prop(inst, "BindURL", &val2) == CMPI_RC_OK) { > + if (cdev->source_dev.tcp.mode != NULL) > + return "ConsoleRASD: Only ConnectURL or BindURL are allowed for " > + "TCP client/server console."; Similar comment from above - cannot supply both. > + CU_DEBUG("BindURL = '%s'",val2); > + cdev->source_dev.tcp.mode = strdup("bind"); > + val = val2; > + } > + > + if (val) { > + if (!parse_console_url(val, > + &cdev->source_dev.tcp.protocol, > + &cdev->source_dev.tcp.host, > + &cdev->source_dev.tcp.service)) > + return "ConsoleRASD: Invalid ConnectURL or BindURL for " > + "TCP client/server console."; > + if (cdev->source_dev.tcp.service == NULL) > + return "ConsoleRASD: Missing TCP port for TCP client/server console."; > + } else Again the "} else {" > + return "ConsoleRASD: ConnectURL or BindURL not specified for " > + "TCP client/server console."; > + > + if (STREQC("udp",cdev->source_dev.tcp.protocol)) { > + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'", cdev->source_dev.tcp.protocol); > + return "ConsoleRASD: Invalid protocol 'udp' was specified at " > + "TCP client/server console."; > + } > + > + if (STREQC("file", cdev->source_dev.tcp.protocol)) { > + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'",cdev->source_dev.tcp.protocol); > + return "ConsoleRASD: Invalid protocol 'file' was specified at " > + "TCP client/server console."; > + } > + > + return NULL; > +} > + > +static const char *console_rasd_to_vdev(CMPIInstance *inst, > + struct virt_device *dev) > +{ > + int rc = 0; > + const char *msg = NULL; > + const char *val = NULL; > + struct console_device *cdev = &dev->dev.console; > + uint16_t tmp; > + > + rc = cu_get_u16_prop(inst, "SourceType", &tmp); > + if (rc != CMPI_RC_OK) > + return "ConsoleRASD: SourceType field not specified."; > + > + if (tmp < 0 || tmp >= CIM_CHARDEV_SOURCE_TYPE_INVALIDTYPE) tmp is a uint16_t so a < 0 comparison is not possible. > + return "ConsoleRASD: Invalid SourceType value"; > + > + cdev->source_type = tmp; > + CU_DEBUG("Processeing SourceType: %d", cdev->source_type); > + > + /* property not required */ > + if (cu_get_str_prop(inst, "TargetType", &val) == CMPI_RC_OK) > + cdev->target_type = strdup(val); > + CU_DEBUG("TargetType is '%s'", cdev->target_type); More strdup/debug Nothing overly serious - let me know how you want to proceed especially with respect to realloc() failure and unsigned compare less than zero John > + > + switch (cdev->source_type) { > + case CIM_CHARDEV_SOURCE_TYPE_PTY: > + /* property not required */ > + if (cu_get_str_prop(inst, "SourcePath", &val) == CMPI_RC_OK) > + cdev->source_dev.pty.path = strdup(val); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_DEV: > + if (cu_get_str_prop(inst, "SourcePath", &val) != CMPI_RC_OK) > + return "ConsoleRASD: SourcePath not specified for Host device proxy."; > + cdev->source_dev.dev.path = strdup(val); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_FILE: > + if (cu_get_str_prop(inst, "SourcePath", &val) != CMPI_RC_OK) > + return "ConsoleRASD: SourcePath not specified for Device logfile."; > + cdev->source_dev.file.path = strdup(val); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_PIPE: > + if (cu_get_str_prop(inst, "SourcePath", &val) != CMPI_RC_OK) > + return "ConsoleRASD: SourcePath not specified for Named pipe."; > + cdev->source_dev.pipe.path = strdup(val); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: > + msg = _unixsock_console_rasd_to_vdev(inst, cdev); > + if (msg != NULL) > + return msg; > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UDP: > + msg = _udp_console_rasd_to_vdev(inst, cdev); > + if (msg != NULL) > + return msg; > + break; > + case CIM_CHARDEV_SOURCE_TYPE_TCP: > + msg = _tcp_console_rasd_to_vdev(inst, cdev); > + if (msg != NULL) > + return msg; > + break; > + > + default: > + /* Nothing to do for : > + CIM_CHARDEV_SOURCE_TYPE_STDIO > + CIM_CHARDEV_SOURCE_TYPE_NULL > + CIM_CHARDEV_SOURCE_TYPE_VC > + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC > + */ > + break; > + } > + > + return NULL; > +} > + > static const char *graphics_rasd_to_vdev(CMPIInstance *inst, > struct virt_device *dev) > { > @@ -1411,10 +1649,10 @@ static const char *graphics_rasd_to_vdev(CMPIInstance *inst, > val = "127.0.0.1:-1"; > } > > - ret = parse_vnc_address(val, > + ret = parse_ip_address(val, > &dev->dev.graphics.dev.vnc.host, > &dev->dev.graphics.dev.vnc.port); > - if (ret != 1) { > + if (ret != 2) { > msg = "GraphicsRASD field Address not valid"; > goto out; > } > @@ -1540,6 +1778,8 @@ static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, > return proc_rasd_to_vdev(inst, dev); > } else if (type == CIM_RES_TYPE_GRAPHICS) { > return graphics_rasd_to_vdev(inst, dev); > + } else if (type == CIM_RES_TYPE_CONSOLE) { > + return console_rasd_to_vdev(inst, dev); > } else if (type == CIM_RES_TYPE_INPUT) { > return input_rasd_to_vdev(inst, dev); > } > @@ -1601,7 +1841,7 @@ static const char *rasd_to_vdev(CMPIInstance *inst, > return msg; > } > > -static char *add_device_nodup(struct virt_device *dev, > +static const char *add_device_nodup(struct virt_device *dev, > struct virt_device *list, > int max, > int *index) > @@ -1663,6 +1903,9 @@ static const char *classify_resources(CMPIArray *resources, > if (!make_space(&domain->dev_graphics, domain->dev_graphics_ct, count)) > return "Failed to alloc graphics list"; > > + if (!make_space(&domain->dev_console, domain->dev_console_ct, count)) > + return "Failed to alloc console list"; > + > if (!make_space(&domain->dev_input, domain->dev_input_ct, count)) > return "Failed to alloc input list"; > > @@ -1765,6 +2008,14 @@ static const char *classify_resources(CMPIArray *resources, > domain->dev_graphics, > gcount, > &domain->dev_graphics_ct); > + } else if (type == CIM_RES_TYPE_CONSOLE) { > + msg = rasd_to_vdev(inst, > + domain, > + &domain->dev_console[domain->dev_console_ct], > + ns, > + p_error); > + if (msg == NULL) > + domain->dev_console_ct+=1; > } else if (type == CIM_RES_TYPE_INPUT) { > domain->dev_input_ct = 1; > msg = rasd_to_vdev(inst, > @@ -2570,6 +2821,9 @@ static struct virt_device **find_list(struct domain *dominfo, > } else if (type == CIM_RES_TYPE_GRAPHICS) { > list = &dominfo->dev_graphics; > *count = &dominfo->dev_graphics_ct; > + } else if (type == CIM_RES_TYPE_CONSOLE) { > + list = &dominfo->dev_console; > + *count = &dominfo->dev_console_ct; > } else if (type == CIM_RES_TYPE_INPUT) { > list = &dominfo->dev_input; > *count = &dominfo->dev_input_ct; > @@ -2693,7 +2947,8 @@ static CMPIStatus resource_del(struct domain *dominfo, > > if (STREQ(dev->id, devid)) { > if ((type == CIM_RES_TYPE_GRAPHICS) || > - (type == CIM_RES_TYPE_INPUT)) > + (type == CIM_RES_TYPE_CONSOLE) || > + (type == CIM_RES_TYPE_INPUT)) > cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); > else { > s = _resource_dynamic(dominfo, > @@ -2774,7 +3029,9 @@ static CMPIStatus resource_add(struct domain *dominfo, > goto out; > } > > - if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT)) { > + if ((type == CIM_RES_TYPE_GRAPHICS) || > + (type == CIM_RES_TYPE_INPUT) || > + (type == CIM_RES_TYPE_CONSOLE)) { > (*count)++; > cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); > goto out; > @@ -2850,7 +3107,8 @@ static CMPIStatus resource_mod(struct domain *dominfo, > } > > if ((type == CIM_RES_TYPE_GRAPHICS) || > - (type == CIM_RES_TYPE_INPUT)) > + (type == CIM_RES_TYPE_INPUT) || > + (type == CIM_RES_TYPE_CONSOLE)) > cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); > else { > #if LIBVIR_VERSION_NUMBER < 9000 > From jferlan at redhat.com Tue Sep 10 22:08:38 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 10 Sep 2013 18:08:38 -0400 Subject: [Libvirt-cim] [PATCH 8/8] VSMS: add default console In-Reply-To: <1378395402-9422-9-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378395402-9422-9-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <522F9866.6080007@redhat.com> On 09/05/2013 11:36 AM, Viktor Mihajlovski wrote: > From: Thilo Boehm > > A new function to add a default console has been added. As with > the default graphics and default input device, the default device > generation is optional and depends on the domain type and > architecture. > Initially, we only create an s390 console, which is necessary to > define a runnable guest. > > Signed-off-by: Thilo Boehm > Signed-off-by: Viktor Mihajlovski > Reviewed-by: Boris Fiuczynski > --- > src/Virt_VirtualSystemManagementService.c | 34 +++++++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) > ACK John FYI: The not checking for memory allocation is endemic throughout libvirt-cim. I suppose "some day" it would be good to do something about it, but there's so many assumptions now it'd probably take the libvirt VIR_ALLOC, VIR_STRDUP, etc macros to fix all the instances. From mihajlov at linux.vnet.ibm.com Wed Sep 11 09:43:03 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Wed, 11 Sep 2013 11:43:03 +0200 Subject: [Libvirt-cim] [PATCH] cimtest: Fix bogus RASD counting in RASD/03_rasd_errs In-Reply-To: <522F76BB.4090401@redhat.com> References: <522F76BB.4090401@redhat.com> Message-ID: <1378892583-1591-1-git-send-email-mihajlov@linux.vnet.ibm.com> The number of expected RASDs for the test domain was incorrectly computed by enumerating all RASDs on the hypervisor which will always fail if the test domain doesn't have every possible RASD associated. Fixed by counting the resource settings in the virtual server instance and comparing that against the RASDs actually found. Signed-off-by: Viktor Mihajlovski --- suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py b/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py index d582ffb..5517a72 100644 --- a/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py +++ b/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py @@ -71,10 +71,6 @@ def init_rasd_list(virt, ip, guest_name): if guest == guest_name: rasd_insts[rasd.Classname] = rasd - if len(rasds) != len(rasd_insts): - logger.error("Expected %d RASDs, got %d", len(rasds), len(rasd_insts)) - return rasd_insts, FAIL - return rasd_insts, PASS @do_main(sup_types) @@ -106,6 +102,11 @@ def main(): logger.error("Unable to build rasd instance list") return status + if len(vsxml.res_settings) != len(rasds): + logger.error("Expected %d RASDs, got %d", len(vsxml.res_settings), + len(rasds)) + return FAIL + expr_values = { 'rc' : CIM_ERR_NOT_FOUND, 'desc' : 'No such instance' -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Wed Sep 11 10:42:13 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Wed, 11 Sep 2013 12:42:13 +0200 Subject: [Libvirt-cim] [PATCH 4/8] libxkutil: Console Support In-Reply-To: <522F8343.301@redhat.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378395402-9422-5-git-send-email-mihajlov@linux.vnet.ibm.com> <522F8343.301@redhat.com> Message-ID: <52304905.1050904@linux.vnet.ibm.com> On 09/10/2013 10:38 PM, John Ferlan wrote: [...] >> + >> + CU_DEBUG("console device type ID = %d", cdev->source_type); >> + free(source_type_str); > > This is free()'d again in err:, so we get a Coverity complaint about a > double free. You need a "source_type_str = NULL;" here. oops ... will fix by moving to the end > >> + >> + for (child = node->children; child != NULL; child = child->next) { >> + if (XSTREQ(child->name, "target")) { >> + cdev->target_type = get_attr_value(child, "type"); >> + CU_DEBUG("Console device target type = '%s'", >> + cdev->target_type); > > If get_attr_value() returns NULL in cdev->target_type, then your > CU_DEBUG() isn't going to be happy. actually, I expect CU_DEBUG to handle that gracefully... as it does in other places (see parse_graphics_device, vnc port determination) > [...] >> + } >> + free(udp_source_mode); > > > This is free()'d again in err:, so we get a Coverity complaint about a > double free. You'll need a udp_source_mode = NULL; here. yep > >> + break; >> + case CIM_CHARDEV_SOURCE_TYPE_TCP: >> + cdev->source_dev.tcp.mode = >> + get_attr_value(child, "mode"); >> + cdev->source_dev.tcp.host = >> + get_attr_value(child, "host"); >> + cdev->source_dev.tcp.service = >> + get_attr_value(child, "service"); >> + break; >> + >> + default: >> + /* Nothing to do for : >> + CIM_CHARDEV_SOURCE_TYPE_STDIO >> + CIM_CHARDEV_SOURCE_TYPE_NULL >> + CIM_CHARDEV_SOURCE_TYPE_VC >> + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC >> + */ >> + break; >> + } >> + } > > Not a whole lot of NULL error checking in any of the get_attr_value() > calls, but that seems to be par for the course in the libvirt-cim code. at some point in time we should consider a 'spring clean' > > The rest seemed fine to me. I can squash in the above listed changes > before pushing unless you really want to make a v2. I'll make a v2, as I saw some other nits, like [...] >> + if (-1 == asprintf(&vdev->id, "charconsole:%s", target_port_ID)) { (left hand side constant in comparison) which escaped my attention before ... >> + CU_DEBUG("Failed to create charconsole id string"); >> + goto err; >> + } -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From mihajlov at linux.vnet.ibm.com Wed Sep 11 11:31:48 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Wed, 11 Sep 2013 13:31:48 +0200 Subject: [Libvirt-cim] [PATCH 5/8] RASD: Provider Support for Console RASDs In-Reply-To: <522F8B1A.206@redhat.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378395402-9422-6-git-send-email-mihajlov@linux.vnet.ibm.com> <522F8B1A.206@redhat.com> Message-ID: <523054A4.5040109@linux.vnet.ibm.com> On 09/10/2013 11:11 PM, John Ferlan wrote: [...] >> + CMSetProperty(inst, "TargetType", >> + (CMPIValue *)cdev->target_type, CMPI_chars); >> + > > Since libxkutil/parse_console_device() didn't do any error checking > w/r/t a NULL return on get_attr_value() calls, we could get into a lot > of trouble here, but again par for the course in libvirt-cim! > The CMPI interface allows you to explicitly set NULL string properties, so no trouble should arise from that at least (I have also checked the code in sfcb and Pegasus to be 100% sure). >> + switch (cdev->source_type) { >> + case CIM_CHARDEV_SOURCE_TYPE_PTY: >> + CMSetProperty(inst, "SourcePath", >> + (CMPIValue *)cdev->source_dev.pty.path, >> + CMPI_chars); >> + break; >> + case CIM_CHARDEV_SOURCE_TYPE_DEV: >> + CMSetProperty(inst, "SourcePath", >> + (CMPIValue *)cdev->source_dev.dev.path, >> + CMPI_chars); >> + break; >> + case CIM_CHARDEV_SOURCE_TYPE_FILE: >> + CMSetProperty(inst, "SourcePath", >> + (CMPIValue *)cdev->source_dev.file.path, >> + CMPI_chars); >> + break; >> + case CIM_CHARDEV_SOURCE_TYPE_PIPE: >> + CMSetProperty(inst, "SourcePath", >> + (CMPIValue *)cdev->source_dev.pipe.path, >> + CMPI_chars); >> + break; >> + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: >> + tmp = _build_console_url("file", >> + cdev->source_dev.unixsock.path, NULL); >> + if (STREQC(cdev->source_dev.unixsock.mode, "bind")) >> + CMSetProperty(inst, "BindURL", >> + (CMPIValue *)tmp, CMPI_chars); >> + >> + if (STREQC(cdev->source_dev.unixsock.mode, "connect")) >> + CMSetProperty(inst, "ConnectURL", >> + (CMPIValue *)tmp, CMPI_chars); >> + >> + free(tmp); >> + break; >> + case CIM_CHARDEV_SOURCE_TYPE_UDP: >> + tmp = _build_console_url("udp", >> + cdev->source_dev.udp.bind_host, >> + cdev->source_dev.udp.bind_service); > > Since 'tmp' can be NULL, could there be any negative repercussion in the > following? no, see above > >> + CMSetProperty(inst, "BindURL", >> + (CMPIValue *)tmp, CMPI_chars); >> + free(tmp); >> + >> + tmp = _build_console_url("udp", >> + cdev->source_dev.udp.connect_host, >> + cdev->source_dev.udp.connect_service); > > Same here > >> + CMSetProperty(inst, "ConnectURL", (CMPIValue *)tmp, CMPI_chars); >> + free(tmp); >> + break; >> + case CIM_CHARDEV_SOURCE_TYPE_TCP: >> + tmp = _build_console_url(cdev->source_dev.tcp.protocol, >> + cdev->source_dev.tcp.host, >> + cdev->source_dev.tcp.service); >> + if (STREQC(cdev->source_dev.tcp.mode, "bind")) > > Again that is probably not good ... will fix in V2 > >> + CMSetProperty(inst, "BindURL", >> + (CMPIValue *)tmp, CMPI_chars); >> + >> + if (STREQC(cdev->source_dev.tcp.mode, "connect")) > > Again yep -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Wed Sep 11 12:05:10 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 11 Sep 2013 08:05:10 -0400 Subject: [Libvirt-cim] [PATCH] REDSAP: Fix double exception possibilty In-Reply-To: <1378475178-27179-1-git-send-email-jferlan@redhat.com> References: <1378475178-27179-1-git-send-email-jferlan@redhat.com> Message-ID: <52305C76.1070706@redhat.com> On 09/06/2013 09:46 AM, John Ferlan wrote: > Test failed with the following: > > -------------------------------------------------------------------- > KVMRedirectionSAP - 01_enum_KVMredSAP.py: FAIL > ERROR - Failed to enumerate the class of KVM_KVMRedirectionSAP > ERROR - Exception details: Got more than one record for: test_kvmredsap_dom > ERROR - Exception details: 'ElementName' Value Mismatch, Expected 5988:-1, Got 5988:0 > ERROR - Exception: Failed to verify information for the defined dom:test_kvmredsap_dom > -------------------------------------------------------------------- > > There are two exceptions listed because the 'enum_redsap()' method was > perusing a list, finding a match, declaring success, and continuing to > peruse the list. Then found another match declared an exception and returned > with status = PASS. > > The caller just checked the status before continuing. > > This patch doesn't resolve the underlying cause, but does avoid the call to > 'verify_redsap_values()' which will also fail... > --- > > NOTE: I was able to reproduce the initial exception if I run this test > very quickly two times in succession. I debated adding a 'sleep(5)' (or > similar) prior to the end of the test to ensure whatever teardown was > not occurring in a timely manner (by the networking code) could happen, > but I believe that wouldn't necessarily fix the problem - just make it > less likely to happen. The resource in question is a specific port in the > underlying VNC technology. That code may have built in 'safeguards' to help > with throttling, e.g. reuse a recently used port thus make it unreliable for > the test to rely on getting the "first" port. Since the test isn't designed > to run twice in a row, I don't think it's a real issue... > > .../libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > Tks for the review - this is now pushed. John From jferlan at redhat.com Wed Sep 11 12:07:15 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 11 Sep 2013 08:07:15 -0400 Subject: [Libvirt-cim] [PATCH 0/2] Make cimtest more s390-friendly In-Reply-To: <1378391140-21815-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378391140-21815-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <52305CF3.5070908@redhat.com> On 09/05/2013 10:25 AM, Viktor Mihajlovski wrote: > cimtest currently doesn't work too well on s390 systems, > the two main areas of failure are the attempt to > define systems with IDE hard drivers and VGA graphics, > both not supported on this host type. > > Changing from IDE to virtio disks fixed a lot of the > test FAILs with no adverse impacts to the x86 runs > on our systems at least. It would be nice if somebody > could verify this. > > Further, we do not add the graphics RASD to the default > guest definition if the hypervisor host is an s390 > system. In principle, we could have removed the graphics > RASD altogether, because libvirt-cim will define a > default graphics device for x86 but since it is only a > small change, it seems safer to do it this way. > > Thilo Boehm (1): > cimtest: Use vda instead of hda for disk RASDs > > Viktor Mihajlovski (1): > cimtest: Don't generate graphics for s390 > > .../cimtest/ElementAllocatedFromPool/01_forward.py | 2 +- > .../cimtest/ElementAllocatedFromPool/02_reverse.py | 2 +- > .../ElementAllocatedFromPool/03_reverse_errs.py | 2 +- > .../ElementAllocatedFromPool/04_forward_errs.py | 2 +- > .../cimtest/HostedAccessPoint/01_forward.py | 2 +- > .../cimtest/HostedAccessPoint/02_reverse.py | 2 +- > .../02_guest_add_mod_rem_rasd_ind.py | 2 +- > .../cimtest/ServiceAccessBySAP/01_forward.py | 2 +- > .../cimtest/ServiceAccessBySAP/02_reverse.py | 2 +- > .../cimtest/SettingsDefine/01_forward.py | 2 +- > .../cimtest/SettingsDefine/02_reverse.py | 2 +- > .../cimtest/SettingsDefine/03_sds_fwd_errs.py | 2 +- > .../cimtest/SettingsDefine/04_sds_rev_errs.py | 2 +- > .../libvirt-cim/cimtest/SystemDevice/01_forward.py | 2 +- > .../libvirt-cim/cimtest/SystemDevice/03_fwderrs.py | 2 +- > suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py | 2 +- > .../13_refconfig_additional_devs.py | 2 +- > .../14_define_sys_disk.py | 2 +- > .../30_dynamic_disk_mod.py | 2 +- > .../02_reverse.py | 2 +- > .../03_vssdc_fwd_errs.py | 2 +- > suites/libvirt-cim/lib/XenKvmLib/const.py | 2 +- > suites/libvirt-cim/lib/XenKvmLib/vsms.py | 2 +- > suites/libvirt-cim/lib/XenKvmLib/vxml.py | 5 +++-- > suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py | 7 +++++++ > 25 files changed, 33 insertions(+), 25 deletions(-) > This is now pushed. John From mihajlov at linux.vnet.ibm.com Wed Sep 11 13:26:38 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Wed, 11 Sep 2013 15:26:38 +0200 Subject: [Libvirt-cim] [PATCH 7/8] VSMS: Support for domains with console devices In-Reply-To: <522F97A5.5060700@redhat.com> References: <1378395402-9422-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378395402-9422-8-git-send-email-mihajlov@linux.vnet.ibm.com> <522F97A5.5060700@redhat.com> Message-ID: <52306F8E.6010200@linux.vnet.ibm.com> On 09/11/2013 12:05 AM, John Ferlan wrote: [...] >> if (strstr(id, "[") != NULL) { >> /* its an ipv6 address */ >> ret = sscanf(id, "%a[^]]]:%as", &tmp_ip, &tmp_port); >> + tmp_ip = realloc(tmp_ip, strlen(tmp_ip) + 2); > > What if tmp_ip == NULL? This one needs to be checked... > yes ... this will become ugly ... >> strcat(tmp_ip, "]"); >> } else { >> ret = sscanf(id, "%a[^:]:%as", &tmp_ip, &tmp_port); >> } >> >> - if (ret != 2) { >> + /* ret == 2: address and port, ret == 1: address only */ >> + if (ret < 1) { >> ret = 0; >> goto out; >> } >> >> - if (ip) >> + if (ip) { >> *ip = strdup(tmp_ip); >> + CU_DEBUG("IP = '%s'",*ip); > > strdup() could return NULL, although I suppose it's only important for > debugging... I was prepared to contradict here ... but I am changing my mind while I type, stupid me ... I will rework the previous patches wrt to this as well > >> + } >> >> - if (port) >> + if (port && tmp_port) { >> *port = strdup(tmp_port); >> - >> - ret = 1; >> + CU_DEBUG("Port = '%s'",*port); > > Again - strdup() could return NULL > >> + } >> >> out: >> - if (ip && port) >> - CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", >> - *ip, *port); >> - >> free(tmp_ip); >> free(tmp_port); >> >> return ret; >> } >> >> +static bool parse_console_url(const char *url, >> + char **protocol, >> + char **host, >> + char **port) >> +{ >> + bool success = false; >> + char *tmp_protocol = NULL; >> + char *tmp_address = NULL; >> + >> + CU_DEBUG("Entering parse_console_url:'%s'", url); >> + >> + if (sscanf(url,"%a[^:]://%as", &tmp_protocol, &tmp_address) != 2) >> + goto out; >> + >> + if (parse_ip_address(tmp_address, host, port) < 1) >> + goto out; >> + >> + if (protocol) { >> + *protocol = strdup(tmp_protocol); >> + CU_DEBUG("Protocol = '%s'", *protocol); > > strdup() failure again > >> + } >> + >> + success = true; >> + >> + out: >> + free(tmp_protocol); >> + free(tmp_address); >> + >> + return success; >> +} >> + >> +static const char *_unixsock_console_rasd_to_vdev(CMPIInstance *inst, >> + struct console_device *cdev) >> +{ >> + const char *val = NULL; >> + const char *val2 = NULL; >> + char* protocol = NULL; >> + >> + cdev->source_dev.unixsock.mode = NULL; >> + if (cu_get_str_prop(inst,"ConnectURL", &val) == CMPI_RC_OK) { >> + CU_DEBUG("ConnectURL = '%s'", val); >> + cdev->source_dev.unixsock.mode = strdup("connect"); >> + } >> + >> + if (cu_get_str_prop(inst, "BindURL", &val2) == CMPI_RC_OK) { >> + if (cdev->source_dev.unixsock.mode != NULL) >> + return "ConsoleRASD: Only ConnectURL or BindURL are allowed for " >> + "UNIX domain socket client/server."; > > Not quite sure I understand the above check - are you checking that both > Connect and Bind aren't being used? Then perhaps the message should > state - cannot supply both ConnectURL and BindURL. Of course the above wording needs improvement ... agreed > strdup() could fail, but that's a different issue... > >> + CU_DEBUG("BindURL = '%s'", val2); >> + cdev->source_dev.unixsock.mode = strdup("bind"); >> + val = val2; >> + } >> + >> + if (val) { >> + if (!parse_console_url(val, &protocol, &cdev->source_dev.unixsock.path, NULL)) >> + return "ConsoleRASD: Invalid ConnectURL or BindURL for " >> + "UNIX domain socket client/server."; >> + >> + if (!STREQC("file", protocol)) { >> + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'",protocol); >> + free(protocol); >> + return "ConsoleRASD: Protocol 'file' was not specified for " >> + "ConnectURL or BindURL for UNIX domain socket client/server."; >> + } >> + free(protocol); >> + } else > > Prefer to see "} else {" as it's cleaner and no one mistakenly adds a > line eventually. BTW: We could get here if strdup() fails... > agree [...] >> + >> + if (cu_get_str_prop(inst, "BindURL", &val2) == CMPI_RC_OK) { >> + if (cdev->source_dev.tcp.mode != NULL) >> + return "ConsoleRASD: Only ConnectURL or BindURL are allowed for " >> + "TCP client/server console."; > > Similar comment from above - cannot supply both. > will do >> + CU_DEBUG("BindURL = '%s'",val2); >> + cdev->source_dev.tcp.mode = strdup("bind"); >> + val = val2; >> + } >> + >> + if (val) { >> + if (!parse_console_url(val, >> + &cdev->source_dev.tcp.protocol, >> + &cdev->source_dev.tcp.host, >> + &cdev->source_dev.tcp.service)) >> + return "ConsoleRASD: Invalid ConnectURL or BindURL for " >> + "TCP client/server console."; >> + if (cdev->source_dev.tcp.service == NULL) >> + return "ConsoleRASD: Missing TCP port for TCP client/server console."; >> + } else > > Again the "} else {" > agree >> + return "ConsoleRASD: ConnectURL or BindURL not specified for " >> + "TCP client/server console."; >> + >> + if (STREQC("udp",cdev->source_dev.tcp.protocol)) { >> + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'", cdev->source_dev.tcp.protocol); >> + return "ConsoleRASD: Invalid protocol 'udp' was specified at " >> + "TCP client/server console."; >> + } >> + >> + if (STREQC("file", cdev->source_dev.tcp.protocol)) { >> + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'",cdev->source_dev.tcp.protocol); >> + return "ConsoleRASD: Invalid protocol 'file' was specified at " >> + "TCP client/server console."; >> + } >> + >> + return NULL; >> +} >> + >> +static const char *console_rasd_to_vdev(CMPIInstance *inst, >> + struct virt_device *dev) >> +{ >> + int rc = 0; >> + const char *msg = NULL; >> + const char *val = NULL; >> + struct console_device *cdev = &dev->dev.console; >> + uint16_t tmp; >> + >> + rc = cu_get_u16_prop(inst, "SourceType", &tmp); >> + if (rc != CMPI_RC_OK) >> + return "ConsoleRASD: SourceType field not specified."; >> + >> + if (tmp < 0 || tmp >= CIM_CHARDEV_SOURCE_TYPE_INVALIDTYPE) > > tmp is a uint16_t so a < 0 comparison is not possible. > yep >> + return "ConsoleRASD: Invalid SourceType value"; >> + >> + cdev->source_type = tmp; >> + CU_DEBUG("Processeing SourceType: %d", cdev->source_type); >> + >> + /* property not required */ >> + if (cu_get_str_prop(inst, "TargetType", &val) == CMPI_RC_OK) >> + cdev->target_type = strdup(val); >> + CU_DEBUG("TargetType is '%s'", cdev->target_type); > > More strdup/debug > > > Nothing overly serious - let me know how you want to proceed especially > with respect to realloc() failure and unsigned compare less than zero > -> V2 > -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Wed Sep 11 14:13:58 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 11 Sep 2013 10:13:58 -0400 Subject: [Libvirt-cim] [PATCH] cimtest: Fix bogus RASD counting in RASD/03_rasd_errs In-Reply-To: <1378892583-1591-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <522F76BB.4090401@redhat.com> <1378892583-1591-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <52307AA6.5060601@redhat.com> On 09/11/2013 05:43 AM, Viktor Mihajlovski wrote: > The number of expected RASDs for the test domain was incorrectly > computed by enumerating all RASDs on the hypervisor which will > always fail if the test domain doesn't have every possible > RASD associated. > Fixed by counting the resource settings in the virtual server > instance and comparing that against the RASDs actually found. > > Signed-off-by: Viktor Mihajlovski > --- > suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py b/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py > index d582ffb..5517a72 100644 > --- a/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py > +++ b/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py > @@ -71,10 +71,6 @@ def init_rasd_list(virt, ip, guest_name): > if guest == guest_name: > rasd_insts[rasd.Classname] = rasd > > - if len(rasds) != len(rasd_insts): > - logger.error("Expected %d RASDs, got %d", len(rasds), len(rasd_insts)) > - return rasd_insts, FAIL > - > return rasd_insts, PASS > > @do_main(sup_types) > @@ -106,6 +102,11 @@ def main(): > logger.error("Unable to build rasd instance list") > return status > > + if len(vsxml.res_settings) != len(rasds): > + logger.error("Expected %d RASDs, got %d", len(vsxml.res_settings), > + len(rasds)) > + return FAIL > + > expr_values = { > 'rc' : CIM_ERR_NOT_FOUND, > 'desc' : 'No such instance' > ACK and pushed with the following change to account for the error paths not undefining the guest: diff --git a/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py b/suites/libvirt-ci index 5517a72..feec39b 100644 --- a/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py +++ b/suites/libvirt-cim/cimtest/RASD/03_rasd_errs.py @@ -100,11 +100,13 @@ def main(): rasds, status = init_rasd_list(virt, options.ip, test_dom) if status != PASS: logger.error("Unable to build rasd instance list") + vsxml.undefine(server) return status if len(vsxml.res_settings) != len(rasds): logger.error("Expected %d RASDs, got %d", len(vsxml.res_settings), len(rasds)) + vsxml.undefine(server) return FAIL expr_values = { John From mihajlov at linux.vnet.ibm.com Wed Sep 11 14:45:36 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Wed, 11 Sep 2013 16:45:36 +0200 Subject: [Libvirt-cim] [PATCHv2 2/7] schema: New SVPC types for chardev/consoles In-Reply-To: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378910741-22520-3-git-send-email-mihajlov@linux.vnet.ibm.com> From: Thilo Boehm C definitions for the console source types, defining the representation of the consoles in the hypervisor host. Includes mapping from and to string representations. Signed-off-by: Thilo Boehm Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- src/svpc_types.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/src/svpc_types.h b/src/svpc_types.h index 99dd56f..2e4d73f 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007, 2013 * * Authors: * Dan Smith @@ -167,5 +167,100 @@ enum CIM_op_status { CIM_OP_STATUS_POWER_MODE = 18, }; +/* emum for the Character device Source resource types */ +enum CIM_chardev_source_type { + CIM_CHARDEV_SOURCE_TYPE_NULL = 0, + CIM_CHARDEV_SOURCE_TYPE_VC = 1, + CIM_CHARDEV_SOURCE_TYPE_PTY = 2, + CIM_CHARDEV_SOURCE_TYPE_DEV = 3, + CIM_CHARDEV_SOURCE_TYPE_FILE = 4, + CIM_CHARDEV_SOURCE_TYPE_PIPE = 5, + CIM_CHARDEV_SOURCE_TYPE_STDIO = 6, + CIM_CHARDEV_SOURCE_TYPE_UDP = 7, + CIM_CHARDEV_SOURCE_TYPE_TCP = 8, + CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK = 9, + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC = 10, + /* please insert new source types above */ + CIM_CHARDEV_SOURCE_TYPE_INVALIDTYPE, + CIM_CHARDEV_SOURCE_TYPE_UNKNOWN = 32768, +}; + +static inline int chardev_source_type_StrToID(const char *type_str) +{ + int rc = CIM_CHARDEV_SOURCE_TYPE_UNKNOWN; + + if (type_str == NULL) + return rc; + + if (STREQC(type_str, "null")) + rc = CIM_CHARDEV_SOURCE_TYPE_NULL; + else if (STREQC(type_str, "vc")) + rc = CIM_CHARDEV_SOURCE_TYPE_VC; + else if (STREQC(type_str, "pty")) + rc = CIM_CHARDEV_SOURCE_TYPE_PTY; + else if (STREQC(type_str, "dev")) + rc = CIM_CHARDEV_SOURCE_TYPE_DEV; + else if (STREQC(type_str, "file")) + rc = CIM_CHARDEV_SOURCE_TYPE_FILE; + else if (STREQC(type_str, "pipe")) + rc = CIM_CHARDEV_SOURCE_TYPE_PIPE; + else if (STREQC(type_str, "stdio")) + rc = CIM_CHARDEV_SOURCE_TYPE_STDIO; + else if (STREQC(type_str, "udp")) + rc = CIM_CHARDEV_SOURCE_TYPE_UDP; + else if (STREQC(type_str, "tcp")) + rc = CIM_CHARDEV_SOURCE_TYPE_TCP; + else if (STREQC(type_str, "unix")) + rc = CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK; + else if (STREQC(type_str, "spicevmc")) + rc = CIM_CHARDEV_SOURCE_TYPE_SPICEVMC; + + return rc; +} + +static inline const char* chardev_source_type_IDToStr(int type) +{ + char *type_str = NULL; + + switch (type) + { + case CIM_CHARDEV_SOURCE_TYPE_NULL: + type_str = "null"; + break; + case CIM_CHARDEV_SOURCE_TYPE_VC: + type_str = "vc"; + break; + case CIM_CHARDEV_SOURCE_TYPE_PTY: + type_str = "pty"; + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + type_str = "dev"; + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + type_str = "file"; + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + type_str = "pipe"; + break; + case CIM_CHARDEV_SOURCE_TYPE_STDIO: + type_str = "stdio"; + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + type_str = "udp"; + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + type_str = "tcp"; + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + type_str = "unix"; + break; + case CIM_CHARDEV_SOURCE_TYPE_SPICEVMC: + type_str = "spicevmc"; + break; + default: + break; + } + return type_str; +} #endif -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Wed Sep 11 14:45:34 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Wed, 11 Sep 2013 16:45:34 +0200 Subject: [Libvirt-cim] [PATCHv2 0/7] Support for full function consoles Message-ID: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> Motivation: the current libvirt-cim support for consoles is very limited in that it doesn't allow to specify the target and source types supported by libvirt. Having full support of the libvirt console feature is however mandatory for architectures like s390. The current implementation using a Graphics_RASD to represent consoles cannot easily be extended without breaking the existing implementation (or without being entirely unusable). Therefore a new RASD class is added to represent consoles in the model. Since there's no SVPC resource type for a console we use the combination of ResourceType = 1 (Other) and OtherResourceType = "console" for the new RASD instances. In order to be backward compatible, the only console type supported by older libvirt-cim versions (target type 'pty') will still be returned as Graphics_RASD. In the long run, this should be deprecated. V2 Changes: - Squashed old patches 2 and 5 and moved that one to position 4 - Fix double frees - Fix NULL pointer accesses - Improve error handling - Improve error messages - Some cosmetic changes Thilo Boehm (5): schema: New SVPC types for chardev/consoles libxkutil: Console Support RASD: Schema and Provider Support for Console RASDs VSMS: Support for domains with console devices VSMS: add default console Viktor Mihajlovski (2): VSMS: Set resource types for default devices Device: CIM_LogicalDevice for consoles libxkutil/device_parsing.c | 314 ++++++++++++++++++- libxkutil/device_parsing.h | 43 ++- libxkutil/xmlgen.c | 191 ++++++++++- schema/ResourceAllocationSettingData.mof | 246 ++++++++++++++- schema/ResourceAllocationSettingData.registration | 5 +- src/Virt_Device.c | 33 ++ src/Virt_RASD.c | 149 ++++++++- src/Virt_VirtualSystemManagementService.c | 348 +++++++++++++++++++-- src/svpc_types.h | 102 +++++- 9 files changed, 1392 insertions(+), 39 deletions(-) -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Wed Sep 11 14:45:39 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Wed, 11 Sep 2013 16:45:39 +0200 Subject: [Libvirt-cim] [PATCHv2 5/7] Device: CIM_LogicalDevice for consoles In-Reply-To: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378910741-22520-6-git-send-email-mihajlov@linux.vnet.ibm.com> Extended the Virt_Device provider to return DisplayController devices for the consoles found. This mainly for the purpose of consistency with the other RASD types. Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- src/Virt_Device.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/Virt_Device.c b/src/Virt_Device.c index c3b515c..aa47276 100644 --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -251,6 +251,34 @@ static CMPIInstance *graphics_instance(const CMPIBroker *broker, return inst; } +static CMPIInstance *console_instance(const CMPIBroker *broker, + struct console_device *dev, + const virDomainPtr dom, + const char *ns) +{ + CMPIInstance *inst; + virConnectPtr conn; + const char *ctype; + + conn = virDomainGetConnect(dom); + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "DisplayController", + ns, + true); + + if (inst == NULL) { + CU_DEBUG("Failed to get instance for DisplayController"); + return NULL; + } + + ctype = chardev_source_type_IDToStr(dev->source_type); + CMSetProperty(inst, "VideoProcessor", + (CMPIValue *)ctype, CMPI_chars); + + return inst; +} + int get_input_dev_caption(const char *type, const char *bus, char **cap) @@ -483,6 +511,11 @@ static bool device_instances(const CMPIBroker *broker, &dev->dev.graphics, dom, ns); + else if (dev->type == CIM_RES_TYPE_CONSOLE) + instance = console_instance(broker, + &dev->dev.console, + dom, + ns); else if (dev->type == CIM_RES_TYPE_INPUT) instance = input_instance(broker, &dev->dev.input, -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Wed Sep 11 14:45:37 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Wed, 11 Sep 2013 16:45:37 +0200 Subject: [Libvirt-cim] [PATCHv2 3/7] libxkutil: Console Support In-Reply-To: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378910741-22520-4-git-send-email-mihajlov@linux.vnet.ibm.com> From: Thilo Boehm Added data types for the representation of console devices and their source type specific properties. Further, implemented libvirt XML parsing and generation of console device XML. Signed-off-by: Thilo Boehm Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- V2 Changes: - avoid double free in the error path - check NULL in CU_DEBUG libxkutil/device_parsing.c | 314 ++++++++++++++++++++++++++++++++++++++++++-- libxkutil/device_parsing.h | 43 +++++- libxkutil/xmlgen.c | 191 ++++++++++++++++++++++++++- src/svpc_types.h | 5 +- 4 files changed, 541 insertions(+), 12 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index fa9f998..ddd7a30 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007, 2013 * * Authors: * Dan Smith @@ -41,6 +41,11 @@ #define NET_XPATH (xmlChar *)"/domain/devices/interface" #define EMU_XPATH (xmlChar *)"/domain/devices/emulator" #define MEM_XPATH (xmlChar *)"/domain/memory | /domain/currentMemory" +#define CONSOLE_XPATH (xmlChar *)"/domain/devices/console" +/* + * To be backward compatible, serial and console is + * still part of the graphics. + */ #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ "/domain/devices/console | /domain/devices/serial" #define INPUT_XPATH (xmlChar *)"/domain/devices/input" @@ -50,6 +55,11 @@ #define MAX(a,b) (((a)>(b))?(a):(b)) +#define DUP_FIELD(d, s, f) do { \ + if ((s)->f != NULL) \ + (d)->f = strdup((s)->f); \ + } while (0); + /* Device parse function */ typedef int (*dev_parse_func_t)(xmlNode *, struct virt_device **); @@ -133,6 +143,140 @@ static void cleanup_graphics_device(struct graphics_device *dev) free(dev->type); } +static void cleanup_path_device(struct path_device *dev) +{ + if (dev == NULL) + return; + + free(dev->path); + +} + +static void cleanup_unixsock_device(struct unixsock_device *dev) +{ + if (dev == NULL) + return; + + free(dev->path); + free(dev->mode); + +} + +static void cleanup_tcp_device(struct tcp_device *dev) +{ + if (dev == NULL) + return; + + free(dev->mode); + free(dev->protocol); + free(dev->host); + free(dev->service); + +} + +static void cleanup_udp_device(struct udp_device *dev) +{ + if (dev == NULL) + return; + + free(dev->bind_host); + free(dev->bind_service); + free(dev->connect_host); + free(dev->connect_service); +}; + +static void cleanup_console_device(struct console_device *dev) +{ + if (dev == NULL) + return; + + switch (dev->source_type) + { + case CIM_CHARDEV_SOURCE_TYPE_PTY: + cleanup_path_device(&dev->source_dev.pty); + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + cleanup_path_device(&dev->source_dev.dev); + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + cleanup_path_device(&dev->source_dev.file); + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + cleanup_path_device(&dev->source_dev.pipe); + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + cleanup_unixsock_device(&dev->source_dev.unixsock); + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + cleanup_udp_device(&dev->source_dev.udp); + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + cleanup_tcp_device(&dev->source_dev.tcp); + break; + default: + /* Nothing to do for : + CIM_CHARDEV_SOURCE_TYPE_STDIO + CIM_CHARDEV_SOURCE_TYPE_NULL + CIM_CHARDEV_SOURCE_TYPE_VC + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC + */ + break; + } + + dev->source_type = 0; + free(dev->target_type); + memset(&dev->source_dev, 0, sizeof(dev->source_dev)); +}; + +static void console_device_dup(struct console_device *t, + struct console_device *s) +{ + cleanup_console_device(t); + + t->source_type = s->source_type; + DUP_FIELD(t, s, target_type); + + switch (s->source_type) + { + case CIM_CHARDEV_SOURCE_TYPE_PTY: + DUP_FIELD(t, s, source_dev.pty.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + DUP_FIELD(t, s, source_dev.dev.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + DUP_FIELD(t, s, source_dev.file.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + DUP_FIELD(t, s, source_dev.pipe.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + DUP_FIELD(t, s, source_dev.unixsock.path); + DUP_FIELD(t, s, source_dev.unixsock.mode); + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + DUP_FIELD(t, s, source_dev.udp.bind_host); + DUP_FIELD(t, s, source_dev.udp.bind_service); + DUP_FIELD(t, s, source_dev.udp.connect_host); + DUP_FIELD(t, s, source_dev.udp.connect_service); + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + DUP_FIELD(t, s, source_dev.tcp.mode); + DUP_FIELD(t, s, source_dev.tcp.protocol); + DUP_FIELD(t, s, source_dev.tcp.host); + DUP_FIELD(t, s, source_dev.tcp.service); + break; + default: + /* Nothing to do for : + CIM_CHARDEV_SOURCE_TYPE_STDIO + CIM_CHARDEV_SOURCE_TYPE_NULL + CIM_CHARDEV_SOURCE_TYPE_VC + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC + */ + break; + } +} + static void cleanup_input_device(struct input_device *dev) { if (dev == NULL) @@ -157,6 +301,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_graphics_device(&dev->dev.graphics); else if (dev->type == CIM_RES_TYPE_INPUT) cleanup_input_device(&dev->dev.input); + else if (dev->type == CIM_RES_TYPE_CONSOLE) + cleanup_console_device(&dev->dev.console); free(dev->id); @@ -613,6 +759,138 @@ static char *get_attr_value_default(xmlNode *node, char *attrname, return ret; } +static int parse_console_device(xmlNode *node, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct console_device *cdev = NULL; + char *source_type_str = NULL; + char *target_port_ID = NULL; + char *udp_source_mode = NULL; + + xmlNode *child = NULL; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.console); + + source_type_str = get_attr_value(node, "type"); + if (source_type_str == NULL) + goto err; + CU_DEBUG("console device type = %s", source_type_str ? : "NULL"); + + cdev->source_type = chardev_source_type_StrToID(source_type_str); + if (cdev->source_type == CIM_CHARDEV_SOURCE_TYPE_UNKNOWN) + goto err; + + CU_DEBUG("console device type ID = %d", cdev->source_type); + + for (child = node->children; child != NULL; child = child->next) { + if (XSTREQ(child->name, "target")) { + cdev->target_type = get_attr_value(child, "type"); + CU_DEBUG("Console device target type = '%s'", + cdev->target_type ? : "NULL"); + target_port_ID = get_attr_value(child, "port"); + if (target_port_ID == NULL) + goto err; + } + + if (XSTREQ(child->name, "source")) { + switch (cdev->source_type) + { + case CIM_CHARDEV_SOURCE_TYPE_PTY: + cdev->source_dev.pty.path = + get_attr_value(child, "path"); + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + cdev->source_dev.dev.path = + get_attr_value(child, "path"); + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + cdev->source_dev.file.path = + get_attr_value(child, "path"); + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + cdev->source_dev.pipe.path = + get_attr_value(child, "path"); + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + cdev->source_dev.unixsock.mode = + get_attr_value(child, "mode"); + cdev->source_dev.unixsock.path = + get_attr_value(child, "path"); + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + udp_source_mode = get_attr_value(child, "mode"); + if (udp_source_mode == NULL) + goto err; + if (STREQC(udp_source_mode, "bind")) { + cdev->source_dev.udp.bind_host = + get_attr_value(child, "host"); + cdev->source_dev.udp.bind_service = + get_attr_value(child, "service"); + } else if (STREQC(udp_source_mode, "connect")) { + cdev->source_dev.udp.connect_host = + get_attr_value(child, "host"); + cdev->source_dev.udp.connect_service = + get_attr_value(child, "service"); + } else { + CU_DEBUG("unknown udp mode: %s", + udp_source_mode ? : "NULL"); + goto err; + } + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + cdev->source_dev.tcp.mode = + get_attr_value(child, "mode"); + cdev->source_dev.tcp.host = + get_attr_value(child, "host"); + cdev->source_dev.tcp.service = + get_attr_value(child, "service"); + break; + + default: + /* Nothing to do for : + CIM_CHARDEV_SOURCE_TYPE_STDIO + CIM_CHARDEV_SOURCE_TYPE_NULL + CIM_CHARDEV_SOURCE_TYPE_VC + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC + */ + break; + } + } + if ((cdev->source_type == CIM_CHARDEV_SOURCE_TYPE_TCP) + && XSTREQ(child->name, "protocol")) { + cdev->source_dev.tcp.protocol = + get_attr_value(child, "type"); + } + } + + vdev->type = CIM_RES_TYPE_CONSOLE; + + if (asprintf(&vdev->id, "charconsole:%s", target_port_ID) == -1) { + CU_DEBUG("Failed to create charconsole id string"); + goto err; + } + + *vdevs = vdev; + free(source_type_str); + free(target_port_ID); + free(udp_source_mode); + + return 1; + + err: + free(source_type_str); + free(target_port_ID); + free(udp_source_mode); + cleanup_console_device(cdev); + free(vdev); + + return 0; +} + static int parse_graphics_device(xmlNode *node, struct virt_device **vdevs) { struct virt_device *vdev = NULL; @@ -664,8 +942,20 @@ static int parse_graphics_device(xmlNode *node, struct virt_device **vdevs) child = child->next) { if (XSTREQ(child->name, "source")) gdev->dev.vnc.host = get_attr_value(child, "path"); - else if (XSTREQ(child->name, "target")) - gdev->dev.vnc.port = get_attr_value(child, "port"); + else if (XSTREQ(child->name, "target")) { + gdev->dev.vnc.port = + get_attr_value(child, "port"); + /* The graphics pty console can only be a + virtio console. If 'type' is not set in the + xml, the default of libvirt is virtio.*/ + char *t_type = get_attr_value(child, "type"); + if (t_type != NULL && !STREQC(t_type, "virtio")) { + CU_DEBUG("Not a pty-virtio graphics console"); + free(t_type); + goto err; + } + free(t_type); + } } } else { @@ -841,6 +1131,11 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_graphics_device; break; + case CIM_RES_TYPE_CONSOLE: + xpathstr = CONSOLE_XPATH; + func = &parse_console_device; + break; + case CIM_RES_TYPE_INPUT: xpathstr = INPUT_XPATH; func = &parse_input_device; @@ -876,11 +1171,6 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) return count; } -#define DUP_FIELD(d, s, f) do { \ - if ((s)->f != NULL) \ - (d)->f = strdup((s)->f); \ - } while (0); - struct virt_device *virt_device_dup(struct virt_device *_dev) { struct virt_device *dev; @@ -939,8 +1229,10 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_INPUT) { DUP_FIELD(dev, _dev, dev.input.type); DUP_FIELD(dev, _dev, dev.input.bus); + } else if (dev->type == CIM_RES_TYPE_CONSOLE) { + console_device_dup(&dev->dev.console, + &_dev->dev.console); } - return dev; } @@ -1299,6 +1591,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_graphics_ct = parse_devices(xml, &(*dominfo)->dev_graphics, CIM_RES_TYPE_GRAPHICS); + (*dominfo)->dev_console_ct = parse_devices(xml, + &(*dominfo)->dev_console, + CIM_RES_TYPE_CONSOLE); (*dominfo)->dev_input_ct = parse_devices(xml, &(*dominfo)->dev_input, CIM_RES_TYPE_INPUT); @@ -1396,6 +1691,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_vcpu, dom->dev_vcpu_ct); cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); + cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); free(dom); diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 14e49b8..2803d6a 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007, 2013 * * Authors: * Dan Smith @@ -111,6 +111,43 @@ struct graphics_device { } dev; }; +struct path_device { + char *path; +}; + +struct unixsock_device { + char *path; + char *mode; +}; + +struct tcp_device { + char *mode; + char *protocol; + char *host; + char *service; +}; + +struct udp_device { + char *bind_host; + char *bind_service; + char *connect_host; + char *connect_service; +}; + +struct console_device { + uint16_t source_type; + union { + struct path_device file; + struct path_device pty; + struct path_device dev; + struct path_device pipe; + struct unixsock_device unixsock; + struct tcp_device tcp; + struct udp_device udp; + } source_dev; + char *target_type; +}; + struct input_device { char *type; char *bus; @@ -125,6 +162,7 @@ struct virt_device { struct vcpu_device vcpu; struct emu_device emu; struct graphics_device graphics; + struct console_device console; struct input_device input; } dev; char *id; @@ -182,6 +220,9 @@ struct domain { struct virt_device *dev_graphics; int dev_graphics_ct; + struct virt_device *dev_console; + int dev_console_ct; + struct virt_device *dev_emu; struct virt_device *dev_input; diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 2ca2341..45bfb04 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007, 2013 * * Authors: * Dan Smith @@ -42,6 +42,189 @@ typedef const char *(*devfn_t)(xmlNodePtr node, struct domain *dominfo); typedef const char *(*poolfn_t)(xmlNodePtr node, struct virt_pool *pool); typedef const char *(*resfn_t)(xmlNodePtr node, struct virt_pool_res *res); +static int _count_graphics_console_definitions(struct domain *dominfo) +{ + int i; + int num = 0; + + for (i = 0; i < dominfo->dev_graphics_ct; i++) { + struct virt_device *_dev = &dominfo->dev_graphics[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct graphics_device *dev = &_dev->dev.graphics; + + if (STREQC(dev->type, "console")) { + num++; + } + } + CU_DEBUG("Found %d console defintions in graphics devices.",num); + return num; + +} + +static const char *console_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + xmlNodePtr console; + xmlNodePtr tmp; + int num_graphics_consol_def = 0; + int num_suppressed_console_def = 0; + + num_graphics_consol_def = _count_graphics_console_definitions(dominfo); + + for (i = 0; i < dominfo->dev_console_ct; i++) { + struct virt_device *_dev = &dominfo->dev_console[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct console_device *cdev = &_dev->dev.console; + + /* Due to backward compatibility, the graphics device handling + is still parsing consoles: + source = pty, target = virtio (which is the default target) + But the console device handling processes these kind of + consoles too. This would lead to a duplication of these + default consoles in the domain xml definition. + This code prevents the console handling of writing xml for + duplicate pty/virtio consoles which are written by the + graphics device handling. */ + if (cdev->source_type == CIM_CHARDEV_SOURCE_TYPE_PTY && + (cdev->target_type == NULL || + STREQC(cdev->target_type, "virtio"))) { + if (num_suppressed_console_def < + num_graphics_consol_def) { + num_suppressed_console_def++; + continue; + } + } + + console = xmlNewChild(root, NULL, BAD_CAST "console", NULL); + if (console == NULL) + return XML_ERROR; + + xmlNewProp(console, BAD_CAST "type", + BAD_CAST + chardev_source_type_IDToStr(cdev->source_type)); + + switch (cdev->source_type) { + case CIM_CHARDEV_SOURCE_TYPE_PTY: + /* The path property is not mandatory */ + if (cdev->source_dev.pty.path) { + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "path", + BAD_CAST cdev->source_dev.pty.path); + } + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "path", + BAD_CAST cdev->source_dev.dev.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "path", + BAD_CAST cdev->source_dev.file.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "path", + BAD_CAST cdev->source_dev.pipe.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "mode", + BAD_CAST cdev->source_dev.unixsock.mode); + xmlNewProp(tmp, BAD_CAST "path", + BAD_CAST cdev->source_dev.unixsock.path); + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "mode", BAD_CAST "bind"); + xmlNewProp(tmp, BAD_CAST "host", + BAD_CAST cdev->source_dev.udp.bind_host); + /* The service property is not mandatory */ + if (cdev->source_dev.udp.bind_service) + xmlNewProp(tmp, BAD_CAST "service", + BAD_CAST + cdev->source_dev.udp.bind_service); + + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "mode", BAD_CAST "connect"); + xmlNewProp(tmp, BAD_CAST "host", + BAD_CAST cdev->source_dev.udp.connect_host); + /* The service property is not mandatory */ + if (cdev->source_dev.udp.connect_service) + xmlNewProp(tmp, BAD_CAST "service", + BAD_CAST + cdev->source_dev.udp.connect_service); + + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + tmp = xmlNewChild(console, NULL, + BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "mode", + BAD_CAST cdev->source_dev.tcp.mode); + xmlNewProp(tmp, BAD_CAST "host", + BAD_CAST cdev->source_dev.tcp.host); + if (cdev->source_dev.tcp.service) + xmlNewProp(tmp, BAD_CAST "service", + BAD_CAST + cdev->source_dev.tcp.service); + if (cdev->source_dev.tcp.protocol) { + tmp = xmlNewChild(console, NULL, + BAD_CAST "protocol", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "type", + BAD_CAST cdev->source_dev.tcp.protocol); + } + break; + default: + /* Nothing to do for : + CIM_CHARDEV_SOURCE_TYPE_STDIO + CIM_CHARDEV_SOURCE_TYPE_NULL + CIM_CHARDEV_SOURCE_TYPE_VC + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC + */ + break; + } + + if (cdev->target_type) { + tmp = xmlNewChild(console, NULL, + BAD_CAST "target", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "type", + BAD_CAST cdev->target_type); + } + } + return NULL; +} + static char *disk_block_xml(xmlNodePtr root, struct disk_device *dev) { xmlNodePtr disk; @@ -977,6 +1160,11 @@ char *device_to_xml(struct virt_device *_dev) dominfo->dev_graphics_ct = 1; dominfo->dev_graphics = dev; break; + case CIM_RES_TYPE_CONSOLE: + func = console_xml; + dominfo->dev_console_ct = 1; + dominfo->dev_console = dev; + break; case CIM_RES_TYPE_INPUT: func = input_xml; dominfo->dev_input_ct = 1; @@ -1017,6 +1205,7 @@ char *system_to_xml(struct domain *dominfo) &disk_xml, &net_xml, &input_xml, + &console_xml, &graphics_xml, &emu_xml, NULL diff --git a/src/svpc_types.h b/src/svpc_types.h index 2e4d73f..0f46a86 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -25,6 +25,7 @@ #define CIM_OPERATIONAL_STATUS 2 #define CIM_RES_TYPE_ALL 0 +#define CIM_RES_TYPE_OTHER 1 #define CIM_RES_TYPE_PROC 3 #define CIM_RES_TYPE_MEM 4 #define CIM_RES_TYPE_NET 10 @@ -34,8 +35,9 @@ #define CIM_RES_TYPE_INPUT 13 #define CIM_RES_TYPE_UNKNOWN 1000 #define CIM_RES_TYPE_IMAGE 32768 +#define CIM_RES_TYPE_CONSOLE 32769 -#define CIM_RES_TYPE_COUNT 6 +#define CIM_RES_TYPE_COUNT 7 const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, @@ -43,6 +45,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = CIM_RES_TYPE_PROC, CIM_RES_TYPE_GRAPHICS, CIM_RES_TYPE_INPUT, + CIM_RES_TYPE_CONSOLE, }; #define CIM_VSSD_RECOVERY_NONE 2 -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Wed Sep 11 14:45:35 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Wed, 11 Sep 2013 16:45:35 +0200 Subject: [Libvirt-cim] [PATCHv2 1/7] VSMS: Set resource types for default devices In-Reply-To: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378910741-22520-2-git-send-email-mihajlov@linux.vnet.ibm.com> The default graphics and input devices were built without their resource types being set correctly. This has not hurted yet. Future changes will however require that the device resource type is matching the actual device type. Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- src/Virt_VirtualSystemManagementService.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 79dec73..6629b35 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -581,6 +581,7 @@ static bool default_graphics_device(struct domain *domain) return false; } + domain->dev_graphics->type = CIM_RES_TYPE_GRAPHICS; domain->dev_graphics->dev.graphics.type = strdup("vnc"); domain->dev_graphics->dev.graphics.dev.vnc.port = strdup("-1"); domain->dev_graphics->dev.graphics.dev.vnc.host = strdup("127.0.0.1"); @@ -609,6 +610,7 @@ static bool default_input_device(struct domain *domain) return false; } + domain->dev_input->type = CIM_RES_TYPE_INPUT; domain->dev_input->dev.input.type = strdup("mouse"); if (domain->type == DOMAIN_XENPV) { -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Wed Sep 11 14:45:41 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Wed, 11 Sep 2013 16:45:41 +0200 Subject: [Libvirt-cim] [PATCHv2 7/7] VSMS: add default console In-Reply-To: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378910741-22520-8-git-send-email-mihajlov@linux.vnet.ibm.com> From: Thilo Boehm A new function to add a default console has been added. As with the default graphics and default input device, the default device generation is optional and depends on the domain type and architecture. Initially, we only create an s390 console, which is necessary to define a runnable guest. Signed-off-by: Thilo Boehm Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- src/Virt_VirtualSystemManagementService.c | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 67dd3f2..d556086 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -592,6 +592,38 @@ static bool default_graphics_device(struct domain *domain) return true; } +static bool default_console_device(struct domain *domain) +{ + /* currently only taking care for s390 guests */ + if ((domain->type == DOMAIN_KVM || domain->type == DOMAIN_QEMU) && + domain->os_info.fv.arch != NULL && + (XSTREQ(domain->os_info.fv.arch, "s390") || + XSTREQ(domain->os_info.fv.arch, "s390x" ))) { + char * consoletype = NULL; + if (domain->os_info.fv.machine != NULL && + XSTREQ(domain->os_info.fv.machine, "s390-ccw-virtio")) { + consoletype = "sclp"; + } else { + consoletype = "virtio"; + } + free(domain->dev_console); + domain->dev_console = calloc(1, sizeof(*domain->dev_console)); + if (domain->dev_console == NULL) { + CU_DEBUG("Failed to allocate default console device."); + return false; + } + CU_DEBUG("Defining default console device for s390."); + domain->dev_console->type = CIM_RES_TYPE_CONSOLE; + domain->dev_console->dev.console.source_type = + CIM_CHARDEV_SOURCE_TYPE_PTY; + domain->dev_console->dev.console.target_type = + strdup(consoletype); + domain->dev_console_ct = 1; + } + + return true; +} + static bool default_input_device(struct domain *domain) { if (domain->type == DOMAIN_LXC) @@ -628,6 +660,8 @@ static bool add_default_devs(struct domain *domain) { if (domain->dev_graphics_ct < 1 && domain->dev_console_ct < 1) { + if (!default_console_device(domain)) + return false; if (!default_graphics_device(domain)) return false; } -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Wed Sep 11 14:45:40 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Wed, 11 Sep 2013 16:45:40 +0200 Subject: [Libvirt-cim] [PATCHv2 6/7] VSMS: Support for domains with console devices In-Reply-To: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378910741-22520-7-git-send-email-mihajlov@linux.vnet.ibm.com> From: Thilo Boehm An instance of KVM_ConsoleResourceAllocationSettingData can be added to domain specification for VSMS DefineSystem() to define a console for a domain. A console definition can not be modified or deleted. It only can be added at system definition and deleted at system deletion. If a KVM_ConsoleRASD is specified on a system definition, no default graphics adapter definition is done. Signed-off-by: Thilo Boehm Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- V2 Changes - Fix realloc error handling - Improve error message - Check for NULL pointers before passing to STREQC and CU_DEBUG - Fix uin16_t usage - Fix a few whitespace issues src/Virt_VirtualSystemManagementService.c | 312 ++++++++++++++++++++++++++--- 1 file changed, 289 insertions(+), 23 deletions(-) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 6629b35..67dd3f2 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007, 2013 * * Authors: * Dan Smith @@ -626,7 +626,8 @@ static bool default_input_device(struct domain *domain) static bool add_default_devs(struct domain *domain) { - if (domain->dev_graphics_ct < 1) { + if (domain->dev_graphics_ct < 1 && + domain->dev_console_ct < 1) { if (!default_graphics_device(domain)) return false; } @@ -1339,47 +1340,292 @@ static int parse_sdl_address(const char *id, return ret; } -static int parse_vnc_address(const char *id, - char **ip, - char **port) +static int parse_ip_address(const char *id, + char **ip, + char **port) { int ret; char *tmp_ip = NULL; char *tmp_port = NULL; - CU_DEBUG("Entering parse_vnc_address, address is %s", id); + CU_DEBUG("Entering parse_ip_address, address is %s", id); if (strstr(id, "[") != NULL) { /* its an ipv6 address */ ret = sscanf(id, "%a[^]]]:%as", &tmp_ip, &tmp_port); - strcat(tmp_ip, "]"); + if (tmp_ip != NULL) { + tmp_ip = realloc(tmp_ip, strlen(tmp_ip) + 2); + if (tmp_ip != NULL) { + strcat(tmp_ip, "]"); + } + } } else { ret = sscanf(id, "%a[^:]:%as", &tmp_ip, &tmp_port); } - if (ret != 2) { + /* ret == 2: address and port, ret == 1: address only */ + if (ret < 1) { ret = 0; goto out; } - if (ip) + if (ip) { *ip = strdup(tmp_ip); + CU_DEBUG("IP = '%s'",*ip); + } - if (port) + if (port && tmp_port) { *port = strdup(tmp_port); - - ret = 1; + CU_DEBUG("Port = '%s'",*port); + } out: - if (ip && port) - CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", - *ip, *port); - free(tmp_ip); free(tmp_port); return ret; } +static bool parse_console_url(const char *url, + char **protocol, + char **host, + char **port) +{ + bool success = false; + char *tmp_protocol = NULL; + char *tmp_address = NULL; + + CU_DEBUG("Entering parse_console_url:'%s'", url); + + if (sscanf(url,"%a[^:]://%as", &tmp_protocol, &tmp_address) != 2) + goto out; + + if (parse_ip_address(tmp_address, host, port) < 1) + goto out; + + if (protocol) { + *protocol = strdup(tmp_protocol); + CU_DEBUG("Protocol = '%s'", *protocol); + } + + success = true; + + out: + free(tmp_protocol); + free(tmp_address); + + return success; +} + +static const char *_unixsock_console_rasd_to_vdev(CMPIInstance *inst, + struct console_device *cdev) +{ + const char *val = NULL; + const char *val2 = NULL; + char* protocol = NULL; + + cdev->source_dev.unixsock.mode = NULL; + if (cu_get_str_prop(inst,"ConnectURL", &val) == CMPI_RC_OK) { + CU_DEBUG("ConnectURL = '%s'", val); + cdev->source_dev.unixsock.mode = strdup("connect"); + } + + if (cu_get_str_prop(inst, "BindURL", &val2) == CMPI_RC_OK) { + if (cdev->source_dev.unixsock.mode != NULL) + return "ConsoleRASD: Only one of ConnectURL or BindURL " + "is allowed for UNIX domain sockets."; + CU_DEBUG("BindURL = '%s'", val2); + cdev->source_dev.unixsock.mode = strdup("bind"); + val = val2; + } + + if (val) { + if (!parse_console_url(val, &protocol, &cdev->source_dev.unixsock.path, NULL)) + return "ConsoleRASD: Invalid ConnectURL or BindURL for " + "UNIX domain socket client/server."; + + if (protocol != NULL && !STREQC("file", protocol)) { + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'", protocol); + free(protocol); + return "ConsoleRASD: Protocol 'file' was not specified for " + "ConnectURL or BindURL for UNIX domain socket client/server."; + } + free(protocol); + } else { + return "ConsoleRASD: ConnectURL or BindURL not specified for " + "UNIX domain socket client/server."; + } + + return NULL; +} + +static const char *_udp_console_rasd_to_vdev(CMPIInstance *inst, + struct console_device *cdev) +{ + const char *val = NULL; + char* protocol = NULL; + + if (cu_get_str_prop(inst, "ConnectURL", &val) != CMPI_RC_OK) + return "ConsoleRASD: ConnectURL not specified for UDP network console."; + + if (!parse_console_url(val, &protocol, + &cdev->source_dev.udp.connect_host, + &cdev->source_dev.udp.connect_service)) + return "ConsoleRASD: Invalid ConnectURL specified for UDP network console."; + + if (protocol != NULL && !STREQC("udp", protocol)) { + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'", protocol); + free(protocol); + return "ConsoleRASD: Protocol 'udp' was not specified at " + "ConnectURL for UDP network console."; + } + + free(protocol); + + if (cu_get_str_prop(inst, "BindURL", &val) != CMPI_RC_OK) + return "ConsoleRASD: BindURL not specified for UDP network console."; + + if (!parse_console_url(val, &protocol, + &cdev->source_dev.udp.bind_host, + &cdev->source_dev.udp.bind_service)) + return "ConsoleRASD: Invalid BindURL specified for UDP network console."; + + if (protocol != NULL && !STREQC("udp", protocol)) { + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'", protocol); + free(protocol); + return "ConsoleRASD: Protocol 'udp' was not specified at BindURL " + "for UDP network console."; + } + + free(protocol); + return NULL; +} + +static const char *_tcp_console_rasd_to_vdev(CMPIInstance *inst, + struct console_device *cdev) +{ + const char *val = NULL; + const char *val2 = NULL; + + cdev->source_dev.tcp.mode = NULL; + if (cu_get_str_prop(inst, "ConnectURL", &val) == CMPI_RC_OK) { + CU_DEBUG("ConnectURL = '%s'", val); + cdev->source_dev.tcp.mode = strdup("connect"); + } + + if (cu_get_str_prop(inst, "BindURL", &val2) == CMPI_RC_OK) { + if (cdev->source_dev.tcp.mode != NULL) + return "ConsoleRASD: Only one of ConnectURL or BindURL " + "is allowed for TCP sockets."; + CU_DEBUG("BindURL = '%s'", val2); + cdev->source_dev.tcp.mode = strdup("bind"); + val = val2; + } + + if (val) { + if (!parse_console_url(val, + &cdev->source_dev.tcp.protocol, + &cdev->source_dev.tcp.host, + &cdev->source_dev.tcp.service)) + return "ConsoleRASD: Invalid ConnectURL or BindURL for " + "TCP client/server console."; + if (cdev->source_dev.tcp.service == NULL) + return "ConsoleRASD: Missing TCP port for TCP client/server console."; + } else { + return "ConsoleRASD: ConnectURL or BindURL not specified for " + "TCP client/server console."; + } + + if (cdev->source_dev.tcp.protocol != NULL) { + if (STREQC("udp", cdev->source_dev.tcp.protocol)) { + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'", + cdev->source_dev.tcp.protocol); + return "ConsoleRASD: Invalid protocol 'udp' was specified at " + "TCP client/server console."; + } else if (STREQC("file", cdev->source_dev.tcp.protocol)) { + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'", + cdev->source_dev.tcp.protocol); + return "ConsoleRASD: Invalid protocol 'file' was specified at " + "TCP client/server console."; + } + } + + return NULL; +} + +static const char *console_rasd_to_vdev(CMPIInstance *inst, + struct virt_device *dev) +{ + int rc = 0; + const char *msg = NULL; + const char *val = NULL; + struct console_device *cdev = &dev->dev.console; + uint16_t tmp; + + rc = cu_get_u16_prop(inst, "SourceType", &tmp); + if (rc != CMPI_RC_OK) + return "ConsoleRASD: SourceType field not specified."; + + if (tmp >= CIM_CHARDEV_SOURCE_TYPE_INVALIDTYPE) + return "ConsoleRASD: Invalid SourceType value"; + + cdev->source_type = tmp; + CU_DEBUG("Processing SourceType: %d", cdev->source_type); + + /* property not required */ + if (cu_get_str_prop(inst, "TargetType", &val) == CMPI_RC_OK) + cdev->target_type = strdup(val); + CU_DEBUG("TargetType is '%s'", cdev->target_type ? : "NULL" ); + + switch (cdev->source_type) { + case CIM_CHARDEV_SOURCE_TYPE_PTY: + /* property not required */ + if (cu_get_str_prop(inst, "SourcePath", &val) == CMPI_RC_OK) + cdev->source_dev.pty.path = strdup(val); + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + if (cu_get_str_prop(inst, "SourcePath", &val) != CMPI_RC_OK) + return "ConsoleRASD: SourcePath not specified for Host device proxy."; + cdev->source_dev.dev.path = strdup(val); + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + if (cu_get_str_prop(inst, "SourcePath", &val) != CMPI_RC_OK) + return "ConsoleRASD: SourcePath not specified for Device logfile."; + cdev->source_dev.file.path = strdup(val); + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + if (cu_get_str_prop(inst, "SourcePath", &val) != CMPI_RC_OK) + return "ConsoleRASD: SourcePath not specified for Named pipe."; + cdev->source_dev.pipe.path = strdup(val); + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + msg = _unixsock_console_rasd_to_vdev(inst, cdev); + if (msg != NULL) + return msg; + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + msg = _udp_console_rasd_to_vdev(inst, cdev); + if (msg != NULL) + return msg; + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + msg = _tcp_console_rasd_to_vdev(inst, cdev); + if (msg != NULL) + return msg; + break; + + default: + /* Nothing to do for : + CIM_CHARDEV_SOURCE_TYPE_STDIO + CIM_CHARDEV_SOURCE_TYPE_NULL + CIM_CHARDEV_SOURCE_TYPE_VC + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC + */ + break; + } + + return NULL; +} + static const char *graphics_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev) { @@ -1394,7 +1640,7 @@ static const char *graphics_rasd_to_vdev(CMPIInstance *inst, } dev->dev.graphics.type = strdup(val); - CU_DEBUG("graphics type = %s", dev->dev.graphics.type); + CU_DEBUG("graphics type = %s", dev->dev.graphics.type ? : "NULL"); /* FIXME: Add logic to prevent address:port collisions */ if (STREQC(dev->dev.graphics.type, "vnc")) { @@ -1411,10 +1657,10 @@ static const char *graphics_rasd_to_vdev(CMPIInstance *inst, val = "127.0.0.1:-1"; } - ret = parse_vnc_address(val, + ret = parse_ip_address(val, &dev->dev.graphics.dev.vnc.host, &dev->dev.graphics.dev.vnc.port); - if (ret != 1) { + if (ret != 2) { msg = "GraphicsRASD field Address not valid"; goto out; } @@ -1540,6 +1786,8 @@ static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, return proc_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_GRAPHICS) { return graphics_rasd_to_vdev(inst, dev); + } else if (type == CIM_RES_TYPE_CONSOLE) { + return console_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_INPUT) { return input_rasd_to_vdev(inst, dev); } @@ -1601,7 +1849,7 @@ static const char *rasd_to_vdev(CMPIInstance *inst, return msg; } -static char *add_device_nodup(struct virt_device *dev, +static const char *add_device_nodup(struct virt_device *dev, struct virt_device *list, int max, int *index) @@ -1663,6 +1911,9 @@ static const char *classify_resources(CMPIArray *resources, if (!make_space(&domain->dev_graphics, domain->dev_graphics_ct, count)) return "Failed to alloc graphics list"; + if (!make_space(&domain->dev_console, domain->dev_console_ct, count)) + return "Failed to alloc console list"; + if (!make_space(&domain->dev_input, domain->dev_input_ct, count)) return "Failed to alloc input list"; @@ -1765,6 +2016,14 @@ static const char *classify_resources(CMPIArray *resources, domain->dev_graphics, gcount, &domain->dev_graphics_ct); + } else if (type == CIM_RES_TYPE_CONSOLE) { + msg = rasd_to_vdev(inst, + domain, + &domain->dev_console[domain->dev_console_ct], + ns, + p_error); + if (msg == NULL) + domain->dev_console_ct+=1; } else if (type == CIM_RES_TYPE_INPUT) { domain->dev_input_ct = 1; msg = rasd_to_vdev(inst, @@ -2570,6 +2829,9 @@ static struct virt_device **find_list(struct domain *dominfo, } else if (type == CIM_RES_TYPE_GRAPHICS) { list = &dominfo->dev_graphics; *count = &dominfo->dev_graphics_ct; + } else if (type == CIM_RES_TYPE_CONSOLE) { + list = &dominfo->dev_console; + *count = &dominfo->dev_console_ct; } else if (type == CIM_RES_TYPE_INPUT) { list = &dominfo->dev_input; *count = &dominfo->dev_input_ct; @@ -2693,7 +2955,8 @@ static CMPIStatus resource_del(struct domain *dominfo, if (STREQ(dev->id, devid)) { if ((type == CIM_RES_TYPE_GRAPHICS) || - (type == CIM_RES_TYPE_INPUT)) + (type == CIM_RES_TYPE_CONSOLE) || + (type == CIM_RES_TYPE_INPUT)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else { s = _resource_dynamic(dominfo, @@ -2774,7 +3037,9 @@ static CMPIStatus resource_add(struct domain *dominfo, goto out; } - if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT)) { + if ((type == CIM_RES_TYPE_GRAPHICS) || + (type == CIM_RES_TYPE_INPUT) || + (type == CIM_RES_TYPE_CONSOLE)) { (*count)++; cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); goto out; @@ -2850,7 +3115,8 @@ static CMPIStatus resource_mod(struct domain *dominfo, } if ((type == CIM_RES_TYPE_GRAPHICS) || - (type == CIM_RES_TYPE_INPUT)) + (type == CIM_RES_TYPE_INPUT) || + (type == CIM_RES_TYPE_CONSOLE)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else { #if LIBVIR_VERSION_NUMBER < 9000 -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Wed Sep 11 14:45:38 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Wed, 11 Sep 2013 16:45:38 +0200 Subject: [Libvirt-cim] [PATCHv2 4/7] RASD: Schema and Provider Support for Console RASDs In-Reply-To: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1378910741-22520-5-git-send-email-mihajlov@linux.vnet.ibm.com> From: Thilo Boehm Representing console devices was very limited with the previous approach using a special graphical display. For instance it was not possible to define different target types (serial, virtio, sclp) nor to exploit all source types (pty, file, tcp, ...) available in libvirt. With the following new RASD classes it is possible to define real console resources: KVM_ConsoleResouceAllocationSettingData Xen_ConsoleResouceAllocationSettingData LXC_ConsoleResouceAllocationSettingData The ResourceType of the returned instances is is '1' (Other) and the OtherResourceType is 'console'. Implemented CIM operations: enumerate instances enumerate instance names get instance Signed-off-by: Thilo Boehm Signed-off-by: Viktor Mihajlovski Reviewed-by: Boris Fiuczynski --- V2 Changes - squash schema and provider patch into one - check for NULL strings before using STREQC - reformat comparisons where the constant is on the left hand side schema/ResourceAllocationSettingData.mof | 246 ++++++++++++++++++++- schema/ResourceAllocationSettingData.registration | 5 +- src/Virt_RASD.c | 149 ++++++++++++- 3 files changed, 397 insertions(+), 3 deletions(-) diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index 871ab04..ebc4806 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2007 +// Copyright IBM Corp. 2007, 2013 [Description ("Xen virtual disk configuration"), Provider("cmpi::Virt_RASD") @@ -445,3 +445,247 @@ class KVM_StorageVolumeResourceAllocationSettingData : KVM_ResourceAllocationSet string AllocationUnits; }; +[Description ("KVM virtual character device"), + Provider("cmpi::Virt_RASD") +] +class KVM_CharacterResourceAllocationSettingData : KVM_ResourceAllocationSettingData +{ + [Description ("The type of resource in the source/host environment."), + ValueMap {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, + Values {"null", "vc", "pty", "dev", "file", "pipe", + "stdio", "udp", "tcp", "unix", "spicevmc"}, + ModelCorrespondence {"KVM_CharacterResourceAllocationSettingData.SourcePath", + "KVM_CharacterResourceAllocationSettingData.ConnectURL", + "KVM_CharacterResourceAllocationSettingData.BindURL"}] + uint16 SourceType; + + [Description ("If SourceType=4 ('file'),this is the full qualified file path. " + "The file is opened and all data sent to the character device " + "is written to the file. " + "If SourceType=2 ('pty'),this is the full qualified Pseudo TTY path. " + "A Pseudo TTY is allocated using /dev/ptmx. " + "If SourceType=3 ('dev'), this is the full qualified file path " + "to the underlying phsical character device. The device types must " + "match, eg the emulated serial port should only be connected to a " + "host serial port - don't connect a serial port to a parallel port. " + "If SourceType=5 ('pipe'), this is the full qualified file path " + "of a named pipe."), + ModelCorrespondence {"KVM_CharacterResourceAllocationSettingData.SourceType"}] + string SourcePath; + + [Description ("This URL describes the connection to a remote or local location " + "where the character devices acts as a client." + "To use a literal IPv6 address in the URI, the literal address should be " + "enclosed in '[' and ']' characters. " + "If SourceType=7 ('udp'), this is defines a udp remote host and port connection " + "to send packages. That the character device acts as a UDP netconsole service, " + "sending and receiving packets, the BindURL property must also be defined. " + "This is a lossy service. " + "Only 'udp' is valid for the protocol part of the URI. " + "Format of the URL: ://:. e.g. udp://0.0.0.0:2245 " + "If SourceType=8 ('tcp'), this is defines a remote host and port connection. " + "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. " + "Format of the URL: ://:. e.g. raw://[3ffe:2a00:100:7031::1]:2245 " + "If SourceType=9 ('unix'), this is defined the full qualified file path " + "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. " + "Format of the URL: file://. " + "e.g. file:///tmp/console-out"), + ModelCorrespondence {"KVM_CharacterResourceAllocationSettingData.SourceType"}] + string ConnectURL; + + [Description ("This URL describes the connection to a remote or local location " + "where the character devices acts as a server. " + "To use a literal IPv6 address in the URI, the literal address should be " + "enclosed in '[' and ']' characters. " + "If SourceType=7 ('udp'), this is defines a udp remote host and port connection " + "to receive packages. That the character device acts as a UDP netconsole service, " + "sending and receiving packets, the ConnectURL property must also be defined. " + "This is a lossy service. " + "Only 'udp' is valid for the protocol part of the URI. " + "Format of the URL: ://:. e.g. udp://0.0.0.0:2245 " + "If SourceType=8 ('tcp'), this is defines a remote host and port connection. " + "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. " + "Format of the URL: ://:. e.g. raw://[3ffe:2a00:100:7031::1]:2245 " + "If SourceType=9 ('unix'), this is defined the full qualified file path " + "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. " + "Format of the URL: file://. " + "e.g. file:///tmp/console-in"), + ModelCorrespondence {"KVM_CharacterResourceAllocationSettingData.SourceType"}] + string BindURL; +}; + + +[Description ("KVM virtual console device. It is identified by: " + "CIM_ResourceAllocationSettingData.ResourceType=1 ( 'Other' ) and " + "CIM_ResourceAllocationSettingData.OtherResourceType='console'"), + Provider("cmpi::Virt_RASD") +] +class KVM_ConsoleResourceAllocationSettingData : KVM_CharacterResourceAllocationSettingData +{ + [Description ("The type of the console in the target/guest environment.")] + string TargetType; +}; + + + +[Description ("Xen virtual character device"), + Provider("cmpi::Virt_RASD") +] +class Xen_CharacterResourceAllocationSettingData : Xen_ResourceAllocationSettingData +{ + [Description ("The type of resource in the source/host environment."), + ValueMap {"0","1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, + Values {"null", "vc", "pty", "dev", "file", "pipe", + "stdio", "udp", "tcp", "unix", "spicevmc"}, + ModelCorrespondence {"Xen_CharacterResourceAllocationSettingData.SourcePath", + "Xen_CharacterResourceAllocationSettingData.ConnectURL", + "Xen_CharacterResourceAllocationSettingData.BindURL"}] + uint16 SourceType; + + [Description ("If SourceType=4 ('file'),this is the full qualified file path. " + "The file is opened and all data sent to the character device " + "is written to the file. " + "If SourceType=2 ('pty'),this is the full qualified Pseudo TTY path. " + "A Pseudo TTY is allocated using /dev/ptmx. " + "If SourceType=3 ('dev'), this is the full qualified file path " + "to the underlying phsical character device. The device types must " + "match, eg the emulated serial port should only be connected to a " + "host serial port - don't connect a serial port to a parallel port. " + "If SourceType=5 ('pipe'), this is the full qualified file path " + "of a named pipe."), + ModelCorrespondence {"Xen_CharacterResourceAllocationSettingData.SourceType"}] + string SourcePath; + + [Description ("This URL describes the connection to a remote or local location " + "where the character devices acts as a client." + "To use a literal IPv6 address in the URI, the literal address should be " + "enclosed in '[' and ']' characters. " + "If SourceType=7 ('udp'), this is defines a udp remote host and port connection " + "to send packages. That the character device acts as a UDP netconsole service, " + "sending and receiving packets, the BindURL property must also be defined. " + "This is a lossy service. " + "Only 'udp' is valid for the protocol part of the URI. " + "Format of the URL: ://:. e.g. udp://0.0.0.0:2245 " + "If SourceType=8 ('tcp'), this is defines a remote host and port connection. " + "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. " + "Format of the URL: ://:. e.g. raw://[3ffe:2a00:100:7031::1]:2245 " + "If SourceType=9 ('unix'), this is defined the full qualified file path " + "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. " + "Format of the URL: file://. " + "e.g. file:///tmp/console-out"), + ModelCorrespondence {"Xen_CharacterResourceAllocationSettingData.SourceType"}] + string ConnectURL; + + [Description ("This URL describes the connection to a remote or local location " + "where the character devices acts as a server. " + "To use a literal IPv6 address in the URI, the literal address should be " + "enclosed in '[' and ']' characters. " + "If SourceType=7 ('udp'), this is defines a udp remote host and port connection " + "to receive packages. That the character device acts as a UDP netconsole service, " + "sending and receiving packets, the ConnectURL property must also be defined. " + "This is a lossy service. " + "Only 'udp' is valid for the protocol part of the URI. " + "Format of the URL: ://:. e.g. udp://0.0.0.0:2245 " + "If SourceType=8 ('tcp'), this is defines a remote host and port connection. " + "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. " + "Format of the URL: ://:. e.g. raw://[3ffe:2a00:100:7031::1]:2245 " + "If SourceType=9 ('unix'), this is defined the full qualified file path " + "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. " + "Format of the URL: file://. " + "e.g. file:///tmp/console-in"), + ModelCorrespondence {"Xen_CharacterResourceAllocationSettingData.SourceType"}] + string BindURL; +}; + + +[Description ("Xen virtual console device. It is identified by: " + "CIM_ResourceAllocationSettingData.ResourceType=1 ( 'Other' ) and " + "CIM_ResourceAllocationSettingData.OtherResourceType='console'"), + Provider("cmpi::Virt_RASD") +] +class Xen_ConsoleResourceAllocationSettingData : Xen_CharacterResourceAllocationSettingData +{ + [Description ( "The type of the console in the target/guest environment.")] + string TargetType; +}; + +[Description ("LXC virtual character device"), + Provider("cmpi::Virt_RASD") +] +class LXC_CharacterResourceAllocationSettingData : LXC_ResourceAllocationSettingData +{ + [Description ("The type of resource in the source/host environment."), + ValueMap {"0","1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, + Values {"null", "vc", "pty", "dev", "file", "pipe", + "stdio", "udp", "tcp", "unix", "spicevmc"}, + ModelCorrespondence {"LXC_CharacterResourceAllocationSettingData.SourcePath", + "LXC_CharacterResourceAllocationSettingData.ConnectURL", + "LXC_CharacterResourceAllocationSettingData.BindURL"}] + uint16 SourceType; + + [Description ("If SourceType=4 ('file'),this is the full qualified file path. " + "The file is opened and all data sent to the character device " + "is written to the file. " + "If SourceType=2 ('pty'),this is the full qualified Pseudo TTY path. " + "A Pseudo TTY is allocated using /dev/ptmx. " + "If SourceType=3 ('dev'), this is the full qualified file path " + "to the underlying phsical character device. The device types must " + "match, eg the emulated serial port should only be connected to a " + "host serial port - don't connect a serial port to a parallel port. " + "If SourceType=5 ('pipe'), this is the full qualified file path " + "of a named pipe."), + ModelCorrespondence {"LXC_CharacterResourceAllocationSettingData.SourceType"}] + string SourcePath; + + [Description ("This URL describes the connection to a remote or local location " + "where the character devices acts as a client." + "To use a literal IPv6 address in the URI, the literal address should be " + "enclosed in '[' and ']' characters. " + "If SourceType=7 ('udp'), this is defines a udp remote host and port connection " + "to send packages. That the character device acts as a UDP netconsole service, " + "sending and receiving packets, the BindURL property must also be defined. " + "This is a lossy service. " + "Only 'udp' is valid for the protocol part of the URI. " + "Format of the URL: ://:. e.g. udp://0.0.0.0:2245 " + "If SourceType=8 ('tcp'), this is defines a remote host and port connection. " + "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. " + "Format of the URL: ://:. e.g. raw://[3ffe:2a00:100:7031::1]:2245 " + "If SourceType=9 ('unix'), this is defined the full qualified file path " + "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. " + "Format of the URL: file://. " + "e.g. file:///tmp/console-out"), + ModelCorrespondence {"LXC_CharacterResourceAllocationSettingData.SourceType"}] + string ConnectURL; + + [Description ("This URL describes the connection to a remote or local location " + "where the character devices acts as a server. " + "To use a literal IPv6 address in the URI, the literal address should be " + "enclosed in '[' and ']' characters. " + "If SourceType=7 ('udp'), this is defines a udp remote host and port connection " + "to receive packages. That the character device acts as a UDP netconsole service, " + "sending and receiving packets, the ConnectURL property must also be defined. " + "This is a lossy service. " + "Only 'udp' is valid for the protocol part of the URI. " + "Format of the URL: ://:. e.g. udp://0.0.0.0:2245 " + "If SourceType=8 ('tcp'), this is defines a remote host and port connection. " + "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. " + "Format of the URL: ://:. e.g. raw://[3ffe:2a00:100:7031::1]:2245 " + "If SourceType=9 ('unix'), this is defined the full qualified file path " + "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. " + "Format of the URL: file://. " + "e.g. file:///tmp/console-in"), + ModelCorrespondence {"LXC_CharacterResourceAllocationSettingData.SourceType"}] + string BindURL; +}; + + +[Description ("LXC virtual console device. It is identified by: " + "CIM_ResourceAllocationSettingData.ResourceType=1 ( 'Other' ) and " + "CIM_ResourceAllocationSettingData.OtherResourceType='console'"), + Provider("cmpi::Virt_RASD") +] +class LXC_ConsoleResourceAllocationSettingData : LXC_CharacterResourceAllocationSettingData +{ + [Description ("The type of the console in the target/guest environment.")] + string TargetType; +}; diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration index 2747f91..b969bfe 100644 --- a/schema/ResourceAllocationSettingData.registration +++ b/schema/ResourceAllocationSettingData.registration @@ -1,4 +1,4 @@ -# Copyright IBM Corp. 2007 +# Copyright IBM Corp. 2007, 2013 # Classname Namespace ProviderName ProviderModule ProviderTypes Xen_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance @@ -6,14 +6,17 @@ Xen_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +Xen_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index 150ccd3..e28d4e6 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007, 2013 * * Authors: * Dan Smith @@ -662,6 +662,143 @@ static CMPIStatus set_graphics_rasd_params(const struct virt_device *dev, return s; } +static char* _build_console_url(const char *protocol, + const char *host, + const char *port) +{ + char* result = NULL; + + if (host == NULL) + goto out; + + if (protocol != NULL && STREQC("file", protocol)) { + /* The host string contains the file name. + Even if the file name does not start with a '/' + it is treated by libvirt as a full qualified path. + */ + if (host[0] == '/') { + if (asprintf(&result, "file://%s", host) < 0) + result = NULL; + goto out; + } else { + if (asprintf(&result, "file:///%s", host) < 0) + result = NULL; + goto out; + } + } + /* The assumption is that the host does not contain a port. + If the host string contains a ':', + the host is treated as an IPv6 address. + */ + if (strchr(host, ':') == NULL) { + if (port == NULL) { + if (asprintf(&result,"%s://%s", protocol, host) < 0) + result = NULL; + goto out; + } else { + if (asprintf(&result,"%s://%s:%s", protocol, + host,port) < 0) + result = NULL; + goto out; + } + } + out: + return result; +} + + +static CMPIStatus set_console_rasd_params(const struct virt_device *vdev, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + const struct console_device *cdev = NULL; + char* tmp = NULL; + + cdev = &vdev->dev.console; + + CMSetProperty(inst, "OtherResourceType", "console", CMPI_chars); + CMSetProperty(inst, "SourceType", + (CMPIValue *)&cdev->source_type, CMPI_uint16); + CMSetProperty(inst, "TargetType", + (CMPIValue *)cdev->target_type, CMPI_chars); + + switch (cdev->source_type) { + case CIM_CHARDEV_SOURCE_TYPE_PTY: + CMSetProperty(inst, "SourcePath", + (CMPIValue *)cdev->source_dev.pty.path, + CMPI_chars); + break; + case CIM_CHARDEV_SOURCE_TYPE_DEV: + CMSetProperty(inst, "SourcePath", + (CMPIValue *)cdev->source_dev.dev.path, + CMPI_chars); + break; + case CIM_CHARDEV_SOURCE_TYPE_FILE: + CMSetProperty(inst, "SourcePath", + (CMPIValue *)cdev->source_dev.file.path, + CMPI_chars); + break; + case CIM_CHARDEV_SOURCE_TYPE_PIPE: + CMSetProperty(inst, "SourcePath", + (CMPIValue *)cdev->source_dev.pipe.path, + CMPI_chars); + break; + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: + tmp = _build_console_url("file", + cdev->source_dev.unixsock.path, NULL); + if (cdev->source_dev.unixsock.mode != NULL) { + if (STREQC(cdev->source_dev.unixsock.mode, "bind")) + CMSetProperty(inst, "BindURL", + (CMPIValue *)tmp, CMPI_chars); + else if (STREQC(cdev->source_dev.unixsock.mode, + "connect")) + CMSetProperty(inst, "ConnectURL", + (CMPIValue *)tmp, CMPI_chars); + } + free(tmp); + break; + case CIM_CHARDEV_SOURCE_TYPE_UDP: + tmp = _build_console_url("udp", + cdev->source_dev.udp.bind_host, + cdev->source_dev.udp.bind_service); + CMSetProperty(inst, "BindURL", + (CMPIValue *)tmp, CMPI_chars); + free(tmp); + + tmp = _build_console_url("udp", + cdev->source_dev.udp.connect_host, + cdev->source_dev.udp.connect_service); + CMSetProperty(inst, "ConnectURL", (CMPIValue *)tmp, CMPI_chars); + free(tmp); + break; + case CIM_CHARDEV_SOURCE_TYPE_TCP: + tmp = _build_console_url(cdev->source_dev.tcp.protocol, + cdev->source_dev.tcp.host, + cdev->source_dev.tcp.service); + if (cdev->source_dev.tcp.mode != NULL) { + if (STREQC(cdev->source_dev.tcp.mode, "bind")) + CMSetProperty(inst, "BindURL", + (CMPIValue *)tmp, CMPI_chars); + else if (STREQC(cdev->source_dev.tcp.mode, "connect")) + CMSetProperty(inst, "ConnectURL", + (CMPIValue *)tmp, CMPI_chars); + } + free(tmp); + break; + + default: + /* Nothing to do for : + CIM_CHARDEV_SOURCE_TYPE_STDIO + CIM_CHARDEV_SOURCE_TYPE_NULL + CIM_CHARDEV_SOURCE_TYPE_VC + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC + */ + break; + } + + return s; +} + static CMPIStatus set_input_rasd_params(const struct virt_device *dev, CMPIInstance *inst) { @@ -721,6 +858,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, } else if (dev->type == CIM_RES_TYPE_GRAPHICS) { type = CIM_RES_TYPE_GRAPHICS; base = "GraphicsResourceAllocationSettingData"; + } else if (dev->type == CIM_RES_TYPE_CONSOLE) { + type = CIM_RES_TYPE_OTHER; + base = "ConsoleResourceAllocationSettingData"; } else if (dev->type == CIM_RES_TYPE_INPUT) { type = CIM_RES_TYPE_INPUT; base = "InputResourceAllocationSettingData"; @@ -777,6 +917,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, s = set_graphics_rasd_params(dev, inst, host, CLASSNAME(ref)); } else if (dev->type == CIM_RES_TYPE_INPUT) { s = set_input_rasd_params(dev, inst); + } else if (dev->type == CIM_RES_TYPE_CONSOLE) { + s = set_console_rasd_params(dev, inst); } /* FIXME: Put the HostResource in place */ @@ -909,6 +1051,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) *type = CIM_RES_TYPE_INPUT; else if (STREQ(base, "StorageVolumeResourceAllocationSettingData")) *type = CIM_RES_TYPE_IMAGE; + else if (STREQ(base, "ConsoleResourceAllocationSettingData")) + *type = CIM_RES_TYPE_CONSOLE; else goto out; @@ -940,6 +1084,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) case CIM_RES_TYPE_GRAPHICS: *classname = "GraphicsResourceAllocationSettingData"; break; + case CIM_RES_TYPE_CONSOLE: + *classname = "ConsoleResourceAllocationSettingData"; + break; case CIM_RES_TYPE_INPUT: *classname = "InputResourceAllocationSettingData"; break; -- 1.7.9.5 From jferlan at redhat.com Wed Sep 11 21:14:55 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 11 Sep 2013 17:14:55 -0400 Subject: [Libvirt-cim] [PATCH 1/2] libxkutil: Plug memory leaks in device parsing In-Reply-To: <1378469396-31284-2-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378469396-31284-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378469396-31284-2-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <5230DD4F.9050509@redhat.com> On 09/06/2013 08:09 AM, Viktor Mihajlovski wrote: > Fixed a number of memory leaks detected while running xml_parse_test > under valgrind. > > Signed-off-by: Viktor Mihajlovski > Reviewed-by: Boris Fiuczynski > --- > libxkutil/device_parsing.c | 30 ++++++++++++++++++++---------- > 1 file changed, 20 insertions(+), 10 deletions(-) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index 06acbac..59186a3 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -105,6 +105,8 @@ static void cleanup_net_device(struct net_device *dev) > free(dev->device); > free(dev->net_mode); > free(dev->filter_ref); > + free(dev->poolid); > + cleanup_vsi_device(&dev->vsi); > } > > static void cleanup_emu_device(struct emu_device *dev) > @@ -712,6 +714,8 @@ static int parse_mem_device(xmlNode *node, struct virt_device **vdevs) > struct virt_device *vdev = NULL; > struct mem_device *mdev = NULL; > char *content = NULL; > + char *tmpval = NULL; > + int ret = 0; > > vdev = calloc(1, sizeof(*vdev)); > if (vdev == NULL) > @@ -725,27 +729,25 @@ static int parse_mem_device(xmlNode *node, struct virt_device **vdevs) > sscanf(content, "%" PRIu64, &mdev->size); > else if (XSTREQ(node->name, "memory")) { > sscanf(content, "%" PRIu64, &mdev->maxsize); > - content = get_attr_value(node, "dumpCore"); > - if (content && XSTREQ(content, "on")) { > + tmpval = get_attr_value(node, "dumpCore"); > + if (tmpval && XSTREQ(tmpval, "on")) { > mdev->dumpCore = MEM_DUMP_CORE_ON; > - } else if (content && XSTREQ(content, "off")) { > + } else if (tmpval && XSTREQ(content, "off")) { > mdev->dumpCore = MEM_DUMP_CORE_OFF; > } else { > mdev->dumpCore = MEM_DUMP_CORE_NOT_SET; > } > } > > - free(content); > - > *vdevs = vdev; Since vdev is going to be returned - we'll need to : vdev = NULL; here, which I've done and tested successfully. I'll squash before push. John > - > - return 1; > + ret = 1; > > err: > free(content); > + free(tmpval); > free(vdev); > > - return 0; > + return ret; > } > > static char *get_attr_value_default(xmlNode *node, char *attrname, > @@ -1079,7 +1081,10 @@ static int do_parse(xmlNodeSet *nsv, dev_parse_func_t do_real_parse, > } > > out: > - *l = list; > + if (list) { > + free(*l); > + *l = list; > + } > return lstidx; > } > > @@ -1497,7 +1502,7 @@ static int parse_features(struct domain *dominfo, xmlNode *features) > > static void set_action(int *val, xmlNode *child) > { > - const char *action = (char *)xmlNodeGetContent(child); > + char *action = (char *)xmlNodeGetContent(child); > > if (action == NULL) > *val = CIM_VSSD_RECOVERY_NONE; > @@ -1509,6 +1514,8 @@ static void set_action(int *val, xmlNode *child) > *val = CIM_VSSD_RECOVERY_RESTART; > else > *val = CIM_VSSD_RECOVERY_NONE; > + > + xmlFree(action); > } > > static int parse_domain(xmlNodeSet *nsv, struct domain *dominfo) > @@ -1663,9 +1670,11 @@ void cleanup_dominfo(struct domain **dominfo) > > dom = *dominfo; > free(dom->name); > + free(dom->typestr); > free(dom->uuid); > free(dom->bootloader); > free(dom->bootloader_args); > + free(dom->clock); > > if (dom->type == DOMAIN_XENPV) { > free(dom->os_info.pv.type); > @@ -1687,6 +1696,7 @@ void cleanup_dominfo(struct domain **dominfo) > CU_DEBUG("Unknown domain type %i", dom->type); > } > > + cleanup_virt_devices(&dom->dev_emu, 1); > cleanup_virt_devices(&dom->dev_mem, dom->dev_mem_ct); > cleanup_virt_devices(&dom->dev_net, dom->dev_net_ct); > cleanup_virt_devices(&dom->dev_disk, dom->dev_disk_ct); > From jferlan at redhat.com Wed Sep 11 21:15:42 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 11 Sep 2013 17:15:42 -0400 Subject: [Libvirt-cim] [PATCH 2/2] xml_parse_test: Call cleanup_dominfo before exiting In-Reply-To: <1378469396-31284-3-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378469396-31284-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378469396-31284-3-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <5230DD7E.5030800@redhat.com> On 09/06/2013 08:09 AM, Viktor Mihajlovski wrote: > This avoids misleading valgrind output running xml_parse_test. > > Signed-off-by: Viktor Mihajlovski > Reviewed-by: Boris Fiuczynski > --- > libxkutil/xml_parse_test.c | 2 ++ > 1 file changed, 2 insertions(+) > ACK (and pushed) John From mihajlov at linux.vnet.ibm.com Thu Sep 12 08:27:33 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 12 Sep 2013 10:27:33 +0200 Subject: [Libvirt-cim] [PATCH 1/2] libxkutil: Plug memory leaks in device parsing In-Reply-To: <5230DD4F.9050509@redhat.com> References: <1378469396-31284-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378469396-31284-2-git-send-email-mihajlov@linux.vnet.ibm.com> <5230DD4F.9050509@redhat.com> Message-ID: <52317AF5.1020806@linux.vnet.ibm.com> On 09/11/2013 11:14 PM, John Ferlan wrote: [...] >> *vdevs = vdev; > > Since vdev is going to be returned - we'll need to : > > vdev = NULL; > > here, which I've done and tested successfully. I'll squash before push. embarrassing ... I'm really glad you caught this (no wonder the leaks were gone :-) -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From mihajlov at linux.vnet.ibm.com Thu Sep 12 08:28:11 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 12 Sep 2013 10:28:11 +0200 Subject: [Libvirt-cim] [PATCH 2/2] xml_parse_test: Call cleanup_dominfo before exiting In-Reply-To: <5230DD7E.5030800@redhat.com> References: <1378469396-31284-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378469396-31284-3-git-send-email-mihajlov@linux.vnet.ibm.com> <5230DD7E.5030800@redhat.com> Message-ID: <52317B1B.7090300@linux.vnet.ibm.com> On 09/11/2013 11:15 PM, John Ferlan wrote: > On 09/06/2013 08:09 AM, Viktor Mihajlovski wrote: >> This avoids misleading valgrind output running xml_parse_test. >> >> Signed-off-by: Viktor Mihajlovski >> Reviewed-by: Boris Fiuczynski >> --- >> libxkutil/xml_parse_test.c | 2 ++ >> 1 file changed, 2 insertions(+) >> > ACK (and pushed) > > John > Thanks, appreciate your support very much. -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Thu Sep 12 15:31:15 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 12 Sep 2013 11:31:15 -0400 Subject: [Libvirt-cim] [PATCHv2 6/7] VSMS: Support for domains with console devices In-Reply-To: <1378910741-22520-7-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378910741-22520-7-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <5231DE43.5080701@redhat.com> On 09/11/2013 10:45 AM, Viktor Mihajlovski wrote: > From: Thilo Boehm > > An instance of KVM_ConsoleResourceAllocationSettingData can be added to > domain specification for VSMS DefineSystem() to define a console for a domain. > A console definition can not be modified or deleted. > It only can be added at system definition and deleted at system deletion. > If a KVM_ConsoleRASD is specified on a system definition, > no default graphics adapter definition is done. > > Signed-off-by: Thilo Boehm > Signed-off-by: Viktor Mihajlovski > Reviewed-by: Boris Fiuczynski > --- > V2 Changes > - Fix realloc error handling > - Improve error message > - Check for NULL pointers before passing to STREQC and CU_DEBUG > - Fix uin16_t usage > - Fix a few whitespace issues > > src/Virt_VirtualSystemManagementService.c | 312 ++++++++++++++++++++++++++--- > 1 file changed, 289 insertions(+), 23 deletions(-) > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > index 6629b35..67dd3f2 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -1,5 +1,5 @@ > /* > - * Copyright IBM Corp. 2007 > + * Copyright IBM Corp. 2007, 2013 > * > * Authors: > * Dan Smith > @@ -626,7 +626,8 @@ static bool default_input_device(struct domain *domain) > > static bool add_default_devs(struct domain *domain) > { > - if (domain->dev_graphics_ct < 1) { > + if (domain->dev_graphics_ct < 1 && > + domain->dev_console_ct < 1) { > if (!default_graphics_device(domain)) > return false; > } > @@ -1339,47 +1340,292 @@ static int parse_sdl_address(const char *id, > return ret; > } > > -static int parse_vnc_address(const char *id, > - char **ip, > - char **port) > +static int parse_ip_address(const char *id, > + char **ip, > + char **port) > { > int ret; > char *tmp_ip = NULL; > char *tmp_port = NULL; > > - CU_DEBUG("Entering parse_vnc_address, address is %s", id); > + CU_DEBUG("Entering parse_ip_address, address is %s", id); > if (strstr(id, "[") != NULL) { > /* its an ipv6 address */ > ret = sscanf(id, "%a[^]]]:%as", &tmp_ip, &tmp_port); > - strcat(tmp_ip, "]"); > + if (tmp_ip != NULL) { > + tmp_ip = realloc(tmp_ip, strlen(tmp_ip) + 2); > + if (tmp_ip != NULL) { > + strcat(tmp_ip, "]"); > + } It's possible that tmp_ip == NULL, so how about this instead: if (tmp_ip == NULL) { ret = 0; goto out; } strcat(tmp_ip, "]"); You won't be getting too far if realloc() fails anyway, but better than core in a few lines on strdup(tmp_ip); failure. > + } > } else { > ret = sscanf(id, "%a[^:]:%as", &tmp_ip, &tmp_port); > } > > - if (ret != 2) { > + /* ret == 2: address and port, ret == 1: address only */ > + if (ret < 1) { > ret = 0; > goto out; > } > > - if (ip) > + if (ip) { > *ip = strdup(tmp_ip); If 'tmp_ip == NULL' then this is problematic Everything else seems fine - so if you want me to sqaush in the above I will do so and then just push. John > + CU_DEBUG("IP = '%s'",*ip); > + } > > - if (port) > + if (port && tmp_port) { > *port = strdup(tmp_port); > - > - ret = 1; > + CU_DEBUG("Port = '%s'",*port); > + } > > out: > - if (ip && port) > - CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", > - *ip, *port); > - > free(tmp_ip); > free(tmp_port); > > return ret; > } > > +static bool parse_console_url(const char *url, > + char **protocol, > + char **host, > + char **port) > +{ > + bool success = false; > + char *tmp_protocol = NULL; > + char *tmp_address = NULL; > + > + CU_DEBUG("Entering parse_console_url:'%s'", url); > + > + if (sscanf(url,"%a[^:]://%as", &tmp_protocol, &tmp_address) != 2) > + goto out; > + > + if (parse_ip_address(tmp_address, host, port) < 1) > + goto out; > + > + if (protocol) { > + *protocol = strdup(tmp_protocol); > + CU_DEBUG("Protocol = '%s'", *protocol); > + } > + > + success = true; > + > + out: > + free(tmp_protocol); > + free(tmp_address); > + > + return success; > +} > + > +static const char *_unixsock_console_rasd_to_vdev(CMPIInstance *inst, > + struct console_device *cdev) > +{ > + const char *val = NULL; > + const char *val2 = NULL; > + char* protocol = NULL; > + > + cdev->source_dev.unixsock.mode = NULL; > + if (cu_get_str_prop(inst,"ConnectURL", &val) == CMPI_RC_OK) { > + CU_DEBUG("ConnectURL = '%s'", val); > + cdev->source_dev.unixsock.mode = strdup("connect"); > + } > + > + if (cu_get_str_prop(inst, "BindURL", &val2) == CMPI_RC_OK) { > + if (cdev->source_dev.unixsock.mode != NULL) > + return "ConsoleRASD: Only one of ConnectURL or BindURL " > + "is allowed for UNIX domain sockets."; > + CU_DEBUG("BindURL = '%s'", val2); > + cdev->source_dev.unixsock.mode = strdup("bind"); > + val = val2; > + } > + > + if (val) { > + if (!parse_console_url(val, &protocol, &cdev->source_dev.unixsock.path, NULL)) > + return "ConsoleRASD: Invalid ConnectURL or BindURL for " > + "UNIX domain socket client/server."; > + > + if (protocol != NULL && !STREQC("file", protocol)) { > + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'", protocol); > + free(protocol); > + return "ConsoleRASD: Protocol 'file' was not specified for " > + "ConnectURL or BindURL for UNIX domain socket client/server."; > + } > + free(protocol); > + } else { > + return "ConsoleRASD: ConnectURL or BindURL not specified for " > + "UNIX domain socket client/server."; > + } > + > + return NULL; > +} > + > +static const char *_udp_console_rasd_to_vdev(CMPIInstance *inst, > + struct console_device *cdev) > +{ > + const char *val = NULL; > + char* protocol = NULL; > + > + if (cu_get_str_prop(inst, "ConnectURL", &val) != CMPI_RC_OK) > + return "ConsoleRASD: ConnectURL not specified for UDP network console."; > + > + if (!parse_console_url(val, &protocol, > + &cdev->source_dev.udp.connect_host, > + &cdev->source_dev.udp.connect_service)) > + return "ConsoleRASD: Invalid ConnectURL specified for UDP network console."; > + > + if (protocol != NULL && !STREQC("udp", protocol)) { > + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'", protocol); > + free(protocol); > + return "ConsoleRASD: Protocol 'udp' was not specified at " > + "ConnectURL for UDP network console."; > + } > + > + free(protocol); > + > + if (cu_get_str_prop(inst, "BindURL", &val) != CMPI_RC_OK) > + return "ConsoleRASD: BindURL not specified for UDP network console."; > + > + if (!parse_console_url(val, &protocol, > + &cdev->source_dev.udp.bind_host, > + &cdev->source_dev.udp.bind_service)) > + return "ConsoleRASD: Invalid BindURL specified for UDP network console."; > + > + if (protocol != NULL && !STREQC("udp", protocol)) { > + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'", protocol); > + free(protocol); > + return "ConsoleRASD: Protocol 'udp' was not specified at BindURL " > + "for UDP network console."; > + } > + > + free(protocol); > + return NULL; > +} > + > +static const char *_tcp_console_rasd_to_vdev(CMPIInstance *inst, > + struct console_device *cdev) > +{ > + const char *val = NULL; > + const char *val2 = NULL; > + > + cdev->source_dev.tcp.mode = NULL; > + if (cu_get_str_prop(inst, "ConnectURL", &val) == CMPI_RC_OK) { > + CU_DEBUG("ConnectURL = '%s'", val); > + cdev->source_dev.tcp.mode = strdup("connect"); > + } > + > + if (cu_get_str_prop(inst, "BindURL", &val2) == CMPI_RC_OK) { > + if (cdev->source_dev.tcp.mode != NULL) > + return "ConsoleRASD: Only one of ConnectURL or BindURL " > + "is allowed for TCP sockets."; > + CU_DEBUG("BindURL = '%s'", val2); > + cdev->source_dev.tcp.mode = strdup("bind"); > + val = val2; > + } > + > + if (val) { > + if (!parse_console_url(val, > + &cdev->source_dev.tcp.protocol, > + &cdev->source_dev.tcp.host, > + &cdev->source_dev.tcp.service)) > + return "ConsoleRASD: Invalid ConnectURL or BindURL for " > + "TCP client/server console."; > + if (cdev->source_dev.tcp.service == NULL) > + return "ConsoleRASD: Missing TCP port for TCP client/server console."; > + } else { > + return "ConsoleRASD: ConnectURL or BindURL not specified for " > + "TCP client/server console."; > + } > + > + if (cdev->source_dev.tcp.protocol != NULL) { > + if (STREQC("udp", cdev->source_dev.tcp.protocol)) { > + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'", > + cdev->source_dev.tcp.protocol); > + return "ConsoleRASD: Invalid protocol 'udp' was specified at " > + "TCP client/server console."; > + } else if (STREQC("file", cdev->source_dev.tcp.protocol)) { > + CU_DEBUG("Wrong ConsoleRASD protocol specified: '%s'", > + cdev->source_dev.tcp.protocol); > + return "ConsoleRASD: Invalid protocol 'file' was specified at " > + "TCP client/server console."; > + } > + } > + > + return NULL; > +} > + > +static const char *console_rasd_to_vdev(CMPIInstance *inst, > + struct virt_device *dev) > +{ > + int rc = 0; > + const char *msg = NULL; > + const char *val = NULL; > + struct console_device *cdev = &dev->dev.console; > + uint16_t tmp; > + > + rc = cu_get_u16_prop(inst, "SourceType", &tmp); > + if (rc != CMPI_RC_OK) > + return "ConsoleRASD: SourceType field not specified."; > + > + if (tmp >= CIM_CHARDEV_SOURCE_TYPE_INVALIDTYPE) > + return "ConsoleRASD: Invalid SourceType value"; > + > + cdev->source_type = tmp; > + CU_DEBUG("Processing SourceType: %d", cdev->source_type); > + > + /* property not required */ > + if (cu_get_str_prop(inst, "TargetType", &val) == CMPI_RC_OK) > + cdev->target_type = strdup(val); > + CU_DEBUG("TargetType is '%s'", cdev->target_type ? : "NULL" ); > + > + switch (cdev->source_type) { > + case CIM_CHARDEV_SOURCE_TYPE_PTY: > + /* property not required */ > + if (cu_get_str_prop(inst, "SourcePath", &val) == CMPI_RC_OK) > + cdev->source_dev.pty.path = strdup(val); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_DEV: > + if (cu_get_str_prop(inst, "SourcePath", &val) != CMPI_RC_OK) > + return "ConsoleRASD: SourcePath not specified for Host device proxy."; > + cdev->source_dev.dev.path = strdup(val); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_FILE: > + if (cu_get_str_prop(inst, "SourcePath", &val) != CMPI_RC_OK) > + return "ConsoleRASD: SourcePath not specified for Device logfile."; > + cdev->source_dev.file.path = strdup(val); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_PIPE: > + if (cu_get_str_prop(inst, "SourcePath", &val) != CMPI_RC_OK) > + return "ConsoleRASD: SourcePath not specified for Named pipe."; > + cdev->source_dev.pipe.path = strdup(val); > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK: > + msg = _unixsock_console_rasd_to_vdev(inst, cdev); > + if (msg != NULL) > + return msg; > + break; > + case CIM_CHARDEV_SOURCE_TYPE_UDP: > + msg = _udp_console_rasd_to_vdev(inst, cdev); > + if (msg != NULL) > + return msg; > + break; > + case CIM_CHARDEV_SOURCE_TYPE_TCP: > + msg = _tcp_console_rasd_to_vdev(inst, cdev); > + if (msg != NULL) > + return msg; > + break; > + > + default: > + /* Nothing to do for : > + CIM_CHARDEV_SOURCE_TYPE_STDIO > + CIM_CHARDEV_SOURCE_TYPE_NULL > + CIM_CHARDEV_SOURCE_TYPE_VC > + CIM_CHARDEV_SOURCE_TYPE_SPICEVMC > + */ > + break; > + } > + > + return NULL; > +} > + > static const char *graphics_rasd_to_vdev(CMPIInstance *inst, > struct virt_device *dev) > { > @@ -1394,7 +1640,7 @@ static const char *graphics_rasd_to_vdev(CMPIInstance *inst, > } > dev->dev.graphics.type = strdup(val); > > - CU_DEBUG("graphics type = %s", dev->dev.graphics.type); > + CU_DEBUG("graphics type = %s", dev->dev.graphics.type ? : "NULL"); > > /* FIXME: Add logic to prevent address:port collisions */ > if (STREQC(dev->dev.graphics.type, "vnc")) { > @@ -1411,10 +1657,10 @@ static const char *graphics_rasd_to_vdev(CMPIInstance *inst, > val = "127.0.0.1:-1"; > } > > - ret = parse_vnc_address(val, > + ret = parse_ip_address(val, > &dev->dev.graphics.dev.vnc.host, > &dev->dev.graphics.dev.vnc.port); > - if (ret != 1) { > + if (ret != 2) { > msg = "GraphicsRASD field Address not valid"; > goto out; > } > @@ -1540,6 +1786,8 @@ static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, > return proc_rasd_to_vdev(inst, dev); > } else if (type == CIM_RES_TYPE_GRAPHICS) { > return graphics_rasd_to_vdev(inst, dev); > + } else if (type == CIM_RES_TYPE_CONSOLE) { > + return console_rasd_to_vdev(inst, dev); > } else if (type == CIM_RES_TYPE_INPUT) { > return input_rasd_to_vdev(inst, dev); > } > @@ -1601,7 +1849,7 @@ static const char *rasd_to_vdev(CMPIInstance *inst, > return msg; > } > > -static char *add_device_nodup(struct virt_device *dev, > +static const char *add_device_nodup(struct virt_device *dev, > struct virt_device *list, > int max, > int *index) > @@ -1663,6 +1911,9 @@ static const char *classify_resources(CMPIArray *resources, > if (!make_space(&domain->dev_graphics, domain->dev_graphics_ct, count)) > return "Failed to alloc graphics list"; > > + if (!make_space(&domain->dev_console, domain->dev_console_ct, count)) > + return "Failed to alloc console list"; > + > if (!make_space(&domain->dev_input, domain->dev_input_ct, count)) > return "Failed to alloc input list"; > > @@ -1765,6 +2016,14 @@ static const char *classify_resources(CMPIArray *resources, > domain->dev_graphics, > gcount, > &domain->dev_graphics_ct); > + } else if (type == CIM_RES_TYPE_CONSOLE) { > + msg = rasd_to_vdev(inst, > + domain, > + &domain->dev_console[domain->dev_console_ct], > + ns, > + p_error); > + if (msg == NULL) > + domain->dev_console_ct+=1; > } else if (type == CIM_RES_TYPE_INPUT) { > domain->dev_input_ct = 1; > msg = rasd_to_vdev(inst, > @@ -2570,6 +2829,9 @@ static struct virt_device **find_list(struct domain *dominfo, > } else if (type == CIM_RES_TYPE_GRAPHICS) { > list = &dominfo->dev_graphics; > *count = &dominfo->dev_graphics_ct; > + } else if (type == CIM_RES_TYPE_CONSOLE) { > + list = &dominfo->dev_console; > + *count = &dominfo->dev_console_ct; > } else if (type == CIM_RES_TYPE_INPUT) { > list = &dominfo->dev_input; > *count = &dominfo->dev_input_ct; > @@ -2693,7 +2955,8 @@ static CMPIStatus resource_del(struct domain *dominfo, > > if (STREQ(dev->id, devid)) { > if ((type == CIM_RES_TYPE_GRAPHICS) || > - (type == CIM_RES_TYPE_INPUT)) > + (type == CIM_RES_TYPE_CONSOLE) || > + (type == CIM_RES_TYPE_INPUT)) > cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); > else { > s = _resource_dynamic(dominfo, > @@ -2774,7 +3037,9 @@ static CMPIStatus resource_add(struct domain *dominfo, > goto out; > } > > - if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT)) { > + if ((type == CIM_RES_TYPE_GRAPHICS) || > + (type == CIM_RES_TYPE_INPUT) || > + (type == CIM_RES_TYPE_CONSOLE)) { > (*count)++; > cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); > goto out; > @@ -2850,7 +3115,8 @@ static CMPIStatus resource_mod(struct domain *dominfo, > } > > if ((type == CIM_RES_TYPE_GRAPHICS) || > - (type == CIM_RES_TYPE_INPUT)) > + (type == CIM_RES_TYPE_INPUT) || > + (type == CIM_RES_TYPE_CONSOLE)) > cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); > else { > #if LIBVIR_VERSION_NUMBER < 9000 > From mihajlov at linux.vnet.ibm.com Thu Sep 12 15:46:26 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Thu, 12 Sep 2013 17:46:26 +0200 Subject: [Libvirt-cim] [PATCHv2 6/7] VSMS: Support for domains with console devices In-Reply-To: <5231DE43.5080701@redhat.com> References: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> <1378910741-22520-7-git-send-email-mihajlov@linux.vnet.ibm.com> <5231DE43.5080701@redhat.com> Message-ID: <5231E1D2.7080901@linux.vnet.ibm.com> On 09/12/2013 05:31 PM, John Ferlan wrote: [...] > > It's possible that tmp_ip == NULL, so how about this instead: > > if (tmp_ip == NULL) { > ret = 0; > goto out; > } > strcat(tmp_ip, "]"); > > You won't be getting too far if realloc() fails anyway, but better than > core in a few lines on strdup(tmp_ip); failure. right ... Boris pointed that out to me today, I was too eager to get over it, and sent V2 before I got his feedback > > > >> + } >> } else { >> ret = sscanf(id, "%a[^:]:%as", &tmp_ip, &tmp_port); >> } >> >> - if (ret != 2) { >> + /* ret == 2: address and port, ret == 1: address only */ >> + if (ret < 1) { >> ret = 0; >> goto out; >> } >> >> - if (ip) >> + if (ip) { >> *ip = strdup(tmp_ip); > > If 'tmp_ip == NULL' then this is problematic > > > Everything else seems fine - so if you want me to sqaush in the above I > will do so and then just push. > That would be really nice ... thanks! -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Thu Sep 12 16:36:50 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 12 Sep 2013 12:36:50 -0400 Subject: [Libvirt-cim] [PATCHv2 0/7] Support for full function consoles In-Reply-To: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1378910741-22520-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <5231EDA2.4060600@redhat.com> On 09/11/2013 10:45 AM, Viktor Mihajlovski wrote: > Motivation: the current libvirt-cim support for consoles is > very limited in that it doesn't allow to specify the target > and source types supported by libvirt. Having full support > of the libvirt console feature is however mandatory for > architectures like s390. > > The current implementation using a Graphics_RASD to represent > consoles cannot easily be extended without breaking the existing > implementation (or without being entirely unusable). > > Therefore a new RASD class is added to represent consoles in > the model. Since there's no SVPC resource type for a console > we use the combination of ResourceType = 1 (Other) and > OtherResourceType = "console" for the new RASD instances. > > In order to be backward compatible, the only console type supported > by older libvirt-cim versions (target type 'pty') will still > be returned as Graphics_RASD. In the long run, this should be > deprecated. > > V2 Changes: > - Squashed old patches 2 and 5 and moved that one to position 4 > - Fix double frees > - Fix NULL pointer accesses > - Improve error handling > - Improve error messages > - Some cosmetic changes > > Thilo Boehm (5): > schema: New SVPC types for chardev/consoles > libxkutil: Console Support > RASD: Schema and Provider Support for Console RASDs > VSMS: Support for domains with console devices > VSMS: add default console > > Viktor Mihajlovski (2): > VSMS: Set resource types for default devices > Device: CIM_LogicalDevice for consoles > > libxkutil/device_parsing.c | 314 ++++++++++++++++++- > libxkutil/device_parsing.h | 43 ++- > libxkutil/xmlgen.c | 191 ++++++++++- > schema/ResourceAllocationSettingData.mof | 246 ++++++++++++++- > schema/ResourceAllocationSettingData.registration | 5 +- > src/Virt_Device.c | 33 ++ > src/Virt_RASD.c | 149 ++++++++- > src/Virt_VirtualSystemManagementService.c | 348 +++++++++++++++++++-- > src/svpc_types.h | 102 +++++- > 9 files changed, 1392 insertions(+), 39 deletions(-) > Series ACK and pushed with minor adjustment to 6/7 to check for NULL return on realloc() John From mihajlov at linux.vnet.ibm.com Tue Sep 17 12:54:15 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Tue, 17 Sep 2013 14:54:15 +0200 Subject: [Libvirt-cim] [PATCH] Make sure provider revision is a number Message-ID: <1379422455-28364-1-git-send-email-mihajlov@linux.vnet.ibm.com> Commit 4a7fae9 changed the revision returned by get_provider_version to a string. However, the revision has to be a number because (since git is used) it's basically the number of commits in HEAD. Comparing a string against an int in Python 2.x will always result in the string value being greater than the int value. Since there are a lot of compares against revision numbers all over the test scripts, this change is probably the most economic. Signed-off-by: Viktor Mihajlovski --- Not being a python guy I got wacked myself when I was testing my (soon to come) cimtest changes against a pre-console libvirt-cim. '1272' > 1276 silently returned True leading to epic failures :-( suites/libvirt-cim/lib/XenKvmLib/const.py | 4 +++- suites/libvirt-cim/lib/XenKvmLib/reporting.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/suites/libvirt-cim/lib/XenKvmLib/const.py b/suites/libvirt-cim/lib/XenKvmLib/const.py index a8d0254..a454b2f 100755 --- a/suites/libvirt-cim/lib/XenKvmLib/const.py +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py @@ -179,7 +179,9 @@ def get_provider_version(virt, ip): revision = revision.strip("+") if revision.isdigit(): revision = int(revision) + else: + raise Exception("revision %s is not a digit", revision) - return str(revision), str(changeset) + return revision, changeset diff --git a/suites/libvirt-cim/lib/XenKvmLib/reporting.py b/suites/libvirt-cim/lib/XenKvmLib/reporting.py index 67ec974..88375b0 100644 --- a/suites/libvirt-cim/lib/XenKvmLib/reporting.py +++ b/suites/libvirt-cim/lib/XenKvmLib/reporting.py @@ -101,7 +101,7 @@ def get_env_data(ip, virt): rev, changeset = get_provider_version(virt, ip) cimtest_revision, cimtest_changeset = get_cimtest_version() - lc_ver = "Libvirt-cim revision: %s\nLibvirt-cim changeset: %s\n" % \ + lc_ver = "Libvirt-cim revision: %d\nLibvirt-cim changeset: %s\n" % \ (rev, changeset) cimtest_ver = "Cimtest revision: %s\nCimtest changeset: %s\n" % \ (cimtest_revision, cimtest_changeset) -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Fri Sep 20 15:26:00 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 20 Sep 2013 17:26:00 +0200 Subject: [Libvirt-cim] [PATCH 1/3] libxkutil: Simplify XML handling of consoles In-Reply-To: <1379690762-15127-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1379690762-15127-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1379690762-15127-2-git-send-email-mihajlov@linux.vnet.ibm.com> The attempt to avoid duplication of console definitions was a bit too complicated and error prone. We move the generation of console XML entirely to the new console code. Further, it's incorrect to restrict PTY consoles being represented as GraphicsRASDs to virtio only. At least serial must be allowed, but it doesn't really hurt to map all PTYs to GraphicsRASD consoles. Further, the parsing code returned two instances for serial consoles, one from the /domain/devices/console and /domain/devices/serial both representing the same device. This confuses cimtest and, more problematic, will prevent DefineSystem to work, if a reference VSSD with a serial console is passed in. Signed-off-by: Viktor Mihajlovski Reviewed-by: Daniel Hansel --- libxkutil/device_parsing.c | 12 +------ libxkutil/xmlgen.c | 76 -------------------------------------------- 2 files changed, 1 insertion(+), 87 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index 55c8d57..aecca4c 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -47,7 +47,7 @@ * still part of the graphics. */ #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ - "/domain/devices/console | /domain/devices/serial" + "/domain/devices/console" #define INPUT_XPATH (xmlChar *)"/domain/devices/input" #define DEFAULT_BRIDGE "xenbr0" @@ -948,16 +948,6 @@ static int parse_graphics_device(xmlNode *node, struct virt_device **vdevs) else if (XSTREQ(child->name, "target")) { gdev->dev.vnc.port = get_attr_value(child, "port"); - /* The graphics pty console can only be a - virtio console. If 'type' is not set in the - xml, the default of libvirt is virtio.*/ - char *t_type = get_attr_value(child, "type"); - if (t_type != NULL && !STREQC(t_type, "virtio")) { - CU_DEBUG("Not a pty-virtio graphics console"); - free(t_type); - goto err; - } - free(t_type); } } } diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 45bfb04..7e8801d 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -42,36 +42,11 @@ typedef const char *(*devfn_t)(xmlNodePtr node, struct domain *dominfo); typedef const char *(*poolfn_t)(xmlNodePtr node, struct virt_pool *pool); typedef const char *(*resfn_t)(xmlNodePtr node, struct virt_pool_res *res); -static int _count_graphics_console_definitions(struct domain *dominfo) -{ - int i; - int num = 0; - - for (i = 0; i < dominfo->dev_graphics_ct; i++) { - struct virt_device *_dev = &dominfo->dev_graphics[i]; - if (_dev->type == CIM_RES_TYPE_UNKNOWN) - continue; - - struct graphics_device *dev = &_dev->dev.graphics; - - if (STREQC(dev->type, "console")) { - num++; - } - } - CU_DEBUG("Found %d console defintions in graphics devices.",num); - return num; - -} - static const char *console_xml(xmlNodePtr root, struct domain *dominfo) { int i; xmlNodePtr console; xmlNodePtr tmp; - int num_graphics_consol_def = 0; - int num_suppressed_console_def = 0; - - num_graphics_consol_def = _count_graphics_console_definitions(dominfo); for (i = 0; i < dominfo->dev_console_ct; i++) { struct virt_device *_dev = &dominfo->dev_console[i]; @@ -80,25 +55,6 @@ static const char *console_xml(xmlNodePtr root, struct domain *dominfo) struct console_device *cdev = &_dev->dev.console; - /* Due to backward compatibility, the graphics device handling - is still parsing consoles: - source = pty, target = virtio (which is the default target) - But the console device handling processes these kind of - consoles too. This would lead to a duplication of these - default consoles in the domain xml definition. - This code prevents the console handling of writing xml for - duplicate pty/virtio consoles which are written by the - graphics device handling. */ - if (cdev->source_type == CIM_CHARDEV_SOURCE_TYPE_PTY && - (cdev->target_type == NULL || - STREQC(cdev->target_type, "virtio"))) { - if (num_suppressed_console_def < - num_graphics_consol_def) { - num_suppressed_console_def++; - continue; - } - } - console = xmlNewChild(root, NULL, BAD_CAST "console", NULL); if (console == NULL) return XML_ERROR; @@ -760,35 +716,6 @@ static const char *graphics_vnc_xml(xmlNodePtr root, 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->dev.vnc.host) - xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev->dev.vnc.host); - - tmp = xmlNewChild(pty, NULL, BAD_CAST "target", NULL); - if (tmp == NULL) - return XML_ERROR; - - if(dev->dev.vnc.port) - xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->dev.vnc.port); - - return NULL; -} - static const char *graphics_xml(xmlNodePtr root, struct domain *dominfo) { const char *msg = NULL; @@ -803,9 +730,6 @@ static const char *graphics_xml(xmlNodePtr root, struct domain *dominfo) 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; -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Fri Sep 20 15:26:01 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 20 Sep 2013 17:26:01 +0200 Subject: [Libvirt-cim] [PATCH 2/3] Virt_Device: Add a device class for consoles In-Reply-To: <1379690762-15127-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1379690762-15127-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1379690762-15127-3-git-send-email-mihajlov@linux.vnet.ibm.com> libvirt-cim has a very strict assumption about the presence of a CIM_LogicalDevice class being associated to a RASD. It is practically impossible to extend the cimtest framework for the ConsoleRASD class without having a matching device class. Adding a new ConsoleDisplayController class for this purpose. Signed-off-by: Viktor Mihajlovski Reviewed-by: Daniel Hansel --- schema/DisplayController.mof | 15 +++++++++++++++ schema/DisplayController.registration | 3 +++ src/Virt_Device.c | 18 ++++++++++-------- src/Virt_ElementSettingData.c | 3 +++ src/Virt_SettingsDefineState.c | 6 ++++++ src/Virt_SystemDevice.c | 3 +++ src/Virt_VSSDComponent.c | 3 +++ 7 files changed, 43 insertions(+), 8 deletions(-) diff --git a/schema/DisplayController.mof b/schema/DisplayController.mof index b57c9cc..8ccdc07 100644 --- a/schema/DisplayController.mof +++ b/schema/DisplayController.mof @@ -15,3 +15,18 @@ class LXC_DisplayController : CIM_DisplayController { }; +[ Provider("cmpi::Virt_Device") ] +class Xen_ConsoleDisplayController : CIM_DisplayController +{ +}; + +[ Provider("cmpi::Virt_Device") ] +class KVM_ConsoleDisplayController : CIM_DisplayController +{ +}; + +[ Provider("cmpi::Virt_Device") ] +class LXC_ConsoleDisplayController : CIM_DisplayController +{ +}; + diff --git a/schema/DisplayController.registration b/schema/DisplayController.registration index de8adc9..e7e9770 100644 --- a/schema/DisplayController.registration +++ b/schema/DisplayController.registration @@ -3,3 +3,6 @@ Xen_DisplayController root/virt Virt_Device Virt_Device instance KVM_DisplayController root/virt Virt_Device Virt_Device instance LXC_DisplayController root/virt Virt_Device Virt_Device instance +Xen_ConsoleDisplayController root/virt Virt_Device Virt_Device instance +KVM_ConsoleDisplayController root/virt Virt_Device Virt_Device instance +LXC_ConsoleDisplayController root/virt Virt_Device Virt_Device instance diff --git a/src/Virt_Device.c b/src/Virt_Device.c index aa47276..498ce2c 100644 --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -263,12 +263,12 @@ static CMPIInstance *console_instance(const CMPIBroker *broker, conn = virDomainGetConnect(dom); inst = get_typed_instance(broker, pfx_from_conn(conn), - "DisplayController", + "ConsoleDisplayController", ns, true); if (inst == NULL) { - CU_DEBUG("Failed to get instance for DisplayController"); + CU_DEBUG("Failed to get instance for ConsoleDisplayController"); return NULL; } @@ -541,17 +541,19 @@ static bool device_instances(const CMPIBroker *broker, uint16_t res_type_from_device_classname(const char *classname) { - if (strstr(classname, "NetworkPort")) + if (strstr(classname, "_NetworkPort")) return CIM_RES_TYPE_NET; - else if (strstr(classname, "LogicalDisk")) + else if (strstr(classname, "_LogicalDisk")) return CIM_RES_TYPE_DISK; - else if (strstr(classname, "Memory")) + else if (strstr(classname, "_Memory")) return CIM_RES_TYPE_MEM; - else if (strstr(classname, "Processor")) + else if (strstr(classname, "_Processor")) return CIM_RES_TYPE_PROC; - else if (strstr(classname, "DisplayController")) + else if (strstr(classname, "_DisplayController")) return CIM_RES_TYPE_GRAPHICS; - else if (strstr(classname, "PointingDevice")) + else if (strstr(classname, "_ConsoleDisplayController")) + return CIM_RES_TYPE_CONSOLE; + else if (strstr(classname, "_PointingDevice")) return CIM_RES_TYPE_INPUT; else return CIM_RES_TYPE_UNKNOWN; diff --git a/src/Virt_ElementSettingData.c b/src/Virt_ElementSettingData.c index c257710..c088e49 100644 --- a/src/Virt_ElementSettingData.c +++ b/src/Virt_ElementSettingData.c @@ -128,18 +128,21 @@ static char* resource_allocation_setting_data[] = { "Xen_NetResourceAllocationSettingData", "Xen_ProcResourceAllocationSettingData", "Xen_GraphicsResourceAllocationSettingData", + "Xen_ConsoleResourceAllocationSettingData", "Xen_InputResourceAllocationSettingData", "KVM_DiskResourceAllocationSettingData", "KVM_MemResourceAllocationSettingData", "KVM_NetResourceAllocationSettingData", "KVM_ProcResourceAllocationSettingData", "KVM_GraphicsResourceAllocationSettingData", + "KVM_ConsoleResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", "LXC_ProcResourceAllocationSettingData", "LXC_GraphicsResourceAllocationSettingData", + "LXC_ConsoleResourceAllocationSettingData", "LXC_InputResourceAllocationSettingData", NULL }; diff --git a/src/Virt_SettingsDefineState.c b/src/Virt_SettingsDefineState.c index f30f45f..be2ded5 100644 --- a/src/Virt_SettingsDefineState.c +++ b/src/Virt_SettingsDefineState.c @@ -327,18 +327,21 @@ static char* logical_device[] = { "Xen_NetworkPort", "Xen_LogicalDisk", "Xen_DisplayController", + "Xen_ConsoleDisplayController", "Xen_PointingDevice", "KVM_Processor", "KVM_Memory", "KVM_NetworkPort", "KVM_LogicalDisk", "KVM_DisplayController", + "KVM_ConsoleDisplayController", "KVM_PointingDevice", "LXC_Processor", "LXC_Memory", "LXC_NetworkPort", "LXC_LogicalDisk", "LXC_DisplayController", + "LXC_ConsoleDisplayController", "LXC_PointingDevice", NULL }; @@ -350,18 +353,21 @@ static char* resource_allocation_setting_data[] = { "Xen_ProcResourceAllocationSettingData", "Xen_GraphicsResourceAllocationSettingData", "Xen_InputResourceAllocationSettingData", + "Xen_ConsoleResourceAllocationSettingData", "KVM_DiskResourceAllocationSettingData", "KVM_MemResourceAllocationSettingData", "KVM_NetResourceAllocationSettingData", "KVM_ProcResourceAllocationSettingData", "KVM_GraphicsResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", + "KVM_ConsoleResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", "LXC_ProcResourceAllocationSettingData", "LXC_GraphicsResourceAllocationSettingData", "LXC_InputResourceAllocationSettingData", + "LXC_ConsoleResourceAllocationSettingData", NULL }; diff --git a/src/Virt_SystemDevice.c b/src/Virt_SystemDevice.c index 3a2f7ce..d2e526d 100644 --- a/src/Virt_SystemDevice.c +++ b/src/Virt_SystemDevice.c @@ -135,18 +135,21 @@ static char* part_component[] = { "Xen_NetworkPort", "Xen_LogicalDisk", "Xen_DisplayController", + "Xen_ConsoleDisplayController", "Xen_PointingDevice", "KVM_Processor", "KVM_Memory", "KVM_NetworkPort", "KVM_LogicalDisk", "KVM_DisplayController", + "KVM_ConsoleDisplayController", "KVM_PointingDevice", "LXC_Processor", "LXC_Memory", "LXC_NetworkPort", "LXC_LogicalDisk", "LXC_DisplayController", + "LXC_ConsoleDisplayController", "LXC_PointingDevice", NULL }; diff --git a/src/Virt_VSSDComponent.c b/src/Virt_VSSDComponent.c index 378de96..35bffde 100644 --- a/src/Virt_VSSDComponent.c +++ b/src/Virt_VSSDComponent.c @@ -132,6 +132,7 @@ static char* part_component[] = { "Xen_NetResourceAllocationSettingData", "Xen_ProcResourceAllocationSettingData", "Xen_GraphicsResourceAllocationSettingData", + "Xen_ConsoleResourceAllocationSettingData", "Xen_InputResourceAllocationSettingData", "KVM_DiskResourceAllocationSettingData", "KVM_MemResourceAllocationSettingData", @@ -139,12 +140,14 @@ static char* part_component[] = { "KVM_ProcResourceAllocationSettingData", "KVM_GraphicsResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", + "KVM_ConsoleResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", "LXC_ProcResourceAllocationSettingData", "LXC_GraphicsResourceAllocationSettingData", "LXC_InputResourceAllocationSettingData", + "LXC_ConsoleResourceAllocationSettingData", NULL }; -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Fri Sep 20 15:26:02 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 20 Sep 2013 17:26:02 +0200 Subject: [Libvirt-cim] [PATCH 3/3] KVMRedirectionSAP: Only return redirection SAPs for VNC graphics In-Reply-To: <1379690762-15127-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1379690762-15127-1-git-send-email-mihajlov@linux.vnet.ibm.com> Message-ID: <1379690762-15127-4-git-send-email-mihajlov@linux.vnet.ibm.com> Since pty consoles still show up as GraphicsRASDs the check for VNC redirection proved to be too rigid. Instead of failing the associator call, PTY consoles will just be ignored now. This is an old bug, but will be exposed when cimtest is extended to handle consoles. Signed-off-by: Viktor Mihajlovski Reviewed-by: Daniel Hansel --- src/Virt_KVMRedirectionSAP.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Virt_KVMRedirectionSAP.c b/src/Virt_KVMRedirectionSAP.c index 708b0d1..1a2aa69 100644 --- a/src/Virt_KVMRedirectionSAP.c +++ b/src/Virt_KVMRedirectionSAP.c @@ -265,9 +265,11 @@ static CMPIStatus get_vnc_sessions(const CMPIBroker *broker, } static bool check_graphics(virDomainPtr dom, - struct domain **dominfo) + struct domain **dominfo, + int *pos) { int ret = 0; + int i; ret = get_dominfo(dom, dominfo); if (!ret) { @@ -280,12 +282,16 @@ static bool check_graphics(virDomainPtr dom, return false; } - if (!STREQC((*dominfo)->dev_graphics->dev.graphics.type, "vnc")) { - CU_DEBUG("Only vnc devices have console redirection sessions"); - return false; + for (i = 0; i < (*dominfo)->dev_graphics_ct; i++) { + if (STREQC((*dominfo)->dev_graphics[i].dev.graphics.type, "vnc")) { + if (pos) + *pos = i; + return true; + } } - return true; + CU_DEBUG("Only vnc devices have console redirection sessions"); + return false; } static CMPIStatus return_console_sap(const CMPIObjectPath *ref, @@ -362,12 +368,13 @@ CMPIStatus enum_console_sap(const CMPIBroker *broker, } for (i = 0; i < count; i++) { - if (!check_graphics(domain_list[i], &dominfo)) { + int pos; + if (!check_graphics(domain_list[i], &dominfo, &pos)) { cleanup_dominfo(&dominfo); continue; } - ret = sscanf(dominfo->dev_graphics->dev.graphics.dev.vnc.port, + ret = sscanf(dominfo->dev_graphics[pos].dev.graphics.dev.vnc.port, "%d", &lport); if (ret != 1) { @@ -449,7 +456,7 @@ CMPIStatus get_console_sap_by_name(const CMPIBroker *broker, goto out; } - if (!check_graphics(dom, &dominfo)) { + if (!check_graphics(dom, &dominfo, NULL)) { virt_set_status(broker, &s, CMPI_RC_ERR_FAILED, conn, -- 1.7.9.5 From mihajlov at linux.vnet.ibm.com Fri Sep 20 15:25:59 2013 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 20 Sep 2013 17:25:59 +0200 Subject: [Libvirt-cim] [PATCH 0/3] Console Fixes and Enhancements Message-ID: <1379690762-15127-1-git-send-email-mihajlov@linux.vnet.ibm.com> Enabling cimtest for the Console RASDs required a few improvements. The XML generation code was simplified, a logical device class for consoles had to be added and a bug in the KVM redirection service was fixed. Viktor Mihajlovski (3): libxkutil: Simplify XML handling of consoles Virt_Device: Add a device class for consoles KVMRedirectionSAP: Only return redirection SAPs for VNC graphics libxkutil/device_parsing.c | 12 +----- libxkutil/xmlgen.c | 76 --------------------------------- schema/DisplayController.mof | 15 +++++++ schema/DisplayController.registration | 3 ++ src/Virt_Device.c | 18 ++++---- src/Virt_ElementSettingData.c | 3 ++ src/Virt_KVMRedirectionSAP.c | 23 ++++++---- src/Virt_SettingsDefineState.c | 6 +++ src/Virt_SystemDevice.c | 3 ++ src/Virt_VSSDComponent.c | 3 ++ 10 files changed, 59 insertions(+), 103 deletions(-) -- 1.7.9.5 From gesaint at linux.vnet.ibm.com Thu Sep 26 07:28:24 2013 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Thu, 26 Sep 2013 15:28:24 +0800 Subject: [Libvirt-cim] [PATCH] cimtest: Add type == 'bridge' handling branch in vsms_util.py Message-ID: <1380180504-19574-1-git-send-email-gesaint@linux.vnet.ibm.com> The name of interface should be read based on the type of it. There are two basic types for interface device (bridge and network). The name should be fetched in different way. I don't clear if Xen could support network type so I didn't make any change for it and just enhanced the logic in "virt == 'KVM'". I'll submit a set of patches and they solved XFAIL of VirtualSystemManagementService/ 22_addmulti_brg_interface.py. So it's necessary to fix it. Signed-off-by: Xu Wang --- suites/libvirt-cim/lib/XenKvmLib/vsms_util.py | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py index 075c09f..7839a38 100644 --- a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py @@ -189,10 +189,19 @@ def add_net_res(server, service, virt, cxml, vssd_ref, nasd, attr): % attr['nmac']) if virt == "KVM": - name = cxml.get_value_xpath( + if attr['ntype'] == "network": + name = cxml.get_value_xpath( '/domain/devices/interface/source/@network[. = "%s"]' % attr['net_name']) - + elif attr['ntype'] == "bridge": + br = get_bridge_from_network_xml(attr['net_name'], server, virt) + name = cxml.get_value_xpath( + '/domain/devices/interface/source/@bridge[. = "%s"]' + % br) + if name != None: + name = attr['net_name'] + else: + logger.error("Unrecognized interface type: %s" % type) else: # For Xen, network interfaces are converted to bridge interfaces. br = get_bridge_from_network_xml(attr['net_name'], server, virt) -- 1.7.1