[libvirt] [PATCH] build: avoid 'make syntax-check' failure
by Eric Blake
* tests/utiltest.c (DO_TEST): Fix indentation for cppi.
---
Pushing under the build-breaker rule.
tests/utiltest.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tests/utiltest.c b/tests/utiltest.c
index 1b26b72..774a2f7 100644
--- a/tests/utiltest.c
+++ b/tests/utiltest.c
@@ -160,7 +160,7 @@ mymain(void)
virSetErrorFunc(NULL, testQuietError);
- #define DO_TEST(_name) \
+#define DO_TEST(_name) \
do { \
if (virtTestRun("Util "#_name, 1, test##_name, \
NULL) < 0) { \
--
1.7.4.4
13 years, 4 months
[libvirt] virtual switch - how to store state information
by Laine Stump
(If you already know about my work on putting a logical switch
abstraction into libvirt's <network>, skip to part 2)
INTRODUCTION
===========
The rudimentary logical network switch capability I'm currently
implementing (see https://bugzilla.redhat.com/show_bug.cgi?id=643947) is
intended to allow a guest's interface XML to be free of any specific
physical network device name, particularly in bridge and direct modes.
It does this by expanding the definition of a libvirt <network> to
include cases that merely describe a host-configured bridge, or a host
interface (or pool of interfaces) that can be used by a guest in one of
the 'direct' modes (bridge, private, vepa, or passthrough). It will also
allow certain details of the guest's network connection to be configured
by "portgroups" in the <network> definition (initially this will be
limited to a portgroup containing a <virtualportprofile> and bandwidth
limiting information).
For example, in the past, a guest that wanted to connect to interface
eth10 using the direct (aka 'macvtap') "vepa" mode would need to have
this <interface> in its guest XML:
<interface type='direct'>
<mac address='52:54:00:34:a5:aa'/>
<source dev='eth10' mode='vepa'/>
<model type='virtio'/>
<virtualport type='802.1Qbg'>
<parameters managerid='33' typeid='89' typeidversion='3'/>
</virtualport>
</interface>
With my new code, you can instead define a <network> with connections on
several physical ethernets:
<network>
<name>test</name>
<forward mode='vepa'>
<interface dev='eth10'/>
<interface dev='eth11'/>
<interface dev='eth12'/>
<interface dev='eth13'/>
<interface dev='eth14'/>
<interface dev='eth15'/>
<interface dev='eth16'/>
<interface dev='eth17'/>
</forward>
<portgroup name='accounting'>
<virtualport type='802.1Qbg'>
<parameters managerid='44' typeid='54' typeidversion='1'/>
</virtualport>
</portgroup>
<portgroup name='engineering' default='yes'>
<virtualport type='802.1Qbg'>
<parameters managerid='33' typeid='89' typeidversion='3'/>
</virtualport>
</portgroup>
</network>
and then tell the domain's <interface> to get the information from the
network:
<interface type='network'>
<mac address='52:54:00:34:a5:aa'/>
<source network='test' portgroup='engineering'/>
<model type='virtio'/>
</interface>
When libvirt sets up the interface connection, it will grab the config
for network 'test', see that the forward mode is 'vepa', decide which
physical ethernet to use, add in any extra stuff from the <portgroup>,
and use that as the information for connection. In this manner, 1) it
will remove the hardcoded device name from the domain config, making it
possible to migrate the domain to other hardware, and 2) share a pool of
physical devices over a group of domains.
PROPOSAL
========
After I've determined which physical device to use, I need to save that
information for as long as the domain is running, so that if libvirtd is
restarted, it won't be lost (in some configs, only a single guest can
use any particular netdev at a given time, so we want to be able to
manage allocation of the devices without leaking any). My current idea
is to save this in the domain <interface> XML that's put in the state
directory, but make sure that it's never put into the XML returned by
virsh dumpxml. What I'm thinking of is to add an <actual> subelement
under <interface>, like this:
<interface type='network'>
<mac address='52:54:00:34:a5:aa'/>
<source network='test' porgroup='engineering'/>
<model type='virtio'/>
<actual type='direct'/>
<source dev='eth10' mode='vepa'/>
<virtualport type='802.1Qbg'>
<parameters managerid='33' typeid='89' typeidversion='3'/>
</virtualport>
</actual>
</interface>
This will be a private/internal thing used only within libvirt, however
it does need to be stable, since it has to be understandable by a
libvirtd that has started up while guests are running (eg during a
libvirt upgrade). So I want to make sure I'm doing something reasonable.
So, it is?
Should <actual> contain *everything* from the parent interface, plus the
items that are changed? Or should it contain only:
* type attribute
* source element
* <bridge name=.../> (if applicable)
* <virtualport> (and other items that might come from <portgroup> in
the future
(i.e. the things that have changed)?
I *think* the answer is that it should just contain the items that have
changed, and there should be a wrapper API around the virDomainNetDef
object for retrieving things like type (if (def->actual) return
def->actual.type; else return def->type; and similar) to make sure that
all functions use the correct data.
13 years, 4 months
[libvirt] [PATCH] tests: Add a general util test
by Matthias Bolte
Move non-esx specific tests from esxutilstest there and add a
test for virParseVersionString.
---
tests/.gitignore | 1 +
tests/Makefile.am | 8 ++-
tests/esxutilstest.c | 70 --------------------
tests/utiltest.c | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 186 insertions(+), 71 deletions(-)
create mode 100644 tests/utiltest.c
diff --git a/tests/.gitignore b/tests/.gitignore
index 7f26dd7..32457ab 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -30,6 +30,7 @@ sockettest
statstest
storagepoolxml2xmltest
storagevolxml2xmltest
+utiltest
virbuftest
virnetmessagetest
virnetsockettest
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4bea18e..30b2d95 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -84,7 +84,8 @@ EXTRA_DIST = \
check_PROGRAMS = virshtest conftest sockettest \
nodeinfotest qparamtest virbuftest \
commandtest commandhelper seclabeltest \
- hashtest virnetmessagetest virnetsockettest ssh
+ hashtest virnetmessagetest virnetsockettest ssh \
+ utiltest
# This is a fake SSH we use from virnetsockettest
ssh_SOURCES = ssh.c
@@ -202,6 +203,7 @@ TESTS = virshtest \
hashtest \
virnetmessagetest \
virnetsockettest \
+ utiltest \
$(test_scripts)
if HAVE_YAJL
@@ -460,6 +462,10 @@ jsontest_SOURCES = \
jsontest.c testutils.h testutils.c
jsontest_LDADD = $(LDADDS)
+utiltest_SOURCES = \
+ utiltest.c testutils.h testutils.c
+utiltest_LDADD = $(LDADDS)
+
if WITH_LIBVIRTD
eventtest_SOURCES = \
eventtest.c testutils.h testutils.c
diff --git a/tests/esxutilstest.c b/tests/esxutilstest.c
index 51c1e34..2097648 100644
--- a/tests/esxutilstest.c
+++ b/tests/esxutilstest.c
@@ -24,74 +24,6 @@ testQuietError(void *userData ATTRIBUTE_UNUSED,
-static const char* names[] = {
- "sda", "sdb", "sdc", "sdd", "sde", "sdf", "sdg", "sdh", "sdi", "sdj", "sdk", "sdl", "sdm", "sdn", "sdo", "sdp", "sdq", "sdr", "sds", "sdt", "sdu", "sdv", "sdw", "sdx", "sdy", "sdz",
- "sdaa", "sdab", "sdac", "sdad", "sdae", "sdaf", "sdag", "sdah", "sdai", "sdaj", "sdak", "sdal", "sdam", "sdan", "sdao", "sdap", "sdaq", "sdar", "sdas", "sdat", "sdau", "sdav", "sdaw", "sdax", "sday", "sdaz",
- "sdba", "sdbb", "sdbc", "sdbd", "sdbe", "sdbf", "sdbg", "sdbh", "sdbi", "sdbj", "sdbk", "sdbl", "sdbm", "sdbn", "sdbo", "sdbp", "sdbq", "sdbr", "sdbs", "sdbt", "sdbu", "sdbv", "sdbw", "sdbx", "sdby", "sdbz",
- "sdca", "sdcb", "sdcc", "sdcd", "sdce", "sdcf", "sdcg", "sdch", "sdci", "sdcj", "sdck", "sdcl", "sdcm", "sdcn", "sdco", "sdcp", "sdcq", "sdcr", "sdcs", "sdct", "sdcu", "sdcv", "sdcw", "sdcx", "sdcy", "sdcz",
- "sdda", "sddb", "sddc", "sddd", "sdde", "sddf", "sddg", "sddh", "sddi", "sddj", "sddk", "sddl", "sddm", "sddn", "sddo", "sddp", "sddq", "sddr", "sdds", "sddt", "sddu", "sddv", "sddw", "sddx", "sddy", "sddz",
- "sdea", "sdeb", "sdec", "sded", "sdee", "sdef", "sdeg", "sdeh", "sdei", "sdej", "sdek", "sdel", "sdem", "sden", "sdeo", "sdep", "sdeq", "sder", "sdes", "sdet", "sdeu", "sdev", "sdew", "sdex", "sdey", "sdez",
- "sdfa", "sdfb", "sdfc", "sdfd", "sdfe", "sdff", "sdfg", "sdfh", "sdfi", "sdfj", "sdfk", "sdfl", "sdfm", "sdfn", "sdfo", "sdfp", "sdfq", "sdfr", "sdfs", "sdft", "sdfu", "sdfv", "sdfw", "sdfx", "sdfy", "sdfz",
- "sdga", "sdgb", "sdgc", "sdgd", "sdge", "sdgf", "sdgg", "sdgh", "sdgi", "sdgj", "sdgk", "sdgl", "sdgm", "sdgn", "sdgo", "sdgp", "sdgq", "sdgr", "sdgs", "sdgt", "sdgu", "sdgv", "sdgw", "sdgx", "sdgy", "sdgz",
- "sdha", "sdhb", "sdhc", "sdhd", "sdhe", "sdhf", "sdhg", "sdhh", "sdhi", "sdhj", "sdhk", "sdhl", "sdhm", "sdhn", "sdho", "sdhp", "sdhq", "sdhr", "sdhs", "sdht", "sdhu", "sdhv", "sdhw", "sdhx", "sdhy", "sdhz",
- "sdia", "sdib", "sdic", "sdid", "sdie", "sdif", "sdig", "sdih", "sdii", "sdij", "sdik", "sdil", "sdim", "sdin", "sdio", "sdip", "sdiq", "sdir", "sdis", "sdit", "sdiu", "sdiv", "sdiw", "sdix", "sdiy", "sdiz"
-};
-
-static int
-testIndexToDiskName(const void *data ATTRIBUTE_UNUSED)
-{
- int i;
- char *name = NULL;
-
- for (i = 0; i < ARRAY_CARDINALITY(names); ++i) {
- VIR_FREE(name);
-
- name = virIndexToDiskName(i, "sd");
-
- if (STRNEQ(names[i], name)) {
- virtTestDifference(stderr, names[i], name);
- VIR_FREE(name);
-
- return -1;
- }
- }
-
- VIR_FREE(name);
-
- return 0;
-}
-
-static int
-testDiskNameToIndex(const void *data ATTRIBUTE_UNUSED)
-{
- int i, k;
- char *name = NULL;
-
- for (i = 0; i < 100000; ++i) {
- VIR_FREE(name);
-
- name = virIndexToDiskName(i, "sd");
- k = virDiskNameToIndex(name);
-
- if (k != i) {
- if (virTestGetDebug() > 0) {
- fprintf(stderr, "\nExpect [%d]\n", i);
- fprintf(stderr, "Actual [%d]\n", k);
- }
-
- VIR_FREE(name);
-
- return -1;
- }
- }
-
- VIR_FREE(name);
-
- return 0;
-}
-
-
-
struct testPath {
const char *datastorePath;
int result;
@@ -336,8 +268,6 @@ mymain(void)
} \
} while (0)
- DO_TEST(IndexToDiskName);
- DO_TEST(DiskNameToIndex);
DO_TEST(ParseDatastorePath);
DO_TEST(ConvertDateTimeToCalendarTime);
DO_TEST(EscapeDatastoreItem);
diff --git a/tests/utiltest.c b/tests/utiltest.c
new file mode 100644
index 0000000..1b26b72
--- /dev/null
+++ b/tests/utiltest.c
@@ -0,0 +1,178 @@
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "internal.h"
+#include "memory.h"
+#include "testutils.h"
+#include "util.h"
+
+
+static void
+testQuietError(void *userData ATTRIBUTE_UNUSED,
+ virErrorPtr error ATTRIBUTE_UNUSED)
+{
+ /* nothing */
+}
+
+
+
+static const char* diskNames[] = {
+ "sda", "sdb", "sdc", "sdd", "sde", "sdf", "sdg", "sdh", "sdi", "sdj", "sdk", "sdl", "sdm", "sdn", "sdo", "sdp", "sdq", "sdr", "sds", "sdt", "sdu", "sdv", "sdw", "sdx", "sdy", "sdz",
+ "sdaa", "sdab", "sdac", "sdad", "sdae", "sdaf", "sdag", "sdah", "sdai", "sdaj", "sdak", "sdal", "sdam", "sdan", "sdao", "sdap", "sdaq", "sdar", "sdas", "sdat", "sdau", "sdav", "sdaw", "sdax", "sday", "sdaz",
+ "sdba", "sdbb", "sdbc", "sdbd", "sdbe", "sdbf", "sdbg", "sdbh", "sdbi", "sdbj", "sdbk", "sdbl", "sdbm", "sdbn", "sdbo", "sdbp", "sdbq", "sdbr", "sdbs", "sdbt", "sdbu", "sdbv", "sdbw", "sdbx", "sdby", "sdbz",
+ "sdca", "sdcb", "sdcc", "sdcd", "sdce", "sdcf", "sdcg", "sdch", "sdci", "sdcj", "sdck", "sdcl", "sdcm", "sdcn", "sdco", "sdcp", "sdcq", "sdcr", "sdcs", "sdct", "sdcu", "sdcv", "sdcw", "sdcx", "sdcy", "sdcz",
+ "sdda", "sddb", "sddc", "sddd", "sdde", "sddf", "sddg", "sddh", "sddi", "sddj", "sddk", "sddl", "sddm", "sddn", "sddo", "sddp", "sddq", "sddr", "sdds", "sddt", "sddu", "sddv", "sddw", "sddx", "sddy", "sddz",
+ "sdea", "sdeb", "sdec", "sded", "sdee", "sdef", "sdeg", "sdeh", "sdei", "sdej", "sdek", "sdel", "sdem", "sden", "sdeo", "sdep", "sdeq", "sder", "sdes", "sdet", "sdeu", "sdev", "sdew", "sdex", "sdey", "sdez",
+ "sdfa", "sdfb", "sdfc", "sdfd", "sdfe", "sdff", "sdfg", "sdfh", "sdfi", "sdfj", "sdfk", "sdfl", "sdfm", "sdfn", "sdfo", "sdfp", "sdfq", "sdfr", "sdfs", "sdft", "sdfu", "sdfv", "sdfw", "sdfx", "sdfy", "sdfz",
+ "sdga", "sdgb", "sdgc", "sdgd", "sdge", "sdgf", "sdgg", "sdgh", "sdgi", "sdgj", "sdgk", "sdgl", "sdgm", "sdgn", "sdgo", "sdgp", "sdgq", "sdgr", "sdgs", "sdgt", "sdgu", "sdgv", "sdgw", "sdgx", "sdgy", "sdgz",
+ "sdha", "sdhb", "sdhc", "sdhd", "sdhe", "sdhf", "sdhg", "sdhh", "sdhi", "sdhj", "sdhk", "sdhl", "sdhm", "sdhn", "sdho", "sdhp", "sdhq", "sdhr", "sdhs", "sdht", "sdhu", "sdhv", "sdhw", "sdhx", "sdhy", "sdhz",
+ "sdia", "sdib", "sdic", "sdid", "sdie", "sdif", "sdig", "sdih", "sdii", "sdij", "sdik", "sdil", "sdim", "sdin", "sdio", "sdip", "sdiq", "sdir", "sdis", "sdit", "sdiu", "sdiv", "sdiw", "sdix", "sdiy", "sdiz"
+};
+
+static int
+testIndexToDiskName(const void *data ATTRIBUTE_UNUSED)
+{
+ int i;
+ char *diskName = NULL;
+
+ for (i = 0; i < ARRAY_CARDINALITY(diskNames); ++i) {
+ VIR_FREE(diskName);
+
+ diskName = virIndexToDiskName(i, "sd");
+
+ if (STRNEQ(diskNames[i], diskName)) {
+ virtTestDifference(stderr, diskNames[i], diskName);
+ VIR_FREE(diskName);
+
+ return -1;
+ }
+ }
+
+ VIR_FREE(diskName);
+
+ return 0;
+}
+
+
+
+static int
+testDiskNameToIndex(const void *data ATTRIBUTE_UNUSED)
+{
+ int i, k;
+ char *diskName = NULL;
+
+ for (i = 0; i < 100000; ++i) {
+ VIR_FREE(diskName);
+
+ diskName = virIndexToDiskName(i, "sd");
+ k = virDiskNameToIndex(diskName);
+
+ if (k != i) {
+ if (virTestGetDebug() > 0) {
+ fprintf(stderr, "\nExpect [%d]\n", i);
+ fprintf(stderr, "Actual [%d]\n", k);
+ }
+
+ VIR_FREE(diskName);
+
+ return -1;
+ }
+ }
+
+ VIR_FREE(diskName);
+
+ return 0;
+}
+
+
+
+struct testVersionString
+{
+ const char *string;
+ bool allowMissing;
+ int result;
+ unsigned long version;
+};
+
+static struct testVersionString versions[] = {
+ { "2.6.38-8-generic", false, 0, 1000000 * 2 + 1000 * 6 + 38 },
+ { "3.0-1-virtual", true, 0, 1000000 * 3 + 1000 * 0 + 0 },
+ { "5", true, 0, 1000000 * 5 + 1000 * 0 + 0 },
+ { "4.1.0", false, 0, 1000000 * 4 + 1000 * 1 + 0 },
+ { "12.345.678", false, 0, 1000000 * 12 + 1000 * 345 + 678 },
+ { "1.234.5678", false, -1, 0 },
+ { "1.2345.678", false, -1, 0 },
+ { "12345.6.78", false, -1, 0 },
+ { "123456789", true, -1, 0 },
+ { "3.0-2-virtual", false, -1, 0 },
+ { "no-number-here", false, -1, 0 },
+};
+
+static int
+testParseVersionString(const void *data ATTRIBUTE_UNUSED)
+{
+ int i, result;
+ unsigned long version;
+
+ for (i = 0; i < ARRAY_CARDINALITY(versions); ++i) {
+ result = virParseVersionString(versions[i].string, &version,
+ versions[i].allowMissing);
+
+ if (result != versions[i].result) {
+ if (virTestGetDebug() > 0) {
+ fprintf(stderr, "\nVersion string [%s]\n", versions[i].string);
+ fprintf(stderr, "Expect result [%d]\n", versions[i].result);
+ fprintf(stderr, "Actual result [%d]\n", result);
+ }
+
+ return -1;
+ }
+
+ if (result < 0) {
+ continue;
+ }
+
+ if (version != versions[i].version) {
+ if (virTestGetDebug() > 0) {
+ fprintf(stderr, "\nVersion string [%s]\n", versions[i].string);
+ fprintf(stderr, "Expect version [%lu]\n", versions[i].version);
+ fprintf(stderr, "Actual version [%lu]\n", version);
+ }
+
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
+
+
+static int
+mymain(void)
+{
+ int result = 0;
+
+ virSetErrorFunc(NULL, testQuietError);
+
+ #define DO_TEST(_name) \
+ do { \
+ if (virtTestRun("Util "#_name, 1, test##_name, \
+ NULL) < 0) { \
+ result = -1; \
+ } \
+ } while (0)
+
+ DO_TEST(IndexToDiskName);
+ DO_TEST(DiskNameToIndex);
+ DO_TEST(ParseVersionString);
+
+ return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+VIRT_TEST_MAIN(mymain)
--
1.7.4.1
13 years, 4 months
[libvirt] [PATCH] fix virParseVersionString with linux 3.0
by Scott Moser
linux 3.0 has no micro version number, and that is causing problems
for virParseVersionString. The patch below should allow for:
major
major.minor
major.minor.micro
If major or minor are not present they just default to zero.
We found this in Ubuntu (https://bugs.launchpad.net/bugs/802977)
diff --git a/src/util/util.c b/src/util/util.c
index 463d2b8..01848a1 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -1598,17 +1598,17 @@ virParseNumber(const char **str)
int
virParseVersionString(const char *str, unsigned long *version)
{
- unsigned int major, minor, micro;
+ unsigned int major, minor=0, micro=0;
char *tmp;
- if (virStrToLong_ui(str, &tmp, 10, &major) < 0 || *tmp != '.')
+ if (virStrToLong_ui(str, &tmp, 10, &major) < 0)
return -1;
- if (virStrToLong_ui(tmp + 1, &tmp, 10, &minor) < 0 || *tmp != '.')
- return -1;
+ if ((*tmp == '.') && virStrToLong_ui(tmp + 1, &tmp, 10, &minor) < 0)
+ return -1;
- if (virStrToLong_ui(tmp + 1, &tmp, 10, µ) < 0)
- return -1;
+ if ((*tmp == '.') && virStrToLong_ui(tmp + 1, &tmp, 10, µ) < 0)
+ return -1;
*version = 1000000 * major + 1000 * minor + micro;
13 years, 4 months
[libvirt] [PATCHv2] build: consistently use CFLAGS
by Eric Blake
According to the automake manual, CPPFLAGS (aka INCLUDES, as spelled
in automake 1.9.6) should only include -I, -D, and -U directives; more
generic directives like -Wall belong in CFLAGS since they affect more
phases of the build process. Therefore, we should be sticking CFLAGS
additions into a CFLAGS container, not a CPPFLAGS container.
* src/Makefile.am (INCLUDES): Move CFLAGS items...
(AM_CFLAGS): ...to their proper location.
* python/Makefile.am (INCLUDES, AM_CFLAGS): Likewise.
* tests/Makefile.am (INCLUDES, AM_CFLAGS): Likewise.
---
v1 had no review:
https://www.redhat.com/archives/libvir-list/2011-May/msg01934.html
changes from v1: rebase to latest
I tested it on top of these two patches, hopefully they'll be ack'd first:
https://www.redhat.com/archives/libvir-list/2011-June/msg01537.html
https://www.redhat.com/archives/libvir-list/2011-June/msg01486.html
python/Makefile.am | 5 +++--
src/Makefile.am | 15 +++++++--------
tests/Makefile.am | 8 +++++---
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/python/Makefile.am b/python/Makefile.am
index 432ad70..0edb3e4 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -3,12 +3,13 @@
SUBDIRS= . tests
INCLUDES = \
- $(WARN_CFLAGS) \
- $(PYTHON_INCLUDES) \
+ $(PYTHON_INCLUDES) \
-I$(top_srcdir)/include \
-I$(top_builddir)/include \
-I$(top_builddir)/$(subdir)
+AM_CFLAGS = $(WARN_CFLAGS)
+
DOCS_DIR = $(datadir)/doc/libvirt-python-$(LIBVIRT_VERSION)
DOCS = ${srcdir}/TODO
diff --git a/src/Makefile.am b/src/Makefile.am
index 4ba3ea7..10ee20a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,20 +3,19 @@
# No libraries with the exception of LIBXML should be listed
# here. List them against the individual XXX_la_CFLAGS targets
# that actually use them
-INCLUDES = \
- -I$(top_srcdir)/gnulib/lib \
+INCLUDES = -I$(top_srcdir)/gnulib/lib \
-I../gnulib/lib \
-I../include \
-I@top_srcdir@/src/util \
-I@top_srcdir@/include \
- $(DRIVER_MODULE_CFLAGS) \
+ -DIN_LIBVIRT
+
+AM_CFLAGS = $(DRIVER_MODULE_CFLAGS) \
$(LIBXML_CFLAGS) \
$(WARN_CFLAGS) \
- $(LOCK_CHECKING_CFLAGS) \
- -DIN_LIBVIRT \
- $(WIN32_EXTRA_CFLAGS)
-
-AM_CFLAGS = $(COVERAGE_CFLAGS)
+ $(LOCK_CHECKING_CFLAGS) \
+ $(WIN32_EXTRA_CFLAGS) \
+ $(COVERAGE_CFLAGS)
AM_LDFLAGS = $(COVERAGE_LDFLAGS)
EXTRA_DIST = $(conf_DATA)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 38a353f..984d8fd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,15 +8,17 @@ INCLUDES = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/util \
- -I$(top_srcdir)/src/conf \
+ -I$(top_srcdir)/src/conf
+
+AM_CFLAGS = \
$(LIBXML_CFLAGS) \
$(GNUTLS_CFLAGS) \
$(SASL_CFLAGS) \
$(SELINUX_CFLAGS) \
$(APPARMOR_CFLAGS) \
$(YAJL_CFLAGS) \
- $(COVERAGE_CFLAGS) \
- $(WARN_CFLAGS)
+ $(COVERAGE_CFLAGS) \
+ $(WARN_CFLAGS)
if WITH_DRIVER_MODULES
INCLUDES += \
--
1.7.4.4
13 years, 4 months
[libvirt] [PATCH] build: remove dead variables
by Eric Blake
Detected by Coverity. No real harm in leaving these, but fixing
them cuts down on the noise for future analysis.
* src/rpc/virnetserver.c (virNetServerAddService): Delete unused
entry.
* src/util/sysinfo.c (virSysinfoRead): Delete dead assignment to
base.
---
src/rpc/virnetserver.c | 7 +++----
src/util/sysinfo.c | 2 +-
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 0ef81fd..5e1719b 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -529,11 +529,10 @@ int virNetServerAddService(virNetServerPtr srv,
#if HAVE_AVAHI
if (mdnsEntryName) {
int port = virNetServerServiceGetPort(svc);
- virNetServerMDNSEntryPtr entry;
- if (!(entry = virNetServerMDNSAddEntry(srv->mdnsGroup,
- mdnsEntryName,
- port)))
+ if (!virNetServerMDNSAddEntry(srv->mdnsGroup,
+ mdnsEntryName,
+ port))
goto error;
}
#endif
diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c
index f4edde9..eec996b 100644
--- a/src/util/sysinfo.c
+++ b/src/util/sysinfo.c
@@ -472,7 +472,7 @@ virSysinfoRead(void) {
ret->nmemory = 0;
ret->memory = NULL;
- if ((base = virSysinfoParseMemory(base, ret)) == NULL)
+ if (virSysinfoParseMemory(base, ret) == NULL)
goto no_memory;
cleanup:
--
1.7.4.4
13 years, 4 months
[libvirt] [Libvirt-test-API][PATCH 1/6] add createWithFlags() API and modify migrate() function to align with libvirt Python migration definition
by Guannan.ren
---
lib/domainAPI.py | 57 ++++++++++++++++++++++++++++++++++++------------------
1 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/lib/domainAPI.py b/lib/domainAPI.py
index 0c725f8..5667c20 100644
--- a/lib/domainAPI.py
+++ b/lib/domainAPI.py
@@ -40,18 +40,6 @@ append_path(result.group(0))
import exception
-# DomainMigrateFlags
-VIR_MIGRATE_LIVE = 1
-
-# DomainState
-VIR_DOMAIN_NOSTATE = 0
-VIR_DOMAIN_RUNNING = 1
-VIR_DOMAIN_BLOCKED = 2
-VIR_DOMAIN_PAUSED = 3
-VIR_DOMAIN_SHUTDOWN = 4
-VIR_DOMAIN_SHUTOFF = 5
-VIR_DOMAIN_CRASHED = 6
-
class DomainAPI(object):
def __init__(self, connection):
self.conn = connection
@@ -182,6 +170,16 @@ class DomainAPI(object):
code = e.get_error_code()
raise exception.LibvirtAPI(message, code)
+ def start_with_flags(self, domname, flags = 0):
+ try:
+ dom_obj = self.get_defined_obj(domname)
+ retval = dom_obj.createWithFlags(flags)
+ return retval
+ except libvirt.libvirtError, e:
+ message = e.get_error_message()
+ code = e.get_error_code()
+ raise exception.LibvirtAPI(message, code)
+
def suspend(self, domname):
try:
dom_obj = self.get_domain_by_name(domname)
@@ -223,10 +221,10 @@ class DomainAPI(object):
code = e.get_error_code()
raise exception.LibvirtAPI(message, code)
- def migrate(self, domname, dconn, flags = VIR_MIGRATE_LIVE):
+ def migrate(self, domname, dconn, flags, dname = None, uri = None, bandwidth = 0):
try:
dom_obj = self.get_domain_by_name(domname)
- retval = dom_obj.migrate(dconn, flags, None, None, 0)
+ retval = dom_obj.migrate(dconn, flags, dname, uri, 0)
return retval
except libvirt.libvirtError, e:
message = e.get_error_message()
@@ -484,7 +482,7 @@ class DomainAPI(object):
dom_obj = self.get_domain_by_name(domname)
state = dom_obj.info()
if state[0] == VIR_DOMAIN_NOSTATE:
- dom_state = 'no state'
+ dom_state = 'nostate'
elif state[0] == VIR_DOMAIN_RUNNING:
dom_state = 'running'
elif state[0] == VIR_DOMAIN_BLOCKED:
@@ -581,7 +579,7 @@ class DomainAPI(object):
code = e.get_error_code()
raise exception.LibvirtAPI(message, code)
- def isActive(self, domname):
+ def is_active(self, domname):
try:
dom_obj = self.get_domain_by_name(domname)
return dom_obj.isActive()
@@ -590,7 +588,7 @@ class DomainAPI(object):
code = e.get_error_code()
raise exception.LibvirtAPI(message, code)
- def isPersistent(self, domname):
+ def is_persistent(self, domname):
try:
dom_obj = self.get_domain_by_name(domname)
return dom_obj.isPersistent()
@@ -662,10 +660,10 @@ class DomainAPI(object):
code = e.get_error_code()
raise exception.LibvirtAPI(message, code)
- def migrate_to_uri(self, domname, duri, dname, bandwidth, flag = 0):
+ def migrate_to_uri(self, domname, duri, flags, dname = None, bandwidth = 0):
try:
dom_obj = self.get_domain_by_name(domname)
- return dom_obj.migrateToURI(duri, dname, bandwidth, flag)
+ return dom_obj.migrateToURI(duri, flags, dname, bandwidth)
except libvirt.libvirtError, e:
message = e.get_error_message()
code = e.get_error_code()
@@ -761,3 +759,24 @@ class DomainAPI(object):
code = e.get_error_code()
raise exception.LibvirtAPI(message, code)
+
+# DomainState
+VIR_DOMAIN_NOSTATE = 0
+VIR_DOMAIN_RUNNING = 1
+VIR_DOMAIN_BLOCKED = 2
+VIR_DOMAIN_PAUSED = 3
+VIR_DOMAIN_SHUTDOWN = 4
+VIR_DOMAIN_SHUTOFF = 5
+VIR_DOMAIN_CRASHED = 6
+
+
+# virDomainMigrateFlags
+VIR_MIGRATE_LIVE = 1
+VIR_MIGRATE_PEER2PEER = 2
+VIR_MIGRATE_TUNNELLED = 4
+VIR_MIGRATE_PERSIST_DEST = 8
+VIR_MIGRATE_UNDEFINE_SOURCE = 16
+VIR_MIGRATE_PAUSED = 32
+VIR_MIGRATE_NON_SHARED_DISK = 64
+VIR_MIGRATE_NON_SHARED_INC = 128
+
--
1.7.1
13 years, 4 months
[libvirt] PPPoE-Server problem
by B Veera-B37207
HI,
I am using Libvirt with LXC as hypervisor.
When I am starting pppoe-server , unable to create ppp0 interface in Virtual machine, it is unable to serve ips to clients.
Let me know is there any plug-in for this (Or) What is the solution.
Regards,
Veera.
13 years, 4 months
[libvirt] [PATCH] Add test case for parsing JSON docs
by Daniel P. Berrange
While investigating some memory leaks it was unclear whether the
JSON code correctly free'd all memory during parsing. Add a test
case which can be run under valgrind to clearly demonstrate that
the parser is leak free.
* tests/Makefile.am: Add 'jsontest'
* tests/jsontest.c: A few simple JSON parsing tests
---
tests/Makefile.am | 14 +++++++
tests/jsontest.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 125 insertions(+), 0 deletions(-)
create mode 100644 tests/jsontest.c
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7db9d1f..3bde22e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,6 +14,7 @@ INCLUDES = \
$(SASL_CFLAGS) \
$(SELINUX_CFLAGS) \
$(APPARMOR_CFLAGS) \
+ $(YAJL_CFLAGS) \
$(COVERAGE_CFLAGS) \
$(WARN_CFLAGS)
@@ -29,6 +30,7 @@ LDADDS = \
$(SASL_LIBS) \
$(SELINUX_LIBS) \
$(APPARMOR_LIBS) \
+ $(YAJL_LIBS) \
$(WARN_CFLAGS) \
../src/libvirt_test.la \
../gnulib/lib/libgnu.la \
@@ -112,6 +114,10 @@ if WITH_CIL
check_PROGRAMS += object-locking
endif
+if HAVE_YAJL
+check_PROGRAMS += jsontest
+endif
+
check_PROGRAMS += networkxml2xmltest
check_PROGRAMS += networkxml2argvtest
@@ -195,6 +201,10 @@ TESTS = virshtest \
virnetsockettest \
$(test_scripts)
+if HAVE_YAJL
+TESTS += jsontest
+endif
+
if WITH_XEN
TESTS += xml2sexprtest \
sexpr2xmltest \
@@ -443,6 +453,10 @@ hashtest_SOURCES = \
hashtest.c hashdata.h testutils.h testutils.c
hashtest_LDADD = $(LDADDS)
+jsontest_SOURCES = \
+ jsontest.c jsondata.h testutils.h testutils.c
+jsontest_LDADD = $(LDADDS)
+
if WITH_LIBVIRTD
eventtest_SOURCES = \
eventtest.c testutils.h testutils.c
diff --git a/tests/jsontest.c b/tests/jsontest.c
new file mode 100644
index 0000000..412f475
--- /dev/null
+++ b/tests/jsontest.c
@@ -0,0 +1,111 @@
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "internal.h"
+#include "json.h"
+#include "testutils.h"
+
+struct testInfo {
+ const char *doc;
+ bool pass;
+};
+
+
+static int
+testJSONFromString(const void *data)
+{
+ const struct testInfo *info = data;
+ virJSONValuePtr json;
+ int ret = -1;
+
+ json = virJSONValueFromString(info->doc);
+
+ if (info->pass) {
+ if (!json) {
+ if (virTestGetVerbose())
+ fprintf(stderr, "Fail to parse %s\n", info->doc);
+ ret = -1;
+ goto cleanup;
+ } else {
+ if (virTestGetDebug())
+ fprintf(stderr, "Parsed %s\n", info->doc);
+ }
+ } else {
+ if (json) {
+ if (virTestGetVerbose())
+ fprintf(stderr, "Should not have parsed %s\n", info->doc);
+ ret = -1;
+ goto cleanup;
+ } else {
+ if (virTestGetDebug())
+ fprintf(stderr, "Fail to parse %s\n", info->doc);
+ }
+ }
+
+ ret = 0;
+
+cleanup:
+ virJSONValueFree(json);
+ return ret;
+}
+
+
+static int
+mymain(void)
+{
+ int ret = 0;
+
+#define DO_TEST_FULL(name, cmd, doc, pass) \
+ do { \
+ struct testInfo info = { doc, pass }; \
+ if (virtTestRun(name, 1, testJSON ## cmd, &info) < 0) \
+ ret = -1; \
+ } while (0)
+
+#define DO_TEST_PARSE(name, doc) \
+ DO_TEST_FULL(name, FromString, doc, true)
+
+ DO_TEST_PARSE("Simple", "{\"return\": {}, \"id\": \"libvirt-1\"}");
+ DO_TEST_PARSE("NotSoSimple", "{\"QMP\": {\"version\": {\"qemu\":"
+ "{\"micro\": 91, \"minor\": 13, \"major\": 0},"
+ "\"package\": \" (qemu-kvm-devel)\"}, \"capabilities\": []}}");
+
+
+ DO_TEST_PARSE("Harder", "{\"return\": [{\"filename\": "
+ "\"unix:/home/berrange/.libvirt/qemu/lib/tck.monitor,server\","
+ "\"label\": \"charmonitor\"}, {\"filename\": \"pty:/dev/pts/158\","
+ "\"label\": \"charserial0\"}], \"id\": \"libvirt-3\"}");
+
+ DO_TEST_PARSE("VeryHard", "{\"return\": [{\"name\": \"quit\"}, {\"name\":"
+ "\"eject\"}, {\"name\": \"change\"}, {\"name\": \"screendump\"},"
+ "{\"name\": \"stop\"}, {\"name\": \"cont\"}, {\"name\": "
+ "\"system_reset\"}, {\"name\": \"system_powerdown\"}, "
+ "{\"name\": \"device_add\"}, {\"name\": \"device_del\"}, "
+ "{\"name\": \"cpu\"}, {\"name\": \"memsave\"}, {\"name\": "
+ "\"pmemsave\"}, {\"name\": \"migrate\"}, {\"name\": "
+ "\"migrate_cancel\"}, {\"name\": \"migrate_set_speed\"},"
+ "{\"name\": \"client_migrate_info\"}, {\"name\": "
+ "\"migrate_set_downtime\"}, {\"name\": \"netdev_add\"}, "
+ "{\"name\": \"netdev_del\"}, {\"name\": \"block_resize\"},"
+ "{\"name\": \"balloon\"}, {\"name\": \"set_link\"}, {\"name\":"
+ "\"getfd\"}, {\"name\": \"closefd\"}, {\"name\": \"block_passwd\"},"
+ "{\"name\": \"set_password\"}, {\"name\": \"expire_password\"},"
+ "{\"name\": \"qmp_capabilities\"}, {\"name\": "
+ "\"human-monitor-command\"}, {\"name\": \"query-version\"},"
+ "{\"name\": \"query-commands\"}, {\"name\": \"query-chardev\"},"
+ "{\"name\": \"query-block\"}, {\"name\": \"query-blockstats\"}, "
+ "{\"name\": \"query-cpus\"}, {\"name\": \"query-pci\"}, {\"name\":"
+ "\"query-kvm\"}, {\"name\": \"query-status\"}, {\"name\": "
+ "\"query-mice\"}, {\"name\": \"query-vnc\"}, {\"name\": "
+ "\"query-spice\"}, {\"name\": \"query-name\"}, {\"name\": "
+ "\"query-uuid\"}, {\"name\": \"query-migrate\"}, {\"name\": "
+ "\"query-balloon\"}], \"id\": \"libvirt-2\"}");
+
+ return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+VIRT_TEST_MAIN(mymain)
--
1.7.4.4
13 years, 4 months
[libvirt] network filters not working at all in 0.9.2
by xxyton
Hi there,
is just upgraded to libvirt 0.9.2 and restarted my domains but now all
network filters are gone.
Why does libvirt not set iptables configuration while filterref clause
exists?
Is this a known bug? How can I fix it.
Restarting / redefining doesn't output any errors.
Example config XML of domain:
...
<filterref filter='clean-traffic'>
<parameter name='IP' value='192.168.2.34'/>
</filterref>
...
# virsh -v
0.9.2
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:bootps
ACCEPT tcp -- anywhere anywhere tcp dpt:bootps
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere 192.168.122.0/24 state
RELATED,ESTABLISHED
ACCEPT all -- 192.168.122.0/24 anywhere
ACCEPT all -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with
icmp-port-unreachable
REJECT all -- anywhere anywhere reject-with
icmp-port-unreachable
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
13 years, 4 months