[libvirt] [for 1.2.6 PATCH] qemu: snapshot: Save persistent domain config when taking external snapshot
by Peter Krempa
Commit 55bbb011b965c7962933604c70f61cef45e8ec04 introduced a regression
where we forgot to save the persistent domain configuration after a
external snapshot. This would make libvirt forget the snapshots and
effectively revert to the previous state in the following scenario:
1) Start VM
2) Take snapshot
3) Destroy VM
4) Restart libvirtd
Also fix spurious blank line added by patch mentioned above.
---
src/qemu/qemu_driver.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d34da6f..775f6ab 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13126,8 +13126,10 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
int indx = virDomainDiskIndexByName(vm->newDef,
vm->def->disks[i]->dst,
false);
- if (indx >= 0)
+ if (indx >= 0) {
persistDisk = vm->newDef->disks[indx];
+ persist = true;
+ }
}
ret = qemuDomainSnapshotCreateSingleDiskActive(driver, vm,
@@ -13173,7 +13175,6 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
persistDisk = vm->newDef->disks[indx];
persist = true;
}
-
}
qemuDomainSnapshotUndoSingleDiskActive(driver, vm,
--
1.9.3
10 years, 4 months
[libvirt] Track an error
by David kiarie
Hi there,
Just a silly question, do we have a simpler way of checking where
exactly a test is failing.The tests are failing after hacking stuff
around.
I have this error
../build-aux/test-driver: line 95: 20128 Segmentation fault "$@"
> $log_file 2>&1
Yes am having a segfault!
I don't know how to track it, well, I could review the whole file but
is there some other method I am missing.Could you help me interpret
the error, what does 20128 stand for?
10 years, 4 months
[libvirt] [PATCH 0/2] memdev device: add share argument for type=file
by Michele Paolino
This patch enables the possibility to run a qemu virtual machine with the
share option for the memory-backend-file. The xml description looks like:
<memdev type='file' share='on'>
<name>ram0</name>
<source mem-path='/hugetlbfs'/>
<capacity unit='MiB'>1024</capacity>
</memdev>
This work is based on the previous work of Chen Fan[1].
We are aware of the existing conflict with the previous numa patches[2].
We are sharing this because it is a dependency for some use cases of the
qemu vhost-user support(e.g. snabbswitch).
[1] http://www.redhat.com/archives/libvir-list/2014-June/msg01195.html
[2] http://www.redhat.com/archives/libvir-list/2014-June/msg00201.html
Michele Paolino (2):
Add share argument to memdev devices(type=file)
Documentation and test for the share argument in memdev device
docs/formatdomain.html.in | 7 +++++++
docs/schemas/domaincommon.rng | 3 +++
src/conf/domain_conf.c | 16 ++++++++++++++++
src/conf/domain_conf.h | 1 +
src/qemu/qemu_command.c | 3 +++
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.args | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.xml | 2 +-
7 files changed, 32 insertions(+), 2 deletions(-)
--
1.9.3
10 years, 4 months
[libvirt] Entering freeze for libvirt-1.2.6
by Daniel Veillard
As stated yesterday, we just entered freeze for libvirt-1.2.6,
I have pushed a first release candidate tarball and signed rpms
at the usual place:
ftp://libvirt.org/libvirt/
I gave it a try and with my limited testing it looks okay, but
please have a look and test. The goal is to make the release on
Tues 1st if all goes well.
Also of note I will likely move the libvirt.org server Monday
morning (chinese time i.e. sunday for most), it should be quick,
just that if you hit the old IP untim DNS propagates you may
have the old server (I will block ssh access after the move on
the old to avoid split pushes)
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, 4 months
[libvirt] [PATCH] net: merge virNetworkGetDHCPLeases and virNetworkGetDHCPLeasesForMAC
by Peter Krempa
Instead of maintaining two very similar APIs, add the "@mac" parameter
to virNetworkGetDHCPLeases and kill virNetworkGetDHCPLeasesForMAC. Both
of those functions would return data the same way, so making @mac an
optional filter simplifies a lot of stuff.
---
daemon/remote.c | 69 +-----------------------------------------
include/libvirt/libvirt.h.in | 6 +---
src/driver.h | 8 +----
src/libvirt.c | 70 ++++++-------------------------------------
src/libvirt_public.syms | 1 -
src/network/bridge_driver.c | 69 +++++++++++-------------------------------
src/remote/remote_driver.c | 71 ++------------------------------------------
src/remote/remote_protocol.x | 20 ++-----------
src/remote_protocol-structs | 15 +---------
tools/virsh-network.c | 5 +---
10 files changed, 35 insertions(+), 299 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 9ffc1cb..ea16789 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -6292,6 +6292,7 @@ remoteDispatchNetworkGetDHCPLeases(virNetServerPtr server ATTRIBUTE_UNUSED,
goto cleanup;
if ((nleases = virNetworkGetDHCPLeases(net,
+ args->mac ? *args->mac : NULL,
args->need_results ? &leases : NULL,
args->flags)) < 0)
goto cleanup;
@@ -6336,74 +6337,6 @@ remoteDispatchNetworkGetDHCPLeases(virNetServerPtr server ATTRIBUTE_UNUSED,
}
-static int
-remoteDispatchNetworkGetDHCPLeasesForMAC(virNetServerPtr server ATTRIBUTE_UNUSED,
- virNetServerClientPtr client,
- virNetMessagePtr msg ATTRIBUTE_UNUSED,
- virNetMessageErrorPtr rerr,
- remote_network_get_dhcp_leases_for_mac_args *args,
- remote_network_get_dhcp_leases_for_mac_ret *ret)
-{
- int rv = -1;
- size_t i;
- struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
- virNetworkDHCPLeasePtr *leases = NULL;
- virNetworkPtr net = NULL;
- int nleases = 0;
-
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
- goto cleanup;
- }
-
- if (!(net = get_nonnull_network(priv->conn, args->net)))
- goto cleanup;
-
- if ((nleases = virNetworkGetDHCPLeasesForMAC(net, args->mac,
- args->need_results ? &leases : NULL,
- args->flags)) < 0)
- goto cleanup;
-
- if (nleases > REMOTE_NETWORK_DHCP_LEASES_MAX) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Number of leases is %d, which exceeds max limit: %d"),
- nleases, REMOTE_NETWORK_DHCP_LEASES_MAX);
- return -1;
- }
-
- if (leases && nleases) {
- if (VIR_ALLOC_N(ret->leases.leases_val, nleases) < 0)
- goto cleanup;
-
- ret->leases.leases_len = nleases;
-
- for (i = 0; i < nleases; i++) {
- if (remoteSerializeDHCPLease(ret->leases.leases_val + i, leases[i]) < 0)
- goto cleanup;
- }
-
- } else {
- ret->leases.leases_len = 0;
- ret->leases.leases_val = NULL;
- }
-
- ret->ret = nleases;
-
- rv = 0;
-
- cleanup:
- if (rv < 0)
- virNetMessageSaveError(rerr);
- if (leases) {
- for (i = 0; i < nleases; i++)
- virNetworkDHCPLeaseFree(leases[i]);
- VIR_FREE(leases);
- }
- virNetworkFree(net);
- return rv;
-}
-
-
/*----- Helpers. -----*/
/* get_nonnull_domain and get_nonnull_network turn an on-wire
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 594521e..032d6e6 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -5169,14 +5169,10 @@ struct _virNetworkDHCPLease {
void virNetworkDHCPLeaseFree(virNetworkDHCPLeasePtr lease);
int virNetworkGetDHCPLeases(virNetworkPtr network,
+ const char *mac,
virNetworkDHCPLeasePtr **leases,
unsigned int flags);
-int virNetworkGetDHCPLeasesForMAC(virNetworkPtr network,
- const char *mac,
- virNetworkDHCPLeasePtr **leases,
- unsigned int flags);
-
/**
* virConnectNetworkEventGenericCallback:
* @conn: the connection pointer
diff --git a/src/driver.h b/src/driver.h
index 6e72e92..5018068 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1184,15 +1184,10 @@ typedef int
typedef int
(*virDrvNetworkGetDHCPLeases)(virNetworkPtr network,
+ const char *mac,
virNetworkDHCPLeasePtr **leases,
unsigned int flags);
-typedef int
-(*virDrvNetworkGetDHCPLeasesForMAC)(virNetworkPtr network,
- const char *mac,
- virNetworkDHCPLeasePtr **leases,
- unsigned int flags);
-
typedef struct _virDriver virDriver;
typedef virDriver *virDriverPtr;
@@ -1546,7 +1541,6 @@ struct _virNetworkDriver {
virDrvNetworkIsActive networkIsActive;
virDrvNetworkIsPersistent networkIsPersistent;
virDrvNetworkGetDHCPLeases networkGetDHCPLeases;
- virDrvNetworkGetDHCPLeasesForMAC networkGetDHCPLeasesForMAC;
};
diff --git a/src/libvirt.c b/src/libvirt.c
index 566f984..49c9d16 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -21014,6 +21014,7 @@ virNodeGetFreePages(virConnectPtr conn,
/**
* virNetworkGetDHCPLeases:
* @network: Pointer to network object
+ * @mac: Optional ASCII formatted MAC address of an interface
* @leases: Pointer to a variable to store the array containing details on
* obtained leases, or NULL if the list is not required (just returns
* number of leases).
@@ -21040,6 +21041,11 @@ virNodeGetFreePages(virConnectPtr conn,
* Note: @mac, @iaid, @ipaddr, @clientid are in ASCII form, not raw bytes.
* Note: @expirytime can 0, in case the lease is for infinite time.
*
+ * The API fetches leases info of guests in the specified network. If the
+ * optional parameter @mac is specified, the returned list will contain only
+ * lease info about a specific guest interface with @mac. There can be
+ * multiple leases for a single @mac because this API supports DHCPv6 too.
+ *
* Returns the number of leases found or -1 and sets @leases to NULL in
* case of error. On success, the array stored into @leases is guaranteed to
* have an extra allocated element set to NULL but not included in the return
@@ -21057,7 +21063,7 @@ virNodeGetFreePages(virConnectPtr conn,
* int nleases;
* unsigned int flags = 0;
*
- * nleases = virNetworkGetDHCPLeases(network, &leases, flags);
+ * nleases = virNetworkGetDHCPLeases(network, NULL, &leases, flags);
* if (nleases < 0)
* error();
*
@@ -21079,6 +21085,7 @@ virNodeGetFreePages(virConnectPtr conn,
*/
int
virNetworkGetDHCPLeases(virNetworkPtr network,
+ const char *mac,
virNetworkDHCPLeasePtr **leases,
unsigned int flags)
{
@@ -21097,7 +21104,7 @@ virNetworkGetDHCPLeases(virNetworkPtr network,
if (conn->networkDriver && conn->networkDriver->networkGetDHCPLeases) {
int ret;
- ret = conn->networkDriver->networkGetDHCPLeases(network, leases, flags);
+ ret = conn->networkDriver->networkGetDHCPLeases(network, mac, leases, flags);
if (ret < 0)
goto error;
return ret;
@@ -21110,65 +21117,6 @@ virNetworkGetDHCPLeases(virNetworkPtr network,
return -1;
}
-/**
- * virNetworkGetDHCPLeasesForMAC:
- * @network: Pointer to network object
- * @mac: ASCII formatted MAC address of an interface
- * @leases: Pointer to a variable to store the array containing details on
- * obtained leases, or NULL if the list is not required (just returns
- * number of leases).
- * @flags: extra flags, not used yet, so callers should always pass 0
- *
- * The API fetches leases info of the interface which matches with the
- * given @mac. There can be multiple leases for a single @mac because this
- * API supports DHCPv6 too.
- *
- * Returns the number of leases found or -1 and sets @leases to NULL in case of
- * error. On success, the array stored into @leases is guaranteed to have an
- * extra allocated element set to NULL but not included in the return count,
- * to make iteration easier. The caller is responsible for calling
- * virNetworkDHCPLeaseFree() on each array element, then calling free() on @leases.
- *
- * See virNetworkGetDHCPLeases() for more details on list contents.
- */
-int
-virNetworkGetDHCPLeasesForMAC(virNetworkPtr network,
- const char *mac,
- virNetworkDHCPLeasePtr **leases,
- unsigned int flags)
-{
- virConnectPtr conn;
-
- VIR_DEBUG("network=%p, mac=%s, leases=%p, flags=%x",
- network, mac, leases, flags);
-
- virResetLastError();
-
- if (leases)
- *leases = NULL;
-
- virCheckNonNullArgGoto(mac, error);
-
- virCheckNetworkReturn(network, -1);
-
- conn = network->conn;
-
- if (conn->networkDriver &&
- conn->networkDriver->networkGetDHCPLeasesForMAC) {
- int ret;
- ret = conn->networkDriver->networkGetDHCPLeasesForMAC(network, mac,
- leases, flags);
- if (ret < 0)
- goto error;
- return ret;
- }
-
- virReportUnsupportedError();
-
- error:
- virDispatchError(network->conn);
- return -1;
-}
/**
* virNetworkDHCPLeaseFree:
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index f64462e..65a5b43 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -663,7 +663,6 @@ LIBVIRT_1.2.6 {
virNodeGetFreePages;
virNetworkDHCPLeaseFree;
virNetworkGetDHCPLeases;
- virNetworkGetDHCPLeasesForMAC;
} LIBVIRT_1.2.5;
# .... define new API here using predicted next version number ....
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 1c20b66..0ece432 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -3369,9 +3369,10 @@ static int networkSetAutostart(virNetworkPtr net,
}
static int
-networkGetDHCPLeasesHelper(virNetworkObjPtr obj,
- const char *mac,
- virNetworkDHCPLeasePtr **leases)
+networkGetDHCPLeases(virNetworkPtr network,
+ const char *mac,
+ virNetworkDHCPLeasePtr **leases,
+ unsigned int flags)
{
size_t i, j;
size_t nleases = 0;
@@ -3391,6 +3392,15 @@ networkGetDHCPLeasesHelper(virNetworkObjPtr obj,
virNetworkIpDefPtr ipdef_tmp = NULL;
virNetworkDHCPLeasePtr lease = NULL;
virNetworkDHCPLeasePtr *leases_ret = NULL;
+ virNetworkObjPtr obj;
+
+ virCheckFlags(0, -1);
+
+ if (!(obj = networkObjFromNetwork(network)))
+ return -1;
+
+ if (virNetworkGetDHCPLeasesEnsureACL(network->conn, obj->def) < 0)
+ goto cleanup;
/* Retrieve custom leases file location */
custom_lease_file = networkDnsmasqLeaseFileNameCustom(obj->def->bridge);
@@ -3530,6 +3540,10 @@ networkGetDHCPLeasesHelper(virNetworkObjPtr obj,
VIR_FREE(lease_entries);
VIR_FREE(custom_lease_file);
virJSONValueFree(leases_array);
+
+ if (obj)
+ virNetworkObjUnlock(obj);
+
return rv;
error:
@@ -3541,54 +3555,6 @@ networkGetDHCPLeasesHelper(virNetworkObjPtr obj,
goto cleanup;
}
-static int
-networkGetDHCPLeases(virNetworkPtr network,
- virNetworkDHCPLeasePtr **leases,
- unsigned int flags)
-{
- int rv = -1;
- virNetworkObjPtr obj;
-
- virCheckFlags(0, -1);
-
- if (!(obj = networkObjFromNetwork(network)))
- return rv;
-
- if (virNetworkGetDHCPLeasesEnsureACL(network->conn, obj->def) < 0)
- goto cleanup;
-
- rv = networkGetDHCPLeasesHelper(obj, NULL, leases);
-
- cleanup:
- if (obj)
- virNetworkObjUnlock(obj);
- return rv;
-}
-
-static int
-networkGetDHCPLeasesForMAC(virNetworkPtr network,
- const char *mac,
- virNetworkDHCPLeasePtr **leases,
- unsigned int flags)
-{
- int rv = -1;
- virNetworkObjPtr obj;
-
- virCheckFlags(0, -1);
-
- if (!(obj = networkObjFromNetwork(network)))
- return rv;
-
- if (virNetworkGetDHCPLeasesForMACEnsureACL(network->conn, obj->def) < 0)
- goto cleanup;
-
- rv = networkGetDHCPLeasesHelper(obj, mac, leases);
-
- cleanup:
- if (obj)
- virNetworkObjUnlock(obj);
- return rv;
-}
static virNetworkDriver networkDriver = {
"Network",
@@ -3616,7 +3582,6 @@ static virNetworkDriver networkDriver = {
.networkIsActive = networkIsActive, /* 0.7.3 */
.networkIsPersistent = networkIsPersistent, /* 0.7.3 */
.networkGetDHCPLeases = networkGetDHCPLeases, /* 1.2.6 */
- .networkGetDHCPLeasesForMAC = networkGetDHCPLeasesForMAC, /* 1.2.6 */
};
static virStateDriver networkStateDriver = {
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 76ce4a9..04039ac 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -7601,6 +7601,7 @@ remoteSerializeDHCPLease(virNetworkDHCPLeasePtr lease_dst, remote_network_dhcp_l
static int
remoteNetworkGetDHCPLeases(virNetworkPtr net,
+ const char *mac,
virNetworkDHCPLeasePtr **leases,
unsigned int flags)
{
@@ -7614,6 +7615,7 @@ remoteNetworkGetDHCPLeases(virNetworkPtr net,
remoteDriverLock(priv);
make_nonnull_network(&args.net, net);
+ args.mac = mac == NULL ? NULL : (char **) &mac;
args.flags = flags;
args.need_results = !!leases;
@@ -7665,74 +7667,6 @@ remoteNetworkGetDHCPLeases(virNetworkPtr net,
}
-static int
-remoteNetworkGetDHCPLeasesForMAC(virNetworkPtr net,
- const char *mac,
- virNetworkDHCPLeasePtr **leases,
- unsigned int flags)
-{
- int rv = -1;
- size_t i;
- struct private_data *priv = net->conn->networkPrivateData;
- remote_network_get_dhcp_leases_for_mac_args args;
- remote_network_get_dhcp_leases_for_mac_ret ret;
-
- virNetworkDHCPLeasePtr *leases_ret = NULL;
- remoteDriverLock(priv);
-
- make_nonnull_network(&args.net, net);
- args.mac = (char *) mac;
- args.flags = flags;
- args.need_results = !!leases;
-
- memset(&ret, 0, sizeof(ret));
-
- if (call(net->conn, priv, 0, REMOTE_PROC_NETWORK_GET_DHCP_LEASES_FOR_MAC,
- (xdrproc_t)xdr_remote_network_get_dhcp_leases_for_mac_args, (char *)&args,
- (xdrproc_t)xdr_remote_network_get_dhcp_leases_for_mac_ret, (char *)&ret) == -1)
- goto done;
-
- if (ret.leases.leases_len > REMOTE_NETWORK_DHCP_LEASES_MAX) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Number of leases is %d, which exceeds max limit: %d"),
- ret.leases.leases_len, REMOTE_NETWORK_DHCP_LEASES_MAX);
- goto cleanup;
- }
-
- if (leases) {
- if (ret.leases.leases_len &&
- VIR_ALLOC_N(leases_ret, ret.leases.leases_len + 1) < 0)
- goto cleanup;
-
- for (i = 0; i < ret.leases.leases_len; i++) {
- if (VIR_ALLOC(leases_ret[i]) < 0)
- goto cleanup;
-
- if (remoteSerializeDHCPLease(leases_ret[i], &ret.leases.leases_val[i]) < 0)
- goto cleanup;
- }
-
- *leases = leases_ret;
- leases_ret = NULL;
- }
-
- rv = ret.ret;
-
- cleanup:
- if (leases_ret) {
- for (i = 0; i < ret.leases.leases_len; i++)
- virNetworkDHCPLeaseFree(leases_ret[i]);
- VIR_FREE(leases_ret);
- }
- xdr_free((xdrproc_t)xdr_remote_network_get_dhcp_leases_for_mac_ret,
- (char *) &ret);
-
- done:
- remoteDriverUnlock(priv);
- return rv;
-}
-
-
/* get_nonnull_domain and get_nonnull_network turn an on-wire
* (name, uuid) pair into virDomainPtr or virNetworkPtr object.
* These can return NULL if underlying memory allocations fail,
@@ -8098,7 +8032,6 @@ static virNetworkDriver network_driver = {
.networkIsActive = remoteNetworkIsActive, /* 0.7.3 */
.networkIsPersistent = remoteNetworkIsPersistent, /* 0.7.3 */
.networkGetDHCPLeases = remoteNetworkGetDHCPLeases, /* 1.2.6 */
- .networkGetDHCPLeasesForMAC = remoteNetworkGetDHCPLeasesForMAC, /* 1.2.6 */
};
static virInterfaceDriver interface_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 4b75bdb..bff2c47 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -3035,6 +3035,7 @@ struct remote_network_dhcp_lease {
struct remote_network_get_dhcp_leases_args {
remote_nonnull_network net;
+ remote_string mac;
int need_results;
unsigned int flags;
};
@@ -3044,18 +3045,6 @@ struct remote_network_get_dhcp_leases_ret {
unsigned int ret;
};
-struct remote_network_get_dhcp_leases_for_mac_args {
- remote_nonnull_network net;
- remote_nonnull_string mac;
- int need_results;
- unsigned int flags;
-};
-
-struct remote_network_get_dhcp_leases_for_mac_ret {
- remote_network_dhcp_lease leases<REMOTE_NETWORK_DHCP_LEASES_MAX>;
- unsigned int ret;
-};
-
/*----- Protocol. -----*/
/* Define the program number, protocol version and procedure numbers here. */
@@ -5413,11 +5402,6 @@ enum remote_procedure {
* @generate: none
* @acl: network:read
*/
- REMOTE_PROC_NETWORK_GET_DHCP_LEASES = 341,
+ REMOTE_PROC_NETWORK_GET_DHCP_LEASES = 341
- /**
- * @generate: none
- * @acl: network:read
- */
- REMOTE_PROC_NETWORK_GET_DHCP_LEASES_FOR_MAC = 342
};
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 222f125..a14e1fd 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -2498,6 +2498,7 @@ struct remote_network_dhcp_lease {
};
struct remote_network_get_dhcp_leases_args {
remote_nonnull_network net;
+ remote_string mac;
int need_results;
u_int flags;
};
@@ -2508,19 +2509,6 @@ struct remote_network_get_dhcp_leases_ret {
} leases;
u_int ret;
};
-struct remote_network_get_dhcp_leases_for_mac_args {
- remote_nonnull_network net;
- remote_nonnull_string mac;
- int need_results;
- u_int flags;
-};
-struct remote_network_get_dhcp_leases_for_mac_ret {
- struct {
- u_int leases_len;
- remote_network_dhcp_lease * leases_val;
- } leases;
- u_int ret;
-};
enum remote_procedure {
REMOTE_PROC_CONNECT_OPEN = 1,
REMOTE_PROC_CONNECT_CLOSE = 2,
@@ -2863,5 +2851,4 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB_2 = 339,
REMOTE_PROC_NODE_GET_FREE_PAGES = 340,
REMOTE_PROC_NETWORK_GET_DHCP_LEASES = 341,
- REMOTE_PROC_NETWORK_GET_DHCP_LEASES_FOR_MAC = 342,
};
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 2d5b9be..e7499fa 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -1348,10 +1348,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd)
if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
return false;
- nleases = mac ? virNetworkGetDHCPLeasesForMAC(network, mac, &leases, flags)
- : virNetworkGetDHCPLeases(network, &leases, flags);
-
- if (nleases < 0) {
+ if ((nleases = virNetworkGetDHCPLeases(network, mac, &leases, flags) < 0)) {
vshError(ctl, _("Failed to get leases info for %s"), name);
goto cleanup;
}
--
1.9.3
10 years, 4 months
[libvirt] [libvirt-glib] [PATCHv2 1/2] libvirt-gobject-domain: Add _fetch_snapshots
by Timm Bäder
This function can be used to fetch the snapshots of a domain (according
to the given GVirDomainSnapshotListFlags) and save them in a
domain-internal GHashTable. A function to access them from outside will
be added in a later patch.
---
libvirt-gobject/libvirt-gobject-domain.c | 61 ++++++++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-domain.h | 36 +++++++++++++++++++
libvirt-gobject/libvirt-gobject.sym | 2 ++
3 files changed, 99 insertions(+)
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index c6e30e5..a527d4e 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -38,6 +38,7 @@ struct _GVirDomainPrivate
{
virDomainPtr handle;
gchar uuid[VIR_UUID_STRING_BUFLEN];
+ GHashTable *snapshots;
};
G_DEFINE_TYPE(GVirDomain, gvir_domain, G_TYPE_OBJECT);
@@ -121,6 +122,10 @@ static void gvir_domain_finalize(GObject *object)
g_debug("Finalize GVirDomain=%p", domain);
+ if (priv->snapshots) {
+ g_hash_table_unref (priv->snapshots);
+ }
+
virDomainFree(priv->handle);
G_OBJECT_CLASS(gvir_domain_parent_class)->finalize(object);
@@ -1514,3 +1519,59 @@ gvir_domain_create_snapshot(GVirDomain *dom,
g_free(custom_xml);
return dom_snapshot;
}
+
+
+
+/**
+ * gvir_domain_fetch_snapshots:
+ * @dom: The domain
+ * @list_flags: bitwise-OR of #GVirDomainSnapshotListFlags
+ * @error: (allow-none): Place-holder for error or NULL
+ *
+ * Returns: TRUE on success, FALSE otherwise.
+ */
+gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
+ guint list_flags,
+ GError **error)
+{
+ GVirDomainPrivate *priv;
+ virDomainSnapshotPtr *snapshots = NULL;
+ GVirDomainSnapshot *snap;
+ int n_snaps = 0;
+ int i;
+
+ g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+ g_return_val_if_fail((error == NULL) || (*error == NULL), FALSE);
+
+ priv = dom->priv;
+
+ if (priv->snapshots != NULL) {
+ g_hash_table_unref (priv->snapshots);
+ }
+
+ priv->snapshots = g_hash_table_new_full(g_str_hash,
+ g_str_equal,
+ NULL,
+ g_object_unref);
+
+
+ n_snaps = virDomainListAllSnapshots(priv->handle, &snapshots, list_flags);
+
+ if (n_snaps < 0) {
+ gvir_set_error(error, GVIR_DOMAIN_ERROR, 0,
+ "Unable to fetch snapshots of %s",
+ gvir_domain_get_name (dom));
+ return FALSE;
+ }
+
+ for (i = 0; i < n_snaps; i ++) {
+ snap = GVIR_DOMAIN_SNAPSHOT(g_object_new(GVIR_TYPE_DOMAIN_SNAPSHOT,
+ "handle", snapshots[i],
+ NULL));
+ g_hash_table_insert(priv->snapshots,
+ (gpointer)gvir_domain_snapshot_get_name(snap),
+ snap);
+ }
+ free(snapshots);
+ return TRUE;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index 38d3458..fb33e2b 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -183,6 +183,39 @@ typedef enum {
GVIR_DOMAIN_REBOOT_GUEST_AGENT = VIR_DOMAIN_REBOOT_GUEST_AGENT,
} GVirDomainRebootFlags;
+/**
+ * GVirDomainSnapshotListFlags:
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_ALL: List all snapshots
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS: List all descendants, not just
+ * children, when listing a snapshot.
+ * For historical reasons, groups do not use contiguous bits.
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_ROOTS: Filter by snapshots with no parents, when listing a domain
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_METADATA: Filter by snapshots which have metadata
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_LEAVES: Filter by snapshots with no children
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES: Filter by snapshots that have children
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA: Filter by snapshots with no metadata
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_INACTIVE: Filter by snapshots taken while guest was shut off
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_ACTIVE: Filter by snapshots taken while guest was active, and with memory state
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_DISK_ONLY: Filter by snapshots taken while guest was active, but without memory state
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_INTERNAL: Filter by snapshots stored internal to disk images
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL: Filter by snapshots that use files external to disk images
+ */
+typedef enum {
+ GVIR_DOMAIN_SNAPSHOT_LIST_ALL = 0,
+ GVIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS = VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS,
+ GVIR_DOMAIN_SNAPSHOT_LIST_ROOTS = VIR_DOMAIN_SNAPSHOT_LIST_ROOTS,
+ GVIR_DOMAIN_SNAPSHOT_LIST_METADATA = VIR_DOMAIN_SNAPSHOT_LIST_METADATA,
+ GVIR_DOMAIN_SNAPSHOT_LIST_LEAVES = VIR_DOMAIN_SNAPSHOT_LIST_LEAVES,
+ GVIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES = VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES,
+ GVIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA = VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA,
+ GVIR_DOMAIN_SNAPSHOT_LIST_INACTIVE = VIR_DOMAIN_SNAPSHOT_LIST_INACTIVE,
+ GVIR_DOMAIN_SNAPSHOT_LIST_ACTIVE = VIR_DOMAIN_SNAPSHOT_LIST_ACTIVE,
+ GVIR_DOMAIN_SNAPSHOT_LIST_DISK_ONLY = VIR_DOMAIN_SNAPSHOT_LIST_DISK_ONLY,
+ GVIR_DOMAIN_SNAPSHOT_LIST_INTERNAL = VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL,
+ GVIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL = VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL
+} GVirDomainSnapshotListFlags;
+
+
typedef struct _GVirDomainInfo GVirDomainInfo;
struct _GVirDomainInfo
{
@@ -330,6 +363,9 @@ gvir_domain_create_snapshot(GVirDomain *dom,
guint flags,
GError **err);
+gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
+ guint flags,
+ GError **error);
G_END_DECLS
#endif /* __LIBVIRT_GOBJECT_DOMAIN_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index b781cc6..781310f 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -236,7 +236,9 @@ LIBVIRT_GOBJECT_0.1.5 {
LIBVIRT_GOBJECT_0.1.9 {
global:
+ gvir_domain_fetch_snapshots;
gvir_domain_snapshot_delete;
+ gvir_domain_snapshot_list_flags_get_type;
} LIBVIRT_GOBJECT_0.1.5;
# .... define new API here using predicted next version number ....
--
2.0.0
10 years, 5 months
[libvirt] [PATCH] bhyve: fix build by fixing typo in variable name
by Roman Bogorodskiy
Commit 80d0918b introduced a typo in variable name:
s/failIncomaptible/failIncompatible/
Pushed under the build breaker rule.
---
src/bhyve/bhyve_driver.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index d784ed1..eb5fc95 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -1326,14 +1326,14 @@ bhyveConnectCompareCPU(virConnectPtr conn,
if (virConnectCompareCPUEnsureACL(conn) < 0)
goto cleanup;
- failIncomaptible = !!(flags & VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE);
+ failIncompatible = !!(flags & VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE);
if (!(caps = bhyveDriverGetCapabilities(driver)))
goto cleanup;
if (!caps->host.cpu ||
!caps->host.cpu->model) {
- if (failIncomaptible) {
+ if (failIncompatible) {
virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s",
_("cannot get host CPU capabilities"));
} else {
@@ -1341,7 +1341,7 @@ bhyveConnectCompareCPU(virConnectPtr conn,
ret = VIR_CPU_COMPARE_INCOMPATIBLE;
}
} else {
- ret = cpuCompareXML(caps->host.cpu, xmlDesc, failIncomaptible);
+ ret = cpuCompareXML(caps->host.cpu, xmlDesc, failIncompatible);
}
cleanup:
--
1.9.0
10 years, 5 months
[libvirt] [PATCH] cpu: Add new Broadwell CPU model
by Jiri Denemark
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
Notes:
The corresponding patch [1] for QEMU is not usptream yet but nobody
seems to be complaining about that model. And chances are the patch gets
in before QEMU enters hard freeze for 2.1. So please review this patch
but I won't push it until the model gets pushed to QEMU.
[1] https://lists.gnu.org/archive/html/qemu-devel/2014-06/msg04025.html
src/cpu/cpu_map.xml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 7d34d40..d704e59 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -511,6 +511,14 @@
<feature name='rtm'/>
</model>
+ <model name='Broadwell'>
+ <model name='Haswell'/>
+ <feature name='3dnowprefetch'/>
+ <feature name='rdseed'/>
+ <feature name='adx'/>
+ <feature name='smap'/>
+ </model>
+
<!-- AMD CPUs -->
<model name='athlon'>
<model name='pentiumpro'/>
--
2.0.0
10 years, 5 months
[libvirt] [PATCH RFC 0/4] Expose Expose IOMMU and VFIO host capabilities
by Michal Privoznik
*** NOT FOR UPSTREAM MERGE ***
This is pure RFC, that's why it contains just code without any documentation,
RNG schemas, tests, ..., with sparse commit messages. I just want to make sure
I'm on the right track this time.
BTW: The ACL issue on the command is still not resolved and honestly, I've no
solution. Long story short, with this API I'm introducing users with RO
connection can execute arbitrary files on the host. Isn't that just nice?
So, what you should see after these patches are applied? Something like this:
virsh # domcapabilities /usr/bin/qemu-system-x86_64 kvm
<emulatorCapabilities>
<path>/usr/bin/qemu-system-x86_64</path>
<domain>kvm</domain>
<machine>pc-i440fx-2.1</machine>
<arch>x86_64</arch>
<vcpu>255</vcpu>
<devices>
<disk supported='yes'>
<enum name='diskDevice'>
<value>disk</value>
<value>cdrom</value>
<value>floppy</value>
<value>lun</value>
</enum>
<enum name='bus'>
<value>ide</value>
<value>fdc</value>
<value>scsi</value>
<value>virtio</value>
<value>xen</value>
<value>usb</value>
<value>sd</value>
</enum>
</disk>
<hostdev supported='yes'>
<enum name='mode'/>
<enum name='startupPolicy'>
<value>default</value>
<value>mandatory</value>
<value>requisite</value>
<value>optional</value>
</enum>
<enum name='subsysType'>
<value>usb</value>
<value>pci</value>
<value>scsi</value>
</enum>
<enum name='capsType'/>
<enum name='pciBackend'>
<value>default</value>
<value>kvm</value>
<value>vfio</value>
</enum>
</hostdev>
</devices>
</emulatorCapabilities>
Michal Privoznik (4):
Introduce domain_capabilities
Introduce virConnectGetDomainCapabilities
virsh: expose virConnectGetDomainCapabilities
qemu: Implement virConnectGetDomainCapabilities
include/libvirt/libvirt.h.in | 7 ++
src/Makefile.am | 1 +
src/conf/domain_capabilities.c | 217 +++++++++++++++++++++++++++++++++++++++++
src/conf/domain_capabilities.h | 89 +++++++++++++++++
src/driver.h | 9 ++
src/libvirt.c | 52 ++++++++++
src/libvirt_private.syms | 6 ++
src/libvirt_public.syms | 1 +
src/qemu/qemu_capabilities.c | 82 ++++++++++++++++
src/qemu/qemu_capabilities.h | 4 +
src/qemu/qemu_driver.c | 102 +++++++++++++++++++
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 20 +++-
src/remote_protocol-structs | 11 +++
tools/virsh-host.c | 84 ++++++++++++++++
15 files changed, 685 insertions(+), 1 deletion(-)
create mode 100644 src/conf/domain_capabilities.c
create mode 100644 src/conf/domain_capabilities.h
--
1.8.5.5
10 years, 5 months
[libvirt] [python PATCHv2] Implement new virNetworkGetDHCPLeases API
by Peter Krempa
From: Nehal J Wani <nehaljw.kkd1(a)gmail.com>
This API returns a list of DHCP leases for all network interfaces
connected to the given virtual network or limited output just for one
interface if mac is specified.
Example Output:
[{'iface': 'virbr3', 'ipaddr': '192.168.150.181', 'hostname': 'ubuntu14',
'expirytime': 1403737495L, 'prefix': 24, 'clientid': None,
'mac': '52:54:00:e8:73:eb', 'iaid': None, 'type': 0},
{'iface': 'virbr3', 'ipaddr': '2001:db8:ca2:2:1::bd', 'hostname': 'fedora20-test',
'expirytime': 1403738587L, 'prefix': 64, 'clientid': '00:04:b1:d8:86:42:e1:6a:aa:cf:d5:86:94:23:6f:94:04:cd',
'mac': '52:54:00:5b:40:98', 'iaid': '5980312', 'type': 1}]
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
examples/README | 1 +
examples/dhcpleases.py | 53 +++++++++++++++++++++++++++++
generator.py | 4 +++
libvirt-override-api.xml | 7 ++++
libvirt-override.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
sanitytest.py | 6 ++++
6 files changed, 159 insertions(+)
create mode 100755 examples/dhcpleases.py
diff --git a/examples/README b/examples/README
index f4db76c..5b5d405 100644
--- a/examples/README
+++ b/examples/README
@@ -10,6 +10,7 @@ domsave.py - save all running domU's into a directory
domrestore.py - restore domU's from their saved files in a directory
esxlist.py - list active domains of an VMware ESX host and print some info.
also demonstrates how to use the libvirt.openAuth() method
+dhcpleases.py - list dhcp leases for a given virtual network
The XML files in this directory are examples of the XML format that libvirt
expects, and will have to be adapted for your setup. They are only needed
diff --git a/examples/dhcpleases.py b/examples/dhcpleases.py
new file mode 100755
index 0000000..c172dc2
--- /dev/null
+++ b/examples/dhcpleases.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# netdhcpleases - print leases info for given virtual network
+
+import libvirt
+import sys
+import time
+
+def usage():
+ print "Usage: %s [URI] NETWORK" % sys.argv[0]
+ print " Print leases info for a given virtual network"
+
+uri = None
+network = None
+args = len(sys.argv)
+
+if args == 2:
+ network = sys.argv[1]
+elif args == 3:
+ uri = sys.argv[1]
+ network = sys.argv[2]
+else:
+ usage()
+ sys.exit(2)
+
+conn = libvirt.open(uri)
+if conn == None:
+ print "Unable to open connection to libvirt"
+ sys.exit(1)
+
+try:
+ net = conn.networkLookupByName(network)
+except libvirt.libvirtError:
+ print "Network %s not found" % network
+ sys.exit(0)
+
+leases = net.DHCPLeases();
+if (leases == None):
+ print "Failed to get leases for %s" % net.name()
+ sys.exit(0)
+
+def toIPAddrType(addrType):
+ if addrType == libvirt.VIR_IP_ADDR_TYPE_IPV4:
+ return "ipv4"
+ elif addrType == libvirt.VIR_IP_ADDR_TYPE_IPV6:
+ return "ipv6"
+
+print " {0:20} {1:18} {2:9} {3:25} {4:15} {5}".format("Expiry Time", "MAC address", "Protocol", "IP address", "Hostname", "Client ID or DUID")
+print "-"*115
+
+for lease in leases:
+ print " {0:20}".format(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(lease['expirytime']))),
+ print "{0:18} {1:9}".format(lease['mac'], toIPAddrType(lease['type'])),
+ print "{0:<25} {1:15} {2}".format("{}/{}".format(lease['ipaddr'], lease['prefix']), lease['hostname'], lease['clientid'])
diff --git a/generator.py b/generator.py
index 03027c6..a12c52b 100755
--- a/generator.py
+++ b/generator.py
@@ -463,6 +463,7 @@ skip_impl = (
'virDomainMigrateToURI3',
'virConnectGetCPUModelNames',
'virNodeGetFreePages',
+ 'virNetworkGetDHCPLeases',
)
lxc_skip_impl = (
@@ -568,6 +569,8 @@ skip_function = (
"virTypedParamsGetString",
"virTypedParamsGetUInt",
"virTypedParamsGetULLong",
+
+ 'virNetworkDHCPLeaseFree', # only useful in C, python code uses list
)
lxc_skip_function = (
@@ -1115,6 +1118,7 @@ def nameFixup(name, classe, type, file):
elif name[0:13] == "virNetworkGet":
func = name[13:]
func = func[0:1].lower() + func[1:]
+ func = func.replace("dHCP", "DHCP")
elif name[0:10] == "virNetwork":
func = name[10:]
func = func[0:1].lower() + func[1:]
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index bbf0ab1..09bbbf8 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -633,5 +633,12 @@
<arg name='flags' type='int' info='unused, pass 0'/>
<return type='char *' info='the list available memory in the cells'/>
</function>
+ <function name="virNetworkGetDHCPLeases" file='python'>
+ <info>Returns a list of dhcp leases for interfaces connected to the given virtual network</info>
+ <arg name='network' type='virNetworkPtr' info='a network object'/>
+ <arg name='mac' type='const char *' info='optional mac address'/>
+ <arg name='flags' type='unsigned int' info='unused, pass 0'/>
+ <return type='char *' info="list of leases"/>
+ </function>
</symbols>
</api>
diff --git a/libvirt-override.c b/libvirt-override.c
index 40aefcc..ed5e9e4 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -7866,6 +7866,93 @@ libvirt_virNodeGetFreePages(PyObject *self ATTRIBUTE_UNUSED,
VIR_FREE(counts);
return py_retval;
}
+
+
+static PyObject *
+libvirt_virNetworkGetDHCPLeases(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ PyObject *py_retval = NULL;
+ PyObject *py_lease = NULL;
+ virNetworkPtr network;
+ PyObject *pyobj_network;
+ unsigned int flags;
+ virNetworkDHCPLeasePtr *leases = NULL;
+ int leases_count;
+ char *mac = NULL;
+ size_t i;
+
+ if (!PyArg_ParseTuple(args, (char *) "Ozi:virNetworkDHCPLeasePtr",
+ &pyobj_network, &mac, &flags))
+ return NULL;
+
+ network = (virNetworkPtr) PyvirNetwork_Get(pyobj_network);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ leases_count = virNetworkGetDHCPLeases(network, mac, &leases, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (leases_count < 0) {
+ py_retval = VIR_PY_NONE;
+ goto cleanup;
+ }
+
+ if (!(py_retval = PyList_New(leases_count)))
+ goto no_memory;
+
+ for (i = 0; i < leases_count; i++) {
+ virNetworkDHCPLeasePtr lease = leases[i];
+
+ if ((py_lease = PyDict_New()) == NULL)
+ goto no_memory;
+
+#define VIR_SET_LEASE_ITEM(NAME, VALUE_OBJ_FUNC) \
+ do { \
+ PyObject *tmp_val; \
+ \
+ if (!(tmp_val = VALUE_OBJ_FUNC)) \
+ goto no_memory; \
+ \
+ if (PyDict_SetItemString(py_lease, NAME, tmp_val) < 0) { \
+ Py_DECREF(tmp_val); \
+ goto no_memory; \
+ } \
+ } while (0)
+
+ VIR_SET_LEASE_ITEM("iface", libvirt_charPtrWrap(lease->iface));
+ VIR_SET_LEASE_ITEM("expirytime", libvirt_longlongWrap(lease->expirytime));
+ VIR_SET_LEASE_ITEM("type", libvirt_intWrap(lease->type));
+ VIR_SET_LEASE_ITEM("mac", libvirt_charPtrWrap(lease->mac));
+ VIR_SET_LEASE_ITEM("ipaddr", libvirt_charPtrWrap(lease->ipaddr));
+ VIR_SET_LEASE_ITEM("prefix", libvirt_uintWrap(lease->prefix));
+ VIR_SET_LEASE_ITEM("hostname", libvirt_charPtrWrap(lease->hostname));
+ VIR_SET_LEASE_ITEM("clientid", libvirt_charPtrWrap(lease->clientid));
+ VIR_SET_LEASE_ITEM("iaid", libvirt_charPtrWrap(lease->iaid));
+
+#undef VIR_SET_LEASE_ITEM
+
+ if (PyList_SetItem(py_retval, i, py_lease) < 0)
+ goto no_memory;
+
+ py_lease = NULL;
+ }
+
+ cleanup:
+ Py_XDECREF(py_lease);
+ if (leases) {
+ for (i = 0; i < leases_count; i++)
+ virNetworkDHCPLeaseFree(leases[i]);
+ }
+ VIR_FREE(leases);
+
+ return py_retval;
+
+ no_memory:
+ Py_XDECREF(py_retval);
+ py_retval = PyErr_NoMemory();
+ goto cleanup;
+}
+
#endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
/************************************************************************
@@ -8051,6 +8138,7 @@ static PyMethodDef libvirtMethods[] = {
#endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
#if LIBVIR_CHECK_VERSION(1, 2, 6)
{(char *) "virNodeGetFreePages", libvirt_virNodeGetFreePages, METH_VARARGS, NULL},
+ {(char *) "virNetworkGetDHCPLeases", libvirt_virNetworkGetDHCPLeases, METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
{NULL, NULL, 0, NULL}
};
diff --git a/sanitytest.py b/sanitytest.py
index 6067a3f..4f4a648 100644
--- a/sanitytest.py
+++ b/sanitytest.py
@@ -78,6 +78,9 @@ for cname in wantfunctions:
if name[0:14] == "virTypedParams":
continue
+ if name[0:23] == "virNetworkDHCPLeaseFree":
+ continue
+
# These aren't functions, they're callback signatures
if name in ["virConnectAuthCallbackPtr", "virConnectCloseFunc",
"virStreamSinkFunc", "virStreamSourceFunc", "virStreamEventCallback",
@@ -210,6 +213,9 @@ for name in sorted(basicklassmap):
if func[0:8] == "fSFreeze" or func[0:6] == "fSThaw":
func = "fs" + func[2:]
+ if klass == "virNetwork":
+ func = func.replace("dHCP", "DHCP")
+
# ...except when they don't. More stupid naming
# decisions we can't fix
if func == "iD":
--
1.9.3
10 years, 5 months