[libvirt] [PATCH] Fix bugzilla link in virsh man page

Note, I haven't generated a new virsh.1 because Pod::Man 2.16 gives a bunch of warnings even with the existing version. Signed-off-by: Mark McLoughlin <markmc@redhat.com> --- docs/virsh.pod | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/virsh.pod b/docs/virsh.pod index 8b42ea0..58bba6b 100644 --- a/docs/virsh.pod +++ b/docs/virsh.pod @@ -540,9 +540,9 @@ L<virt-install(1)>, L<xm(1)>, L<virt-top(1)>, L<virt-mem(1)>, L<virt-df(1)>, L<h =head1 BUGS -Bugs can be view on the RedHat bugzilla page under the libvirt +Bugs can be filed in Red Hat bugzilla under the Virtualization Tools/libvirt L<https://bugzilla.redhat.com/> -L<https://bugzilla.redhat.com/bugzilla/buglist.cgi?product=Fedora+Core&component=libvirt&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=MODIFIED&short_desc_type=allwordssubstr&short_desc=&long_desc_type=allwordssubstr> +L<https://bugzilla.redhat.com/buglist.cgi?product=Virtualization+Tools&component=libvirt&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED> =end -- 1.6.0.6

It looks like these functions have never existed. Signed-off-by: Mark McLoughlin <markmc@redhat.com> --- src/xml.h | 8 -------- 1 files changed, 0 insertions(+), 8 deletions(-) diff --git a/src/xml.h b/src/xml.h index 0daa874..da9d3b5 100644 --- a/src/xml.h +++ b/src/xml.h @@ -21,14 +21,6 @@ int virXPathNumber (virConnectPtr conn, const char *xpath, xmlXPathContextPtr ctxt, double *value); -int virXPathInt (virConnectPtr conn, - const char *xpath, - xmlXPathContextPtr ctxt, - int *value); -int virXPathUInt (virConnectPtr conn, - const char *xpath, - xmlXPathContextPtr ctxt, - unsigned int *value); int virXPathLong (virConnectPtr conn, const char *xpath, xmlXPathContextPtr ctxt, -- 1.6.0.6

Just some copy-and-paste mixups. Signed-off-by: Mark McLoughlin <markmc@redhat.com> --- src/xml.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/xml.c b/src/xml.c index ad77eca..9c27a10 100644 --- a/src/xml.c +++ b/src/xml.c @@ -140,7 +140,7 @@ virXPathLong(virConnectPtr conn, if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { virXMLError(conn, VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid parameter to virXPathNumber()")); + "%s", _("Invalid parameter to virXPathLong()")); return (-1); } relnode = ctxt->node; @@ -195,7 +195,7 @@ virXPathULong(virConnectPtr conn, if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { virXMLError(conn, VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid parameter to virXPathNumber()")); + "%s", _("Invalid parameter to virXPathULong()")); return (-1); } relnode = ctxt->node; -- 1.6.0.6

Re-factor the code from networkEnableIpForwarding() into a utility function in preparation for code which writes to sysfs files. Signed-off-by: Mark McLoughlin <markmc@redhat.com> --- src/libvirt_private.syms | 1 + src/network_driver.c | 26 ++------------------------ src/util.c | 24 ++++++++++++++++++++++++ src/util.h | 2 ++ 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4338da7..9e9b3e5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -279,6 +279,7 @@ virCondBroadcast; # util.h virFileReadAll; +virFileWriteStr; virStrToLong_i; virStrToLong_ll; virStrToLong_ull; diff --git a/src/network_driver.c b/src/network_driver.c index 4138939..b256e3d 100644 --- a/src/network_driver.c +++ b/src/network_driver.c @@ -794,33 +794,11 @@ networkRemoveIptablesRules(struct network_driver *driver, iptablesSaveRules(driver->iptables); } -/* Enable IP Forwarding. - Return 0 for success, nonzero for failure. - Be careful to preserve any errno value upon failure. */ +/* Enable IP Forwarding. Return 0 for success, nonzero for failure. */ static int networkEnableIpForwarding(void) { -#define PROC_IP_FORWARD "/proc/sys/net/ipv4/ip_forward" - - int fd; - - if ((fd = open(PROC_IP_FORWARD, O_WRONLY|O_TRUNC)) == -1) - return 0; - - if (safewrite(fd, "1\n", 2) < 0) { - int saved_errno = errno; - close (fd); - errno = saved_errno; - return 0; - } - - /* Use errno from failed close only if there was no write error. */ - if (close (fd) != 0) - return 0; - - return 1; - -#undef PROC_IP_FORWARD + return virFileWriteStr("/proc/sys/net/ipv4/ip_forward", "1\n"); } static int networkStartNetworkDaemon(virConnectPtr conn, diff --git a/src/util.c b/src/util.c index 01fe37a..990433a 100644 --- a/src/util.c +++ b/src/util.c @@ -774,6 +774,30 @@ int virFileReadAll(const char *path, int maxlen, char **buf) return len; } +/* Truncate @path and write @str to it. + Return 0 for success, nonzero for failure. + Be careful to preserve any errno value upon failure. */ +int virFileWriteStr(const char *path, const char *str) +{ + int fd; + + if ((fd = open(path, O_WRONLY|O_TRUNC)) == -1) + return -1; + + if (safewrite(fd, str, strlen(str)) < 0) { + int saved_errno = errno; + close (fd); + errno = saved_errno; + return -1; + } + + /* Use errno from failed close only if there was no write error. */ + if (close (fd) != 0) + return -1; + + return 0; +} + int virFileMatchesNameSuffix(const char *file, const char *name, const char *suffix) diff --git a/src/util.h b/src/util.h index 4667b92..a79cfa7 100644 --- a/src/util.h +++ b/src/util.h @@ -56,6 +56,8 @@ int virFileReadLimFD(int fd, int maxlen, char **buf); int virFileReadAll(const char *path, int maxlen, char **buf); +int virFileWriteStr(const char *path, const char *str); + int virFileMatchesNameSuffix(const char *file, const char *name, const char *suffix); -- 1.6.0.6

