From cvincent at linux.vnet.ibm.com Wed Aug 3 17:33:55 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 03 Aug 2011 13:33:55 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] Update RASDIndication test to use "vnc" instead of "graphics" In-Reply-To: <4E31A9A2.6070207@linux.vnet.ibm.com> References: <3c23103a2ca19d6cf66d.1311866595@elm3b151.beaverton.ibm.com> <4E31A9A2.6070207@linux.vnet.ibm.com> Message-ID: <4E398683.4080707@linux.vnet.ibm.com> Pushed with corrections. On 07/28/2011 02:25 PM, Eduardo Lima (Etrunko) wrote: > On 07/28/2011 12:23 PM, Sharad Mishra wrote: >> # HG changeset patch >> # User Sharad Mishra >> # Date 1311864875 25200 >> # Node ID 3c23103a2ca19d6cf66d84a7d87f4dd93e2d609f >> # Parent 3bc1a0fc5683d705c022014364cacf6d5860ba28 >> [TEST] Update RASDIndication test to use "vnc" instead of "graphics" >> >> Graphics RASDs now include support for serial/consoel devices, which > *console > >> includes support for unqiue InstanceIDs. This patch updates the test > *unique > >> to look for/vnc where is used to just look for graphics >> >> Signed-off-by: Sharad Mishra >> >> diff -r 3bc1a0fc5683 -r 3c23103a2ca1 >> suites/libvirt-cim/cimtest/RASDIndications/02_guest_add_mod_rem_rasd_ind.py >> >> --- >> a/suites/libvirt-cim/cimtest/RASDIndications/02_guest_add_mod_rem_rasd_ind.py >> Tue Jul 12 16:02:27 2011 -0300 >> +++ >> b/suites/libvirt-cim/cimtest/RASDIndications/02_guest_add_mod_rem_rasd_ind.py >> Thu Jul 28 07:54:35 2011 -0700 >> @@ -108,7 +108,7 @@ >> >> elif ind_name == 'delete': >> cn = 'GraphicsResourceAllocationSettingData' >> - inst_id = '%s/%s' % (test_dom, "graphics") >> + inst_id = '%s/%s' % (test_dom, "vnc") >> classname = get_typed_class(virt, cn) >> nrasd = get_rasd_rec(virt, cn, s_sysname, inst_id) >> > ACK > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Wed Aug 3 17:38:26 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 03 Aug 2011 13:38:26 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] Reduce the length of bridge name In-Reply-To: <8c23ed99a218f1d1eea5.1311878187@elm3b151.beaverton.ibm.com> References: <8c23ed99a218f1d1eea5.1311878187@elm3b151.beaverton.ibm.com> Message-ID: <4E398792.1040001@linux.vnet.ibm.com> -------------------------------------------------------------------- VirtualSystemManagementService - 06_addresource.py: PASS -------------------------------------------------------------------- +1 and pushed. On 07/28/2011 02:36 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1311878184 25200 > # Node ID 8c23ed99a218f1d1eea5c662b2fa3c211fe6d531 > # Parent 3bc1a0fc5683d705c022014364cacf6d5860ba28 > [TEST] Reduce the length of bridge name. > > Lately I have seen this > (VirtualSystemManagementService - 06_addresource.py) test > fails with following error - > > # virsh -c qemu:///system net-create /home/net.xml > error: Failed to create network from /home/net.xml > error: cannot create dummy tap device 'testbridge55-nic' to set mac address on bridge 'testbridge55': Invalid argument > > Reducing the size of bridge name fixed this issue. I looked on > the net but could not find more info on when this behaviour > changed in libvirt. > > Signed-off-by: Sharad Mishra > > diff -r 3bc1a0fc5683 -r 8c23ed99a218 suites/libvirt-cim/lib/XenKvmLib/const.py > --- a/suites/libvirt-cim/lib/XenKvmLib/const.py Tue Jul 12 16:02:27 2011 -0300 > +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Thu Jul 28 11:36:24 2011 -0700 > @@ -58,7 +58,7 @@ > > > # vxml.NetXML > -default_bridge_name = 'testbridge' > +default_bridge_name = 'testbr' > default_network_name = 'cimtest-networkpool' > default_net_type = 'network' > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Wed Aug 3 17:43:44 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 03 Aug 2011 13:43:44 -0400 Subject: [Libvirt-cim] [PATCH] New entry "poolid" was not getting DUPed In-Reply-To: <4E31A263.5070500@linux.vnet.ibm.com> References: <5dc300d4dfd7b9741a60.1311800213@elm3b151.beaverton.ibm.com> <4E31A263.5070500@linux.vnet.ibm.com> Message-ID: <4E3988D0.3010308@linux.vnet.ibm.com> Thanks. Pushed. On 07/28/2011 01:54 PM, Eduardo Lima (Etrunko) wrote: > On 07/27/2011 05:56 PM, Sharad Mishra wrote: >> # HG changeset patch >> # User Sharad Mishra >> # Date 1311797923 25200 >> # Node ID 5dc300d4dfd7b9741a6086e4e5b8da632bcdcd2d >> # Parent 0f42cab9c45c53cc13407b16418399ed8ed4a026 >> New entry "poolid" was not getting DUPed. >> >> A recent patch added support for network poolid, >> but missed to add DUP for it. This patch fixes the >> issue. >> >> Signed-off-by: Sharad Mishra >> >> diff -r 0f42cab9c45c -r 5dc300d4dfd7 libxkutil/device_parsing.c >> --- a/libxkutil/device_parsing.c Mon Jul 25 13:14:22 2011 -0700 >> +++ b/libxkutil/device_parsing.c Wed Jul 27 13:18:43 2011 -0700 >> @@ -775,6 +775,7 @@ >> DUP_FIELD(dev, _dev, dev.net.type); >> DUP_FIELD(dev, _dev, dev.net.source); >> DUP_FIELD(dev, _dev, dev.net.model); >> + DUP_FIELD(dev, _dev, dev.net.poolid); >> DUP_FIELD(dev, _dev, dev.net.device); >> DUP_FIELD(dev, _dev, dev.net.net_mode); >> DUP_FIELD(dev, _dev, dev.net.filter_ref); >> > > ACK > > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Thu Aug 4 15:23:51 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 04 Aug 2011 11:23:51 -0400 Subject: [Libvirt-cim] [PATCH] Retrun object paths for newly created filter associations Message-ID: <43d8048faffd40edd88e.1312471431@oc0840652111.ibm.com> # HG changeset patch # User Chip Vincent # Date 1312471352 14400 # Node ID 43d8048faffd40edd88ec339b7e615ff48a70b6a # Parent 5dc300d4dfd7b9741a6086e4e5b8da632bcdcd2d Retrun object paths for newly created filter associations. Fix to return the resulting new association object path at the end CreateInstance for Nested and AppliedFilterList. This is simply passing back the object path that was passed to the provider if there are no failures during the creation process. Signed-off-by: Chip Vincent diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c --- a/src/Virt_AppliedFilterList.c +++ b/src/Virt_AppliedFilterList.c @@ -508,6 +508,7 @@ goto out; } + CMReturnObjectPath(results, reference); CU_DEBUG("CreateInstance complete"); out: diff --git a/src/Virt_NestedFilterList.c b/src/Virt_NestedFilterList.c --- a/src/Virt_NestedFilterList.c +++ b/src/Virt_NestedFilterList.c @@ -386,6 +386,7 @@ goto out; } + CMReturnObjectPath(results, reference); CU_DEBUG("CreateInstance completed"); out: From xiawenc at linux.vnet.ibm.com Mon Aug 8 03:04:49 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Mon, 08 Aug 2011 11:04:49 +0800 Subject: [Libvirt-cim] [PATCH] bug fix: KVM_MemResourceAllocationSettingData does not conform to profile In-Reply-To: <4E3267C6.3060108@linux.vnet.ibm.com> References: <4E3267C6.3060108@linux.vnet.ibm.com> Message-ID: <4E3F5251.8070402@linux.vnet.ibm.com> Tried to changing all allocation unit in the libvirt-cim, but it seems these changes would be exposed to the user, so I think this may have impact to existing user case. I thought it would be better to waiting for a profile updating, what's your ideas? > ? 2011-7-22 9:19, Gareth S Bestor ??: >> >> So long as this new VM memory RASD AllocationUnits ("byte*2^10") will >> match that of the MemoryPool capabilities' RASDs, and the new 'augmented >> BNF' string is parsed ok when passed as an embedded instance to the >> cimom (pegasus, sfcb) then I'm okay with this one-off too. Both these >> are required otherwise existing usecases will break. >> >> - G > Searching the project , I do find another place using the old string: > Virt_SettingsDefineCapabilities.c:354: > > CMSetProperty(inst, "AllocationUnits", > (CMPIValue *)"KiloBytes", CMPI_chars); > > After this is changed, I thought the libvirt-cim would have no more > "KiloBytes". But I don't understand the BNF' string you refered, could > u give more tips about that? > >> >> Dr. Gareth S. Bestor >> IBM Senior Software Engineer >> Systems & Technology Group - Systems Management Standards >> 971-285-6375 (mobile) >> bestor at us.ibm.com >> >> >> >> *Re: [Libvirt-cim] [PATCH] bug fix: KVM_MemResourceAllocationSettingData >> does not conform to profile* >> >> >> *Chip Vincent * to: libvirt-cim >> 07/21/11 05:50 PM >> >> >> Sent by: *libvirt-cim-bounces at redhat.com* >> >> >> *Please respond to cvincent, List for discussion and development of >> libvirt CIM * >> >> >> >> >> >> >> >> We do have a schema update planned for this year. I think the origianl >> plan was just to update the schema but perhaps we should rebase some of >> the profiles as a follow on. If everyone agrees we should rebase the >> profiles as part of the schema update, then I'm okay with this as a >> 'one-off' change for now. >> >> Comments? >> >> On 07/21/2011 11:52 AM, Gareth S Bestor wrote: >> > >> > } else if (dev->type == CIM_RES_TYPE_MEM) { >> > - const char *units = "KiloBytes"; >> > + const char *units = "byte*2^10"; >> > >> > >> > If we're doing this sorta change here then we should probably do it >> > everywhere, since users may be checking AllocationUnits between CIM >> > classes. Specifically, these should match the units being returned from >> > memory pool capabilities, and we need to check these new units will be >> > correctly parsed when passed as embedded instances (eg DefineSystem(), >> > ModifyResourceSettings(), etc)... Alternatively, we might want to >> > consider going thru the entire libvirt-cim suite and upgrading all >> > classes from DSP0004v2.4 to DSP0004 2.5+ conformance level (ie using >> > Augmented BNFeverywhere its relevant) rather than having in old and new >> > units sprinkled around. >> > >> > Basically, doing this change here and now may have much wider >> implications. >> > >> > - Gareth >> > >> > Dr. Gareth S. Bestor >> > IBM Senior Software Engineer >> > Systems & Technology Group - Systems Management Standards >> > 971-285-6375 (mobile) >> > bestor at us.ibm.com >> > >> > >> > >> > *[Libvirt-cim] [PATCH] bug fix: KVM_MemResourceAllocationSettingData >> > does not conform to profile* >> > >> > >> > *Wayne Xia * to: List for discussion and development of libvirt CIM >> > 07/21/11 12:34 AM >> > >> > >> > Sent by: *libvirt-cim-bounces at redhat.com* >> > >> > >> > *Please respond to List for discussion and development of libvirt CIM * >> > >> > >> > >> > >> > >> ------------------------------------------------------------------------ >> > >> > >> > >> > # HG changeset patch >> > # User Wayne Xia >> > # Date 1311231387 -28800 >> > # Node ID 677867c3d2a16a97591bde2828808f9f39b859a7 >> > # Parent 3c90a88a5199a4ed931a4a76097cff8f55deae41 >> > changed a bit to make it conform to CIM profile >> > >> > According to the discuss and profile, the reserved property means the >> > memory actually allocated to support the VM running, and the unit >> > should be byte*2^10. This patch added some code to retrieve VM's state, >> > and the report the memory status according to that. >> > https://bugzilla.linux.ibm.com/show_bug.cgi?id=72759 >> > >> > Signed-off-by: Wayne Xia >> > >> > diff -r 3c90a88a5199 -r 677867c3d2a1 libxkutil/device_parsing.c >> > --- a/libxkutil/device_parsing.c Mon Jul 18 11:13:40 2011 -0300 >> > +++ b/libxkutil/device_parsing.c Thu Jul 21 14:56:27 2011 +0800 >> > @@ -792,6 +792,7 @@ >> > } else if (dev->type == CIM_RES_TYPE_MEM) { >> > dev->dev.mem.size = _dev->dev.mem.size; >> > dev->dev.mem.maxsize = _dev->dev.mem.maxsize; >> > + dev->dev.mem.reserved = _dev->dev.mem.reserved; >> > } else if (dev->type == CIM_RES_TYPE_PROC) { >> > dev->dev.vcpu.quantity = _dev->dev.vcpu.quantity; >> > } else if (dev->type == CIM_RES_TYPE_EMU) { >> > @@ -885,8 +886,22 @@ >> > if (xml == NULL) >> > return 0; >> > >> > - if (type == CIM_RES_TYPE_MEM) >> > + if (type == CIM_RES_TYPE_MEM) { >> > ret = _get_mem_device(xml, list); >> > + if (*list != NULL) { >> > + virDomainInfo dom_info; >> > + if (virDomainGetInfo(dom, &dom_info) == 0) { >> > + (*list)->dev.mem.reserved = dom_info.memory; >> > + if (dom_info.state == 5) { /* VM not active */ >> > + (*list)->dev.mem.reserved = 0; >> > + } >> > + } >> > + else { >> > + CU_DEBUG("failed to get dom state for mem"); >> > + ret = -1; >> > + } >> > + } >> > + } >> > else if (type == CIM_RES_TYPE_PROC) >> > ret = _get_proc_device(xml, list); >> > else >> > diff -r 3c90a88a5199 -r 677867c3d2a1 libxkutil/device_parsing.h >> > --- a/libxkutil/device_parsing.h Mon Jul 18 11:13:40 2011 -0300 >> > +++ b/libxkutil/device_parsing.h Thu Jul 21 14:56:27 2011 +0800 >> > @@ -71,6 +71,7 @@ >> > struct mem_device { >> > uint64_t size; >> > uint64_t maxsize; >> > + uint64_t reserved; >> > }; >> > >> > struct vcpu_device { >> > diff -r 3c90a88a5199 -r 677867c3d2a1 src/Virt_RASD.c >> > --- a/src/Virt_RASD.c Mon Jul 18 11:13:40 2011 -0300 >> > +++ b/src/Virt_RASD.c Thu Jul 21 14:56:27 2011 +0800 >> > @@ -576,14 +576,14 @@ >> > inst); >> > >> > } else if (dev->type == CIM_RES_TYPE_MEM) { >> > - const char *units = "KiloBytes"; >> > + const char *units = "byte*2^10"; >> > >> > CMSetProperty(inst, "AllocationUnits", >> > (CMPIValue *)units, CMPI_chars); >> > CMSetProperty(inst, "VirtualQuantity", >> > (CMPIValue *)&dev->dev.mem.size, >> > CMPI_uint64); >> > CMSetProperty(inst, "Reservation", >> > - (CMPIValue *)&dev->dev.mem.size, >> > CMPI_uint64); >> > + (CMPIValue *)&dev->dev.mem.reserved, >> > CMPI_uint64); >> > CMSetProperty(inst, "Limit", >> > (CMPIValue *)&dev->dev.mem.maxsize, >> > CMPI_uint64); >> > } else if (dev->type == CIM_RES_TYPE_PROC) { >> > >> > _______________________________________________ >> > Libvirt-cim mailing list >> > Libvirt-cim at redhat.com >> > https://www.redhat.com/mailman/listinfo/libvirt-cim >> > >> > >> > >> > _______________________________________________ >> > Libvirt-cim mailing list >> > Libvirt-cim at redhat.com >> > https://www.redhat.com/mailman/listinfo/libvirt-cim >> >> -- >> Chip Vincent >> Open Virtualization >> IBM Linux Technology Center >> cvincent at linux.vnet.ibm.com >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim >> >> >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim > > -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From xiawenc at linux.vnet.ibm.com Tue Aug 9 07:16:12 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Tue, 09 Aug 2011 15:16:12 +0800 Subject: [Libvirt-cim] Network-pool seems not conform to profile Message-ID: <4E40DEBC.6040401@linux.vnet.ibm.com> By executing following command: wbemcli -nl ei http://root:123456 at localhost:5988/root/virt:KVM_NetworkPool There would be 2 network pool, NetworkPool/default and NetworkPool/0. I think NetworkPool/0 is OK, which represent the primordial pool for network device, but NetworkPool/default should not be there, because it comes from the calling of the libvirt's API which returns the existing logical network device on the host, not the network pool. Another issue is that, it seems now libvirt-cim supports the creation of NetworkPool as a child, but the libvirt now does not support that. So I think this function should be removed, otherwise we need extra files to record the organization of the network pools. -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From snmishra at us.ibm.com Tue Aug 9 16:52:26 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Tue, 9 Aug 2011 09:52:26 -0700 Subject: [Libvirt-cim] Network-pool seems not conform to profile In-Reply-To: <4E40DEBC.6040401@linux.vnet.ibm.com> References: <4E40DEBC.6040401@linux.vnet.ibm.com> Message-ID: Libvirt-cim handles networking differently. I think, we need to decide if we want to change it and open a work item to handle it. Regards, Sharad Mishra Open Virtualization Linux Technology Center IBM Wayne Xia To Sent by: List for discussion and development libvirt-cim-bounc of libvirt CIM es at redhat.com cc 08/09/11 12:16 AM Subject [Libvirt-cim] Network-pool seems not conform to profile Please respond to List for discussion and development of libvirt CIM By executing following command: wbemcli -nl ei http://root:123456 at localhost:5988/root/virt:KVM_NetworkPool There would be 2 network pool, NetworkPool/default and NetworkPool/0. I think NetworkPool/0 is OK, which represent the primordial pool for network device, but NetworkPool/default should not be there, because it comes from the calling of the libvirt's API which returns the existing logical network device on the host, not the network pool. Another issue is that, it seems now libvirt-cim supports the creation of NetworkPool as a child, but the libvirt now does not support that. So I think this function should be removed, otherwise we need extra files to record the organization of the network pools. -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 _______________________________________________ Libvirt-cim mailing list Libvirt-cim at redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: graycol.gif Type: image/gif Size: 105 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pic32568.gif Type: image/gif Size: 1255 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ecblank.gif Type: image/gif Size: 45 bytes Desc: not available URL: From xiawenc at linux.vnet.ibm.com Wed Aug 10 05:31:59 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Wed, 10 Aug 2011 13:31:59 +0800 Subject: [Libvirt-cim] [PATCH] (#2) bugfix: KVM_MemResourceAllocationSettingData does not conform to profile Message-ID: # HG changeset patch # User Wayne Xia # Date 1311231387 -28800 # Node ID d4002b23fffc97fd358811d551abbce28659839b # Parent dd060dd8dbbd6c1d9a73de4dffa9fb2ab84d62b9 (#2) bugfix: KVM_MemResourceAllocationSettingData does not conform to profile According to the discuss and profile, the reserved property means the memory actually allocated to support the VM running, and the unit should be byte*2^10. This patch added some code to retrieve VM's state, and the report the memory status according to that. #2 removed the unit changing to avoid impacting to existing user case. Signed-off-by: Wayne Xia diff -r dd060dd8dbbd -r d4002b23fffc libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Thu Aug 04 11:22:32 2011 -0400 +++ b/libxkutil/device_parsing.c Thu Jul 21 14:56:27 2011 +0800 @@ -801,6 +801,7 @@ } else if (dev->type == CIM_RES_TYPE_MEM) { dev->dev.mem.size = _dev->dev.mem.size; dev->dev.mem.maxsize = _dev->dev.mem.maxsize; + dev->dev.mem.reserved = _dev->dev.mem.reserved; } else if (dev->type == CIM_RES_TYPE_PROC) { dev->dev.vcpu.quantity = _dev->dev.vcpu.quantity; } else if (dev->type == CIM_RES_TYPE_EMU) { @@ -895,8 +896,22 @@ if (xml == NULL) return 0; - if (type == CIM_RES_TYPE_MEM) + if (type == CIM_RES_TYPE_MEM) { ret = _get_mem_device(xml, list); + if (*list != NULL) { + virDomainInfo dom_info; + if (virDomainGetInfo(dom, &dom_info) == 0) { + (*list)->dev.mem.reserved = dom_info.memory; + if (dom_info.state == 5) { /* VM not active */ + (*list)->dev.mem.reserved = 0; + } + } + else { + CU_DEBUG("failed to get dom state for mem"); + ret = -1; + } + } + } else if (type == CIM_RES_TYPE_PROC) ret = _get_proc_device(xml, list); else diff -r dd060dd8dbbd -r d4002b23fffc libxkutil/device_parsing.h --- a/libxkutil/device_parsing.h Thu Aug 04 11:22:32 2011 -0400 +++ b/libxkutil/device_parsing.h Thu Jul 21 14:56:27 2011 +0800 @@ -72,6 +72,7 @@ struct mem_device { uint64_t size; uint64_t maxsize; + uint64_t reserved; }; struct vcpu_device { diff -r dd060dd8dbbd -r d4002b23fffc src/Virt_RASD.c --- a/src/Virt_RASD.c Thu Aug 04 11:22:32 2011 -0400 +++ b/src/Virt_RASD.c Thu Jul 21 14:56:27 2011 +0800 @@ -633,7 +633,7 @@ CMSetProperty(inst, "VirtualQuantity", (CMPIValue *)&dev->dev.mem.size, CMPI_uint64); CMSetProperty(inst, "Reservation", - (CMPIValue *)&dev->dev.mem.size, CMPI_uint64); + (CMPIValue *)&dev->dev.mem.reserved, CMPI_uint64); CMSetProperty(inst, "Limit", (CMPIValue *)&dev->dev.mem.maxsize, CMPI_uint64); } else if (dev->type == CIM_RES_TYPE_PROC) { From eblima at linux.vnet.ibm.com Wed Aug 10 19:53:37 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 10 Aug 2011 16:53:37 -0300 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Fixing potential null dereferences and leaks Message-ID: <8759e60c17c42101118f.1313006017@etrunko-t410.br.ibm.com> # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1312918075 10800 # Node ID 8759e60c17c42101118f914215d071138340c70f # Parent 0291fb05e93a0cbcbf2b80c894a47d58f7c37d23 VirtualSystemManagementService: Fixing potential null dereferences and leaks As reported in https://bugzilla.redhat.com/show_bug.cgi?id=728245 line 1048 - Comparing "path" to null implies that "path" might be null. line 1057 - Dereferencing null variable "path". line 1088 - Comparing "port" to null implies that "port" might be null. line 1094 - Dereferencing null variable "port". Signed-off-by: Eduardo Lima (Etrunko) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1054,8 +1054,12 @@ ret = 1; out: - CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", - *path, *port); + free(tmp_path); + free(tmp_port); + + if (path && port) + CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", + *path, *port); return ret; } @@ -1091,8 +1095,12 @@ ret = 1; out: - CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", - *ip, *port); + free(tmp_ip); + free(tmp_port); + + if (ip && port) + CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", + *ip, *port); return ret; } From eblima at linux.vnet.ibm.com Wed Aug 10 19:53:49 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 10 Aug 2011 16:53:49 -0300 Subject: [Libvirt-cim] [PATCH] acl_parsing: Fixing potential leaks Message-ID: <2b1b79a72ab0288d6493.1313006029@etrunko-t410.br.ibm.com> # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1313005735 10800 # Node ID 2b1b79a72ab0288d649399118dffce26fd05e066 # Parent 8759e60c17c42101118f914215d071138340c70f acl_parsing: Fixing potential leaks Also adds missing checks for errors in some function calls. As reported in https://bugzilla.redhat.com/show_bug.cgi?id=728245 line 144 - Function cleanup_filter does not free its parameter filter (this causes a lot of Coverity Resource leak warnings). line 397 - Dynamically allocated variable rule is not freed in function parse_acl_filter as a result of line #399. line 630 - Function "malloc" without NULL check. line 659 - Function "malloc" without NULL check. Signed-off-by: Eduardo Lima (Etrunko) diff --git a/libxkutil/acl_parsing.c b/libxkutil/acl_parsing.c --- a/libxkutil/acl_parsing.c +++ b/libxkutil/acl_parsing.c @@ -139,6 +139,7 @@ }; rule->type = UNKNOWN_RULE; + free(rule); } void cleanup_filter(struct acl_filter *filter) @@ -152,10 +153,8 @@ free(filter->name); free(filter->chain); - for (i = 0; i < filter->rule_ct; i++) { + for (i = 0; i < filter->rule_ct; i++) cleanup_rule(filter->rules[i]); - free(filter->rules[i]); - } free(filter->rules); filter->rule_ct = 0; @@ -401,14 +400,16 @@ if (parse_acl_rule(child, rule) == 0) goto err; - append_filter_rule(filter, rule); + if (append_filter_rule(filter, rule) == 0) + goto err; } else if (XSTREQ(child->name, "filterref")) { filter_ref = get_attr_value(child, "filter"); if (filter_ref == NULL) goto err; - append_filter_ref(filter, filter_ref); + if (append_filter_ref(filter, filter_ref) == 0) + goto err; } } @@ -440,14 +441,15 @@ if (xmldoc == NULL) goto err; - *filter = malloc(sizeof(**filter)); + *filter = calloc(1, sizeof(**filter)); if (*filter == NULL) goto err; - memset(*filter, 0, sizeof(**filter)); - parse_acl_filter(xmldoc->children, *filter); - - ret = 1; + ret = parse_acl_filter(xmldoc->children, *filter); + if (ret == 0) { + free(*filter); + *filter = NULL; + } err: xmlSetGenericErrorFunc(NULL, NULL); @@ -508,9 +510,7 @@ if (xml == NULL) return 0; - get_filter_from_xml(xml, filter); - - return 1; + return get_filter_from_xml(xml, filter); #else return 0; #endif @@ -534,7 +534,8 @@ virConnectListNWFilters(conn, names, count); - filters = malloc(count * sizeof(struct acl_filter)); + filters = calloc(count, sizeof(*filters)); + if (filters == NULL) goto err; @@ -542,7 +543,8 @@ { struct acl_filter *filter = NULL; - get_filter_by_name(conn, names[i], &filter); + if (get_filter_by_name(conn, names[i], &filter) == 0) + break; memcpy(&filters[i], filter, sizeof(*filter)); } @@ -630,6 +632,12 @@ filter->rules = malloc((filter->rule_ct + 1) * sizeof(struct acl_rule *)); + if (filter->rules == NULL) { + CU_DEBUG("Failed to allocate memory for new rule"); + filter->rules = old_rules; + return 0; + } + memcpy(filter->rules, old_rules, filter->rule_ct * sizeof(struct acl_rule *)); @@ -657,6 +665,13 @@ old_refs = filter->refs; filter->refs = malloc((filter->ref_ct + 1) * sizeof(char *)); + + if (filter->refs == NULL) { + CU_DEBUG("Failed to allocate memory for new ref"); + filter->refs = old_refs; + return 0; + } + memcpy(filter->refs, old_refs, filter->ref_ct * sizeof(char *)); filter->refs[filter->ref_ct] = name; @@ -682,8 +697,9 @@ if (STREQC(old_refs[i], name)) { free(old_refs[i]); } - else - append_filter_ref(filter, old_refs[i]); + else if(append_filter_ref(filter, old_refs[i]) == 0) { + return 0; + } } return 1; From snmishra at us.ibm.com Wed Aug 10 20:50:56 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Wed, 10 Aug 2011 13:50:56 -0700 Subject: [Libvirt-cim] [PATCH] Check to see if stream is non-null before closing Message-ID: # HG changeset patch # User Sharad Mishra # Date 1312828809 25200 # Node ID 8b4f6d69f40904ced24f7948f04f89e770e37bce # Parent dd060dd8dbbd6c1d9a73de4dffa9fb2ab84d62b9 Check to see if stream is non-null before closing. Added a check to see if the stream is non-null before calling close. Signed-off-by: Sharad Mishra diff -r dd060dd8dbbd -r 8b4f6d69f409 src/Virt_SwitchService.c --- a/src/Virt_SwitchService.c Thu Aug 04 11:22:32 2011 -0400 +++ b/src/Virt_SwitchService.c Mon Aug 08 11:40:09 2011 -0700 @@ -91,7 +91,8 @@ "No VSI Support found"); out: - pclose(stream); + if (stream != NULL) + pclose(stream); return s; } -------------- next part -------------- An HTML attachment was scrubbed... URL: From eblima at linux.vnet.ibm.com Wed Aug 10 21:02:59 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 10 Aug 2011 18:02:59 -0300 Subject: [Libvirt-cim] [PATCH] Check to see if stream is non-null before closing In-Reply-To: References: Message-ID: <4E42F203.3050105@linux.vnet.ibm.com> On 08/10/2011 05:50 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1312828809 25200 > # Node ID 8b4f6d69f40904ced24f7948f04f89e770e37bce > # Parent dd060dd8dbbd6c1d9a73de4dffa9fb2ab84d62b9 > Check to see if stream is non-null before closing. > > Added a check to see if the stream is non-null before > calling close. > > Signed-off-by: Sharad Mishra > > diff -r dd060dd8dbbd -r 8b4f6d69f409 src/Virt_SwitchService.c > --- a/src/Virt_SwitchService.c Thu Aug 04 11:22:32 2011 -0400 > +++ b/src/Virt_SwitchService.c Mon Aug 08 11:40:09 2011 -0700 > @@ -91,7 +91,8 @@ > "No VSI Support found"); > > out: > - pclose(stream); > + if (stream != NULL) > + pclose(stream); > return s; > } > +1 -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From xiawenc at linux.vnet.ibm.com Thu Aug 11 05:08:29 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Thu, 11 Aug 2011 13:08:29 +0800 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Fixing potential null dereferences and leaks In-Reply-To: <8759e60c17c42101118f.1313006017@etrunko-t410.br.ibm.com> References: <8759e60c17c42101118f.1313006017@etrunko-t410.br.ibm.com> Message-ID: <4E4363CD.3010503@linux.vnet.ibm.com> Seems fine, +1 ? 2011-8-11 3:53, Eduardo Lima (Etrunko) ??: > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1312918075 10800 > # Node ID 8759e60c17c42101118f914215d071138340c70f > # Parent 0291fb05e93a0cbcbf2b80c894a47d58f7c37d23 > VirtualSystemManagementService: Fixing potential null dereferences and leaks > > As reported in https://bugzilla.redhat.com/show_bug.cgi?id=728245 > > line 1048 - Comparing "path" to null implies that "path" might be null. > line 1057 - Dereferencing null variable "path". > line 1088 - Comparing "port" to null implies that "port" might be null. > line 1094 - Dereferencing null variable "port". > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -1054,8 +1054,12 @@ > ret = 1; > > out: > - CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", > - *path, *port); > + free(tmp_path); > + free(tmp_port); > + > + if (path&& port) > + CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", > + *path, *port); > > return ret; > } > @@ -1091,8 +1095,12 @@ > ret = 1; > > out: > - CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", > - *ip, *port); > + free(tmp_ip); > + free(tmp_port); > + > + if (ip&& port) > + CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", > + *ip, *port); > > return ret; > } > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From xiawenc at linux.vnet.ibm.com Thu Aug 11 08:48:18 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Thu, 11 Aug 2011 16:48:18 +0800 Subject: [Libvirt-cim] [PATCH] Check to see if stream is non-null before closing In-Reply-To: References: Message-ID: <4E439752.3060902@linux.vnet.ibm.com> +1 ? 2011-8-11 4:50, Sharad Mishra ??: > # HG changeset patch > # User Sharad Mishra > # Date 1312828809 25200 > # Node ID 8b4f6d69f40904ced24f7948f04f89e770e37bce > # Parent dd060dd8dbbd6c1d9a73de4dffa9fb2ab84d62b9 > Check to see if stream is non-null before closing. > > Added a check to see if the stream is non-null before > calling close. > > Signed-off-by: Sharad Mishra > > diff -r dd060dd8dbbd -r 8b4f6d69f409 src/Virt_SwitchService.c > --- a/src/Virt_SwitchService.c Thu Aug 04 11:22:32 2011 -0400 > +++ b/src/Virt_SwitchService.c Mon Aug 08 11:40:09 2011 -0700 > @@ -91,7 +91,8 @@ > "No VSI Support found"); > > out: > - pclose(stream); > + if (stream != NULL) > + pclose(stream); > return s; > } > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From xiawenc at linux.vnet.ibm.com Thu Aug 11 09:07:32 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Thu, 11 Aug 2011 17:07:32 +0800 Subject: [Libvirt-cim] Network-pool seems not conform to profile In-Reply-To: References: <4E40DEBC.6040401@linux.vnet.ibm.com> Message-ID: <4E439BD4.1000505@linux.vnet.ibm.com> Did more investigation about that, I thought the original author may want to create one child pool for every different type of networks, but currently , when guest have network device with "source bridge" in xml, there is no such pool as parent shown. ? 2011-8-10 0:52, Sharad Mishra ??: > Libvirt-cim handles networking differently. I think, we need to decide > if we want to change it and open a work item to handle it. > > Regards, > Sharad Mishra > Open Virtualization > Linux Technology Center > IBM > > Inactive hide details for Wayne Xia ---08/09/2011 12:18:34 AM---By > executing following command: Wayne Xia ---08/09/2011 12:18:34 AM---By > executing following command: > > *Wayne Xia * > Sent by: libvirt-cim-bounces at redhat.com > > 08/09/11 12:16 AM > Please respond to > List for discussion and development of libvirt > CIM > > > > To > > List for discussion and development of libvirt CIM > > cc > > > Subject > > [Libvirt-cim] Network-pool seems not conform to profile > > > > > By executing following command: > wbemcli -nl ei http://root:123456 at localhost:5988/root/virt:KVM_NetworkPool > > > There would be 2 network pool, NetworkPool/default and > NetworkPool/0. I think NetworkPool/0 is OK, which represent the > primordial pool for network device, but NetworkPool/default should not > be there, because it comes from the calling of the libvirt's API which > returns the existing logical network device on the host, not the > network pool. > > Another issue is that, it seems now libvirt-cim supports the creation > of NetworkPool as a child, but the libvirt now does not support that. > So I think this function should be removed, otherwise we need extra > files to record the organization of the network pools. > > > -- > Best Regards > > Wayne Xia > mail:xiawenc at linux.vnet.ibm.com > tel:86-010-82450803 > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From eblima at linux.vnet.ibm.com Thu Aug 11 15:09:03 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 11 Aug 2011 12:09:03 -0300 Subject: [Libvirt-cim] [PATCH] device_parsing: Fixing potential leaks Message-ID: # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1313075262 10800 # Node ID c0f20dbefb8fd73c278a619bbbd2efb567da07d4 # Parent 2b1b79a72ab0288d649399118dffce26fd05e066 device_parsing: Fixing potential leaks As reported in https://bugzilla.redhat.com/show_bug.cgi?id=728245 line 106 - Function cleanup_virt_device does not free its parameter dev (this causes a lot of Coverity Resource leak warnings). In future use cases, please consider using cleanup_virt_devices function instead of cleanup_virt_device if the virt_device structure is allocated dynamically. Signed-off-by: Eduardo Lima (Etrunko) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -829,12 +829,10 @@ if (ret <= 0) return ret; - mdev = malloc(sizeof(*mdev)); + mdev = calloc(1, sizeof(*mdev)); if (mdev == NULL) return 0; - memset(mdev, 0, sizeof(*mdev)); - /* We could get one or two memory devices back, depending on * if there is a currentMemory tag or not. Coalesce these * into a single device to return @@ -870,12 +868,10 @@ if (ret <= 0) return ret; - proc_dev = malloc(sizeof(*proc_dev)); + proc_dev = calloc(1, sizeof(*proc_dev)); if (proc_dev == NULL) return 0; - memset(proc_dev, 0, sizeof(*proc_dev)); - proc_dev->type = CIM_RES_TYPE_PROC; proc_dev->id = strdup("proc"); proc_dev->dev.vcpu.quantity = proc_devs[0].dev.vcpu.quantity; @@ -1031,8 +1027,6 @@ xmlNode **nodes = nsv->nodeTab; xmlNode *child; - memset(dominfo, 0, sizeof(*dominfo)); - dominfo->typestr = get_attr_value(nodes[0], "type"); for (child = nodes[0]->children; child != NULL; child = child->next) { @@ -1098,7 +1092,7 @@ int ret; CU_DEBUG("In get_dominfo_from_xml"); - *dominfo = malloc(sizeof(**dominfo)); + *dominfo = calloc(1, sizeof(**dominfo)); if (*dominfo == NULL) return 0; diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -832,7 +832,7 @@ dominfo->dev_input = dev; break; default: - cleanup_virt_device(dev); + cleanup_virt_devices(&dev, 1); goto out; } diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c --- a/src/Virt_AppliedFilterList.c +++ b/src/Virt_AppliedFilterList.c @@ -516,7 +516,7 @@ free(net_name); cleanup_filter(filter); - cleanup_virt_device(device); + cleanup_virt_devices(&device, 1); virDomainFree(dom); virConnectClose(conn); @@ -626,7 +626,7 @@ free(net_name); cleanup_filter(filter); - cleanup_virt_device(device); + cleanup_virt_devices(&device, 1); virDomainFree(dom); virConnectClose(conn); diff --git a/src/Virt_Device.c b/src/Virt_Device.c --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -700,14 +700,15 @@ } for (i = 0; i < count; i++) { - if (STREQC(device, list[i].id)) + if (STREQC(device, list[i].id)) { dev = virt_device_dup(&list[i]); + break; + } - cleanup_virt_device(&list[i]); } + cleanup_virt_devices(&list, count); out: - free(list); return dev; } @@ -785,7 +786,7 @@ &tmp_list); } - cleanup_virt_device(dev); + cleanup_virt_devices(&dev, 1); *_inst = tmp_list.list[0]; diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -664,7 +664,7 @@ char *host = NULL; char *devid = NULL; virConnectPtr conn = NULL; - struct virt_device *dev; + struct virt_device *dev = NULL; conn = connect_by_classname(broker, CLASSNAME(reference), &s); if (conn == NULL) { @@ -700,8 +700,8 @@ "Failed to set instance properties"); else *_inst = inst; - - cleanup_virt_device(dev); + + cleanup_virt_devices(&dev, 1); out: virConnectClose(conn); @@ -863,10 +863,7 @@ tmp_dev->id = strdup("proc"); - for (i = 0; i < count; i++) - cleanup_virt_device(&devs[i]); - - free(devs); + cleanup_virt_devices(&devs, count); devs = tmp_dev; count = 1; } @@ -877,9 +874,6 @@ CMPI_RC_ERR_FAILED, "Failed to get domain name"); - for (i = 0; i < count; i++) - cleanup_virt_device(&devs[i]); - goto out; } @@ -893,12 +887,10 @@ properties); if (dev) inst_list_add(list, dev); - - cleanup_virt_device(&devs[i]); } out: - free(devs); + cleanup_virt_devices(&devs, count); return s; } diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -200,12 +200,6 @@ cleanup_virt_device(domain->dev_emu); - domain->dev_emu = calloc(1, sizeof(*domain->dev_emu)); - if (domain->dev_emu == NULL) { - CU_DEBUG("Failed to allocate default emulator device"); - return false; - } - domain->dev_emu->type = CIM_RES_TYPE_EMU; domain->dev_emu->dev.emu.path = strdup(emu); domain->dev_emu->id = strdup("emulator"); From eblima at linux.vnet.ibm.com Thu Aug 11 17:31:45 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 11 Aug 2011 14:31:45 -0300 Subject: [Libvirt-cim] [PATCH 0 of 2] Add SDL frame buffer support in libvirt-cim, V4 In-Reply-To: References: Message-ID: <4E441201.8030105@linux.vnet.ibm.com> On 07/29/2011 04:05 AM, Wayne Xia wrote: > these patches would add support of SDL frame buffer configuration. > Oh, I somehow missed these patches in my inbox. So sorry! Review following! -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From eblima at linux.vnet.ibm.com Thu Aug 11 17:43:58 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 11 Aug 2011 14:43:58 -0300 Subject: [Libvirt-cim] [PATCH 1 of 2] (#4) made the graphic structure as union In-Reply-To: <640ea61807cff06e1d15.1311923149@localhost6.localdomain6> References: <640ea61807cff06e1d15.1311923149@localhost6.localdomain6> Message-ID: <4E4414DE.8010003@linux.vnet.ibm.com> On 07/29/2011 04:05 AM, Wayne Xia wrote: [snip] > diff -r 0f42cab9c45c -r 640ea61807cf libxkutil/device_parsing.c > --- a/libxkutil/device_parsing.c Mon Jul 25 13:14:22 2011 -0700 > +++ b/libxkutil/device_parsing.c Mon Jul 25 19:39:08 2011 +0800 > @@ -88,13 +88,31 @@ > free(dev->path); > } > > +static void cleanup_vnc_device(struct graphics_device *dev) > +{ > + free(dev->type); > + free(dev->dev.vnc.port); > + free(dev->dev.vnc.host); > + free(dev->dev.vnc.keymap); > + free(dev->dev.vnc.passwd); > +} > + > +static void cleanup_sdl_device(struct graphics_device *dev) > +{ > + free(dev->type); > + free(dev->dev.sdl.display); > + free(dev->dev.sdl.xauth); > + free(dev->dev.sdl.fullscreen); > +} > + > static void cleanup_graphics_device(struct graphics_device *dev) > { > - free(dev->type); > - free(dev->port); > - free(dev->host); > - free(dev->keymap); > - free(dev->passwd); > + if (STREQC(dev->type, "sdl")) { > + cleanup_sdl_device(dev); > + } > + else { > + cleanup_vnc_device(dev); > + } > } > As dev->type is a common field, it should be on the cleanup_graphics function, while the cleanup_sdl and cleanup_vnc would handle the specifics thus avoiding code duplicity. > diff -r 0f42cab9c45c -r 640ea61807cf libxkutil/device_parsing.h > --- a/libxkutil/device_parsing.h Mon Jul 25 13:14:22 2011 -0700 > +++ b/libxkutil/device_parsing.h Mon Jul 25 19:39:08 2011 +0800 > @@ -84,14 +84,28 @@ > char *path; > }; > > -struct graphics_device { > - char *type; > +//vnc_device must be larger or equal than sdl_device With the specific cleanup functions this comment is not necessary. ACK, I think those small bits can be fixed before pushing. -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From eblima at linux.vnet.ibm.com Thu Aug 11 17:57:09 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 11 Aug 2011 14:57:09 -0300 Subject: [Libvirt-cim] [PATCH 2 of 2] (#4) add sdl frame buffer support In-Reply-To: References: Message-ID: <4E4417F5.5010907@linux.vnet.ibm.com> On 07/29/2011 04:05 AM, Wayne Xia wrote: > diff -r 640ea61807cf -r f170cdc0acb5 src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c Mon Jul 25 19:39:08 2011 +0800 > +++ b/src/Virt_VirtualSystemManagementService.c Tue Jul 26 17:02:51 2011 +0800 > @@ -1060,6 +1060,52 @@ > return ret; > } > > +static int parse_sdl_address(const char *id, > + char **display, > + char **xauth) > +{ > + int ret; > + char *tmp_display = NULL; > + char *tmp_xauth = NULL; > + > + CU_DEBUG("Entering parse_sdl_address, address is %s", id); > + > + ret = sscanf(id, "%a[^:]:%as",&tmp_xauth,&tmp_display); > + > + if (ret<= 0) { > + ret = sscanf(id, ":%as",&tmp_display); > + if (ret<= 0) { > + if (STREQC(id, ":")) { > + /* do nothing, it is empty */ > + } > + else { > + ret = 0; > + goto out; > + } > + } > + } > + > + if (display) { > + if (tmp_display == NULL) > + *display = NULL; > + else > + *display = strdup(tmp_display); > + } > + if (xauth) { > + if (tmp_xauth == NULL) > + *xauth = NULL; > + else > + *xauth = strdup(tmp_xauth); > + } > + ret = 1; > + > + out: This would leak tmp_display and tmp_xauth variables. According to sscanf(3), the 'a' character implies the resulting buffer should be freed. free(tmp_display); free(tmp_xauth); > + CU_DEBUG("Exiting parse_sdl_address, display is %s, xauth is %s", > + *display, *xauth); > + > + return ret; > +} ACK. Again, this could be fixed before push. -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From bestor at us.ibm.com Thu Aug 11 18:55:55 2011 From: bestor at us.ibm.com (Gareth S Bestor) Date: Thu, 11 Aug 2011 11:55:55 -0700 Subject: [Libvirt-cim] Is virStoragePoolRefresh() synchronous or asynchronous? Message-ID: Basically, when you call virStoragePoolRefresh(), eg to pickup any new disks that may have just been created under the pool path, when the API returns are you guaranteed that the refresh operation is completed, or might the pool still be refreshing itself? I ask because I understand this refresh operation can be 'expensive', so I'm wondering if in fact things may still be going on in the background after the API returns... - Gareth Dr. Gareth S. Bestor IBM Senior Software Engineer Systems & Technology Group - Systems Management Standards 971-285-6375 (mobile) bestor at us.ibm.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From eblima at linux.vnet.ibm.com Thu Aug 11 20:42:06 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 11 Aug 2011 17:42:06 -0300 Subject: [Libvirt-cim] Is virStoragePoolRefresh() synchronous or asynchronous? In-Reply-To: References: Message-ID: <4E443E9E.3030604@linux.vnet.ibm.com> On 08/11/2011 03:55 PM, Gareth S Bestor wrote: > > Basically, when you call virStoragePoolRefresh(), eg to pickup any new > disks that may have just been created under the pool path, when the API > returns are you guaranteed that the refresh operation is completed, or > might the pool still be refreshing itself? I ask because I understand > this refresh operation can be 'expensive', so I'm wondering if in fact > things may still be going on in the background after the API returns... > I can't really tell for sure due to very little knowledge of libvirt code, but I took a quick look there and nothing shows the virStoragePoolRefresh could be asynchronous. In fact, the function will fail if there are any jobs pending. > - Gareth > > Dr. Gareth S. Bestor > IBM Senior Software Engineer > Systems & Technology Group - Systems Management Standards > 971-285-6375 (mobile) > bestor at us.ibm.com > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From snmishra at us.ibm.com Fri Aug 12 00:20:10 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 11 Aug 2011 17:20:10 -0700 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Fixing potential null dereferences and leaks In-Reply-To: <4E4363CD.3010503@linux.vnet.ibm.com> References: <8759e60c17c42101118f.1313006017@etrunko-t410.br.ibm.com> <4E4363CD.3010503@linux.vnet.ibm.com> Message-ID: +1 Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces at redhat.com wrote on 08/10/2011 10:08:29 PM: > Wayne Xia > Sent by: libvirt-cim-bounces at redhat.com > > 08/10/11 10:08 PM > > Please respond to > List for discussion and development of libvirt CIM > > To > > List for discussion and development of libvirt CIM > > cc > > Subject > > Re: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Fixing > potential null dereferences and leaks > > Seems fine, +1 > > ? 2011-8-11 3:53, Eduardo Lima (Etrunko) ??: > > # HG changeset patch > > # User Eduardo Lima (Etrunko) > > # Date 1312918075 10800 > > # Node ID 8759e60c17c42101118f914215d071138340c70f > > # Parent 0291fb05e93a0cbcbf2b80c894a47d58f7c37d23 > > VirtualSystemManagementService: Fixing potential null dereferencesand leaks > > > > As reported in https://bugzilla.redhat.com/show_bug.cgi?id=728245 > > > > line 1048 - Comparing "path" to null implies that "path" might be null. > > line 1057 - Dereferencing null variable "path". > > line 1088 - Comparing "port" to null implies that "port" might be null. > > line 1094 - Dereferencing null variable "port". > > > > Signed-off-by: Eduardo Lima (Etrunko) > > > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/ > Virt_VirtualSystemManagementService.c > > --- a/src/Virt_VirtualSystemManagementService.c > > +++ b/src/Virt_VirtualSystemManagementService.c > > @@ -1054,8 +1054,12 @@ > > ret = 1; > > > > out: > > - CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", > > - *path, *port); > > + free(tmp_path); > > + free(tmp_port); > > + > > + if (path&& port) > > + CU_DEBUG("Exiting parse_console_address, ip is % > s, port is %s", > > + *path, *port); > > > > return ret; > > } > > @@ -1091,8 +1095,12 @@ > > ret = 1; > > > > out: > > - CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", > > - *ip, *port); > > + free(tmp_ip); > > + free(tmp_port); > > + > > + if (ip&& port) > > + CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", > > + *ip, *port); > > > > return ret; > > } > > > > _______________________________________________ > > Libvirt-cim mailing list > > Libvirt-cim at redhat.com > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > > -- > Best Regards > > Wayne Xia > mail:xiawenc at linux.vnet.ibm.com > tel:86-010-82450803 > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From xiawenc at linux.vnet.ibm.com Fri Aug 12 02:53:09 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Fri, 12 Aug 2011 10:53:09 +0800 Subject: [Libvirt-cim] Is virStoragePoolRefresh() synchronous or asynchronous? In-Reply-To: References: Message-ID: <4E449595.2030409@linux.vnet.ibm.com> Took a quick look at libvirt's code, it seems not to create a thread for this, and in virsh.c,line 6306: static bool cmdPoolRefresh(vshControl *ctl, const vshCmd *cmd) { virStoragePoolPtr pool; bool ret = true; const char *name; if (!vshConnectionUsability(ctl, ctl->conn)) return false; if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) return false; if (virStoragePoolRefresh(pool, 0) == 0) { vshPrint(ctl, _("Pool %s refreshed\n"), name); } else { vshError(ctl, _("Failed to refresh pool %s"), name); ret = false; } virStoragePoolFree(pool); return ret; } this showed the calling of this API have just 2 result: succeed or fail, so I think it is synchronize calling. ? 2011-8-12 2:55, Gareth S Bestor ??: > > Basically, when you call virStoragePoolRefresh(), eg to pickup any new > disks that may have just been created under the pool path, when the API > returns are you guaranteed that the refresh operation is completed, or > might the pool still be refreshing itself? I ask because I understand > this refresh operation can be 'expensive', so I'm wondering if in fact > things may still be going on in the background after the API returns... > > - Gareth > > Dr. Gareth S. Bestor > IBM Senior Software Engineer > Systems & Technology Group - Systems Management Standards > 971-285-6375 (mobile) > bestor at us.ibm.com > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From xiawenc at linux.vnet.ibm.com Fri Aug 12 03:00:39 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Fri, 12 Aug 2011 11:00:39 +0800 Subject: [Libvirt-cim] [PATCH 0 of 2] Add SDL frame buffer support in libvirt-cim, V5 Message-ID: these patches would add support for SDL frame buffer configuration, also fix some memory leak problem. From xiawenc at linux.vnet.ibm.com Fri Aug 12 03:00:40 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Fri, 12 Aug 2011 11:00:40 +0800 Subject: [Libvirt-cim] [PATCH 1 of 2] (#5) made the graphic structure as union In-Reply-To: References: Message-ID: <03cc267a3d534f19eb48.1313118040@localhost6.localdomain6> # HG changeset patch # User Wayne Xia # Date 1311593948 -28800 # Node ID 03cc267a3d534f19eb489be3c430ea5de8787ccc # Parent 8b4f6d69f40904ced24f7948f04f89e770e37bce (#5) made the graphic structure as union These change were made to allow SDL device properties added more clearly #5 removed tailing space and some comments, added different free functions for graphic device. Signed-off-by: Wayne Xia (Wayne) diff -r 8b4f6d69f409 -r 03cc267a3d53 libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Mon Aug 08 11:40:09 2011 -0700 +++ b/libxkutil/device_parsing.c Mon Jul 25 19:39:08 2011 +0800 @@ -88,13 +88,30 @@ free(dev->path); } +static void cleanup_vnc_device(struct graphics_device *dev) +{ + free(dev->dev.vnc.port); + free(dev->dev.vnc.host); + free(dev->dev.vnc.keymap); + free(dev->dev.vnc.passwd); +} + +static void cleanup_sdl_device(struct graphics_device *dev) +{ + free(dev->dev.sdl.display); + free(dev->dev.sdl.xauth); + free(dev->dev.sdl.fullscreen); +} + static void cleanup_graphics_device(struct graphics_device *dev) { + if (STREQC(dev->type, "sdl")) { + cleanup_sdl_device(dev); + } + else { + cleanup_vnc_device(dev); + } free(dev->type); - free(dev->port); - free(dev->host); - free(dev->keymap); - free(dev->passwd); } static void cleanup_input_device(struct input_device *dev) @@ -530,12 +547,12 @@ CU_DEBUG("graphics device type = %s", gdev->type); if (STREQC(gdev->type, "vnc")) { - gdev->port = get_attr_value(node, "port"); - gdev->host = get_attr_value(node, "listen"); - gdev->keymap = get_attr_value(node, "keymap"); - gdev->passwd = get_attr_value(node, "passwd"); + gdev->dev.vnc.port = get_attr_value(node, "port"); + gdev->dev.vnc.host = get_attr_value(node, "listen"); + gdev->dev.vnc.keymap = get_attr_value(node, "keymap"); + gdev->dev.vnc.passwd = get_attr_value(node, "passwd"); - if (gdev->port == NULL || gdev->host == NULL) + if (gdev->dev.vnc.port == NULL || gdev->dev.vnc.host == NULL) goto err; } else if (STREQC(gdev->type, "pty")) { @@ -550,9 +567,9 @@ for (child = node->children; child != NULL; child = child->next) { if (XSTREQ(child->name, "source")) - gdev->host = get_attr_value(child, "path"); + gdev->dev.vnc.host = get_attr_value(child, "path"); else if (XSTREQ(child->name, "target")) - gdev->port = get_attr_value(child, "port"); + gdev->dev.vnc.port = get_attr_value(child, "port"); } } else { @@ -565,7 +582,7 @@ if (STREQC(gdev->type, "vnc")) ret = asprintf(&vdev->id, "%s", gdev->type); else - ret = asprintf(&vdev->id, "%s:%s", gdev->type, gdev->port); + ret = asprintf(&vdev->id, "%s:%s", gdev->type, gdev->dev.vnc.port); if (ret == -1) { CU_DEBUG("Failed to create graphics is string"); @@ -807,10 +824,10 @@ DUP_FIELD(dev, _dev, dev.emu.path); } else if (dev->type == CIM_RES_TYPE_GRAPHICS) { DUP_FIELD(dev, _dev, dev.graphics.type); - DUP_FIELD(dev, _dev, dev.graphics.port); - DUP_FIELD(dev, _dev, dev.graphics.host); - DUP_FIELD(dev, _dev, dev.graphics.keymap); - DUP_FIELD(dev, _dev, dev.graphics.passwd); + DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.host); + DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.port); + DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.keymap); + DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.passwd); } else if (dev->type == CIM_RES_TYPE_INPUT) { DUP_FIELD(dev, _dev, dev.input.type); DUP_FIELD(dev, _dev, dev.input.bus); diff -r 8b4f6d69f409 -r 03cc267a3d53 libxkutil/device_parsing.h --- a/libxkutil/device_parsing.h Mon Aug 08 11:40:09 2011 -0700 +++ b/libxkutil/device_parsing.h Mon Jul 25 19:39:08 2011 +0800 @@ -84,14 +84,27 @@ char *path; }; -struct graphics_device { - char *type; +struct vnc_device { char *port; char *host; char *keymap; char *passwd; }; +struct sdl_device { + char *display; + char *xauth; + char *fullscreen; +}; + +struct graphics_device { + char *type; + union { + struct vnc_device vnc; + struct sdl_device sdl; + } dev; +}; + struct input_device { char *type; char *bus; diff -r 8b4f6d69f409 -r 03cc267a3d53 libxkutil/xml_parse_test.c --- a/libxkutil/xml_parse_test.c Mon Aug 08 11:40:09 2011 -0700 +++ b/libxkutil/xml_parse_test.c Mon Jul 25 19:39:08 2011 +0800 @@ -116,7 +116,7 @@ FILE *d) { print_value(d, "Graphics Type", dev->dev.graphics.type); - print_value(d, "Graphics Port", dev->dev.graphics.port); + print_value(d, "Graphics Port", dev->dev.graphics.dev.vnc.port); } static void print_devices(struct domain *dominfo, diff -r 8b4f6d69f409 -r 03cc267a3d53 libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c Mon Aug 08 11:40:09 2011 -0700 +++ b/libxkutil/xmlgen.c Mon Jul 25 19:39:08 2011 +0800 @@ -424,22 +424,22 @@ if (STREQC(dev->type, "sdl")) return NULL; - if (dev->port) { - xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); - if (STREQC(dev->port, "-1")) + if (dev->dev.vnc.port) { + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->dev.vnc.port); + if (STREQC(dev->dev.vnc.port, "-1")) xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes"); else xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no"); } - if (dev->host) - xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host); + if (dev->dev.vnc.host) + xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->dev.vnc.host); - if (dev->passwd) - xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST dev->passwd); + if (dev->dev.vnc.passwd) + xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST dev->dev.vnc.passwd); - if (dev->keymap) - xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap); + if (dev->dev.vnc.keymap) + xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->dev.vnc.keymap); return NULL; } @@ -459,16 +459,16 @@ tmp = xmlNewChild(pty, NULL, BAD_CAST "source", NULL); if (tmp == NULL) return XML_ERROR; - - if(dev->host) - xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev->host); + + 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->port) - xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); + + if(dev->dev.vnc.port) + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->dev.vnc.port); return NULL; } diff -r 8b4f6d69f409 -r 03cc267a3d53 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Mon Aug 08 11:40:09 2011 -0700 +++ b/src/Virt_ComputerSystem.c Mon Jul 25 19:39:08 2011 +0800 @@ -104,7 +104,7 @@ "Virtual System (Console on %s://%s:%s)", domain->dev_graphics[0].dev.graphics.type, host, - domain->dev_graphics[0].dev.graphics.port); + domain->dev_graphics[0].dev.graphics.dev.vnc.port); else ret = asprintf(&cap, "Virtual System (No console)"); diff -r 8b4f6d69f409 -r 03cc267a3d53 src/Virt_Device.c --- a/src/Virt_Device.c Mon Aug 08 11:40:09 2011 -0700 +++ b/src/Virt_Device.c Mon Jul 25 19:39:08 2011 +0800 @@ -194,8 +194,8 @@ else rc = asprintf(&vp_str, "%s/%s:%s", dev->type, - dev->host, - dev->port); + dev->dev.vnc.host, + dev->dev.vnc.port); if (rc == -1) return 0; diff -r 8b4f6d69f409 -r 03cc267a3d53 src/Virt_KVMRedirectionSAP.c --- a/src/Virt_KVMRedirectionSAP.c Mon Aug 08 11:40:09 2011 -0700 +++ b/src/Virt_KVMRedirectionSAP.c Mon Jul 25 19:39:08 2011 +0800 @@ -366,7 +366,7 @@ continue; } - ret = sscanf(dominfo->dev_graphics->dev.graphics.port, + ret = sscanf(dominfo->dev_graphics->dev.graphics.dev.vnc.port, "%d", &lport); if (ret != 1) { diff -r 8b4f6d69f409 -r 03cc267a3d53 src/Virt_RASD.c --- a/src/Virt_RASD.c Mon Aug 08 11:40:09 2011 -0700 +++ b/src/Virt_RASD.c Mon Jul 25 19:39:08 2011 +0800 @@ -481,9 +481,9 @@ rc = asprintf(&addr_str, "%s", dev->dev.graphics.type); else { rc = asprintf(&addr_str, - "%s:%s", - dev->dev.graphics.host, - dev->dev.graphics.port); + "%s:%s", + dev->dev.graphics.dev.vnc.host, + dev->dev.graphics.dev.vnc.port); } CU_DEBUG("graphics Address = %s", addr_str); @@ -496,7 +496,7 @@ if (STREQC(dev->dev.graphics.type, "vnc")) { CMSetProperty(inst, "KeyMap", - (CMPIValue *)dev->dev.graphics.keymap, CMPI_chars); + (CMPIValue *)dev->dev.graphics.dev.vnc.keymap, CMPI_chars); conn = connect_by_classname(_BROKER, classname, &s); if (conn == NULL) @@ -511,7 +511,8 @@ goto out; } - if (dev->dev.graphics.passwd && strlen(dev->dev.graphics.passwd)) { + if (dev->dev.graphics.dev.vnc.passwd && + strlen(dev->dev.graphics.dev.vnc.passwd)) { CU_DEBUG("has password"); CMSetProperty(inst, "Password", (CMPIValue *)"********", CMPI_chars); diff -r 8b4f6d69f409 -r 03cc267a3d53 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Mon Aug 08 11:40:09 2011 -0700 +++ b/src/Virt_VirtualSystemManagementService.c Mon Jul 25 19:39:08 2011 +0800 @@ -370,10 +370,10 @@ } domain->dev_graphics->dev.graphics.type = strdup("vnc"); - domain->dev_graphics->dev.graphics.port = strdup("-1"); - domain->dev_graphics->dev.graphics.host = strdup("127.0.0.1"); - domain->dev_graphics->dev.graphics.keymap = strdup("en-us"); - domain->dev_graphics->dev.graphics.passwd = NULL; + domain->dev_graphics->dev.graphics.dev.vnc.port = strdup("-1"); + domain->dev_graphics->dev.graphics.dev.vnc.host = strdup("127.0.0.1"); + domain->dev_graphics->dev.graphics.dev.vnc.keymap = strdup("en-us"); + domain->dev_graphics->dev.graphics.dev.vnc.passwd = NULL; domain->dev_graphics_ct = 1; return true; @@ -1129,24 +1129,24 @@ } ret = parse_vnc_address(val, - &dev->dev.graphics.host, - &dev->dev.graphics.port); + &dev->dev.graphics.dev.vnc.host, + &dev->dev.graphics.dev.vnc.port); if (ret != 1) { msg = "GraphicsRASD field Address not valid"; goto out; } if (cu_get_str_prop(inst, "KeyMap", &val) != CMPI_RC_OK) - dev->dev.graphics.keymap = strdup("en-us"); + dev->dev.graphics.dev.vnc.keymap = strdup("en-us"); else - dev->dev.graphics.keymap = strdup(val); + dev->dev.graphics.dev.vnc.keymap = strdup(val); if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { CU_DEBUG("vnc password is not set"); - dev->dev.graphics.passwd = NULL; + dev->dev.graphics.dev.vnc.passwd = NULL; } else { CU_DEBUG("vnc password is set"); - dev->dev.graphics.passwd = strdup(val); + dev->dev.graphics.dev.vnc.passwd = strdup(val); } } else if (STREQC(dev->dev.graphics.type, "console") || @@ -1157,8 +1157,8 @@ } ret = parse_console_address(val, - &dev->dev.graphics.host, - &dev->dev.graphics.port); + &dev->dev.graphics.dev.vnc.host, + &dev->dev.graphics.dev.vnc.port); if (ret != 1) { msg = "GraphicsRASD field Address not valid"; goto out; @@ -1175,7 +1175,7 @@ ret = asprintf(&dev->id, "%s", dev->dev.graphics.type); else ret = asprintf(&dev->id, "%s:%s", - dev->dev.graphics.type, dev->dev.graphics.port); + dev->dev.graphics.type, dev->dev.graphics.dev.vnc.port); if (ret == -1) { msg = "Failed to create graphics is string"; From xiawenc at linux.vnet.ibm.com Fri Aug 12 03:00:41 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Fri, 12 Aug 2011 11:00:41 +0800 Subject: [Libvirt-cim] [PATCH 2 of 2] (#5) add sdl frame buffer support In-Reply-To: References: Message-ID: <80f69bdadfe2ffe05787.1313118041@localhost6.localdomain6> # HG changeset patch # User Wayne Xia # Date 1311670971 -28800 # Node ID 80f69bdadfe2ffe057873f4c0f6c8d6a0ef60816 # Parent 03cc267a3d534f19eb489be3c430ea5de8787ccc (#5) add sdl frame buffer support. Now libvirt still supports sdl frame buffer, and it may take three parameters: display,xauth,fullscreen. This patch enable the libvirt-cim to accept these configuration and pass them in XML define to let libvirt know about it. Exposed interface could be found in the file ResourceAllocationSettingData.mof. This Patch also fix some memory leak problem. #5 fixed the memory leak problem in Virt_VirtualSystemManagementService.c. Signed-off-by: Wayne Xia (Wayne) diff -r 03cc267a3d53 -r 80f69bdadfe2 libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Mon Jul 25 19:39:08 2011 +0800 +++ b/libxkutil/device_parsing.c Tue Jul 26 17:02:51 2011 +0800 @@ -555,6 +555,11 @@ if (gdev->dev.vnc.port == NULL || gdev->dev.vnc.host == NULL) goto err; } + else if (STREQC(gdev->type, "sdl")) { + gdev->dev.sdl.display = get_attr_value(node, "display"); + gdev->dev.sdl.xauth = get_attr_value(node, "xauth"); + gdev->dev.sdl.fullscreen = get_attr_value(node, "fullscreen"); + } else if (STREQC(gdev->type, "pty")) { if (node->name == NULL) goto err; diff -r 03cc267a3d53 -r 80f69bdadfe2 libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c Mon Jul 25 19:39:08 2011 +0800 +++ b/libxkutil/xmlgen.c Tue Jul 26 17:02:51 2011 +0800 @@ -421,8 +421,21 @@ xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); - if (STREQC(dev->type, "sdl")) - return NULL; + if (STREQC(dev->type, "sdl")) { + if (dev->dev.sdl.display) { + xmlNewProp(tmp, BAD_CAST "display", + BAD_CAST dev->dev.sdl.display); + } + if (dev->dev.sdl.xauth) { + xmlNewProp(tmp, BAD_CAST "xauth", + BAD_CAST dev->dev.sdl.xauth); + } + if (dev->dev.sdl.fullscreen) { + xmlNewProp(tmp, BAD_CAST "fullscreen", + BAD_CAST dev->dev.sdl.fullscreen); + } + return NULL; + } if (dev->dev.vnc.port) { xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->dev.vnc.port); diff -r 03cc267a3d53 -r 80f69bdadfe2 schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof Mon Jul 25 19:39:08 2011 +0800 +++ b/schema/ResourceAllocationSettingData.mof Tue Jul 26 17:02:51 2011 +0800 @@ -219,7 +219,9 @@ [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType " "is 'console', this is a character device path in " - "path:port format (e.g., '/dev/pts/3:0'\)")] + "path:port format (e.g., '/dev/pts/3:0'\) " + "if ResourceSubType is 'sdl', this is a combination of its params as " + "xauth:display (e.g., '/root/.Xauthority::0'\)")] string Address; [Description ("Keyboard keymapping")] @@ -228,7 +230,8 @@ [Description ("VNC password")] string Password; - [Description ("Is IPv6 only addressing is to be used")] + [Description ("Is IPv6 only addressing is to be used." + "if ResourceSubType is 'sdl', this means whether sdl is fullscreen")] boolean IsIPv6Only; }; diff -r 03cc267a3d53 -r 80f69bdadfe2 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Mon Jul 25 19:39:08 2011 +0800 +++ b/src/Virt_VirtualSystemManagementService.c Tue Jul 26 17:02:51 2011 +0800 @@ -1057,6 +1057,58 @@ CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", *path, *port); + free(tmp_path); + free(tmp_port); + + return ret; +} + +static int parse_sdl_address(const char *id, + char **display, + char **xauth) +{ + int ret; + char *tmp_display = NULL; + char *tmp_xauth = NULL; + + CU_DEBUG("Entering parse_sdl_address, address is %s", id); + + ret = sscanf(id, "%a[^:]:%as", &tmp_xauth, &tmp_display); + + if (ret <= 0) { + ret = sscanf(id, ":%as", &tmp_display); + if (ret <= 0) { + if (STREQC(id, ":")) { + /* do nothing, it is empty */ + } + else { + ret = 0; + goto out; + } + } + } + + if (display) { + if (tmp_display == NULL) + *display = NULL; + else + *display = strdup(tmp_display); + } + if (xauth) { + if (tmp_xauth == NULL) + *xauth = NULL; + else + *xauth = strdup(tmp_xauth); + } + ret = 1; + + out: + CU_DEBUG("Exiting parse_sdl_address, display is %s, xauth is %s", + *display, *xauth); + + free(tmp_display); + free(tmp_xauth); + return ret; } @@ -1094,6 +1146,9 @@ CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", *ip, *port); + free(tmp_ip); + free(tmp_port); + return ret; } @@ -1163,6 +1218,30 @@ msg = "GraphicsRASD field Address not valid"; goto out; } + } + else if (STREQC(dev->dev.graphics.type, "sdl")) { + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { + CU_DEBUG("sdl graphics Address empty, using default"); + dev->dev.graphics.dev.sdl.display = NULL; + dev->dev.graphics.dev.sdl.xauth = NULL; + } + else { + ret = parse_sdl_address(val, + &dev->dev.graphics.dev.sdl.display, + &dev->dev.graphics.dev.sdl.xauth); + if (ret != 1) { + msg = "GraphicsRASD sdl Address not valid"; + goto out; + } + } + dev->dev.graphics.dev.sdl.fullscreen = NULL; + if (cu_get_bool_prop(inst, "IsIPV6Only", &ipv6) == + CMPI_RC_OK) { + if (ipv6) + dev->dev.graphics.dev.sdl.fullscreen = strdup("yes"); + else + dev->dev.graphics.dev.sdl.fullscreen = strdup("no"); + } } else { CU_DEBUG("Unsupported graphics type %s", dev->dev.graphics.type); @@ -1171,7 +1250,8 @@ } free(dev->id); - if (STREQC(dev->dev.graphics.type, "vnc")) + if ((STREQC(dev->dev.graphics.type, "vnc"))|| + (STREQC(dev->dev.graphics.type, "sdl"))) ret = asprintf(&dev->id, "%s", dev->dev.graphics.type); else ret = asprintf(&dev->id, "%s:%s", From bestor at us.ibm.com Fri Aug 12 22:37:40 2011 From: bestor at us.ibm.com (Gareth S Bestor) Date: Fri, 12 Aug 2011 15:37:40 -0700 Subject: [Libvirt-cim] Patches for Virt_SettingsDefineCapabilities: incorrect Default ValueRole, strstr() misuse Message-ID: # HG changeset patch # User Gareth S. Bestor # Date 1313162799 25200 # Node ID 39c85f57c94fa36c681d4e9caa6e14617dcc7e60 # Parent 8b4f6d69f40904ced24f7948f04f89e770e37bce Patches for Virt_SettingsDefineCapabilities: incorrect Default ValueRole, strstr() misuse - The CIM_AllocationCapabilities for 'Default' RASDs have the incorrect ValueRole. per DSP1043 "Allocation Capabilities Profile", Section 10.5 "CIM_SettingsDefineCapabilities ? Default" the ValueRole should be 0 ("Default") - Fixed mistake with usage of strstr() swapping the arguments; should be: char *strstr(const char *haystack, const char *needle); This may not have mattered before when both strings were always exactly same or didnt match, but now for new 'Point' instances the instanceid has a prefix. Signed-off-by: Gareth S. Bestor diff -r 8b4f6d69f409 -r 39c85f57c94f src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Mon Aug 08 11:40:09 2011 -0700 +++ b/src/Virt_SettingsDefineCapabilities.c Fri Aug 12 08:26:39 2011 -0700 @@ -2054,19 +2054,22 @@ goto out; } - if (strstr("Default", iid) != NULL) + if (strstr(iid, "Default") != NULL) { valuerange = SDC_RANGE_POINT; - else if (strstr("Increment", iid) != NULL) + valuerole = SDC_ROLE_DEFAULT; + } + else if (strstr(iid, "Point") != NULL) + valuerange = SDC_RANGE_POINT; + else if (strstr(iid, "Increment") != NULL) valuerange = SDC_RANGE_INC; - else if (strstr("Maximum", iid) != NULL) + else if (strstr(iid, "Maximum") != NULL) valuerange = SDC_RANGE_MAX; - else if (strstr("Minimum", iid) != NULL) + else if (strstr(iid, "Minimum") != NULL) valuerange = SDC_RANGE_MIN; - else - CU_DEBUG("Unknown default RASD type: `%s'", iid); - - if (valuerange == SDC_RANGE_POINT) - valuerole = SDC_ROLE_DEFAULT; + else { + CU_DEBUG("Unknown RASD type: `%s'", iid); + goto out; + } CMSetProperty(ref_inst, "ValueRole", (CMPIValue *)&valuerole, CMPI_uint16); -------------- next part -------------- An HTML attachment was scrubbed... URL: From xiawenc at linux.vnet.ibm.com Mon Aug 15 02:05:36 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Mon, 15 Aug 2011 10:05:36 +0800 Subject: [Libvirt-cim] Patches for Virt_SettingsDefineCapabilities: incorrect Default ValueRole, strstr() misuse In-Reply-To: References: Message-ID: <4E487EF0.4@linux.vnet.ibm.com> Seems good, +1 ? 2011-8-13 6:37, Gareth S Bestor ??: > > # HG changeset patch > # User Gareth S. Bestor > # Date 1313162799 25200 > # Node ID 39c85f57c94fa36c681d4e9caa6e14617dcc7e60 > # Parent 8b4f6d69f40904ced24f7948f04f89e770e37bce > Patches for Virt_SettingsDefineCapabilities: incorrect Default > ValueRole, strstr() misuse > > - The CIM_AllocationCapabilities for 'Default' RASDs have the incorrect > ValueRole. per DSP1043 "Allocation Capabilities Profile", Section 10.5 > "CIM_SettingsDefineCapabilities ? Default" the ValueRole should be 0 > ("Default") > > - Fixed mistake with usage of strstr() swapping the arguments; should be: > char *strstr(const char *haystack, const char *needle); > This may not have mattered before when both strings were always exactly > same or didnt match, but now for new 'Point' instances the instanceid > has a prefix. > > Signed-off-by: Gareth S. Bestor > > diff -r 8b4f6d69f409 -r 39c85f57c94f src/Virt_SettingsDefineCapabilities.c > --- a/src/Virt_SettingsDefineCapabilities.c Mon Aug 08 11:40:09 2011 -0700 > +++ b/src/Virt_SettingsDefineCapabilities.c Fri Aug 12 08:26:39 2011 -0700 > @@ -2054,19 +2054,22 @@ > goto out; > } > > - if (strstr("Default", iid) != NULL) > + if (strstr(iid, "Default") != NULL) { > valuerange = SDC_RANGE_POINT; > - else if (strstr("Increment", iid) != NULL) > + valuerole = SDC_ROLE_DEFAULT; > + } > + else if (strstr(iid, "Point") != NULL) > + valuerange = SDC_RANGE_POINT; > + else if (strstr(iid, "Increment") != NULL) > valuerange = SDC_RANGE_INC; > - else if (strstr("Maximum", iid) != NULL) > + else if (strstr(iid, "Maximum") != NULL) > valuerange = SDC_RANGE_MAX; > - else if (strstr("Minimum", iid) != NULL) > + else if (strstr(iid, "Minimum") != NULL) > valuerange = SDC_RANGE_MIN; > - else > - CU_DEBUG("Unknown default RASD type: `%s'", iid); > - > - if (valuerange == SDC_RANGE_POINT) > - valuerole = SDC_ROLE_DEFAULT; > + else { > + CU_DEBUG("Unknown RASD type: `%s'", iid); > + goto out; > + } > > CMSetProperty(ref_inst, "ValueRole", > (CMPIValue *)&valuerole, CMPI_uint16); > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From cvincent at linux.vnet.ibm.com Tue Aug 16 22:14:57 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 16 Aug 2011 18:14:57 -0400 Subject: [Libvirt-cim] [PATCH] (#3) add sdl frame buffer support In-Reply-To: <4E31AE5E.8000200@linux.vnet.ibm.com> References: <4E31AE5E.8000200@linux.vnet.ibm.com> Message-ID: <4E4AEBE1.6060707@linux.vnet.ibm.com> On 07/28/2011 02:45 PM, Eduardo Lima (Etrunko) wrote: [snip] >> >> - [Description ("Is IPv6 only addressing is to be used")] >> + [Description ("Is IPv6 only addressing is to be used." >> + "if ResourceSubType is 'sdl', this means whether sdl is fullscreen")] >> boolean IsIPv6Only; >> }; > > Would be nice to hear comments about this 'change' in the schema from > the CIM experts. > Perfectly fine (and preferred) to update the Description qualifier. +1 -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Tue Aug 16 22:21:14 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 16 Aug 2011 18:21:14 -0400 Subject: [Libvirt-cim] [PATCH] acl_parsing: Fixing potential leaks In-Reply-To: <2b1b79a72ab0288d6493.1313006029@etrunko-t410.br.ibm.com> References: <2b1b79a72ab0288d6493.1313006029@etrunko-t410.br.ibm.com> Message-ID: <4E4AED5A.8010008@linux.vnet.ibm.com> Very nice. Thank you. +1 and pushed. On 08/10/2011 03:53 PM, Eduardo Lima (Etrunko) wrote: > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1313005735 10800 > # Node ID 2b1b79a72ab0288d649399118dffce26fd05e066 > # Parent 8759e60c17c42101118f914215d071138340c70f > acl_parsing: Fixing potential leaks > > Also adds missing checks for errors in some function calls. > > As reported in https://bugzilla.redhat.com/show_bug.cgi?id=728245 > > line 144 - Function cleanup_filter does not free its parameter filter (this > causes a lot of Coverity Resource leak warnings). > line 397 - Dynamically allocated variable rule is not freed in function > parse_acl_filter as a result of line #399. > line 630 - Function "malloc" without NULL check. > line 659 - Function "malloc" without NULL check. > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/libxkutil/acl_parsing.c b/libxkutil/acl_parsing.c > --- a/libxkutil/acl_parsing.c > +++ b/libxkutil/acl_parsing.c > @@ -139,6 +139,7 @@ > }; > > rule->type = UNKNOWN_RULE; > + free(rule); > } > > void cleanup_filter(struct acl_filter *filter) > @@ -152,10 +153,8 @@ > free(filter->name); > free(filter->chain); > > - for (i = 0; i< filter->rule_ct; i++) { > + for (i = 0; i< filter->rule_ct; i++) > cleanup_rule(filter->rules[i]); > - free(filter->rules[i]); > - } > > free(filter->rules); > filter->rule_ct = 0; > @@ -401,14 +400,16 @@ > if (parse_acl_rule(child, rule) == 0) > goto err; > > - append_filter_rule(filter, rule); > + if (append_filter_rule(filter, rule) == 0) > + goto err; > } > else if (XSTREQ(child->name, "filterref")) { > filter_ref = get_attr_value(child, "filter"); > if (filter_ref == NULL) > goto err; > > - append_filter_ref(filter, filter_ref); > + if (append_filter_ref(filter, filter_ref) == 0) > + goto err; > } > } > > @@ -440,14 +441,15 @@ > if (xmldoc == NULL) > goto err; > > - *filter = malloc(sizeof(**filter)); > + *filter = calloc(1, sizeof(**filter)); > if (*filter == NULL) > goto err; > > - memset(*filter, 0, sizeof(**filter)); > - parse_acl_filter(xmldoc->children, *filter); > - > - ret = 1; > + ret = parse_acl_filter(xmldoc->children, *filter); > + if (ret == 0) { > + free(*filter); > + *filter = NULL; > + } > > err: > xmlSetGenericErrorFunc(NULL, NULL); > @@ -508,9 +510,7 @@ > if (xml == NULL) > return 0; > > - get_filter_from_xml(xml, filter); > - > - return 1; > + return get_filter_from_xml(xml, filter); > #else > return 0; > #endif > @@ -534,7 +534,8 @@ > > virConnectListNWFilters(conn, names, count); > > - filters = malloc(count * sizeof(struct acl_filter)); > + filters = calloc(count, sizeof(*filters)); > + > if (filters == NULL) > goto err; > > @@ -542,7 +543,8 @@ > { > struct acl_filter *filter = NULL; > > - get_filter_by_name(conn, names[i],&filter); > + if (get_filter_by_name(conn, names[i],&filter) == 0) > + break; > > memcpy(&filters[i], filter, sizeof(*filter)); > } > @@ -630,6 +632,12 @@ > filter->rules = > malloc((filter->rule_ct + 1) * sizeof(struct acl_rule *)); > > + if (filter->rules == NULL) { > + CU_DEBUG("Failed to allocate memory for new rule"); > + filter->rules = old_rules; > + return 0; > + } > + > memcpy(filter->rules, > old_rules, > filter->rule_ct * sizeof(struct acl_rule *)); > @@ -657,6 +665,13 @@ > old_refs = filter->refs; > > filter->refs = malloc((filter->ref_ct + 1) * sizeof(char *)); > + > + if (filter->refs == NULL) { > + CU_DEBUG("Failed to allocate memory for new ref"); > + filter->refs = old_refs; > + return 0; > + } > + > memcpy(filter->refs, old_refs, filter->ref_ct * sizeof(char *)); > > filter->refs[filter->ref_ct] = name; > @@ -682,8 +697,9 @@ > if (STREQC(old_refs[i], name)) { > free(old_refs[i]); > } > - else > - append_filter_ref(filter, old_refs[i]); > + else if(append_filter_ref(filter, old_refs[i]) == 0) { > + return 0; > + } > } > > return 1; > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From bestor at us.ibm.com Wed Aug 17 16:46:36 2011 From: bestor at us.ibm.com (Gareth S Bestor) Date: Wed, 17 Aug 2011 09:46:36 -0700 Subject: [Libvirt-cim] which vols added to storage pool during refresh? Message-ID: We're looking at a problem when we have a libvirt pool defined, below [root at xnl2192 ~]# virsh pool-dumpxml ScsiPool-host2 ScsiPool-host2 f2ea1882-881f-9f49-838d-39e070f68002 136583315456 136583315456 0 /dev/disk/by-id 0700 -1 -1 As you can see, this pool maps to /dev/disk/by-id. There may be a large number of actual volume entries in /dev/disk/by-id, however it appears only a distinct subset of them are actually added into the libvirt pool when you do a pool-refresh. What does libvirt check when determining which, and whether or not, to add one of these volume into the vol-list? In particular, we have a case when one specific volume in /dev/disk/by-id is *not* added into the pool, and no amount of pool-refresh makes a difference. We did notice that if you remove all the sym links in /dev/disk/by-id and do a pool-refresh, that libvirt re-scans the bus, recreates the links in /dev/disk/by-id, and adds (some of) the volumes back into the vol-list. But not this one problematic vol, so clearly there is something about this vol that libvirt doesnt like and why it is (deliberately?) not added to the pool. What checks, etc does libvirt make against vols when determining whether to add them to a pool? - G Dr. Gareth S. Bestor IBM Senior Software Engineer Systems & Technology Group - Systems Management Standards 971-285-6375 (mobile) bestor at us.ibm.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From cvincent at linux.vnet.ibm.com Thu Aug 18 02:15:25 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 17 Aug 2011 22:15:25 -0400 Subject: [Libvirt-cim] [PATCH 2 of 2] (#5) add sdl frame buffer support In-Reply-To: <80f69bdadfe2ffe05787.1313118041@localhost6.localdomain6> References: <80f69bdadfe2ffe05787.1313118041@localhost6.localdomain6> Message-ID: <4E4C75BD.30101@linux.vnet.ibm.com> +1 and pushed. On 08/11/2011 11:00 PM, Wayne Xia wrote: > # HG changeset patch > # User Wayne Xia > # Date 1311670971 -28800 > # Node ID 80f69bdadfe2ffe057873f4c0f6c8d6a0ef60816 > # Parent 03cc267a3d534f19eb489be3c430ea5de8787ccc > (#5) add sdl frame buffer support. > > Now libvirt still supports sdl frame buffer, and it may take three > parameters: display,xauth,fullscreen. This patch enable the libvirt-cim > to accept these configuration and pass them in XML define to let > libvirt know about it. Exposed interface could be found in the file > ResourceAllocationSettingData.mof. > This Patch also fix some memory leak problem. > > #5 fixed the memory leak problem in Virt_VirtualSystemManagementService.c. > > Signed-off-by: Wayne Xia (Wayne) > > diff -r 03cc267a3d53 -r 80f69bdadfe2 libxkutil/device_parsing.c > --- a/libxkutil/device_parsing.c Mon Jul 25 19:39:08 2011 +0800 > +++ b/libxkutil/device_parsing.c Tue Jul 26 17:02:51 2011 +0800 > @@ -555,6 +555,11 @@ > if (gdev->dev.vnc.port == NULL || gdev->dev.vnc.host == NULL) > goto err; > } > + else if (STREQC(gdev->type, "sdl")) { > + gdev->dev.sdl.display = get_attr_value(node, "display"); > + gdev->dev.sdl.xauth = get_attr_value(node, "xauth"); > + gdev->dev.sdl.fullscreen = get_attr_value(node, "fullscreen"); > + } > else if (STREQC(gdev->type, "pty")) { > if (node->name == NULL) > goto err; > diff -r 03cc267a3d53 -r 80f69bdadfe2 libxkutil/xmlgen.c > --- a/libxkutil/xmlgen.c Mon Jul 25 19:39:08 2011 +0800 > +++ b/libxkutil/xmlgen.c Tue Jul 26 17:02:51 2011 +0800 > @@ -421,8 +421,21 @@ > > xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); > > - if (STREQC(dev->type, "sdl")) > - return NULL; > + if (STREQC(dev->type, "sdl")) { > + if (dev->dev.sdl.display) { > + xmlNewProp(tmp, BAD_CAST "display", > + BAD_CAST dev->dev.sdl.display); > + } > + if (dev->dev.sdl.xauth) { > + xmlNewProp(tmp, BAD_CAST "xauth", > + BAD_CAST dev->dev.sdl.xauth); > + } > + if (dev->dev.sdl.fullscreen) { > + xmlNewProp(tmp, BAD_CAST "fullscreen", > + BAD_CAST dev->dev.sdl.fullscreen); > + } > + return NULL; > + } > > if (dev->dev.vnc.port) { > xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->dev.vnc.port); > diff -r 03cc267a3d53 -r 80f69bdadfe2 schema/ResourceAllocationSettingData.mof > --- a/schema/ResourceAllocationSettingData.mof Mon Jul 25 19:39:08 2011 +0800 > +++ b/schema/ResourceAllocationSettingData.mof Tue Jul 26 17:02:51 2011 +0800 > @@ -219,7 +219,9 @@ > [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " > "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType " > "is 'console', this is a character device path in " > - "path:port format (e.g., '/dev/pts/3:0'\)")] > + "path:port format (e.g., '/dev/pts/3:0'\) " > + "if ResourceSubType is 'sdl', this is a combination of its params as " > + "xauth:display (e.g., '/root/.Xauthority::0'\)")] > string Address; > > [Description ("Keyboard keymapping")] > @@ -228,7 +230,8 @@ > [Description ("VNC password")] > string Password; > > - [Description ("Is IPv6 only addressing is to be used")] > + [Description ("Is IPv6 only addressing is to be used." > + "if ResourceSubType is 'sdl', this means whether sdl is fullscreen")] > boolean IsIPv6Only; > }; > > diff -r 03cc267a3d53 -r 80f69bdadfe2 src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c Mon Jul 25 19:39:08 2011 +0800 > +++ b/src/Virt_VirtualSystemManagementService.c Tue Jul 26 17:02:51 2011 +0800 > @@ -1057,6 +1057,58 @@ > CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", > *path, *port); > > + free(tmp_path); > + free(tmp_port); > + > + return ret; > +} > + > +static int parse_sdl_address(const char *id, > + char **display, > + char **xauth) > +{ > + int ret; > + char *tmp_display = NULL; > + char *tmp_xauth = NULL; > + > + CU_DEBUG("Entering parse_sdl_address, address is %s", id); > + > + ret = sscanf(id, "%a[^:]:%as",&tmp_xauth,&tmp_display); > + > + if (ret<= 0) { > + ret = sscanf(id, ":%as",&tmp_display); > + if (ret<= 0) { > + if (STREQC(id, ":")) { > + /* do nothing, it is empty */ > + } > + else { > + ret = 0; > + goto out; > + } > + } > + } > + > + if (display) { > + if (tmp_display == NULL) > + *display = NULL; > + else > + *display = strdup(tmp_display); > + } > + if (xauth) { > + if (tmp_xauth == NULL) > + *xauth = NULL; > + else > + *xauth = strdup(tmp_xauth); > + } > + ret = 1; > + > + out: > + CU_DEBUG("Exiting parse_sdl_address, display is %s, xauth is %s", > + *display, *xauth); > + > + free(tmp_display); > + free(tmp_xauth); > + > return ret; > } > > @@ -1094,6 +1146,9 @@ > CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", > *ip, *port); > > + free(tmp_ip); > + free(tmp_port); > + > return ret; > } > > @@ -1163,6 +1218,30 @@ > msg = "GraphicsRASD field Address not valid"; > goto out; > } > + } > + else if (STREQC(dev->dev.graphics.type, "sdl")) { > + if (cu_get_str_prop(inst, "Address",&val) != CMPI_RC_OK) { > + CU_DEBUG("sdl graphics Address empty, using default"); > + dev->dev.graphics.dev.sdl.display = NULL; > + dev->dev.graphics.dev.sdl.xauth = NULL; > + } > + else { > + ret = parse_sdl_address(val, > +&dev->dev.graphics.dev.sdl.display, > +&dev->dev.graphics.dev.sdl.xauth); > + if (ret != 1) { > + msg = "GraphicsRASD sdl Address not valid"; > + goto out; > + } > + } > + dev->dev.graphics.dev.sdl.fullscreen = NULL; > + if (cu_get_bool_prop(inst, "IsIPV6Only",&ipv6) == > + CMPI_RC_OK) { > + if (ipv6) > + dev->dev.graphics.dev.sdl.fullscreen = strdup("yes"); > + else > + dev->dev.graphics.dev.sdl.fullscreen = strdup("no"); > + } > } else { > CU_DEBUG("Unsupported graphics type %s", > dev->dev.graphics.type); > @@ -1171,7 +1250,8 @@ > } > > free(dev->id); > - if (STREQC(dev->dev.graphics.type, "vnc")) > + if ((STREQC(dev->dev.graphics.type, "vnc"))|| > + (STREQC(dev->dev.graphics.type, "sdl"))) > ret = asprintf(&dev->id, "%s", dev->dev.graphics.type); > else > ret = asprintf(&dev->id, "%s:%s", > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Thu Aug 18 02:15:11 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 17 Aug 2011 22:15:11 -0400 Subject: [Libvirt-cim] [PATCH 1 of 2] (#5) made the graphic structure as union In-Reply-To: <03cc267a3d534f19eb48.1313118040@localhost6.localdomain6> References: <03cc267a3d534f19eb48.1313118040@localhost6.localdomain6> Message-ID: <4E4C75AF.8090001@linux.vnet.ibm.com> +1 and pushed. On 08/11/2011 11:00 PM, Wayne Xia wrote: > # HG changeset patch > # User Wayne Xia > # Date 1311593948 -28800 > # Node ID 03cc267a3d534f19eb489be3c430ea5de8787ccc > # Parent 8b4f6d69f40904ced24f7948f04f89e770e37bce > (#5) made the graphic structure as union > > These change were made to allow SDL device properties added more clearly > > #5 removed tailing space and some comments, added different free functions > for graphic device. > > Signed-off-by: Wayne Xia (Wayne) > > diff -r 8b4f6d69f409 -r 03cc267a3d53 libxkutil/device_parsing.c > --- a/libxkutil/device_parsing.c Mon Aug 08 11:40:09 2011 -0700 > +++ b/libxkutil/device_parsing.c Mon Jul 25 19:39:08 2011 +0800 > @@ -88,13 +88,30 @@ > free(dev->path); > } > > +static void cleanup_vnc_device(struct graphics_device *dev) > +{ > + free(dev->dev.vnc.port); > + free(dev->dev.vnc.host); > + free(dev->dev.vnc.keymap); > + free(dev->dev.vnc.passwd); > +} > + > +static void cleanup_sdl_device(struct graphics_device *dev) > +{ > + free(dev->dev.sdl.display); > + free(dev->dev.sdl.xauth); > + free(dev->dev.sdl.fullscreen); > +} > + > static void cleanup_graphics_device(struct graphics_device *dev) > { > + if (STREQC(dev->type, "sdl")) { > + cleanup_sdl_device(dev); > + } > + else { > + cleanup_vnc_device(dev); > + } > free(dev->type); > - free(dev->port); > - free(dev->host); > - free(dev->keymap); > - free(dev->passwd); > } > > static void cleanup_input_device(struct input_device *dev) > @@ -530,12 +547,12 @@ > CU_DEBUG("graphics device type = %s", gdev->type); > > if (STREQC(gdev->type, "vnc")) { > - gdev->port = get_attr_value(node, "port"); > - gdev->host = get_attr_value(node, "listen"); > - gdev->keymap = get_attr_value(node, "keymap"); > - gdev->passwd = get_attr_value(node, "passwd"); > + gdev->dev.vnc.port = get_attr_value(node, "port"); > + gdev->dev.vnc.host = get_attr_value(node, "listen"); > + gdev->dev.vnc.keymap = get_attr_value(node, "keymap"); > + gdev->dev.vnc.passwd = get_attr_value(node, "passwd"); > > - if (gdev->port == NULL || gdev->host == NULL) > + if (gdev->dev.vnc.port == NULL || gdev->dev.vnc.host == NULL) > goto err; > } > else if (STREQC(gdev->type, "pty")) { > @@ -550,9 +567,9 @@ > for (child = node->children; child != NULL; > child = child->next) { > if (XSTREQ(child->name, "source")) > - gdev->host = get_attr_value(child, "path"); > + gdev->dev.vnc.host = get_attr_value(child, "path"); > else if (XSTREQ(child->name, "target")) > - gdev->port = get_attr_value(child, "port"); > + gdev->dev.vnc.port = get_attr_value(child, "port"); > } > } > else { > @@ -565,7 +582,7 @@ > if (STREQC(gdev->type, "vnc")) > ret = asprintf(&vdev->id, "%s", gdev->type); > else > - ret = asprintf(&vdev->id, "%s:%s", gdev->type, gdev->port); > + ret = asprintf(&vdev->id, "%s:%s", gdev->type, gdev->dev.vnc.port); > > if (ret == -1) { > CU_DEBUG("Failed to create graphics is string"); > @@ -807,10 +824,10 @@ > DUP_FIELD(dev, _dev, dev.emu.path); > } else if (dev->type == CIM_RES_TYPE_GRAPHICS) { > DUP_FIELD(dev, _dev, dev.graphics.type); > - DUP_FIELD(dev, _dev, dev.graphics.port); > - DUP_FIELD(dev, _dev, dev.graphics.host); > - DUP_FIELD(dev, _dev, dev.graphics.keymap); > - DUP_FIELD(dev, _dev, dev.graphics.passwd); > + DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.host); > + DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.port); > + DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.keymap); > + DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.passwd); > } else if (dev->type == CIM_RES_TYPE_INPUT) { > DUP_FIELD(dev, _dev, dev.input.type); > DUP_FIELD(dev, _dev, dev.input.bus); > diff -r 8b4f6d69f409 -r 03cc267a3d53 libxkutil/device_parsing.h > --- a/libxkutil/device_parsing.h Mon Aug 08 11:40:09 2011 -0700 > +++ b/libxkutil/device_parsing.h Mon Jul 25 19:39:08 2011 +0800 > @@ -84,14 +84,27 @@ > char *path; > }; > > -struct graphics_device { > - char *type; > +struct vnc_device { > char *port; > char *host; > char *keymap; > char *passwd; > }; > > +struct sdl_device { > + char *display; > + char *xauth; > + char *fullscreen; > +}; > + > +struct graphics_device { > + char *type; > + union { > + struct vnc_device vnc; > + struct sdl_device sdl; > + } dev; > +}; > + > struct input_device { > char *type; > char *bus; > diff -r 8b4f6d69f409 -r 03cc267a3d53 libxkutil/xml_parse_test.c > --- a/libxkutil/xml_parse_test.c Mon Aug 08 11:40:09 2011 -0700 > +++ b/libxkutil/xml_parse_test.c Mon Jul 25 19:39:08 2011 +0800 > @@ -116,7 +116,7 @@ > FILE *d) > { > print_value(d, "Graphics Type", dev->dev.graphics.type); > - print_value(d, "Graphics Port", dev->dev.graphics.port); > + print_value(d, "Graphics Port", dev->dev.graphics.dev.vnc.port); > } > > static void print_devices(struct domain *dominfo, > diff -r 8b4f6d69f409 -r 03cc267a3d53 libxkutil/xmlgen.c > --- a/libxkutil/xmlgen.c Mon Aug 08 11:40:09 2011 -0700 > +++ b/libxkutil/xmlgen.c Mon Jul 25 19:39:08 2011 +0800 > @@ -424,22 +424,22 @@ > if (STREQC(dev->type, "sdl")) > return NULL; > > - if (dev->port) { > - xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); > - if (STREQC(dev->port, "-1")) > + if (dev->dev.vnc.port) { > + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->dev.vnc.port); > + if (STREQC(dev->dev.vnc.port, "-1")) > xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes"); > else > xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no"); > } > > - if (dev->host) > - xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host); > + if (dev->dev.vnc.host) > + xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->dev.vnc.host); > > - if (dev->passwd) > - xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST dev->passwd); > + if (dev->dev.vnc.passwd) > + xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST dev->dev.vnc.passwd); > > - if (dev->keymap) > - xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap); > + if (dev->dev.vnc.keymap) > + xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->dev.vnc.keymap); > > return NULL; > } > @@ -459,16 +459,16 @@ > tmp = xmlNewChild(pty, NULL, BAD_CAST "source", NULL); > if (tmp == NULL) > return XML_ERROR; > - > - if(dev->host) > - xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev->host); > + > + 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->port) > - xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); > + > + if(dev->dev.vnc.port) > + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->dev.vnc.port); > > return NULL; > } > diff -r 8b4f6d69f409 -r 03cc267a3d53 src/Virt_ComputerSystem.c > --- a/src/Virt_ComputerSystem.c Mon Aug 08 11:40:09 2011 -0700 > +++ b/src/Virt_ComputerSystem.c Mon Jul 25 19:39:08 2011 +0800 > @@ -104,7 +104,7 @@ > "Virtual System (Console on %s://%s:%s)", > domain->dev_graphics[0].dev.graphics.type, > host, > - domain->dev_graphics[0].dev.graphics.port); > + domain->dev_graphics[0].dev.graphics.dev.vnc.port); > else > ret = asprintf(&cap, > "Virtual System (No console)"); > diff -r 8b4f6d69f409 -r 03cc267a3d53 src/Virt_Device.c > --- a/src/Virt_Device.c Mon Aug 08 11:40:09 2011 -0700 > +++ b/src/Virt_Device.c Mon Jul 25 19:39:08 2011 +0800 > @@ -194,8 +194,8 @@ > else > rc = asprintf(&vp_str, "%s/%s:%s", > dev->type, > - dev->host, > - dev->port); > + dev->dev.vnc.host, > + dev->dev.vnc.port); > if (rc == -1) > return 0; > > diff -r 8b4f6d69f409 -r 03cc267a3d53 src/Virt_KVMRedirectionSAP.c > --- a/src/Virt_KVMRedirectionSAP.c Mon Aug 08 11:40:09 2011 -0700 > +++ b/src/Virt_KVMRedirectionSAP.c Mon Jul 25 19:39:08 2011 +0800 > @@ -366,7 +366,7 @@ > continue; > } > > - ret = sscanf(dominfo->dev_graphics->dev.graphics.port, > + ret = sscanf(dominfo->dev_graphics->dev.graphics.dev.vnc.port, > "%d", > &lport); > if (ret != 1) { > diff -r 8b4f6d69f409 -r 03cc267a3d53 src/Virt_RASD.c > --- a/src/Virt_RASD.c Mon Aug 08 11:40:09 2011 -0700 > +++ b/src/Virt_RASD.c Mon Jul 25 19:39:08 2011 +0800 > @@ -481,9 +481,9 @@ > rc = asprintf(&addr_str, "%s", dev->dev.graphics.type); > else { > rc = asprintf(&addr_str, > - "%s:%s", > - dev->dev.graphics.host, > - dev->dev.graphics.port); > + "%s:%s", > + dev->dev.graphics.dev.vnc.host, > + dev->dev.graphics.dev.vnc.port); > } > > CU_DEBUG("graphics Address = %s", addr_str); > @@ -496,7 +496,7 @@ > > if (STREQC(dev->dev.graphics.type, "vnc")) { > CMSetProperty(inst, "KeyMap", > - (CMPIValue *)dev->dev.graphics.keymap, CMPI_chars); > + (CMPIValue *)dev->dev.graphics.dev.vnc.keymap, CMPI_chars); > > conn = connect_by_classname(_BROKER, classname,&s); > if (conn == NULL) > @@ -511,7 +511,8 @@ > goto out; > } > > - if (dev->dev.graphics.passwd&& strlen(dev->dev.graphics.passwd)) { > + if (dev->dev.graphics.dev.vnc.passwd&& > + strlen(dev->dev.graphics.dev.vnc.passwd)) { > CU_DEBUG("has password"); > CMSetProperty(inst, "Password", > (CMPIValue *)"********", CMPI_chars); > diff -r 8b4f6d69f409 -r 03cc267a3d53 src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c Mon Aug 08 11:40:09 2011 -0700 > +++ b/src/Virt_VirtualSystemManagementService.c Mon Jul 25 19:39:08 2011 +0800 > @@ -370,10 +370,10 @@ > } > > domain->dev_graphics->dev.graphics.type = strdup("vnc"); > - domain->dev_graphics->dev.graphics.port = strdup("-1"); > - domain->dev_graphics->dev.graphics.host = strdup("127.0.0.1"); > - domain->dev_graphics->dev.graphics.keymap = strdup("en-us"); > - domain->dev_graphics->dev.graphics.passwd = NULL; > + domain->dev_graphics->dev.graphics.dev.vnc.port = strdup("-1"); > + domain->dev_graphics->dev.graphics.dev.vnc.host = strdup("127.0.0.1"); > + domain->dev_graphics->dev.graphics.dev.vnc.keymap = strdup("en-us"); > + domain->dev_graphics->dev.graphics.dev.vnc.passwd = NULL; > domain->dev_graphics_ct = 1; > > return true; > @@ -1129,24 +1129,24 @@ > } > > ret = parse_vnc_address(val, > -&dev->dev.graphics.host, > -&dev->dev.graphics.port); > +&dev->dev.graphics.dev.vnc.host, > +&dev->dev.graphics.dev.vnc.port); > if (ret != 1) { > msg = "GraphicsRASD field Address not valid"; > goto out; > } > > if (cu_get_str_prop(inst, "KeyMap",&val) != CMPI_RC_OK) > - dev->dev.graphics.keymap = strdup("en-us"); > + dev->dev.graphics.dev.vnc.keymap = strdup("en-us"); > else > - dev->dev.graphics.keymap = strdup(val); > + dev->dev.graphics.dev.vnc.keymap = strdup(val); > > if (cu_get_str_prop(inst, "Password",&val) != CMPI_RC_OK) { > CU_DEBUG("vnc password is not set"); > - dev->dev.graphics.passwd = NULL; > + dev->dev.graphics.dev.vnc.passwd = NULL; > } else { > CU_DEBUG("vnc password is set"); > - dev->dev.graphics.passwd = strdup(val); > + dev->dev.graphics.dev.vnc.passwd = strdup(val); > } > } > else if (STREQC(dev->dev.graphics.type, "console") || > @@ -1157,8 +1157,8 @@ > } > > ret = parse_console_address(val, > -&dev->dev.graphics.host, > -&dev->dev.graphics.port); > +&dev->dev.graphics.dev.vnc.host, > +&dev->dev.graphics.dev.vnc.port); > if (ret != 1) { > msg = "GraphicsRASD field Address not valid"; > goto out; > @@ -1175,7 +1175,7 @@ > ret = asprintf(&dev->id, "%s", dev->dev.graphics.type); > else > ret = asprintf(&dev->id, "%s:%s", > - dev->dev.graphics.type, dev->dev.graphics.port); > + dev->dev.graphics.type, dev->dev.graphics.dev.vnc.port); > > if (ret == -1) { > msg = "Failed to create graphics is string"; > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Thu Aug 18 04:47:26 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 18 Aug 2011 00:47:26 -0400 Subject: [Libvirt-cim] Patches for Virt_SettingsDefineCapabilities: incorrect Default ValueRole, strstr() misuse In-Reply-To: <4E487EF0.4@linux.vnet.ibm.com> References: <4E487EF0.4@linux.vnet.ibm.com> Message-ID: <4E4C995E.2050108@linux.vnet.ibm.com> +1 and pushed. I'm pretty sure the existing cimtest does not cover this, but perhaps it should (?) On 08/14/2011 10:05 PM, Wayne Xia wrote: > Seems good, +1 > > ? 2011-8-13 6:37, Gareth S Bestor ??: >> >> # HG changeset patch >> # User Gareth S. Bestor >> # Date 1313162799 25200 >> # Node ID 39c85f57c94fa36c681d4e9caa6e14617dcc7e60 >> # Parent 8b4f6d69f40904ced24f7948f04f89e770e37bce >> Patches for Virt_SettingsDefineCapabilities: incorrect Default >> ValueRole, strstr() misuse >> >> - The CIM_AllocationCapabilities for 'Default' RASDs have the incorrect >> ValueRole. per DSP1043 "Allocation Capabilities Profile", Section 10.5 >> "CIM_SettingsDefineCapabilities ? Default" the ValueRole should be 0 >> ("Default") >> >> - Fixed mistake with usage of strstr() swapping the arguments; should be: >> char *strstr(const char *haystack, const char *needle); >> This may not have mattered before when both strings were always exactly >> same or didnt match, but now for new 'Point' instances the instanceid >> has a prefix. >> >> Signed-off-by: Gareth S. Bestor >> >> diff -r 8b4f6d69f409 -r 39c85f57c94f >> src/Virt_SettingsDefineCapabilities.c >> --- a/src/Virt_SettingsDefineCapabilities.c Mon Aug 08 11:40:09 2011 >> -0700 >> +++ b/src/Virt_SettingsDefineCapabilities.c Fri Aug 12 08:26:39 2011 >> -0700 >> @@ -2054,19 +2054,22 @@ >> goto out; >> } >> >> - if (strstr("Default", iid) != NULL) >> + if (strstr(iid, "Default") != NULL) { >> valuerange = SDC_RANGE_POINT; >> - else if (strstr("Increment", iid) != NULL) >> + valuerole = SDC_ROLE_DEFAULT; >> + } >> + else if (strstr(iid, "Point") != NULL) >> + valuerange = SDC_RANGE_POINT; >> + else if (strstr(iid, "Increment") != NULL) >> valuerange = SDC_RANGE_INC; >> - else if (strstr("Maximum", iid) != NULL) >> + else if (strstr(iid, "Maximum") != NULL) >> valuerange = SDC_RANGE_MAX; >> - else if (strstr("Minimum", iid) != NULL) >> + else if (strstr(iid, "Minimum") != NULL) >> valuerange = SDC_RANGE_MIN; >> - else >> - CU_DEBUG("Unknown default RASD type: `%s'", iid); >> - >> - if (valuerange == SDC_RANGE_POINT) >> - valuerole = SDC_ROLE_DEFAULT; >> + else { >> + CU_DEBUG("Unknown RASD type: `%s'", iid); >> + goto out; >> + } >> >> CMSetProperty(ref_inst, "ValueRole", >> (CMPIValue *)&valuerole, CMPI_uint16); >> >> >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim > > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Thu Aug 18 05:05:40 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 18 Aug 2011 01:05:40 -0400 Subject: [Libvirt-cim] which vols added to storage pool during refresh? In-Reply-To: References: Message-ID: <4E4C9DA4.30902@linux.vnet.ibm.com> Perhaps we should put this on libvirt-list at redhat.com? On 08/17/2011 12:46 PM, Gareth S Bestor wrote: > > We're looking at a problem when we have a libvirt pool defined, below > > [root at xnl2192 ~]# virsh pool-dumpxml ScsiPool-host2 > > ScsiPool-host2 > f2ea1882-881f-9f49-838d-39e070f68002 > 136583315456 > 136583315456 > 0 > > > > > /dev/disk/by-id > > 0700 > -1 > -1 > > > > > As you can see, this pool maps to /dev/disk/by-id. There may be a large > number of actual volume entries in /dev/disk/by-id, however it appears > only a distinct subset of them are actually added into the libvirt pool > when you do a pool-refresh. What does libvirt check when determining > which, and whether or not, to add one of these volume into the vol-list? > > In particular, we have a case when one specific volume in > /dev/disk/by-id is *not* added into the pool, and no amount of > pool-refresh makes a difference. We did notice that if you remove all > the sym links in /dev/disk/by-id and do a pool-refresh, that libvirt > re-scans the bus, recreates the links in /dev/disk/by-id, and adds (some > of) the volumes back into the vol-list. But not this one problematic > vol, so clearly there is something about this vol that libvirt doesnt > like and why it is (deliberately?) not added to the pool. > > What checks, etc does libvirt make against vols when determining whether > to add them to a pool? > > - G > > Dr. Gareth S. Bestor > IBM Senior Software Engineer > Systems & Technology Group - Systems Management Standards > 971-285-6375 (mobile) > bestor at us.ibm.com > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From snmishra at us.ibm.com Thu Aug 18 05:25:45 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Wed, 17 Aug 2011 22:25:45 -0700 Subject: [Libvirt-cim] which vols added to storage pool during refresh? In-Reply-To: <4E4C9DA4.30902@linux.vnet.ibm.com> References: <4E4C9DA4.30902@linux.vnet.ibm.com> Message-ID: libvirt-users is a better list, and I noticed that Gareth already posted on it and got some replies. Sharad Mishra Open Virtualization Linux Technology Center IBM Chip Vincent To Sent by: libvirt-cim at redhat.com libvirt-cim-bounc cc es at redhat.com Subject Re: [Libvirt-cim] which vols added 08/17/11 10:05 PM to storage pool during refresh? Please respond to cvincent at linux.vn et.ibm.com; Please respond to List for discussion and development of libvirt CIM Perhaps we should put this on libvirt-list at redhat.com? On 08/17/2011 12:46 PM, Gareth S Bestor wrote: > > We're looking at a problem when we have a libvirt pool defined, below > > [root at xnl2192 ~]# virsh pool-dumpxml ScsiPool-host2 > > ScsiPool-host2 > f2ea1882-881f-9f49-838d-39e070f68002 > 136583315456 > 136583315456 > 0 > > > > > /dev/disk/by-id > > 0700 > -1 > -1 > > > > > As you can see, this pool maps to /dev/disk/by-id. There may be a large > number of actual volume entries in /dev/disk/by-id, however it appears > only a distinct subset of them are actually added into the libvirt pool > when you do a pool-refresh. What does libvirt check when determining > which, and whether or not, to add one of these volume into the vol-list? > > In particular, we have a case when one specific volume in > /dev/disk/by-id is *not* added into the pool, and no amount of > pool-refresh makes a difference. We did notice that if you remove all > the sym links in /dev/disk/by-id and do a pool-refresh, that libvirt > re-scans the bus, recreates the links in /dev/disk/by-id, and adds (some > of) the volumes back into the vol-list. But not this one problematic > vol, so clearly there is something about this vol that libvirt doesnt > like and why it is (deliberately?) not added to the pool. > > What checks, etc does libvirt make against vols when determining whether > to add them to a pool? > > - G > > Dr. Gareth S. Bestor > IBM Senior Software Engineer > Systems & Technology Group - Systems Management Standards > 971-285-6375 (mobile) > bestor at us.ibm.com > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com _______________________________________________ Libvirt-cim mailing list Libvirt-cim at redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: graycol.gif Type: image/gif Size: 105 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pic27645.gif Type: image/gif Size: 1255 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ecblank.gif Type: image/gif Size: 45 bytes Desc: not available URL: From cvincent at linux.vnet.ibm.com Thu Aug 18 05:26:01 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 18 Aug 2011 01:26:01 -0400 Subject: [Libvirt-cim] [PATCH] device_parsing: Fixing potential leaks In-Reply-To: References: Message-ID: <4E4CA269.6070509@linux.vnet.ibm.com> On 08/11/2011 11:09 AM, Eduardo Lima (Etrunko) wrote: > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1313075262 10800 > # Node ID c0f20dbefb8fd73c278a619bbbd2efb567da07d4 > # Parent 2b1b79a72ab0288d649399118dffce26fd05e066 > device_parsing: Fixing potential leaks > > As reported in https://bugzilla.redhat.com/show_bug.cgi?id=728245 > > line 106 - Function cleanup_virt_device does not free its parameter dev (this > causes a lot of Coverity Resource leak warnings). > > In future use cases, please consider using cleanup_virt_devices function > instead of cleanup_virt_device if the virt_device structure is allocated > dynamically. > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -829,12 +829,10 @@ > if (ret<= 0) > return ret; > > - mdev = malloc(sizeof(*mdev)); > + mdev = calloc(1, sizeof(*mdev)); What are the benefits to this change? > if (mdev == NULL) > return 0; > > - memset(mdev, 0, sizeof(*mdev)); > - > /* We could get one or two memory devices back, depending on > * if there is a currentMemory tag or not. Coalesce these > * into a single device to return > @@ -870,12 +868,10 @@ > if (ret<= 0) > return ret; > > - proc_dev = malloc(sizeof(*proc_dev)); > + proc_dev = calloc(1, sizeof(*proc_dev)); > if (proc_dev == NULL) > return 0; > > - memset(proc_dev, 0, sizeof(*proc_dev)); > - > proc_dev->type = CIM_RES_TYPE_PROC; > proc_dev->id = strdup("proc"); > proc_dev->dev.vcpu.quantity = proc_devs[0].dev.vcpu.quantity; > @@ -1031,8 +1027,6 @@ > xmlNode **nodes = nsv->nodeTab; > xmlNode *child; > > - memset(dominfo, 0, sizeof(*dominfo)); > - > dominfo->typestr = get_attr_value(nodes[0], "type"); > > for (child = nodes[0]->children; child != NULL; child = child->next) { > @@ -1098,7 +1092,7 @@ > int ret; > > CU_DEBUG("In get_dominfo_from_xml"); > - *dominfo = malloc(sizeof(**dominfo)); > + *dominfo = calloc(1, sizeof(**dominfo)); > if (*dominfo == NULL) > return 0; > > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -832,7 +832,7 @@ > dominfo->dev_input = dev; > break; > default: > - cleanup_virt_device(dev); > + cleanup_virt_devices(&dev, 1); > goto out; > } > > diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c > --- a/src/Virt_AppliedFilterList.c > +++ b/src/Virt_AppliedFilterList.c > @@ -516,7 +516,7 @@ > free(net_name); > > cleanup_filter(filter); > - cleanup_virt_device(device); > + cleanup_virt_devices(&device, 1); It seems to me that these two commands should be equal? Wouldn't the correct change be to ensure that they are? > > virDomainFree(dom); > virConnectClose(conn); > @@ -626,7 +626,7 @@ > free(net_name); > > cleanup_filter(filter); > - cleanup_virt_device(device); > + cleanup_virt_devices(&device, 1); > > virDomainFree(dom); > virConnectClose(conn); > diff --git a/src/Virt_Device.c b/src/Virt_Device.c > --- a/src/Virt_Device.c > +++ b/src/Virt_Device.c > @@ -700,14 +700,15 @@ > } > > for (i = 0; i< count; i++) { > - if (STREQC(device, list[i].id)) > + if (STREQC(device, list[i].id)) { > dev = virt_device_dup(&list[i]); > + break; > + } > > - cleanup_virt_device(&list[i]); > } > > + cleanup_virt_devices(&list, count); > out: > - free(list); > > return dev; > } > @@ -785,7 +786,7 @@ > &tmp_list); > } > > - cleanup_virt_device(dev); > + cleanup_virt_devices(&dev, 1); > > *_inst = tmp_list.list[0]; > > diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c > --- a/src/Virt_RASD.c > +++ b/src/Virt_RASD.c > @@ -664,7 +664,7 @@ > char *host = NULL; > char *devid = NULL; > virConnectPtr conn = NULL; > - struct virt_device *dev; > + struct virt_device *dev = NULL; > > conn = connect_by_classname(broker, CLASSNAME(reference),&s); > if (conn == NULL) { > @@ -700,8 +700,8 @@ > "Failed to set instance properties"); > else > *_inst = inst; > - > - cleanup_virt_device(dev); > + > + cleanup_virt_devices(&dev, 1); > > out: > virConnectClose(conn); > @@ -863,10 +863,7 @@ > > tmp_dev->id = strdup("proc"); > > - for (i = 0; i< count; i++) > - cleanup_virt_device(&devs[i]); > - > - free(devs); > + cleanup_virt_devices(&devs, count); > devs = tmp_dev; > count = 1; > } > @@ -877,9 +874,6 @@ > CMPI_RC_ERR_FAILED, > "Failed to get domain name"); > > - for (i = 0; i< count; i++) > - cleanup_virt_device(&devs[i]); > - > goto out; > } > > @@ -893,12 +887,10 @@ > properties); > if (dev) > inst_list_add(list, dev); > - > - cleanup_virt_device(&devs[i]); > } > > out: > - free(devs); > + cleanup_virt_devices(&devs, count); > return s; > } > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -200,12 +200,6 @@ > > cleanup_virt_device(domain->dev_emu); > > - domain->dev_emu = calloc(1, sizeof(*domain->dev_emu)); > - if (domain->dev_emu == NULL) { > - CU_DEBUG("Failed to allocate default emulator device"); > - return false; > - } > - > domain->dev_emu->type = CIM_RES_TYPE_EMU; > domain->dev_emu->dev.emu.path = strdup(emu); > domain->dev_emu->id = strdup("emulator"); > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From eblima at linux.vnet.ibm.com Thu Aug 18 14:05:06 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 18 Aug 2011 11:05:06 -0300 Subject: [Libvirt-cim] [PATCH] device_parsing: Fixing potential leaks In-Reply-To: <4E4CA269.6070509@linux.vnet.ibm.com> References: <4E4CA269.6070509@linux.vnet.ibm.com> Message-ID: <4E4D1C12.1060106@linux.vnet.ibm.com> On 08/18/2011 02:26 AM, Chip Vincent wrote: > On 08/11/2011 11:09 AM, Eduardo Lima (Etrunko) wrote: >> # HG changeset patch >> # User Eduardo Lima (Etrunko) >> # Date 1313075262 10800 >> # Node ID c0f20dbefb8fd73c278a619bbbd2efb567da07d4 >> # Parent 2b1b79a72ab0288d649399118dffce26fd05e066 >> device_parsing: Fixing potential leaks >> >> As reported in https://bugzilla.redhat.com/show_bug.cgi?id=728245 >> >> line 106 - Function cleanup_virt_device does not free its parameter >> dev (this >> causes a lot of Coverity Resource leak warnings). >> >> In future use cases, please consider using cleanup_virt_devices function >> instead of cleanup_virt_device if the virt_device structure is allocated >> dynamically. >> >> Signed-off-by: Eduardo Lima (Etrunko) >> >> diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c >> --- a/libxkutil/device_parsing.c >> +++ b/libxkutil/device_parsing.c >> @@ -829,12 +829,10 @@ >> if (ret<= 0) >> return ret; >> >> - mdev = malloc(sizeof(*mdev)); >> + mdev = calloc(1, sizeof(*mdev)); > > What are the benefits to this change? > Well, nothing else than saving the memset below. >> if (mdev == NULL) >> return 0; >> >> - memset(mdev, 0, sizeof(*mdev)); >> - This one. >> /* We could get one or two memory devices back, depending on >> * if there is a currentMemory tag or not. Coalesce these >> * into a single device to return >> @@ -870,12 +868,10 @@ >> if (ret<= 0) >> return ret; >> >> - proc_dev = malloc(sizeof(*proc_dev)); >> + proc_dev = calloc(1, sizeof(*proc_dev)); >> if (proc_dev == NULL) >> return 0; >> >> - memset(proc_dev, 0, sizeof(*proc_dev)); >> - >> proc_dev->type = CIM_RES_TYPE_PROC; >> proc_dev->id = strdup("proc"); >> proc_dev->dev.vcpu.quantity = proc_devs[0].dev.vcpu.quantity; >> @@ -1031,8 +1027,6 @@ >> xmlNode **nodes = nsv->nodeTab; >> xmlNode *child; >> >> - memset(dominfo, 0, sizeof(*dominfo)); >> - >> dominfo->typestr = get_attr_value(nodes[0], "type"); >> >> for (child = nodes[0]->children; child != NULL; child = child->next) { >> @@ -1098,7 +1092,7 @@ >> int ret; >> >> CU_DEBUG("In get_dominfo_from_xml"); >> - *dominfo = malloc(sizeof(**dominfo)); >> + *dominfo = calloc(1, sizeof(**dominfo)); >> if (*dominfo == NULL) >> return 0; >> >> diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c >> --- a/libxkutil/xmlgen.c >> +++ b/libxkutil/xmlgen.c >> @@ -832,7 +832,7 @@ >> dominfo->dev_input = dev; >> break; >> default: >> - cleanup_virt_device(dev); >> + cleanup_virt_devices(&dev, 1); >> goto out; >> } >> >> diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c >> --- a/src/Virt_AppliedFilterList.c >> +++ b/src/Virt_AppliedFilterList.c >> @@ -516,7 +516,7 @@ >> free(net_name); >> >> cleanup_filter(filter); >> - cleanup_virt_device(device); >> + cleanup_virt_devices(&device, 1); > > It seems to me that these two commands should be equal? Wouldn't the > correct change be to ensure that they are? > The only difference between those two functions is that the former does not free the struct device while the last does. It is useful to use the first in the case you don't allocate that struct dynamically, as said in the commit message. >> >> virDomainFree(dom); >> virConnectClose(conn); >> @@ -626,7 +626,7 @@ >> free(net_name); >> >> cleanup_filter(filter); >> - cleanup_virt_device(device); >> + cleanup_virt_devices(&device, 1); >> >> virDomainFree(dom); >> virConnectClose(conn); >> diff --git a/src/Virt_Device.c b/src/Virt_Device.c >> --- a/src/Virt_Device.c >> +++ b/src/Virt_Device.c >> @@ -700,14 +700,15 @@ >> } >> >> for (i = 0; i< count; i++) { >> - if (STREQC(device, list[i].id)) >> + if (STREQC(device, list[i].id)) { >> dev = virt_device_dup(&list[i]); >> + break; >> + } >> >> - cleanup_virt_device(&list[i]); >> } >> >> + cleanup_virt_devices(&list, count); >> out: >> - free(list); >> >> return dev; >> } >> @@ -785,7 +786,7 @@ >> &tmp_list); >> } >> >> - cleanup_virt_device(dev); >> + cleanup_virt_devices(&dev, 1); >> >> *_inst = tmp_list.list[0]; >> >> diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c >> --- a/src/Virt_RASD.c >> +++ b/src/Virt_RASD.c >> @@ -664,7 +664,7 @@ >> char *host = NULL; >> char *devid = NULL; >> virConnectPtr conn = NULL; >> - struct virt_device *dev; >> + struct virt_device *dev = NULL; >> >> conn = connect_by_classname(broker, CLASSNAME(reference),&s); >> if (conn == NULL) { >> @@ -700,8 +700,8 @@ >> "Failed to set instance properties"); >> else >> *_inst = inst; >> - >> - cleanup_virt_device(dev); >> + >> + cleanup_virt_devices(&dev, 1); >> >> out: >> virConnectClose(conn); >> @@ -863,10 +863,7 @@ >> >> tmp_dev->id = strdup("proc"); >> >> - for (i = 0; i< count; i++) >> - cleanup_virt_device(&devs[i]); >> - >> - free(devs); >> + cleanup_virt_devices(&devs, count); >> devs = tmp_dev; >> count = 1; >> } >> @@ -877,9 +874,6 @@ >> CMPI_RC_ERR_FAILED, >> "Failed to get domain name"); >> >> - for (i = 0; i< count; i++) >> - cleanup_virt_device(&devs[i]); >> - >> goto out; >> } >> >> @@ -893,12 +887,10 @@ >> properties); >> if (dev) >> inst_list_add(list, dev); >> - >> - cleanup_virt_device(&devs[i]); >> } >> >> out: >> - free(devs); >> + cleanup_virt_devices(&devs, count); >> return s; >> } >> >> diff --git a/src/Virt_VirtualSystemManagementService.c >> b/src/Virt_VirtualSystemManagementService.c >> --- a/src/Virt_VirtualSystemManagementService.c >> +++ b/src/Virt_VirtualSystemManagementService.c >> @@ -200,12 +200,6 @@ >> >> cleanup_virt_device(domain->dev_emu); >> >> - domain->dev_emu = calloc(1, sizeof(*domain->dev_emu)); >> - if (domain->dev_emu == NULL) { >> - CU_DEBUG("Failed to allocate default emulator device"); >> - return false; >> - } >> - Here is the use case for cleanup_virt_device. You already have memory for dev->emu but you want to update the information stored. No need to allocate new memory, just fill in the fields and you're done. If it is the case, it is possible to declare cleanup_virt_device static and ensure it is not called anywhere else in the code besides device_parsing.c. Best regards, Etrunko -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From cvincent at linux.vnet.ibm.com Thu Aug 18 18:32:28 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 18 Aug 2011 14:32:28 -0400 Subject: [Libvirt-cim] [PATCH] device_parsing: Fixing potential leaks In-Reply-To: <4E4D1C12.1060106@linux.vnet.ibm.com> References: <4E4CA269.6070509@linux.vnet.ibm.com> <4E4D1C12.1060106@linux.vnet.ibm.com> Message-ID: <4E4D5ABC.1090208@linux.vnet.ibm.com> It would be nice to normalize the cleanup_* commands so they work consistently, but that can be done via another patch. +1 & pushed. On 08/18/2011 10:05 AM, Eduardo Lima (Etrunko) wrote: > On 08/18/2011 02:26 AM, Chip Vincent wrote: >> On 08/11/2011 11:09 AM, Eduardo Lima (Etrunko) wrote: >>> # HG changeset patch >>> # User Eduardo Lima (Etrunko) >>> # Date 1313075262 10800 >>> # Node ID c0f20dbefb8fd73c278a619bbbd2efb567da07d4 >>> # Parent 2b1b79a72ab0288d649399118dffce26fd05e066 >>> device_parsing: Fixing potential leaks >>> >>> As reported in https://bugzilla.redhat.com/show_bug.cgi?id=728245 >>> >>> line 106 - Function cleanup_virt_device does not free its parameter >>> dev (this >>> causes a lot of Coverity Resource leak warnings). >>> >>> In future use cases, please consider using cleanup_virt_devices function >>> instead of cleanup_virt_device if the virt_device structure is allocated >>> dynamically. >>> >>> Signed-off-by: Eduardo Lima (Etrunko) >>> >>> diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c >>> --- a/libxkutil/device_parsing.c >>> +++ b/libxkutil/device_parsing.c >>> @@ -829,12 +829,10 @@ >>> if (ret<= 0) >>> return ret; >>> >>> - mdev = malloc(sizeof(*mdev)); >>> + mdev = calloc(1, sizeof(*mdev)); >> >> What are the benefits to this change? >> > > Well, nothing else than saving the memset below. > >>> if (mdev == NULL) >>> return 0; >>> >>> - memset(mdev, 0, sizeof(*mdev)); >>> - > > This one. > >>> /* We could get one or two memory devices back, depending on >>> * if there is a currentMemory tag or not. Coalesce these >>> * into a single device to return >>> @@ -870,12 +868,10 @@ >>> if (ret<= 0) >>> return ret; >>> >>> - proc_dev = malloc(sizeof(*proc_dev)); >>> + proc_dev = calloc(1, sizeof(*proc_dev)); >>> if (proc_dev == NULL) >>> return 0; >>> >>> - memset(proc_dev, 0, sizeof(*proc_dev)); >>> - >>> proc_dev->type = CIM_RES_TYPE_PROC; >>> proc_dev->id = strdup("proc"); >>> proc_dev->dev.vcpu.quantity = proc_devs[0].dev.vcpu.quantity; >>> @@ -1031,8 +1027,6 @@ >>> xmlNode **nodes = nsv->nodeTab; >>> xmlNode *child; >>> >>> - memset(dominfo, 0, sizeof(*dominfo)); >>> - >>> dominfo->typestr = get_attr_value(nodes[0], "type"); >>> >>> for (child = nodes[0]->children; child != NULL; child = child->next) { >>> @@ -1098,7 +1092,7 @@ >>> int ret; >>> >>> CU_DEBUG("In get_dominfo_from_xml"); >>> - *dominfo = malloc(sizeof(**dominfo)); >>> + *dominfo = calloc(1, sizeof(**dominfo)); >>> if (*dominfo == NULL) >>> return 0; >>> >>> diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c >>> --- a/libxkutil/xmlgen.c >>> +++ b/libxkutil/xmlgen.c >>> @@ -832,7 +832,7 @@ >>> dominfo->dev_input = dev; >>> break; >>> default: >>> - cleanup_virt_device(dev); >>> + cleanup_virt_devices(&dev, 1); >>> goto out; >>> } >>> >>> diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c >>> --- a/src/Virt_AppliedFilterList.c >>> +++ b/src/Virt_AppliedFilterList.c >>> @@ -516,7 +516,7 @@ >>> free(net_name); >>> >>> cleanup_filter(filter); >>> - cleanup_virt_device(device); >>> + cleanup_virt_devices(&device, 1); >> >> It seems to me that these two commands should be equal? Wouldn't the >> correct change be to ensure that they are? >> > > The only difference between those two functions is that the former does > not free the struct device while the last does. It is useful to use the > first in the case you don't allocate that struct dynamically, as said in > the commit message. > >>> >>> virDomainFree(dom); >>> virConnectClose(conn); >>> @@ -626,7 +626,7 @@ >>> free(net_name); >>> >>> cleanup_filter(filter); >>> - cleanup_virt_device(device); >>> + cleanup_virt_devices(&device, 1); >>> >>> virDomainFree(dom); >>> virConnectClose(conn); >>> diff --git a/src/Virt_Device.c b/src/Virt_Device.c >>> --- a/src/Virt_Device.c >>> +++ b/src/Virt_Device.c >>> @@ -700,14 +700,15 @@ >>> } >>> >>> for (i = 0; i< count; i++) { >>> - if (STREQC(device, list[i].id)) >>> + if (STREQC(device, list[i].id)) { >>> dev = virt_device_dup(&list[i]); >>> + break; >>> + } >>> >>> - cleanup_virt_device(&list[i]); >>> } >>> >>> + cleanup_virt_devices(&list, count); >>> out: >>> - free(list); >>> >>> return dev; >>> } >>> @@ -785,7 +786,7 @@ >>> &tmp_list); >>> } >>> >>> - cleanup_virt_device(dev); >>> + cleanup_virt_devices(&dev, 1); >>> >>> *_inst = tmp_list.list[0]; >>> >>> diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c >>> --- a/src/Virt_RASD.c >>> +++ b/src/Virt_RASD.c >>> @@ -664,7 +664,7 @@ >>> char *host = NULL; >>> char *devid = NULL; >>> virConnectPtr conn = NULL; >>> - struct virt_device *dev; >>> + struct virt_device *dev = NULL; >>> >>> conn = connect_by_classname(broker, CLASSNAME(reference),&s); >>> if (conn == NULL) { >>> @@ -700,8 +700,8 @@ >>> "Failed to set instance properties"); >>> else >>> *_inst = inst; >>> - >>> - cleanup_virt_device(dev); >>> + >>> + cleanup_virt_devices(&dev, 1); >>> >>> out: >>> virConnectClose(conn); >>> @@ -863,10 +863,7 @@ >>> >>> tmp_dev->id = strdup("proc"); >>> >>> - for (i = 0; i< count; i++) >>> - cleanup_virt_device(&devs[i]); >>> - >>> - free(devs); >>> + cleanup_virt_devices(&devs, count); >>> devs = tmp_dev; >>> count = 1; >>> } >>> @@ -877,9 +874,6 @@ >>> CMPI_RC_ERR_FAILED, >>> "Failed to get domain name"); >>> >>> - for (i = 0; i< count; i++) >>> - cleanup_virt_device(&devs[i]); >>> - >>> goto out; >>> } >>> >>> @@ -893,12 +887,10 @@ >>> properties); >>> if (dev) >>> inst_list_add(list, dev); >>> - >>> - cleanup_virt_device(&devs[i]); >>> } >>> >>> out: >>> - free(devs); >>> + cleanup_virt_devices(&devs, count); >>> return s; >>> } >>> >>> diff --git a/src/Virt_VirtualSystemManagementService.c >>> b/src/Virt_VirtualSystemManagementService.c >>> --- a/src/Virt_VirtualSystemManagementService.c >>> +++ b/src/Virt_VirtualSystemManagementService.c >>> @@ -200,12 +200,6 @@ >>> >>> cleanup_virt_device(domain->dev_emu); >>> >>> - domain->dev_emu = calloc(1, sizeof(*domain->dev_emu)); >>> - if (domain->dev_emu == NULL) { >>> - CU_DEBUG("Failed to allocate default emulator device"); >>> - return false; >>> - } >>> - > > Here is the use case for cleanup_virt_device. You already have memory > for dev->emu but you want to update the information stored. No need to > allocate new memory, just fill in the fields and you're done. > > If it is the case, it is possible to declare cleanup_virt_device static > and ensure it is not called anywhere else in the code besides > device_parsing.c. > > Best regards, Etrunko > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From eblima at linux.vnet.ibm.com Thu Aug 18 19:12:19 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 18 Aug 2011 16:12:19 -0300 Subject: [Libvirt-cim] [PATCH] (#2) VirtualSystemManagementService: Fixing potential null dereferences Message-ID: # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1312918075 10800 # Node ID a346baf140d64177a9dc1066677c307ee6518236 # Parent 90ba6e1f899ea3ec47bc175e86bd245983e9375f VirtualSystemManagementService: Fixing potential null dereferences As reported in https://bugzilla.redhat.com/show_bug.cgi?id=728245 line 1048 - Comparing "path" to null implies that "path" might be null. line 1057 - Dereferencing null variable "path". line 1088 - Comparing "port" to null implies that "port" might be null. line 1094 - Dereferencing null variable "port". Changes since #1 - Removed free calls, incorporated at revision 1130. - Avoid NULL dereference in parse_sdl_address as well. Signed-off-by: Eduardo Lima (Etrunko) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1047,9 +1047,10 @@ ret = 1; - out: - CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", - *path, *port); + out: + if (path && port) + CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", + *path, *port); free(tmp_path); free(tmp_port); @@ -1097,8 +1098,9 @@ ret = 1; out: - CU_DEBUG("Exiting parse_sdl_address, display is %s, xauth is %s", - *display, *xauth); + if (display && xauth) + CU_DEBUG("Exiting parse_sdl_address, display is %s, xauth is %s", + *display, *xauth); free(tmp_display); free(tmp_xauth); @@ -1137,8 +1139,9 @@ ret = 1; out: - CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", - *ip, *port); + if (ip && port) + CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", + *ip, *port); free(tmp_ip); free(tmp_port); From cvincent at linux.vnet.ibm.com Thu Aug 18 19:59:13 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 18 Aug 2011 15:59:13 -0400 Subject: [Libvirt-cim] [PATCH] (#2) VirtualSystemManagementService: Fixing potential null dereferences In-Reply-To: References: Message-ID: <4E4D6F11.3040609@linux.vnet.ibm.com> Thanks. +1 and pushed. On 08/18/2011 03:12 PM, Eduardo Lima (Etrunko) wrote: > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1312918075 10800 > # Node ID a346baf140d64177a9dc1066677c307ee6518236 > # Parent 90ba6e1f899ea3ec47bc175e86bd245983e9375f > VirtualSystemManagementService: Fixing potential null dereferences > > As reported inhttps://bugzilla.redhat.com/show_bug.cgi?id=728245 > > line 1048 - Comparing "path" to null implies that "path" might be null. > line 1057 - Dereferencing null variable "path". > line 1088 - Comparing "port" to null implies that "port" might be null. > line 1094 - Dereferencing null variable "port". > > Changes since #1 > - Removed free calls, incorporated at revision 1130. > - Avoid NULL dereference in parse_sdl_address as well. > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -1047,9 +1047,10 @@ > > ret = 1; > > - out: > - CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", > - *path, *port); > + out: > + if (path&& port) > + CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", > + *path, *port); > > free(tmp_path); > free(tmp_port); > @@ -1097,8 +1098,9 @@ > ret = 1; > > out: > - CU_DEBUG("Exiting parse_sdl_address, display is %s, xauth is %s", > - *display, *xauth); > + if (display&& xauth) > + CU_DEBUG("Exiting parse_sdl_address, display is %s, xauth is %s", > + *display, *xauth); > > free(tmp_display); > free(tmp_xauth); > @@ -1137,8 +1139,9 @@ > ret = 1; > > out: > - CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", > - *ip, *port); > + if (ip&& port) > + CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", > + *ip, *port); > > free(tmp_ip); > free(tmp_port); > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From eblima at linux.vnet.ibm.com Tue Aug 23 15:12:19 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Tue, 23 Aug 2011 12:12:19 -0300 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Fix yet another possible leak Message-ID: <277b56b3863b5f81a3fa.1314112339@etrunko-t410.br.ibm.com> # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1314112289 10800 # Node ID 277b56b3863b5f81a3faa18aeb7b9951b963b489 # Parent a346baf140d64177a9dc1066677c307ee6518236 VirtualSystemManagementService: Fix yet another possible leak Signed-off-by: Eduardo Lima (Etrunko) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1377,7 +1377,11 @@ if (tmp == NULL) return false; - memcpy(tmp, *list, sizeof(*tmp) * cur); + if (*list) { + memcpy(tmp, *list, sizeof(*tmp) * cur); + free(*list); + } + *list = tmp; return true; From eblima at linux.vnet.ibm.com Wed Aug 24 16:26:48 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 24 Aug 2011 13:26:48 -0300 Subject: [Libvirt-cim] [PATCH] ACL: Add 'Action' property to KVM_{IPHeaders, Hdr8021}Filter Message-ID: <4d837e60bb82daa73bba.1314203208@etrunko-t410.br.ibm.com> # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1311872160 10800 # Node ID 4d837e60bb82daa73bba8e13bbab9041fc7632ee # Parent 277b56b3863b5f81a3faa18aeb7b9951b963b489 ACL: Add 'Action' property to KVM_{IPHeaders,Hdr8021}Filter This property should be defined in the CIM_FilterEntryBase parent class (would also apply to 'Direction' and 'Priority' properties), considering the fact that, according to libvirt documentation, the 'action' attribute of a rule is mandatory. For reference please check: http://libvirt.org/formatnwfilter.html#nwfelemsRules Signed-off-by: Eduardo Lima (Etrunko) diff --git a/schema/FilterEntry.mof b/schema/FilterEntry.mof --- a/schema/FilterEntry.mof +++ b/schema/FilterEntry.mof @@ -2,6 +2,14 @@ [Provider("cmpi::Virt_FilterEntry")] class KVM_Hdr8021Filter : CIM_Hdr8021Filter { + [Description ( + "This defines whether the action should be to forward or " + "deny traffic meeting the match condition specified in " + "this filter." ), + ValueMap { "1", "2" }, + Values { "Permit", "Deny" }] + uint16 Action; + [Description("This defines whether the Filter is used for input, " "output, or both input and output filtering. All values are " "used with respect to the interface for which the Filter " @@ -32,6 +40,14 @@ [Provider("cmpi::Virt_FilterEntry")] class KVM_IPHeadersFilter : CIM_IPHeadersFilter { + [Description ( + "This defines whether the action should be to forward or " + "deny traffic meeting the match condition specified in " + "this filter." ), + ValueMap { "1", "2" }, + Values { "Permit", "Deny" }] + uint16 Action; + [Description("This defines whether the Filter is used for input, " "output, or both input and output filtering. All values are " "used with respect to the interface for which the Filter " diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c --- a/src/Virt_FilterEntry.c +++ b/src/Virt_FilterEntry.c @@ -159,6 +159,19 @@ return priority; } +static int convert_action(const char *s) +{ + enum {NONE=0, ACCEPT, DENY} action = NONE; + + if (s != NULL) { + if (STREQC(s, "accept")) + action = ACCEPT; + else if (STREQC(s, "drop") || STREQC(s, "reject")) + action = DENY; + } + return action; +} + static CMPIInstance *convert_mac_rule_to_instance( struct acl_rule *rule, const CMPIBroker *broker, @@ -169,7 +182,7 @@ CMPIInstance *inst = NULL; const char *sys_name = NULL; const char *sys_ccname = NULL; - int direction, priority = 0; + int action, direction, priority = 0; unsigned int bytes[48]; unsigned int size = 0; CMPIArray *array = NULL; @@ -203,6 +216,9 @@ CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); + action = convert_action(rule->action); + CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); + direction = convert_direction(rule->direction); CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); @@ -259,7 +275,7 @@ CMPIInstance *inst = NULL; const char *sys_name = NULL; const char *sys_ccname = NULL; - int direction, priority = 0; + int action, direction, priority = 0; unsigned int bytes[48]; unsigned int size = 0; unsigned int n = 0; @@ -293,6 +309,9 @@ CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); + action = convert_action(rule->action); + CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); + direction = convert_direction(rule->direction); CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); From snmishra at us.ibm.com Wed Aug 24 16:58:53 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Wed, 24 Aug 2011 09:58:53 -0700 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Fix yet another possible leak In-Reply-To: <277b56b3863b5f81a3fa.1314112339@etrunko-t410.br.ibm.com> References: <277b56b3863b5f81a3fa.1314112339@etrunko-t410.br.ibm.com> Message-ID: +1 Eduardo, I remember you telling me that you have run cimtests successfully with this patch, correct? Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces at redhat.com wrote on 08/23/2011 08:12:19 AM: > "Eduardo Lima \(Etrunko\)" > Sent by: libvirt-cim-bounces at redhat.com > > 08/23/11 08:12 AM > > Please respond to > List for discussion and development of libvirt CIM > > To > > libvirt-cim at redhat.com > > cc > > Subject > > [Libvirt-cim] [PATCH] VirtualSystemManagementService: Fix yet > another possible leak > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1314112289 10800 > # Node ID 277b56b3863b5f81a3faa18aeb7b9951b963b489 > # Parent a346baf140d64177a9dc1066677c307ee6518236 > VirtualSystemManagementService: Fix yet another possible leak > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/ > Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -1377,7 +1377,11 @@ > if (tmp == NULL) > return false; > > - memcpy(tmp, *list, sizeof(*tmp) * cur); > + if (*list) { > + memcpy(tmp, *list, sizeof(*tmp) * cur); > + free(*list); > + } > + > *list = tmp; > > return true; > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From eblima at linux.vnet.ibm.com Wed Aug 24 17:06:46 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 24 Aug 2011 14:06:46 -0300 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Fix yet another possible leak In-Reply-To: References: <277b56b3863b5f81a3fa.1314112339@etrunko-t410.br.ibm.com> Message-ID: <4E552FA6.502@linux.vnet.ibm.com> On 08/24/2011 01:58 PM, Sharad Mishra wrote: > +1 > > Eduardo, I remember you telling me that you have run cimtests > successfully with this patch, correct? > Yes, I checked it before posting to the mailing list. :) > Sharad Mishra > Open Virtualization > Linux Technology Center > IBM > > libvirt-cim-bounces at redhat.com wrote on 08/23/2011 08:12:19 AM: > > > "Eduardo Lima \(Etrunko\)" > > Sent by: libvirt-cim-bounces at redhat.com > > > > 08/23/11 08:12 AM > > > > Please respond to > > List for discussion and development of libvirt CIM > > > > > To > > > > libvirt-cim at redhat.com > > > > cc > > > > Subject > > > > [Libvirt-cim] [PATCH] VirtualSystemManagementService: Fix yet > > another possible leak > > > > # HG changeset patch > > # User Eduardo Lima (Etrunko) > > # Date 1314112289 10800 > > # Node ID 277b56b3863b5f81a3faa18aeb7b9951b963b489 > > # Parent a346baf140d64177a9dc1066677c307ee6518236 > > VirtualSystemManagementService: Fix yet another possible leak > > > > Signed-off-by: Eduardo Lima (Etrunko) > > > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/ > > Virt_VirtualSystemManagementService.c > > --- a/src/Virt_VirtualSystemManagementService.c > > +++ b/src/Virt_VirtualSystemManagementService.c > > @@ -1377,7 +1377,11 @@ > > if (tmp == NULL) > > return false; > > > > - memcpy(tmp, *list, sizeof(*tmp) * cur); > > + if (*list) { > > + memcpy(tmp, *list, sizeof(*tmp) * cur); > > + free(*list); > > + } > > + > > *list = tmp; > > > > return true; > > > > _______________________________________________ > > Libvirt-cim mailing list > > Libvirt-cim at redhat.com > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From snmishra at us.ibm.com Fri Aug 26 17:32:18 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Fri, 26 Aug 2011 17:32:18 -0000 Subject: [Libvirt-cim] [PATCH] Workaround to fix race condition around libvirt init Message-ID: # HG changeset patch # User Sharad Mishra # Date 1314379933 25200 # Node ID a42b68361ed9cb4f7d6f15de5b58ccc68e88ef38 # Parent a346baf140d64177a9dc1066677c307ee6518236 Workaround to fix race condition around libvirt init. This patch fixes the race condition caused when mutiple threads try to start a VM. This patch also fixes the issue of incorrect mem allocation for VSSD property - emulator. Signed-off-by: Sharad Mishra diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c --- a/libxkutil/misc_util.c +++ b/libxkutil/misc_util.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,9 @@ #include "misc_util.h" #include "cs_util.h" +static pthread_mutex_t libvirt_mutex = PTHREAD_MUTEX_INITIALIZER; +/* libvirt library not initialized */ +static int libvirt_initialized = 0; #define URI_ENV "HYPURI" @@ -114,11 +118,15 @@ CU_DEBUG("Connecting to libvirt with uri `%s'", uri); + pthread_mutex_lock(&libvirt_mutex); + if (is_read_only()) conn = virConnectOpenReadOnly(uri); else conn = virConnectOpen(uri); + pthread_mutex_unlock(&libvirt_mutex); + if (!conn) { CU_DEBUG("Unable to connect to `%s'", uri); return NULL; @@ -530,7 +538,19 @@ bool libvirt_cim_init(void) { - return virInitialize() == 0; + int ret=0; + + /* double-check lock pattern used for performance reasons */ + if (0 == libvirt_initialized) { + pthread_mutex_lock(&libvirt_mutex); + if (0 == libvirt_initialized) { + ret = virInitialize(); + if (ret == 0) + libvirt_initialized=1; + } + pthread_mutex_unlock(&libvirt_mutex); + } + return (ret == 0); } bool check_refs_pfx_match(const CMPIObjectPath *refa, diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -188,6 +188,20 @@ return 1; } +static bool make_space(struct virt_device **list, int cur, int new) +{ + struct virt_device *tmp; + + tmp = calloc(cur + new, sizeof(*tmp)); + if (tmp == NULL) + return false; + + memcpy(tmp, *list, sizeof(*tmp) * cur); + *list = tmp; + + return true; +} + static bool fv_set_emulator(struct domain *domain, const char *emu) { @@ -198,6 +212,11 @@ if (emu == NULL) return true; + if (!make_space(&domain->dev_emu, 0, 1)) { + CU_DEBUG("Failed to alloc disk list"); + return false; + } + cleanup_virt_device(domain->dev_emu); domain->dev_emu->type = CIM_RES_TYPE_EMU; @@ -1369,20 +1388,6 @@ return msg; } -static bool make_space(struct virt_device **list, int cur, int new) -{ - struct virt_device *tmp; - - tmp = calloc(cur + new, sizeof(*tmp)); - if (tmp == NULL) - return false; - - memcpy(tmp, *list, sizeof(*tmp) * cur); - *list = tmp; - - return true; -} - static char *add_device_nodup(struct virt_device *dev, struct virt_device *list, int max, From snmishra at us.ibm.com Fri Aug 26 17:38:29 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Fri, 26 Aug 2011 17:38:29 -0000 Subject: [Libvirt-cim] [PATCH] DO NOT PUSH UPSTREAM Message-ID: <73e7bb11410f3c10d3b0.1314380309@elm3b193.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1314380301 25200 # Node ID 73e7bb11410f3c10d3b0b61678531314262f09b7 # Parent 2984ede9c082bab48b3494ef4b9f5561fadef2ad DO NOT PUSH UPSTREAM This is the workaround that was given to zGryphon team to prevent unloading of idle providers. There is a bug in libvirt that needs to be fixed. That fix will be the actual fix for this problem that cause segfault when those providers are unloaded that make a call to virConnectOpen. This patch is being put on mailing list just for archiving reasons. It should not be pushed upstream. Signed-off-by: Sharad Mishra diff --git a/libcmpiutil.h b/libcmpiutil.h --- a/libcmpiutil.h +++ b/libcmpiutil.h @@ -508,7 +508,16 @@ static CMPIStatus pn##Cleanup(CMPIInstanceMI *mi, \ const CMPIContext *c, \ CMPIBoolean terminating) \ - { RETURN_UNSUPPORTED(); } + { \ + if (terminating) \ + { \ + return (CMPIStatus) {CMPI_RC_OK, NULL}; \ + } \ + else \ + { \ + return (CMPIStatus) {CMPI_RC_NEVER_UNLOAD, NULL}; \ + } \ + } #define DEFAULT_IND_CLEANUP(pn) \ static CMPIStatus pn##IndicationCleanup(CMPIIndicationMI *mi, \ diff --git a/libcmpiutil.spec.in b/libcmpiutil.spec.in --- a/libcmpiutil.spec.in +++ b/libcmpiutil.spec.in @@ -3,7 +3,7 @@ Summary: CMPI Utility Library Name: libcmpiutil Version: @PACKAGE_VERSION@ -Release: 1%{?dist}%{?extra_release} +Release: 2%{?dist}%{?extra_release} License: LGPLv2+ Group: System Environment/Libraries Source: libcmpiutil-%{version}.tar.gz From eblima at linux.vnet.ibm.com Fri Aug 26 20:49:33 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Fri, 26 Aug 2011 17:49:33 -0300 Subject: [Libvirt-cim] [PATCH] Workaround to fix race condition around libvirt init In-Reply-To: References: Message-ID: <4E5806DD.3040504@linux.vnet.ibm.com> On 08/26/2011 02:32 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1314379933 25200 > # Node ID a42b68361ed9cb4f7d6f15de5b58ccc68e88ef38 > # Parent a346baf140d64177a9dc1066677c307ee6518236 > Workaround to fix race condition around libvirt init. > > This patch fixes the race condition caused when mutiple > threads try to start a VM. This patch also fixes the issue > of incorrect mem allocation for VSSD property - emulator. > > Signed-off-by: Sharad Mishra > > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > --- a/libxkutil/misc_util.c > +++ b/libxkutil/misc_util.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -45,6 +46,9 @@ > #include "misc_util.h" > #include "cs_util.h" > > +static pthread_mutex_t libvirt_mutex = PTHREAD_MUTEX_INITIALIZER; > +/* libvirt library not initialized */ > +static int libvirt_initialized = 0; > > #define URI_ENV "HYPURI" > > @@ -114,11 +118,15 @@ > > CU_DEBUG("Connecting to libvirt with uri `%s'", uri); > > + pthread_mutex_lock(&libvirt_mutex); > + > if (is_read_only()) > conn = virConnectOpenReadOnly(uri); > else > conn = virConnectOpen(uri); > > + pthread_mutex_unlock(&libvirt_mutex); > + > if (!conn) { > CU_DEBUG("Unable to connect to `%s'", uri); > return NULL; > @@ -530,7 +538,19 @@ > > bool libvirt_cim_init(void) > { > - return virInitialize() == 0; > + int ret=0; > + > + /* double-check lock pattern used for performance reasons */ > + if (0 == libvirt_initialized) { > + pthread_mutex_lock(&libvirt_mutex); > + if (0 == libvirt_initialized) { > + ret = virInitialize(); > + if (ret == 0) > + libvirt_initialized=1; > + } > + pthread_mutex_unlock(&libvirt_mutex); > + } > + return (ret == 0); > } > Please check the coding style for this snippet. > bool check_refs_pfx_match(const CMPIObjectPath *refa, > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -188,6 +188,20 @@ > return 1; > } > > +static bool make_space(struct virt_device **list, int cur, int new) > +{ > + struct virt_device *tmp; > + > + tmp = calloc(cur + new, sizeof(*tmp)); > + if (tmp == NULL) > + return false; > + > + memcpy(tmp, *list, sizeof(*tmp) * cur); > + *list = tmp; > + > + return true; > +} > + This undoes the patch in revision 1134 "VirtualSystemManagementService: Fix yet another possible leak". In resume, NACK! Please review and post again. -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From xiawenc at linux.vnet.ibm.com Mon Aug 29 04:06:49 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Mon, 29 Aug 2011 12:06:49 +0800 Subject: [Libvirt-cim] [PATCH] Workaround to fix race condition around libvirt init In-Reply-To: References: Message-ID: <4E5B1059.8060109@linux.vnet.ibm.com> I thought libvirt should guarantee that it would not start a VM twice, but if you fix that in CIM, I thought it is OK too. ? 2011-8-27 1:32, Sharad Mishra ??: > # HG changeset patch > # User Sharad Mishra > # Date 1314379933 25200 > # Node ID a42b68361ed9cb4f7d6f15de5b58ccc68e88ef38 > # Parent a346baf140d64177a9dc1066677c307ee6518236 > Workaround to fix race condition around libvirt init. > > This patch fixes the race condition caused when mutiple > threads try to start a VM. This patch also fixes the issue > of incorrect mem allocation for VSSD property - emulator. > > Signed-off-by: Sharad Mishra > > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > --- a/libxkutil/misc_util.c > +++ b/libxkutil/misc_util.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -45,6 +46,9 @@ > #include "misc_util.h" > #include "cs_util.h" > > +static pthread_mutex_t libvirt_mutex = PTHREAD_MUTEX_INITIALIZER; > +/* libvirt library not initialized */ > +static int libvirt_initialized = 0; > > #define URI_ENV "HYPURI" > > @@ -114,11 +118,15 @@ > > CU_DEBUG("Connecting to libvirt with uri `%s'", uri); > > + pthread_mutex_lock(&libvirt_mutex); > + > if (is_read_only()) > conn = virConnectOpenReadOnly(uri); > else > conn = virConnectOpen(uri); > > + pthread_mutex_unlock(&libvirt_mutex); > + > if (!conn) { > CU_DEBUG("Unable to connect to `%s'", uri); > return NULL; > @@ -530,7 +538,19 @@ > > bool libvirt_cim_init(void) > { > - return virInitialize() == 0; > + int ret=0; > + > + /* double-check lock pattern used for performance reasons */ > + if (0 == libvirt_initialized) { > + pthread_mutex_lock(&libvirt_mutex); > + if (0 == libvirt_initialized) { > + ret = virInitialize(); > + if (ret == 0) > + libvirt_initialized=1; > + } > + pthread_mutex_unlock(&libvirt_mutex); > + } > + return (ret == 0); > } > > bool check_refs_pfx_match(const CMPIObjectPath *refa, > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -188,6 +188,20 @@ > return 1; > } > > +static bool make_space(struct virt_device **list, int cur, int new) > +{ > + struct virt_device *tmp; > + > + tmp = calloc(cur + new, sizeof(*tmp)); > + if (tmp == NULL) > + return false; > + > + memcpy(tmp, *list, sizeof(*tmp) * cur); > + *list = tmp; > + > + return true; > +} > + > static bool fv_set_emulator(struct domain *domain, > const char *emu) > { > @@ -198,6 +212,11 @@ > if (emu == NULL) > return true; > > + if (!make_space(&domain->dev_emu, 0, 1)) { > + CU_DEBUG("Failed to alloc disk list"); > + return false; > + } > + > cleanup_virt_device(domain->dev_emu); > > domain->dev_emu->type = CIM_RES_TYPE_EMU; > @@ -1369,20 +1388,6 @@ > return msg; > } > > -static bool make_space(struct virt_device **list, int cur, int new) > -{ > - struct virt_device *tmp; > - > - tmp = calloc(cur + new, sizeof(*tmp)); > - if (tmp == NULL) > - return false; > - > - memcpy(tmp, *list, sizeof(*tmp) * cur); > - *list = tmp; > - > - return true; > -} > - > static char *add_device_nodup(struct virt_device *dev, > struct virt_device *list, > int max, > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From xiawenc at linux.vnet.ibm.com Mon Aug 29 09:35:24 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Mon, 29 Aug 2011 17:35:24 +0800 Subject: [Libvirt-cim] Better to Add Code to check "End of line" character in schema file Message-ID: <4E5B5D5C.7090406@linux.vnet.ibm.com> When I try add new class to libvirt-cim, I found that if the "end of line" character use the windows format(\t\n), then the rpm making would succeed, but the pegasus would not find the correct .so file, indeed pegasus seems to linked to a wrong file. It takes me a long time to find the reason, so I think it is better to add some scripts to check this, or show a warning for it. -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From xiawenc at linux.vnet.ibm.com Mon Aug 29 09:47:34 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Mon, 29 Aug 2011 17:47:34 +0800 Subject: [Libvirt-cim] [PATCH] Workaround to fix race condition around libvirt init In-Reply-To: References: Message-ID: <4E5B6036.4060109@linux.vnet.ibm.com> Is it possible that libvirt would invoke one VM twice? also some comments below. ? 2011-8-27 1:32, Sharad Mishra ??: > # HG changeset patch > # User Sharad Mishra > # Date 1314379933 25200 > # Node ID a42b68361ed9cb4f7d6f15de5b58ccc68e88ef38 > # Parent a346baf140d64177a9dc1066677c307ee6518236 > Workaround to fix race condition around libvirt init. > > This patch fixes the race condition caused when mutiple > threads try to start a VM. This patch also fixes the issue > of incorrect mem allocation for VSSD property - emulator. > > Signed-off-by: Sharad Mishra > > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > --- a/libxkutil/misc_util.c > +++ b/libxkutil/misc_util.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -45,6 +46,9 @@ > #include "misc_util.h" > #include "cs_util.h" > > +static pthread_mutex_t libvirt_mutex = PTHREAD_MUTEX_INITIALIZER; > +/* libvirt library not initialized */ > +static int libvirt_initialized = 0; > > #define URI_ENV "HYPURI" > > @@ -114,11 +118,15 @@ > > CU_DEBUG("Connecting to libvirt with uri `%s'", uri); > > + pthread_mutex_lock(&libvirt_mutex); > + > if (is_read_only()) > conn = virConnectOpenReadOnly(uri); > else > conn = virConnectOpen(uri); > > + pthread_mutex_unlock(&libvirt_mutex); > + > if (!conn) { > CU_DEBUG("Unable to connect to `%s'", uri); > return NULL; > @@ -530,7 +538,19 @@ > > bool libvirt_cim_init(void) > { > - return virInitialize() == 0; > + int ret=0; > + > + /* double-check lock pattern used for performance reasons */ > + if (0 == libvirt_initialized) { > + pthread_mutex_lock(&libvirt_mutex); > + if (0 == libvirt_initialized) { > + ret = virInitialize(); > + if (ret == 0) > + libvirt_initialized=1; > + } > + pthread_mutex_unlock(&libvirt_mutex); > + } > + return (ret == 0); > } > > bool check_refs_pfx_match(const CMPIObjectPath *refa, > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -188,6 +188,20 @@ > return 1; > } > > +static bool make_space(struct virt_device **list, int cur, int new) > +{ > + struct virt_device *tmp; > + > + tmp = calloc(cur + new, sizeof(*tmp)); > + if (tmp == NULL) > + return false; > + maybe some lines should be added here like this: if (*list!=NULL) { memcpy(tmp, *list, sizeof(*tmp) * cur); free(*list); *list = tmp; } > + memcpy(tmp, *list, sizeof(*tmp) * cur); > + *list = tmp; > + > + return true; > +} > + > static bool fv_set_emulator(struct domain *domain, > const char *emu) > { > @@ -198,6 +212,11 @@ > if (emu == NULL) > return true; > > + if (!make_space(&domain->dev_emu, 0, 1)) { > + CU_DEBUG("Failed to alloc disk list"); > + return false; > + } > + > cleanup_virt_device(domain->dev_emu); > > domain->dev_emu->type = CIM_RES_TYPE_EMU; > @@ -1369,20 +1388,6 @@ > return msg; > } > > -static bool make_space(struct virt_device **list, int cur, int new) > -{ > - struct virt_device *tmp; > - > - tmp = calloc(cur + new, sizeof(*tmp)); > - if (tmp == NULL) > - return false; > - > - memcpy(tmp, *list, sizeof(*tmp) * cur); > - *list = tmp; > - > - return true; > -} > - > static char *add_device_nodup(struct virt_device *dev, > struct virt_device *list, > int max, > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From snmishra at us.ibm.com Mon Aug 29 16:37:22 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Mon, 29 Aug 2011 09:37:22 -0700 Subject: [Libvirt-cim] Better to Add Code to check "End of line" character in schema file In-Reply-To: <4E5B5D5C.7090406@linux.vnet.ibm.com> References: <4E5B5D5C.7090406@linux.vnet.ibm.com> Message-ID: Wayne, Are you saying that after you install libvirt-cim RPM it does not find libvirt-cim libs? I have not seen this issue, I always uninstall (rpm -e) libvirt-cim before installing (rpm -i) the new version. Sharad Mishra Open Virtualization Linux Technology Center IBM Wayne Xia To Chip Vincent 08/29/11 02:35 AM , "Eduardo Lima (Etrunko)" , Sharad Mishra/Beaverton/IBM at IBMUS, Gareth S Bestor/Poughkeepsie/IBM at IBMUS, List for discussion and development of libvirt CIM cc Subject Better to Add Code to check "End of line" character in schema file When I try add new class to libvirt-cim, I found that if the "end of line" character use the windows format(\t\n), then the rpm making would succeed, but the pegasus would not find the correct .so file, indeed pegasus seems to linked to a wrong file. It takes me a long time to find the reason, so I think it is better to add some scripts to check this, or show a warning for it. -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: graycol.gif Type: image/gif Size: 105 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pic24629.gif Type: image/gif Size: 1255 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ecblank.gif Type: image/gif Size: 45 bytes Desc: not available URL: From snmishra at us.ibm.com Mon Aug 29 16:42:03 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Mon, 29 Aug 2011 09:42:03 -0700 Subject: [Libvirt-cim] [PATCH] Workaround to fix race condition around libvirt init In-Reply-To: <4E5B6036.4060109@linux.vnet.ibm.com> References: <4E5B6036.4060109@linux.vnet.ibm.com> Message-ID: Wayne Xia wrote on 08/29/2011 02:47:34 AM: > Wayne Xia > 08/29/11 02:47 AM > > To > > libvirt-cim at redhat.com, Sharad Mishra/Beaverton/IBM at IBMUS > > cc > > Subject > > Re: [Libvirt-cim] [PATCH] Workaround to fix race condition around libvirt init Thanks for the comment, Wayne. > > Is it possible that libvirt would invoke one VM twice? that will be a bug. I have never seen that happen. > > also some comments below. > > ? 2011-8-27 1:32, Sharad Mishra ??: > > # HG changeset patch > > # User Sharad Mishra > > # Date 1314379933 25200 > > # Node ID a42b68361ed9cb4f7d6f15de5b58ccc68e88ef38 > > # Parent a346baf140d64177a9dc1066677c307ee6518236 > > Workaround to fix race condition around libvirt init. > > > > This patch fixes the race condition caused when mutiple > > threads try to start a VM. This patch also fixes the issue > > of incorrect mem allocation for VSSD property - emulator. > > > > Signed-off-by: Sharad Mishra > > > > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > > --- a/libxkutil/misc_util.c > > +++ b/libxkutil/misc_util.c > > @@ -28,6 +28,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -45,6 +46,9 @@ > > #include "misc_util.h" > > #include "cs_util.h" > > > > +static pthread_mutex_t libvirt_mutex = PTHREAD_MUTEX_INITIALIZER; > > +/* libvirt library not initialized */ > > +static int libvirt_initialized = 0; > > > > #define URI_ENV "HYPURI" > > > > @@ -114,11 +118,15 @@ > > > > CU_DEBUG("Connecting to libvirt with uri `%s'", uri); > > > > + pthread_mutex_lock(&libvirt_mutex); > > + > > if (is_read_only()) > > conn = virConnectOpenReadOnly(uri); > > else > > conn = virConnectOpen(uri); > > > > + pthread_mutex_unlock(&libvirt_mutex); > > + > > if (!conn) { > > CU_DEBUG("Unable to connect to `%s'", uri); > > return NULL; > > @@ -530,7 +538,19 @@ > > > > bool libvirt_cim_init(void) > > { > > - return virInitialize() == 0; > > + int ret=0; > > + > > + /* double-check lock pattern used for performance reasons */ > > + if (0 == libvirt_initialized) { > > + pthread_mutex_lock(&libvirt_mutex); > > + if (0 == libvirt_initialized) { > > + ret = virInitialize(); > > + if (ret == 0) > > + libvirt_initialized=1; > > + } > > + pthread_mutex_unlock(&libvirt_mutex); > > + } > > + return (ret == 0); > > } > > > > bool check_refs_pfx_match(const CMPIObjectPath *refa, > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/ > Virt_VirtualSystemManagementService.c > > --- a/src/Virt_VirtualSystemManagementService.c > > +++ b/src/Virt_VirtualSystemManagementService.c > > @@ -188,6 +188,20 @@ > > return 1; > > } > > > > +static bool make_space(struct virt_device **list, int cur, int new) > > +{ > > + struct virt_device *tmp; > > + > > + tmp = calloc(cur + new, sizeof(*tmp)); > > + if (tmp == NULL) > > + return false; > > + > maybe some lines should be added here like this: > > if (*list!=NULL) { > memcpy(tmp, *list, sizeof(*tmp) * cur); > free(*list); > *list = tmp; > } > Eduardo already submitted a patch for this. I will redo this patch to include Eduardo's fix. > > + memcpy(tmp, *list, sizeof(*tmp) * cur); > > + *list = tmp; > > + > > + return true; > > +} > > + > > static bool fv_set_emulator(struct domain *domain, > > const char *emu) > > { > > @@ -198,6 +212,11 @@ > > if (emu == NULL) > > return true; > > > > + if (!make_space(&domain->dev_emu, 0, 1)) { > > + CU_DEBUG("Failed to alloc disk list"); > > + return false; > > + } > > + > > cleanup_virt_device(domain->dev_emu); > > > > domain->dev_emu->type = CIM_RES_TYPE_EMU; > > @@ -1369,20 +1388,6 @@ > > return msg; > > } > > > > -static bool make_space(struct virt_device **list, int cur, int new) > > -{ > > - struct virt_device *tmp; > > - > > - tmp = calloc(cur + new, sizeof(*tmp)); > > - if (tmp == NULL) > > - return false; > > - > > - memcpy(tmp, *list, sizeof(*tmp) * cur); > > - *list = tmp; > > - > > - return true; > > -} > > - > > static char *add_device_nodup(struct virt_device *dev, > > struct virt_device *list, > > int max, > > > > _______________________________________________ > > Libvirt-cim mailing list > > Libvirt-cim at redhat.com > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > > -- > Best Regards > > Wayne Xia > mail:xiawenc at linux.vnet.ibm.com > tel:86-010-82450803 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From snmishra at us.ibm.com Mon Aug 29 16:46:04 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Mon, 29 Aug 2011 09:46:04 -0700 Subject: [Libvirt-cim] [PATCH] Workaround to fix race condition around libvirt init In-Reply-To: <4E5B1059.8060109@linux.vnet.ibm.com> References: <4E5B1059.8060109@linux.vnet.ibm.com> Message-ID: libvirt-cim-bounces at redhat.com wrote on 08/28/2011 09:06:49 PM: > Wayne Xia > Sent by: libvirt-cim-bounces at redhat.com > > 08/28/11 09:06 PM > > Please respond to > List for discussion and development of libvirt CIM > > To > > List for discussion and development of libvirt CIM > > cc > > Subject > > Re: [Libvirt-cim] [PATCH] Workaround to fix race condition around libvirt init > > I thought libvirt should guarantee that it would not start a VM > twice, but if you fix that in CIM, I thought it is OK too. My comments below are misleading. I meant to say multiple threads are trying to start multiple VMs at the same time and each thread is starting a unique VM. So the situation is ... you have 6 VMs to start on the host and you start 6 threads to start those VMs. I will correct the comment in next rev of this patch. > > ? 2011-8-27 1:32, Sharad Mishra ??: > > # HG changeset patch > > # User Sharad Mishra > > # Date 1314379933 25200 > > # Node ID a42b68361ed9cb4f7d6f15de5b58ccc68e88ef38 > > # Parent a346baf140d64177a9dc1066677c307ee6518236 > > Workaround to fix race condition around libvirt init. > > > > This patch fixes the race condition caused when mutiple > > threads try to start a VM. This patch also fixes the issue > > of incorrect mem allocation for VSSD property - emulator. > > > > Signed-off-by: Sharad Mishra > > > > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > > --- a/libxkutil/misc_util.c > > +++ b/libxkutil/misc_util.c > > @@ -28,6 +28,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -45,6 +46,9 @@ > > #include "misc_util.h" > > #include "cs_util.h" > > > > +static pthread_mutex_t libvirt_mutex = PTHREAD_MUTEX_INITIALIZER; > > +/* libvirt library not initialized */ > > +static int libvirt_initialized = 0; > > > > #define URI_ENV "HYPURI" > > > > @@ -114,11 +118,15 @@ > > > > CU_DEBUG("Connecting to libvirt with uri `%s'", uri); > > > > + pthread_mutex_lock(&libvirt_mutex); > > + > > if (is_read_only()) > > conn = virConnectOpenReadOnly(uri); > > else > > conn = virConnectOpen(uri); > > > > + pthread_mutex_unlock(&libvirt_mutex); > > + > > if (!conn) { > > CU_DEBUG("Unable to connect to `%s'", uri); > > return NULL; > > @@ -530,7 +538,19 @@ > > > > bool libvirt_cim_init(void) > > { > > - return virInitialize() == 0; > > + int ret=0; > > + > > + /* double-check lock pattern used for performance reasons */ > > + if (0 == libvirt_initialized) { > > + pthread_mutex_lock(&libvirt_mutex); > > + if (0 == libvirt_initialized) { > > + ret = virInitialize(); > > + if (ret == 0) > > + libvirt_initialized=1; > > + } > > + pthread_mutex_unlock(&libvirt_mutex); > > + } > > + return (ret == 0); > > } > > > > bool check_refs_pfx_match(const CMPIObjectPath *refa, > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/ > Virt_VirtualSystemManagementService.c > > --- a/src/Virt_VirtualSystemManagementService.c > > +++ b/src/Virt_VirtualSystemManagementService.c > > @@ -188,6 +188,20 @@ > > return 1; > > } > > > > +static bool make_space(struct virt_device **list, int cur, int new) > > +{ > > + struct virt_device *tmp; > > + > > + tmp = calloc(cur + new, sizeof(*tmp)); > > + if (tmp == NULL) > > + return false; > > + > > + memcpy(tmp, *list, sizeof(*tmp) * cur); > > + *list = tmp; > > + > > + return true; > > +} > > + > > static bool fv_set_emulator(struct domain *domain, > > const char *emu) > > { > > @@ -198,6 +212,11 @@ > > if (emu == NULL) > > return true; > > > > + if (!make_space(&domain->dev_emu, 0, 1)) { > > + CU_DEBUG("Failed to alloc disk list"); > > + return false; > > + } > > + > > cleanup_virt_device(domain->dev_emu); > > > > domain->dev_emu->type = CIM_RES_TYPE_EMU; > > @@ -1369,20 +1388,6 @@ > > return msg; > > } > > > > -static bool make_space(struct virt_device **list, int cur, int new) > > -{ > > - struct virt_device *tmp; > > - > > - tmp = calloc(cur + new, sizeof(*tmp)); > > - if (tmp == NULL) > > - return false; > > - > > - memcpy(tmp, *list, sizeof(*tmp) * cur); > > - *list = tmp; > > - > > - return true; > > -} > > - > > static char *add_device_nodup(struct virt_device *dev, > > struct virt_device *list, > > int max, > > > > _______________________________________________ > > Libvirt-cim mailing list > > Libvirt-cim at redhat.com > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > > -- > Best Regards > > Wayne Xia > mail:xiawenc at linux.vnet.ibm.com > tel:86-010-82450803 > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From xiawenc at linux.vnet.ibm.com Tue Aug 30 02:33:34 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Tue, 30 Aug 2011 10:33:34 +0800 Subject: [Libvirt-cim] Better to Add Code to check "End of line" character in schema file In-Reply-To: References: <4E5B5D5C.7090406@linux.vnet.ibm.com> Message-ID: <4E5C4BFE.8060602@linux.vnet.ibm.com> In the case of using "\t\n" in .mof and .registration file, after the libvirt-cim' rpm was made and installed, the libs was found by pegasus, but seems it was not correctly done. situation: tried to add class KVM_EthernetPort, then wbemcli -nl ein http://root:123456xwc at localhost:5988/root/virt:KVM_EthernetPort nothing returned. then delete Virt_EthernetPort.so*. wbemcli -nl ein http://root:123456xwc at localhost:5988/root/virt:KVM_EthernetPort nothing returned. It did not say the lib was missing. After rewrite the .mof and .registration file, problem resolved. So I think there is some problem in the lib searching of pegasus, in this situation. 2011-8-30 0:37, Sharad Mishra: > Wayne, > > Are you saying that after you install libvirt-cim RPM it does not find > libvirt-cim libs? > I have not seen this issue, I always uninstall (rpm -e) libvirt-cim > before installing (rpm -i) the new version. > > Sharad Mishra > Open Virtualization > Linux Technology Center > IBM > > Inactive hide details for Wayne Xia ---08/29/2011 02:37:10 AM---When I > try add new class to libvirt-cim, I found that if the "eWayne Xia > ---08/29/2011 02:37:10 AM---When I try add new class to libvirt-cim, I > found that if the "end of > > *Wayne Xia * > > 08/29/11 02:35 AM > > > > To > > Chip Vincent , "Eduardo Lima (Etrunko)" > , Sharad Mishra/Beaverton/IBM at IBMUS, Gareth S > Bestor/Poughkeepsie/IBM at IBMUS, List for discussion and development of > libvirt CIM > > cc > > > Subject > > Better to Add Code to check "End of line" character in schema file > > > > > When I try add new class to libvirt-cim, I found that if the "end of > line" character use the windows format(\t\n), then the rpm making would > succeed, but the pegasus would not find the correct .so file, indeed > pegasus seems to linked to a wrong file. > > It takes me a long time to find the reason, so I think it is better to > add some scripts to check this, or show a warning for it. > > > > > > -- > Best Regards > > Wayne Xia > mail:xiawenc at linux.vnet.ibm.com > tel:86-010-82450803 > > -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From veillard at redhat.com Tue Aug 30 08:43:06 2011 From: veillard at redhat.com (Daniel Veillard) Date: Tue, 30 Aug 2011 16:43:06 +0800 Subject: [Libvirt-cim] [PATCH] DO NOT PUSH UPSTREAM In-Reply-To: <73e7bb11410f3c10d3b0.1314380309@elm3b193.beaverton.ibm.com> References: <73e7bb11410f3c10d3b0.1314380309@elm3b193.beaverton.ibm.com> Message-ID: <20110830084306.GC27356@redhat.com> On Fri, Aug 26, 2011 at 05:38:29PM -0000, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1314380301 25200 > # Node ID 73e7bb11410f3c10d3b0b61678531314262f09b7 > # Parent 2984ede9c082bab48b3494ef4b9f5561fadef2ad > DO NOT PUSH UPSTREAM > > This is the workaround that was given to zGryphon > team to prevent unloading of idle providers. > There is a bug in libvirt that needs to be fixed. > That fix will be the actual fix for this problem > that cause segfault when those providers are unloaded > that make a call to virConnectOpen. I'm curious about the libvirt bug, which one is it ? Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ From snmishra at us.ibm.com Tue Aug 30 13:48:38 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Tue, 30 Aug 2011 06:48:38 -0700 Subject: [Libvirt-cim] [PATCH] DO NOT PUSH UPSTREAM In-Reply-To: <20110830084306.GC27356@redhat.com> References: <73e7bb11410f3c10d3b0.1314380309@elm3b193.beaverton.ibm.com> <20110830084306.GC27356@redhat.com> Message-ID: DV, Its not mirrored to RH yet, I am working on it. In the meantime, here is the description of the defect. ******************************************** virInitialize leads to segfault when unloading libvirt-cim providers. Contact Information = Sharad Mishra/snmishra at us.ibm.com, ---uname output--- Linux elm3b193.beaverton.ibm.com 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux Machine Type = IBM system x blade, machine type - 8853, model - MC1 ---Debugger--- A debugger is not configured ---Steps to Reproduce--- 1. Install libvirt and libvirt-cim 2 start libvirtd 3. start tog-pegasus 4. run wbemcli command to enum instance on KVM_ComputerSystem class. This is just a way to load the provider to memory. All we need to do is run virConnectOpen() and virConnectClose() in this provider. So in this step all that is required is for virConnectOpen and virConnectClose to run. 5. Stop tog-pegasus. A core is gererated. ---System Management Component Data--- Userspace tool common name: libvirt/libvirt-cim/tog-pegasus System management type: IMM The userspace tool has the following bit modes: 64 Userspace rpm: libvirt-0.6.3-33.el5, libvirt-cim-0.5.14-1 and tog-pegasus-2.9.2-2.el5 Userspace tool obtained from project website: na *Additional Instructions for Sharad Mishra/snmishra at us.ibm.com, : -Post a private note with access information to the machine that the bug is occuring on. -Attach ltrace and strace of userspace application. -Attach screen shoot of System Managment Utility Here is the gist of investigation done so far --- Here is the gist of his investigation - I've looked into the libvirt source code and the reason for issues with the unload of libvirt-cim providers is there (and cimprovider -r forces an unload, just as cimserver shutdown does). virConnectOpen() does call virInitialize() which then will initialize the gcrypt library after initializes the thread setup ->virThreadInitialize(), creates the error reporting structure ->virErrorInitialize() and initialize a random number generator ->virRandomInitialize(). The issue is hidden in virErrorInitialize(). It calls virErrorInitialize() which uses the wrapper function virThreadLocalInit(&virLastErr, virLastErrFreeData);. virThreadLocalInit() calls pthread_create() with a destructor function (virLastErrFreeData()) which will be called on thread exits. Trouble here is that pthread_key_delete() is never called in libvirt, but next time the system runs through the key list and libvirt has been unloaded the system will jump to an already unloaded function (the pointer were virLastErrFreeData() was loaded formerly) and consequently crash the process. Fixing this will not be easy, but a start would be a libvirt function on its externalize interface that allows cleanup short before library unload, or alternatively libvirt does the thread key delete on library unload. Trace output from gdb - /var/log/messages: Aug 6 11:35:58 SYX-e41f13fe5558 cimserver[21602]: OpenPegasus stopped. Aug 6 11:35:59 SYX-e41f13fe5558 kernel: cimserver[21376]: segfault at 00002aaaab165f00 rip 00002aaaab165f00 rsp 00000000457d40b8 error 14 call stack trace: command: gdb -batch -x /tmp/gdb.27236.cmd /usr/sbin/cimserver /var/log/core/core.25567 time: Sat Aug 6 11:35:59 UTC 2011 stdout/stderr: ----------------------------------------------------------------- [New Thread 25567] Core was generated by `/usr/sbin/cimserver'. Program terminated with signal 11, Segmentation fault. #0 0x00002aaaab4f6f00 in ?? () #0 0x00002aaaab4f6f00 in ?? () #1 0x00002ab4fb3c6ad9 in __nptl_deallocate_tsd () from /lib64/libpthread.so.0 #2 0x00002ab4fb3c774b in start_thread () from /lib64/libpthread.so.0 #3 0x00002ab4fc07af6d in clone () from /lib64/libc.so.6 ----------------------------------------------------------------- exit_code=0 ----------------------------------------------------------------- Regards, Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces at redhat.com wrote on 08/30/2011 01:43:06 AM: > Daniel Veillard > Sent by: libvirt-cim-bounces at redhat.com > > 08/30/11 01:43 AM > > Please respond to > veillard at redhat.com; Please respond to > List for discussion and development of libvirt CIM > > To > > List for discussion and development of libvirt CIM > > cc > > Subject > > Re: [Libvirt-cim] [PATCH] DO NOT PUSH UPSTREAM > > On Fri, Aug 26, 2011 at 05:38:29PM -0000, Sharad Mishra wrote: > > # HG changeset patch > > # User Sharad Mishra > > # Date 1314380301 25200 > > # Node ID 73e7bb11410f3c10d3b0b61678531314262f09b7 > > # Parent 2984ede9c082bab48b3494ef4b9f5561fadef2ad > > DO NOT PUSH UPSTREAM > > > > This is the workaround that was given to zGryphon > > team to prevent unloading of idle providers. > > There is a bug in libvirt that needs to be fixed. > > That fix will be the actual fix for this problem > > that cause segfault when those providers are unloaded > > that make a call to virConnectOpen. > > I'm curious about the libvirt bug, which one is it ? > > Daniel > > -- > Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ > daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/ > http://veillard.com/ | virtualization library http://libvirt.org/ > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From snmishra at us.ibm.com Tue Aug 30 17:14:40 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Tue, 30 Aug 2011 17:14:40 -0000 Subject: [Libvirt-cim] [PATCH] (#2) Workaround to fix race condition around libvirt init Message-ID: # HG changeset patch # User Sharad Mishra # Date 1314719316 25200 # Node ID c54aafd0b2c6414f91b96bc30e2f148bb78d5c59 # Parent 277b56b3863b5f81a3faa18aeb7b9951b963b489 (#2) Workaround to fix race condition around libvirt init. This patch fixes the race condition caused when mutiple threads try to start VMs at the same time. This patch also fixes the issue of incorrect mem allocation for VSSD property - emulator. #2: included Edurdo's patch for make_space took care of coding guidelines. Signed-off-by: Sharad Mishra diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c --- a/libxkutil/misc_util.c +++ b/libxkutil/misc_util.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,9 @@ #include "misc_util.h" #include "cs_util.h" +static pthread_mutex_t libvirt_mutex = PTHREAD_MUTEX_INITIALIZER; +/* libvirt library not initialized */ +static int libvirt_initialized = 0; #define URI_ENV "HYPURI" @@ -114,11 +118,15 @@ CU_DEBUG("Connecting to libvirt with uri `%s'", uri); + pthread_mutex_lock(&libvirt_mutex); + if (is_read_only()) conn = virConnectOpenReadOnly(uri); else conn = virConnectOpen(uri); + pthread_mutex_unlock(&libvirt_mutex); + if (!conn) { CU_DEBUG("Unable to connect to `%s'", uri); return NULL; @@ -530,7 +538,19 @@ bool libvirt_cim_init(void) { - return virInitialize() == 0; + int ret = 0; + + /* double-check lock pattern used for performance reasons */ + if (libvirt_initialized == 0) { + pthread_mutex_lock(&libvirt_mutex); + if (libvirt_initialized == 0) { + ret = virInitialize(); + if (ret == 0) + libvirt_initialized = 1; + } + pthread_mutex_unlock(&libvirt_mutex); + } + return (ret == 0); } bool check_refs_pfx_match(const CMPIObjectPath *refa, diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -188,6 +188,24 @@ return 1; } +static bool make_space(struct virt_device **list, int cur, int new) +{ + struct virt_device *tmp; + + tmp = calloc(cur + new, sizeof(*tmp)); + if (tmp == NULL) + return false; + + if (*list) { + memcpy(tmp, *list, sizeof(*tmp) * cur); + free(*list); + } + + *list = tmp; + + return true; +} + static bool fv_set_emulator(struct domain *domain, const char *emu) { @@ -198,6 +216,11 @@ if (emu == NULL) return true; + if (!make_space(&domain->dev_emu, 0, 1)) { + CU_DEBUG("Failed to alloc disk list"); + return false; + } + cleanup_virt_device(domain->dev_emu); domain->dev_emu->type = CIM_RES_TYPE_EMU; @@ -1369,24 +1392,6 @@ return msg; } -static bool make_space(struct virt_device **list, int cur, int new) -{ - struct virt_device *tmp; - - tmp = calloc(cur + new, sizeof(*tmp)); - if (tmp == NULL) - return false; - - if (*list) { - memcpy(tmp, *list, sizeof(*tmp) * cur); - free(*list); - } - - *list = tmp; - - return true; -} - static char *add_device_nodup(struct virt_device *dev, struct virt_device *list, int max, From eblima at linux.vnet.ibm.com Wed Aug 31 13:41:56 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 31 Aug 2011 10:41:56 -0300 Subject: [Libvirt-cim] [PATCH] (#2) Workaround to fix race condition around libvirt init In-Reply-To: References: Message-ID: <4E5E3A24.3060906@linux.vnet.ibm.com> On 08/30/2011 02:14 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1314719316 25200 > # Node ID c54aafd0b2c6414f91b96bc30e2f148bb78d5c59 > # Parent 277b56b3863b5f81a3faa18aeb7b9951b963b489 > (#2) Workaround to fix race condition around libvirt init. > > This patch fixes the race condition caused when mutiple > threads try to start VMs at the same time. This patch > also fixes the issue of incorrect mem allocation for > VSSD property - emulator. > > #2: included Edurdo's patch for make_space > took care of coding guidelines. > > Signed-off-by: Sharad Mishra > > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > --- a/libxkutil/misc_util.c > +++ b/libxkutil/misc_util.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -45,6 +46,9 @@ > #include "misc_util.h" > #include "cs_util.h" > > +static pthread_mutex_t libvirt_mutex = PTHREAD_MUTEX_INITIALIZER; > +/* libvirt library not initialized */ > +static int libvirt_initialized = 0; > > #define URI_ENV "HYPURI" > > @@ -114,11 +118,15 @@ > > CU_DEBUG("Connecting to libvirt with uri `%s'", uri); > > + pthread_mutex_lock(&libvirt_mutex); > + > if (is_read_only()) > conn = virConnectOpenReadOnly(uri); > else > conn = virConnectOpen(uri); > > + pthread_mutex_unlock(&libvirt_mutex); > + > if (!conn) { > CU_DEBUG("Unable to connect to `%s'", uri); > return NULL; > @@ -530,7 +538,19 @@ > > bool libvirt_cim_init(void) > { > - return virInitialize() == 0; > + int ret = 0; > + > + /* double-check lock pattern used for performance reasons */ > + if (libvirt_initialized == 0) { > + pthread_mutex_lock(&libvirt_mutex); > + if (libvirt_initialized == 0) { > + ret = virInitialize(); > + if (ret == 0) > + libvirt_initialized = 1; > + } > + pthread_mutex_unlock(&libvirt_mutex); > + } > + return (ret == 0); > } > > bool check_refs_pfx_match(const CMPIObjectPath *refa, > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -188,6 +188,24 @@ > return 1; > } > > +static bool make_space(struct virt_device **list, int cur, int new) > +{ > + struct virt_device *tmp; > + > + tmp = calloc(cur + new, sizeof(*tmp)); > + if (tmp == NULL) > + return false; > + > + if (*list) { > + memcpy(tmp, *list, sizeof(*tmp) * cur); > + free(*list); > + } > + > + *list = tmp; > + > + return true; > +} > + > static bool fv_set_emulator(struct domain *domain, > const char *emu) > { > @@ -198,6 +216,11 @@ > if (emu == NULL) > return true; > > + if (!make_space(&domain->dev_emu, 0, 1)) { > + CU_DEBUG("Failed to alloc disk list"); > + return false; > + } > + > cleanup_virt_device(domain->dev_emu); > > domain->dev_emu->type = CIM_RES_TYPE_EMU; > @@ -1369,24 +1392,6 @@ > return msg; > } > > -static bool make_space(struct virt_device **list, int cur, int new) > -{ > - struct virt_device *tmp; > - > - tmp = calloc(cur + new, sizeof(*tmp)); > - if (tmp == NULL) > - return false; > - > - if (*list) { > - memcpy(tmp, *list, sizeof(*tmp) * cur); > - free(*list); > - } > - > - *list = tmp; > - > - return true; > -} > - > static char *add_device_nodup(struct virt_device *dev, > struct virt_device *list, > int max, > +1. Tricky stuff. :) -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com