[libvirt] Packaged Java bindings for libvirt
by Daniel Veillard
Now that java is officially free, it's a good time to get the bindings
the full support they deserve. This work is based on Tóth István ealier
0.0.1 version sent to the list. I refactored the tree a bit, added auto*
configure capabilities, spec file and added it in CVS.
I used a separate tree for CVS, I think we don't need to couple the
releases for both. The package is named libvirt-java (no suprize),
it compiles, build and seems to work fine on Fedora 9 with OpenJDK 6,
compilation seems to also work with gcj but my build failed because
jar failed to run du to a missing class...
I'm really not a Java expert, I would really welcome addition
from those who know, there is many things to be added:
- ant makefile
- Eclipse integration/makefile
- making it work on Windows
- completing the API to cover the full 0.4.x set
- many things that Java experts will find missing !
I think we can keep this mailing-list as the primary channel for
discussions.
The CVS base is next to the libvirt one, use the same instructions
but use 'co libvirt-java' instead of 'co libvirt', next thing I need to
do is write a documentation page to put on libvirt.org.
Anyway:
libvirt-java-0.1.0 can be fetched from ftp://libvirt.org/libvirt/java/
I will submit this for Fedora inclusion too,
feedback and patches very welcome.
many thanks to Tóth, he's the one who did all the code, and he reviewed
my first version :-)
enjoy !
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
16 years, 6 months
[libvirt] [PATCH] quiet "make syntax-check"
by Jim Meyering
[Here's a tiny patch, mainly to test our just-patched mailman.
Note the patch below, included verbatim from "git format-patch" output. ]
>From c7ac46c5ea71bb17164b4f94bd83106b8001944d Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 13 May 2008 11:20:07 +0200
Subject: [PATCH] quiet "make syntax-check"
* Makefile.maint (strftime-check): Add "@" prefix.
(po-check): Likewise.
---
Makefile.maint | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index a593ae2..dff75fe 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -420,7 +420,7 @@ patch-check:
# which date accepts but GNU strftime does not.
extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
strftime-check:
- if test -f $(srcdir)/src/date.c; then \
+ @if test -f $(srcdir)/src/date.c; then \
grep '^ %. ' $(srcdir)/src/date.c | sort \
| $(extract_char) > $@-src; \
{ echo N; \
@@ -467,7 +467,7 @@ m4-check:
# Verify that all source files using _() are listed in po/POTFILES.in.
# FIXME: don't hard-code file names below; use a more general mechanism.
po-check:
- if test -f po/POTFILES.in; then \
+ @if test -f po/POTFILES.in; then \
grep -E -v '^(#|$$)' po/POTFILES.in \
| grep -v '^src/false\.c$$' | sort > $@-1; \
files=; \
--
1.5.6.57.g6615b
16 years, 6 months
[libvirt] [PATCH] Eliminate noise from python type wrappers
by Ryan Scott
Hi,
We recently had a virt-install build failure when someone tried
building on a system with debug libvirt packages installed. It was
caused by extra noise from commands that load libvirt. For example:
$ python ./setup.py --version
libvirt_virConnectPtrWrap: node = 8938fb8
0.300.3
I've seen (internal) complaints about this, and I think the
irritation from the noise outweighs the usefulness of these statements,
so they should be removed.
Signed-off-by: Ryan Scott <ryan.scott(a)sun.com>
--- python/types.c.orig 2008-06-10 11:15:40.372795533 -0700
+++ python/types.c 2008-06-24 11:21:25.825967564 -0700
@@ -20,10 +20,6 @@ PyObject *
libvirt_intWrap(int val)
{
PyObject *ret;
-
-#ifdef DEBUG
- printf("libvirt_intWrap: val = %d\n", val);
-#endif
ret = PyInt_FromLong((long) val);
return (ret);
}
@@ -32,10 +28,6 @@ PyObject *
libvirt_longWrap(long val)
{
PyObject *ret;
-
-#ifdef DEBUG
- printf("libvirt_longWrap: val = %ld\n", val);
-#endif
ret = PyInt_FromLong(val);
return (ret);
}
@@ -44,10 +36,6 @@ PyObject *
libvirt_ulongWrap(unsigned long val)
{
PyObject *ret;
-
-#ifdef DEBUG
- printf("libvirt_ulongWrap: val = %lu\n", val);
-#endif
ret = PyLong_FromLong(val);
return (ret);
}
@@ -56,10 +44,6 @@ PyObject *
libvirt_longlongWrap(long long val)
{
PyObject *ret;
-
-#ifdef DEBUG
- printf("libvirt_longWrap: val = %ld\n", val);
-#endif
ret = PyLong_FromUnsignedLongLong((unsigned long long) val);
return (ret);
}
@@ -73,9 +57,6 @@ libvirt_charPtrWrap(char *str)
Py_INCREF(Py_None);
return (Py_None);
}
-#ifdef DEBUG
- printf("libvirt_xmlcharPtrWrap: str = %s\n", str);
-#endif
ret = PyString_FromString(str);
free(str);
return (ret);
@@ -90,9 +71,6 @@ libvirt_constcharPtrWrap(const char *str
Py_INCREF(Py_None);
return (Py_None);
}
-#ifdef DEBUG
- printf("libvirt_xmlcharPtrWrap: str = %s\n", str);
-#endif
ret = PyString_FromString(str);
return (ret);
}
@@ -106,9 +84,6 @@ libvirt_charPtrConstWrap(const char *str
Py_INCREF(Py_None);
return (Py_None);
}
-#ifdef DEBUG
- printf("libvirt_xmlcharPtrWrap: str = %s\n", str);
-#endif
ret = PyString_FromString(str);
return (ret);
}
@@ -118,9 +93,6 @@ libvirt_virDomainPtrWrap(virDomainPtr no
{
PyObject *ret;
-#ifdef DEBUG
- printf("libvirt_virDomainPtrWrap: node = %p\n", node);
-#endif
if (node == NULL) {
Py_INCREF(Py_None);
return (Py_None);
@@ -136,9 +108,6 @@ libvirt_virNetworkPtrWrap(virNetworkPtr
{
PyObject *ret;
-#ifdef DEBUG
- printf("libvirt_virNetworkPtrWrap: node = %p\n", node);
-#endif
if (node == NULL) {
Py_INCREF(Py_None);
return (Py_None);
@@ -154,9 +123,6 @@ libvirt_virStoragePoolPtrWrap(virStorage
{
PyObject *ret;
-#ifdef DEBUG
- printf("libvirt_virStoragePoolPtrWrap: node = %p\n", node);
-#endif
if (node == NULL) {
Py_INCREF(Py_None);
return (Py_None);
@@ -172,9 +138,6 @@ libvirt_virStorageVolPtrWrap(virStorageV
{
PyObject *ret;
-#ifdef DEBUG
- printf("libvirt_virStorageVolPtrWrap: node = %p\n", node);
-#endif
if (node == NULL) {
Py_INCREF(Py_None);
return (Py_None);
@@ -190,9 +153,6 @@ libvirt_virConnectPtrWrap(virConnectPtr
{
PyObject *ret;
-#ifdef DEBUG
- printf("libvirt_virConnectPtrWrap: node = %p\n", node);
-#endif
if (node == NULL) {
Py_INCREF(Py_None);
return (Py_None);
16 years, 6 months
[libvirt] Release of libvirt-0.4.4
by Daniel Veillard
A new release to fix the few bugs which made 0.4.3 really unsuitable for oVirt
available as usual at ftp://libvirt.org/libvirt/
* Bug fixes:
- QEmu network serialization (Kaitlin Rupert)
- internal memory allocation fixes (Chris Lalancette Jim Meyering)
- virsh large file config problem (Jim Meyering)
- xen list APIs when max is zero
- string escape problems in the xm driver
* Improvements:
- add autogen to tarballs
- improve iSCSI support (Chris Lalancette)
- localization updates
* Cleanups:
- const-ness fixed (Daniel P. Berrange)
- string helpers for enumeations (Daniel P. Berrange)
thanks for the bug reports and patches !
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
16 years, 6 months
[libvirt] PATCH: Helper for enumerations
by Daniel P. Berrange
There are quite a few places in our code where we have to convert from
a string to an int enumeration, and vica-verca. This is tedious code to
write, and I'm about to introduce a tonne more enumerations in the new
generic domain XML parser / generator. So I reckon its time for some
helper APIs
The current pattern is that we have an enumeration
enum virStoragePoolDisk {
VIR_STORAGE_POOL_DISK_DOS,
VIR_STORAGE_POOL_DISK_DVH,
VIR_STORAGE_POOL_DISK_GPT,
VIR_STORAGE_POOL_DISK_MAC,
VIR_STORAGE_POOL_DISK_BSD,
VIR_STORAGE_POOL_DISK_PC98,
VIR_STORAGE_POOL_DISK_SUN,
};
And then 2 helpers
static int
virStorageBackendDiskPoolFormatFromString(const char *format) {
if (STREQ(format, "dos"))
return VIR_STORAGE_POOL_DISK_DOS;
if (STREQ(format, "dvh"))
return VIR_STORAGE_POOL_DISK_DVH;
if (STREQ(format, "gpt"))
return VIR_STORAGE_POOL_DISK_GPT;
if (STREQ(format, "mac"))
return VIR_STORAGE_POOL_DISK_MAC;
if (STREQ(format, "bsd"))
return VIR_STORAGE_POOL_DISK_BSD;
if (STREQ(format, "pc98"))
return VIR_STORAGE_POOL_DISK_PC98;
if (STREQ(format, "sun"))
return VIR_STORAGE_POOL_DISK_SUN;
return -1;
}
static const char *
virStorageBackendDiskPoolFormatToString(int format) {
switch (format) {
case VIR_STORAGE_POOL_DISK_DOS:
return "dos";
case VIR_STORAGE_POOL_DISK_DVH:
return "dvh";
case VIR_STORAGE_POOL_DISK_GPT:
return "gpt";
case VIR_STORAGE_POOL_DISK_MAC:
return "mac";
case VIR_STORAGE_POOL_DISK_BSD:
return "bsd";
case VIR_STORAGE_POOL_DISK_PC98:
return "pc98";
case VIR_STORAGE_POOL_DISK_SUN:
return "sun";
}
return NULL;
}
This patch adds 2 generic ToString and FromString methods to the util.c
module, which take a list of strings, in the same order as the enum
int virEnumFromString(const char *const*types,
int ntypes,
const char *type);
const char *virEnumToString(const char *const*types,
int ntypes,
int type);
Passing around the list of strings (the "char *const*types" arg) is a
little tedious, so there are 2 macros to simplify this by defining
wrappers around the virEnumXXX functions
VIR_ENUM_DECL(name)
will define the function prototypes, and should be used in a header
file, while
VIR_ENUM_IMPL(name, maxvals, types)
will define the implementation, type checked at compile time
So, going back to the earlier example - we need to adapt the enum to add
a sentinal at the end
enum virStoragePoolDisk {
VIR_STORAGE_POOL_DISK_DOS,
VIR_STORAGE_POOL_DISK_DVH,
VIR_STORAGE_POOL_DISK_GPT,
VIR_STORAGE_POOL_DISK_MAC,
VIR_STORAGE_POOL_DISK_BSD,
VIR_STORAGE_POOL_DISK_PC98,
VIR_STORAGE_POOL_DISK_SUN,
VIR_STORAGE_POOL_DISK_LAST
};
Then, we can provide the ToString and FromString methods with just
VIR_ENUM_DECL(virStoragePoolDisk)
VIR_ENUM_IMPL(virStoragePoolDisk, VIR_STORAGE_POOL_DISK_LAST,
"dos", "dvh", "gpt", "mac", "bsd", "pc98", "sun")
This has compile time checking to ensure there are enough strings for every
enumeration value.
Daniel.
diff -r bc1615919490 src/util.c
--- a/src/util.c Fri Jun 13 15:43:20 2008 +0100
+++ b/src/util.c Fri Jun 13 18:52:39 2008 +0100
@@ -798,3 +798,24 @@
return idx;
}
+int virEnumFromString(const char *const*types,
+ int ntypes,
+ const char *type)
+{
+ int i;
+ for (i = 0 ; i < ntypes ; i++)
+ if (STREQ(types[i], type))
+ return i;
+
+ return -1;
+}
+
+const char *virEnumToString(const char *const*types,
+ int ntypes,
+ int type)
+{
+ if (type < 0 || type >= ntypes)
+ return NULL;
+
+ return types[type];
+}
diff -r bc1615919490 src/util.h
--- a/src/util.h Fri Jun 13 15:43:20 2008 +0100
+++ b/src/util.h Fri Jun 13 18:52:39 2008 +0100
@@ -25,6 +25,7 @@
#define __VIR_UTIL_H__
#include "util-lib.h"
+#include "verify.h"
int virExec(virConnectPtr conn, char **argv, int *retpid,
int infd, int *outfd, int *errfd);
@@ -88,4 +89,31 @@
int virDiskNameToIndex(const char* str);
+
+int virEnumFromString(const char *const*types,
+ int ntypes,
+ const char *type);
+
+const char *virEnumToString(const char *const*types,
+ int ntypes,
+ int type);
+
+#define VIR_ENUM_IMPL(name, lastVal, ...) \
+ static const char const *name ## TypeList[] = { __VA_ARGS__ }; \
+ verify(ARRAY_CARDINALITY(name ## TypeList) == lastVal); \
+ const char *name ## TypeToString(int type) { \
+ return virEnumToString(name ## TypeList, \
+ ARRAY_CARDINALITY(name ## TypeList), \
+ type); \
+ } \
+ int name ## TypeFromString(const char *type) { \
+ return virEnumFromString(name ## TypeList, \
+ ARRAY_CARDINALITY(name ## TypeList), \
+ type); \
+ }
+
+#define VIR_ENUM_DECL(name) \
+ const char *name ## TypeToString(int type); \
+ int name ## TypeFromString(const char*type);
+
#endif /* __VIR_UTIL_H__ */
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
16 years, 6 months
[libvirt] [PATCH 0 of 3] LXC network interface support
by Dan Smith
This set is actually authored by Dave Leskovec. He is moving on to some other
work and I will be working this into the tree. I have made a few changes
to this, mostly to allow this code to compile out if the proper kernel
and userspace support is not present.
I am submitting it as an RFC because the required kernel patches are not yet
upstream (even in -mm) and there are some missing userspace patches to
iproute2 as well. I expect there to be quite a few comments and suggestions
about the veth.c patch, so I wanted to go ahead and get that started while
we wait for upstream to catch up.
Comments appreciated!
16 years, 6 months
[Libvir] [PATCH] Fix USB device name mis-conversion from S-Expr to XML
by Hiroyuki Kaguchi
"tablet" and "mouse" are set as a value of the
/local/domain/<domid>/image/hvm/usbdevice,
but libvirt expects "usbdevice" and "usbmouse" as a value.
This causes the following.
If a USB device is attached by virt-manager,
the USB device is not seen from virt-manager.
This patch fixes expected value of libvirt
Thanks,
Hiroyuki Kaguchi
Index: xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.162
diff -u -r1.162 xend_internal.c
--- xend_internal.c 21 Jan 2008 16:29:10 -0000 1.162
+++ xend_internal.c 23 Jan 2008 00:37:02 -0000
@@ -1743,11 +1743,9 @@
node = cur->u.s.car;
if (sexpr_lookup(node, "usbdevice")) {
tmp = sexpr_node(node, "usbdevice");
- if (tmp && *tmp) {
- if (!strcmp(tmp, "usbtablet"))
- virBufferAdd(&buf, " <input type='tablet'
bus='usb'/>\n", 37);
- else if (!strcmp(tmp, "usbmouse"))
- virBufferAdd(&buf, " <input type='mouse'
bus='usb'/>\n", 36);
+ if (!strcmp(tmp, "tablet") ||
+ !strcmp(tmp, "mouse")) {
+ virBufferVSprintf(&buf, " <input type='%s'
bus='usb'/>\n", tmp);
}
}
}
16 years, 6 months
[libvirt] libvirt passes wrong MAC address to KVM
by Nikola Ciprich
Hi all,
I think there could be a bug in libvirt passing MAC address to KVM.
If I have following in my xml config:
<interface type="bridge">
<source bridge="br0"/>
<mac address="00:16:3e:0d:24:00"/>
</interface>
and start the domain (I'm using python binding btw), qemu is then executed with following parameter:
... -net nic,macaddr=00:16:3e:18:24:00,vlan=0 ...
MAC address given in config is not used by any other machine. Does somebody have a tip on where the problem could be?
I'm using libvirt-0.4.3.
Thanks in advance
BR
nik
--
-------------------------------------
Nikola CIPRICH
LinuxBox.cz, s.r.o.
28. rijna 168, 709 01 Ostrava
tel.: +420 596 603 142
fax: +420 596 621 273
mobil: +420 777 093 799
www.linuxbox.cz
mobil servis: +420 737 238 656
email servis: servis(a)linuxbox.cz
-------------------------------------
16 years, 6 months