[libvirt] [libvirt-test-API][PATCH] Add global IPv6 default values to network part

2015-01-25 Thread jiahu
Added below variables into global.cfg.
netip6addr/netip6prefix/netip6start/netip6end
---
 global.cfg | 9 +
 1 file changed, 9 insertions(+)

diff --git a/global.cfg b/global.cfg
index db8f71e..56677a5 100644
--- a/global.cfg
+++ b/global.cfg
@@ -195,6 +195,15 @@ defaultnetstart = 192.168.111.2
 # default the ending address ip
 defaultnetend = 192.168.111.254
 
+# default bridge ipv6 addr
+netip6addr = 2001:db8:ca2:99::1
+# default bridge ipv6 prefix
+netip6prefix = 64
+# default the starting ipv6 address
+netip6start = 2001:db8:ca2:99::11
+# default the ending ipv6 address
+netip6end = 2001:db8:ca2:99::ff
+
 
 #
 # host interface
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-test-API][PATCH] Add IPv6 section into network case

2015-01-25 Thread jiahu
Add IPv6 family related scenarios to virtual network case
---
 cases/basic_network.conf   | 8 
 repos/network/define.py| 7 ++-
 repos/network/xmls/network.xml | 5 +
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/cases/basic_network.conf b/cases/basic_network.conf
index e9abd57..5d1438e 100644
--- a/cases/basic_network.conf
+++ b/cases/basic_network.conf
@@ -13,6 +13,14 @@ network:define
 $defaultnetend
 netmode
 nat
+netip6addr
+$netip6addr
+netip6prefix
+$netip6prefix
+netip6start
+$netip6start
+netip6end
+$netip6end
 
 network:network_list
 flags
diff --git a/repos/network/define.py b/repos/network/define.py
index dd054f7..6e50eb7 100644
--- a/repos/network/define.py
+++ b/repos/network/define.py
@@ -17,7 +17,12 @@ required_params = ('networkname',
'bridgenetmask',
'netstart',
'netend',
-   'netmode',)
+   'netmode',
+   'netip6addr',
+   'netip6prefix',
+   'netip6start',
+   'netip6end',
+   )
 optional_params = {'xml' : 'xmls/network.xml',
   }
 
diff --git a/repos/network/xmls/network.xml b/repos/network/xmls/network.xml
index 220169b..97e3517 100644
--- a/repos/network/xmls/network.xml
+++ b/repos/network/xmls/network.xml
@@ -7,4 +7,9 @@
   
 
   
+  
+
+  
+
+  
 
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v8 3/4] domifaddr: Implement the API for qemu

2015-01-25 Thread Nehal J Wani
By querying the qemu guest agent with the QMP command
"guest-network-get-interfaces" and converting the received JSON
output to structured objects.

Although "ifconfig" is deprecated, IP aliases created by "ifconfig"
are supported by this API. The legacy syntax of an IP alias is:
":". Since we want all aliases to be clubbed
under parent interface, simply stripping ":" suffices.
Note that IP aliases formed by "ip" aren't visible to "ifconfig",
and aliases created by "ip" do not have any specific name. But
we are lucky, as qemu guest agent detects aliases created by both.

src/qemu/qemu_agent.h:
  * Define qemuAgentGetInterfaces

src/qemu/qemu_agent.c:
  * Implement qemuAgentGetInterface

src/qemu/qemu_driver.c:
  * New function qemuGetDHCPInterfaces
  * New function qemuDomainInterfaceAddresses

src/remote_protocol-sructs:
  * Define new structs

tests/qemuagenttest.c:
  * Add new test: testQemuAgentGetInterfaces
Test cases for IP aliases, 0 or multiple ipv4/ipv6 address(es)

Signed-off-by: Nehal J Wani 
---
 src/qemu/qemu_agent.c  | 202 +
 src/qemu/qemu_agent.h  |   4 +
 src/qemu/qemu_driver.c | 173 ++
 tests/qemuagenttest.c  | 188 +
 4 files changed, 567 insertions(+)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 5fcc40f..e881cdc 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1953,3 +1953,205 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr 
**info,
 virJSONValueFree(reply);
 return ret;
 }
