Bug 582144
Summary: | $g->aug_set doesn't allow a NULL value | |||
---|---|---|---|---|
Product: | [Fedora] Fedora EPEL | Reporter: | Matthew Booth <mbooth> | |
Component: | libguestfs | Assignee: | Richard W.M. Jones <rjones> | |
Status: | CLOSED ERRATA | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | |
Severity: | medium | Docs Contact: | ||
Priority: | low | |||
Version: | el5 | CC: | jzheng, mbooth, rjones, virt-maint | |
Target Milestone: | --- | |||
Target Release: | --- | |||
Hardware: | All | |||
OS: | Linux | |||
Whiteboard: | ||||
Fixed In Version: | libguestfs-1.2.11-1.2.el5 | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | ||
Clone Of: | ||||
: | 582173 (view as bug list) | Environment: | ||
Last Closed: | 2010-09-03 21:57:22 UTC | Type: | --- | |
Regression: | --- | Mount Type: | --- | |
Documentation: | --- | CRM: | ||
Verified Versions: | Category: | --- | ||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
Cloudforms Team: | --- | Target Upstream Version: | ||
Embargoed: | ||||
Bug Depends On: | ||||
Bug Blocks: | 582173 |
Description
Matthew Booth
2010-04-14 09:16:04 UTC
Upstream fix: http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=66477d07e37ffe66cd6fea1105dd92b616d3cd27 libguestfs-1.2.2-1.el5.6 has been submitted as an update for Fedora EPEL 5. http://admin.fedoraproject.org/updates/libguestfs-1.2.2-1.el5.6 libguestfs-1.2.2-1.el5.6 has been pushed to the Fedora EPEL 5 testing repository. If problems still persist, please make note of it in this bug report. If you want to test the update, you can install it with su -c 'yum --enablerepo=updates-testing update libguestfs'. You can provide feedback for this update here: http://admin.fedoraproject.org/updates/libguestfs-1.2.2-1.el5.6 In my knowledge perl does not have a definition for 'NULL' as in other languages. Usually perl scripts uses empty string as replacement. Although we can pass a real NULL through C or python to aug_set, it results in an error because aug_set does not accept NULL. I can verify this as I said in bug 582173, and with the package provided in comment 2 the aug_clear API is available for us to delete the value associated with the node. (In reply to comment #4) > In my knowledge perl does not have a definition for 'NULL' as in other > languages. Usually perl scripts uses empty string as replacement. This isn't true. In Perl, undef is different from the empty string "". > Although we can pass a real NULL through C or python to aug_set, it results in > an error because aug_set does not accept NULL. The issue wasn't with Perl. It was an issue in the RPC protocol that we use between the library and the daemon. We incorrectly used the XDR "string<>" type to represent the second parameter to aug_set. However the XDR "string<>" type is not a nullable type (you cannot pass a NULL), and we cannot change this without breaking the ABI between the library and daemon. Therefore we had to introduce another API call (aug_clear) which sets the named node to NULL. By using both aug_set and aug_clear you can now set a node either to a string value (including the empty string) _or_ to NULL. For details, see: libguestfs/src/guestfs_protocol.x struct guestfs_aug_set_args vs struct guestfs_aug_clear_args (In reply to comment #5) > (In reply to comment #4) > > In my knowledge perl does not have a definition for 'NULL' as in other > > languages. Usually perl scripts uses empty string as replacement. > > This isn't true. In Perl, undef is different from the empty string "". I see. But what happens if we pass undef? Does perl translate it to empty string since it's expecting a string that is not nullable? (In reply to comment #6) > (In reply to comment #5) > > (In reply to comment #4) > > > In my knowledge perl does not have a definition for 'NULL' as in other > > > languages. Usually perl scripts uses empty string as replacement. > > > > This isn't true. In Perl, undef is different from the empty string "". > > I see. But what happens if we pass undef? Does perl translate it to empty > string since it's expecting a string that is not nullable? Yes, sometimes. In the underlying C API, if you call: guestfs_aug_set (g, "/foo", NULL); then you would either get a segfault (in the stable branch and in RHEL) or you would get an error message (in the development branch, see bug 501893 and [1]). In Perl it's depends on how the function parameter was declared in the generator[2]. If the parameter was declared as String, then the Perl bindings translate undef -> "". If the parameter was declared as OptString, then the Perl bindings pass through undef as NULL to the C binding and any string as a string. You can probably most easily see the difference in a test script. First using add_drive where the parameter is declared as String: $ perl -MSys::Guestfs -w -e '$g = Sys::Guestfs->new (); $g->add_drive (undef);' Use of uninitialized value in subroutine entry at -e line 1. : No such file or directory at -e line 1. Second using set_path where the parameter is declared as OptString; $ perl -MSys::Guestfs -w -e '$g = Sys::Guestfs->new (); $g->set_path (undef);' One possible bug/improvement here would be to catch the case where undef is passed to a String parameter, since the implicit conversion of undef -> "" in Perl is never useful or intentional. [1] http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=30c091f49dafab4ca9c8b6640d19fc0450b15971 [2] http://git.annexia.org/?p=libguestfs.git;a=blob;f=src/generator.ml;h=d640343e7a407543401dc30c58451f7c6e7a74ae;hb=HEAD#l1258 libguestfs-1.2.9-1.el5.2 has been submitted as an update for Fedora EPEL 5. http://admin.fedoraproject.org/updates/libguestfs-1.2.9-1.el5.2 libguestfs-1.2.9-1.el5.2 has been pushed to the Fedora EPEL 5 testing repository. If problems still persist, please make note of it in this bug report. If you want to test the update, you can install it with su -c 'yum --enablerepo=updates-testing update libguestfs'. You can provide feedback for this update here: http://admin.fedoraproject.org/updates/libguestfs-1.2.9-1.el5.2 (In reply to comment #8) > libguestfs-1.2.9-1.el5.2 has been submitted as an update for Fedora EPEL 5. > http://admin.fedoraproject.org/updates/libguestfs-1.2.9-1.el5.2 The aug_clear API is included in this version, so move to VERIFIED. $ rpm -q libguestfs libguestfs-1.2.9-1.el5.2 $ guestfish help aug_clear NAME aug-clear - clear Augeas path SYNOPSIS aug-clear augpath DESCRIPTION Set the value associated with "path" to "NULL". This is the same as the augtool(1) "clear" command. libguestfs-1.2.10-1.el5 has been submitted as an update for Fedora EPEL 5. http://admin.fedoraproject.org/updates/libguestfs-1.2.10-1.el5 libguestfs-1.2.10-1.el5 has been pushed to the Fedora EPEL 5 testing repository. If problems still persist, please make note of it in this bug report. If you want to test the update, you can install it with su -c 'yum --enablerepo=updates-testing update libguestfs'. You can provide feedback for this update here: http://admin.fedoraproject.org/updates/libguestfs-1.2.10-1.el5 # rpm -q libguestfs libguestfs-1.2.10-1.el5 # guestfish help aug-clear NAME aug-clear - clear Augeas path SYNOPSIS aug-clear augpath DESCRIPTION Set the value associated with "path" to "NULL". This is the same as the augtool(1) "clear" command. Move to VERIFIED again.. libguestfs-1.2.11-1.2.el5 has been submitted as an update for Fedora EPEL 5. http://admin.fedoraproject.org/updates/libguestfs-1.2.11-1.2.el5 libguestfs-1.2.11-1.2.el5 has been pushed to the Fedora EPEL 5 testing repository. If problems still persist, please make note of it in this bug report. If you want to test the update, you can install it with su -c 'yum --enablerepo=updates-testing update libguestfs'. You can provide feedback for this update here: http://admin.fedoraproject.org/updates/libguestfs-1.2.11-1.2.el5 # rpm -q libguestfs libguestfs-1.2.11-1.2.el5 # guestfish help aug-clear NAME aug-clear - clear Augeas path SYNOPSIS aug-clear augpath DESCRIPTION Set the value associated with "path" to "NULL". This is the same as the augtool(1) "clear" command. # guestfish -i test.img ... ><fs> aug-get /files/etc/passwd/root/home /root ><fs> aug-clear /files/etc/passwd/root/home ><fs> aug-get /files/etc/passwd/root/home libguestfs: error: aug_get: Augeas returned NULL match According to the test above, the aug_clear API is verified to effectively erase a value associated with a node. libguestfs-1.2.11-1.2.el5 has been pushed to the Fedora EPEL 5 stable repository. If problems still persist, please make note of it in this bug report. |