Re: [libvirt] System.DllNotFoundException
by arnaud.champion@devatom.fr
?Hi,
what do you mean when you say "I use the .cs file you release to create a dll project" ?
C# bindings are provided with a visual studio 2010 solution, I think it's better to use it if you can. If you can't (because you have vs2005 or vs2008), please re-create a solution with all C# bindings codes.
Be sure you have the dll in your Debug directory :
libcurl-4.dll
libgcrypt-11.dll
libgnutls-26.dll
libgpg-error-0.dll
libportablexdr-0.dll
libtasn1-3.dll
libvirt-0.dll
libxml2-2.dll
Also, be carefull about one thing : these dll must be in the directory of the executable. I mean if you create a project "testBinding" which produce "testBindings.exe", then these dlls must be in the same directory of "testBindings.exe".
You can also use "depends.exe" (http://www.dependencywalker.com/) which is a tool used to check dll dependency. You open your libvirt-0.dll with it and see if there is no missing dll (maybe a dll miss you, and I don't see it because my system ever own it, I don't know).
Arnaud
From: 黄亮
Sent: Friday, October 29, 2010 3:51 AM
To: arnaud.champion(a)devatom.fr
Subject: System.DllNotFoundException
Hello Arnaud
I've compiled libvirt using photron scripts and got the libvirt-0.dll
I use the .cs file you released to create a dll project, and get CSharpDll.dll
Then I create a new project to invoke CSharpDll.dll, I got a System.DllNotFoundException while "Libvirt.Connect.Open" is trying to work.
The exception shows libvirt-0.dll cannot be found.
I tried to put libvirt-0.dll everywhere. In the same dir with .sln, with .cs file, in Debug dir, even in Windows/System32 dir. But I got no luck. It's still stuck.
So I need your help to get me out of the mess. Would you please tell me where I may go wrong?
Many Thanks
2010-10-29
--------------------------------------------------------------------------------
Lancer
14 years
[libvirt] [PATCH C#] Fix two memory leaks in the ConnectCredential.Result setter
by Matthias Bolte
StringToHGlobalAnsi returns a pointer to unmanaged memory that
must be freed using FreeHGlobal.
When the setter is called twice the strdup'ed unmanaged string
from the first call leaks. Free it before assigning it again.
---
NativeFunctions.cs | 6 +++++-
Types.cs | 13 +++++++++++--
projects/MonoDevelop/LibvirtBindings.dll.config | 2 ++
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/NativeFunctions.cs b/NativeFunctions.cs
index 25d7532..71136b8 100644
--- a/NativeFunctions.cs
+++ b/NativeFunctions.cs
@@ -16,8 +16,12 @@ namespace Libvirt
{
public class NativeFunctions
{
- // TODO : this is atemporary workaround for virConnectOpenAuth callback, this should be removed
+ // TODO : this is a temporary workaround for virConnectOpenAuth callback, this should be removed
[DllImport("msvcrt.dll", EntryPoint = "_strdup", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr StrDup(IntPtr strSource);
+
+ // TODO : this is a temporary workaround for virConnectOpenAuth callback, this should be removed
+ [DllImport("msvcrt.dll", EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)]
+ public static extern void Free(IntPtr ptr);
}
}
diff --git a/Types.cs b/Types.cs
index 0d471fb..37a1f47 100644
--- a/Types.cs
+++ b/Types.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C)
* Arnaud Champion <arnaud.champion(a)devatom.fr>
* Jaromír Červenka <cervajz(a)cervajz.com>
@@ -406,6 +406,10 @@ namespace Libvirt
[StructLayout(LayoutKind.Sequential)]
public class ConnectCredential
{
+ public ConnectCredential ()
+ {
+ result = IntPtr.Zero;
+ }
///<summary>
/// One of virConnectCredentialType constants
///</summary>
@@ -473,8 +477,13 @@ namespace Libvirt
}
set
{
- result = NativeFunctions.StrDup(Marshal.StringToHGlobalAnsi(value));
+ IntPtr tmp = Marshal.StringToHGlobalAnsi(value);
+
+ NativeFunctions.Free(result);
+ result = NativeFunctions.StrDup(tmp);
resultlen = (uint)value.Length;
+
+ Marshal.FreeHGlobal(tmp);
}
}
}
diff --git a/projects/MonoDevelop/LibvirtBindings.dll.config b/projects/MonoDevelop/LibvirtBindings.dll.config
index d0ded4c..2dfa2e4 100644
--- a/projects/MonoDevelop/LibvirtBindings.dll.config
+++ b/projects/MonoDevelop/LibvirtBindings.dll.config
@@ -6,6 +6,8 @@
</dllmap>
<dllmap dll="msvcrt.dll">
<dllentry os="windows" dll="msvcrt.dll" name="_strdup" target="_strdup" />
+ <dllentry os="windows" dll="msvcrt.dll" name="free" target="free" />
<dllentry os="linux" dll="libc.so.6" name="_strdup" target="strdup" />
+ <dllentry os="linux" dll="libc.so.6" name="free" target="free" />
</dllmap>
</configuration>
--
1.7.0.4
14 years
[libvirt] [PATCH] show compiled in options in virsh --version
by Daniel Veillard
To ease debugging this trivial patch allows to find what was compiled
in in the local version of libvirt, this doesn't work for remote access
but that's probably sufficient. With the patch I get on my machine:
paphio:~/libvirt/tools -> ./virsh --version
Virsh command line tool of libvirt 0.8.4
See web site at http://libvirt.org/
Compiled with support for:
Hypervisors: Xen QEmu/KVM UML OpenVZ LXC ESX PHYP Test
Networking: Remote Daemon Network Bridging Netcf Nwfilter
Storage: Dir Disk Filesystem SCSI Multipath iSCSI LVM
Miscellaneous: SELinux Secrets Debug Readline
paphio:~/libvirt/tools ->
instead of just "0.8.4"
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
14 years
[libvirt] [PATCH 0/2] speed up qemu domain save by increasing dd blocksize
by Laine Stump
These two patches are posted together because applying the 2nd exposes
the bug fixed by the first.
Here are the results of tests I made with various block sizes before
deciding the 1MB really was the best balance (all tests were done on a
paused 512MB domain, saving to local disk on a Lenovo T61 laptop)
BS M:SS save image size
----- ---- ---------------
2048K - 0:56 476135451
1024K - 0:56 475090953
512k - 1:02 474564173
256k - 1:10 474303797
128k - 1:25 474176859
512 - 3:47 474085423 - the original
I didn't bother testing sizes between 512 and 128k, as there was still
significant improvement from 128k to 256k.
14 years, 1 month
[libvirt] [PATCH] fix warnign on virtaudit.c
by KAMEZAWA Hiroyuki
I met this on the latest git tree.
==
>From fdd982b0cf3b772f61825736e6fc98bf948c4792 Mon Sep 17 00:00:00 2001
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com>
Date: Thu, 28 Oct 2010 16:18:07 +0900
Subject: [PATCH] libvirt-audit-printf-warning-fix
fix warning
CC libvirt_util_la-virtaudit.lo
cc1: warnings being treated as errors
util/virtaudit.c: In function 'virAuditEncode':
util/virtaudit.c:146: error: implicit declaration of function 'virAsprintf' [-Wimplicit-function-declaration]
util/virtaudit.c:146: error: nested extern declaration of 'virAsprintf' [-Wnested-externs]
---
src/util/virtaudit.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/util/virtaudit.c b/src/util/virtaudit.c
index d568660..6af7af0 100644
--- a/src/util/virtaudit.c
+++ b/src/util/virtaudit.c
@@ -30,6 +30,7 @@
#include "virterror_internal.h"
#include "logging.h"
#include "virtaudit.h"
+#include "util.h"
/* Provide the macros in case the header file is old.
FIXME: should be removed. */
--
1.7.2.3
14 years, 1 month
[libvirt] libvirt-csharp coverage update
by arnaud.champion@devatom.fr
?Hi Justin,
I have sended some patches today. When they will be pushed the coverage will the one in the xls file.
I have also changed the linux testing environment, now I test mono bindings with Ubuntu 10.10 x64 and mono compiled in 64 bits, because we have seen some troubles with marshaling in this configuration.
So, here are the all the test environements :
- Windows 7 (64 bits) / .Net 4
- Windows 7 (64 bits) / Mono (compiled in 32 bits) 2.6.7
- Ubuntu 10.10 amd64 / Mono (compiled in 64 bits) 2.6.7
I will notify you about any changes about testing envs.
Best regards,
Arnaud
14 years, 1 month
[libvirt] [PATCH] eliminate possibility of a double-closed file descriptor
by Stefan Berger
The 2nd and 3rd hunk show the only double-closed file descriptor code part
that I found while trying to clean up close(). The first hunk seems a
harmless cleanup in that same file.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
Index: Stefan/src/storage/storage_backend_logical.c
===================================================================
--- Stefan.orig/src/storage/storage_backend_logical.c
+++ Stefan/src/storage/storage_backend_logical.c
@@ -37,6 +37,7 @@
#include "util.h"
#include "memory.h"
#include "logging.h"
+#include "files.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE
@@ -408,10 +409,10 @@ virStorageBackendLogicalBuildPool(virCon
virReportSystemError(errno,
_("cannot clear device header of '%s'"),
pool->def->source.devices[i].path);
- close(fd);
+ VIR_FORCE_CLOSE(fd);
goto cleanup;
}
- if (close(fd) < 0) {
+ if (VIR_CLOSE(fd) < 0) {
virReportSystemError(errno,
_("cannot close device '%s'"),
pool->def->source.devices[i].path);
@@ -622,7 +623,7 @@ virStorageBackendLogicalCreateVol(virCon
goto cleanup;
}
- if (close(fd) < 0) {
+ if (VIR_CLOSE(fd) < 0) {
virReportSystemError(errno,
_("cannot close file '%s'"),
vol->target.path);
@@ -641,8 +642,7 @@ virStorageBackendLogicalCreateVol(virCon
return 0;
cleanup:
- if (fd != -1)
- close(fd);
+ VIR_FORCE_CLOSE(fd);
virStorageBackendLogicalDeleteVol(conn, pool, vol, 0);
return -1;
}
14 years, 1 month
[libvirt] [PATCH] qemu: check for vm after starting a job
by Eric Blake
https://bugzilla.redhat.com/show_bug.cgi?id=638285 - when migrating
a guest, it was very easy to provoke a race where an application
could query block information on a VM that had just been migrated
away. Any time qemu code obtains a job lock, it must also check
that the VM was not taken down in the time where it was waiting
for the lock.
* src/qemu/qemu_driver.c (qemudDomainSetMemory)
(qemudDomainGetInfo, qemuDomainGetBlockInfo): Check that vm still
exists after obtaining job lock, before starting monitor action.
---
src/qemu/qemu_driver.c | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ae1d833..af5126d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -463,7 +463,8 @@ static int ATTRIBUTE_RETURN_CHECK qemuDomainObjEndJob(virDomainObjPtr obj)
* obj must be locked before calling, qemud_driver must be unlocked
*
* To be called immediately before any QEMU monitor API call
- * Must have alrady called qemuDomainObjBeginJob().
+ * Must have already called qemuDomainObjBeginJob(), and checked
+ * that the VM is still active.
*
* To be followed with qemuDomainObjExitMonitor() once complete
*/
@@ -504,7 +505,7 @@ static void qemuDomainObjExitMonitor(virDomainObjPtr obj)
* obj must be locked before calling, qemud_driver must be locked
*
* To be called immediately before any QEMU monitor API call
- * Must have alrady called qemuDomainObjBeginJob().
+ * Must have already called qemuDomainObjBeginJob().
*
* To be followed with qemuDomainObjExitMonitorWithDriver() once complete
*/
@@ -522,7 +523,7 @@ static void qemuDomainObjEnterMonitorWithDriver(struct qemud_driver *driver, vir
/* obj must NOT be locked before calling, qemud_driver must be unlocked,
* and will be locked after returning
*
- * Should be paired with an earlier qemuDomainObjEnterMonitor() call
+ * Should be paired with an earlier qemuDomainObjEnterMonitorWithDriver() call
*/
static void qemuDomainObjExitMonitorWithDriver(struct qemud_driver *driver, virDomainObjPtr obj)
{
@@ -4948,6 +4949,12 @@ static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
if (qemuDomainObjBeginJob(vm) < 0)
goto cleanup;
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto endjob;
+ }
+
priv = vm->privateData;
qemuDomainObjEnterMonitor(vm);
r = qemuMonitorSetBalloon(priv->mon, newmem);
@@ -5014,11 +5021,17 @@ static int qemudDomainGetInfo(virDomainPtr dom,
} else if (!priv->jobActive) {
if (qemuDomainObjBeginJob(vm) < 0)
goto cleanup;
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto endjob;
+ }
qemuDomainObjEnterMonitor(vm);
err = qemuMonitorGetBalloonInfo(priv->mon, &balloon);
qemuDomainObjExitMonitor(vm);
if (err < 0) {
+ endjob:
if (qemuDomainObjEndJob(vm) == 0)
vm = NULL;
goto cleanup;
@@ -10343,6 +10356,11 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
qemuDomainObjPrivatePtr priv = vm->privateData;
if (qemuDomainObjBeginJob(vm) < 0)
goto cleanup;
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto endjob;
+ }
qemuDomainObjEnterMonitor(vm);
ret = qemuMonitorGetBlockExtent(priv->mon,
@@ -10350,6 +10368,7 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
&info->allocation);
qemuDomainObjExitMonitor(vm);
+ endjob:
if (qemuDomainObjEndJob(vm) == 0)
vm = NULL;
} else {
--
1.7.2.3
14 years, 1 month
[libvirt] iptables complains about a bad rule
by Matthias Bolte
With libvirt from git on Ubuntu 10.04 I get this 3 errors (actually 2
warnings an 1 error) when starting libvirtd:
23:15:45.221: error : virRunWithHook:855 : internal error
'/sbin/iptables --table mangle --delete POSTROUTING --out-interface
virbr0 --protocol udp --destination-port 68 --jump CHECKSUM
--checksum-fill' exited with non-zero status 2 and signal 0: iptables
v1.4.4: unknown option `--checksum-fill'
Try `iptables -h' or 'iptables --help' for more information.
23:15:45.238: error : virRunWithHook:855 : internal error
'/sbin/iptables --table filter --delete INPUT --in-interface virbr0
--protocol udp --destination-port 69 --jump ACCEPT' exited with
non-zero status 1 and signal 0: iptables: Bad rule (does a matching
rule exist in that chain?).
23:15:45.275: error : virRunWithHook:855 : internal error
'/sbin/iptables --table mangle --insert POSTROUTING --out-interface
virbr0 --protocol udp --destination-port 68 --jump CHECKSUM
--checksum-fill' exited with non-zero status 2 and signal 0: iptables
v1.4.4: unknown option `--checksum-fill'
Try `iptables -h' or 'iptables --help' for more information.
The first and the last one just indicate that my iptables here is too
old to know about --checksum-fill, but what about the second one?
Matthias
14 years, 1 month
[libvirt] cgroups and USB passthrough devices don't work together
by Diego Elio Pettenò
Hi all,
beside the problem with USB devices I sent the patch for earlier, there
is another problem that I'm not sure how to fix: the QEmu cgroup is
_not_ allowed to access the device when adding it to the virtual
machine.
Basically it'd need a call to virCgroupAllowDevicePath() when adding the
device…
--
Diego Elio Pettenò — “Flameeyes”
http://blog.flameeyes.eu/
If you found a .asc file in this mail and know not what it is,
it's a GnuPG digital signature: http://www.gnupg.org/
14 years, 1 month