+
+/*
+ * qemuAgentGetInterfaces:
+ * @mon: Agent monitor
+ * @ifaces: pointer to an array of pointers pointing to interface objects
+ *
+ * Issue guest-network-get-interfaces to guest agent, which returns a
+ * list of interfaces of a running domain along with their IP and MAC
+ * addresses.
+ *
+ * Returns: number of interfaces on success, -1 on error.
+ */
+int
+qemuAgentGetInterfaces(qemuAgentPtr mon,
+   virDomainInterfacePtr **ifaces)
+{
+int ret = -1;
+size_t i, j;
+int size = -1;
+virJSONValuePtr cmd = NULL;
+virJSONValuePtr reply = NULL;
+virJSONValuePtr ret_array = NULL;
+size_t ifaces_count = 0;
+size_t addrs_count = 0;
+virDomainInterfacePtr *ifaces_ret = NULL;
+virHashTablePtr ifaces_store = NULL;
+char **ifname = NULL;
+
+/* Hash table to handle the interface alias */
+if (!(ifaces_store = virHashCreate(ifaces_count, NULL))) {
+virHashFree(ifaces_store);
+return -1;
+}
+
+if (!(cmd = qemuAgentMakeCommand("guest-network-get-interfaces", NULL)))
+goto cleanup;
+
+if (qemuAgentCommand(mon, cmd, &reply, false, 
VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0 ||
+qemuAgentCheckError(cmd, reply) < 0) {
+goto cleanup;
+}
+
+if (!(ret_array = virJSONValueObjectGet(reply, "return"))) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("qemu agent didn't provide 'return' field"));
+goto cleanup;
+}
+
+if ((size = virJSONValueArraySize(ret_array)) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("qemu agent didn't return an array of interfaces"));
+goto cleanup;
+}
+
+for (i = 0; i < size; i++) {
+virJSONValuePtr tmp_iface = virJSONValueArrayGet(ret_array, i);
+virJSONValuePtr ip_addr_arr = NULL;
+const char *hwaddr, *ifname_s, *name = NULL;
+int ip_addr_arr_size;
+virDomainInterfacePtr iface = NULL;
+
+/* Shouldn't happen but doesn't hurt to check neither */
+if (!tmp_iface) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("something has went really wrong"));
+goto error;
+}
+
+/* interface name is required to be presented */
+name = virJSONValueObjectGetString(tmp_iface, "name");
+if (!name) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("qemu agent didn't provide 'name' field"));
+goto error;
+}
+
+/* Handle interface alias (:) */
+ifname = virStringSplit(name, ":", 2);
+ifname_s = ifname[0];
+
+iface = virHashLookup(ifaces_store, ifname_s);
+
+/* If the hash table doesn't contain this iface, add it */
+if (!iface) {
+if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0)
+goto error;
+
+if (VIR_ALLOC(ifaces_ret[ifaces_count - 1]) < 0)
+goto error;
+
+if (virHashAddEntry(ifaces_store, ifname_s,
+ifaces_ret[ifaces_count - 1]) < 0)
+goto error;
+
+iface = ifaces_ret[ifaces_count - 1];
+iface->naddrs = 0;
+
+if (VIR_STRDUP(iface->name, ifname_s) < 0)
+goto error;
+
+hwaddr = virJSONVal

[libvirt] [PATCH v8 4/4] domifaddr: Add virsh support

2015-01-25 Thread Nehal J Wani
tools/virsh-domain-monitor.c
   * Introduce new command : domifaddr
 Usage: domifaddr  [interface] [--full] [--lease] [--agent]

 Example outputs:
 virsh # domifaddr f20
 Name   MAC address  Protocol Address
 
---
 lo 00:00:00:00:00:00ipv4 127.0.0.1/8
 -  -ipv6 ::1/128
 eth0   52:54:00:2e:45:ceipv4 10.1.33.188/24
 -  -ipv6 2001:db8:0:f101::2/64
 -  -ipv6 fe80::5054:ff:fe2e:45ce/64
 eth1   52:54:00:b1:70:19ipv4 192.168.105.201/16
 -  -ipv4 192.168.201.195/16
 -  -ipv6 fe80::5054:ff:feb1:7019/64
 eth2   52:54:00:36:2a:e5N/A  N/A
 eth3   52:54:00:20:70:3dipv4 192.168.105.240/16
 -  -ipv6 fe80::5054:ff:fe20:703d/64

 virsh # domifaddr f20 eth1 --agent
 Name   MAC address  Protocol Address
 
