[libvirt] [PATCH 1/2] event: fix doc typos, and doc more public methods
by Eric Blake
While working on events, I found a number of minor issues; I'm
hoisting these to the front rather than doing it piecemeal in
the patches where I first noticed bad or missing documentation.
* src/conf/object_event.c: Fix grammar, document all parameters
of public functions; wrap some long lines.
* src/conf/object_event.h: Likewise.
* src/conf/network_event.c: Likewise.
* src/conf/domain_event.c: Likewise (except for the large number
of event creation functions).
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/conf/domain_event.c | 64 +++++++++++++++++++++++++--------------
src/conf/network_event.c | 26 +++++++++++-----
src/conf/object_event.c | 78 +++++++++++++++++++++++++++++++++++++++++++-----
src/conf/object_event.h | 7 +++--
4 files changed, 134 insertions(+), 41 deletions(-)
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index e5f5796..8800568 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -1,7 +1,7 @@
/*
* domain_event.c: domain event queue processing helpers
*
- * Copyright (C) 2010-2013 Red Hat, Inc.
+ * Copyright (C) 2010-2014 Red Hat, Inc.
* Copyright (C) 2008 VirtualIron
* Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
*
@@ -70,7 +70,7 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
struct _virDomainEvent {
virObjectEvent parent;
- /* Unused attribute to get virDomainEvent class being created */
+ /* Unused attribute to allow for subclass creation */
bool dummy;
};
typedef struct _virDomainEvent virDomainEvent;
@@ -172,7 +172,8 @@ typedef struct _virDomainEventDeviceRemoved virDomainEventDeviceRemoved;
typedef virDomainEventDeviceRemoved *virDomainEventDeviceRemovedPtr;
-static int virDomainEventsOnceInit(void)
+static int
+virDomainEventsOnceInit(void)
{
if (!(virDomainEventClass =
virClassNew(virClassForObjectEvent(),
@@ -246,32 +247,37 @@ static int virDomainEventsOnceInit(void)
VIR_ONCE_GLOBAL_INIT(virDomainEvents)
-static void virDomainEventDispose(void *obj)
+static void
+virDomainEventDispose(void *obj)
{
virDomainEventPtr event = obj;
VIR_DEBUG("obj=%p", event);
}
-static void virDomainEventLifecycleDispose(void *obj)
+static void
+virDomainEventLifecycleDispose(void *obj)
{
virDomainEventLifecyclePtr event = obj;
VIR_DEBUG("obj=%p", event);
}
-static void virDomainEventRTCChangeDispose(void *obj)
+static void
+virDomainEventRTCChangeDispose(void *obj)
{
virDomainEventRTCChangePtr event = obj;
VIR_DEBUG("obj=%p", event);
}
-static void virDomainEventWatchdogDispose(void *obj)
+static void
+virDomainEventWatchdogDispose(void *obj)
{
virDomainEventWatchdogPtr event = obj;
VIR_DEBUG("obj=%p", event);
}
-static void virDomainEventIOErrorDispose(void *obj)
+static void
+virDomainEventIOErrorDispose(void *obj)
{
virDomainEventIOErrorPtr event = obj;
VIR_DEBUG("obj=%p", event);
@@ -281,7 +287,8 @@ static void virDomainEventIOErrorDispose(void *obj)
VIR_FREE(event->reason);
}
-static void virDomainEventGraphicsDispose(void *obj)
+static void
+virDomainEventGraphicsDispose(void *obj)
{
virDomainEventGraphicsPtr event = obj;
VIR_DEBUG("obj=%p", event);
@@ -307,7 +314,8 @@ static void virDomainEventGraphicsDispose(void *obj)
}
}
-static void virDomainEventBlockJobDispose(void *obj)
+static void
+virDomainEventBlockJobDispose(void *obj)
{
virDomainEventBlockJobPtr event = obj;
VIR_DEBUG("obj=%p", event);
@@ -315,7 +323,8 @@ static void virDomainEventBlockJobDispose(void *obj)
VIR_FREE(event->path);
}
-static void virDomainEventDiskChangeDispose(void *obj)
+static void
+virDomainEventDiskChangeDispose(void *obj)
{
virDomainEventDiskChangePtr event = obj;
VIR_DEBUG("obj=%p", event);
@@ -325,7 +334,8 @@ static void virDomainEventDiskChangeDispose(void *obj)
VIR_FREE(event->devAlias);
}
-static void virDomainEventTrayChangeDispose(void *obj)
+static void
+virDomainEventTrayChangeDispose(void *obj)
{
virDomainEventTrayChangePtr event = obj;
VIR_DEBUG("obj=%p", event);
@@ -333,13 +343,15 @@ static void virDomainEventTrayChangeDispose(void *obj)
VIR_FREE(event->devAlias);
}
-static void virDomainEventBalloonChangeDispose(void *obj)
+static void
+virDomainEventBalloonChangeDispose(void *obj)
{
virDomainEventBalloonChangePtr event = obj;
VIR_DEBUG("obj=%p", event);
}
-static void virDomainEventDeviceRemovedDispose(void *obj)
+static void
+virDomainEventDeviceRemovedDispose(void *obj)
{
virDomainEventDeviceRemovedPtr event = obj;
VIR_DEBUG("obj=%p", event);
@@ -354,7 +366,9 @@ static void virDomainEventDeviceRemovedDispose(void *obj)
* @cbList: the list
* @callback: the callback to remove
*
- * Internal function to remove a callback from a virObjectEventCallbackListPtr
+ * Internal function to remove a callback from a virObjectEventCallbackListPtr,
+ * when registered via the older virConnectDomainEventRegister with no
+ * callbackID
*/
static int
virDomainEventCallbackListRemove(virConnectPtr conn,
@@ -430,9 +444,11 @@ virDomainEventCallbackListMarkDelete(virConnectPtr conn,
* @conn: pointer to the connection
* @cbList: the list
* @callback: the callback to add
- * @opaque: opaque data tio pass to callback
+ * @opaque: opaque data to pass to @callback
+ * @freecb: callback to free @opaque
*
- * Internal function to add a callback from a virObjectEventCallbackListPtr
+ * Internal function to add a callback from a virObjectEventCallbackListPtr,
+ * when registered via the older virConnectDomainEventRegister.
*/
static int
virDomainEventCallbackListAdd(virConnectPtr conn,
@@ -1355,8 +1371,8 @@ cleanup:
* virDomainEventStateRegister:
* @conn: connection to associate with callback
* @state: object event state
- * @callback: function to remove from event
- * @opaque: data blob to pass to callback
+ * @callback: the callback to add
+ * @opaque: data blob to pass to @callback
* @freecb: callback to free @opaque
*
* Register the function @callback with connection @conn,
@@ -1409,14 +1425,16 @@ cleanup:
* virDomainEventStateRegisterID:
* @conn: connection to associate with callback
* @state: object event state
+ * @dom: optional domain for filtering the event
* @eventID: ID of the event type to register for
- * @cb: function to remove from event
- * @opaque: data blob to pass to callback
+ * @cb: function to invoke when event fires
+ * @opaque: data blob to pass to @callback
* @freecb: callback to free @opaque
* @callbackID: filled with callback ID
*
- * Register the function @callbackID with connection @conn,
- * from @state, for events of type @eventID.
+ * Register the function @cb with connection @conn, from @state, for
+ * events of type @eventID, and return the registration handle in
+ * @callbackID.
*
* Returns: the number of callbacks now registered, or -1 on error
*/
diff --git a/src/conf/network_event.c b/src/conf/network_event.c
index 3819702..a192ffe 100644
--- a/src/conf/network_event.c
+++ b/src/conf/network_event.c
@@ -1,6 +1,7 @@
/*
* network_event.c: network event queue processing helpers
*
+ * Copyright (C) 2014 Red Hat, Inc.
* Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
*
* This library is free software; you can redistribute it and/or
@@ -31,7 +32,7 @@
struct _virNetworkEvent {
virObjectEvent parent;
- /* Unused attribute to get virNetworkEvent class being created */
+ /* Unused attribute to allow for subclass creation */
bool dummy;
};
typedef struct _virNetworkEvent virNetworkEvent;
@@ -71,7 +72,7 @@ virNetworkEventsOnceInit(void)
VIR_ONCE_GLOBAL_INIT(virNetworkEvents)
-void
+static void
virNetworkEventDispose(void *obj)
{
virNetworkEventPtr event = obj;
@@ -79,7 +80,7 @@ virNetworkEventDispose(void *obj)
}
-void
+static void
virNetworkEventLifecycleDispose(void *obj)
{
virNetworkEventLifecyclePtr event = obj;
@@ -126,13 +127,14 @@ cleanup:
* @state: object event state
* @net: network to filter on or NULL for all networks
* @eventID: ID of the event type to register for
- * @cb: function to add to event
- * @opaque: data blob to pass to callback
+ * @cb: function to invoke when event occurs
+ * @opaque: data blob to pass to @callback
* @freecb: callback to free @opaque
* @callbackID: filled with callback ID
*
- * Register the function @callbackID with connection @conn,
- * from @state, for events of type @eventID.
+ * Register the function @cb with connection @conn, from @state, for
+ * events of type @eventID, and return the registration handle in
+ * @callbackID.
*
* Returns: the number of callbacks now registered, or -1 on error
*/
@@ -161,6 +163,16 @@ virNetworkEventStateRegisterID(virConnectPtr conn,
cb, opaque, freecb, callbackID);
}
+
+/**
+ * virNetworkEventLifecycleNew:
+ * @name: name of the network object the event describes
+ * @uuid: uuid of the network object the event describes
+ * @type: type of lifecycle event
+ * @detail: more details about @type
+ *
+ * Create a new network lifecycle event.
+ */
virObjectEventPtr
virNetworkEventLifecycleNew(const char *name,
const unsigned char *uuid,
diff --git a/src/conf/object_event.c b/src/conf/object_event.c
index c86974b..eca6a10 100644
--- a/src/conf/object_event.c
+++ b/src/conf/object_event.c
@@ -1,7 +1,7 @@
/*
* object_event.c: object event queue processing helpers
*
- * Copyright (C) 2010-2013 Red Hat, Inc.
+ * Copyright (C) 2010-2014 Red Hat, Inc.
* Copyright (C) 2008 VirtualIron
* Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
*
@@ -43,7 +43,6 @@ struct _virObjectEventQueue {
static virClassPtr virObjectEventClass;
-static virClassPtr virObjectEventClass;
static void virObjectEventDispose(void *obj);
static int
@@ -60,6 +59,12 @@ virObjectEventOnceInit(void)
VIR_ONCE_GLOBAL_INIT(virObjectEvent)
+/**
+ * virClassForObjectEvent:
+ *
+ * Return the class object to be used as a parent when creating an
+ * event subclass.
+ */
virClassPtr
virClassForObjectEvent(void)
{
@@ -233,7 +238,8 @@ virObjectEventCallbackListPurgeMarked(virObjectEventCallbackListPtr cbList)
* @klass: the base event class
* @eventID: the event ID
* @callback: the callback to add
- * @opaque: opaque data tio pass to callback
+ * @opaque: opaque data to pass to @callback
+ * @freecb: callback to free @opaque
* @callbackID: filled with callback ID
*
* Internal function to add a callback from a virObjectEventCallbackListPtr
@@ -399,18 +405,33 @@ virObjectEventQueueNew(void)
return ret;
}
+
+/**
+ * virObjectEventStateLock:
+ * @state: the event state object
+ *
+ * Lock event state before calling functions from object_event_private.h.
+ */
void
virObjectEventStateLock(virObjectEventStatePtr state)
{
virMutexLock(&state->lock);
}
+
+/**
+ * virObjectEventStateUnlock:
+ * @state: the event state object
+ *
+ * Unlock event state after calling functions from object_event_private.h.
+ */
void
virObjectEventStateUnlock(virObjectEventStatePtr state)
{
virMutexUnlock(&state->lock);
}
+
/**
* virObjectEventStateFree:
* @list: virObjectEventStatePtr to free
@@ -436,6 +457,16 @@ virObjectEventStateFree(virObjectEventStatePtr state)
static void virObjectEventStateFlush(virObjectEventStatePtr state);
+
+/**
+ * virObjectEventTimer:
+ * @timer: id of the event loop timer
+ * @opaque: the event state object
+ *
+ * Register this function with the event state as its opaque data as
+ * the callback of a periodic timer on the event loop, in order to
+ * flush the callback queue.
+ */
void
virObjectEventTimer(int timer ATTRIBUTE_UNUSED, void *opaque)
{
@@ -444,8 +475,11 @@ virObjectEventTimer(int timer ATTRIBUTE_UNUSED, void *opaque)
virObjectEventStateFlush(state);
}
+
/**
* virObjectEventStateNew:
+ *
+ * Allocate a new event state object.
*/
virObjectEventStatePtr
virObjectEventStateNew(void)
@@ -477,6 +511,18 @@ error:
return NULL;
}
+
+/**
+ * virObjectEventNew:
+ * @klass: subclass of event to be created
+ * @dispatcher: callback for dispatching the particular subclass of event
+ * @eventID: id of the event
+ * @id: id of the object the event describes, or 0
+ * @name: name of the object the event describes
+ * @uuid: uuid of the object the event describes
+ *
+ * Create a new event, with the information common to all events.
+ */
void *
virObjectEventNew(virClassPtr klass,
virObjectEventDispatchFunc dispatcher,
@@ -514,6 +560,7 @@ virObjectEventNew(virClassPtr klass,
return event;
}
+
/**
* virObjectEventQueuePush:
* @evtQueue: the object event queue
@@ -613,6 +660,16 @@ virObjectEventStateQueueDispatch(virObjectEventStatePtr state,
queue->count = 0;
}
+
+/**
+ * virObjectEventStateQueue:
+ * @state: the event state object
+ * @event: event to add to the queue
+ *
+ * Adds @event to the queue of events to be dispatched at the next
+ * safe moment. The caller should no longer use @event after this
+ * call.
+ */
void
virObjectEventStateQueue(virObjectEventStatePtr state,
virObjectEventPtr event)
@@ -667,15 +724,19 @@ virObjectEventStateFlush(virObjectEventStatePtr state)
* virObjectEventStateRegisterID:
* @conn: connection to associate with callback
* @state: domain event state
+ * @uuid: uuid of the object for event filtering
+ * @name: name of the object for event filtering
+ * @id: id of the object for event filtering, or 0
* @klass: the base event class
* @eventID: ID of the event type to register for
- * @cb: function to remove from event
- * @opaque: data blob to pass to callback
+ * @cb: function to invoke when event occurs
+ * @opaque: data blob to pass to @callback
* @freecb: callback to free @opaque
* @callbackID: filled with callback ID
*
- * Register the function @callbackID with connection @conn,
- * from @state, for events of type @eventID.
+ * Register the function @cb with connection @conn, from @state, for
+ * events of type @eventID, and return the registration handle in
+ * @callbackID.
*
* Returns: the number of callbacks now registered, or -1 on error
*/
@@ -746,7 +807,8 @@ virObjectEventStateDeregisterID(virConnectPtr conn,
virObjectEventStateLock(state);
if (state->isDispatching)
ret = virObjectEventCallbackListMarkDeleteID(conn,
- state->callbacks, callbackID);
+ state->callbacks,
+ callbackID);
else
ret = virObjectEventCallbackListRemoveID(conn,
state->callbacks, callbackID);
diff --git a/src/conf/object_event.h b/src/conf/object_event.h
index 23ecb34..fa1281c 100644
--- a/src/conf/object_event.h
+++ b/src/conf/object_event.h
@@ -1,7 +1,7 @@
/*
* object_event.h: object event queue processing helpers
*
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2012-2014 Red Hat, Inc.
* Copyright (C) 2008 VirtualIron
* Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
*
@@ -47,7 +47,7 @@ void virObjectEventStateFree(virObjectEventStatePtr state);
virObjectEventStatePtr
virObjectEventStateNew(void);
-/*
+/**
* virConnectObjectEventGenericCallback:
* @conn: the connection pointer
* @obj: the object pointer
@@ -60,7 +60,8 @@ typedef void (*virConnectObjectEventGenericCallback)(virConnectPtr conn,
void *obj,
void *opaque);
-# define VIR_OBJECT_EVENT_CALLBACK(cb) ((virConnectObjectEventGenericCallback)(cb))
+# define VIR_OBJECT_EVENT_CALLBACK(cb) \
+ ((virConnectObjectEventGenericCallback)(cb))
void
virObjectEventStateQueue(virObjectEventStatePtr state,
--
1.8.4.2
10 years, 11 months
[libvirt] [PATCHv5 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 regexp 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
v5:
* The patches are modified according to a first review by Laine Stump:
* renamed virSearchUuid to virSearchRegex and moved it from
viruuid.{c,h} to virstring.{c,h}.
* Various fixes.
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):
virstring.h/c: Util method for finding regexp 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/libvirt_private.syms | 2 +
src/util/virstring.c | 163 +++-
src/util/virstring.h | 4 +
src/vbox/vbox_tmpl.c | 2347 ++++++++++++++++++++++++++++++++++++++++++----
5 files changed, 2346 insertions(+), 171 deletions(-)
--
1.7.10.4
10 years, 11 months
[libvirt] [PATCH] BSD: implement nodeGetMemoryStats
by Roman Bogorodskiy
Implementation of nodeGetMemoryStats() for FreeBSD. I've added the
code under __APPLE__ directives as well with the other similar code,
however, I didn't test that on MacOS as I don't have one.
It would be good if somebody could test that on MacOS, otherwise I'll
probably just leave that code under #ifdef __FreeBSD__ only.
Roman Bogorodskiy (1):
BSD: implement nodeGetMemoryStats
src/nodeinfo.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
--
1.8.4.3
10 years, 11 months
[libvirt] How to change the env PATH of a container?
by WANG Cheng D
Dear Laine,
I will install a new version fedora as you said. Thank you.
By the way, do you know how to change the PATH of the container? I tried to change the .bashrc, but it doesn’t work.
I wonder if a container can have its own .bashrc.
Have a nice day.
Cheng
From: sendmail [mailto:justsendmailnothingelse@gmail.com] On Behalf Of Laine Stump
Sent: 2014年1月2日 17:21
To: libvir-list(a)redhat.com
Cc: WANG Cheng D
Subject: Re: [libvirt] How to execute an initial script in a container to start the network interface automatically
On 01/02/2014 05:16 AM, WANG Cheng D wrote:
Dear All,
Happy new year to you.
I have a similar question which had been replied by Daniel in the following post:
http://www.redhat.com/archives/libvir-list/2010-March/msg00296.html
I also want to assign a static IP to the container.
As Daniel said, I can successfully assign a static IP to the container manually using “ # ifconfig eth0 192.168.122.3 netmask 255.255.255.0 up”.
Daniel also said that we can use “the regular distro initscripts” to automatically start the network interface, but this doesn’t work on my system.
My host is fedora16.
I haven't played with lxc enough to answer your question, but you *definitely* need to upgrade your Fedora installation - Fedora 16 has been "out of support" (i.e. no new updates, not even for security holes) for almost a year now. Even if you're building your own libvirt from source (the 1.0.3 libvirt you're using is newer than the last update of libvirt for F16, but still several months out of date), the other packages on the system will be extremely out of date and likely to cause problems that will never be fixed (because no F16 package will ever again be updated).
My libvirtd and virsh version is 1.0.3.
10 years, 11 months
[libvirt] [RFC] Implementing ftrace support for libvirt
by yuxh
Hi all,
Happy new year!
The existing trace mechanism in libvirt is dtrace. Although the dtrace
can work, it's not work well enough. Every time we want get information
from the trace point we must write a systemtap script and run it
together with libvirt.
That's really unpractical on some occasion, especially on production
server since the systemtap script can't be executed automatically.
And some problems may be not easy to reproduce, then it will cost a
lot of time to get the trace information again.
So I think it is essential to add supporting for record the trace
information automatically in libvirt to satisfy the user's requirement.
That's why I'm currently implementing ftrace support in libvirt.
How do you think about my idea? Any comment will be appreciated!
Thanks,
Yu
10 years, 11 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, 11 months
[libvirt] [RFC] lxc.cgroup.blkio.weight_device automatic conversion
by Cedric Bosdonnat
Hi all,
I wish you all a happy new year 2014.
I'm currently implementing connectDomainXMLFromNative for the LXC
driver. The idea is to convert sourceforge LXC's config file into domain
XML files.
I just hit a problem with converting blkio device weights. LXC's config
directly stores the cgroup value, defining the device with it's major
and minor numbers. It seems to me that there is no way to get a path
from these numbers, so what would you think about extending
_virBlkioDevice to store either a path or a major/minor pair and extend
the domain XML schema accordingly?
Regards,
--
Cedric
10 years, 11 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, 11 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, 11 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, 11 months