On Fri, Feb 13, 2009 at 12:06:12PM +0000, Mark McLoughlin wrote:
Re-factor the code from networkEnableIpForwarding() into a utility function in preparation for code which writes to sysfs files.
Signed-off-by: Mark McLoughlin <markmc@redhat.com> --- src/libvirt_private.syms | 1 + src/network_driver.c | 26 ++------------------------ src/util.c | 24 ++++++++++++++++++++++++ src/util.h | 2 ++ 4 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4338da7..9e9b3e5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -279,6 +279,7 @@ virCondBroadcast;
# util.h virFileReadAll; +virFileWriteStr; virStrToLong_i; virStrToLong_ll; virStrToLong_ull; diff --git a/src/network_driver.c b/src/network_driver.c index 4138939..b256e3d 100644 --- a/src/network_driver.c +++ b/src/network_driver.c @@ -794,33 +794,11 @@ networkRemoveIptablesRules(struct network_driver *driver, iptablesSaveRules(driver->iptables); }
-/* Enable IP Forwarding. - Return 0 for success, nonzero for failure. - Be careful to preserve any errno value upon failure. */ +/* Enable IP Forwarding. Return 0 for success, nonzero for failure. */ static int networkEnableIpForwarding(void) { -#define PROC_IP_FORWARD "/proc/sys/net/ipv4/ip_forward" - - int fd; - - if ((fd = open(PROC_IP_FORWARD, O_WRONLY|O_TRUNC)) == -1) - return 0; - - if (safewrite(fd, "1\n", 2) < 0) { - int saved_errno = errno; - close (fd); - errno = saved_errno; - return 0; - } - - /* Use errno from failed close only if there was no write error. */ - if (close (fd) != 0) - return 0; - - return 1; - -#undef PROC_IP_FORWARD + return virFileWriteStr("/proc/sys/net/ipv4/ip_forward", "1\n"); }
static int networkStartNetworkDaemon(virConnectPtr conn, diff --git a/src/util.c b/src/util.c index 01fe37a..990433a 100644 --- a/src/util.c +++ b/src/util.c @@ -774,6 +774,30 @@ int virFileReadAll(const char *path, int maxlen, char **buf) return len; }
+/* Truncate @path and write @str to it. + Return 0 for success, nonzero for failure. + Be careful to preserve any errno value upon failure. */ +int virFileWriteStr(const char *path, const char *str) +{ + int fd; + + if ((fd = open(path, O_WRONLY|O_TRUNC)) == -1) + return -1; + + if (safewrite(fd, str, strlen(str)) < 0) { + int saved_errno = errno; + close (fd); + errno = saved_errno; + return -1; + } + + /* Use errno from failed close only if there was no write error. */ + if (close (fd) != 0) + return -1; + + return 0; +} + int virFileMatchesNameSuffix(const char *file, const char *name, const char *suffix) diff --git a/src/util.h b/src/util.h index 4667b92..a79cfa7 100644 --- a/src/util.h +++ b/src/util.h @@ -56,6 +56,8 @@ int virFileReadLimFD(int fd, int maxlen, char **buf);
int virFileReadAll(const char *path, int maxlen, char **buf);
+int virFileWriteStr(const char *path, const char *str); + int virFileMatchesNameSuffix(const char *file, const char *name, const char *suffix); --
ACK. You might like to make virCgroupSetValueStr() use this new method too, since it has more or less this same exact code. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Fri, 2009-02-13 at 12:06 +0000, Mark McLoughlin wrote:
static int networkEnableIpForwarding(void) { ... - return 1; - -#undef PROC_IP_FORWARD + return virFileWriteStr("/proc/sys/net/ipv4/ip_forward", "1\n");
networkEnableIpForwarding() used to return 1 on success, now it is returning zero. I'm commiting the change below to fix it. Cheers, Mark. diff --git a/src/network_driver.c b/src/network_driver.c index b256e3d..3c765c8 100644 --- a/src/network_driver.c +++ b/src/network_driver.c @@ -794,7 +794,7 @@ networkRemoveIptablesRules(struct network_driver *driver, iptablesSaveRules(driver->iptables); } -/* Enable IP Forwarding. Return 0 for success, nonzero for failure. */ +/* Enable IP Forwarding. Return 0 for success, -1 for failure. */ static int networkEnableIpForwarding(void) { @@ -853,7 +853,7 @@ static int networkStartNetworkDaemon(virConnectPtr conn, goto err_delbr1; if (network->def->forwardType != VIR_NETWORK_FORWARD_NONE && - !networkEnableIpForwarding()) { + networkEnableIpForwarding() < 0) { virReportSystemError(conn, errno, "%s", _("failed to enable IP forwarding")); goto err_delbr2;

On Fri, Feb 13, 2009 at 12:06:11PM +0000, Mark McLoughlin wrote:
Just some copy-and-paste mixups.
Signed-off-by: Mark McLoughlin <markmc@redhat.com> --- src/xml.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/xml.c b/src/xml.c index ad77eca..9c27a10 100644 --- a/src/xml.c +++ b/src/xml.c @@ -140,7 +140,7 @@ virXPathLong(virConnectPtr conn,
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { virXMLError(conn, VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid parameter to virXPathNumber()")); + "%s", _("Invalid parameter to virXPathLong()")); return (-1); } relnode = ctxt->node; @@ -195,7 +195,7 @@ virXPathULong(virConnectPtr conn,
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { virXMLError(conn, VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid parameter to virXPathNumber()")); + "%s", _("Invalid parameter to virXPathULong()")); return (-1); } relnode = ctxt->node;
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Fri, Feb 13, 2009 at 12:06:10PM +0000, Mark McLoughlin wrote:
It looks like these functions have never existed.
They did at one point in my out of tree patches for some feature, but guess I removed them and forget the header before finally comitting.
diff --git a/src/xml.h b/src/xml.h index 0daa874..da9d3b5 100644 --- a/src/xml.h +++ b/src/xml.h @@ -21,14 +21,6 @@ int virXPathNumber (virConnectPtr conn, const char *xpath, xmlXPathContextPtr ctxt, double *value); -int virXPathInt (virConnectPtr conn, - const char *xpath, - xmlXPathContextPtr ctxt, - int *value); -int virXPathUInt (virConnectPtr conn, - const char *xpath, - xmlXPathContextPtr ctxt, - unsigned int *value); int virXPathLong (virConnectPtr conn, const char *xpath, xmlXPathContextPtr ctxt,
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Fri, Feb 13, 2009 at 12:06:09PM +0000, Mark McLoughlin wrote:
Note, I haven't generated a new virsh.1 because Pod::Man 2.16 gives a bunch of warnings even with the existing version.
Which Perl version does that correspond to ? FWIW, the pod2man on Fedora 9, perl-5.10.0-40.fc9.i386 generates without any warnings.
diff --git a/docs/virsh.pod b/docs/virsh.pod index 8b42ea0..58bba6b 100644 --- a/docs/virsh.pod +++ b/docs/virsh.pod @@ -540,9 +540,9 @@ L<virt-install(1)>, L<xm(1)>, L<virt-top(1)>, L<virt-mem(1)>, L<virt-df(1)>, L<h
=head1 BUGS
-Bugs can be view on the RedHat bugzilla page under the libvirt +Bugs can be filed in Red Hat bugzilla under the Virtualization Tools/libvirt L<https://bugzilla.redhat.com/>
-L<https://bugzilla.redhat.com/bugzilla/buglist.cgi?product=Fedora+Core&component=libvirt&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=MODIFIED&short_desc_type=allwordssubstr&short_desc=&long_desc_type=allwordssubstr> +L<https://bugzilla.redhat.com/buglist.cgi?product=Virtualization+Tools&component=libvirt&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED>
=end --
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (2)
-
Daniel P. Berrange
-
Mark McLoughlin