[libvirt] [PATCH] add sentinel attribute
by Paolo Bonzini
This patch adds a (macro-wrapped) sentinel attribute to functions
that take a NULL-terminated variable argument list. This is a nice
debugging aid.
* src/internal.h (ATTRIBUTE_SENTINEL): New.
* src/util/buf.c (virBufferStrcat): Use it.
* src/util/ebtables.c (ebtablesAddRemoveRule): Use it.
* src/util/iptables.c (iptableAddRemoveRule: Use it.
* src/util/qparams.h (new_qparam_set, append_qparams): Use it.
---
src/internal.h | 11 +++++++++++
src/util/buf.h | 3 ++-
src/util/ebtables.c | 2 +-
src/util/iptables.c | 2 +-
src/util/qparams.h | 6 ++++--
5 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/src/internal.h b/src/internal.h
index bd1cfe6..09c19ea 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -93,6 +93,17 @@
#endif
/**
+ * ATTRIBUTE_SENTINEL:
+ *
+ * Macro to check for NULL-terminated varargs lists
+ */
+#ifndef ATTRIBUTE_SENTINEL
+#if __GNUC_PREREQ (4, 0)
+#define ATTRIBUTE_SENTINEL __attribute__((__sentinel__))
+#endif
+#endif
+
+/**
* ATTRIBUTE_FMT_PRINTF
*
* Macro used to check printf like functions, if compiling
diff --git a/src/util/buf.h b/src/util/buf.h
index 7d31cb2..94ee8a3 100644
--- a/src/util/buf.h
+++ b/src/util/buf.h
@@ -41,7 +41,8 @@ void virBufferAdd(const virBufferPtr buf, const char *str, int len);
void virBufferAddChar(const virBufferPtr buf, char c);
void virBufferVSprintf(const virBufferPtr buf, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3);
-void virBufferStrcat(const virBufferPtr buf, ...);
+void virBufferStrcat(const virBufferPtr buf, ...)
+ ATTRIBUTE_SENTINEL;
void virBufferEscapeString(const virBufferPtr buf, const char *format, const char *str);
void virBufferURIEncodeString (const virBufferPtr buf, const char *str);
diff --git a/src/util/ebtables.c b/src/util/ebtables.c
index 60427d7..20f3342 100644
--- a/src/util/ebtables.c
+++ b/src/util/ebtables.c
@@ -175,7 +175,7 @@ ebtRulesNew(const char *table,
return NULL;
}
-static int
+static int ATTRIBUTE_SENTINEL
ebtablesAddRemoveRule(ebtRules *rules, int action, const char *arg, ...)
{
va_list args;
diff --git a/src/util/iptables.c b/src/util/iptables.c
index 4562800..284f3c0 100644
--- a/src/util/iptables.c
+++ b/src/util/iptables.c
@@ -382,7 +382,7 @@ iptRulesNew(const char *table,
return NULL;
}
-static int
+static int ATTRIBUTE_SENTINEL
iptablesAddRemoveRule(iptRules *rules, int action, const char *arg, ...)
{
va_list args;
diff --git a/src/util/qparams.h b/src/util/qparams.h
index 1a92048..a2f5aa2 100644
--- a/src/util/qparams.h
+++ b/src/util/qparams.h
@@ -38,10 +38,12 @@ struct qparam_set {
};
/* New parameter set. */
-extern struct qparam_set *new_qparam_set (int init_alloc, ...);
+extern struct qparam_set *new_qparam_set (int init_alloc, ...)
+ ATTRIBUTE_SENTINEL;
/* Appending parameters. */
-extern int append_qparams (struct qparam_set *ps, ...);
+extern int append_qparams (struct qparam_set *ps, ...)
+ ATTRIBUTE_SENTINEL;
extern int append_qparam (struct qparam_set *ps,
const char *name, const char *value);
--
1.6.2.5
15 years, 6 months
Re: [libvirt] Remote access and libvirtd
by Maximilian Wilhelm
Anno domini 2009 Dave Bryson scripsit:
Hi Dave!
(Moved the thread back to the list, hope thats OK)
> Thank you for the response. I'm working with ESX and am looking at
> libvirt to see if it would be beneficial to use over the ESX SOAP API
> (i'm not a SOAP fan). But in the case of remote access it doesn't appear
> that libvirt will be able to help me.
Well, the ESX driver is working completely remote and should therefore
be helpful.
The driver only uses the VI API, which practically is SOAP, to
communicate with the server.
If you could describe the problem you are facing a bit more precisly,
one could give you some hints about how to solve this.
Ciao
Max
--
Träume nicht von Dein Leben: Lebe Deinen Traum!
15 years, 6 months
[libvirt] [PATCH 0/2] test: Update inactive guest config on shutdown
by Cole Robinson
This small series teaches the test driver to abide changes to the inactive
domain definition (caused by 'defining' over an already running domain).
Cole Robinson (2):
test: Add testDomainShutdownState helper
test: Update inactive guest config on shutdown
src/test/test_driver.c | 48 +++++++++++++++++++++++++++++-------------------
1 files changed, 29 insertions(+), 19 deletions(-)
15 years, 6 months
[libvirt] [PATCH] fix cut-and-paste error
by Paolo Bonzini
Seems like a bad merge conflict.
* src/qemu/qemu_driver.c (qemudDomainMigratePerform): Do call
doPeer2PeerMigrate for VIR_MIGRATE_PEER2PEER.
---
Note: untested beyond compiling.
src/qemu/qemu_driver.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0ed2136..635d787 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6792,9 +6792,9 @@ qemudDomainMigratePerform (virDomainPtr dom,
event = NULL;
}
- if ((flags & VIR_MIGRATE_TUNNELLED)) {
+ if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) {
if (doPeer2PeerMigrate(dom, vm, uri, flags, dname, resource) < 0)
- /* doTunnelMigrate already set the error, so just get out */
+ /* doPeer2PeerMigrate already set the error, so just get out */
goto cleanup;
} else {
if (doNativeMigrate(dom, vm, uri, flags, dname, resource) < 0)
--
1.6.2.5
15 years, 6 months
[libvirt] [PATCH] network utilities: Add functions for address->text and get/set port number
by Matthew Booth
---
src/libvirt_private.syms | 3 ++
src/util/network.c | 88 +++++++++++++++++++++++++++++++++++++++++++++-
src/util/network.h | 6 +++
3 files changed, 96 insertions(+), 1 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8525dbd..15d75fd 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -289,10 +289,13 @@ virFree;
virSocketAddrInNetwork;
virSocketAddrIsNetmask;
virSocketCheckNetmask;
+virSocketFormatAddr;
+virSocketGetPort;
virSocketGetRange;
virSocketParseAddr;
virSocketParseIpv4Addr;
virSocketParseIpv6Addr;
+virSocketSetPort;
# network_conf.h
diff --git a/src/util/network.c b/src/util/network.c
index abd866c..094130f 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -9,6 +9,7 @@
*/
#include <config.h>
+#include <arpa/inet.h>
#include "memory.h"
#include "network.h"
@@ -64,7 +65,7 @@ static int getIPv6Addr(virSocketAddrPtr addr, virIPv6AddrPtr tab) {
* Mostly a wrapper for getaddrinfo() extracting the address storage
* from the numeric string like 1.2.3.4 or 2001:db8:85a3:0:0:8a2e:370:7334
*
- * Returns the lenght of the network address or -1 in case of error.
+ * Returns the length of the network address or -1 in case of error.
*/
int
virSocketParseAddr(const char *val, virSocketAddrPtr addr, int hint) {
@@ -116,6 +117,91 @@ virSocketParseIpv6Addr(const char *val, virSocketAddrPtr addr) {
return(virSocketParseAddr(val, addr, AF_INET6));
}
+/*
+ * virSocketFormatAddr:
+ * @addr: an initialised virSocketAddrPtr
+ *
+ * Returns a string representation of the given address
+ * Returns NULL on any error
+ * Caller must free the returned string
+ */
+char *
+virSocketFormatAddr(virSocketAddrPtr addr) {
+ char *out;
+ size_t outlen;
+ void *inaddr;
+
+ if (addr->stor.ss_family == AF_INET) {
+ outlen = INET_ADDRSTRLEN;
+ inaddr = &addr->inet4.sin_addr;
+ }
+
+ else if (addr->stor.ss_family == AF_INET6) {
+ outlen = INET6_ADDRSTRLEN;
+ inaddr = &addr->inet6.sin6_addr;
+ }
+
+ else {
+ return NULL;
+ }
+
+ if (VIR_ALLOC_N(out, outlen) < 0)
+ return NULL;
+
+ if (inet_ntop(addr->stor.ss_family, inaddr, out, outlen) == NULL) {
+ VIR_FREE(out);
+ return NULL;
+ }
+
+ return out;
+}
+
+/*
+ * virSocketSetPort:
+ * @addr: an initialised virSocketAddrPtr
+ * @port: the port number to set
+ *
+ * Set the transport layer port of the given virtSocketAddr
+ *
+ * Returns 0 on success, -1 on failure
+ */
+int
+virSocketSetPort(virSocketAddrPtr addr, in_port_t port) {
+ if(addr->stor.ss_family == AF_INET) {
+ addr->inet4.sin_port = port;
+ }
+
+ else if(addr->stor.ss_family == AF_INET6) {
+ addr->inet6.sin6_port = port;
+ }
+
+ else {
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * virSocketGetPort:
+ * @addr: an initialised virSocketAddrPtr
+ *
+ * Returns the transport layer port of the given virtSocketAddr
+ * Returns 0 if @addr is invalid
+ */
+in_port_t
+virSocketGetPort(virSocketAddrPtr addr) {
+ if(addr->stor.ss_family == AF_INET) {
+ return addr->inet4.sin_port;
+ }
+
+ else if(addr->stor.ss_family == AF_INET6) {
+ return addr->inet6.sin6_port;
+ }
+
+ return 0;
+}
+
/**
* virSocketAddrIsNetmask:
* @netmask: the netmask address
diff --git a/src/util/network.h b/src/util/network.h
index e590747..7618547 100644
--- a/src/util/network.h
+++ b/src/util/network.h
@@ -34,6 +34,12 @@ int virSocketParseIpv4Addr(const char *val,
int virSocketParseIpv6Addr(const char *val,
virSocketAddrPtr addr);
+char * virSocketFormatAddr(virSocketAddrPtr addr);
+
+int virSocketSetPort(virSocketAddrPtr addr, in_port_t port);
+
+in_port_t virSocketGetPort(virSocketAddrPtr addr);
+
int virSocketAddrInNetwork(virSocketAddrPtr addr1,
virSocketAddrPtr addr2,
virSocketAddrPtr netmask);
--
1.6.2.5
15 years, 6 months
[libvirt] [PATCH] create() and destroy() support for Power Hypervisor
by Eduardo Otubo
Hello all,
This patch includes a lot of changes:
* I changed all references of uuid_db to uuid_table. Bigger name, but
this semantic has a better understanding.
* Now we have a little control of UUID generated for each partition.
It's based on a table that matches UUID with LPAR's IDs, I keep it in a
file that is stored in the managed system (HMC or IVM). Even having
isolated functions to manipulate this file I still need to implement a
way to lock it and make the operation atomic to avoid corruptions.
* The XML file used in the create() function still must be improved. I
used the <disk> tag to make a work around to handle storage pools. Now I
ask for some help, how do I use the <pool> tag if there is no reference
to it at the virDomainDef structure?
I've been told that libvirt possibly would make a mini-release this week
to push some major fixes on Fedora 12. Is there a little possibility to
push these new phyp features too? This would be very important for the
phyp project, since this functions are not just to manage partitions but
manipulate them.
Any comments are always welcome.
[]'s
--
Eduardo Otubo
Software Engineer
Linux Technology Center
IBM Systems & Technology Group
Mobile: +55 19 8135 0885
eotubo(a)linux.vnet.ibm.com
15 years, 6 months
[libvirt] Remote access and libvirtd
by Dave Bryson
I need to be able to access libvirt remotely. Reading through the
documention is says "libvirtd should be running on the remote
machine" for clarification does this mean that libvirtd needs to run
*on* the remote hypervisor?
Thanks,
Dave
15 years, 6 months
[libvirt] Add support for legacy -vmchannel option
by Matthew Booth
These patches add support for the legacy qemu -vmchannel option. The following
domain xml:
<channel type='unix'>
<source mode='bind' path='/tmp/vmchannel'/>
<target type='vmchannel' deviceid='0200'/>
</channel>
becomes:
-vmchannel di:0200,unix:/tmp/vmchannel,server,nowait
I don't expect these to be merged, but I would appreciate a review.
Thanks,
Matt
15 years, 6 months
[libvirt] Guestfwd support (round 3)
by Matthew Booth
This is substantially the same as the last set. I don't think I changed patches
1 and 2 at all.
Patch 3 is updated to use a virBuffer as Rich Jones recommended.
Patch 4 is updated slightly for the above change, and there are a couple of
other trivial tidy ups in there.
Patch 5 is new. QEMU's guestfwd only supports IPv4 addresses, so we check for
that.
Rich Jones also noted that guestfwd is specific to QEMU. If there's a good
chance this same syntax might do something simililar in a different driver, I
agree that changing the name would be a good idea. However, I'm not familiar
enough with other hypervisors to be able to make a call on this. If nothing else
does anything similar, I'd keep the QEMU name for clarity.
Matt
15 years, 6 months