[libvirt] [RFC: PATCH 0/4] Update array allocation macros
by Eric Blake
I'm posing this series as an RFC for the moment. The basic premise is
that I got bit trying to use VIR_REALLOC_N when working on the
virCommand API, assuming that it zeroed out new memory because the
documentation said so, only to hit a core dump. On looking closer, it
became obvious to me that the VIR_REALLOC_N API is deficient - there's
no way to know how much memory, if any, to zeroize without knowing the
original size, so the new memory has to be uninitialized (explaining
my crash), and the documentation is wrong.
So, after some IRC discussions, two ideas emerged in addition to the
obvious documentation update. One is the simpler VIR_EXPAND_N, where
the array size always matches the array allocation, along with a
VIR_SHRINK_N counterpart which can trim an array back down (and
failure to trim need not be fatal). But this can scale quadratically
if you end up with a large array, as the existing contents must be
copied on every realloc. See patches 1 and 2 for an implementation
and use.
The other idea is VIR_RESIZE_N, which tracks allocation separately
from usage, and has better scaling by doing geometric growth only when
needed rather than on every array usage increase. But it takes more
parameters (making it slightly harder to remember how to use
correctly), along with possible modifications of the struct tracking
an array (so it might not be possible to modify all uses of
VIR_REALLOC_N to use this, if it would end up altering a public struct
layout). See patches 3 and 4 for an implementation and use.
Note that event.c is an example of code that already tracked
allocation separately from usage, so the new VIR_RESIZE_N was
very easy to use. On the other hand, libvirtd.c is an example
of code where I had to add allocation tracking; notice the
difference between patches 2/4 and 4/4 of the logic differences
needed when using VIR_EXPAND_N vs. VIR_RESIZE_N. And notice
that both patch 2 and patch 4 provide a net reduction in lines
outside of memory.[ch].
Either way, I'm willing to audit all remaining uses of VIR_REALLOC_N
(in fact, libvirtd.c has another use of VIR_REALLOC_N to allocate
a buffer for getgrnam_r, where the uninitialized memory aspect
was just fine and not worth converting). The only reason I'm posting
this series as an RFC is to get a feel for which of the two styles
I should prefer when doing my audit on the rest of the code base
(rather than doing style A now only to find that style B would be
preferred).
Also, as written, the implementation forces all array count variables
to be size_t if using VIR_EXPAND_N or VIR_RESIZE_N; I may come across
a public API where I can't change the array count type, in which case
I will have to rewrite the macros to be type-agnostic. Well, more
like making the macro choose between a 4-byte or 8-byte
implementation, based on sizeof(count), and adding a compiler verify()
that count must be one of those two sizes, whether on 32-bit or 64-bit
machines.
Eric Blake (4):
memory: make it safer to expand arrays
daemon: use safer memory growth macros
memory: make it easier to avoid quadratic scaling of arrays
daemon: use more efficient memory growth macros
daemon/event.c | 44 ++++++++++-------------
daemon/libvirtd.c | 8 ++---
daemon/libvirtd.h | 11 +++---
docs/hacking.html.in | 61 ++++++++++++++++++++++++++------
src/util/memory.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++-
src/util/memory.h | 77 +++++++++++++++++++++++++++++++++++++---
6 files changed, 242 insertions(+), 53 deletions(-)
--
1.7.2.1
14 years, 3 months
[libvirt] xen live migration with libvirt
by 姚远
The format of live migration command is "virsh migrate --live domain xen:///
xenmigr://remotehost" or another?
My source and destination is rhel5.4 and xen is 3.1.0, libvirt is 0.8.2. I
configured a shared storage between source and destination and modified
/etc/xen/xend-config.sxp.
I test the command "xm migrate --live domain remotehost" and it's going
well. But when I use "virsh migrate --live domain xen:///
xenmigr://remotehost", a error appeared.
error:post operation failed:xend_post:error from xen daemon:(xend.err
'/usr/lib64/xen/bin/xc_save 23 2 0 0 5 failed')
Regards,
Best wishes.
14 years, 3 months
[libvirt] [PATCH v3] nwfilter:
by Stefan Berger
v3:
- Fixed an indentation problem
- added bool parameter to function terminating the IP address
learner threads to determine whether future threads may still run
(needed in case of driver reload) or all must terminate (need in case of
libvirtd termination)
v2:
- Fixes to the nwfilter driver reload function that also needs a
valid virConnectPtr.
In this patch I am extending and fixing the nwfilter module's reload
support to stop all ongoing threads (for learning IP addresses of
interfaces) and rebuild the filtering rules of all interfaces of all VMs
when libvirt is started. Now libvirtd rebuilds the filters upon the
SIGHUP signal and libvirtd restart.
About the patch: The nwfilter functions require a virConnectPtr.
Therefore I am opening a connection in qemudStartup, which later on
needs to be closed outside where the driver lock is held since otherwise
it ends up in a deadlock due to virConnectClose() trying to lock the
driver as well.
I have tested this now for a while with several machines running and
needing the IP address learner thread(s). The rebuilding of the firewall
rules seems to work fine following libvirtd restart or a SIGHUP. Also
the termination of libvirtd worked fine.
Signed-off-by: Stefan Berger <stefanb us ibm com>
---
src/nwfilter/nwfilter_driver.c | 21 +++++++++++---
src/nwfilter/nwfilter_learnipaddr.c | 16 ++++++++---
src/nwfilter/nwfilter_learnipaddr.h | 1
src/qemu/qemu_driver.c | 52
+++++++++++++++++++++++++++++++++---
4 files changed, 77 insertions(+), 13 deletions(-)
Index: libvirt-acl/src/nwfilter/nwfilter_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_driver.c
@@ -143,15 +143,26 @@ conf_init_err:
*/
static int
nwfilterDriverReload(void) {
+ virConnectPtr conn;
+
if (!driverState) {
return -1;
}
- nwfilterDriverLock(driverState);
- virNWFilterPoolLoadAllConfigs(NULL,
- &driverState->pools,
- driverState->configDir);
- nwfilterDriverUnlock(driverState);
+ conn = virConnectOpen("qemu:///system");
+
+ if (conn) {
+ /* shut down all threads -- qemud for example will restart them */
+ virNWFilterLearnThreadsTerminate(true);
+
+ nwfilterDriverLock(driverState);
+ virNWFilterPoolLoadAllConfigs(conn,
+ &driverState->pools,
+ driverState->configDir);
+ nwfilterDriverUnlock(driverState);
+
+ virConnectClose(conn);
+ }
return 0;
}
Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_learnipaddr.c
+++ libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
@@ -857,6 +857,17 @@ virNWFilterLearnInit(void) {
}
+void
+virNWFilterLearnThreadsTerminate(bool allowNewThreads) {
+ threadsTerminate = true;
+
+ while (virHashSize(pendingLearnReq) != 0)
+ usleep((PKT_TIMEOUT_MS * 1000) / 3);
+
+ if (allowNewThreads)
+ threadsTerminate = false;
+}
+
/**
* virNWFilterLearnShutdown
* Shutdown of this layer
@@ -864,10 +875,7 @@ virNWFilterLearnInit(void) {
void
virNWFilterLearnShutdown(void) {
- threadsTerminate = true;
-
- while (virHashSize(pendingLearnReq) != 0)
- usleep((PKT_TIMEOUT_MS * 1000) / 3);
+ virNWFilterLearnThreadsTerminate(false);
virHashFree(pendingLearnReq, freeLearnReqEntry);
pendingLearnReq = NULL;
Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.h
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_learnipaddr.h
+++ libvirt-acl/src/nwfilter/nwfilter_learnipaddr.h
@@ -71,5 +71,6 @@ void virNWFilterUnlockIface(const char *
int virNWFilterLearnInit(void);
void virNWFilterLearnShutdown(void);
+void virNWFilterLearnThreadsTerminate(bool allowNewThreads);
#endif /* __NWFILTER_LEARNIPADDR_H */
Index: libvirt-acl/src/qemu/qemu_driver.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_driver.c
+++ libvirt-acl/src/qemu/qemu_driver.c
@@ -170,6 +170,9 @@ static int qemuDetectVcpuPIDs(struct qem
static int qemuUpdateActivePciHostdevs(struct qemud_driver *driver,
virDomainDefPtr def);
+static int qemudVMFiltersInstantiate(virConnectPtr conn,
+ virDomainDefPtr def);
+
static struct qemud_driver *qemu_driver = NULL;
@@ -1423,6 +1426,10 @@ error:
return ret;
}
+struct virReconnectDomainData {
+ virConnectPtr conn;
+ struct qemud_driver *driver;
+};
/*
* Open an existing VM's monitor, re-detect VCPU threads
* and re-reserve the security labels in use
@@ -1431,9 +1438,11 @@ static void
qemuReconnectDomain(void *payload, const char *name ATTRIBUTE_UNUSED,
void *opaque)
{
virDomainObjPtr obj = payload;
- struct qemud_driver *driver = opaque;
+ struct virReconnectDomainData *data = opaque;
+ struct qemud_driver *driver = data->driver;
qemuDomainObjPrivatePtr priv;
unsigned long long qemuCmdFlags;
+ virConnectPtr conn = data->conn;
virDomainObjLock(obj);
@@ -1467,6 +1476,9 @@ qemuReconnectDomain(void *payload, const
obj) < 0)
goto error;
+ if (qemudVMFiltersInstantiate(conn, obj->def))
+ goto error;
+
if (obj->def->id >= driver->nextvmid)
driver->nextvmid = obj->def->id + 1;
@@ -1491,9 +1503,10 @@ error:
* about.
*/
static void
-qemuReconnectDomains(struct qemud_driver *driver)
+qemuReconnectDomains(virConnectPtr conn, struct qemud_driver *driver)
{
- virHashForEach(driver->domains.objs, qemuReconnectDomain, driver);
+ struct virReconnectDomainData data = {conn, driver};
+ virHashForEach(driver->domains.objs, qemuReconnectDomain, &data);
}
@@ -1691,6 +1704,7 @@ qemudStartup(int privileged) {
char *base = NULL;
char driverConf[PATH_MAX];
int rc;
+ virConnectPtr conn = NULL;
if (VIR_ALLOC(qemu_driver) < 0)
return -1;
@@ -1912,7 +1926,11 @@ qemudStartup(int privileged) {
1, NULL, NULL) < 0)
goto error;
- qemuReconnectDomains(qemu_driver);
+ conn = virConnectOpen(qemu_driver->privileged ?
+ "qemu:///system" :
+ "qemu:///session");
+
+ qemuReconnectDomains(conn, qemu_driver);
/* Then inactive persistent configs */
if (virDomainLoadAllConfigs(qemu_driver->caps,
@@ -1930,6 +1948,8 @@ qemudStartup(int privileged) {
qemudAutostartConfigs(qemu_driver);
+ if (conn)
+ virConnectClose(conn);
return 0;
@@ -1938,6 +1958,8 @@ out_of_memory:
error:
if (qemu_driver)
qemuDriverUnlock(qemu_driver);
+ if (conn)
+ virConnectClose(conn);
VIR_FREE(base);
qemudShutdown();
return -1;
@@ -12738,6 +12760,28 @@ qemudVMFilterRebuild(virConnectPtr conn
return 0;
}
+static int
+qemudVMFiltersInstantiate(virConnectPtr conn,
+ virDomainDefPtr def)
+{
+ int err = 0;
+ int i;
+
+ if (!conn)
+ return 1;
+
+ for (i = 0 ; i < def->nnets ; i++) {
+ virDomainNetDefPtr net = def->nets[i];
+ if ((net->filter) && (net->ifname)) {
+ if (virDomainConfNWFilterInstantiate(conn, net)) {
+ err = 1;
+ break;
+ }
+ }
+ }
+
+ return err;
+}
static virNWFilterCallbackDriver qemuCallbackDriver = {
.name = "QEMU",
14 years, 3 months
[libvirt] [PATCH] build: allow mingw VPATH build
by Eric Blake
* .gnulib: Update to latest.
Reported by Matthias Bolte.
---
Mainly for the top one, but there are a couple of relevant
upstream patches in this list.
* .gnulib 1629006...7ba06c8 (152):
> pthread: fix pthread.h creation for srcdir != builddir
> avoid some overlong lines from posix urls, etc.
> autoupdate
> missed commit
> autoupdate
> strtod: fix const diagnostic
> copy-acl: ignore ENOTSUP on HP-UX
> open, chown: relax license
> autocheck new ar-lib script from automake
> readlinkat: adjust client modules
> mknod: be more vocal about danger of running tests as root
> readlinkat: split into its own module
> memxfrm: Speed up.
> erroneous commas inside @var
> remove spurious leading i
> missing @item inside @itemize
> autoupdate
> Integrate the regex documentation.
> Whitespace cleanup.
> Add regex documentation.
> link: Update documentation.
> ansi-c++-opt: Mention last change in NEWS.
> Update modules list.
> Improve doc in MODULES.html.
> ansi-c++-opt: Provide option --enable-c++/--disable-c++ when possible.
> readlink, areadlink: Relax test a bit.
> unistr/u8-strstr, unistr/u16-strstr: Optimize the one-character case.
> unistr/u*-strstr: Fix dependencies.
> unistr/u8-chr, unistr/u8-strchr: Optimize and add comments.
> unistr/u8-strchr: Fix several bugs.
> More tests for unistr/u8-strchr.
> Oops, fix last commit so that it also works with modf().
> posix-modules: Ignore backup files of documentation files.
> symlinkat: Fix documentation.
> fchownat: Replace also when chown has the trailing slash bug.
> Complete last ChangeLog entry.
> linkat: Work around AIX 7.1 bug.
> Correctly determine whether pow is available in libc on AIX 7 with xlc.
> iconv: Work around AIX 6.1..7.1 bug.
> readlink: Relax test a bit.
> copysign: Does not require -lm on glibc systems.
> duplocale: Work around AIX 7.1 bug.
> dirfd: Avoid link error on AIX 7.1.
> strtod: next round of AIX fixes
> futimens: fix configure check
> getline: Update regarding AIX.
> wcwidth: Drop replacement on AIX 7.
> strtok_r: Avoid triggering bug in AIX 7.1 xlc compiler.
> unlink: Update regarding AIX.
> symlink: Update regarding AIX.
> strndup: Update regarding AIX.
> stat: Update regarding AIX.
> truncl: Fix autoconf test.
> round: Update regarding AIX.
> rename: Update regarding AIX.
> printf.m4: Update regarding AIX.
> iconv: Update regarding AIX.
> getopt: Update regarding AIX.
> ldexpl; Update regarding AIX.
> frexpl: Update regarding AIX.
> open, fopen: Update regarding AIX.
> chown: Update doc regarding AIX.
> autoupdate
> strtod: fix bug in replacement function on AIX
> mbrlen: Fix cross-compilation guess for AIX.
> mbrtowc: Fix cross-compilation guess for AIX.
> * build-aux/gendocs.sh: restore lost x bit
> init.sh: work around trap limitation of some shells
> strtod: aid debugging
> unistr/u*-chr, unistr/u*-strchr: Fix link errors and warnings.
> Add ChangeLog entries for recent commits.
> Use spaces for indentation, not tabs.
> mbspcasecmp: Fix function specification.
> autoupdate
> timespec: use cast and not conditional, as truncation isn't possible
> unistr/u8-chr, unistr/u8-strchr: use Boyer-Moore like algorithm.
> unistr/u*-strchr: add tests
> unistr/u*-chr: test multibyte sequences more
> unistr/u*-chr: test multibyte sequences
> unistr/u*-chr: prepare for multibyte tests
> unistr/u8-strchr: Optimize non-ASCII argument case.
> fdl.texi from gnustandards
> getcwd: on Solaris, work better if ancestors are inaccessible
> pthread: Add enough so that coreutils/src/sort.c compiles.
> striconveh: Simplify last commit.
> striconveh: Don't malloc memory if the result buffer is sufficient.
> strtod: Add safety check.
> Unify tests that set gl_cv_func_ldexpl_no_libm.
> Unify tests that set gl_cv_func_ldexp_no_libm.
> Unify tests that set gl_cv_func_frexpl_no_libm.
> Unify tests that set gl_cv_func_frexp_no_libm.
> memcoll: clarify sizes versus lengths, document better, and tweak perf
> Tests for module '_Exit'.
> New module '_Exit'.
> strtod: make it more-accurate typically, and don't require libm
> autoupdate
> unistr/u8-strchr: Optimize ASCII argument case.
> (x)memcoll: minor tweaks
> (x)memcoll: speedup when input is known to be NUL delimited
> bootstrap: discard non translation project po files
> fsusage: Clarify which code applies to which platforms.
> havelib: Fix bug when AC_LIB_FROMPACKAGE is used more than twice.
> hash: once again explicitly disallow insertion of NULL
> stdbool: Update doc.
> hash: extend module to deal with non-pointer keys
> gettext: Use AC_GNU_SOURCE as a fallback for AC_USE_SYSTEM_EXTENSIONS.
> idpriv-drop: Fix tests.
> string: Fix syntax error with g++ 2.96.
> unitypes: Fix bug introduced on 2010-05-18.
> autoupdate
> autoupdates
> memmem: slight optimization
> Fix HAVE_CALLOC_POSIX misnomer.
> Use modern idiom for calloc() replacement.
> Fix HAVE_REALLOC_POSIX misnomer.
> Use modern idiom for realloc() replacement.
> Fix HAVE_MALLOC_POSIX misnomer.
> Use modern idiom for malloc() replacement.
> stdio.in.h: fix compilation failure when using HP-UX 11's C compiler
> update from texinfo
> update from texinfo
> update from texinfo
> ipv6: fix detection under mingw
> strtod: Assume strtod() works when cross-compiling to new-enough glibc.
> Factor out common code in gl_FUNC_STRTOD.
> strtod: Stop using AC_FUNC_STRTOD.
> select: Correct timeout.
> git-version-gen: init shell var to avoid env var influence
> priv-set: Don't assume that priv.h exists merely because getppriv does.
> relocatable: Make it easier to test whether to install wrappers.
> gnulib-tool: Display specified modules and dependencies differently.
> gnulib-tool: Align code of func_import and func_create_testdir.
> test-inttostr: avoid spurious failure on Solaris 9
> update from texinfo
> test-sys_socket: mark variables as used more readably
> Avoid some more warnings from "gcc -Wwrite-strings".
> init.sh: change framework_failure_ to fail with status 99, not 1
> test-inttostr: avoid warnings about 4-6KB literal strings
> init.sh: don't use $ME_ or skip_ before they are defined
> test-sys_socket: avoid set-but-not-used warnings from gcc
> test-xvasprintf: avoid 'const' discard warnings
> tests: avoid compilation warnings in argmatch and exclude tests...
> tests: avoid 'const' discard warnings in mbsstr tests
> test-verify: avoid warning from gcc's -Wmissing-declarations
> test-inttostr.c: include <string.h> for use of strcmp
> test-linkat: avoid failed assertion on "other" architectures
> printf.m4: avoid autoconf's "Expanded Before Required" warning
> Replacement header templates are now named with ".in", not "_".
> inttostr-tests: depend on snprintf, not snprintf-posix
> autoupdate
> inttostr: add a new function, inttostr, and tests
> Add "Extending Gnulib" chapter to manual.
.gnulib | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/.gnulib b/.gnulib
index 1629006..7ba06c8 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 1629006348e1f66f07ce3ddcf3ebd2d14556cfce
+Subproject commit 7ba06c8ff37d8725cb824c64b94be41b9294ffb7
--
1.7.2.1
14 years, 3 months
[libvirt] [PATCH v2] esx: Explicitly disable unused floppy devices
by Matthias Bolte
floppy0.present defaults to true. Therefore, it needs to be
explicitly set to false when the XML config doesn't specify the
corresponding floppy device.
---
v2:
- This issue affects ESX too, the assumed default was wrong in
general
- Explicitly disable unused floppy devices independent of the
product version
src/esx/esx_vmx.c | 19 +++++++++++++++----
src/esx/esx_vmx.h | 2 +-
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
index d5d9ff0..12cd005 100644
--- a/src/esx/esx_vmx.c
+++ b/src/esx/esx_vmx.c
@@ -215,7 +215,7 @@ def->disks[0]...
## disks: floppy from .flp image ###############################################
- floppy0.present = "true" # defaults to "false"
+ floppy0.present = "true" # defaults to "true"
floppy0.startConnected = "true" # defaults to "true"
floppy0.clientDevice = "false" # defaults to "false"
@@ -235,7 +235,7 @@ def->disks[0]...
## disks: floppy from host device ##############################################
- floppy0.present = "true" # defaults to "false"
+ floppy0.present = "true" # defaults to "true"
floppy0.startConnected = "true" # defaults to "true"
floppy0.clientDevice = "false" # defaults to "false"
@@ -2320,6 +2320,7 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
virBuffer buffer = VIR_BUFFER_INITIALIZER;
bool scsi_present[4] = { false, false, false, false };
int scsi_virtualDev[4] = { -1, -1, -1, -1 };
+ bool floppy_present[2] = { false, false };
if (ctx->formatFileName == NULL) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -2525,7 +2526,8 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
break;
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
- if (esxVMX_FormatFloppy(ctx, def->disks[i], &buffer) < 0) {
+ if (esxVMX_FormatFloppy(ctx, def->disks[i], &buffer,
+ floppy_present) < 0) {
goto failure;
}
@@ -2539,6 +2541,13 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
}
}
+ for (i = 0; i < 2; ++i) {
+ /* floppy[0..1].present defaults to true, disable it explicitly */
+ if (! floppy_present[i]) {
+ virBufferVSprintf(&buffer, "floppy%d.present = \"false\"\n", i);
+ }
+ }
+
/* def:fss */
/* FIXME */
@@ -2810,7 +2819,7 @@ esxVMX_FormatCDROM(esxVMX_Context *ctx, virDomainDiskDefPtr def,
int
esxVMX_FormatFloppy(esxVMX_Context *ctx, virDomainDiskDefPtr def,
- virBufferPtr buffer)
+ virBufferPtr buffer, bool floppy_present[2])
{
int unit;
char *fileName = NULL;
@@ -2824,6 +2833,8 @@ esxVMX_FormatFloppy(esxVMX_Context *ctx, virDomainDiskDefPtr def,
return -1;
}
+ floppy_present[unit] = true;
+
virBufferVSprintf(buffer, "floppy%d.present = \"true\"\n", unit);
if (def->type == VIR_DOMAIN_DISK_TYPE_FILE) {
diff --git a/src/esx/esx_vmx.h b/src/esx/esx_vmx.h
index a77264a..12fc5af 100644
--- a/src/esx/esx_vmx.h
+++ b/src/esx/esx_vmx.h
@@ -137,7 +137,7 @@ esxVMX_FormatCDROM(esxVMX_Context *ctx, virDomainDiskDefPtr def,
int
esxVMX_FormatFloppy(esxVMX_Context *ctx, virDomainDiskDefPtr def,
- virBufferPtr buffer);
+ virBufferPtr buffer, bool floppy_present[2]);
int
esxVMX_FormatEthernet(virDomainNetDefPtr def, int controller,
--
1.7.0.4
14 years, 3 months
[libvirt] [PATCH] Generate libvirt_qemu.def from libvirt_qemu.syms for MinGW builds
by Matthias Bolte
---
configure.ac | 1 +
src/.gitignore | 1 +
src/Makefile.am | 9 ++++++++-
3 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index cd48c1b..a762bae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1866,6 +1866,7 @@ case "$host" in
# Also set the symbol file to .def, so src/Makefile generates libvirt.def
# from libvirt.syms and passes libvirt.def instead of libvirt.syms to the linker
LIBVIRT_SYMBOL_FILE=libvirt.def
+ LIBVIRT_QEMU_SYMBOL_FILE='$(srcdir)/libvirt_qemu.def'
# mingw's ld has the --version-script parameter, but it requires a .def file
# instead to work properly, therefore clear --version-script here and use
# -Wl, to pass the .def file to the linker
diff --git a/src/.gitignore b/src/.gitignore
index 5d114c9..7ea8d89 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -11,6 +11,7 @@ libvirt_parthelper
libvirt_lxc
libvirt.def
libvirt.syms
+libvirt_qemu.def
*.i
*.s
virt-aa-helper
diff --git a/src/Makefile.am b/src/Makefile.am
index a66eb2a..d7858dd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1010,7 +1010,7 @@ EXTRA_DIST += \
libvirt_daemon.syms \
libvirt_nwfilter.syms
-BUILT_SOURCES += libvirt.syms libvirt.def
+BUILT_SOURCES += libvirt.syms libvirt.def libvirt_qemu.def
libvirt.syms: libvirt_public.syms $(USED_SYM_FILES)
$(AM_V_GEN)rm -f $@-tmp $@ ; \
@@ -1033,6 +1033,13 @@ libvirt.def: libvirt.syms
chmod a-w $@-tmp && \
mv $@-tmp libvirt.def
+libvirt_qemu.def: libvirt_qemu.syms
+ $(AM_V_GEN)rm -f -- $@-tmp $@ ; \
+ printf 'EXPORTS\n' > $@-tmp && \
+ sed -e '/^$$/d; /#/d; /:/d; /\}/d; /\*/d; /LIBVIRT_/d; s/[ \t]*\(.*\)\;/ \1/g' $^ >> $@-tmp && \
+ chmod a-w $@-tmp && \
+ mv $@-tmp libvirt_qemu.def
+
# Empty source list - it merely links a bunch of convenience libs together
libvirt_la_SOURCES =
libvirt_la_LDFLAGS = $(VERSION_SCRIPT_FLAGS)$(LIBVIRT_SYMBOL_FILE) \
--
1.7.0.4
14 years, 3 months
[libvirt] [PATCH] PHYP: Add rudimentary network driver
by Eduardo Otubo
I changed virStorage[Open|Close] to virVIOSDriver[Open|Close] so
the network driver can use it - since the network driver deals
with Open/Close in the same way.
---
src/phyp/phyp_driver.c | 33 +++++++++++++++++++++++++++++----
1 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index aa4722e..975d941 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3864,7 +3864,7 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus)
}
static virDrvOpenStatus
-phypStorageOpen(virConnectPtr conn,
+phypVIOSDriverOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
int flags)
{
@@ -3877,7 +3877,7 @@ phypStorageOpen(virConnectPtr conn,
}
static int
-phypStorageClose(virConnectPtr conn ATTRIBUTE_UNUSED)
+phypVIOSDriverClose(virConnectPtr conn ATTRIBUTE_UNUSED)
{
return 0;
}
@@ -3984,8 +3984,8 @@ static virDriver phypDriver = {
static virStorageDriver phypStorageDriver = {
.name = "PHYP",
- .open = phypStorageOpen,
- .close = phypStorageClose,
+ .open = phypVIOSDriverOpen,
+ .close = phypVIOSDriverClose,
.numOfPools = phypNumOfStoragePools,
.listPools = phypListStoragePools,
@@ -4023,6 +4023,29 @@ static virStorageDriver phypStorageDriver = {
.poolIsPersistent = NULL
};
+static virNetworkDriver phypNetworkDriver = {
+ .name = "PHYP",
+ .open = phypVIOSDriverOpen,
+ .close = phypVIOSDriverClose,
+ .numOfNetworks = NULL,
+ .listNetworks = NULL,
+ .numOfDefinedNetworks = NULL,
+ .listDefinedNetworks = NULL,
+ .networkLookupByUUID = NULL,
+ .networkLookupByName = NULL,
+ .networkCreateXML = NULL,
+ .networkDefineXML = NULL,
+ .networkUndefine = NULL,
+ .networkCreate = NULL,
+ .networkDestroy = NULL,
+ .networkDumpXML = NULL,
+ .networkGetBridgeName = NULL,
+ .networkGetAutostart = NULL,
+ .networkSetAutostart = NULL,
+ .networkIsActive = NULL,
+ .networkIsPersistent = NULL
+};
+
int
phypRegister(void)
{
@@ -4030,6 +4053,8 @@ phypRegister(void)
return -1;
if (virRegisterStorageDriver(&phypStorageDriver) < 0)
return -1;
+ if (virRegisterNetworkDriver(&phypNetworkDriver) < 0)
+ return -1;
return 0;
}
--
1.7.0.4
14 years, 3 months
[libvirt] [PATCH 2/3] Make umlConnectTapDevice ask brAddTap for a persistent tap device.
by Soren Hansen
This patch does two things:
* It makes umlConnectTapDevice ask brAddTap for a persistent tap by
passing it a NULL tapfd argument.
* Stops umlConnectTapDevice from immediately dismantling the bridge
it just set up.
Signed-off-by: Soren Hansen <soren(a)linux2go.dk>
---
src/uml/uml_conf.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index bc8cbce..06543cb 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -112,7 +112,6 @@ umlConnectTapDevice(virDomainNetDefPtr net,
const char *bridge)
{
brControl *brctl = NULL;
- int tapfd = -1;
int template_ifname = 0;
int err;
unsigned char tapmac[VIR_MAC_BUFLEN];
@@ -140,7 +139,7 @@ umlConnectTapDevice(virDomainNetDefPtr net,
&net->ifname,
tapmac,
0,
- &tapfd))) {
+ NULL))) {
if (err == ENOTSUP) {
/* In this particular case, give a better diagnostic. */
umlReportError(VIR_ERR_INTERNAL_ERROR,
@@ -164,9 +163,6 @@ umlConnectTapDevice(virDomainNetDefPtr net,
VIR_FREE(net->ifname);
goto error;
}
- close(tapfd);
-
- brShutdown(brctl);
return 0;
--
1.7.0.4
14 years, 3 months
[libvirt] [PATCH 1/3] Close fd's of persistent tap devices
by Soren Hansen
When passing a NULL tapfd argument to brAddTap, we need to close the fd
of the tap device. If we don't, libvirt will keep the fd open
indefinitely and renders the the guest unable to configure its side of
the tap device.
Signed-off-by: Soren Hansen <soren(a)linux2go.dk>
---
src/util/bridge.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/util/bridge.c b/src/util/bridge.c
index 7d0caae..da62c5e 100644
--- a/src/util/bridge.c
+++ b/src/util/bridge.c
@@ -538,6 +538,8 @@ brAddTap(brControl *ctl,
goto error;
if (tapfd)
*tapfd = fd;
+ else
+ close(fd);
return 0;
error:
--
1.7.0.4
14 years, 3 months