[libvirt] [PATCH] virNetDevBandwidthClear: Improve error handling
by Martin Kletzander
Two changes are introduced in this patch. The first change removes
ATTRIBUTE_RETURN_CHECK from virNetDevBandwidthClear, because it was
called with ignore_value always, anyway. The function is used even
when it's not necessary to call it, just for cleanup purposes. The
second change is an added parameter "ignore_error" for the same
function, which basically means "Ignore any errors from the commands
that will be run". This parameter, when true, doesn't suppress any
libvirt errors, just the exit value of commands ran.
---
src/network/bridge_driver.c | 4 ++--
src/util/virnetdevbandwidth.c | 15 ++++++++++-----
src/util/virnetdevbandwidth.h | 6 +++---
3 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 0e38016..f153cdd 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2161,7 +2161,7 @@ networkStartNetworkVirtual(struct network_driver *driver,
return 0;
err5:
- ignore_value(virNetDevBandwidthClear(network->def->bridge));
+ virNetDevBandwidthClear(network->def->bridge, true);
err4:
if (!save_err)
@@ -2206,7 +2206,7 @@ networkStartNetworkVirtual(struct network_driver *driver,
static int networkShutdownNetworkVirtual(struct network_driver *driver,
virNetworkObjPtr network)
{
- ignore_value(virNetDevBandwidthClear(network->def->bridge));
+ virNetDevBandwidthClear(network->def->bridge, true);
if (network->radvdPid > 0) {
char *radvdpidbase;
diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c
index b23ccd3..98f6b68 100644
--- a/src/util/virnetdevbandwidth.c
+++ b/src/util/virnetdevbandwidth.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 Red Hat, Inc.
+ * Copyright (C) 2009-2012 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -69,7 +69,7 @@ virNetDevBandwidthSet(const char *ifname,
goto cleanup;
}
- ignore_value(virNetDevBandwidthClear(ifname));
+ virNetDevBandwidthClear(ifname, true);
if (bandwidth->in) {
if (virAsprintf(&average, "%llukbps", bandwidth->in->average) < 0)
@@ -163,15 +163,19 @@ cleanup:
* Return 0 on success, -1 otherwise.
*/
int
-virNetDevBandwidthClear(const char *ifname)
+virNetDevBandwidthClear(const char *ifname, bool ignore_error)
{
int ret = 0;
+ int exitstatus, *es = NULL;
virCommandPtr cmd = NULL;
+ if (ignore_error)
+ es = &exitstatus;
+
cmd = virCommandNew(TC);
virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "root", NULL);
- if (virCommandRun(cmd, NULL) < 0)
+ if (virCommandRun(cmd, es) < 0)
ret = -1;
virCommandFree(cmd);
@@ -179,8 +183,9 @@ virNetDevBandwidthClear(const char *ifname)
cmd = virCommandNew(TC);
virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "ingress", NULL);
- if (virCommandRun(cmd, NULL) < 0)
+ if (virCommandRun(cmd, es) < 0)
ret = -1;
+
virCommandFree(cmd);
return ret;
diff --git a/src/util/virnetdevbandwidth.h b/src/util/virnetdevbandwidth.h
index 18384ae..f15b489 100644
--- a/src/util/virnetdevbandwidth.h
+++ b/src/util/virnetdevbandwidth.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 Red Hat, Inc.
+ * Copyright (C) 2009-2012 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -43,8 +43,8 @@ void virNetDevBandwidthFree(virNetDevBandwidthPtr def);
int virNetDevBandwidthSet(const char *ifname, virNetDevBandwidthPtr bandwidth)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
-int virNetDevBandwidthClear(const char *ifname)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
+int virNetDevBandwidthClear(const char *ifname, bool ignore_error)
+ ATTRIBUTE_NONNULL(1);
int virNetDevBandwidthCopy(virNetDevBandwidthPtr *dest, const virNetDevBandwidthPtr src)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
--
1.7.12
12 years, 3 months
[libvirt] [PATCH] secret: Fix error for private secrets
by Martin Kletzander
When trying to get the value of a private secret, the code used
'operation denied' error. That error is specified as an error for
read-only connections trying to perform denied operation. The
following error seems more accurate.
To compare the difference:
- BEFORE
error: operation secret is private forbidden for read only access
- AFTER
error: Invalid secret: secret is private
---
src/secret/secret_driver.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index 2ad66dd..67c7323 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -1,7 +1,7 @@
/*
* secret_driver.c: local driver for secret manipulation API
*
- * Copyright (C) 2009-2011 Red Hat, Inc.
+ * Copyright (C) 2009-2012 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -990,7 +990,7 @@ secretGetValue(virSecretPtr obj, size_t *value_size, unsigned int flags,
if ((internalFlags & VIR_SECRET_GET_VALUE_INTERNAL_CALL) == 0 &&
secret->def->private) {
- virReportError(VIR_ERR_OPERATION_DENIED, "%s",
+ virReportError(VIR_ERR_INVALID_SECRET, "%s",
_("secret is private"));
goto cleanup;
}
--
1.7.12
12 years, 3 months
[libvirt] [PATCH] syntax-check: fix run.in
by Martin Kletzander
Two more problems in "run.in" made the syntax-check fail.
---
Pushed under the 'build-breaker' rule.
cfg.mk | 2 +-
run.in | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 0dd58df..bbfd4a2 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -789,7 +789,7 @@ exclude_file_name_regexp--sc_prohibit_newline_at_end_of_diagnostic = \
^src/rpc/gendispatch\.pl$$
exclude_file_name_regexp--sc_prohibit_nonreentrant = \
- ^((po|tests)/|docs/.*py$$)
+ ^((po|tests)/|docs/.*py|run.in$$)
exclude_file_name_regexp--sc_prohibit_raw_allocation = \
^(src/util/memory\.[ch]|examples/.*)$$
diff --git a/run.in b/run.in
index 83c1785..f7d30ca 100644
--- a/run.in
+++ b/run.in
@@ -1,6 +1,6 @@
#!/bin/bash -
# libvirt 'run' programs locally script
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
--
1.7.12
12 years, 3 months
[libvirt] [PATCH] Adhere to copyright_address check
by Guido Günther
to fix "make syntax-check"
Found by http://honk.sigxcpu.org:8001/job/libvirt-syntax-check/
---
run.in | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/run.in b/run.in
index 7700e52..83c1785 100644
--- a/run.in
+++ b/run.in
@@ -13,8 +13,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# along with this program; If not, see <http://www.gnu.org/licenses/>.
#----------------------------------------------------------------------
#
--
1.7.10.4
12 years, 3 months
[libvirt] [PATCH] qemuhelptest: convert runaway tab to spaces
by Ján Tomko
Make syntax-check happy and smiling again.
---
tests/qemuhelptest.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 5c6ecd5..a3d9656 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -845,7 +845,7 @@ mymain(void)
QEMU_CAPS_SCSI_LSI,
QEMU_CAPS_VIRTIO_SCSI_PCI,
QEMU_CAPS_BLOCKIO,
- QEMU_CAPS_SCSI_DISK_WWN,
+ QEMU_CAPS_SCSI_DISK_WWN,
QEMU_CAPS_SECCOMP_SANDBOX);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
--
1.7.8.6
12 years, 3 months
[libvirt] [libvirt-glib][PATCH] autobuild: Init AUTOBUILD_INSTALL_ROOT variable
by Michal Privoznik
Otherwise autobuild sets prefix to / resulting in
Permission denied when building as non-root as
'make install' tries to write to /lib. We need to
set this var to accessible path like $HOME/builder.
---
autobuild.sh | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/autobuild.sh b/autobuild.sh
index 3675249..053dc1f 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -4,6 +4,7 @@ set -e
set -v
test -n "$1" && RESULTS=$1 || RESULTS=results.log
+: ${AUTOBUILD_INSTALL_ROOT=$HOME/builder}
# Make things clean.
test -f Makefile && make -k distclean || :
--
1.7.8.6
12 years, 3 months
[libvirt] [PATCH 00/10] new virNetworkUpdate API
by Laine Stump
This patchset implements a new API function called virNetworkUpdate
which enables updating certain parts of a libvirt network's definition
without the need to destroy/re-start the network. This is especially
useful, for example, to add/remove hosts from the dhcp static hosts
table, or change portgroup settings.
This was previously discussed in this thread:
https://www.redhat.com/archives/libvir-list/2012-August/msg01535.html
continuing here in September:
https://www.redhat.com/archives/libvir-list/2012-September/msg00328.html
with the final form here:
https://www.redhat.com/archives/libvir-list/2012-September/msg00465.html
In short, the single function has a "section" specifier which tells
the part of the network definition to be updated, a "parentIndex" that
gives the index of the *parent* element containing this section (when
there are multiples - in particular in the case of the <ip> element),
and a fully formed XML element which will be added as-is in the case
of VIR_NETWORK_UPDATE_ADD_* (after checking for a duplicate), used to
search for the specific element to delete in case of
VIR_NETWORK_UPDATE_DELETE, and used both to find the existing element
and replace its current contents in the case of VIR_UPDATE_EXISTING
(this implies that you can't change the change the attribute used for
indexing, e.g. the name of a portgroup, or mac address of a dhcp host
entry).
An example of use: to add a dhcp host entry to network "net", you would do this:
virNetworkUpdate(net, VIR_NETWORK_SECTION_IP_DHCP_HOST, -1,
"<host mac='00:11:22:33:44:55' ip='192.168.122.5'/>",
VIR_NETWORK_UPDATE_AFFECT_LIVE
| VIR_NETWORK_UPDATE_AFFECT_CONFIG
| VIR_NETWORK_UPDATE_ADD_LAST);
To delete that same entry:
virNetworkUpdate(net, VIR_NETWORK_SECTION_IP_DHCP_HOST, -1,
"<host mac='00:11:22:33:44:55'/>",
VIR_NETWORK_UPDATE_AFFECT_LIVE
| VIR_NETWORK_UPDATE_AFFECT_CONFIG
| VIR_NETWORK_UPDATE_DELETE);
If you wanted to force any of these to affect the dhcp host list in
the 3rd <ip> element of the network, you would replace "-1" with "2".
Another example: to modify the portgroup named "engineering" (e.g. to
increase the inbound average bandwidth from 1000 to 2000):
virNetworkUpdate(net, VIR_NETWORK_SECTION_PORTGROUP, -1,
"<portgroup name='engineering' default='yes'>"
" <virtualport type='802.1Qbh'>"
" <parameters profileid='test'/>"
" </virtualport>"
" <bandwidth>"
" <inbound average='2000' peak='5000' burst='5120'/>"
" <outbound average='1000' peak='5000' burst='5120'/>"
" </bandwidth>"
"</portgroup>",
VIR_NETWORK_UPDATE_EXISTING | VIR_NETWORK_UPDATE_LIVE
| VIR_NETWORK_UPDATE_CONFIG)
(note that parentIndex is irrelevant for PORTGROUP, since they are in
the toplevel of <network>, so there aren't multiple instances of
parents. In such cases, the caller *must* set parentIndex to -1 or 0 -
any other value indicates that they don't understand the purpose/usage
of parentIndex, so it must result in an error. Also note that the
above function would fail if it couldn't find an existing portgroup
with name='engineering' (i.e. it wouldn't automatically add a new one).)
Adding support for each of the different sections has been reduced to
a single function that handles the update of a virNetworkDef; all the
logic to determine which virNetworkDef (def or newDef) and to
restart/SIGHUP the appropriate daemons is in higher levels and is 100%
complete. The low level functions aren't yet finished, although the
function for IP_DHCP_HOST is nearly done.
As usual, several of the patches are re-factoring existing code, and a
couple are bugfixes that are only peripherally related:
1/10 - splits out parsing of dhcp related elements to separate functions
2/10 - fixes a small bug that would probably never be encountered IRL anyway
3/10+4/10 - actual API
5/10 - utility functions to simplify API implementation
6/10 - framework for backend that updates the virNetworkDef
7/10 - refactoring in bridge_driver
8/10 - virNetworkUpdate for bridge_driver
9/10 - virNetworkUpdate for test_driver
10/10 - simple troubleshooting aid - restart dnsmasq/radvd
when libvirtd is restarted (if its process is missing).
I'll try to have the following additional patches posted later today:
11/10 - backend for IP_DHCP_HOST update
12/10 - backend for PORTGROUP update
13/10 - virsh "net-update" command
Differences from email thread:
1) Aside from being actual code instead of just pseudo code, I've
changed the "index" arg into "parentIndex" to avoid confusion between
the index of the element we're looking at (e.g. which host in the list
of hosts in a <dhcp> element) and the index of the parent (e.g. which
<ip> element will contain the <dhcp> with the list of <hosts> we want
to update).
I also changed this from a unsigned into to an int so that it can hold
the special value "-1", which means "pick the most useful/only
item". Again, in the case of VIR_NETWORK_SECTION_IP_DHCP_HOST, this
would mean to pick the one <ip> element that actually has a <dhcp>
section (may not be the first, but there can only be one).
2) added VIR_NETWORK_UPDATE_AFFECT_CURRENT similar to
VIR_DOMAIN_AFFECT_CURRENT
12 years, 3 months
[libvirt] [PATCH] rpc: Fix name of member in remote_protocol-structs
by Peter Krempa
Commit 7a99b0abafb69e1686198ac3473892a9aaeb8255 adds a new RPC struct
but one of the members has different names in remote_protocol.x and
remote_protocol-struct breaking make check.
---
Pushing under build-breaker rule.
src/remote_protocol-structs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 0a9beff..4d2627a 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -981,7 +981,7 @@ struct remote_network_update_args {
remote_nonnull_network net;
u_int command;
u_int section;
- int index;
+ int parentIndex;
remote_nonnull_string xml;
u_int flags;
};
--
1.7.12
12 years, 3 months
[libvirt] Add a ./run script for running programs from the local directory.
by Richard W.M. Jones
In libguestfs we successfully use a ./run script which sets up the
environment so you can run libguestfs programs (internal and external
ones, in C and non-C) without needing to install anything. This adds
a similar script for libvirt.
Here is the documentation included in the script:
# With this script you can run libvirt programs without needing to
# install them first. You just have to do for example:
#
# ./run ./tools/virsh [args ...]
#
# If you are already in the tools/ subdirectory, then the following
# command will also work:
#
# ../run ./virsh [...]
#
# You can also run the C programs under valgrind like this:
#
# ./run valgrind [valgrind opts...] ./program
#
# or under gdb:
#
# ./run gdb --args ./program
#
# This also works with sudo (eg. if you need root access for libvirt):
#
# sudo ./run ./tools/virsh list --all
12 years, 3 months