From raghunp at cisco.com Sun Jun 3 16:12:20 2012 From: raghunp at cisco.com (Raghunatha Reddy P (raghunp)) Date: Sun, 3 Jun 2012 16:12:20 +0000 Subject: [Libvirt-cim] regarding creating VM using libvirt-cim In-Reply-To: <20120530115120.Horde.ZJbPVJir309PxkH4P1oEFIA@imap.linux.ibm.com> References: , <20120530115120.Horde.ZJbPVJir309PxkH4P1oEFIA@imap.linux.ibm.com> Message-ID: Hi Sharad, Thanks for the information. We need to use CIM-Schemas, defined by DMTF, to create and work on VMs. Could you please share the following, - What are all soft-wares do I need to install to start working on this. Would be good if you can provide step step procedure for this. - What are all the hyper-visors are supported by libvirt-cim? Deos it support ESX hypervisor? - Do we have any detailed documentation/ wiki for this in addition to http://www.libvirt.org/CIM/ Best Regards Raghu ________________________________________ From: snmishra at linux.vnet.ibm.com [snmishra at linux.vnet.ibm.com] Sent: Wednesday, May 30, 2012 9:21 PM To: Raghunatha Reddy P (raghunp) Subject: Re: [Libvirt-cim] regarding creating VM using libvirt-cim Quoting "Raghunatha Reddy P (raghunp)" : > Hi All, > I am very new to libvirt-cim. We wanted to create a VM using > libvirt-cim using CIM schemas. Could you please detail the steps > involved in this task, procedures, softwares to be installed and run, > docs, wikipages, blogs..etc. Hi Raghu, Welcome to libvirt-cim. Best way to learn how to use libvirt-cim is to create a VM using cimtest. You can download cimtest snapshot from http://libvirt.org/git/?p=cimtest.git;a=tree. Go to cimtest directory and run the following command - CIM_NS=root/virt CIM_USER=<> CIM_PASS=<> ./runtests libvirt-cim -i localhost -c -d -v KVM -g ComputerSystem -t 06_paused_active_suspend.py Replace <> and <> with your username and password. You may have some missing packages that cimtest needs. Once you have them installed, you can follow the test to learn how VMs are created. There are lot more tests under cimtest which do more advanced things like adding disk/memeory/CPU to existing VM. Feel free to post on the mailing list if you have any more questions. -Sharad Mishra IBM > > Thanks in advance. > > > Best Regards > Raghu > > -----Original Message----- > From: libvirt-cim-bounces at redhat.com > [mailto:libvirt-cim-bounces at redhat.com] On Behalf Of > libvirt-cim-request at redhat.com > Sent: 30 May 2012 10:50 > To: Raghunatha Reddy P (raghunp) > Subject: Welcome to the "Libvirt-cim" mailing list > > Welcome to the Libvirt-cim at redhat.com mailing list! > > To post to this list, send your email to: > > libvirt-cim at redhat.com > > General information about the mailing list is at: > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > If you ever want to unsubscribe or change your options (eg, switch to or > from digest mode, change your password, etc.), visit your subscription > page at: > > https://www.redhat.com/mailman/options/libvirt-cim/raghunp%40cisco.com > > > You can also make such adjustments via email by sending a message to: > > Libvirt-cim-request at redhat.com > > with the word `help' in the subject or body (don't include the quotes), > and you will get back a message with instructions. > > You must know your password to change your options (including changing > the password, itself) or to unsubscribe. It is: > > reddy123 > > Normally, Mailman will remind you of your redhat.com mailing list > passwords once every month, although you can disable this if you prefer. > This reminder will also include instructions on how to unsubscribe or > change your account options. There is also a button on your options > page that will email your current password to you. > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim From snmishra at linux.vnet.ibm.com Mon Jun 4 14:16:27 2012 From: snmishra at linux.vnet.ibm.com (snmishra at linux.vnet.ibm.com) Date: Mon, 04 Jun 2012 10:16:27 -0400 Subject: [Libvirt-cim] regarding creating VM using libvirt-cim In-Reply-To: References: , <20120530115120.Horde.ZJbPVJir309PxkH4P1oEFIA@imap.linux.ibm.com> Message-ID: <20120604101627.Horde.c51WYpir309PzMM70HTxmOA@imap.linux.ibm.com> Quoting "Raghunatha Reddy P (raghunp)" : > Hi Sharad, > > Thanks for the information. > > We need to use CIM-Schemas, defined by DMTF, to create and work on > VMs. Could you please share the following, > - What are all soft-wares do I need to install to start working > on this. Would be good if you can provide step step procedure for > this. It is really simple. All you need are libcmpiutil and libvirt-cim. Are you using pegasus cimom? > - What are all the hyper-visors are supported by libvirt-cim? > Deos it support ESX hypervisor? KVM, Xen and linux containers. > - Do we have any detailed documentation/ wiki for this in > addition to http://www.libvirt.org/CIM/ > > Best Regards > Raghu > ________________________________________ > From: snmishra at linux.vnet.ibm.com [snmishra at linux.vnet.ibm.com] > Sent: Wednesday, May 30, 2012 9:21 PM > To: Raghunatha Reddy P (raghunp) > Subject: Re: [Libvirt-cim] regarding creating VM using libvirt-cim > > Quoting "Raghunatha Reddy P (raghunp)" : > >> Hi All, >> I am very new to libvirt-cim. We wanted to create a VM using >> libvirt-cim using CIM schemas. Could you please detail the steps >> involved in this task, procedures, softwares to be installed and run, >> docs, wikipages, blogs..etc. > > Hi Raghu, > > Welcome to libvirt-cim. > Best way to learn how to use libvirt-cim is to create a VM using > cimtest. You can download cimtest snapshot from > http://libvirt.org/git/?p=cimtest.git;a=tree. Go to cimtest directory > and run the following command - > > CIM_NS=root/virt CIM_USER=<> CIM_PASS=<> > ./runtests libvirt-cim -i localhost -c -d -v KVM -g ComputerSystem -t > 06_paused_active_suspend.py > > Replace <> and <> with your username and > password. > > You may have some missing packages that cimtest needs. Once you have > them installed, you can follow the test to learn how VMs are created. > There are lot more tests under cimtest which do more advanced things > like adding disk/memeory/CPU to existing VM. > > Feel free to post on the mailing list if you have any more questions. > > -Sharad Mishra > IBM > >> >> Thanks in advance. >> >> >> Best Regards >> Raghu >> >> -----Original Message----- >> From: libvirt-cim-bounces at redhat.com >> [mailto:libvirt-cim-bounces at redhat.com] On Behalf Of >> libvirt-cim-request at redhat.com >> Sent: 30 May 2012 10:50 >> To: Raghunatha Reddy P (raghunp) >> Subject: Welcome to the "Libvirt-cim" mailing list >> >> Welcome to the Libvirt-cim at redhat.com mailing list! >> >> To post to this list, send your email to: >> >> libvirt-cim at redhat.com >> >> General information about the mailing list is at: >> >> https://www.redhat.com/mailman/listinfo/libvirt-cim >> >> If you ever want to unsubscribe or change your options (eg, switch to or >> from digest mode, change your password, etc.), visit your subscription >> page at: >> >> https://www.redhat.com/mailman/options/libvirt-cim/raghunp%40cisco.com >> >> >> You can also make such adjustments via email by sending a message to: >> >> Libvirt-cim-request at redhat.com >> >> with the word `help' in the subject or body (don't include the quotes), >> and you will get back a message with instructions. >> >> You must know your password to change your options (including changing >> the password, itself) or to unsubscribe. It is: >> >> reddy123 >> >> Normally, Mailman will remind you of your redhat.com mailing list >> passwords once every month, although you can disable this if you prefer. >> This reminder will also include instructions on how to unsubscribe or >> change your account options. There is also a button on your options >> page that will email your current password to you. >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim From raghunp at cisco.com Mon Jun 4 16:17:23 2012 From: raghunp at cisco.com (Raghunatha Reddy P (raghunp)) Date: Mon, 4 Jun 2012 16:17:23 +0000 Subject: [Libvirt-cim] regarding creating VM using libvirt-cim In-Reply-To: <20120604101627.Horde.c51WYpir309PzMM70HTxmOA@imap.linux.ibm.com> References: , <20120530115120.Horde.ZJbPVJir309PxkH4P1oEFIA@imap.linux.ibm.com> <20120604101627.Horde.c51WYpir309PzMM70HTxmOA@imap.linux.ibm.com> Message-ID: Yes. I have installed Pegasus, libcmpiutil and libvirt-cim. But I am not sure how to use them. Could you please share if you have any detailed doc? One line answer is not really helping me out. Best Regards Raghu -----Original Message----- From: snmishra at linux.vnet.ibm.com [mailto:snmishra at linux.vnet.ibm.com] Sent: 04 June 2012 19:46 To: Raghunatha Reddy P (raghunp) Cc: libvirt-cim at redhat.com Subject: Re: [Libvirt-cim] regarding creating VM using libvirt-cim Quoting "Raghunatha Reddy P (raghunp)" : > Hi Sharad, > > Thanks for the information. > > We need to use CIM-Schemas, defined by DMTF, to create and work on > VMs. Could you please share the following, > - What are all soft-wares do I need to install to start working on > this. Would be good if you can provide step step procedure for this. It is really simple. All you need are libcmpiutil and libvirt-cim. Are you using pegasus cimom? > - What are all the hyper-visors are supported by libvirt-cim? > Deos it support ESX hypervisor? KVM, Xen and linux containers. > - Do we have any detailed documentation/ wiki for this in addition > to http://www.libvirt.org/CIM/ > > Best Regards > Raghu > ________________________________________ > From: snmishra at linux.vnet.ibm.com [snmishra at linux.vnet.ibm.com] > Sent: Wednesday, May 30, 2012 9:21 PM > To: Raghunatha Reddy P (raghunp) > Subject: Re: [Libvirt-cim] regarding creating VM using libvirt-cim > > Quoting "Raghunatha Reddy P (raghunp)" : > >> Hi All, >> I am very new to libvirt-cim. We wanted to create a VM using >> libvirt-cim using CIM schemas. Could you please detail the steps >> involved in this task, procedures, softwares to be installed and run, >> docs, wikipages, blogs..etc. > > Hi Raghu, > > Welcome to libvirt-cim. > Best way to learn how to use libvirt-cim is to create a VM using > cimtest. You can download cimtest snapshot from > http://libvirt.org/git/?p=cimtest.git;a=tree. Go to cimtest directory > and run the following command - > > CIM_NS=root/virt CIM_USER=<> CIM_PASS=<> > ./runtests libvirt-cim -i localhost -c -d -v KVM -g ComputerSystem -t > 06_paused_active_suspend.py > > Replace <> and <> with your username and > password. > > You may have some missing packages that cimtest needs. Once you have > them installed, you can follow the test to learn how VMs are created. > There are lot more tests under cimtest which do more advanced things > like adding disk/memeory/CPU to existing VM. > > Feel free to post on the mailing list if you have any more questions. > > -Sharad Mishra > IBM > >> >> Thanks in advance. >> >> >> Best Regards >> Raghu >> >> -----Original Message----- >> From: libvirt-cim-bounces at redhat.com >> [mailto:libvirt-cim-bounces at redhat.com] On Behalf Of >> libvirt-cim-request at redhat.com >> Sent: 30 May 2012 10:50 >> To: Raghunatha Reddy P (raghunp) >> Subject: Welcome to the "Libvirt-cim" mailing list >> >> Welcome to the Libvirt-cim at redhat.com mailing list! >> >> To post to this list, send your email to: >> >> libvirt-cim at redhat.com >> >> General information about the mailing list is at: >> >> https://www.redhat.com/mailman/listinfo/libvirt-cim >> >> If you ever want to unsubscribe or change your options (eg, switch to >> or from digest mode, change your password, etc.), visit your >> subscription page at: >> >> >> https://www.redhat.com/mailman/options/libvirt-cim/raghunp%40cisco.co >> m >> >> >> You can also make such adjustments via email by sending a message to: >> >> Libvirt-cim-request at redhat.com >> >> with the word `help' in the subject or body (don't include the >> quotes), and you will get back a message with instructions. >> >> You must know your password to change your options (including >> changing the password, itself) or to unsubscribe. It is: >> >> reddy123 >> >> Normally, Mailman will remind you of your redhat.com mailing list >> passwords once every month, although you can disable this if you prefer. >> This reminder will also include instructions on how to unsubscribe or >> change your account options. There is also a button on your options >> page that will email your current password to you. >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim From snmishra at linux.vnet.ibm.com Mon Jun 4 16:41:55 2012 From: snmishra at linux.vnet.ibm.com (snmishra at linux.vnet.ibm.com) Date: Mon, 04 Jun 2012 12:41:55 -0400 Subject: [Libvirt-cim] regarding creating VM using libvirt-cim In-Reply-To: References: , <20120530115120.Horde.ZJbPVJir309PxkH4P1oEFIA@imap.linux.ibm.com> <20120604101627.Horde.c51WYpir309PzMM70HTxmOA@imap.linux.ibm.com> Message-ID: <20120604124155.Horde.R3Qsy5ir309PzOVTpcYRmPA@imap.linux.ibm.com> Quoting "Raghunatha Reddy P (raghunp)" : > Yes. I have installed Pegasus, libcmpiutil and libvirt-cim. But I am > not sure how to use them. Could you please share if you have any > detailed doc? One line answer is not really helping me out. I don't know your level of CIM expertise. Libvirt-cim is a set of CIM providers, as with any providers, you can look at the schema definitions to figure out the interface and how to use them. We don't have any more documentation. I pointed you to cimtest to give you an idea of flow of libvirt-cim. It is actually not needed. We use it as automated test. You can download the source from http://libvirt.org/git/?p=libvirt-cim.git. All schemas are defined under 'schema' directory. -Sharad > > Best Regards > Raghu > > -----Original Message----- > From: snmishra at linux.vnet.ibm.com [mailto:snmishra at linux.vnet.ibm.com] > Sent: 04 June 2012 19:46 > To: Raghunatha Reddy P (raghunp) > Cc: libvirt-cim at redhat.com > Subject: Re: [Libvirt-cim] regarding creating VM using libvirt-cim > > > Quoting "Raghunatha Reddy P (raghunp)" : > >> Hi Sharad, >> >> Thanks for the information. >> >> We need to use CIM-Schemas, defined by DMTF, to create and work on >> VMs. Could you please share the following, >> - What are all soft-wares do I need to install to start working on >> this. Would be good if you can provide step step procedure for this. > > It is really simple. All you need are libcmpiutil and libvirt-cim. > Are you using pegasus cimom? > >> - What are all the hyper-visors are supported by libvirt-cim? >> Deos it support ESX hypervisor? > > KVM, Xen and linux containers. > >> - Do we have any detailed documentation/ wiki for this in addition >> to http://www.libvirt.org/CIM/ >> >> Best Regards >> Raghu >> ________________________________________ >> From: snmishra at linux.vnet.ibm.com [snmishra at linux.vnet.ibm.com] >> Sent: Wednesday, May 30, 2012 9:21 PM >> To: Raghunatha Reddy P (raghunp) >> Subject: Re: [Libvirt-cim] regarding creating VM using libvirt-cim >> >> Quoting "Raghunatha Reddy P (raghunp)" : >> >>> Hi All, >>> I am very new to libvirt-cim. We wanted to create a VM using >>> libvirt-cim using CIM schemas. Could you please detail the steps >>> involved in this task, procedures, softwares to be installed and run, >>> docs, wikipages, blogs..etc. >> >> Hi Raghu, >> >> Welcome to libvirt-cim. >> Best way to learn how to use libvirt-cim is to create a VM using >> cimtest. You can download cimtest snapshot from >> http://libvirt.org/git/?p=cimtest.git;a=tree. Go to cimtest directory >> and run the following command - >> >> CIM_NS=root/virt CIM_USER=<> CIM_PASS=<> >> ./runtests libvirt-cim -i localhost -c -d -v KVM -g ComputerSystem -t >> 06_paused_active_suspend.py >> >> Replace <> and <> with your username and >> password. >> >> You may have some missing packages that cimtest needs. Once you have >> them installed, you can follow the test to learn how VMs are created. >> There are lot more tests under cimtest which do more advanced things >> like adding disk/memeory/CPU to existing VM. >> >> Feel free to post on the mailing list if you have any more questions. >> >> -Sharad Mishra >> IBM >> >>> >>> Thanks in advance. >>> >>> >>> Best Regards >>> Raghu >>> >>> -----Original Message----- >>> From: libvirt-cim-bounces at redhat.com >>> [mailto:libvirt-cim-bounces at redhat.com] On Behalf Of >>> libvirt-cim-request at redhat.com >>> Sent: 30 May 2012 10:50 >>> To: Raghunatha Reddy P (raghunp) >>> Subject: Welcome to the "Libvirt-cim" mailing list >>> >>> Welcome to the Libvirt-cim at redhat.com mailing list! >>> >>> To post to this list, send your email to: >>> >>> libvirt-cim at redhat.com >>> >>> General information about the mailing list is at: >>> >>> https://www.redhat.com/mailman/listinfo/libvirt-cim >>> >>> If you ever want to unsubscribe or change your options (eg, switch to >>> or from digest mode, change your password, etc.), visit your >>> subscription page at: >>> >>> >>> https://www.redhat.com/mailman/options/libvirt-cim/raghunp%40cisco.co >>> m >>> >>> >>> You can also make such adjustments via email by sending a message to: >>> >>> Libvirt-cim-request at redhat.com >>> >>> with the word `help' in the subject or body (don't include the >>> quotes), and you will get back a message with instructions. >>> >>> You must know your password to change your options (including >>> changing the password, itself) or to unsubscribe. It is: >>> >>> reddy123 >>> >>> Normally, Mailman will remind you of your redhat.com mailing list >>> passwords once every month, although you can disable this if you prefer. >>> This reminder will also include instructions on how to unsubscribe or >>> change your account options. There is also a button on your options >>> page that will email your current password to you. >>> >>> _______________________________________________ >>> Libvirt-cim mailing list >>> Libvirt-cim at redhat.com >>> https://www.redhat.com/mailman/listinfo/libvirt-cim From raghunp at cisco.com Mon Jun 18 08:16:16 2012 From: raghunp at cisco.com (Raghunatha Reddy P (raghunp)) Date: Mon, 18 Jun 2012 08:16:16 +0000 Subject: [Libvirt-cim] help needed in resolving libvirt-cim compilation errors.. Message-ID: Hi All, I am getting following error while compiling libvirt-cim using "make install". Any help is appreciated. edProfile.mof ./schema/AllocationCapabilities.mof /bin/sh /root/RAGHU/libvirt-cim/libvirt-cim-0.6.0/install-sh -c -m 644 -t "/usr/local/share/libvirt-cim" ./schema/RegisteredProfile.registration ./schema/ElementConformsToProfile.registration ./schema/ReferencedProfile.registration if [[ sfcb != pegasus ]]; then \ sed -i '/^# --/,/^# --!/d' .//usr/local/share/libvirt-cim/RegisteredProfile.registration .//usr/local/share/libvirt-cim/ElementConformsToProfile.registration .//usr/local/share/libvirt-cim/ReferencedProfile.registration; \ fi sed: can't read .//usr/local/share/libvirt-cim/RegisteredProfile.registration: No such file or directory sed: can't read .//usr/local/share/libvirt-cim/ElementConformsToProfile.registration: No such file or directory sed: can't read .//usr/local/share/libvirt-cim/ReferencedProfile.registration: No such file or directory make[2]: *** [install-data-local] Error 2 make[2]: Leaving directory `/root/RAGHU/libvirt-cim/libvirt-cim-0.6.0' make[1]: *** [install-am] Error 2 make[1]: Leaving directory `/root/RAGHU/libvirt-cim/libvirt-cim-0.6.0' make: *** [install-recursive] Error 1 [root at vmware-nexus1k-01 libvirt-cim-0.6.0]# Best Regards Raghu -------------- next part -------------- An HTML attachment was scrubbed... URL: From veillard at redhat.com Mon Jun 18 12:10:14 2012 From: veillard at redhat.com (Daniel Veillard) Date: Mon, 18 Jun 2012 20:10:14 +0800 Subject: [Libvirt-cim] help needed in resolving libvirt-cim compilation errors.. In-Reply-To: References: Message-ID: <20120618121014.GC2661@redhat.com> On Mon, Jun 18, 2012 at 08:16:16AM +0000, Raghunatha Reddy P (raghunp) wrote: > Hi All, > > > > I am getting following error while compiling libvirt-cim using "make install". Any help is appreciated. > > > > edProfile.mof ./schema/AllocationCapabilities.mof > > /bin/sh /root/RAGHU/libvirt-cim/libvirt-cim-0.6.0/install-sh -c -m 644 -t "/usr/local/share/libvirt-cim" ./schema/RegisteredProfile.registration ./schema/ElementConformsToProfile.registration ./schema/ReferencedProfile.registration > > if [[ sfcb != pegasus ]]; then \ > > sed -i '/^# --/,/^# --!/d' .//usr/local/share/libvirt-cim/RegisteredProfile.registration .//usr/local/share/libvirt-cim/ElementConformsToProfile.registration .//usr/local/share/libvirt-cim/ReferencedProfile.registration; \ > > fi > > sed: can't read .//usr/local/share/libvirt-cim/RegisteredProfile.registration: No such file or directory > > sed: can't read .//usr/local/share/libvirt-cim/ElementConformsToProfile.registration: No such file or directory > > sed: can't read .//usr/local/share/libvirt-cim/ReferencedProfile.registration: No such file or directory > > make[2]: *** [install-data-local] Error 2 > > make[2]: Leaving directory `/root/RAGHU/libvirt-cim/libvirt-cim-0.6.0' > > make[1]: *** [install-am] Error 2 > > make[1]: Leaving directory `/root/RAGHU/libvirt-cim/libvirt-cim-0.6.0' > > make: *** [install-recursive] Error 1 > > [root at vmware-nexus1k-01 libvirt-cim-0.6.0]# I think that's a bug when you rebuild with sblim-fscb installed we have a patch that need to be applied and pushed in a release: https://www.redhat.com/archives/libvirt-cim/2012-March/msg00014.html Could you try to apply it and see if fixes it for you and report ? 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 raghunp at cisco.com Tue Jun 19 08:16:41 2012 From: raghunp at cisco.com (Raghunatha Reddy P (raghunp)) Date: Tue, 19 Jun 2012 08:16:41 +0000 Subject: [Libvirt-cim] 2nd try : help needed in resolving libvirt-cim compilation errors.. Message-ID: Any help on this is appreciated. Best Regards Raghu From: Raghunatha Reddy P (raghunp) Sent: 18 June 2012 13:47 To: 'snmishra at linux.vnet.ibm.com'; libvirt-cim at redhat.com Subject: help needed in resolving libvirt-cim compilation errors.. Hi All, I am getting following error while compiling libvirt-cim using "make install". Any help is appreciated. edProfile.mof ./schema/AllocationCapabilities.mof /bin/sh /root/RAGHU/libvirt-cim/libvirt-cim-0.6.0/install-sh -c -m 644 -t "/usr/local/share/libvirt-cim" ./schema/RegisteredProfile.registration ./schema/ElementConformsToProfile.registration ./schema/ReferencedProfile.registration if [[ sfcb != pegasus ]]; then \ sed -i '/^# --/,/^# --!/d' .//usr/local/share/libvirt-cim/RegisteredProfile.registration .//usr/local/share/libvirt-cim/ElementConformsToProfile.registration .//usr/local/share/libvirt-cim/ReferencedProfile.registration; \ fi sed: can't read .//usr/local/share/libvirt-cim/RegisteredProfile.registration: No such file or directory sed: can't read .//usr/local/share/libvirt-cim/ElementConformsToProfile.registration: No such file or directory sed: can't read .//usr/local/share/libvirt-cim/ReferencedProfile.registration: No such file or directory make[2]: *** [install-data-local] Error 2 make[2]: Leaving directory `/root/RAGHU/libvirt-cim/libvirt-cim-0.6.0' make[1]: *** [install-am] Error 2 make[1]: Leaving directory `/root/RAGHU/libvirt-cim/libvirt-cim-0.6.0' make: *** [install-recursive] Error 1 [root at vmware-nexus1k-01 libvirt-cim-0.6.0]# Best Regards Raghu -------------- next part -------------- An HTML attachment was scrubbed... URL: From veillard at redhat.com Tue Jun 19 08:34:28 2012 From: veillard at redhat.com (Daniel Veillard) Date: Tue, 19 Jun 2012 16:34:28 +0800 Subject: [Libvirt-cim] 2nd try : help needed in resolving libvirt-cim compilation errors.. In-Reply-To: References: Message-ID: <20120619083427.GU2661@redhat.com> On Tue, Jun 19, 2012 at 08:16:41AM +0000, Raghunatha Reddy P (raghunp) wrote: > Any help on this is appreciated. I replied to your mail from yesterday ! https://www.redhat.com/archives/libvirt-cim/2012-June/msg00005.html But you didn't reply to my question ... the problem is on your end at this point ! 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 raghunp at cisco.com Tue Jun 19 10:14:04 2012 From: raghunp at cisco.com (Raghunatha Reddy P (raghunp)) Date: Tue, 19 Jun 2012 10:14:04 +0000 Subject: [Libvirt-cim] 2nd try : help needed in resolving libvirt-cim compilation errors.. In-Reply-To: <20120619083427.GU2661@redhat.com> References: <20120619083427.GU2661@redhat.com> Message-ID: Hi Daniel, I am very sorry for missing your reply. It worked fine me. 'make install' went fine. After make install, I ran 'make postinstall' which throwed an error, Registering class KVM_HostedFilterList Staging provider registration. provider-register.sh: line 505: sfcbstage: command not found Failed to stage provider registration. make: *** [postinstall] Error 1 [root at vmware-nexus1k-01 libvirt-cim-0.6.0]# Could you please tell how to fix this? Best Regards Raghu -----Original Message----- From: Daniel Veillard [mailto:veillard at redhat.com] Sent: 19 June 2012 14:04 To: Raghunatha Reddy P (raghunp) Cc: List for discussion and development of libvirt CIM Subject: Re: [Libvirt-cim] 2nd try : help needed in resolving libvirt-cim compilation errors.. On Tue, Jun 19, 2012 at 08:16:41AM +0000, Raghunatha Reddy P (raghunp) wrote: > Any help on this is appreciated. I replied to your mail from yesterday ! https://www.redhat.com/archives/libvirt-cim/2012-June/msg00005.html But you didn't reply to my question ... the problem is on your end at this point ! 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 eblima at linux.vnet.ibm.com Tue Jun 19 15:35:40 2012 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Tue, 19 Jun 2012 12:35:40 -0300 Subject: [Libvirt-cim] [PATCH 3/3] Make pool device paths use linked list implementation In-Reply-To: <1340120140-31321-1-git-send-email-eblima@linux.vnet.ibm.com> References: <1340120140-31321-1-git-send-email-eblima@linux.vnet.ibm.com> Message-ID: <1340120140-31321-4-git-send-email-eblima@linux.vnet.ibm.com> From: "Eduardo Lima (Etrunko)" Signed-off-by: Eduardo Lima (Etrunko) --- libxkutil/pool_parsing.c | 27 ++++++------------------- libxkutil/pool_parsing.h | 4 ++-- libxkutil/xmlgen.c | 29 +++++++++++++++++---------- src/Virt_ResourcePoolConfigurationService.c | 28 +++++++++----------------- 4 files changed, 35 insertions(+), 53 deletions(-) diff --git a/libxkutil/pool_parsing.c b/libxkutil/pool_parsing.c index e41fc09..bb616d4 100644 --- a/libxkutil/pool_parsing.c +++ b/libxkutil/pool_parsing.c @@ -54,8 +54,6 @@ static void cleanup_net_pool(struct net_pool pool) { } static void cleanup_disk_pool(struct disk_pool pool) { - uint16_t i; - free(pool.path); free(pool.host); free(pool.src_dir); @@ -63,10 +61,7 @@ static void cleanup_disk_pool(struct disk_pool pool) { free(pool.port_name); free(pool.node_name); - for (i = 0; i < pool.device_paths_ct; i++) - free(pool.device_paths[i]); - - free(pool.device_paths); + list_free(pool.device_paths); } void cleanup_virt_pool(struct virt_pool **pool) @@ -130,22 +125,15 @@ static int parse_disk_target(xmlNode *node, struct disk_pool *pool) static int parse_disk_source(xmlNode *node, struct disk_pool *pool) { xmlNode *child; - char **dev_paths = NULL; - unsigned ct = 0; for (child = node->children; child != NULL; child = child->next) { if (XSTREQ(child->name, "device")) { - char **tmp = NULL; - - tmp = realloc(dev_paths, sizeof(char *) * (ct + 1)); - if (tmp == NULL) { - CU_DEBUG("Could not alloc space for dev path"); - continue; - } - dev_paths = tmp; + if (pool->device_paths == NULL) + pool->device_paths = list_new(free, + (list_data_cmp_cb) strcmp); - dev_paths[ct] = get_attr_value(child, "path"); - ct++; + list_append(pool->device_paths, + get_attr_value(child, "path")); } else if (XSTREQ(child->name, "host")) { pool->host = get_attr_value(child, "name"); if (pool->host == NULL) @@ -161,12 +149,9 @@ static int parse_disk_source(xmlNode *node, struct disk_pool *pool) } } - pool->device_paths_ct = ct; - pool->device_paths = dev_paths; return 1; err: - free(dev_paths); return 0; } diff --git a/libxkutil/pool_parsing.h b/libxkutil/pool_parsing.h index 9f1a386..50fbeac 100644 --- a/libxkutil/pool_parsing.h +++ b/libxkutil/pool_parsing.h @@ -26,6 +26,7 @@ #include #include "../src/svpc_types.h" +#include "list_util.h" struct net_pool { char *addr; @@ -46,8 +47,7 @@ struct disk_pool { DISK_POOL_LOGICAL, DISK_POOL_SCSI} pool_type; char *path; - char **device_paths; - uint16_t device_paths_ct; + list_t *device_paths; char *host; char *src_dir; char *adapter; diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 2dcd0d2..26e7203 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -1177,27 +1177,34 @@ static const char *disk_pool_type_to_str(uint16_t type) return NULL; } +static bool device_paths_foreach(void *list_data, void *user_data) +{ + char *dev_path = (char *) list_data; + xmlNodePtr src = (xmlNodePtr) user_data; + xmlNodePtr tmp = NULL; + + tmp = xmlNewChild(src, NULL, BAD_CAST "device", BAD_CAST NULL); + if (tmp == NULL) + return false; + + if (xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev_path) == NULL) + return false; + + return true; +} + static const char *set_disk_pool_source(xmlNodePtr disk, struct disk_pool *pool) { xmlNodePtr src; xmlNodePtr tmp; - uint16_t i; src = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); if (src == NULL) return XML_ERROR; - for (i = 0; i < pool->device_paths_ct; i++) { - tmp = xmlNewChild(src, NULL, BAD_CAST "device", BAD_CAST NULL); - if (tmp == NULL) - return XML_ERROR; - - if (xmlNewProp(tmp, - BAD_CAST "path", - BAD_CAST pool->device_paths[i]) == NULL) - return XML_ERROR; - } + if (!list_foreach(pool->device_paths, device_paths_foreach, src)) + return XML_ERROR; if (pool->host != NULL) { tmp = xmlNewChild(src, NULL, BAD_CAST "host", BAD_CAST NULL); diff --git a/src/Virt_ResourcePoolConfigurationService.c b/src/Virt_ResourcePoolConfigurationService.c index 751d016..bc3e431 100644 --- a/src/Virt_ResourcePoolConfigurationService.c +++ b/src/Virt_ResourcePoolConfigurationService.c @@ -143,7 +143,6 @@ static const char *net_rasd_to_pool(CMPIInstance *inst, static void init_disk_pool(struct virt_pool *pool) { pool->pool_info.disk.device_paths = NULL; - pool->pool_info.disk.device_paths_ct = 0; pool->pool_info.disk.path = NULL; pool->pool_info.disk.host = NULL; pool->pool_info.disk.src_dir = NULL; @@ -153,9 +152,8 @@ static void init_disk_pool(struct virt_pool *pool) pool->pool_info.disk.autostart = 0; } -static char *get_dev_paths(CMPIInstance *inst, - char ***path_list, - uint16_t *count) + +static char *get_dev_paths(CMPIInstance *inst, list_t **path_list) { CMPICount i; CMPICount ct; @@ -170,11 +168,8 @@ static char *get_dev_paths(CMPIInstance *inst, if ((s.rc != CMPI_RC_OK) || (ct <= 0)) return "Unable to get DevicePaths array count"; - *path_list = calloc(ct, sizeof(char *)); if (*path_list == NULL) - return "Failed to alloc space for device paths"; - - *count = ct; + *path_list = list_new(free, (list_data_cmp_cb) strcmp); for (i = 0; i < ct; i++) { const char *str = NULL; @@ -187,7 +182,7 @@ static char *get_dev_paths(CMPIInstance *inst, if (str == NULL) return "Unable to get value of DevicePaths element"; - *path_list[i] = strdup(str); + list_append(*path_list, strdup(str)); } return NULL; @@ -198,10 +193,7 @@ static const char *disk_fs_or_disk_or_logical_pool(CMPIInstance *inst, { const char *msg = NULL; - msg = get_dev_paths(inst, - &pool->pool_info.disk.device_paths, - &pool->pool_info.disk.device_paths_ct); - + msg = get_dev_paths(inst, &pool->pool_info.disk.device_paths); /* Specifying a value for DevicePaths isn't mandatory for logical pool types. */ @@ -209,7 +201,7 @@ static const char *disk_fs_or_disk_or_logical_pool(CMPIInstance *inst, if (msg != NULL) return msg; - if (pool->pool_info.disk.device_paths_ct != 1) { + if (list_count(pool->pool_info.disk.device_paths) != 1) { CU_DEBUG("%d only takes one device path", pool->pool_info.disk.pool_type); return "Specified pool type only takes one device path"; @@ -243,14 +235,12 @@ static const char *disk_iscsi_pool(CMPIInstance *inst, const char *val = NULL; const char *msg = NULL; - msg = get_dev_paths(inst, - &pool->pool_info.disk.device_paths, - &pool->pool_info.disk.device_paths_ct); - + msg = get_dev_paths(inst, &pool->pool_info.disk.device_paths); + if (msg != NULL) return msg; - if (pool->pool_info.disk.device_paths_ct != 1) + if (list_count(pool->pool_info.disk.device_paths) != 1) return "Specified pool type only takes one device path"; if (cu_get_str_prop(inst, "Host", &val) != CMPI_RC_OK) -- 1.7.10.4 From eblima at linux.vnet.ibm.com Tue Jun 19 15:35:39 2012 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Tue, 19 Jun 2012 12:35:39 -0300 Subject: [Libvirt-cim] [PATCH 2/3] ACL: Port filter rules to use list implementation In-Reply-To: <1340120140-31321-1-git-send-email-eblima@linux.vnet.ibm.com> References: <1340120140-31321-1-git-send-email-eblima@linux.vnet.ibm.com> Message-ID: <1340120140-31321-3-git-send-email-eblima@linux.vnet.ibm.com> From: "Eduardo Lima (Etrunko)" Signed-off-by: Eduardo Lima (Etrunko) --- libxkutil/acl_parsing.c | 71 +++++++++------------------------------- libxkutil/acl_parsing.h | 5 +-- src/Virt_EntriesInFilterList.c | 49 ++++++++++++++------------- src/Virt_FilterEntry.c | 35 +++++++------------- src/Virt_NestedFilterList.c | 3 -- 5 files changed, 56 insertions(+), 107 deletions(-) diff --git a/libxkutil/acl_parsing.c b/libxkutil/acl_parsing.c index 41ab319..8156854 100644 --- a/libxkutil/acl_parsing.c +++ b/libxkutil/acl_parsing.c @@ -126,8 +126,6 @@ void cleanup_rule(struct acl_rule *rule) void cleanup_filter(struct acl_filter *filter) { - int i; - if(filter == NULL) return; @@ -136,12 +134,7 @@ void cleanup_filter(struct acl_filter *filter) free(filter->chain); free(filter->priority); - for (i = 0; i < filter->rule_ct; i++) - cleanup_rule(filter->rules[i]); - - free(filter->rules); - filter->rule_ct = 0; - + list_free(filter->rules); list_free(filter->refs); } @@ -574,53 +567,39 @@ int delete_filter(virConnectPtr conn, struct acl_filter *filter) #endif } -int append_filter_rule(struct acl_filter *filter, struct acl_rule *rule) +static int filter_rule_cmp(void *list_data, void *user_data) { - struct acl_rule **old_rules = NULL; + struct acl_rule * rule = (struct acl_rule *) list_data; + const char * name = (const char *) user_data; - if ((filter == NULL) || (rule == NULL)) - return 0; + return strcmp(rule->name, name); +} - rule->name = make_rule_id(filter->name, filter->rule_ct); - if (rule->name == NULL) +int append_filter_rule(struct acl_filter *filter, struct acl_rule *rule) +{ + if ((filter == NULL) || (rule == NULL)) return 0; - old_rules = filter->rules; + if (filter->rules == NULL) + filter->rules = list_new((list_data_free_cb) cleanup_rule, + filter_rule_cmp); - 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; + rule->name = make_rule_id(filter->name, list_count(filter->rules)); + if (rule->name == NULL) return 0; - } - - memcpy(filter->rules, - old_rules, - filter->rule_ct * sizeof(struct acl_rule *)); - filter->rules[filter->rule_ct] = rule; - filter->rule_ct++; - - free(old_rules); + list_append(filter->rules, rule); return 1; } - -static int filter_ref_cmp(void *list_data, void *user_data) -{ - return strcmp((const char *)list_data, (const char *) user_data); -} - int append_filter_ref(struct acl_filter *filter, char *name) { if (filter == NULL || name == NULL) return 0; if (filter->refs == NULL) - filter->refs = list_new(free, filter_ref_cmp); + filter->refs = list_new(free, (list_data_cmp_cb) strcmp); if (list_find(filter->refs, name) != NULL) { free(name); @@ -659,24 +638,6 @@ char *make_rule_id(const char *filter, int index) return rule_id; } - -int parse_rule_id(const char *rule_id, char **filter, int *index) -{ - int ret; - - if ((filter == NULL) || (index == NULL)) - return 0; - ret = sscanf(rule_id, "%as[^:]:%u", filter, index); - if (ret != 2) { - free(*filter); - *filter = NULL; - - return 0; - } - - return 1; -} - /* * Local Variables: * mode: C diff --git a/libxkutil/acl_parsing.h b/libxkutil/acl_parsing.h index a0e2f9a..4dca43f 100644 --- a/libxkutil/acl_parsing.h +++ b/libxkutil/acl_parsing.h @@ -152,9 +152,7 @@ struct acl_filter { char *chain; char *priority; - struct acl_rule **rules; - int rule_ct; - + list_t *rules; list_t *refs; }; @@ -171,7 +169,6 @@ int get_filter_by_name(virConnectPtr conn, const char *name, struct acl_filter **filter); char *make_rule_id(const char *filter, int index); -int parse_rule_id(const char *rule_id, char **filter, int *index); int create_filter(virConnectPtr conn, struct acl_filter *filter); int update_filter(virConnectPtr conn, struct acl_filter *filter); diff --git a/src/Virt_EntriesInFilterList.c b/src/Virt_EntriesInFilterList.c index 2c8ac47..ccaa751 100644 --- a/src/Virt_EntriesInFilterList.c +++ b/src/Virt_EntriesInFilterList.c @@ -45,9 +45,10 @@ static CMPIStatus list_to_rule( CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *instance = NULL; struct acl_filter *filter = NULL; + struct acl_rule *rule = NULL; const char *name = NULL; virConnectPtr conn = NULL; - int i; + list_node_t *head, *node; CU_DEBUG("Reference = %s", REF2STR(reference)); @@ -68,21 +69,29 @@ static CMPIStatus list_to_rule( goto out; } - for (i = 0; i < filter->rule_ct; i++) { - CU_DEBUG("Processing %s", filter->rules[i]->name); + head = node = list_first_node(filter->rules); + if (head == NULL) + goto end; + + do { + rule = list_node_data_get(node); + CU_DEBUG("Processing %s", rule->name); s = instance_from_rule(_BROKER, info->context, reference, - filter->rules[i], + rule, &instance); if (instance != NULL) { inst_list_add(list, instance); instance = NULL; } - } + node = list_node_next_node(node); + } while (node != head); + + end: cleanup_filters(&filter, 1); out: @@ -104,8 +113,7 @@ static CMPIStatus rule_to_list( CMPIInstance *instance = NULL; const char *name = NULL; virConnectPtr conn = NULL; - int count = 0; - int i, j = 0; + int i, count = 0; CU_DEBUG("Reference = %s", REF2STR(reference)); @@ -126,21 +134,18 @@ static CMPIStatus rule_to_list( /* return the filter that contains the rule */ for (i = 0; i < count; i++) { - for (j = 0; j < filters[i].rule_ct; j++) { - if (STREQC(name, filters[i].rules[j]->name)) { - CU_DEBUG("Processing %s,",filters[i].name); - - s = instance_from_filter(_BROKER, - info->context, - reference, - &filters[i], - &instance); - - if (instance != NULL) { - inst_list_add(list, instance); - instance = NULL; - } - + if (list_find(filters[i].rules, (void *) name) != NULL) { + CU_DEBUG("Processing %s,",filters[i].name); + + s = instance_from_filter(_BROKER, + info->context, + reference, + &filters[i], + &instance); + + if (instance != NULL) { + inst_list_add(list, instance); + instance = NULL; } } } diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c index 126615b..70f8142 100644 --- a/src/Virt_FilterEntry.c +++ b/src/Virt_FilterEntry.c @@ -596,8 +596,10 @@ CMPIStatus enum_filter_rules( { virConnectPtr conn = NULL; struct acl_filter *filters = NULL; - int i, j, count = 0; + int i, count = 0; CMPIStatus s = {CMPI_RC_OK, NULL}; + list_node_t *head, *node; + CU_DEBUG("Reference = %s", REF2STR(reference)); @@ -618,11 +620,14 @@ CMPIStatus enum_filter_rules( count = get_filters(conn, &filters); for (i = 0; i < count; i++) { - for (j = 0; j < filters[i].rule_ct; j++) { - CMPIInstance *instance = NULL; + CMPIInstance *instance = NULL; + head = node = list_first_node(filters[i].rules); + if (head == NULL) + continue; + do { instance = convert_rule_to_instance( - filters[i].rules[j], + list_node_data_get(node), broker, context, reference, @@ -630,8 +635,9 @@ CMPIStatus enum_filter_rules( if (instance != NULL) inst_list_add(list, instance); - } + node = list_node_next_node(node); + } while (node != head); } out: @@ -652,9 +658,7 @@ CMPIStatus get_rule_by_ref( struct acl_rule *rule = NULL; const char *name = NULL; char *filter_name = NULL; - int rule_index; virConnectPtr conn = NULL; - int i; CU_DEBUG("Reference = %s", REF2STR(reference)); @@ -665,15 +669,6 @@ CMPIStatus get_rule_by_ref( goto out; } - if (parse_rule_id(name, &filter_name, &rule_index) == 0) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "Could not parse filter name"); - goto out; - } - - CU_DEBUG("Filter name = %s, rule index = %u", filter_name, rule_index); - conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); if (conn == NULL) goto out; @@ -686,13 +681,7 @@ CMPIStatus get_rule_by_ref( goto out; } - for (i = 0; i < filter->rule_ct; i++) { - if (rule_index == i) { - rule = filter->rules[i]; - break; - } - } - + rule = list_find(filter->rules, (void *) name); if (rule == NULL) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_NOT_FOUND, diff --git a/src/Virt_NestedFilterList.c b/src/Virt_NestedFilterList.c index a8565d6..3e9fcc3 100644 --- a/src/Virt_NestedFilterList.c +++ b/src/Virt_NestedFilterList.c @@ -141,9 +141,6 @@ static CMPIStatus parent_to_child( goto out; /* Walk refs list */ - if (parent_filter->refs == NULL) - goto end; - head = node = list_first_node(parent_filter->refs); if (head == NULL) goto end; -- 1.7.10.4 From eblima at linux.vnet.ibm.com Tue Jun 19 15:35:38 2012 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Tue, 19 Jun 2012 12:35:38 -0300 Subject: [Libvirt-cim] [PATCH 1/3] list_util: Fix possible memory leak In-Reply-To: <1340120140-31321-1-git-send-email-eblima@linux.vnet.ibm.com> References: <1340120140-31321-1-git-send-email-eblima@linux.vnet.ibm.com> Message-ID: <1340120140-31321-2-git-send-email-eblima@linux.vnet.ibm.com> From: "Eduardo Lima (Etrunko)" The list pointer was leaking in the case where the list was empty. Signed-off-by: Eduardo Lima (Etrunko) --- libxkutil/list_util.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libxkutil/list_util.c b/libxkutil/list_util.c index 84b2ba0..cab0287 100644 --- a/libxkutil/list_util.c +++ b/libxkutil/list_util.c @@ -54,9 +54,12 @@ void list_free(list_t *list) { list_node_t *n, *next; - if (list == NULL || list->head == NULL) + if (list == NULL) return; + if (list->head == NULL) + goto end; + n = list->head; do { @@ -68,6 +71,7 @@ void list_free(list_t *list) n = next; } while (n != list->head); + end: free(list); } -- 1.7.10.4 From eblima at linux.vnet.ibm.com Tue Jun 19 15:35:37 2012 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Tue, 19 Jun 2012 12:35:37 -0300 Subject: [Libvirt-cim] [PATCH 0/3] Port libxkutil helpers to make use of list implementation Message-ID: <1340120140-31321-1-git-send-email-eblima@linux.vnet.ibm.com> From: "Eduardo Lima (Etrunko)" This series include a fix to the list code which was leaking the list pointer in the case where it was empty. Also ports the acl and pool libxkutil helpers to make use of the list implementation. Resulting in much cleaner and smaller code. Eduardo Lima (Etrunko) (3): list_util: Fix possible memory leak ACL: Port filter rules to use list implementation Make pool device paths use linked list implementation libxkutil/acl_parsing.c | 71 ++++++--------------------- libxkutil/acl_parsing.h | 5 +- libxkutil/list_util.c | 6 ++- libxkutil/pool_parsing.c | 27 +++------- libxkutil/pool_parsing.h | 4 +- libxkutil/xmlgen.c | 29 ++++++----- src/Virt_EntriesInFilterList.c | 49 +++++++++--------- src/Virt_FilterEntry.c | 35 +++++-------- src/Virt_NestedFilterList.c | 3 -- src/Virt_ResourcePoolConfigurationService.c | 28 ++++------- 10 files changed, 96 insertions(+), 161 deletions(-) -- 1.7.10.4 From veillard at redhat.com Wed Jun 20 06:32:44 2012 From: veillard at redhat.com (Daniel Veillard) Date: Wed, 20 Jun 2012 14:32:44 +0800 Subject: [Libvirt-cim] [PATCH 1/3] list_util: Fix possible memory leak In-Reply-To: <1340120140-31321-2-git-send-email-eblima@linux.vnet.ibm.com> References: <1340120140-31321-1-git-send-email-eblima@linux.vnet.ibm.com> <1340120140-31321-2-git-send-email-eblima@linux.vnet.ibm.com> Message-ID: <20120620063244.GA2635@redhat.com> On Tue, Jun 19, 2012 at 12:35:38PM -0300, Eduardo Lima (Etrunko) wrote: > From: "Eduardo Lima (Etrunko)" > > The list pointer was leaking in the case where the list was empty. > > Signed-off-by: Eduardo Lima (Etrunko) > --- > libxkutil/list_util.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/libxkutil/list_util.c b/libxkutil/list_util.c > index 84b2ba0..cab0287 100644 > --- a/libxkutil/list_util.c > +++ b/libxkutil/list_util.c > @@ -54,9 +54,12 @@ void list_free(list_t *list) > { > list_node_t *n, *next; > > - if (list == NULL || list->head == NULL) > + if (list == NULL) > return; > > + if (list->head == NULL) > + goto end; > + > n = list->head; > > do { > @@ -68,6 +71,7 @@ void list_free(list_t *list) > n = next; > } while (n != list->head); > > + end: > free(list); > } Patch looks reasonable based on the description, ACK 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 veillard at redhat.com Wed Jun 20 07:08:42 2012 From: veillard at redhat.com (Daniel Veillard) Date: Wed, 20 Jun 2012 15:08:42 +0800 Subject: [Libvirt-cim] [PATCH 2/3] ACL: Port filter rules to use list implementation In-Reply-To: <1340120140-31321-3-git-send-email-eblima@linux.vnet.ibm.com> References: <1340120140-31321-1-git-send-email-eblima@linux.vnet.ibm.com> <1340120140-31321-3-git-send-email-eblima@linux.vnet.ibm.com> Message-ID: <20120620070842.GB2635@redhat.com> On Tue, Jun 19, 2012 at 12:35:39PM -0300, Eduardo Lima (Etrunko) wrote: > From: "Eduardo Lima (Etrunko)" > > Signed-off-by: Eduardo Lima (Etrunko) > --- > libxkutil/acl_parsing.c | 71 +++++++++------------------------------- > libxkutil/acl_parsing.h | 5 +-- > src/Virt_EntriesInFilterList.c | 49 ++++++++++++++------------- > src/Virt_FilterEntry.c | 35 +++++++------------- > src/Virt_NestedFilterList.c | 3 -- > 5 files changed, 56 insertions(+), 107 deletions(-) > > diff --git a/libxkutil/acl_parsing.c b/libxkutil/acl_parsing.c > index 41ab319..8156854 100644 > --- a/libxkutil/acl_parsing.c > +++ b/libxkutil/acl_parsing.c > @@ -126,8 +126,6 @@ void cleanup_rule(struct acl_rule *rule) > > void cleanup_filter(struct acl_filter *filter) > { > - int i; > - > if(filter == NULL) > return; > > @@ -136,12 +134,7 @@ void cleanup_filter(struct acl_filter *filter) > free(filter->chain); > free(filter->priority); > > - for (i = 0; i < filter->rule_ct; i++) > - cleanup_rule(filter->rules[i]); > - > - free(filter->rules); > - filter->rule_ct = 0; > - > + list_free(filter->rules); > list_free(filter->refs); > } > > @@ -574,53 +567,39 @@ int delete_filter(virConnectPtr conn, struct acl_filter *filter) > #endif > } > > -int append_filter_rule(struct acl_filter *filter, struct acl_rule *rule) > +static int filter_rule_cmp(void *list_data, void *user_data) > { > - struct acl_rule **old_rules = NULL; > + struct acl_rule * rule = (struct acl_rule *) list_data; > + const char * name = (const char *) user_data; > > - if ((filter == NULL) || (rule == NULL)) > - return 0; > + return strcmp(rule->name, name); > +} > > - rule->name = make_rule_id(filter->name, filter->rule_ct); > - if (rule->name == NULL) > +int append_filter_rule(struct acl_filter *filter, struct acl_rule *rule) > +{ > + if ((filter == NULL) || (rule == NULL)) > return 0; > > - old_rules = filter->rules; > + if (filter->rules == NULL) > + filter->rules = list_new((list_data_free_cb) cleanup_rule, > + filter_rule_cmp); > > - 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; > + rule->name = make_rule_id(filter->name, list_count(filter->rules)); > + if (rule->name == NULL) > return 0; > - } > - > - memcpy(filter->rules, > - old_rules, > - filter->rule_ct * sizeof(struct acl_rule *)); > > - filter->rules[filter->rule_ct] = rule; > - filter->rule_ct++; > - > - free(old_rules); > + list_append(filter->rules, rule); > > return 1; > } > > - > -static int filter_ref_cmp(void *list_data, void *user_data) > -{ > - return strcmp((const char *)list_data, (const char *) user_data); > -} > - > int append_filter_ref(struct acl_filter *filter, char *name) > { > if (filter == NULL || name == NULL) > return 0; > > if (filter->refs == NULL) > - filter->refs = list_new(free, filter_ref_cmp); > + filter->refs = list_new(free, (list_data_cmp_cb) strcmp); > > if (list_find(filter->refs, name) != NULL) { > free(name); > @@ -659,24 +638,6 @@ char *make_rule_id(const char *filter, int index) > > return rule_id; > } > - > -int parse_rule_id(const char *rule_id, char **filter, int *index) > -{ > - int ret; > - > - if ((filter == NULL) || (index == NULL)) > - return 0; > - ret = sscanf(rule_id, "%as[^:]:%u", filter, index); > - if (ret != 2) { > - free(*filter); > - *filter = NULL; > - > - return 0; > - } > - > - return 1; > -} > - > /* > * Local Variables: > * mode: C > diff --git a/libxkutil/acl_parsing.h b/libxkutil/acl_parsing.h > index a0e2f9a..4dca43f 100644 > --- a/libxkutil/acl_parsing.h > +++ b/libxkutil/acl_parsing.h > @@ -152,9 +152,7 @@ struct acl_filter { > char *chain; > char *priority; > > - struct acl_rule **rules; > - int rule_ct; > - > + list_t *rules; > list_t *refs; > }; > > @@ -171,7 +169,6 @@ int get_filter_by_name(virConnectPtr conn, const char *name, > struct acl_filter **filter); > > char *make_rule_id(const char *filter, int index); > -int parse_rule_id(const char *rule_id, char **filter, int *index); > > int create_filter(virConnectPtr conn, struct acl_filter *filter); > int update_filter(virConnectPtr conn, struct acl_filter *filter); > diff --git a/src/Virt_EntriesInFilterList.c b/src/Virt_EntriesInFilterList.c > index 2c8ac47..ccaa751 100644 > --- a/src/Virt_EntriesInFilterList.c > +++ b/src/Virt_EntriesInFilterList.c > @@ -45,9 +45,10 @@ static CMPIStatus list_to_rule( > CMPIStatus s = {CMPI_RC_OK, NULL}; > CMPIInstance *instance = NULL; > struct acl_filter *filter = NULL; > + struct acl_rule *rule = NULL; > const char *name = NULL; > virConnectPtr conn = NULL; > - int i; > + list_node_t *head, *node; > > CU_DEBUG("Reference = %s", REF2STR(reference)); > > @@ -68,21 +69,29 @@ static CMPIStatus list_to_rule( > goto out; > } > > - for (i = 0; i < filter->rule_ct; i++) { > - CU_DEBUG("Processing %s", filter->rules[i]->name); > + head = node = list_first_node(filter->rules); > + if (head == NULL) > + goto end; > + > + do { > + rule = list_node_data_get(node); > + CU_DEBUG("Processing %s", rule->name); > > s = instance_from_rule(_BROKER, > info->context, > reference, > - filter->rules[i], > + rule, > &instance); > > if (instance != NULL) { > inst_list_add(list, instance); > instance = NULL; > } > - } > > + node = list_node_next_node(node); > + } while (node != head); > + > + end: > cleanup_filters(&filter, 1); > > out: > @@ -104,8 +113,7 @@ static CMPIStatus rule_to_list( > CMPIInstance *instance = NULL; > const char *name = NULL; > virConnectPtr conn = NULL; > - int count = 0; > - int i, j = 0; > + int i, count = 0; > > CU_DEBUG("Reference = %s", REF2STR(reference)); > > @@ -126,21 +134,18 @@ static CMPIStatus rule_to_list( > > /* return the filter that contains the rule */ > for (i = 0; i < count; i++) { > - for (j = 0; j < filters[i].rule_ct; j++) { > - if (STREQC(name, filters[i].rules[j]->name)) { > - CU_DEBUG("Processing %s,",filters[i].name); > - > - s = instance_from_filter(_BROKER, > - info->context, > - reference, > - &filters[i], > - &instance); > - > - if (instance != NULL) { > - inst_list_add(list, instance); > - instance = NULL; > - } > - > + if (list_find(filters[i].rules, (void *) name) != NULL) { > + CU_DEBUG("Processing %s,",filters[i].name); > + > + s = instance_from_filter(_BROKER, > + info->context, > + reference, > + &filters[i], > + &instance); > + > + if (instance != NULL) { > + inst_list_add(list, instance); > + instance = NULL; > } > } > } > diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c > index 126615b..70f8142 100644 > --- a/src/Virt_FilterEntry.c > +++ b/src/Virt_FilterEntry.c > @@ -596,8 +596,10 @@ CMPIStatus enum_filter_rules( > { > virConnectPtr conn = NULL; > struct acl_filter *filters = NULL; > - int i, j, count = 0; > + int i, count = 0; > CMPIStatus s = {CMPI_RC_OK, NULL}; > + list_node_t *head, *node; > + > > CU_DEBUG("Reference = %s", REF2STR(reference)); > > @@ -618,11 +620,14 @@ CMPIStatus enum_filter_rules( > count = get_filters(conn, &filters); > > for (i = 0; i < count; i++) { > - for (j = 0; j < filters[i].rule_ct; j++) { > - CMPIInstance *instance = NULL; > + CMPIInstance *instance = NULL; > + head = node = list_first_node(filters[i].rules); > + if (head == NULL) > + continue; > > + do { > instance = convert_rule_to_instance( > - filters[i].rules[j], > + list_node_data_get(node), > broker, > context, > reference, > @@ -630,8 +635,9 @@ CMPIStatus enum_filter_rules( > > if (instance != NULL) > inst_list_add(list, instance); > - } > > + node = list_node_next_node(node); > + } while (node != head); > } > > out: > @@ -652,9 +658,7 @@ CMPIStatus get_rule_by_ref( > struct acl_rule *rule = NULL; > const char *name = NULL; > char *filter_name = NULL; > - int rule_index; > virConnectPtr conn = NULL; > - int i; > > CU_DEBUG("Reference = %s", REF2STR(reference)); > > @@ -665,15 +669,6 @@ CMPIStatus get_rule_by_ref( > goto out; > } > > - if (parse_rule_id(name, &filter_name, &rule_index) == 0) { > - cu_statusf(_BROKER, &s, > - CMPI_RC_ERR_NOT_FOUND, > - "Could not parse filter name"); > - goto out; > - } > - > - CU_DEBUG("Filter name = %s, rule index = %u", filter_name, rule_index); > - > conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); > if (conn == NULL) > goto out; > @@ -686,13 +681,7 @@ CMPIStatus get_rule_by_ref( > goto out; > } > > - for (i = 0; i < filter->rule_ct; i++) { > - if (rule_index == i) { > - rule = filter->rules[i]; > - break; > - } > - } > - > + rule = list_find(filter->rules, (void *) name); > if (rule == NULL) { > cu_statusf(_BROKER, &s, > CMPI_RC_ERR_NOT_FOUND, > diff --git a/src/Virt_NestedFilterList.c b/src/Virt_NestedFilterList.c > index a8565d6..3e9fcc3 100644 > --- a/src/Virt_NestedFilterList.c > +++ b/src/Virt_NestedFilterList.c > @@ -141,9 +141,6 @@ static CMPIStatus parent_to_child( > goto out; > > /* Walk refs list */ > - if (parent_filter->refs == NULL) > - goto end; > - > head = node = list_first_node(parent_filter->refs); > if (head == NULL) > goto end; That looks reasonnable. The refactoring also decrease code size, Tentative ACK as I don't know the code, 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 veillard at redhat.com Wed Jun 20 07:11:20 2012 From: veillard at redhat.com (Daniel Veillard) Date: Wed, 20 Jun 2012 15:11:20 +0800 Subject: [Libvirt-cim] [PATCH 3/3] Make pool device paths use linked list implementation In-Reply-To: <1340120140-31321-4-git-send-email-eblima@linux.vnet.ibm.com> References: <1340120140-31321-1-git-send-email-eblima@linux.vnet.ibm.com> <1340120140-31321-4-git-send-email-eblima@linux.vnet.ibm.com> Message-ID: <20120620071120.GC2635@redhat.com> On Tue, Jun 19, 2012 at 12:35:40PM -0300, Eduardo Lima (Etrunko) wrote: > From: "Eduardo Lima (Etrunko)" > > Signed-off-by: Eduardo Lima (Etrunko) > --- > libxkutil/pool_parsing.c | 27 ++++++------------------- > libxkutil/pool_parsing.h | 4 ++-- > libxkutil/xmlgen.c | 29 +++++++++++++++++---------- > src/Virt_ResourcePoolConfigurationService.c | 28 +++++++++----------------- > 4 files changed, 35 insertions(+), 53 deletions(-) > > diff --git a/libxkutil/pool_parsing.c b/libxkutil/pool_parsing.c > index e41fc09..bb616d4 100644 > --- a/libxkutil/pool_parsing.c > +++ b/libxkutil/pool_parsing.c > @@ -54,8 +54,6 @@ static void cleanup_net_pool(struct net_pool pool) { > } > > static void cleanup_disk_pool(struct disk_pool pool) { > - uint16_t i; > - > free(pool.path); > free(pool.host); > free(pool.src_dir); > @@ -63,10 +61,7 @@ static void cleanup_disk_pool(struct disk_pool pool) { > free(pool.port_name); > free(pool.node_name); > > - for (i = 0; i < pool.device_paths_ct; i++) > - free(pool.device_paths[i]); > - > - free(pool.device_paths); > + list_free(pool.device_paths); > } > > void cleanup_virt_pool(struct virt_pool **pool) > @@ -130,22 +125,15 @@ static int parse_disk_target(xmlNode *node, struct disk_pool *pool) > static int parse_disk_source(xmlNode *node, struct disk_pool *pool) > { > xmlNode *child; > - char **dev_paths = NULL; > - unsigned ct = 0; > > for (child = node->children; child != NULL; child = child->next) { > if (XSTREQ(child->name, "device")) { > - char **tmp = NULL; > - > - tmp = realloc(dev_paths, sizeof(char *) * (ct + 1)); > - if (tmp == NULL) { > - CU_DEBUG("Could not alloc space for dev path"); > - continue; > - } > - dev_paths = tmp; > + if (pool->device_paths == NULL) > + pool->device_paths = list_new(free, > + (list_data_cmp_cb) strcmp); > > - dev_paths[ct] = get_attr_value(child, "path"); > - ct++; > + list_append(pool->device_paths, > + get_attr_value(child, "path")); > } else if (XSTREQ(child->name, "host")) { > pool->host = get_attr_value(child, "name"); > if (pool->host == NULL) > @@ -161,12 +149,9 @@ static int parse_disk_source(xmlNode *node, struct disk_pool *pool) > } > } > > - pool->device_paths_ct = ct; > - pool->device_paths = dev_paths; > return 1; > > err: > - free(dev_paths); > return 0; > } > > diff --git a/libxkutil/pool_parsing.h b/libxkutil/pool_parsing.h > index 9f1a386..50fbeac 100644 > --- a/libxkutil/pool_parsing.h > +++ b/libxkutil/pool_parsing.h > @@ -26,6 +26,7 @@ > #include > > #include "../src/svpc_types.h" > +#include "list_util.h" > > struct net_pool { > char *addr; > @@ -46,8 +47,7 @@ struct disk_pool { > DISK_POOL_LOGICAL, > DISK_POOL_SCSI} pool_type; > char *path; > - char **device_paths; > - uint16_t device_paths_ct; > + list_t *device_paths; > char *host; > char *src_dir; > char *adapter; > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > index 2dcd0d2..26e7203 100644 > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -1177,27 +1177,34 @@ static const char *disk_pool_type_to_str(uint16_t type) > return NULL; > } > > +static bool device_paths_foreach(void *list_data, void *user_data) > +{ > + char *dev_path = (char *) list_data; > + xmlNodePtr src = (xmlNodePtr) user_data; > + xmlNodePtr tmp = NULL; > + > + tmp = xmlNewChild(src, NULL, BAD_CAST "device", BAD_CAST NULL); > + if (tmp == NULL) > + return false; > + > + if (xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev_path) == NULL) > + return false; > + > + return true; > +} > + > static const char *set_disk_pool_source(xmlNodePtr disk, > struct disk_pool *pool) > { > xmlNodePtr src; > xmlNodePtr tmp; > - uint16_t i; > > src = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); > if (src == NULL) > return XML_ERROR; > > - for (i = 0; i < pool->device_paths_ct; i++) { > - tmp = xmlNewChild(src, NULL, BAD_CAST "device", BAD_CAST NULL); > - if (tmp == NULL) > - return XML_ERROR; > - > - if (xmlNewProp(tmp, > - BAD_CAST "path", > - BAD_CAST pool->device_paths[i]) == NULL) > - return XML_ERROR; > - } > + if (!list_foreach(pool->device_paths, device_paths_foreach, src)) > + return XML_ERROR; > > if (pool->host != NULL) { > tmp = xmlNewChild(src, NULL, BAD_CAST "host", BAD_CAST NULL); > diff --git a/src/Virt_ResourcePoolConfigurationService.c b/src/Virt_ResourcePoolConfigurationService.c > index 751d016..bc3e431 100644 > --- a/src/Virt_ResourcePoolConfigurationService.c > +++ b/src/Virt_ResourcePoolConfigurationService.c > @@ -143,7 +143,6 @@ static const char *net_rasd_to_pool(CMPIInstance *inst, > static void init_disk_pool(struct virt_pool *pool) > { > pool->pool_info.disk.device_paths = NULL; > - pool->pool_info.disk.device_paths_ct = 0; > pool->pool_info.disk.path = NULL; > pool->pool_info.disk.host = NULL; > pool->pool_info.disk.src_dir = NULL; > @@ -153,9 +152,8 @@ static void init_disk_pool(struct virt_pool *pool) > pool->pool_info.disk.autostart = 0; > } > > -static char *get_dev_paths(CMPIInstance *inst, > - char ***path_list, > - uint16_t *count) > + > +static char *get_dev_paths(CMPIInstance *inst, list_t **path_list) > { > CMPICount i; > CMPICount ct; > @@ -170,11 +168,8 @@ static char *get_dev_paths(CMPIInstance *inst, > if ((s.rc != CMPI_RC_OK) || (ct <= 0)) > return "Unable to get DevicePaths array count"; > > - *path_list = calloc(ct, sizeof(char *)); > if (*path_list == NULL) > - return "Failed to alloc space for device paths"; > - > - *count = ct; > + *path_list = list_new(free, (list_data_cmp_cb) strcmp); > > for (i = 0; i < ct; i++) { > const char *str = NULL; > @@ -187,7 +182,7 @@ static char *get_dev_paths(CMPIInstance *inst, > if (str == NULL) > return "Unable to get value of DevicePaths element"; > > - *path_list[i] = strdup(str); > + list_append(*path_list, strdup(str)); > } > > return NULL; > @@ -198,10 +193,7 @@ static const char *disk_fs_or_disk_or_logical_pool(CMPIInstance *inst, > { > const char *msg = NULL; > > - msg = get_dev_paths(inst, > - &pool->pool_info.disk.device_paths, > - &pool->pool_info.disk.device_paths_ct); > - > + msg = get_dev_paths(inst, &pool->pool_info.disk.device_paths); > > /* Specifying a value for DevicePaths isn't mandatory for logical > pool types. */ > @@ -209,7 +201,7 @@ static const char *disk_fs_or_disk_or_logical_pool(CMPIInstance *inst, > if (msg != NULL) > return msg; > > - if (pool->pool_info.disk.device_paths_ct != 1) { > + if (list_count(pool->pool_info.disk.device_paths) != 1) { > CU_DEBUG("%d only takes one device path", > pool->pool_info.disk.pool_type); > return "Specified pool type only takes one device path"; > @@ -243,14 +235,12 @@ static const char *disk_iscsi_pool(CMPIInstance *inst, > const char *val = NULL; > const char *msg = NULL; > > - msg = get_dev_paths(inst, > - &pool->pool_info.disk.device_paths, > - &pool->pool_info.disk.device_paths_ct); > - > + msg = get_dev_paths(inst, &pool->pool_info.disk.device_paths); > + > if (msg != NULL) > return msg; > > - if (pool->pool_info.disk.device_paths_ct != 1) > + if (list_count(pool->pool_info.disk.device_paths) != 1) > return "Specified pool type only takes one device path"; > > if (cu_get_str_prop(inst, "Host", &val) != CMPI_RC_OK) Looks fine but I would rename device_paths_foreach() to indicates what the function does instead of how it is used, something like device_path_dump_xml() or something similar, That doesn't affect the code semantic though ACK, 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 veillard at redhat.com Wed Jun 20 07:15:20 2012 From: veillard at redhat.com (Daniel Veillard) Date: Wed, 20 Jun 2012 15:15:20 +0800 Subject: [Libvirt-cim] 2nd try : help needed in resolving libvirt-cim compilation errors.. In-Reply-To: References: <20120619083427.GU2661@redhat.com> Message-ID: <20120620071520.GD2635@redhat.com> On Tue, Jun 19, 2012 at 10:14:04AM +0000, Raghunatha Reddy P (raghunp) wrote: > Hi Daniel, > > I am very sorry for missing your reply. It worked fine me. 'make install' went fine. > > After make install, I ran 'make postinstall' which throwed an error, > > Registering class KVM_HostedFilterList > Staging provider registration. > provider-register.sh: line 505: sfcbstage: command not found > Failed to stage provider registration. > make: *** [postinstall] Error 1 > [root at vmware-nexus1k-01 libvirt-cim-0.6.0]# > > Could you please tell how to fix this? No precise idea, seems somehow that your sblim-fscb setup is not correct. 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 xiawenc at linux.vnet.ibm.com Mon Jun 25 02:30:32 2012 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Mon, 25 Jun 2012 10:30:32 +0800 Subject: [Libvirt-cim] [PATCH 1/3] list_util: Fix possible memory leak In-Reply-To: <1340120140-31321-2-git-send-email-eblima@linux.vnet.ibm.com> References: <1340120140-31321-1-git-send-email-eblima@linux.vnet.ibm.com> <1340120140-31321-2-git-send-email-eblima@linux.vnet.ibm.com> Message-ID: <4FE7CD48.9030606@linux.vnet.ibm.com> +1 ? 2012-6-19 23:35, Eduardo Lima (Etrunko) ??: > From: "Eduardo Lima (Etrunko)" > > The list pointer was leaking in the case where the list was empty. > > Signed-off-by: Eduardo Lima (Etrunko) > --- > libxkutil/list_util.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/libxkutil/list_util.c b/libxkutil/list_util.c > index 84b2ba0..cab0287 100644 > --- a/libxkutil/list_util.c > +++ b/libxkutil/list_util.c > @@ -54,9 +54,12 @@ void list_free(list_t *list) > { > list_node_t *n, *next; > > - if (list == NULL || list->head == NULL) > + if (list == NULL) > return; > > + if (list->head == NULL) > + goto end; > + > n = list->head; > > do { > @@ -68,6 +71,7 @@ void list_free(list_t *list) > n = next; > } while (n != list->head); > > + end: > free(list); > } > -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From xiawenc at linux.vnet.ibm.com Wed Jun 27 02:03:34 2012 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Wed, 27 Jun 2012 10:03:34 +0800 Subject: [Libvirt-cim] test if mail list is alive Message-ID: <4FEA69F6.4040501@linux.vnet.ibm.com> Need to send a patch, have a test, pls ignore -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From xiawenc at linux.vnet.ibm.com Wed Jun 27 02:13:07 2012 From: xiawenc at linux.vnet.ibm.com (Wenchao Xia) Date: Wed, 27 Jun 2012 10:13:07 +0800 Subject: [Libvirt-cim] [PATCH] distinguish running or inactive state Message-ID: <1340763187-3642-1-git-send-email-xiawenc@linux.vnet.ibm.com> In older version of libvirt-cim, it calls libvirt with current vm state. With ACL patch it changed to call libvirt with inactive vm state. This will cause libvirt-cim show different behavior about running vm compared to old libvirt-cim. For eg, if vnc port that was defined as automatically allocation, after vm power up, user can't get what port is allocated by the system. This patch changed this back as a fix, except for FilterList. Signed-off-by: Wenchao Xia --- libxkutil/device_parsing.c | 10 +++++++--- libxkutil/device_parsing.h | 3 ++- src/Virt_AppliedFilterList.c | 4 ++-- src/Virt_Device.c | 4 ++-- src/Virt_DevicePool.c | 4 ++-- src/Virt_RASD.c | 4 ++-- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index f153c5b..0ed9f03 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -997,13 +997,17 @@ static int _get_proc_device(const char *xml, struct virt_device **list) return 1; }; -int get_devices(virDomainPtr dom, struct virt_device **list, int type) +int get_devices(virDomainPtr dom, struct virt_device **list, int type, + int inactive) { char *xml; int ret; + int xmlflag; - xml = virDomainGetXMLDesc(dom, - VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE); + xmlflag = VIR_DOMAIN_XML_SECURE; + if (inactive == 1) + xmlflag |= VIR_DOMAIN_XML_INACTIVE; + xml = virDomainGetXMLDesc(dom, xmlflag); if (xml == NULL) return 0; diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index b3b75a9..871cf54 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -203,7 +203,8 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo); void cleanup_dominfo(struct domain **dominfo); -int get_devices(virDomainPtr dom, struct virt_device **list, int type); +int get_devices(virDomainPtr dom, struct virt_device **list, int type, + int inactive); void cleanup_virt_device(struct virt_device *dev); void cleanup_virt_devices(struct virt_device **devs, int count); diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c index 0dfe6a3..55a96ee 100644 --- a/src/Virt_AppliedFilterList.c +++ b/src/Virt_AppliedFilterList.c @@ -200,7 +200,7 @@ static CMPIStatus list_to_net( for (i = 0; i < dcount; i++) { /* get domain's network devices */ struct virt_device *devices = NULL; - ncount = get_devices(doms[i], &devices, CIM_RES_TYPE_NET); + ncount = get_devices(doms[i], &devices, CIM_RES_TYPE_NET, 1); CU_DEBUG("Found %u network devices", ncount); @@ -300,7 +300,7 @@ static CMPIStatus net_to_list( /* get domain's network devices */ struct virt_device *devices = NULL; - int count = get_devices(dom, &devices, CIM_RES_TYPE_NET); + int count = get_devices(dom, &devices, CIM_RES_TYPE_NET, 1); CU_DEBUG("Found %u net devices on dom '%s'", count, domain_name); diff --git a/src/Virt_Device.c b/src/Virt_Device.c index abe3d6f..e047a94 100644 --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -529,7 +529,7 @@ static CMPIStatus _get_devices(const CMPIBroker *broker, bool rc; struct virt_device *devs = NULL; - count = get_devices(dom, &devs, type); + count = get_devices(dom, &devs, type, 0); if (count <= 0) goto out; @@ -698,7 +698,7 @@ static struct virt_device *find_dom_dev(virDomainPtr dom, int count; int i; - count = get_devices(dom, &list, type); + count = get_devices(dom, &list, type, 0); if (!count) { CU_DEBUG("No devices for %i", type); goto out; diff --git a/src/Virt_DevicePool.c b/src/Virt_DevicePool.c index def8454..202e509 100644 --- a/src/Virt_DevicePool.c +++ b/src/Virt_DevicePool.c @@ -446,7 +446,7 @@ static char *diskpool_member_of(const CMPIBroker *broker, if (dom == NULL) goto out; - count = get_devices(dom, &devs, CIM_RES_TYPE_DISK); + count = get_devices(dom, &devs, CIM_RES_TYPE_DISK, 0); for (i = 0; i < count; i++) { if (STREQ((devs[i].dev.disk.virtual_dev), dev)) { @@ -578,7 +578,7 @@ static char *netpool_member_of(const CMPIBroker *broker, if (dom == NULL) goto out; - count = get_devices(dom, &devs, CIM_RES_TYPE_NET); + count = get_devices(dom, &devs, CIM_RES_TYPE_NET, 0); for (i = 0; i < count; i++) { if (STREQ((devs[i].id), dev)) { diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index 3ac4cf5..9493077 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -81,7 +81,7 @@ int list_rasds(virConnectPtr conn, if (dom == NULL) return 0; - count = get_devices(dom, list, type); + count = get_devices(dom, list, type, 0); virDomainFree(dom); @@ -965,7 +965,7 @@ static CMPIStatus _get_rasds(const CMPIBroker *broker, struct virt_device *devs = NULL; const char *host = NULL; - count = get_devices(dom, &devs, type); + count = get_devices(dom, &devs, type, 0); if (count <= 0) goto out; -- 1.7.1 From eblima at linux.vnet.ibm.com Wed Jun 27 15:13:36 2012 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 27 Jun 2012 12:13:36 -0300 Subject: [Libvirt-cim] [PATCH] distinguish running or inactive state In-Reply-To: <1340763187-3642-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1340763187-3642-1-git-send-email-xiawenc@linux.vnet.ibm.com> Message-ID: <4FEB2320.4020703@linux.vnet.ibm.com> On 06/26/2012 11:13 PM, Wenchao Xia wrote: > In older version of libvirt-cim, it calls libvirt with current vm state. With > ACL patch it changed to call libvirt with inactive vm state. This will cause > libvirt-cim show different behavior about running vm compared to old > libvirt-cim. For eg, if vnc port that was defined as automatically allocation, > after vm power up, user can't get what port is allocated by the system. This > patch changed this back as a fix, except for FilterList. > > Signed-off-by: Wenchao Xia > --- > libxkutil/device_parsing.c | 10 +++++++--- > libxkutil/device_parsing.h | 3 ++- > src/Virt_AppliedFilterList.c | 4 ++-- > src/Virt_Device.c | 4 ++-- > src/Virt_DevicePool.c | 4 ++-- > src/Virt_RASD.c | 4 ++-- > 6 files changed, 17 insertions(+), 12 deletions(-) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index f153c5b..0ed9f03 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -997,13 +997,17 @@ static int _get_proc_device(const char *xml, struct virt_device **list) > return 1; > }; > > -int get_devices(virDomainPtr dom, struct virt_device **list, int type) > +int get_devices(virDomainPtr dom, struct virt_device **list, int type, > + int inactive) > { > char *xml; > int ret; > + int xmlflag; > > - xml = virDomainGetXMLDesc(dom, > - VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE); > + xmlflag = VIR_DOMAIN_XML_SECURE; > + if (inactive == 1) > + xmlflag |= VIR_DOMAIN_XML_INACTIVE; > + xml = virDomainGetXMLDesc(dom, xmlflag); > if (xml == NULL) > return 0; > Instead of passing an int which will act as boolean, I guess it would be a better option to use thevirDomainXMLFlags itself in the parameter. That would make things less complicated. diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index f153c5b..7f999ee 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -997,13 +997,13 @@ static int _get_proc_device(const char *xml, struct virt_device **list) return 1; }; -int get_devices(virDomainPtr dom, struct virt_device **list, int type) +int get_devices(virDomainPtr dom, struct virt_device **list, int type, unsigned int flags) { char *xml; int ret; xml = virDomainGetXMLDesc(dom, - VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE); + flags | VIR_DOMAIN_XML_SECURE); if (xml == NULL) return 0; What do you think? > diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h > index b3b75a9..871cf54 100644 > --- a/libxkutil/device_parsing.h > +++ b/libxkutil/device_parsing.h > @@ -203,7 +203,8 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo); > > void cleanup_dominfo(struct domain **dominfo); > > -int get_devices(virDomainPtr dom, struct virt_device **list, int type); > +int get_devices(virDomainPtr dom, struct virt_device **list, int type, > + int inactive); > > void cleanup_virt_device(struct virt_device *dev); > void cleanup_virt_devices(struct virt_device **devs, int count); > diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c > index 0dfe6a3..55a96ee 100644 > --- a/src/Virt_AppliedFilterList.c > +++ b/src/Virt_AppliedFilterList.c > @@ -200,7 +200,7 @@ static CMPIStatus list_to_net( > for (i = 0; i < dcount; i++) { > /* get domain's network devices */ > struct virt_device *devices = NULL; > - ncount = get_devices(doms[i], &devices, CIM_RES_TYPE_NET); > + ncount = get_devices(doms[i], &devices, CIM_RES_TYPE_NET, 1); > > CU_DEBUG("Found %u network devices", ncount); > > @@ -300,7 +300,7 @@ static CMPIStatus net_to_list( > > /* get domain's network devices */ > struct virt_device *devices = NULL; > - int count = get_devices(dom, &devices, CIM_RES_TYPE_NET); > + int count = get_devices(dom, &devices, CIM_RES_TYPE_NET, 1); > > CU_DEBUG("Found %u net devices on dom '%s'", count, domain_name); > > diff --git a/src/Virt_Device.c b/src/Virt_Device.c > index abe3d6f..e047a94 100644 > --- a/src/Virt_Device.c > +++ b/src/Virt_Device.c > @@ -529,7 +529,7 @@ static CMPIStatus _get_devices(const CMPIBroker *broker, > bool rc; > struct virt_device *devs = NULL; > > - count = get_devices(dom, &devs, type); > + count = get_devices(dom, &devs, type, 0); > if (count <= 0) > goto out; > > @@ -698,7 +698,7 @@ static struct virt_device *find_dom_dev(virDomainPtr dom, > int count; > int i; > > - count = get_devices(dom, &list, type); > + count = get_devices(dom, &list, type, 0); > if (!count) { > CU_DEBUG("No devices for %i", type); > goto out; > diff --git a/src/Virt_DevicePool.c b/src/Virt_DevicePool.c > index def8454..202e509 100644 > --- a/src/Virt_DevicePool.c > +++ b/src/Virt_DevicePool.c > @@ -446,7 +446,7 @@ static char *diskpool_member_of(const CMPIBroker *broker, > if (dom == NULL) > goto out; > > - count = get_devices(dom, &devs, CIM_RES_TYPE_DISK); > + count = get_devices(dom, &devs, CIM_RES_TYPE_DISK, 0); > > for (i = 0; i < count; i++) { > if (STREQ((devs[i].dev.disk.virtual_dev), dev)) { > @@ -578,7 +578,7 @@ static char *netpool_member_of(const CMPIBroker *broker, > if (dom == NULL) > goto out; > > - count = get_devices(dom, &devs, CIM_RES_TYPE_NET); > + count = get_devices(dom, &devs, CIM_RES_TYPE_NET, 0); > > for (i = 0; i < count; i++) { > if (STREQ((devs[i].id), dev)) { > diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c > index 3ac4cf5..9493077 100644 > --- a/src/Virt_RASD.c > +++ b/src/Virt_RASD.c > @@ -81,7 +81,7 @@ int list_rasds(virConnectPtr conn, > if (dom == NULL) > return 0; > > - count = get_devices(dom, list, type); > + count = get_devices(dom, list, type, 0); > > virDomainFree(dom); > > @@ -965,7 +965,7 @@ static CMPIStatus _get_rasds(const CMPIBroker *broker, > struct virt_device *devs = NULL; > const char *host = NULL; > > - count = get_devices(dom, &devs, type); > + count = get_devices(dom, &devs, type, 0); > if (count <= 0) > goto out; > -- 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 Wed Jun 27 18:46:40 2012 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 27 Jun 2012 15:46:40 -0300 Subject: [Libvirt-cim] [PATCHv2 0/3] Make Shutdown and Reboot state changes jobs In-Reply-To: <4F58AF2F.3060305@linux.vnet.ibm.com> References: <1331056553-29221-1-git-send-email-eblima@linux.vnet.ibm.com> <1331140322.2597.26.camel@snmishra-desktop.beaverton.ibm.com> <4F58AF2F.3060305@linux.vnet.ibm.com> Message-ID: <4FEB5510.8020009@linux.vnet.ibm.com> On 03/08/2012 10:07 AM, Eduardo Lima (Etrunko) wrote: > On 03/07/2012 02:12 PM, Sharad Mishra wrote: >> On Tue, 2012-03-06 at 14:55 -0300, Eduardo Lima (Etrunko) wrote: >>> From: "Eduardo Lima (Etrunko)" >>> >>> This code is based on the VSMigrationService for the job creation and on >>> ComputerSystemIndication for the job thread, which will listen for the >>> respective domain event to mark the job as finished. >>> >>> I am still not able to test this feature in my environment, every call to >>> CBGetInstance fails with code error 100. This is happening in other places of >>> the codebase, not only the ComputerSystem provider, but also ElementConfors, >>> for instance. Please use the test case send in previous email for reference. >> >> Eduardo, It is not clear if you started seeing this error code after >> applying this patch or were you getting it before. > > It already happens with other test cases that will cause the provider to > make a call such as CBGetInstance, CBCreateInstance and others from the > same family. For example, test ElementConforms/02_reverse.py fails with > the same error code 100, with or without this patch applied. I suspect > it can be something messed up with my environment. > Small update on this. I found the issue here with the error code 100. I have dug deeper on tog-pegasus by enabling some debug messages and found something interesting: Http [19773:140483615913728:Socket.cpp:137]: connect() returned error code 13 Looking in /usr/include/asm-generic/errno-base.h we get the following: #define EACCES 13 /* Permission denied */ After disabling SELinux, further cimtest runs never returned the 'Error 100' anymore. I have worked a bit on the patch but it is still not working. Now I'm stuck with a random crash happening on the state_change thread, whenever calls to set properties on the job instance are placed. Looks very likely to be an an issue on the tog-pegasus side, unless I am doing something very wrong in this case. -- 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 Wed Jun 27 18:58:01 2012 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 27 Jun 2012 15:58:01 -0300 Subject: [Libvirt-cim] [PATCH 1/2] VSMigrationService: Move job state definitions to svpc_types.h In-Reply-To: <1340823482-17151-1-git-send-email-eblima@linux.vnet.ibm.com> References: <1340823482-17151-1-git-send-email-eblima@linux.vnet.ibm.com> Message-ID: <1340823482-17151-2-git-send-email-eblima@linux.vnet.ibm.com> From: "Eduardo Lima (Etrunko)" Further job implementations may reuse these values. Signed-off-by: Eduardo Lima (Etrunko) --- src/Virt_VSMigrationService.c | 14 +++++--------- src/svpc_types.h | 13 +++++++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Virt_VSMigrationService.c b/src/Virt_VSMigrationService.c index 76e3d25..a6b5fc0 100644 --- a/src/Virt_VSMigrationService.c +++ b/src/Virt_VSMigrationService.c @@ -52,10 +52,6 @@ #include "config.h" -#define CIM_JOBSTATE_STARTING 3 -#define CIM_JOBSTATE_RUNNING 4 -#define CIM_JOBSTATE_COMPLETE 7 - #define MIGRATE_SHUTDOWN_TIMEOUT 120 #define METHOD_RETURN(r, v) do { \ @@ -1289,19 +1285,19 @@ static CMPI_THREAD_RETURN migration_thread(struct migration_job *job) CBAttachThread(_BROKER, job->context); CU_DEBUG("Migration Job %s started", job->uuid); - migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, 0, "Running"); + migrate_job_set_state(job, CIM_JOB_STATE_RUNNING, 0, "Running"); s = migrate_vs(job); CU_DEBUG("Migration Job %s finished: %i", job->uuid, s.rc); if (s.rc != CMPI_RC_OK) migrate_job_set_state(job, - CIM_JOBSTATE_COMPLETE, + CIM_JOB_STATE_COMPLETED, s.rc, CMGetCharPtr(s.msg)); else migrate_job_set_state(job, - CIM_JOBSTATE_COMPLETE, + CIM_JOB_STATE_COMPLETED, 0, "Completed"); @@ -1361,7 +1357,7 @@ static CMPIInstance *_migrate_job_new_instance(const char *cn, } inst = CMNewInstance(_BROKER, op, &s); - if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(op))) { + if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(inst))) { CU_DEBUG("Failed to create instance from ref: %s", CMGetCharPtr(CMObjectPathToString(op, NULL))); return NULL; @@ -1378,7 +1374,7 @@ static CMPIStatus migrate_create_job_instance(const CMPIContext *context, CMPIInstance *jobinst; CMPIDateTime *start; CMPIBoolean autodelete = true; - uint16_t state = CIM_JOBSTATE_STARTING; + uint16_t state = CIM_JOB_STATE_STARTING; char *type = NULL; start = CMNewDateTime(_BROKER, &s); diff --git a/src/svpc_types.h b/src/svpc_types.h index 90bb608..338a7ef 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -167,5 +167,18 @@ enum CIM_op_status { CIM_OP_STATUS_POWER_MODE = 18, }; +enum CIM_job_state { + CIM_JOB_STATE_NEW = 2, + CIM_JOB_STATE_STARTING, + CIM_JOB_STATE_RUNNING, + CIM_JOB_STATE_SUSPENDED, + CIM_JOB_STATE_SHUTTING_DOWN, + CIM_JOB_STATE_COMPLETED, + CIM_JOB_STATE_TERMINATED, + CIM_JOB_STATE_KILLED, + CIM_JOB_STATE_EXCEPTION, + CIM_JOB_STATE_SERVICE, + CIM_JOB_STATE_QUERY_PENDING, +}; #endif -- 1.7.10.4 From eblima at linux.vnet.ibm.com Wed Jun 27 18:58:02 2012 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 27 Jun 2012 15:58:02 -0300 Subject: [Libvirt-cim] [PATCH 2/2] ComputerSystem: Reboot/Shutdown state changes as jobs In-Reply-To: <1340823482-17151-1-git-send-email-eblima@linux.vnet.ibm.com> References: <1340823482-17151-1-git-send-email-eblima@linux.vnet.ibm.com> Message-ID: <1340823482-17151-3-git-send-email-eblima@linux.vnet.ibm.com> From: "Eduardo Lima (Etrunko)" For Reboot and Shutdown, th RequestStateChange method returns immediately with return code 0 (successful) even though the state change is still not completed. According to the DMTF specification DSP1052 (Computer System Profile) the RequestStateChange() method should return 0x1000 and a corresponding job reference in the return parameters which can be polled for completion. Signed-off-by: Eduardo Lima (Etrunko) --- schema/ComputerSystem.mof | 9 ++ src/Virt_ComputerSystem.c | 326 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 325 insertions(+), 10 deletions(-) diff --git a/schema/ComputerSystem.mof b/schema/ComputerSystem.mof index 10cb8c4..886c085 100644 --- a/schema/ComputerSystem.mof +++ b/schema/ComputerSystem.mof @@ -1,5 +1,14 @@ // Copyright IBM Corp. 2007 +class Xen_ComputerSystemStateChangeJob : CIM_ConcreteJob { +}; + +class KVM_ComputerSystemStateChangeJob : CIM_ConcreteJob { +}; + +class LXC_ComputerSystemStateChangeJob : CIM_ConcreteJob { +}; + [Description ( "A class derived from CIM_ComputerSystem to represent " "the Xen virtual machines/domains running on the system."), diff --git a/src/Virt_ComputerSystem.c b/src/Virt_ComputerSystem.c index e6c7e55..9546da2 100644 --- a/src/Virt_ComputerSystem.c +++ b/src/Virt_ComputerSystem.c @@ -30,23 +30,40 @@ #include #include +#include #include +#include -#include "cs_util.h" #include -#include "misc_util.h" -#include "infostore.h" -#include "device_parsing.h" #include #include #include +#include "cs_util.h" +#include "misc_util.h" +#include "infostore.h" +#include "device_parsing.h" +#include "svpc_types.h" + #include "Virt_ComputerSystem.h" #include "Virt_HostSystem.h" #include "Virt_VirtualSystemSnapshotService.h" const static CMPIBroker *_BROKER; +typedef struct _state_change_job state_change_job_t; +struct _state_change_job { + char uuid[VIR_UUID_STRING_BUFLEN]; + CMPIContext *context; + CMPIObjectPath *obj_path; + CMPIInstance *inst; + char *dom_name; + uint16_t dom_state; + uint16_t status; /* job status */ +}; + +static bool events_registered = false; + /* Set the "Name" property of an instance from a domain */ static int set_name_from_dom(virDomainPtr dom, CMPIInstance *instance) { @@ -1189,19 +1206,20 @@ static CMPIStatus __state_change(const char *name, s = state_change_enable(dom, &info); else if (state == CIM_STATE_DISABLED) s = state_change_disable(dom, &info); - else if (state == CIM_STATE_SHUTDOWN) - s = state_change_shutdown(dom, &info); else if (state == CIM_STATE_PAUSED) s = state_change_pause(dom, &info); - else if (state == CIM_STATE_REBOOT) - s = state_change_reboot(dom, &info); else if (state == CIM_STATE_RESET) s = state_change_reset(dom, &info); + else if (state == CIM_STATE_SHUTDOWN || state == CIM_STATE_REBOOT) + s.rc = CIM_SVPC_RETURN_JOB_STARTED; else cu_statusf(_BROKER, &s, CMPI_RC_ERR_NOT_SUPPORTED, "State not supported"); + if (s.rc != CMPI_RC_OK && s.rc != CIM_SVPC_RETURN_JOB_STARTED) + goto out; + infostore = infostore_open(dom); if (infostore != NULL) { infostore_set_u64(infostore, "reqstate", (uint64_t)state); @@ -1215,6 +1233,265 @@ static CMPIStatus __state_change(const char *name, return s; } +static CMPIStatus create_state_change_job(const CMPIObjectPath *ref, + const CMPIContext *context, + state_change_job_t **job, + uint16_t state) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *job_inst; + CMPIDateTime *start; + CMPIBoolean autodelete = true; + CMPIObjectPath *obj_path; + uuid_t uuid; + char *type = NULL, *cn = NULL, *ns = NULL; + + start = CMNewDateTime(_BROKER, &s); + if ((s.rc != CMPI_RC_OK) || CMIsNullObject(start)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to get job start time"); + goto out; + } + + cn = strdup(CLASSNAME(ref)); + type = get_typed_class(cn, "ComputerSystemStateChangeJob"); + + obj_path = CMNewObjectPath(_BROKER, ns, type, &s); + if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(obj_path))) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to get new object path"); + goto out; + } + + job_inst = CMNewInstance(_BROKER, obj_path, &s); + if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(job_inst))) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to get new instance object"); + goto out; + } + + /* Alloc job struct */ + *job = calloc(1, sizeof(**job)); + if (*job == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to allocate memory for job structure"); + goto out; + } + + (*job)->dom_state = state; + (*job)->status = CIM_JOB_STATE_NEW; + + uuid_generate(uuid); + uuid_unparse(uuid, (*job)->uuid); + + /* Set Properties */ + CMSetProperty(job_inst, "InstanceID", + (CMPIValue *) (*job)->uuid, CMPI_chars); + CMSetProperty(job_inst, "Name", + (CMPIValue *) "ComputerSystemStateChange", CMPI_chars); + CMSetProperty(job_inst, "StartTime", + (CMPIValue *) &start, CMPI_dateTime); + CMSetProperty(job_inst, "JobState", + (CMPIValue *) &((*job)->status), CMPI_uint16); + CMSetProperty(job_inst, "Status", + (CMPIValue *) "New", CMPI_chars); + CMSetProperty(job_inst, "DeleteOnCompletion", + (CMPIValue *)&autodelete, CMPI_boolean); + + obj_path = CMGetObjectPath(job_inst, &s); + if ((obj_path == NULL) || (s.rc != CMPI_RC_OK)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to get path for ComputerSystemStateChangeJob instance"); + goto out; + } + + CMSetNameSpace(obj_path, ns); + + CU_DEBUG("Creating ComputerSystemStateChangeJob instance: %s", + CMGetCharPtr(CMObjectPathToString(obj_path, NULL))); + + obj_path = CBCreateInstance(_BROKER, context, obj_path, job_inst, &s); + if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(obj_path))) { + CU_DEBUG("Failed to create ComputerSystemStateChangeJob instance: %i", s.rc); + goto out; + } + + ns = strdup(NAMESPACE(ref)); + CMSetNameSpace(obj_path, ns); + + (*job)->obj_path = obj_path; + (*job)->context = CBPrepareAttachThread(_BROKER, context); + if ((*job)->context == NULL) { + CU_DEBUG("Failed to create thread context"); + cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, + "Unable to create thread context"); + goto out; + } + + (*job)->inst = CBGetInstance(_BROKER, (*job)->context, (*job)->obj_path, NULL, &s); + if (((*job)->inst == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to get job instance (%i)", s.rc); + goto out; + } + + out: + free(type); + free(cn); + free(ns); + return s; +} + +static void state_change_reboot_cb(virConnectPtr conn, + virDomainPtr dom, + void *data) +{ + state_change_job_t *job = (state_change_job_t *) data; + job->status = CIM_JOB_STATE_COMPLETED; + CU_DEBUG("state_change_reboot_cb(): Reboot complete"); +} + +static void state_change_shutdown_cb(virConnectPtr conn, + virDomainPtr dom, + int event, + int detail, + void *data) +{ + state_change_job_t *job = (state_change_job_t *) data; + if (event == VIR_DOMAIN_EVENT_SHUTDOWN) { + job->status = CIM_JOB_STATE_COMPLETED; + CU_DEBUG("state_change_shutdown_cb(): Shutdown complete"); + } +} + +static CMPI_THREAD_RETURN state_change_thread(void *data) +{ + CMPIStatus s; + state_change_job_t *job = (state_change_job_t *) data; + virConnectPtr conn = NULL; + virDomainPtr dom = NULL; + virDomainInfo info; + int job_cb = -1; + + /* Set job state */ + CBAttachThread(_BROKER, job->context); + CU_DEBUG("State change job %s started", job->uuid); + + job->status = CIM_JOB_STATE_STARTING; + CMSetProperty(job->inst, "JobState", + (CMPIValue *) &(job->status), CMPI_uint16); + CMSetProperty(job->inst, "Status", + (CMPIValue *) "Starting", CMPI_chars); + + /* Connect to domain event callback */ + conn = connect_by_classname(_BROKER, CLASSNAME(job->obj_path), &s); + if (conn == NULL) { + CU_DEBUG("Unable to connect to '%s' hypervisor", + CLASSNAME(job->obj_path)); + goto err; + } + + dom = virDomainLookupByName(conn, job->dom_name); + if (dom == NULL) { + CU_DEBUG("Unable to get domain '%s'", job->dom_name); + goto err; + } + + if (virDomainGetInfo(dom, &info) != 0) { + CU_DEBUG("Unable to get domain info for '%s'", job->dom_name); + goto err; + } + + if (job->dom_state == CIM_STATE_REBOOT) { + job_cb = virConnectDomainEventRegisterAny(conn, NULL, + VIR_DOMAIN_EVENT_ID_REBOOT, + VIR_DOMAIN_EVENT_CALLBACK(state_change_reboot_cb), + job, NULL); + + if (job_cb == -1) { + CU_DEBUG("Unable to connect domain reboot callback"); + goto err; + } + + s = state_change_reboot(dom, &info); + + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Unable to trigger domain reboot: '%s'", + CMGetCharPtr(s.msg)); + goto err; + } + } else if (job->dom_state == CIM_STATE_SHUTDOWN) { + job_cb = virConnectDomainEventRegisterAny(conn, NULL, + VIR_DOMAIN_EVENT_ID_LIFECYCLE, + VIR_DOMAIN_EVENT_CALLBACK(state_change_shutdown_cb), + job, NULL); + + if (job_cb == -1) { + CU_DEBUG("Unable to connect domain shutdown callback"); + goto err; + } + + s = state_change_shutdown(dom, &info); + + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Unable to trigger domain shutdown: '%s'", + CMGetCharPtr(s.msg)); + goto err; + } + } else { + CU_DEBUG("Unrecognized state '%d'", job->dom_state); + goto err; + } + + job->status = CIM_JOB_STATE_RUNNING; + CMSetProperty(job->inst, "JobState", + (CMPIValue *) &(job->status), CMPI_uint16); + CMSetProperty(job->inst, "Status", + (CMPIValue *) "Running", CMPI_chars); + + CU_DEBUG("Entering mainloop implementation"); + /* Wait for operation (shutdown/reboot) to complete */ + while (job->status == CIM_JOB_STATE_RUNNING) { + if (virEventRunDefaultImpl() < 0) { + virErrorPtr err = virGetLastError(); + CU_DEBUG("Failed to run event loop: %s\n", + err && err->message ? err->message : "Unknown error"); + goto err; + } + } + + CU_DEBUG("Job completed"); + CMSetProperty(job->inst, "JobState", + (CMPIValue *) &(job->status), CMPI_uint16); + CMSetProperty(job->inst, "Status", + (CMPIValue *) "Completed", CMPI_chars); + + goto out; + + err: + job->status = CIM_JOB_STATE_EXCEPTION; + CMSetProperty(job->inst, "JobState", + (CMPIValue *) &(job->status), CMPI_uint16); + CMSetProperty(job->inst, "Status", + (CMPIValue *) "Error", CMPI_chars); + + out: + if (job_cb != -1) + virConnectDomainEventDeregisterAny(conn, job_cb); + + virDomainFree(dom); + virConnectClose(conn); + + CBDetachThread(_BROKER, job->context); + free(job->dom_name); + free(job); + return NULL; +} + static CMPIStatus state_change(CMPIMethodMI *self, const CMPIContext *context, const CMPIResult *results, @@ -1244,7 +1521,8 @@ static CMPIStatus state_change(CMPIMethodMI *self, goto out; } - /* Retain original instance of the guest to use for the PreviousInstance attribute when generating an indication. */ + /* Retain original instance of the guest to use for the PreviousInstance + attribute when generating an indication. */ s = get_domain_by_name(_BROKER, reference, name, &prev_inst); if (s.rc != CMPI_RC_OK || prev_inst == NULL) { cu_statusf(_BROKER, &s, @@ -1256,8 +1534,36 @@ static CMPIStatus state_change(CMPIMethodMI *self, s = __state_change(name, state, reference); + rc = s.rc; + if (s.rc == CMPI_RC_OK) - rc = 0; + goto out; + + if (s.rc == CIM_SVPC_RETURN_JOB_STARTED) { + state_change_job_t *job = NULL; + + if (events_registered == false) { + events_registered = true; + if (virEventRegisterDefaultImpl() != 0) { + CU_DEBUG("virEventRegisterDefaultImpl() failed"); + goto out; + } + } + + s = create_state_change_job(reference, context, &job, state); + if (s.rc != CMPI_RC_OK) { + rc = s.rc; + free(job); + goto out; + } + + job->dom_name = strdup(name); + + _BROKER->xft->newThread(state_change_thread, job, 0); + + CMAddArg(argsout, "Job", (CMPIValue *)&(job->obj_path), + CMPI_ref); + } out: CMReturnData(results, &rc, CMPI_uint32); -- 1.7.10.4 From eblima at linux.vnet.ibm.com Wed Jun 27 18:58:00 2012 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 27 Jun 2012 15:58:00 -0300 Subject: [Libvirt-cim] [PATCH v3 0/2] [WIP] Make Shutdown and Reboot state changes jobs Message-ID: <1340823482-17151-1-git-send-email-eblima@linux.vnet.ibm.com> From: "Eduardo Lima (Etrunko)" This code is based on the VSMigrationService for the job creation and on ComputerSystemIndication for the job thread, which will listen for the respective domain event to mark the job as finished. Good news here is that the 'Error 100' problem does not happen anymore. I found it to be an issue with SELinux. By disabling it, that error code will never happen again. Now the problem is a random crash happening on the state_change thread, whenever calls to set properties on the job instance are placed. Looks very likely to be an issue on the tog-pegasus side, unless I am doing something very wrong in this case. Would be nice to have some advice from tog-pegasus experts. :) Differences from v2: - Back again with the first set of patches, removing the intermediate patch to deal specifically with shutdown. - Improve some log messages. - More detailed states of the job instance (NEW, STARTING, RUNNING, COMPLETED, EXCEPTION, etc). - Move event loop registration outside the state_change thread. - Better error handling on the state_change thread. Differences from v1: - Fix conditional causing Reqstate not being set - Fix domain event id for shutdown - Now instead of using the domain events for both shutdown and reboot, there is an intermediate patch, that will deal with the shutdown case by polling for the domain state until it reflects the desired state. This workaround won't work for the reboot case, because is is not possible to monitor the reboot event if not using the domain event callbacks. The third patch of the series contains the complete solution for both cases. Eduardo Lima (Etrunko) (2): VSMigrationService: Move job state definitions to svpc_types.h ComputerSystem: Reboot/Shutdown state changes as jobs schema/ComputerSystem.mof | 9 ++ src/Virt_ComputerSystem.c | 326 +++++++++++++++++++++++++++++++++++++++-- src/Virt_VSMigrationService.c | 14 +- src/svpc_types.h | 13 ++ 4 files changed, 343 insertions(+), 19 deletions(-) -- 1.7.10.4 From xiawenc at linux.vnet.ibm.com Thu Jun 28 05:59:52 2012 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Thu, 28 Jun 2012 13:59:52 +0800 Subject: [Libvirt-cim] [PATCH] distinguish running or inactive state In-Reply-To: <4FEB2320.4020703@linux.vnet.ibm.com> References: <1340763187-3642-1-git-send-email-xiawenc@linux.vnet.ibm.com> <4FEB2320.4020703@linux.vnet.ibm.com> Message-ID: <4FEBF2D8.10502@linux.vnet.ibm.com> sounds reasonable. > On 06/26/2012 11:13 PM, Wenchao Xia wrote: >> In older version of libvirt-cim, it calls libvirt with current vm state. With >> ACL patch it changed to call libvirt with inactive vm state. This will cause >> libvirt-cim show different behavior about running vm compared to old >> libvirt-cim. For eg, if vnc port that was defined as automatically allocation, >> after vm power up, user can't get what port is allocated by the system. This >> patch changed this back as a fix, except for FilterList. >> >> Signed-off-by: Wenchao Xia >> --- >> libxkutil/device_parsing.c | 10 +++++++--- >> libxkutil/device_parsing.h | 3 ++- >> src/Virt_AppliedFilterList.c | 4 ++-- >> src/Virt_Device.c | 4 ++-- >> src/Virt_DevicePool.c | 4 ++-- >> src/Virt_RASD.c | 4 ++-- >> 6 files changed, 17 insertions(+), 12 deletions(-) >> >> diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c >> index f153c5b..0ed9f03 100644 >> --- a/libxkutil/device_parsing.c >> +++ b/libxkutil/device_parsing.c >> @@ -997,13 +997,17 @@ static int _get_proc_device(const char *xml, struct virt_device **list) >> return 1; >> }; >> >> -int get_devices(virDomainPtr dom, struct virt_device **list, int type) >> +int get_devices(virDomainPtr dom, struct virt_device **list, int type, >> + int inactive) >> { >> char *xml; >> int ret; >> + int xmlflag; >> >> - xml = virDomainGetXMLDesc(dom, >> - VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE); >> + xmlflag = VIR_DOMAIN_XML_SECURE; >> + if (inactive == 1) >> + xmlflag |= VIR_DOMAIN_XML_INACTIVE; >> + xml = virDomainGetXMLDesc(dom, xmlflag); >> if (xml == NULL) >> return 0; >> > > Instead of passing an int which will act as boolean, I guess it would be > a better option to use thevirDomainXMLFlags itself in the parameter. > That would make things less complicated. > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index f153c5b..7f999ee 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -997,13 +997,13 @@ static int _get_proc_device(const char *xml, > struct virt_device **list) > return 1; > }; > > -int get_devices(virDomainPtr dom, struct virt_device **list, int type) > +int get_devices(virDomainPtr dom, struct virt_device **list, int type, > unsigned int flags) > { > char *xml; > int ret; > > xml = virDomainGetXMLDesc(dom, > - VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE); > + flags | VIR_DOMAIN_XML_SECURE); > if (xml == NULL) > return 0; > > What do you think? > >> diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h >> index b3b75a9..871cf54 100644 >> --- a/libxkutil/device_parsing.h >> +++ b/libxkutil/device_parsing.h >> @@ -203,7 +203,8 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo); >> >> void cleanup_dominfo(struct domain **dominfo); >> >> -int get_devices(virDomainPtr dom, struct virt_device **list, int type); >> +int get_devices(virDomainPtr dom, struct virt_device **list, int type, >> + int inactive); >> >> void cleanup_virt_device(struct virt_device *dev); >> void cleanup_virt_devices(struct virt_device **devs, int count); >> diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c >> index 0dfe6a3..55a96ee 100644 >> --- a/src/Virt_AppliedFilterList.c >> +++ b/src/Virt_AppliedFilterList.c >> @@ -200,7 +200,7 @@ static CMPIStatus list_to_net( >> for (i = 0; i< dcount; i++) { >> /* get domain's network devices */ >> struct virt_device *devices = NULL; >> - ncount = get_devices(doms[i],&devices, CIM_RES_TYPE_NET); >> + ncount = get_devices(doms[i],&devices, CIM_RES_TYPE_NET, 1); >> >> CU_DEBUG("Found %u network devices", ncount); >> >> @@ -300,7 +300,7 @@ static CMPIStatus net_to_list( >> >> /* get domain's network devices */ >> struct virt_device *devices = NULL; >> - int count = get_devices(dom,&devices, CIM_RES_TYPE_NET); >> + int count = get_devices(dom,&devices, CIM_RES_TYPE_NET, 1); >> >> CU_DEBUG("Found %u net devices on dom '%s'", count, domain_name); >> >> diff --git a/src/Virt_Device.c b/src/Virt_Device.c >> index abe3d6f..e047a94 100644 >> --- a/src/Virt_Device.c >> +++ b/src/Virt_Device.c >> @@ -529,7 +529,7 @@ static CMPIStatus _get_devices(const CMPIBroker *broker, >> bool rc; >> struct virt_device *devs = NULL; >> >> - count = get_devices(dom,&devs, type); >> + count = get_devices(dom,&devs, type, 0); >> if (count<= 0) >> goto out; >> >> @@ -698,7 +698,7 @@ static struct virt_device *find_dom_dev(virDomainPtr dom, >> int count; >> int i; >> >> - count = get_devices(dom,&list, type); >> + count = get_devices(dom,&list, type, 0); >> if (!count) { >> CU_DEBUG("No devices for %i", type); >> goto out; >> diff --git a/src/Virt_DevicePool.c b/src/Virt_DevicePool.c >> index def8454..202e509 100644 >> --- a/src/Virt_DevicePool.c >> +++ b/src/Virt_DevicePool.c >> @@ -446,7 +446,7 @@ static char *diskpool_member_of(const CMPIBroker *broker, >> if (dom == NULL) >> goto out; >> >> - count = get_devices(dom,&devs, CIM_RES_TYPE_DISK); >> + count = get_devices(dom,&devs, CIM_RES_TYPE_DISK, 0); >> >> for (i = 0; i< count; i++) { >> if (STREQ((devs[i].dev.disk.virtual_dev), dev)) { >> @@ -578,7 +578,7 @@ static char *netpool_member_of(const CMPIBroker *broker, >> if (dom == NULL) >> goto out; >> >> - count = get_devices(dom,&devs, CIM_RES_TYPE_NET); >> + count = get_devices(dom,&devs, CIM_RES_TYPE_NET, 0); >> >> for (i = 0; i< count; i++) { >> if (STREQ((devs[i].id), dev)) { >> diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c >> index 3ac4cf5..9493077 100644 >> --- a/src/Virt_RASD.c >> +++ b/src/Virt_RASD.c >> @@ -81,7 +81,7 @@ int list_rasds(virConnectPtr conn, >> if (dom == NULL) >> return 0; >> >> - count = get_devices(dom, list, type); >> + count = get_devices(dom, list, type, 0); >> >> virDomainFree(dom); >> >> @@ -965,7 +965,7 @@ static CMPIStatus _get_rasds(const CMPIBroker *broker, >> struct virt_device *devs = NULL; >> const char *host = NULL; >> >> - count = get_devices(dom,&devs, type); >> + count = get_devices(dom,&devs, type, 0); >> if (count<= 0) >> goto out; >> > > -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From xiawenc at linux.vnet.ibm.com Thu Jun 28 06:55:24 2012 From: xiawenc at linux.vnet.ibm.com (Wenchao Xia) Date: Thu, 28 Jun 2012 14:55:24 +0800 Subject: [Libvirt-cim] [PATCH v2] distinguish running or inactive state Message-ID: <1340866524-3639-1-git-send-email-xiawenc@linux.vnet.ibm.com> In older version of libvirt-cim, it calls libvirt with current vm state. With ACL patch it changed to call libvirt with inactive vm state. This will cause libvirt-cim show different behavior about running vm compared to old libvirt-cim. For eg, if vnc port that was defined as automatically allocation, after vm power up, user can't get what port is allocated by the system. This patch changed this back as a fix, except for FilterList. v2: expose flags in API. Signed-off-by: Wenchao Xia --- libxkutil/device_parsing.c | 6 +++--- libxkutil/device_parsing.h | 4 +++- src/Virt_AppliedFilterList.c | 6 ++++-- src/Virt_Device.c | 4 ++-- src/Virt_DevicePool.c | 4 ++-- src/Virt_RASD.c | 4 ++-- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index f153c5b..5393290 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -997,13 +997,13 @@ static int _get_proc_device(const char *xml, struct virt_device **list) return 1; }; -int get_devices(virDomainPtr dom, struct virt_device **list, int type) +int get_devices(virDomainPtr dom, struct virt_device **list, int type, + unsigned int flags) { char *xml; int ret; - xml = virDomainGetXMLDesc(dom, - VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE); + xml = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_SECURE | flags); if (xml == NULL) return 0; diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index b3b75a9..d652f0f 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -203,7 +203,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo); void cleanup_dominfo(struct domain **dominfo); -int get_devices(virDomainPtr dom, struct virt_device **list, int type); +/* VIR_DOMAIN_XML_SECURE will always be set besides flags */ +int get_devices(virDomainPtr dom, struct virt_device **list, int type, + unsigned int flags); void cleanup_virt_device(struct virt_device *dev); void cleanup_virt_devices(struct virt_device **devs, int count); diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c index 0dfe6a3..c59c11f 100644 --- a/src/Virt_AppliedFilterList.c +++ b/src/Virt_AppliedFilterList.c @@ -200,7 +200,8 @@ static CMPIStatus list_to_net( for (i = 0; i < dcount; i++) { /* get domain's network devices */ struct virt_device *devices = NULL; - ncount = get_devices(doms[i], &devices, CIM_RES_TYPE_NET); + ncount = get_devices(doms[i], &devices, CIM_RES_TYPE_NET, + VIR_DOMAIN_XML_INACTIVE); CU_DEBUG("Found %u network devices", ncount); @@ -300,7 +301,8 @@ static CMPIStatus net_to_list( /* get domain's network devices */ struct virt_device *devices = NULL; - int count = get_devices(dom, &devices, CIM_RES_TYPE_NET); + int count = get_devices(dom, &devices, CIM_RES_TYPE_NET, + VIR_DOMAIN_XML_INACTIVE); CU_DEBUG("Found %u net devices on dom '%s'", count, domain_name); diff --git a/src/Virt_Device.c b/src/Virt_Device.c index abe3d6f..e047a94 100644 --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -529,7 +529,7 @@ static CMPIStatus _get_devices(const CMPIBroker *broker, bool rc; struct virt_device *devs = NULL; - count = get_devices(dom, &devs, type); + count = get_devices(dom, &devs, type, 0); if (count <= 0) goto out; @@ -698,7 +698,7 @@ static struct virt_device *find_dom_dev(virDomainPtr dom, int count; int i; - count = get_devices(dom, &list, type); + count = get_devices(dom, &list, type, 0); if (!count) { CU_DEBUG("No devices for %i", type); goto out; diff --git a/src/Virt_DevicePool.c b/src/Virt_DevicePool.c index def8454..202e509 100644 --- a/src/Virt_DevicePool.c +++ b/src/Virt_DevicePool.c @@ -446,7 +446,7 @@ static char *diskpool_member_of(const CMPIBroker *broker, if (dom == NULL) goto out; - count = get_devices(dom, &devs, CIM_RES_TYPE_DISK); + count = get_devices(dom, &devs, CIM_RES_TYPE_DISK, 0); for (i = 0; i < count; i++) { if (STREQ((devs[i].dev.disk.virtual_dev), dev)) { @@ -578,7 +578,7 @@ static char *netpool_member_of(const CMPIBroker *broker, if (dom == NULL) goto out; - count = get_devices(dom, &devs, CIM_RES_TYPE_NET); + count = get_devices(dom, &devs, CIM_RES_TYPE_NET, 0); for (i = 0; i < count; i++) { if (STREQ((devs[i].id), dev)) { diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index 3ac4cf5..9493077 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -81,7 +81,7 @@ int list_rasds(virConnectPtr conn, if (dom == NULL) return 0; - count = get_devices(dom, list, type); + count = get_devices(dom, list, type, 0); virDomainFree(dom); @@ -965,7 +965,7 @@ static CMPIStatus _get_rasds(const CMPIBroker *broker, struct virt_device *devs = NULL; const char *host = NULL; - count = get_devices(dom, &devs, type); + count = get_devices(dom, &devs, type, 0); if (count <= 0) goto out; -- 1.7.1 From veillard at redhat.com Thu Jun 28 14:15:49 2012 From: veillard at redhat.com (Daniel Veillard) Date: Thu, 28 Jun 2012 22:15:49 +0800 Subject: [Libvirt-cim] test if mail list is alive In-Reply-To: <4FEA69F6.4040501@linux.vnet.ibm.com> References: <4FEA69F6.4040501@linux.vnet.ibm.com> Message-ID: <20120628141549.GB2733@redhat.com> On Wed, Jun 27, 2012 at 10:03:34AM +0800, Wayne Xia wrote: > Need to send a patch, have a test, pls ignore yes i think we will keep the list even if there was a suggestion to merge it with libvir-list at redhat.com a couple of months ago. The code base is really specific and i'm not sure that would really be an improvement for either side. 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/