[libvirt] [Patch v3 0/3] Add QEMU network helper support
by rmarwah@linux.vnet.ibm.com
From: Richa Marwaha <rmarwah(a)linux.vnet.ibm.com>
QEMU has a new feature which allows QEMU to execute under an unprivileged user ID and still be able to
add a tap device to a Linux network bridge. Below is the link to the QEMU patches for the bridge helper
feature:
http://lists.gnu.org/archive/html/qemu-devel/2012-01/msg03562.html
The existing libvirt tap network device support for adding a tap device to a bridge (-netdev tap) works
only when connected to a libvirtd instance running as the privileged system account 'root'.
When connected to a libvirtd instance running as an unprivileged user (ie. using the session URI) creation of
the tap device fails as follows:
error: Failed to start domain F14_64 error: Unable to create tap device vnet%d: Operation not permitted
With this support, creating a tap device in the above scenario will be possible. Additionally, hot attaching
a tap device to a bridge while running when connected to a libvirtd instance running as an unprivileged user
will be possible.
Richa Marwaha (3):
Add -netdev bridge capabilities
Add -netdev bridge support
apparmor: QEMU bridge helper policy updates
AUTHORS | 1 +
examples/apparmor/libvirt-qemu | 21 ++++++++++++++-
src/qemu/qemu_capabilities.c | 13 ++++++---
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 57 +++++++++++++++++++++++++++++----------
src/qemu/qemu_command.h | 2 +
src/qemu/qemu_hotplug.c | 31 ++++++++++++++-------
tests/qemuhelptest.c | 3 +-
8 files changed, 98 insertions(+), 31 deletions(-)
12 years, 3 months
[libvirt] [PATCH] Fix save/restore with USB controller in XML.
by Ján Tomko
USB controller gets put on the first place in XML, but the default one
is added at the end of the controllers array. Sorting them before
checking ABI compatibility solves this.
The default USB controller also doesn't get a PCI address assigned,
making virDomainDeviceInfoCheckABIStability fail.
---
src/conf/domain_conf.c | 55 +++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 58603a3..c98802a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9765,8 +9765,10 @@ static bool virDomainControllerDefCheckABIStability(virDomainControllerDefPtr sr
}
}
- if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
- goto cleanup;
+ /* don't check device info for the default USB controller */
+ if (!(src->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && src->idx == 0 && src->model == -1))
+ if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
+ goto cleanup;
identical = true;
@@ -10180,6 +10182,27 @@ cleanup:
return identical;
}
+static int virDomainControllerCmp(const void *ctrl1,
+ const void *ctrl2)
+{
+ virDomainControllerDefPtr c1 = *(virDomainControllerDefPtr*) ctrl1;
+ virDomainControllerDefPtr c2 = *(virDomainControllerDefPtr*) ctrl2;
+
+ if (c1->type < c2->type)
+ return -1;
+ if (c1->type > c2->type)
+ return 1;
+ if (c1->idx < c2->idx)
+ return -1;
+ if (c1->idx > c2->idx)
+ return 1;
+ if (c1->model < c1->model)
+ return -1;
+ if (c1->model > c2->model)
+ return 1;
+ return 0;
+}
+
/* This compares two configurations and looks for any differences
* which will affect the guest ABI. This is primarily to allow
@@ -10191,6 +10214,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
bool identical = false;
int i;
+ virDomainControllerDefPtr *scontrollers = NULL;
+ virDomainControllerDefPtr *dcontrollers = NULL;
+
if (src->virtType != dst->virtType) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target domain virt type %s does not match source %s"),
@@ -10312,10 +10338,33 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
goto cleanup;
}
+ /* sort the controllers before comparison */
+ if (VIR_ALLOC_N(scontrollers, src->ncontrollers) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ memcpy(scontrollers, src->controllers, src->ncontrollers*sizeof(src->controllers[0]));
+ qsort(scontrollers, src->ncontrollers, sizeof(virDomainControllerDefPtr),
+ virDomainControllerCmp);
+
+
+ if (VIR_ALLOC_N(dcontrollers, dst->ncontrollers) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ memcpy(dcontrollers, dst->controllers, dst->ncontrollers*sizeof(dst->controllers[0]));
+ qsort(dcontrollers, dst->ncontrollers, sizeof(virDomainControllerDefPtr),
+ virDomainControllerCmp);
+
for (i = 0 ; i < src->ncontrollers ; i++)
- if (!virDomainControllerDefCheckABIStability(src->controllers[i], dst->controllers[i]))
+ if (!virDomainControllerDefCheckABIStability(scontrollers[i], dcontrollers[i]))
goto cleanup;
+ VIR_FREE(scontrollers);
+ VIR_FREE(dcontrollers);
+
if (src->nfss != dst->nfss) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target domain filesystem count %d does not match source %d"),
--
1.7.8.6
12 years, 3 months
[libvirt] [PATCH] json: fix interface locale dependency
by Martin Kletzander
libvirt creates invalid commands if wrong locale is selected. For
example with locale that uses comma as a decimal point, JSON commands
created with decimal numbers are invalid because comma separates the
entries in JSON.
But even when decimal point is affected, grouping is not, because for
grouping to be enabled with *printf, there has to be a apostrophe flag
specified (and supported).
---
Fortunately, there should be no other place where output-formatting is
affected by this problem.
I tried to change this in various ways with this posted one being the
cleanest from my point of view, because:
- setting locale is per-proccess, not per-thread (not thread-safe)
- there is no number parsing that mangles the output number because
of floating point precision
src/util/json.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/util/json.c b/src/util/json.c
index 5132989..753a548 100644
--- a/src/util/json.c
+++ b/src/util/json.c
@@ -23,6 +23,8 @@
#include <config.h>
+#include <locale.h>
+
#include "json.h"
#include "memory.h"
#include "virterror_internal.h"
@@ -44,7 +46,6 @@
/* XXX fixme */
#define VIR_FROM_THIS VIR_FROM_NONE
-
typedef struct _virJSONParserState virJSONParserState;
typedef virJSONParserState *virJSONParserStatePtr;
struct _virJSONParserState {
@@ -200,9 +201,27 @@ virJSONValuePtr virJSONValueNewNumberUlong(unsigned long long data)
virJSONValuePtr virJSONValueNewNumberDouble(double data)
{
virJSONValuePtr val = NULL;
- char *str;
+ char *str, *radix, *tmp;
+
if (virAsprintf(&str, "%lf", data) < 0)
return NULL;
+
+ /* because printing double is locale-dependent, we could end up
+ * with invalid JSON code, so we have to do something like this */
+ radix = localeconv()->decimal_point;
+ tmp = strstr(str, radix);
+ if (tmp) {
+ *tmp = '.';
+ if (strlen(radix) > 1) {
+ /* if the current locale specifies more characters as
+ * decimal point then cover the others with decimal
+ * numbers */
+ memcpy(tmp + 1,
+ tmp + strlen(radix),
+ strlen(str) - (tmp - str));
+ }
+ }
+
val = virJSONValueNewNumber(str);
VIR_FREE(str);
return val;
--
1.7.8.6
12 years, 3 months
[libvirt] [PATCH] build: drop conditional use of mdns code
by Eric Blake
Commit 1f6f723 missed a step. At first I was worried that scrubbing
the conditionals would lead to a runtime failure when compiled without
avahi, but my testing makes it appear that the runtime error will only
occur if the .conf files in /etc request mdns advertisement; and the
old behavior was to silently ignore the request, so this is actually
a better behavior of explicitly failing only when the config requests
the impossible.
* src/rpc/virnetserver.c: Drop HAVE_AVAHI conditionals; all
callers already passed NULL if mdns_adv was not configured.
---
In response to: https://www.redhat.com/archives/libvir-list/2012-August/msg00130.html
I originally thought it would be harder than this, but my testing
seems to show that this works. Caveat: my testing without avahi was
done in a VM and not on bare metal, and since nested virt is slower,
I may have inadvertently cut an important corner and missed a flaw
in my above reasoning about why this is safe. So a close review,
including checking all call sites, would be appreciated.
src/rpc/virnetserver.c | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 248ad9f..295e8fd 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -36,9 +36,7 @@
#include "util.h"
#include "virfile.h"
#include "event.h"
-#if HAVE_AVAHI
-# include "virnetservermdns.h"
-#endif
+#include "virnetservermdns.h"
#ifndef SA_SIGINFO
# define SA_SIGINFO 0
@@ -81,10 +79,8 @@ struct _virNetServer {
int sigwatch;
char *mdnsGroupName;
-#if HAVE_AVAHI
virNetServerMDNSPtr mdns;
virNetServerMDNSGroupPtr mdnsGroup;
-#endif
size_t nservices;
virNetServerServicePtr *services;
@@ -364,7 +360,6 @@ virNetServerPtr virNetServerNew(size_t min_workers,
virReportOOMError();
goto error;
}
-#if HAVE_AVAHI
if (srv->mdnsGroupName) {
if (!(srv->mdns = virNetServerMDNSNew()))
goto error;
@@ -372,7 +367,6 @@ virNetServerPtr virNetServerNew(size_t min_workers,
srv->mdnsGroupName)))
goto error;
}
-#endif
if (virMutexInit(&srv->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -592,14 +586,13 @@ error:
int virNetServerAddService(virNetServerPtr srv,
virNetServerServicePtr svc,
- const char *mdnsEntryName ATTRIBUTE_UNUSED)
+ const char *mdnsEntryName)
{
virNetServerLock(srv);
if (VIR_EXPAND_N(srv->services, srv->nservices, 1) < 0)
goto no_memory;
-#if HAVE_AVAHI
if (mdnsEntryName) {
int port = virNetServerServiceGetPort(svc);
@@ -608,7 +601,6 @@ int virNetServerAddService(virNetServerPtr srv,
port))
goto error;
}
-#endif
srv->services[srv->nservices-1] = svc;
virNetServerServiceRef(svc);
@@ -622,9 +614,7 @@ int virNetServerAddService(virNetServerPtr srv,
no_memory:
virReportOOMError();
-#if HAVE_AVAHI
error:
-#endif
virNetServerUnlock(srv);
return -1;
}
@@ -694,11 +684,9 @@ void virNetServerRun(virNetServerPtr srv)
virNetServerLock(srv);
-#if HAVE_AVAHI
if (srv->mdns &&
virNetServerMDNSStart(srv->mdns) < 0)
goto cleanup;
-#endif
srv->quit = 0;
@@ -826,9 +814,7 @@ void virNetServerFree(virNetServerPtr srv)
VIR_FREE(srv->clients);
VIR_FREE(srv->mdnsGroupName);
-#if HAVE_AVAHI
virNetServerMDNSFree(srv->mdns);
-#endif
virMutexDestroy(&srv->lock);
VIR_FREE(srv);
--
1.7.11.2
12 years, 3 months
[libvirt] Debian packaging for the Java bindings
by Wido den Hollander
Currently the Java bindings for libvirt do not provide a Debian package.
Users with Debian based systems like Ubuntu are now forced to compile from source since
no binary distribution of the JAR file is available.
This patch adds building Debian packages with ant
$ ant deb
This will build a .deb file in the target directory.
It requires dpkg-dev to be installed.
Wido
12 years, 3 months
[libvirt] [test-API][PATCH] Fix xml parser problem when node have both attribute and value
by Wayne Sun
When xml node have both attribute and value at first level, the parser
will broke. After fix, the node key will have a dictionary with both
value and attr inside. For example, the xml node:
<capacity unit='bytes'>536870912000</capacity>
will be parsed into:
{u'capacity': {'attr': {u'unit': u'bytes'}, 'value': u'536870912000'}}
Also when fetch the attribute key, should use a new param (attrkey)
other than exist key in outside loop.
Signed-off-by: Wayne Sun <gsun(a)redhat.com>
---
utils/xml_parser.py | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/utils/xml_parser.py b/utils/xml_parser.py
index 04e7501..01b928f 100644
--- a/utils/xml_parser.py
+++ b/utils/xml_parser.py
@@ -88,15 +88,21 @@ class xml_parser(object):
if thenode.attributes != None:
tmpattr = dict()
if thenode.attributes.length > 0:
- for key in thenode.attributes.keys():
+ for attrkey in thenode.attributes.keys():
tmpattr.update(
- {key:thenode.attributes.get(key).nodeValue})
+ {attrkey:thenode.attributes.get(attrkey).nodeValue})
attrdic = { "attr":tmpattr }
if key in out:
if out[key] == None:
- out[key] = value
if attrdic != None:
- out[key].update(attrdic)
+ if value == None:
+ out[key] = attrdic
+ else:
+ valdic = { "value":value }
+ valdic.update(attrdic)
+ out[key] = valdic
+ else:
+ out[key] = value
elif type(out[key]) == list:
if attrdic != None:
newdict.update(attrdic)
@@ -111,7 +117,13 @@ class xml_parser(object):
else:
out[key] = value
if attrdic != None:
- out[key].update(attrdic)
+ if value == None:
+ newdict[key] = attrdic
+ else:
+ valdic = { "value":value }
+ valdic.update(attrdic)
+ newdict = valdic
+ out[key] = newdict
self.parseintodict(thenode, level+1, out, key)
return out
--
1.7.1
12 years, 3 months
[libvirt] [PATCH] [RFC] xen-xm: Generate UUID if not specified
by Jim Fehlig
I received a bug report about 'virsh domxml-from-native xen-xm' failing
when the xm configuration does not contain a UUID. IMO, this is a bit
harsh since UUID is not even required when defining a domain.
I first took the approach of skipping the parsing of UUID when it is not
specified in the xm config, but that results in a UUID of all zeros,
which is the dom0 UUID from the xen tools perspective.
I'd like to hear what other folks think about the attached patch, which
generates a UUID if it is not specified in the xm config.
Regards,
Jim
12 years, 3 months
[libvirt] [PATCH] client: Free message when freeing client
by Peter Krempa
The last message of the client was not freed leaking 4 bytes of memory
in the client when the remote daemon crashed while processing a message.
---
src/rpc/virnetclient.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index b210a72..cb373b6 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -499,6 +499,9 @@ void virNetClientFree(virNetClientPtr client)
#if HAVE_SASL
virNetSASLSessionFree(client->sasl);
#endif
+
+ virNetMessageClear(&client->msg);
+
virNetClientUnlock(client);
virMutexDestroy(&client->lock);
--
1.7.8.6
12 years, 3 months