Re: [libvirt-php] Fix get_xml when xpath is null

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/13/2011 09:50 AM, Lyre wrote:
> ä 2011å04æ13æ 15:32, Michal Novotny åé:
>> On 04/13/2011 06:10 AM, Lyre wrote:
>>> Hi all:
>>>
>>> 	To my surprise, it seems that passing null to php as a string parameter,
>>> will set the pointer which retrive it to an empty string "" , but not NULL.
>>> get_xml_from_xpath() doesn't work correctly since an empty string is
>>> passed as the xpath argument, and libxml will complain "Invalid expression"
>>>
>>> I know seldom about xpath, I'm not sure if it is the correct way to fix it.
>>>
>>> BTW, what xpath shall I pass to get the entire xml?
>>>
>> Hi Lyre,
>> thanks for the information however I was always using the NULL value as
>> second argument for the get_xml_desc(), like e.g.:
>>
>> $entire_xml = libvirt_domain_get_xml_desc($dom, NULL);
>>
>> My development and testing is done on Fedora 14 and
>> php-5.3.6-1.fc14.i686 version of the package and it's working fine for
>> me. However the patch you sent to the list seems better and it's working
>> fine so I've pushed it to the repository right now.
>>
>> Just for the record, what did you mean by passing NULL to php as a
>> string parameter? To pass as 'null' ? I'm using it the way described
>> above and 'null' is required only for libvirt_connect() since there are
>> some issues with passing NULL to libvirt_connect(). We still may need to
>> fix the libvirt_connect() function, that's true.
>>
>> Michal
>>
> Hi Michal:
>
> I'm testing it on sles 11 sp1 with php 5.2.6.
>
> Let's take libvirt_domains_get_xml_desc as an example:
>
> when I called  $entire_xml = libvirt_domain_get_xml_desc($dom, NULL);
>
> In the C code:
>
> PHP_FUNCTION(libvirt_domain_get_xml_desc)
> {
>      char *xpath = NULL;
>      int xpath_len;
>      /* ... */
>
>      GET_DOMAIN_FROM_ARGS("rs|l",&zdomain,&xpath,&xpath_len,&flags);
>
>      /* other stuff */
> }
>
> After fetching arguments, xpath point to an empty string "". So that it 
> was not NULL anymore.
>
> That's strange, or maybe I have misunderstood the argument passing 
> mechanism.
>
>
Hi Lyre,
I can see your point and since you're having different version of php
it's possible the version I'm having had a bug that xpath was not empty
string. I guess passing mechanism could change in next versions of PHP
so I'm not saying that it's bad or anything. I'm just saying I didn't
run into those issues myself but since your patch fixes the issue for
you and it didn't break anything on my setup, then I guess it's good and
I pushed it to the repository already.

Michal

-- 
Michal Novotny <minovotn@xxxxxxxxxx>, RHCE
Virtualization Team (xen userspace), Red Hat

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]