[libvirt] [PATCH] lxcDomainShutdownFlags: Cleanup @flags usage
by Michal Privoznik
Currently, the @flags usage is a bit unclear at first sight to say the
least. There's no need for such unclear code especially when we can
borrow the working code from qemuDomainShutdownFlags().
In addition, this fixes one bug too. If user requested both
VIR_DOMAIN_SHUTDOWN_INITCTL and VIR_DOMAIN_SHUTDOWN_SIGNAL at the same
time, he is basically saying: 'Use the force Luke! If initctl fails try
sending a signal.' But with the current code we don't do that. If
initctl fails for some reason (e.g. inability to write to /dev/initctl)
we don't try sending any signal but fail immediately. To make things
worse, making a domain shutdown with bare _SIGNAL was working by blind
chance of a @rc variable being placed at correct place on the stack so
its initial value was zero.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/lxc/lxc_driver.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index c499182..a563b70 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2594,7 +2594,8 @@ lxcDomainShutdownFlags(virDomainPtr dom,
virDomainObjPtr vm;
char *vroot = NULL;
int ret = -1;
- int rc;
+ int rc = 0;
+ bool useInitctl = false, initctlRequested, signalRequested;
virCheckFlags(VIR_DOMAIN_SHUTDOWN_INITCTL |
VIR_DOMAIN_SHUTDOWN_SIGNAL, -1);
@@ -2623,25 +2624,24 @@ lxcDomainShutdownFlags(virDomainPtr dom,
(unsigned long long)priv->initpid) < 0)
goto cleanup;
- if (flags == 0 ||
- (flags & VIR_DOMAIN_SHUTDOWN_INITCTL)) {
- if ((rc = virInitctlSetRunLevel(VIR_INITCTL_RUNLEVEL_POWEROFF,
- vroot)) < 0) {
+ initctlRequested = flags & VIR_DOMAIN_SHUTDOWN_INITCTL;
+ signalRequested = flags & VIR_DOMAIN_SHUTDOWN_SIGNAL;
+
+ if (initctlRequested || !flags)
+ useInitctl = true;
+
+ if (useInitctl) {
+ rc = virInitctlSetRunLevel(VIR_INITCTL_RUNLEVEL_POWEROFF, vroot);
+ if (rc < 0 && !signalRequested)
goto cleanup;
- }
- if (rc == 0 && flags != 0 &&
- ((flags & ~VIR_DOMAIN_SHUTDOWN_INITCTL) == 0)) {
+ if (rc == 0 && !signalRequested) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("Container does not provide an initctl pipe"));
goto cleanup;
}
- } else {
- rc = 0;
}
- if (rc == 0 &&
- (flags == 0 ||
- (flags & VIR_DOMAIN_SHUTDOWN_SIGNAL))) {
+ if (rc == 0 && !useInitctl) {
if (kill(priv->initpid, SIGTERM) < 0 &&
errno != ESRCH) {
virReportSystemError(errno,
--
1.8.5.1
10 years, 10 months
[libvirt] Setting devid for emulated NICs (Xen 4.3.1 / libvirt 1.2.0) using libxl driver
by Stefan Bader
Using virt-manager "hypervisor default" type:
<interface type='bridge'>
<mac address='00:16:3e:5e:09:9d'/>
<source bridge='br0'/>
<script path='vif-bridge'/>
</interface>
This causes the qemu call to have "-net none" which removes PXE boot
abilities. A linux kernel has network through the xen pv-driver.
Changing in virt-manager to "e1000" type:
<interface type='bridge'>
<mac address='00:16:3e:5e:09:9d'/>
<source bridge='br0'/>
<script path='vif-bridge'/>
<model type='e1000'/>
</interface>
This currently (Xen 4.3.1 + libvirt 1.2.0) fails and the qemu arguments
in the log look suspicious:
-device e1000,id=nic-1,netdev=net-1,mac=00:16:3e:5e:09:9d
-netdev type=tap,id=net-1,ifname=vif1.-1-emu,script=no,downscript=no
Looking through git I found ba64b97134a6129a48684f22f31be92c3b6eef96
libxl: Allow libxl to set NIC devid
which removes a line that sets the devid of new NICs. I assume the comment
says (sorry I always seem to get confused reading it) that devid should
be auto-set by the libxl library provided by Xen. But I could not find
where that would be done. Even the xl command implementation sets it
explicitly. libxl_device_nic_init sets it to -1 which would explain the
wrong qemu arguments above.
For testing I re-added the following after the libxlMakeNic call:
--- libvirt-1.2.0.orig/src/libxl/libxl_conf.c 2013-12-11 17:04:17.000000000 +0
+++ libvirt-1.2.0/src/libxl/libxl_conf.c 2013-12-16 19:08:46.830016646 +0
@@ -907,6 +907,8 @@ libxlMakeNicList(virDomainDefPtr def, l
for (i = 0; i < nnics; i++) {
if (libxlMakeNic(l_nics[i], &x_nics[i]))
goto error;
+ if (x_nics[i].devid < 0)
+ x_nics[i].devid = i;
}
d_config->nics = x_nics;
And with that I get a working PXE boot when I set the device type
in the config. (Side note that I think not using a type defaults to
rtl8139 in the old xend driver. Maybe this should be the same for the
xl driver).
I am not sure how the right fix for it should look like as I am unsure
which part was supposed to set the devid. Just right now it does not
seem to be done.
-Stefan
10 years, 10 months
[libvirt] [PATCH libvirt-java] spec: Only install unversioned jar file
by Cole Robinson
As intended by Fedora's java packaging guidelines:
https://bugzilla.redhat.com/show_bug.cgi?id=1022139
---
libvirt-java.spec.in | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libvirt-java.spec.in b/libvirt-java.spec.in
index b5f1bf8..137af83 100644
--- a/libvirt-java.spec.in
+++ b/libvirt-java.spec.in
@@ -59,8 +59,7 @@ ant build jar docs
rm -fr %{buildroot}
install -d -m0755 %{buildroot}%{_javadir}
install -d -m0755 %{buildroot}%{_javadocdir}/%{name}-%{version}
-cp target/%{prefix}-%{version}.jar %{buildroot}%{_javadir}
-%{__ln_s} %{_javadir}/%{prefix}-%{version}.jar %{buildroot}%{_javadir}/%{prefix}.jar
+cp target/%{prefix}-%{version}.jar %{buildroot}%{_javadir}/%{prefix}.jar
cp -r target/javadoc/* %{buildroot}%{_javadocdir}/%{name}-%{version}
%{__ln_s} %{_javadocdir}/%{name}-%{version} %{buildroot}%{_javadocdir}/%{name}
--
1.8.4.2
10 years, 10 months
[libvirt] [PATCH] Support transient attribute on vmware disks
by Wout Mertens
From: Wout Mertens <Wout.Mertens(a)gmail.com>
vmx/vmx.c ignores the transient attribute on the disk xml format. This patch
adds a 1-1 relationship between it and [disk].mode = "independent-nonpersistent".
The other modes are ignored as before. It works in my testing.
https://bugzilla.redhat.com/show_bug.cgi?id=1044023
---
src/vmx/vmx.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 48487f8..4282390 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -1954,6 +1954,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
* busType = VIR_DOMAIN_DISK_BUS_FDC
* controllerOrBus = [0]
* unit = [0..1]
+ *
*/
int result = -1;
@@ -1980,6 +1981,9 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
char writeThrough_name[32] = "";
bool writeThrough = false;
+ char mode_name[32] = "";
+ char *mode = NULL;
+
if (def == NULL || *def != NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
@@ -2093,6 +2097,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
VMX_BUILD_NAME(fileType);
VMX_BUILD_NAME(fileName);
VMX_BUILD_NAME(writeThrough);
+ VMX_BUILD_NAME(mode);
/* vmx:present */
if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) {
@@ -2121,6 +2126,11 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
goto cleanup;
}
+ /* vmx:mode -> def:transient */
+ if (virVMXGetConfigString(conf, mode_name, &mode, true) < 0) {
+ goto cleanup;
+ }
+
if (clientDevice) {
/*
* Just ignore devices in client mode, because I have no clue how to
@@ -2172,6 +2182,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
(*def)->src = ctx->parseFileName(fileName, ctx->opaque);
(*def)->cachemode = writeThrough ? VIR_DOMAIN_DISK_CACHE_WRITETHRU
: VIR_DOMAIN_DISK_CACHE_DEFAULT;
+ (*def)->transient = STRCASEEQ(mode, "independent-nonpersistent") ? true: false;
if ((*def)->src == NULL) {
goto cleanup;
@@ -3497,7 +3508,11 @@ virVMXFormatDisk(virVMXContext *ctx, virDomainDiskDefPtr def,
return -1;
}
}
-
+
+ if (def->transient) {
+ virBufferAsprintf(buffer, "%s%d:%d.mode = \"independent-nonpersistent\"\n",
+ busType, controllerOrBus, unit);
+ }
return 0;
}
--
1.8.2.3
10 years, 10 months
[libvirt] [PATCH python] define __GNUC_PREREQ macro before using it
by Doug Goldstein
We brought over use of the __GNUC_PREREQ macro from libvirt but didn't
bring over the definition of it. This brings over the macro from libvirt
sources.
---
libvirt-utils.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/libvirt-utils.h b/libvirt-utils.h
index f55be7b..add7553 100644
--- a/libvirt-utils.h
+++ b/libvirt-utils.h
@@ -65,6 +65,15 @@
# endif
# ifdef __GNUC__
+
+# ifndef __GNUC_PREREQ
+# if defined __GNUC__ && defined __GNUC_MINOR__
+# define __GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+# else
+# define __GNUC_PREREQ(maj,min) 0
+# endif
+
/**
* ATTRIBUTE_UNUSED:
*
--
1.8.3.2
10 years, 10 months
[libvirt] Add patches to allow users to join running containers.
by dwalsh@redhat.com
[PATCH 1/2] Add virGetUserDirectoryByUID to retrieve users homedir
[PATCH 2/2] virt-login-shell joins users into lxc container.
This patch implements most of the changes suggested by Dan Berrange and
Eric Blake.
Some replies to suggested changes.
Removed mingw-libvirt.spec.in changes since virt lxc probably can not be
supported in Windows. Not sure if I need to make changes so my code will not
build on that platform.
Did not make the changes to install virt-login-shell as 4755 automatically.
I guess I want a more firm, make that change request...
I did not make a helper function to parse a list of strings out of conf file.
The getuid and getgid calls return the user that executed the program, when the app is setuid geteuid and getegid return "0". I believe getuid and getgid are correct.
Added virt-login-shell --help, not sure what --program would do?
The program is hard coded to LXC because there is no way that I know of for a ZZ
process to join a running qemu instance.
I have heard back from one security review from Miloslav Trmac, who had similar comments as Eric.
10 years, 10 months
[libvirt] [PATCHv4 0/5] Handling of undefine and redefine snapshots with VirtualBox 4.2
by Manuel VIVES
Hi,
This is a serie of patches in order to support undefining and redefining
snapshots with VirtualBox 4.2.
The serie of patches is rather big, and adds among other things some utility
functions unrelated to VirtualBox in patches 1 & 2.
The code review could be done in several parts: e.g. patches 1 & 2 separately to
validate the utility functions.
The VirtualBox API provides only high level operations to manipulate snapshots,
so it not possible to support flags like VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE and
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY with only API calls.
Following an IRC talk with Eric Blake, the decision was taken to emulate these
behaviours by manipulating directly the .vbox XML files.
The first two patches are some util methods for handling uuid and strings that
will be used after.
The third patch brings more details in the snapshot XML returned by libvirt.
We will need those modifications in order to redefine the snapshots.
The fourth patch brings the support of the VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE
and VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT flags in virDomainSnapshotCreateXML.
The fifth and last patch brings the support of the
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY
flag in virDomainSnapshotDelete.
The patches are only tested with Virtualbox 4.2 but the code is
compliant with Virtualbox 4.3 API.
Regards,
Manuel VIVES
V4:
* The code is compliant with Virtualbox 4.3 API
* Some minor modifications in order to satisfy "make syntax-check"
V3:
* Use of STREQ_NULLABLE instead of STREQ in one case
* Fix the method for finding uuids according to Ján Tomko review
V2:
* Fix a licence problem with the method for string replacement
Manuel VIVES (5):
viruuid.h/c: Util method for finding uuid patterns in some strings
virstring.h/c: Util method for making some find and replace in
strings
vbox_tmpl.c: Better XML description for snapshots
vbox_tmpl.c: Patch for redefining snapshots
vbox_tmpl.c: Add methods for undefining snapshots
po/POTFILES.in | 1 +
src/conf/domain_conf.c | 2 +-
src/libvirt_private.syms | 2 +
src/util/virstring.c | 48 ++
src/util/virstring.h | 2 +
src/util/viruuid.c | 81 ++
src/util/viruuid.h | 1 +
src/vbox/vbox_tmpl.c | 1854 +++++++++++++++++++++++++++++++++++++++++++---
8 files changed, 1879 insertions(+), 112 deletions(-)
--
1.7.10.4
10 years, 10 months
[libvirt] [PATCH] event: don't overwrite registration error message
by Eric Blake
Prior to this patch, an attempt to register an event without an
event loop started results in the vague:
libvirt: Remote Driver error : adding cb to list
Now it gives the much nicer:
libvirt: error : internal error: could not initialize domain event timer
This also avoids hiding other reasonable error messages, such as
attempts to register a duplicate callback or OOM errors.
Also, document the event loop usage requirement, since that was how
I ran into the issue.
* src/remote/remote_driver.c (remoteConnectNetworkEventRegisterAny)
(remoteConnectDomainEventRegister)
(remoteConnectDomainEventRegisterAny): Preserve more detailed error.
* src/libvirt.c (virConnectDomainEventRegister)
(virConnectDomainEventRegisterAny)
(virConnectNetworkEventRegisterAny): Document event loop requirement.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/libvirt.c | 24 +++++++++++++++---------
src/remote/remote_driver.c | 12 +++---------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 90773bb..f8b11b3 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -14829,11 +14829,13 @@ error:
* @freecb: optional function to deallocate opaque when not used anymore
*
* Adds a callback to receive notifications of domain lifecycle events
- * occurring on a connection
+ * occurring on a connection. This function requires that an event loop
+ * has been previously registered with virEventRegisterImpl() or
+ * virEventRegisterDefaultImpl().
*
* Use of this method is no longer recommended. Instead applications
* should try virConnectDomainEventRegisterAny() which has a more flexible
- * API contract
+ * API contract.
*
* The virDomainPtr object handle passed into the callback upon delivery
* of an event is only valid for the duration of execution of the callback.
@@ -14842,7 +14844,7 @@ error:
* The reference can be released once the object is no longer required
* by calling virDomainFree.
*
- * Returns 0 on success, -1 on failure
+ * Returns 0 on success, -1 on failure.
*/
int
virConnectDomainEventRegister(virConnectPtr conn,
@@ -17541,10 +17543,12 @@ error:
* @freecb: optional function to deallocate opaque when not used anymore
*
* Adds a callback to receive notifications of arbitrary domain events
- * occurring on a domain.
+ * occurring on a domain. This function requires that an event loop
+ * has been previously registered with virEventRegisterImpl() or
+ * virEventRegisterDefaultImpl().
*
* If @dom is NULL, then events will be monitored for any domain. If @dom
- * is non-NULL, then only the specific domain will be monitored
+ * is non-NULL, then only the specific domain will be monitored.
*
* Most types of event have a callback providing a custom set of parameters
* for the event. When registering an event, it is thus necessary to use
@@ -17562,7 +17566,7 @@ error:
* for the callback. To unregister a callback, this callback ID should
* be passed to the virConnectDomainEventDeregisterAny() method.
*
- * Returns a callback identifier on success, -1 on failure
+ * Returns a callback identifier on success, -1 on failure.
*/
int
virConnectDomainEventRegisterAny(virConnectPtr conn,
@@ -17657,10 +17661,12 @@ error:
* @freecb: optional function to deallocate opaque when not used anymore
*
* Adds a callback to receive notifications of arbitrary network events
- * occurring on a network.
+ * occurring on a network. This function requires that an event loop
+ * has been previously registered with virEventRegisterImpl() or
+ * virEventRegisterDefaultImpl().
*
* If @net is NULL, then events will be monitored for any network. If @net
- * is non-NULL, then only the specific network will be monitored
+ * is non-NULL, then only the specific network will be monitored.
*
* Most types of event have a callback providing a custom set of parameters
* for the event. When registering an event, it is thus necessary to use
@@ -17678,7 +17684,7 @@ error:
* for the callback. To unregister a callback, this callback ID should
* be passed to the virConnectNetworkEventDeregisterAny() method.
*
- * Returns a callback identifier on success, -1 on failure
+ * Returns a callback identifier on success, -1 on failure.
*/
int
virConnectNetworkEventRegisterAny(virConnectPtr conn,
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index be282d6..11785e2 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2932,10 +2932,8 @@ remoteConnectNetworkEventRegisterAny(virConnectPtr conn,
net, eventID,
VIR_OBJECT_EVENT_CALLBACK(callback),
opaque, freecb,
- &callbackID)) < 0) {
- virReportError(VIR_ERR_RPC, "%s", _("adding cb to list"));
+ &callbackID)) < 0)
goto done;
- }
/* If this is the first callback for this eventID, we need to enable
* events on the server */
@@ -4424,10 +4422,8 @@ static int remoteConnectDomainEventRegister(virConnectPtr conn,
remoteDriverLock(priv);
if ((count = virDomainEventStateRegister(conn, priv->domainEventState,
- callback, opaque, freecb)) < 0) {
- virReportError(VIR_ERR_RPC, "%s", _("adding cb to list"));
+ callback, opaque, freecb)) < 0)
goto done;
- }
if (count == 1) {
/* Tell the server when we are the first callback deregistering */
@@ -5234,10 +5230,8 @@ static int remoteConnectDomainEventRegisterAny(virConnectPtr conn,
priv->domainEventState,
dom, eventID,
callback, opaque, freecb,
- &callbackID)) < 0) {
- virReportError(VIR_ERR_RPC, "%s", _("adding cb to list"));
+ &callbackID)) < 0)
goto done;
- }
/* If this is the first callback for this eventID, we need to enable
* events on the server */
--
1.8.4.2
10 years, 10 months
[libvirt] Release of libvirt-python-1.2.0
by Daniel Veillard
So this is the first release fo the separated libvirt-python code base
out of the main libvirt git. In this case the two release have been made
in tandem to avoid disruptions, but there is no guarantee that the
future releases of both project will be bound together (though I will
try to sync those to minimize churn when possible !)
Tarball and rpms are now available on the new location:
ftp://libvirt.org/libvirt/python/
The release obviously is mostly around making the switch to an
independant package, and making sure that this will build on older
version of libvirt already released. Hence a very large set of the
patches are specific to portability issues:
Features:
- Separating libvirt-python releases from libvirt releases (Daniel P. Berrange and Doug Goldstein)
- Add missing binding of security model/label APIs (Daniel P. Berrange)
Bug Fixes:
- Return right error code for baselineCPU (Don Dugger)
- Add missing break to switch-case block (Doug Goldstein)
Documentation:
- Update README file contents and add HACKING file (Daniel P. Berrange)
Portability:
- Deal with old filenames for events/error functions (Daniel P. Berrange)
- Ensure API overrides only used if API exists (Daniel P. Berrange)
- Relax min required libvirt to version 0.9.11 (Daniel P. Berrange)
- virConnectGetCPUModelNames API appeared in 1.1.3 (Doug Goldstein)
- VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED appeared in 1.1.1 (Daniel P. Berrange)
- virDomainCreateXMLWithFiles and virDomainCreateWithFiles APIs appeared in 1.1.1 (Doug Goldstein)
- virDomainMigrate3 and virDomainMigrateToURI3 appeared in 1.1.0 (Doug Goldstein)
- virTypedParams* API appeared in 1.0.2 and used in 1.1.0 (Doug Goldstein)
- virDomainMigrateGetCompressionCache API appeared in 1.0.3 (Doug Goldstein)
- virDomainGetJobStats API appeared in 1.0.3 (Doug Goldstein)
- virNodeGetCPUMap API appeared in 1.0.0 (Doug Goldstein)
- VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK appeared in 1.0.0 (Daniel P. Berrange)
- virStoragePoolListAllVolumes API appeared in 0.10.2 (Doug Goldstein)
- virNode{Get,Set}MemoryParameters API appeared in 0.10.2 (Doug Goldstein)
- virConnectListAll* APIs appeared in 0.10.2 (Doug Goldstein)
- virDomainQemuAgentCommand appeared in 0.10.0 (Daniel P. Berrange)
- virDomainPinEmulator and virDomainGetEmulatorPinInfo APIs appeared in 0.10.0 (Doug Goldstein)
- VIR_DOMAIN_EVENT_ID_BALLOON_CHANGED appeared in 0.10.0 (Daniel P. Berrange)
- virConnect{Unr,R}egisterCloseCallback API appeared in 0.10.0 (Doug Goldstein)
- virDomainSnapshotListAllChildren API appeared in 0.9.13 (Doug Goldstein)
- virConnectListAllDomains API appeared in 0.9.13 (Doug Goldstein)
- virDomainListAllSnapshots API appeared in 0.9.13 (Doug Goldstein)
- Don't build LXC module when building less than 1.0.2 (Doug Goldstein)
Improvements:
- Improve quality of sanitytest check (Daniel P. Berrange)
- Skip copying manually written python for C APIs which don't exist (Daniel P. Berrange)
- Fix misc RPM specfile flaws (Daniel P. Berrange)
- Fix code for avoiding overrides of non-existant functions (Daniel P. Berrange)
- Avoid generating the methods in multiple classes (Daniel P. Berrange)
- Make block pull event dispatcher private (Daniel P. Berrange)
- Don't include virDomainSnapshotRef in python API (Daniel P. Berrange)
- Call virGetLastError from mod rather than py wrapper (Doug Goldstein)
- Make setup.py executable (Martin Kletzander)
- maint: next release is 1.2.0 (Eric Blake)
- Create array of modules to be built (Doug Goldstein)
- Break generator.py to be called per module (Doug Goldstein)
- Setup distutils build system (Daniel P. Berrange)
- Add execute permission for sanitytest.py (Daniel P. Berrange)
- Add build/ to python module path for sanitytest.py (Daniel P. Berrange)
- Import some virTypedParams* APIs from libvirt (Doug Goldstein)
- Import LIBVIR_CHECK_VERSION macro from libvirt (Doug Goldstein)
- Import VIR_FORCE_CLOSE macro from libvirt (Daniel P. Berrange)
- Remove use of virStrcpyStatic (Daniel P. Berrange)
- Import VIR_ALLOC / VIR_ALLOC_N / VIR_REALLOC_N functions (Daniel P. Berrange)
- Import code annotation macros from libvirt (Daniel P. Berrange)
- Import gnulib's ignore_value macro (Daniel P. Berrange)
- Import gnulib's xalloc_oversized macro (Daniel P. Berrange)
- Add decl of MIN macro (Daniel P. Berrange)
- Import STREQ macro from libvirt (Daniel P. Berrange)
- Update header file includes (Daniel P. Berrange)
- Update generator for new code layout (Daniel P. Berrange)
- Remove obsolete Makefile.am (Daniel P. Berrange)
- Move python example programs into python/examples/ subdirectory (Daniel P. Berrange)
Cleanups:
- Mostly revert "python: remove virConnectGetCPUModelNames from globals" (Daniel P. Berrange)
- python: remove virConnectGetCPUModelNames from globals (Doug Goldstein)
- python: remove virConnectGetCPUModelNames from globals (Doug Goldstein)
- maint: fix comma style issues: python (Eric Blake)
thanks everybody for your contributions to this release,
Daniel
--
Daniel Veillard | Open Source and Standards, Red Hat
veillard(a)redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
10 years, 10 months
[libvirt] [RFC/PATCH python] expose the bindings version to Python
by Doug Goldstein
The method getVersion() retrieves the version of the libvirt library
that the binaries are linked against but there is no way to retrieve the
version of the bindings you are using. In the future if we support new
APIs in Python that don't rely on features in the library there needs to
be a way for programmers to detect the version.
---
I would expect there's a cleaner way to implement this than I've done
but I opted for what I saw as the smallest implementation. If anyone
has a suggestion for a better way to do this I'm ok with redoing this
patch.
---
libvirt-override.py | 3 +++
setup.py | 16 ++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/libvirt-override.py b/libvirt-override.py
index 63f8ecb..ed8f73a 100644
--- a/libvirt-override.py
+++ b/libvirt-override.py
@@ -2,6 +2,9 @@
# Manually written part of python bindings for libvirt
#
+__version__ = '@VERSION@'
+version = @VER_TUPLE@
+
# On cygwin, the DLL is called cygvirtmod.dll
import sys
diff --git a/setup.py b/setup.py
index 24d4cf2..ad4f406 100755
--- a/setup.py
+++ b/setup.py
@@ -119,6 +119,21 @@ if have_libvirt_lxc:
class my_build(build):
+ def gen_version(self, filename):
+ os.rename(filename, filename + '.tmp')
+
+ version = self.distribution.get_version()
+ ver_tuple = tuple(int(x) for x in version.split('.'))
+
+ f1 = open(filename + '.tmp', 'r')
+ f2 = open(filename, 'w')
+ for line in f1:
+ f2.write(line
+ .replace('@VER_TUPLE@', str(ver_tuple))
+ .replace('@VERSION@', version))
+ f1.close()
+ f2.close()
+
def run(self):
apis = get_api_xml_files()
@@ -127,6 +142,7 @@ class my_build(build):
if have_libvirt_lxc:
self.spawn([sys.executable, "generator.py", "libvirt-lxc", apis[2]])
+ self.gen_version('build/libvirt.py')
build.run(self)
class my_sdist(sdist):
--
1.8.3.2
10 years, 10 months