[libvirt] [libvirt-designer][PATCH] virtxml: Rename to virt-designer
by Michal Privoznik
Our example utility is called virtxml. However with Cole's latest work,
where he introduced virt-xml binary for editing libvirt XML on CLI [1].
It would be better if our example is called virt-designer so we don't
confuse users.
1: https://www.redhat.com/archives/libvir-list/2014-January/msg01226.html
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
.gitignore | 2 +-
cfg.mk | 2 +-
configure.ac | 2 +-
examples/Makefile.am | 10 +++++-----
examples/{virtxml.c => virt-designer.c} | 32 ++++++++++++++++----------------
libvirt-designer.spec.in | 4 ++--
6 files changed, 26 insertions(+), 26 deletions(-)
rename examples/{virtxml.c => virt-designer.c} (96%)
diff --git a/.gitignore b/.gitignore
index 6b05db9..09e15a5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,7 +15,7 @@ Makefile.in
/config.log
/config.status
/configure
-/examples/virtxml
+/examples/virt-designer
/libtool
/libvirt-designer-1.0.pc
/libvirt-designer.spec
diff --git a/cfg.mk b/cfg.mk
index 1e4b31d..f9ab008 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -104,7 +104,7 @@ sc_copyright_format:
prev_version_file = /dev/null
-exclude_file_name_regexp--sc_bindtextdomain = ^libvirt-designer/(test|libvirt-designer-main\.c)|^examples/virtxml\.c$$
+exclude_file_name_regexp--sc_bindtextdomain = ^libvirt-designer/(test|libvirt-designer-main\.c)|^examples/virt-designer\.c$$
exclude_file_name_regexp--sc_preprocessor_indentation = ^*/*.[ch]$$
diff --git a/configure.ac b/configure.ac
index bad199b..595fea4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,7 +96,7 @@ LIBVIRT_DESIGNER_COVERAGE
LIBVIRT_DESIGNER_INTROSPECTION
AC_ARG_ENABLE([examples],
- AS_HELP_STRING([--enable-examples], [enable virtxml example. Default is check, meaning it is enabled as long as libvirt-gobject is installed]),
+ AS_HELP_STRING([--enable-examples], [enable virt-designer example. Default is check, meaning it is enabled as long as libvirt-gobject is installed]),
[],[enable_examples=check])
if test "x$enable_examples" != "xno" ; then
diff --git a/examples/Makefile.am b/examples/Makefile.am
index ae2667e..1d8947f 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -2,10 +2,10 @@ INCLUDES = \
-I$(top_builddir)/libvirt-designer \
-I$(top_srcdir)
-virtxml_LDADD = \
+virt_designer_LDADD = \
$(top_builddir)/libvirt-designer/libvirt-designer-1.0.la
-virtxml_CFLAGS = \
+virt_designer_CFLAGS = \
$(COVERAGE_CFLAGS) \
$(LIBOSINFO_CFLAGS) \
$(LIBVIRT_GCONFIG_CFLAGS) \
@@ -13,7 +13,7 @@ virtxml_CFLAGS = \
$(LIBVIRT_GOBJECT_CFLAGS) \
$(NULL)
-virtxml_LDFLAGS = \
+virt_designer_LDFLAGS = \
$(LIBOSINFO_LIBS) \
$(LIBVIRT_GCONFIG_LIBS) \
$(LIBVIRT_GOBJECT_LIBS)
@@ -24,9 +24,9 @@ POD2MAN = pod2man -c "Virtualization Support" -r "$(PACKAGE)-$(VERSION)"
$(AM_V_GEN)$(POD2MAN) $< $@
if WITH_EXAMPLES
-bin_PROGRAMS = virtxml
+bin_PROGRAMS = virt-designer
-man1_MANS = virtxml.1
+man1_MANS = virt-designer.1
CLEANFILES = $(man1_MANS)
endif
diff --git a/examples/virtxml.c b/examples/virt-designer.c
similarity index 96%
rename from examples/virtxml.c
rename to examples/virt-designer.c
index 6fb51d5..7628449 100644
--- a/examples/virtxml.c
+++ b/examples/virt-designer.c
@@ -1,7 +1,7 @@
/*
- * virtxml.c: produce an domain XML
+ * virt-designer.c: produce an domain XML
*
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2012, 2014 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
@@ -750,26 +750,26 @@ cleanup:
=head1 NAME
-virtxml - Generate domain XML
+virt-designer - Generate domain XML
=head1 SYNOPSIS
-B<virtxml> [I<OPTION>]...
+B<virt-designer> [I<OPTION>]...
=head1 DESCRIPTION
-B<virtxml> is a command line tool for generating XML documents for
+B<virt-designer> is a command line tool for generating XML documents for
libvirt domains. However, it cooperates with libosinfo database to guess
the correct combination of attributes (e.g. disk driver, NIC model).
-B<virtxml> does not feed libvirt with generated XML though. For now,
+B<virt-designer> does not feed libvirt with generated XML though. For now,
it's a proof of concept.
=head1 OPTIONS
-The basic structure of arguments passed to B<virtxml> is:
+The basic structure of arguments passed to B<virt-designer> is:
- virtxml [-c URI] [OPTION] [OPTION] ...
+ virt-designer [-c URI] [OPTION] [OPTION] ...
However, arguments have no pre-defined order so users can type them
in any order they like.
@@ -844,7 +844,7 @@ the I<recommended> is used.
Usually, both B<--os> and B<--platform> are required as they are needed to
make the right decision on driver, model, ... when adding a new device.
However, when adding a disk which is an installation medium (e.g. a CD-ROM or
-DVD), B<virtxml> tries to guess the OS. Something similar is done with
+DVD), B<virt-designer> tries to guess the OS. Something similar is done with
platform. Usually, the platform is guessed from the connection URI.
=head1 EXAMPLES
@@ -852,16 +852,16 @@ platform. Usually, the platform is guessed from the connection URI.
Domain with Fedora 17 from locally stored ISO and one NIC with mac
00:11:22:33:44:55 and link set down:
- # virtxml -C Fedora-17-x86_64-Live-KDE.iso \
- -i default,mac=00:11:22:33:44:55,link=down
+ # virt-designer -C Fedora-17-x86_64-Live-KDE.iso \
+ -i default,mac=00:11:22:33:44:55,link=down
To add multiple devices just use appropriate argument multiple times:
- # virtxml -d /tmp/home.img,qcow2 \
- -d /var/lib/libvirt/images/f17.img,qcow2 \
- -i default,mac=00:11:22:33:44:55,link=down \
- -i blue_network \
- -r minimal
+ # virt-designer -d /tmp/home.img,qcow2 \
+ -d /var/lib/libvirt/images/f17.img,qcow2 \
+ -i default,mac=00:11:22:33:44:55,link=down \
+ -i blue_network \
+ -r minimal
=head1 AUTHORS
diff --git a/libvirt-designer.spec.in b/libvirt-designer.spec.in
index 894bcb8..fb5c70a 100644
--- a/libvirt-designer.spec.in
+++ b/libvirt-designer.spec.in
@@ -78,8 +78,8 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
-%{_bindir}/virtxml
-%{_mandir}/man1/virtxml.1*
+%{_bindir}/virt-designer
+%{_mandir}/man1/virt-designer.1*
%files libs
%defattr(-,root,root,-)
--
1.8.5.2
10 years, 10 months
[libvirt] [PATCH] qemu: Fix the error message for scsi host device's shareable checking
by Osier Yang
This fixes the wrong argument order.
---
Pushed under trivial rule.
---
src/qemu/qemu_hostdev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 2b11d6c..1b16386 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -1135,8 +1135,8 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_INVALID,
_("SCSI device %s is already in use by "
"other domain(s) as '%s'"),
- tmp_shareable ? "shareable" : "non-shareable",
- virSCSIDeviceGetName(tmp));
+ virSCSIDeviceGetName(tmp),
+ tmp_shareable ? "shareable" : "non-shareable");
goto error;
}
--
1.8.1.4
10 years, 10 months
[libvirt] [PATCH v2]Sheepdog: Auto Adding volume and correct refresh volume problem.
by joel SIMOES
From: Joel SIMOES <joel.simoes(a)laposte.net>
Correct ret return 0 on success
---
src/storage/storage_backend_sheepdog.c | 92 ++++++++++++++++++++++++++++++----
1 file changed, 82 insertions(+), 10 deletions(-)
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index a6981ce..75304b1 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -86,7 +86,8 @@ virStorageBackendSheepdogParseNodeInfo(virStoragePoolDefPtr pool,
pool->available = pool->capacity - pool->allocation;
return 0;
- } while ((p = next));
+ }
+ while ((p = next));
return -1;
}
@@ -109,6 +110,70 @@ virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
virCommandAddArgFormat(cmd, "%d", port);
}
+static int
+virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virStoragePoolObjPtr pool)
+{
+ int ret;
+ char *output = NULL;
+
+ virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "list", "-r", NULL);
+ virStorageBackendSheepdogAddHostArg(cmd, pool);
+ virCommandSetOutputBuffer(cmd, &output);
+ ret = virCommandRun(cmd, NULL);
+ char** lines;
+ char** cells;
+
+ if (ret < 0)
+ goto cleanup;
+
+ ret = -1;
+ lines = virStringSplit(output, "\n", 0);
+ size_t i;
+ for (i = 0; *(lines + i); i++) {
+ char *line = *(lines + i);
+ cells = virStringSplit(line, " ", 0);
+ size_t j;
+ for (j = 0; *(cells + j); j++) {
+
+ char *cell = *(cells + j);
+ if (j == 1) {
+ virStorageVolDefPtr vol = NULL;
+ if (VIR_ALLOC(vol) < 0)
+ goto cleanup;
+
+ if (VIR_STRDUP(vol->name, cell) < 0)
+ goto cleanup;
+
+ vol->type = VIR_STORAGE_VOL_BLOCK;
+
+ if (VIR_EXPAND_N(pool->volumes.objs, pool->volumes.count, 1) < 0)
+ goto cleanup;
+ pool->volumes.objs[pool->volumes.count - 1] = vol;
+
+ if (virStorageBackendSheepdogRefreshVol(conn, pool, vol) < 0)
+ goto cleanup;
+
+ vol = NULL;
+ }
+
+ VIR_FREE(*(cells + j));
+ }
+
+ VIR_FREE(cells);
+ VIR_FREE(*(lines + i));
+ }
+
+
+ VIR_FREE(lines);
+ ret = 0;
+
+cleanup:
+ virCommandFree(cmd);
+ VIR_FREE(lines);
+ VIR_FREE(cells);
+ return ret;
+}
static int
virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
@@ -122,15 +187,18 @@ virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
virStorageBackendSheepdogAddHostArg(cmd, pool);
virCommandSetOutputBuffer(cmd, &output);
ret = virCommandRun(cmd, NULL);
- if (ret == 0)
- ret = virStorageBackendSheepdogParseNodeInfo(pool->def, output);
+ if (ret < 0)
+ goto cleanup;
+ ret = virStorageBackendSheepdogParseNodeInfo(pool->def, output);
+ if (ret < 0)
+ goto cleanup;
+ ret = virStorageBackendSheepdogRefreshAllVol(conn, pool);
+cleanup:
virCommandFree(cmd);
- VIR_FREE(output);
return ret;
}
-
static int
virStorageBackendSheepdogDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool,
@@ -143,12 +211,14 @@ virStorageBackendSheepdogDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "delete", vol->name, NULL);
virStorageBackendSheepdogAddHostArg(cmd, pool);
int ret = virCommandRun(cmd, NULL);
+ if (ret < 0)
+ goto cleanup;
+cleanup:
virCommandFree(cmd);
return ret;
}
-
static int
virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool,
@@ -174,7 +244,6 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
return 0;
}
-
static int
virStorageBackendSheepdogBuildVol(virConnectPtr conn,
virStoragePoolObjPtr pool,
@@ -195,12 +264,12 @@ virStorageBackendSheepdogBuildVol(virConnectPtr conn,
goto cleanup;
ret = 0;
+
cleanup:
virCommandFree(cmd);
return ret;
}
-
int
virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol,
char *output)
@@ -257,7 +326,8 @@ virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol,
return -1;
return 0;
- } while ((p = next));
+ }
+ while ((p = next));
return -1;
}
@@ -295,7 +365,6 @@ cleanup:
return ret;
}
-
static int
virStorageBackendSheepdogResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool,
@@ -310,7 +379,10 @@ virStorageBackendSheepdogResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virCommandAddArgFormat(cmd, "%llu", capacity);
virStorageBackendSheepdogAddHostArg(cmd, pool);
int ret = virCommandRun(cmd, NULL);
+ if (ret < 0)
+ goto cleanup;
+cleanup:
virCommandFree(cmd);
return ret;
--
1.8.3.2
10 years, 10 months
[libvirt] [PATCH 0/2 v4] qemu: Don't fail if the SCSI host device is shareable between domains
by Osier Yang
*** BLURB HERE ***
Osier Yang (2):
qemu: Don't fail if the SCSI host device is shareable between domains
tests: Add tests for scsi utils
docs/formatdomain.html.in | 5 ++
src/libvirt_private.syms | 2 +-
src/qemu/qemu_cgroup.c | 3 +-
src/qemu/qemu_command.c | 3 +-
src/qemu/qemu_command.h | 3 +-
src/qemu/qemu_conf.c | 12 ++-
src/qemu/qemu_hostdev.c | 86 ++++++++++--------
src/security/security_apparmor.c | 3 +-
src/security/security_dac.c | 6 +-
src/security/security_selinux.c | 6 +-
src/util/virscsi.c | 70 +++++++++++----
src/util/virscsi.h | 16 ++--
tests/Makefile.am | 14 +++
tests/testutilsqemu.c | 3 +-
tests/virscsitest.c | 188 +++++++++++++++++++++++++++++++++++++++
15 files changed, 344 insertions(+), 76 deletions(-)
create mode 100644 tests/virscsitest.c
--
1.8.1.4
10 years, 10 months
[libvirt] [PATCH] maint: add configure checks for BSD CPU affinity
by Roman Bogorodskiy
Check for presence of sys/cpuset.h header and cpuset_getaffinity()
in configure instead of just using #ifdef __FreeBSD__ for that code.
---
configure.ac | 10 ++++++++++
src/util/virprocess.c | 7 +++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 3a70375..1670a41 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2604,6 +2604,16 @@ AC_CHECK_DECLS([BRDGSFD, BRDGADD, BRDGDEL],
#include <net/if_bridgevar.h>
])
+# Check for BSD CPU affinity availability
+AC_CHECK_DECLS([cpuset_getaffinity],
+ [AC_DEFINE([HAVE_BSD_CPU_AFFINITY],
+ [1],
+ [whether BSD CPU affinity management is available])],
+ [],
+ [#include <sys/param.h>
+ #include <sys/cpuset.h>
+ ])
+
# Check if we need to look for ifconfig
if test "$want_ifconfig" = "yes"; then
AC_PATH_PROG([IFCONFIG_PATH], [ifconfig])
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 827143c..83d0679 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -34,11 +34,14 @@
#ifdef __FreeBSD__
# include <sys/param.h>
-# include <sys/cpuset.h>
# include <sys/sysctl.h>
# include <sys/user.h>
#endif
+#ifdef HAVE_BSD_CPU_AFFINITY
+# include <sys/cpuset.h>
+#endif
+
#include "viratomic.h"
#include "virprocess.h"
#include "virerror.h"
@@ -457,7 +460,7 @@ realloc:
return 0;
}
-#elif defined(__FreeBSD__)
+#elif defined(HAVE_BSD_CPU_AFFINITY)
int virProcessSetAffinity(pid_t pid ATTRIBUTE_UNUSED,
virBitmapPtr map)
--
1.8.4.3
10 years, 10 months
[libvirt] [PATCH] Revert "networkAllocateActualDevice: Set QoS for bridgeless networks too"
by Michal Privoznik
This reverts commit 2996e6be19a13199ded7c2aa21039cca97318e01
and some parts of 2636dc8c4de83cd37bc0680a6fbc3f6d25023bd7.
Conflicts:
tests/virnetdevbandwidthtest.c: New test has been introduced since
then.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/libvirt_private.syms | 1 -
src/network/bridge_driver.c | 25 +-----------
src/util/virnetdevbandwidth.c | 84 --------------------------------------
src/util/virnetdevbandwidth.h | 6 ---
tests/virnetdevbandwidthtest.c | 91 ------------------------------------------
5 files changed, 2 insertions(+), 205 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7655247..45f3117 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1470,7 +1470,6 @@ virNetDevBandwidthClear;
virNetDevBandwidthCopy;
virNetDevBandwidthEqual;
virNetDevBandwidthFree;
-virNetDevBandwidthMinimal;
virNetDevBandwidthPlug;
virNetDevBandwidthSet;
virNetDevBandwidthUnplug;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 6bdd1d6..0b43a67 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -3284,30 +3284,9 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
else if (portgroup && portgroup->bandwidth)
bandwidth = portgroup->bandwidth;
- /* For bridgeless networks we must take into account any QoS set to them.
- * This is, however, a bit tricky. With bridged network there are two
- * points where QoS can be set: domain's interface and the bridge. The
- * limits on those differ (in general) in which case the lower limit gets
- * into effect. For example, if domain's interface average is 10Mbps but
- * the network's is just 1Mbps, the domain will not be able to send data
- * any faster than 1Mbps. However, on bridgeless networks we can't just set
- * those two points and let kernel do its job since we have only single
- * point. Therefore, we must combine the QoS settings from both domain's
- * interface and network and choose the minimal value from pairs.
- */
- if (netdef->forward.type == VIR_NETWORK_FORWARD_PRIVATE ||
- netdef->forward.type == VIR_NETWORK_FORWARD_VEPA ||
- netdef->forward.type == VIR_NETWORK_FORWARD_PASSTHROUGH ||
- netdef->forward.type == VIR_NETWORK_FORWARD_HOSTDEV) {
- if (virNetDevBandwidthMinimal(&iface->data.network.actual->bandwidth,
- bandwidth,
- netdef->bandwidth) < 0)
- goto error;
- } else if (bandwidth &&
- virNetDevBandwidthCopy(&iface->data.network.actual->bandwidth,
- bandwidth) < 0) {
+ if (bandwidth && virNetDevBandwidthCopy(&iface->data.network.actual->bandwidth,
+ bandwidth) < 0)
goto error;
- }
/* copy appropriate vlan info to actualNet */
if (iface->vlan.nTags > 0)
diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c
index 273c2db..ed6a19d 100644
--- a/src/util/virnetdevbandwidth.c
+++ b/src/util/virnetdevbandwidth.c
@@ -27,7 +27,6 @@
#include "viralloc.h"
#include "virerror.h"
#include "virstring.h"
-#include "virutil.h"
#define VIR_FROM_THIS VIR_FROM_NONE
@@ -589,86 +588,3 @@ cleanup:
VIR_FREE(ceil);
return ret;
}
-
-static void
-virNetDevBandwidthRateMinimal(virNetDevBandwidthRatePtr result,
- virNetDevBandwidthRatePtr band1,
- virNetDevBandwidthRatePtr band2)
-{
- if (!band1 || !band2) {
- memcpy(result, band1 ? band1 : band2, sizeof(*result));
- return;
- }
-
- /* We can't do a simple MIN() here, because zero value doesn't mean the
- * narrowest limit, but an unset value. Hence we need symmetric F(a, b)
- * so that:
- * F(a, 0) = F(0, a) = a; special corner case: F(0, 0) = 0
- * F(a, b) = MIN(a, b) for a != 0 and b != 0
- */
-#define NON_ZERO_MIN(a, b) \
- ((a) && (b) ? MIN(a, b) : (a) ? (a) : (b))
-
- result->average = NON_ZERO_MIN(band1->average, band2->average);
- result->peak = NON_ZERO_MIN(band1->peak, band2->peak);
- result->floor = NON_ZERO_MIN(band1->floor, band2->floor);
- result->burst = NON_ZERO_MIN(band1->burst, band2->burst);
-}
-
-/**
- * virNetDevBandwidthMinimal:
- * @result: the minimal intersect of @band1 and @band2
- * @band1: the first bandwidth
- * @band2: the second bandwidth
- *
- * Combine the two bandwidths into one with choosing the minimal value for each
- * pair of items within bandwidth structure. The resulting bandwidth is stored
- * into @result. In case of both @band1 and @band2 being NULL pointers, the
- * @ret is set to NULL as well as there's no bandwidth to calculate (this is
- * not considered an error). The caller is responsible for freeing @result when
- * no longer needed.
- *
- * Returns 0 on success, -1 otherwise.
- */
-int
-virNetDevBandwidthMinimal(virNetDevBandwidthPtr *result,
- virNetDevBandwidthPtr band1,
- virNetDevBandwidthPtr band2)
-{
- int ret = -1;
-
- if (!band1 && !band2) {
- /* Nothing to compute */
- *result = NULL;
- return 0;
- }
-
- if (!band1 || !band2) {
- /* Sweet, one of the args is NULL. The non-NULL one
- * is our minimum then. */
- return virNetDevBandwidthCopy(result, band1 ? band1 : band2);
- }
-
- if (VIR_ALLOC(*result) < 0)
- goto cleanup;
-
- if (band1->in || band2->in) {
- if (VIR_ALLOC((*result)->in) < 0)
- goto cleanup;
-
- virNetDevBandwidthRateMinimal((*result)->in, band1->in, band2->in);
- }
-
- if (band1->out || band2->out) {
- if (VIR_ALLOC((*result)->out) < 0)
- goto cleanup;
-
- virNetDevBandwidthRateMinimal((*result)->out, band1->out, band2->out);
- }
-
- ret = 0;
-cleanup:
- if (ret < 0)
- VIR_FREE(*result);
- return ret;
-}
diff --git a/src/util/virnetdevbandwidth.h b/src/util/virnetdevbandwidth.h
index ea40df4..4606a07 100644
--- a/src/util/virnetdevbandwidth.h
+++ b/src/util/virnetdevbandwidth.h
@@ -74,10 +74,4 @@ int virNetDevBandwidthUpdateRate(const char *ifname,
unsigned long long new_rate)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
ATTRIBUTE_RETURN_CHECK;
-
-int
-virNetDevBandwidthMinimal(virNetDevBandwidthPtr *result,
- virNetDevBandwidthPtr band1,
- virNetDevBandwidthPtr band2)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
#endif /* __VIR_NETDEV_BANDWIDTH_H__ */
diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c
index 345a0dd..609deb8 100644
--- a/tests/virnetdevbandwidthtest.c
+++ b/tests/virnetdevbandwidthtest.c
@@ -62,56 +62,6 @@ struct testSetStruct {
} while (0)
static int
-testVirNetDevBandwidthMinimal(const void *data)
-{
- int ret = -1;
- const struct testMinimalStruct *info = data;
- virNetDevBandwidthPtr expected_result = NULL, result = NULL,
- band1 = NULL, band2 = NULL;
-
-
- /* Parse given XMLs */
- PARSE(info->expected_result, expected_result);
- PARSE(info->band1, band1);
- PARSE(info->band2, band2);
-
- if (virNetDevBandwidthMinimal(&result, band1, band2) < 0)
- goto cleanup;
-
- if (!virNetDevBandwidthEqual(expected_result, result)) {
- virBuffer exp_buf = VIR_BUFFER_INITIALIZER,
- res_buf = VIR_BUFFER_INITIALIZER;
- char *exp = NULL, *res = NULL;
-
- fprintf(stderr, "expected_result != result");
-
- if (virNetDevBandwidthFormat(expected_result, &exp_buf) < 0 ||
- virNetDevBandwidthFormat(result, &res_buf) < 0 ||
- !(exp = virBufferContentAndReset(&exp_buf)) ||
- !(res = virBufferContentAndReset(&res_buf))) {
- fprintf(stderr, "Failed to fail");
- virBufferFreeAndReset(&exp_buf);
- virBufferFreeAndReset(&res_buf);
- VIR_FREE(exp);
- VIR_FREE(res);
- goto cleanup;
- }
-
- virtTestDifference(stderr, exp, res);
- VIR_FREE(exp);
- VIR_FREE(res);
- }
-
- ret = 0;
-cleanup:
- virNetDevBandwidthFree(expected_result);
- virNetDevBandwidthFree(result);
- virNetDevBandwidthFree(band1);
- virNetDevBandwidthFree(band2);
- return ret;
-}
-
-static int
testVirNetDevBandwidthSet(const void *data)
{
int ret = -1;
@@ -159,15 +109,6 @@ mymain(void)
{
int ret = 0;
-#define DO_TEST_MINIMAL(r, ...) \
- do { \
- struct testMinimalStruct data = {r, __VA_ARGS__}; \
- if (virtTestRun("virNetDevBandwidthMinimal", \
- testVirNetDevBandwidthMinimal, \
- &data) < 0) \
- ret = -1; \
- } while (0)
-
#define DO_TEST_SET(Band, Exp_cmd, ...) \
do { \
struct testSetStruct data = {.band = Band, \
@@ -180,38 +121,6 @@ mymain(void)
} while (0)
- DO_TEST_MINIMAL(NULL, NULL, NULL);
-
- DO_TEST_MINIMAL("<bandwidth>"
- " <inbound average='1000' peak='5000' burst='5120'/>"
- " <outbound average='128' peak='256' burst='256'/>"
- "</bandwidth>",
- .band1 = "<bandwidth>"
- " <inbound average='1000' peak='5000' burst='5120'/>"
- " <outbound average='128' peak='256' burst='256'/>"
- "</bandwidth>");
-
- DO_TEST_MINIMAL("<bandwidth>"
- " <inbound average='1000' peak='5000' burst='5120'/>"
- " <outbound average='128' peak='256' burst='256'/>"
- "</bandwidth>",
- .band2 = "<bandwidth>"
- " <inbound average='1000' peak='5000' burst='5120'/>"
- " <outbound average='128' peak='256' burst='256'/>"
- "</bandwidth>");
- DO_TEST_MINIMAL("<bandwidth>"
- " <inbound average='1' peak='2' floor='3' burst='4'/>"
- " <outbound average='5' peak='6' burst='7'/>"
- "</bandwidth>",
- "<bandwidth>"
- " <inbound average='1' peak='2' burst='4'/>"
- " <outbound average='0' burst='7'/>"
- "</bandwidth>",
- "<bandwidth>"
- " <inbound average='1' peak='2' floor='3'/>"
- " <outbound average='5' peak='6'/>"
- "</bandwidth>");
-
DO_TEST_SET(("<bandwidth>"
" <inbound average='1' peak='2' floor='3' burst='4'/>"
" <outbound average='5' peak='6' burst='7'/>"
--
1.8.5.2
10 years, 10 months
[libvirt] [PATCH 0/4] Improve QoS and unit-test it
by Michal Privoznik
*** BLURB HERE ***
Michal Privoznik (4):
networkAllocateActualDevice: Set QoS for bridgeless networks too
tests: Introduce virnetdevbandwidthtest
virnetdevbandwidthtest: Introduce mocking
virnetdevbandwidthtest: Introduce testVirNetDevBandwidthSet
src/libvirt_private.syms | 1 +
src/network/bridge_driver.c | 25 ++++-
src/util/virnetdevbandwidth.c | 88 +++++++++++++++
src/util/virnetdevbandwidth.h | 6 +
tests/Makefile.am | 14 +++
tests/virnetdevbandwidthmock.c | 106 ++++++++++++++++++
tests/virnetdevbandwidthtest.c | 244 +++++++++++++++++++++++++++++++++++++++++
7 files changed, 482 insertions(+), 2 deletions(-)
create mode 100644 tests/virnetdevbandwidthmock.c
create mode 100644 tests/virnetdevbandwidthtest.c
--
1.8.5.2
10 years, 10 months
[libvirt] ANNOUNCE: virt-xml: Edit libvirt XML with command line options
by Cole Robinson
I've just pushed a new tool to virt-manager.git called virt-xml. virt-xml uses
virt-install's command line options to allow building and editing domain XML.
Best way to describe what it can do is with a bunch of examples:
See a list of all suboptions that --disk and --network take
# virt-xml --disk=? --network=?
Change the <description> of domain 'example':
# virt-xml example --edit --metadata description="my new description"
# Enable the boot device menu for domain 'example':
# virt-xml example --edit --boot bootmenu=on
Clear the previous <cpu> definition of domain 'winxp', change it to
'host-model', but interactively confirm the diff before saving:
# virt-xml winxp --edit --cpu host-model,clearxml=yes --confirm
Change the sound cards with model=ac97 to model=ich6 on 'fedora19', but only
output the diff:
# virt-xml fedora19 --edit model=ac97 --soundhw model=ich6 --print-diff
Update the first graphics password to 'foo' of the running VM 'rhel6':
# virt-xml rhel6 --edit --graphics password=foo --update
Remove the disk path from disk device hdc:
# virt-xml rhel6 --edit target=hdc --disk path=
Change all disk devices of type 'disk' to use cache=none, using XML from
stdin, printing the new XML to stdout.
# cat <xmlfile> | virt-xml --edit device=disk --disk cache=none
Change all host devices to use driver_name=vfio for VM 'fedora20' on the
remote connection
# virt-xml --connect qemu+ssh://remotehost/system \
fedora20 --edit all --host-device driver_name=vfio
Hotplug host USB device 001.003 to running domain 'fedora19':
# virt-xml f19 --add-device --host-device 001.003 --update
Add a spicevmc channel to the domain 'winxp', that will be available after the
next VM shutdown.
# virt-xml winxp --add-device --channel spicevmc
Create a 10G qcow2 disk image and attach it to 'fedora18' for the next VM startup:
# virt-xml fedora18 --add-device \
--disk /var/lib/libvirt/images/newimage.qcow2,format=qcow2,size=10
Remove the disk vdb from the running domain 'rhel7':
# virt-xml rhel7 --remove-device --disk target=vdb
Remove all graphics devices from the VM 'rhel7' after the next shutdown:
# virt-xml rhel7 --remove-device --graphics all
Generate XML for a virtio console device and print it to stdout:
# virt-xml --build-xml --console pty,target_type=virtio
The man page and --help output have more info, man page at:
https://git.fedorahosted.org/cgit/virt-manager.git/tree/man/virt-xml.pod
If you are interested in trying it out before it hits any distro, it's really
simple:
git clone git://git.fedorahosted.org/virt-manager.git
cd virt-manager
./virt-xml --help
Nothing is set in stone yet, so if anyone has suggestions about the command
line syntax or any of the above, please speak up: I plan on cutting a new
virt-manager release with virt-xml within the next few weeks.
Thanks,
Cole
10 years, 10 months
[libvirt] [PATCH v2 0/4] Fix deadlock in nwfilter code
by Daniel P. Berrange
Since we introduced fine grained locking into the QEMU driver so
that VM start can run in parallel, we appear to have caused a
race with the nwfilter code. In particular since we no longer
hold the global QEMU driver lock for the duration of VM startup
we have a lock ordering flaw. This results in deadlock when
nwfilter operations happen in parallel with VM startup. This
also affects the LXC driver.
This patch series attempts to address the problem
https://bugzilla.redhat.com/show_bug.cgi?id=929412
the removal of the windows thread impl isn't strictly required,
I just didn't want to waste time creating a read/write lock impl
for Windows threads.
See also this callgraph
http://berrange.fedorapeople.org/nwfilter.ps
In v2:
- Re-ordered patches and squashed two together
- Add missing locking in state reload function
- Don't remove locking from virNWFilterInstantiateFilterLate
Daniel P. Berrange (4):
Add a read/write lock implementation
Remove windows thread implementation in favour of pthreads
Add a mutex to serialize updates to firewall
Push nwfilter update locking up to top level
configure.ac | 15 +-
src/Makefile.am | 4 -
src/conf/nwfilter_conf.c | 23 +-
src/conf/nwfilter_conf.h | 3 +-
src/libvirt_private.syms | 8 +-
src/lxc/lxc_driver.c | 6 +
src/nwfilter/nwfilter_driver.c | 15 +-
src/nwfilter/nwfilter_gentech_driver.c | 23 +-
src/nwfilter/nwfilter_gentech_driver.h | 2 +-
src/qemu/qemu_driver.c | 6 +
src/uml/uml_driver.c | 4 +
src/util/virthread.c | 291 +++++++++++++++++++++++-
src/util/virthread.h | 51 ++++-
src/util/virthreadpthread.c | 278 -----------------------
src/util/virthreadpthread.h | 49 ----
src/util/virthreadwin32.c | 396 ---------------------------------
src/util/virthreadwin32.h | 53 -----
17 files changed, 404 insertions(+), 823 deletions(-)
delete mode 100644 src/util/virthreadpthread.c
delete mode 100644 src/util/virthreadpthread.h
delete mode 100644 src/util/virthreadwin32.c
delete mode 100644 src/util/virthreadwin32.h
--
1.8.4.2
10 years, 10 months