---
 eth1   52:54:00:b1:70:19ipv4 192.168.105.201/16
 -  -ipv4 192.168.201.195/16
 -  -ipv6 fe80::5054:ff:feb1:7019/64

 virsh # domifaddr f20 eth0 --agent --full
 Name   MAC address  Protocol Address
 
---
 eth0   52:54:00:2e:45:ceipv4 10.1.33.188/24
 eth0   52:54:00:2e:45:ceipv6 2001:db8:0:f101::2/64
 eth0   52:54:00:2e:45:ceipv6 fe80::5054:ff:fe2e:45ce/64

tools/virsh.pod
   * Document new command

Signed-off-by: Nehal J Wani 
---
 tools/virsh-domain-monitor.c | 141 +++
 tools/virsh.pod  |  16 +
 2 files changed, 157 insertions(+)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 925eb1b..960b831 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -2177,6 +2177,141 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd)
 return ret;
 }
 
+/* "domifaddr" command
+ */
+static const vshCmdInfo info_domifaddr[] = {
+{"help", N_("Get network interfaces' addresses for a running domain")},
+{"desc", N_("Get network interfaces' addresses for a running domain")},
+{NULL, NULL}
+};
+
+static const vshCmdOptDef opts_domifaddr[] = {
+{.name = "domain",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("domain name, id or uuid")},
+{.name = "interface",
+ .type = VSH_OT_STRING,
+ .flags = VSH_OFLAG_NONE,
+ .help = N_("network interface name")},
+{.name = "full",
+ .type = VSH_OT_BOOL,
+ .flags = VSH_OFLAG_NONE,
+ .help = N_("display full fields")},
+{.name = "lease",
+ .type = VSH_OT_BOOL,
+ .flags = VSH_OFLAG_NONE,
+ .help = N_("parse dhcp lease file")},
+{.name = "agent",
+ .type = VSH_OT_BOOL,
+ .flags = VSH_OFLAG_NONE,
+ .help = N_("query qemu guest agent")},
+{.name = NULL}
+};
+
+static bool
+cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
+{
+virDomainPtr dom = NULL;
+const char *interface = NULL;
+virDomainInterfacePtr *ifaces = NULL;
+size_t i, j;
+int ifaces_count = 0;
+unsigned int flags = 0;
+bool ret = false;
+bool full = vshCommandOptBool(cmd, "full");
+
+if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+return false;
+
+if (vshCommandOptString(cmd, "interface", &interface) < 0)
+goto cleanup;
+
+if (vshCommandOptBool(cmd, "lease"))
+flags |= VIR_DOMAIN_INTERFACE_ADDRESSES_LEASE;
+
+if (vshCommandOptBool(cmd, "agent"))
+flags |= VIR_DOMAIN_INTERFACE_ADDRESSES_AGENT;
+
+if ((ifaces_count = virDomainInterfaceAddresses(dom, &ifaces, flags)) < 0) 
{
+vshError(ctl, _("Failed to query for interfaces addresses"));
+goto cleanup;
+}
+
+vshPrintExtra(ctl, " %-10s %-20s %-8s %s\n%s%s\n", _("Name"),
+  _("MAC address"), _("Protocol"), _("Address"),
+  _("-"),
+  _("--"));
+
+for (i = 0; i < ifaces_count; i++) {
+virDomainInterfacePtr iface = ifaces[i];
+const char *hwaddr = "";
+const char *ip_addr_str = NULL;
+const char *type = NULL;
+
+if (interface && STRNEQ(interface, iface->name))
+continue;
+
+hwaddr = iface->hwaddr;
+
+/* When the interface has no IP address */
+if (!iface->naddrs) {
+vshPrintExtra(ctl, " %-10s %-17s%-12s %s\n",
+  iface->name, hw

[libvirt] [PATCH v8 1/4] domifaddr: Implement the public APIs

2015-01-25 Thread Nehal J Wani
Define helper function virDomainInterfaceFree, which allows
the upper layer application to free the domain interface object
conveniently.

The API is going to provide multiple methods by flags, e.g.
  * Query guest agent
  * Parse DHCP lease file

include/libvirt/libvirt-domain.h
  * Define virDomainInterfaceAddresses, virDomainInterfaceFree
  * Define structs virDomainInterface, virDomainIPAddress

src/driver-hypervisor.h:
  * Define domainInterfaceAddresses

src/libvirt-domain.c:
  * Implement virDomainInterfaceAddresses
  * Implement virDomainInterfaceFree

src/libvirt_public.syms:
  * Export the new symbols

Signed-off-by: Nehal J Wani 
---
 include/libvirt/libvirt-domain.h |  27 
 src/driver-hypervisor.h  |   5 ++
 src/libvirt-domain.c | 129 +++
 src/libvirt_public.syms  |   6 ++
 4 files changed, 167 insertions(+)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 4dbd7f5..1f832d0 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -3682,5 +3682,32 @@ typedef struct _virTypedParameter virMemoryParameter;
  */
 typedef virMemoryParameter *virMemoryParameterPtr;
 
+typedef enum {
+VIR_DOMAIN_INTERFACE_ADDRESSES_LEASE = (1 << 0), /* Parse DHCP lease file 
*/
+VIR_DOMAIN_INTERFACE_ADDRESSES_AGENT = (1 << 1), /* Query qemu guest agent 
*/
+} virDomainInterfaceAddressesFlags;
+
+typedef struct _virDomainInterfaceIPAddress virDomainIPAddress;
+typedef virDomainIPAddress *virDomainIPAddressPtr;
+struct _virDomainInterfaceIPAddress {
+int type;/* virIPAddrType */
+char *addr;  /* IP address */
+unsigned int prefix; /* IP address prefix */
+};
+
+typedef struct _virDomainInterface virDomainInterface;
+typedef virDomainInterface *virDomainInterfacePtr;
+struct _virDomainInterface {
+char *name; /* interface name */
+char *hwaddr;   /* hardware address */
+unsigned int naddrs;/* number of items in @addrs */
+virDomainIPAddressPtr addrs;/* array of IP addresses */
+};
+
+int virDomainInterfaceAddresses(virDomainPtr dom,
+virDomainInterfacePtr **ifaces,
+unsigned int flags);
+
+void virDomainInterfaceFree(virDomainInterfacePtr iface);
 
 #endif /* __VIR_LIBVIRT_DOMAIN_H__ */
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index a1d2a0a..174c7bd 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -1174,6 +1174,10 @@ typedef int
 unsigned int cellCount,
 unsigned int flags);
 
+typedef int
+(*virDrvDomainInterfaceAddresses)(virDomainPtr dom,
+  virDomainInterfacePtr **ifaces,
+  unsigned int flags);
 
 typedef struct _virHypervisorDriver virHypervisorDriver;
 typedef virHypervisorDriver *virHypervisorDriverPtr;
@@ -1401,6 +1405,7 @@ struct _virHypervisorDriver {
 virDrvConnectGetAllDomainStats connectGetAllDomainStats;
 virDrvNodeAllocPages nodeAllocPages;
 virDrvDomainGetFSInfo domainGetFSInfo;
+virDrvDomainInterfaceAddresses domainInterfaceAddresses;
 };
 
 
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 492e90a..4149332 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -11249,3 +11249,132 @@ virDomainFSInfoFree(virDomainFSInfoPtr info)
 VIR_FREE(info->devAlias[i]);
 VIR_FREE(info->devAlias);
 }
+
+/**
+ * virDomainInterfaceAddresses:
+ * @dom: domain object
+ * @ifaces: pointer to an array of pointers pointing to interface objects
+ * @flags: bitwise-OR of virDomainInterfaceAddressesFlags
+ *
+ * Return a pointer to the allocated array of pointers pointing to interfaces
+ * present in given domain along with their IP and MAC addresses. Note that
+ * single interface can have multiple or even 0 IP address.
+ *
+ * This API dynamically allocates the virDomainInterfacePtr struct based on
+ * how many interfaces domain @dom has, usually there's 1:1 correlation. The
+ * count of the interfaces is returned as the return value.
+ *
+ * In case @flags includes VIR_DOMAIN_INTERFACE_ADDRESSES_AGENT, a configured
+ * guest agent is needed for successful return from this API. Moreover, if
+ * guest agent is used then the interface name is the one seen by guest OS.
+ * To match such interface with the one from @dom XML use MAC address or IP
+ * range.
+ *
+ * The lease-file parsing method returns the interface name of the form 
"vnetN",
+ * which is different from what guest agent returns (like ethN or emN), and
+ * since the MAC address from guest agent might be different with what @dom XML
+ * specifies, we have no way to convert it into the names present in @dom
+ * config. Hence, it is not recommended to mix the flag ..._AGENT with
+ * ..._LEASE as it may lead to ambiguous results because we cannot b

[libvirt] [PATCH v8 2/4] domifaddr: Implement the remote protocol

2015-01-25 Thread Nehal J Wani
daemon/remote.c
   * Define remoteSerializeDomainInterface, 
remoteDispatchDomainInterfaceAddresses

src/remote/remote_driver.c
   * Define remoteDomainInterfaceAddresses

src/remote/remote_protocol.x
   * New RPC procedure: REMOTE_PROC_DOMAIN_INTERFACE_ADDRESSES
   * Define structs remote_domain_ip_addr, remote_domain_interface,
 remote_domain_interfaces_addresse_args, 
remote_domain_interface_addresses_ret
   * Introduce upper bounds (to handle DoS attacks):
 REMOTE_DOMAIN_INTERFACE_MAX = 2048
 REMOTE_DOMAIN_IP_ADDR_MAX = 2048
 Restrictions on the maximum number of aliases per interface were
 removed after kernel v2.0, and theoretically, at present, there
 are no upper limits on number of interfaces per virtual machine
 and on the number of IP addresses per interface.

src/remote_protocol-structs
   * New structs added

Signed-off-by: Nehal J Wani 
---
 daemon/remote.c  | 134 +++
 src/libvirt_public.syms  |   4 +-
 src/remote/remote_driver.c   | 100 
 src/remote/remote_protocol.x |  36 +++-
 src/remote_protocol-structs  |  24 
 5 files changed, 295 insertions(+), 3 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index d657a09..32b567c 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -6438,6 +6438,140 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr server 
ATTRIBUTE_UNUSED,
 }
 
 
+static int
+remoteSerializeDomainInterface(virDomainInterfacePtr *ifaces,
+   unsigned int ifaces_count,
+   remote_domain_interface_addresses_ret *ret)
+{
+size_t i, j;
+
+if (ifaces_count > REMOTE_DOMAIN_INTERFACE_MAX) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Number of interfaces, %d exceeds the max limit: %d"),
+   ifaces_count, REMOTE_DOMAIN_INTERFACE_MAX);
+return -1;
+}
+
+if (VIR_ALLOC_N(ret->ifaces.ifaces_val, ifaces_count) < 0)
+return -1;
+
+ret->ifaces.ifaces_len = ifaces_count;
+
+for (i = 0; i < ifaces_count; i++) {
+virDomainInterfacePtr iface = ifaces[i];
+remote_domain_interface *iface_ret = &(ret->ifaces.ifaces_val[i]);
+
+if ((VIR_STRDUP(iface_ret->name, iface->name)) < 0)
+goto cleanup;
+
+if (iface->hwaddr) {
+char **hwaddr_p = NULL;
+if (VIR_ALLOC(hwaddr_p) < 0)
+goto cleanup;
+if (VIR_STRDUP(*hwaddr_p, iface->hwaddr) < 0) {
+VIR_FREE(hwaddr_p);
+goto cleanup;
+}
+
+iface_ret->hwaddr = hwaddr_p;
+}
+
+if (iface->naddrs > REMOTE_DOMAIN_IP_ADDR_MAX) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Number of interfaces, %d exceeds the max limit: 
%d"),
+   iface->naddrs, REMOTE_DOMAIN_IP_ADDR_MAX);
+goto cleanup;
+}
+
+if (VIR_ALLOC_N(iface_ret->addrs.addrs_val,
+iface->naddrs) < 0)
+goto cleanup;
+
+iface_ret->addrs.addrs_len = iface->naddrs;
+
+for (j = 0; j < iface->naddrs; j++) {
+virDomainIPAddressPtr ip_addr = &(iface->addrs[j]);
+remote_domain_ip_addr *ip_addr_ret =
+&(iface_ret->addrs.addrs_val[j]);
+
+if (VIR_STRDUP(ip_addr_ret->addr, ip_addr->addr) < 0)
+goto cleanup;
+
+ip_addr_ret->prefix = ip_addr->prefix;
+ip_addr_ret->type = ip_addr->type;
+}
+}
+
+return 0;
+
+ cleanup:
+if (ret->ifaces.ifaces_val) {
+for (i = 0; i < ifaces_count; i++) {
+remote_domain_interface *iface_ret = &(ret->ifaces.ifaces_val[i]);
+VIR_FREE(iface_ret->name);
+VIR_FREE(iface_ret->hwaddr);
+for (j = 0; j < iface_ret->addrs.addrs_len; j++) {
+remote_domain_ip_addr *ip_addr =
+&(iface_ret->addrs.addrs_val[j]);
+VIR_FREE(ip_addr->addr);
+}
+VIR_FREE(iface_ret);
+}
+VIR_FREE(ret->ifaces.ifaces_val);
+}
+
+return -1;
+}
+
+
+static int
+remoteDispatchDomainInterfaceAddresses(virNetServerPtr server ATTRIBUTE_UNUSED,
+   virNetServerClientPtr client,
+   virNetMessagePtr msg ATTRIBUTE_UNUSED,
+   virNetMessageErrorPtr rerr,
+   remote_domain_interface_addresses_args 
*args,
+   remote_domain_interface_addresses_ret 
*ret)
+{
+size_t i;
+int rv = -1;
+virDomainPtr dom = NULL;
+virDomainInterfacePtr *ifaces = NULL;
+int ifaces_count = 0;
+struct daemonClientPrivate *priv =
+virNetServerClientGetPrivateData(client);
+
+if (!priv->conn) {
+virReportErr

[libvirt] [PATCH v8 0/4] Introduce API to query IP addresses for given domain

2015-01-25 Thread Nehal J Wani
This feature has been requested for a very long time. Since qemu guest
agent and leaseshelper give us reliable results, now the wait is over.

The RFC was first proposed by Michal Privoznik:
 http://www.redhat.com/archives/libvir-list/2012-February/msg00437.html
A patch was submitted, using structs:
 https://www.redhat.com/archives/libvir-list/2012-June/msg00220.html
Another patch was submitted, using XML:
 https://www.redhat.com/archives/libvir-list/2012-June/msg00904.html

Neither of the patches were accepted, probably due to lack of extensibility
and usability. Hence, we thought of using virTypedParameters for reporting
list of interfaces along with their MAC address and IP addresses. The RFC
can be found here:
 https://www.redhat.com/archives/libvir-list/2013-July/msg00084.html

The idea of extensibility was rejected and rendered out of scope of
libvirt. Hence, we were back to structs.

This API is called virDomainInterfaceAddresses which returns a dynamically
allocated array of virDomainInterface struct. The great disadvantage is
once this gets released, it's written in stone and we cannot change
or add an item into it.

The virsh CLI supports two methods:

* Return information (list of all associated interfaces with MAC address
 and IP addresses) of all of the domain interfaces by default (if
 no interface name is provided)

* Return information for the specified interface (if an interface name
 is provided)

v8:
* qemuDomainInterfaceAddresses: redo logic related to flags
* Make sure that NIC(s) on guest is/are using libvirt virtual network
  before querying leaseshelper
* domifaddr: change --network option from VSH_OT_DATA to VSH_OT_STRING

v7:
* Enable support for DHCP lease file parsing method
* http://www.redhat.com/archives/libvir-list/2014-December/msg00866.html

v6:
* Inclusion of flags, readonly check for guest agent connection
* Correction of memory leaks, other small nits.
* https://www.redhat.com/archives/libvir-list/2013-September/msg00350.html

v5:
* s/virDomainInterfacesAddresses/virDomainInterfaceAddresses.
* Case for IP aliasing handled using virHashTable.
* New test cases added, involving multiple and 0 IP addresse(s)
  per interface.
* IP prefix changed from int to unsigned int.
* Changes to practice libvirt habits.
* https://www.redhat.com/archives/libvir-list/2013-September/msg3.html

v4:
* Various style nits, indentation errors, memory leaks fixed.
* https://www.redhat.com/archives/libvir-list/2013-August/msg01265.html

v3:
* Upper bounds to number of interfaces and addresses per interface
  introduced.
* Change from array of structs to array of pointers
* ifaces_count moved from function argument to return value
* Changes in variable names
* Test cases added for qemuAgentGetInterfaces.
* https://www.redhat.com/archives/libvir-list/2013-August/msg01215.html

v2:
* Logical errors, memory leaks and few other errors fixed.
* https://www.redhat.com/archives/libvir-list/2013-August/msg00631.html

v1:
* http://www.redhat.com/archives/libvir-list/2013-July/msg01553.html


Nehal J Wani (4):
  domifaddr: Implement the public APIs
  domifaddr: Implement the remote protocol
  domifaddr: Implement the API for qemu
  domifaddr: Add virsh support

 daemon/remote.c  | 134 ++
 include/libvirt/libvirt-domain.h |  27 ++
 src/driver-hypervisor.h  |   5 +
 src/libvirt-domain.c | 129 +
 src/libvirt_public.syms  |   6 ++
 src/qemu/qemu_agent.c| 202 +++
 src/qemu/qemu_agent.h|   4 +
 src/qemu/qemu_driver.c   | 173 +
 src/remote/remote_driver.c   | 100 +++
 src/remote/remote_protocol.x |  36 ++-
 src/remote_protocol-structs  |  24 +
 tests/qemuagenttest.c| 188 
 tools/virsh-domain-monitor.c | 141 +++
 tools/virsh.pod  |  16 
 14 files changed, 1184 insertions(+), 1 deletion(-)

-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] [Build-breaker : 1.2.12] Suppress compilation without dbus headers

2015-01-25 Thread Prerna Saxena
Hi,
While testing 1.2.12 rc2 on Powerpc, Fedora 21, I hit a bunch of build failures 
in absence of dbus-devel :

src/util/virsystemd.c:284:17: note: in expansion of macro 'STREQ_NULLABLE'
 if (STREQ_NULLABLE("org.freedesktop.DBus.Error.UnknownMethod",
 ^

src/util/virsystemd.c:288:17: error: implicit declaration of function 
'dbus_error_free' [-Werror=implicit-function-declaration]
 dbus_error_free(&error);


Found that this was because commit 318df5a05 needs Dbus libraries for 
compilation, and configure didnt mark "with_dbus" to be mandatory. In this 
case, the compilation itself failed in a much uglier
fashion on my system where dbus-devel was absent.

The following patch introduces a compile error when dbus-devel is absent, so 
that the build itself proceeds later without cryptic errors.

This has also been reported on the list : 
https://www.redhat.com/archives/libvir-list/2015-January/msg00641.html


>From 8c4f583b6bb47ca41866ff884af0cd55487f047d Mon Sep 17 00:00:00 2001
From: Prerna Saxena 
Date: Sun, 25 Jan 2015 05:35:23 -0600
Subject: [PATCH] Build: Fix dbus m4 macro to correctly flag it as a required
 dependency.

Commit 318df5a needs dbus headers to compile. However, this package
is listed as optional, and so this breaks libvirt compilation
on systems that lack the relevant devel files.

This patch does not allow ./configure to proceed if dbus-devel is absent.

It also tweaks the libvirt spec file to reflect this relationship.
---
 libvirt.spec.in | 3 ---
 m4/virt-dbus.m4 | 1 +
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index ba1cf41..4dfda13 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -627,10 +627,7 @@ BuildRequires: util-linux
 BuildRequires: nfs-utils
 %endif
 
-%if %{with_firewalld}
-# Communication with the firewall daemon uses DBus
 BuildRequires: dbus-devel
-%endif
 
 # Fedora build root suckage
 BuildRequires: gawk
diff --git a/m4/virt-dbus.m4 b/m4/virt-dbus.m4
index 3f9b306..42359cf 100644
--- a/m4/virt-dbus.m4
+++ b/m4/virt-dbus.m4
@@ -19,6 +19,7 @@ dnl
 
 AC_DEFUN([LIBVIRT_CHECK_DBUS],[
   LIBVIRT_CHECK_PKG([DBUS], [dbus-1], [1.0.0])
+  m4_divert_text([DEFAULTS], [with_dbus=yes])
 
   if test "$with_dbus" = "yes" ; then
 old_CFLAGS="$CFLAGS"
-- 
1.8.3.1

-- 
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list