CIM
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
January 2012
- 7 participants
- 48 discussions
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
Yet another series of patches fixing errors revealed by Coverity tool. It would
be nice if we had a similar setup so we could run the tool on a regular basis. I
started playing with clang a while ago. It also provides a static analyser, but
I could not complete the setup by then.
https://bugzilla.redhat.com/show_bug.cgi?id=750418
Changes from v2:
- Revert leak change for libxkutil/xmlgen.c in patch 2 which was causing a
double-free crash and correctly fix the leak problem.
Changes from v1:
- Fix compilation error in Patch 1
Best regards, Etrunko
--
Eduardo de Barros Lima
Software Engineer, Open Virtualization
Linux Technology Center - IBM/Brazil
eblima(a)br.ibm.com
Eduardo Lima (Etrunko) (4):
libxkutil: Fix possible NULL dereferences
Fix possible memory leaks
xml_parse_test: Fix invalid dereference
Fix possible use of unitialized variables
libxkutil/cs_util_instance.c | 5 +++++
libxkutil/device_parsing.c | 14 +++++++-------
libxkutil/pool_parsing.c | 5 +++--
libxkutil/xml_parse_test.c | 3 +--
libxkutil/xmlgen.c | 8 +++++---
src/Virt_AppliedFilterList.c | 3 ++-
src/Virt_Device.c | 20 ++++++++++++++++++++
src/Virt_DevicePool.c | 19 ++++++++++++++++++-
src/Virt_SwitchService.c | 24 ++++++++++++++++++++----
src/Virt_VirtualSystemManagementService.c | 16 ++++++++--------
src/Virt_VirtualSystemSnapshotService.c | 2 +-
11 files changed, 90 insertions(+), 29 deletions(-)
--
1.7.7.5
2
10
20 Jan '12
This patch use ioctl to get bridge settings from kernel. Netlink protocol
can't be used for bridge in linux2.6 kernel.
ioctl is the oldest way to talk to kernel about bridge, so it have some
limit in the ports number and bridge number. Currently they are set to 1024.
Signed-off-by: Wenchao Xia <xiawenc(a)cn.ibm.com>
---
libnetwork/host_network_implement_bridge.c | 224 ++++++++++++++++++++++++++++
libnetwork/host_network_implement_bridge.h | 8 +
2 files changed, 232 insertions(+), 0 deletions(-)
create mode 100644 libnetwork/host_network_implement_bridge.c
create mode 100644 libnetwork/host_network_implement_bridge.h
diff --git a/libnetwork/host_network_implement_bridge.c b/libnetwork/host_network_implement_bridge.c
new file mode 100644
index 0000000..39c6b13
--- /dev/null
+++ b/libnetwork/host_network_implement_bridge.c
@@ -0,0 +1,224 @@
+/*
+ * Copyright IBM Corp. 2012
+ *
+ * Authors:
+ * Wenchao Xia <xiawenc(a)cn.ibm.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <net/if.h>
+#include <linux/if_bridge.h>
+#include <sys/ioctl.h>
+
+#include "host_network_implement_bridge.h"
+#include "host_network_helper.h"
+#include "host_network_error.h"
+
+/* following number can't be changed otherwise ioctl get errors */
+#define BR_NUM_MAX 1024
+#define PORT_NUM_MAX 1024
+#define NAME_BUFF_SIZE 16
+
+static int socket_br = -1;
+
+static int try_socket_init(void)
+{
+ if (socket_br < 0) {
+ if ((socket_br = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0)
+ return -errno;
+ }
+ return 1;
+}
+
+void try_socket_close(void)
+{
+ if (socket_br > 0) {
+ close(socket_br);
+ socket_br = -1;
+ }
+}
+
+static int get_bridge_ports(EthIface *piface)
+{
+ struct ifreq req;
+ char ifname[NAME_BUFF_SIZE];
+ int if_indexes[PORT_NUM_MAX];
+ unsigned long args[4];
+ int i, ret = ERR_LIBBR;
+ BR_Prop *pbr;
+
+ memset(ifname, 0, sizeof(ifname));
+ memset(&req, 0 ,sizeof(req));
+ memset(if_indexes, 0 ,sizeof(if_indexes));
+ args[0] = BRCTL_GET_PORT_LIST;
+ args[1] = (unsigned long)if_indexes;
+ args[2] = PORT_NUM_MAX;
+ args[3] = 0;
+
+ strncpy(req.ifr_name, piface->name, NAME_BUFF_SIZE);
+ req.ifr_data = (char *) &args;
+
+ if (0 > ioctl(socket_br, SIOCDEVPRIVATE, &req)) {
+ CU_DEBUG("failed in ioctl listing ports of bridge %s,"
+ " errno %d, reason %s.",
+ piface->name, errno, strerror(errno));
+ goto out;
+ }
+
+ if (piface->pbr_prop == NULL) {
+ eth_iface_add_br_prop(piface);
+ }
+ pbr = piface->pbr_prop;
+
+ i = -1;
+ while (i < PORT_NUM_MAX) {
+ i++;
+ if (if_indexes[i] <= 0) {
+ continue;
+ }
+ if (0 == if_indextoname(if_indexes[i], ifname)) {
+ CU_DEBUG("failed to translate if_index %d, skip it.", if_indexes);
+ continue;
+ }
+ /* add the ports to the list */
+ if (pbr->port_names == NULL) {
+ SAFE_CALLOC(pbr->port_names,
+ MAX_IFACE_NUM, sizeof(char *));
+ pbr->port_num = 0;
+ }
+ if (pbr->port_num >= MAX_IFACE_NUM) {
+ CU_DEBUG("bridge [%s] have too much eth attached!", piface->name);
+ ret = ERR_DEVICE_EXCEED_MAXNUM;
+ goto out;
+ }
+ pbr->port_names[pbr->port_num] = SAFE_STRDUP(ifname);
+ pbr->port_num++;
+ }
+
+ ret = 1;
+
+ out:
+ return ret;
+}
+
+static int get_bridge_info(EthIface *piface)
+{
+ struct ifreq req;
+ struct __bridge_info binfo;
+ unsigned long args[4];
+ int ret = ERR_LIBBR;
+
+ memset(&req, 0, sizeof(req));
+ memset(&binfo, 0, sizeof(binfo));
+ args[0] = BRCTL_GET_BRIDGE_INFO;
+ args[1] = (unsigned long) &binfo;
+ args[2] = 0;
+ args[3] = 0;
+ req.ifr_data = (char *) &args;
+
+ if (piface->name == NULL) {
+ CU_DEBUG("bridge name not set for ioctl.");
+ goto out;
+ }
+ strncpy(req.ifr_name, piface->name, NAME_BUFF_SIZE);
+ if (ioctl(socket_br, SIOCDEVPRIVATE, &req) < 0) {
+ CU_DEBUG("failed to get info for %s, errno %d, reason %s.",
+ piface->name, errno, strerror(errno));
+ goto out;
+ }
+
+ if (piface->pbr_prop == NULL) {
+ eth_iface_add_br_prop(piface);
+ }
+ piface->pbr_prop->STP = binfo.stp_enabled;
+
+ ret = 1;
+
+ out:
+ return ret;
+}
+
+static int list_bridges(EthIfacesList *plist)
+{
+ int if_indexes[BR_NUM_MAX];
+ unsigned long args[3];
+ int brnum;
+ int i, ret = ERR_LIBBR;
+ EthIface tface;
+
+ eth_iface_init(&tface);
+ SAFE_CALLOC(tface.name, NAME_BUFF_SIZE, 1);
+
+ args[0] = BRCTL_GET_BRIDGES;
+ args[1] = (unsigned long)if_indexes;
+ args[2] = BR_NUM_MAX;
+ memset(if_indexes, 0, sizeof(if_indexes));
+
+ if (0 > try_socket_init()) {
+ CU_DEBUG("failed to init socket for bridge ioctl,"
+ " errno is %d, reason: %s.",
+ errno, strerror(errno));
+ goto out;
+ }
+
+ brnum = ioctl(socket_br, SIOCGIFBR, args);
+ if (brnum < 0) {
+ CU_DEBUG("failed tp get bridge, errno is %d, reason: %s.",
+ errno, strerror(errno));
+ goto out;
+ }
+
+ i = 0;
+ while (i < brnum) {
+ if (!if_indextoname(if_indexes[i], tface.name)) {
+ CU_DEBUG("failed to translate index %d, errno is %d, reason: %s.",
+ if_indexes[i], errno, strerror(errno));
+ goto out;
+ }
+
+ ret = get_bridge_info(&tface);
+ if (ret != 1) {
+ CU_DEBUG("failed to get info for %s.", tface.name);
+ continue;
+ }
+
+ ret = get_bridge_ports(&tface);
+ if (ret != 1) {
+ CU_DEBUG("failed to get info for %s.", tface.name);
+ continue;
+ }
+
+ if (1 != eth_ifaceslist_add(plist, &tface)) {
+ CU_DEBUG("failed to add device to list.");
+ goto out;
+ }
+ eth_iface_uninit(&tface);
+ eth_iface_init(&tface);
+ SAFE_CALLOC(tface.name, NAME_BUFF_SIZE, 1);
+ i++;
+ }
+ ret = 1;
+
+ out:
+ eth_iface_uninit(&tface);
+ try_socket_close();
+ return ret;
+
+}
+
+int get_host_eth_ifaces_osapi_bridge(EthIfacesList *plist)
+{
+ return list_bridges(plist);
+}
diff --git a/libnetwork/host_network_implement_bridge.h b/libnetwork/host_network_implement_bridge.h
new file mode 100644
index 0000000..ed77195
--- /dev/null
+++ b/libnetwork/host_network_implement_bridge.h
@@ -0,0 +1,8 @@
+#ifndef HOST_NETWORK_IMPLE_BRIDGE_H
+#define HOST_NETWORK_IMPLE_BRIDGE_H
+
+#include "host_network_basic.h"
+
+int get_host_eth_ifaces_osapi_bridge(EthIfacesList *plist);
+
+#endif
--
1.7.1
3
2
19 Jan '12
Because libnl-devel-1.1 package missed some header files even if functions
are included in its .so file, they are directly be put here. Codes are from the
help documents that libnl-devel-1.1 provides.
Signed-off-by: Wenchao Xia <xiawenc(a)cn.ibm.com>
---
libnetwork/include/netlink/route/link/info-api.h | 71 ++++++++++++++++++++++
libnetwork/include/netlink/route/link/vlan.h | 55 +++++++++++++++++
2 files changed, 126 insertions(+), 0 deletions(-)
create mode 100644 libnetwork/include/netlink/route/link/info-api.h
create mode 100644 libnetwork/include/netlink/route/link/vlan.h
diff --git a/libnetwork/include/netlink/route/link/info-api.h b/libnetwork/include/netlink/route/link/info-api.h
new file mode 100644
index 0000000..7a2e498
--- /dev/null
+++ b/libnetwork/include/netlink/route/link/info-api.h
@@ -0,0 +1,71 @@
+/*
+ * netlink/route/link/info-api.h Link Info API
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf(a)suug.ch>
+ */
+
+#ifndef NETLINK_LINK_INFO_API_H_
+#define NETLINK_LINK_INFO_API_H_
+
+#include <netlink/netlink.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup link_info
+ *
+ * Link info operations
+ */
+struct rtnl_link_info_ops
+{
+ /** Name of operations, must match name on kernel side */
+ char * io_name;
+
+ /** Reference count (internal, do not use) */
+ int io_refcnt;
+
+ /** Called to assign an info type to a link.
+ * Has to allocate enough resources to hold attributes. Can
+ * use link->l_info to store a pointer. */
+ int (*io_alloc)(struct rtnl_link *);
+
+ /** Called to parse the link info attribute.
+ * Must parse the attribute and assign all values to the link.
+ */
+ int (*io_parse)(struct rtnl_link *,
+ struct nlattr *,
+ struct nlattr *);
+
+ /** Called when the link object is dumped.
+ * Must dump the info type specific attributes. */
+ int (*io_dump[NL_DUMP_MAX+1])(struct rtnl_link *,
+ struct nl_dump_params *, int);
+
+ /** Called when a link object is cloned.
+ * Must clone all info type specific attributes. */
+ int (*io_clone)(struct rtnl_link *, struct rtnl_link *);
+
+ /** Called when construction a link netlink message.
+ * Must append all info type specific attributes to the message. */
+ int (*io_put_attrs)(struct nl_msg *, struct rtnl_link *);
+
+ /** Called to release all resources previously allocated
+ * in either io_alloc() or io_parse(). */
+ void (*io_free)(struct rtnl_link *);
+
+ struct rtnl_link_info_ops * io_next;
+};
+
+extern struct rtnl_link_info_ops *rtnl_link_info_ops_lookup(const char *);
+
+extern int rtnl_link_register_info(struct rtnl_link_info_ops *);
+extern int rtnl_link_unregister_info(struct rtnl_link_info_ops *);
+
+#endif
diff --git a/libnetwork/include/netlink/route/link/vlan.h b/libnetwork/include/netlink/route/link/vlan.h
new file mode 100644
index 0000000..80aa921
--- /dev/null
+++ b/libnetwork/include/netlink/route/link/vlan.h
@@ -0,0 +1,55 @@
+/*
+ * netlink/route/link/vlan.h VLAN interface
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf(a)suug.ch>
+ */
+
+#ifndef NETLINK_LINK_VLAN_H_
+#define NETLINK_LINK_VLAN_H_
+
+#include <netlink/netlink.h>
+#include <netlink/route/link.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct vlan_map
+{
+ uint32_t vm_from;
+ uint32_t vm_to;
+};
+
+#define VLAN_PRIO_MAX 7
+
+extern char * rtnl_link_vlan_flags2str(int, char *, size_t);
+extern int rtnl_link_vlan_str2flags(const char *);
+
+extern int rtnl_link_vlan_set_id(struct rtnl_link *, int);
+extern int rtnl_link_vlan_get_id(struct rtnl_link *);
+
+extern int rtnl_link_vlan_set_flags(struct rtnl_link *,
+ unsigned int);
+extern int rtnl_link_vlan_unset_flags(struct rtnl_link *,
+ unsigned int);
+extern unsigned int rtnl_link_vlan_get_flags(struct rtnl_link *);
+
+extern int rtnl_link_vlan_set_ingress_map(struct rtnl_link *,
+ int, uint32_t);
+extern uint32_t * rtnl_link_vlan_get_ingress_map(struct rtnl_link *);
+
+extern int rtnl_link_vlan_set_egress_map(struct rtnl_link *,
+ uint32_t, int);
+extern struct vlan_map *rtnl_link_vlan_get_egress_map(struct rtnl_link *,
+ int *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--
1.7.1
4
3
18 Jan '12
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
We are now using git (yay!!). Port the commands from mercurial to the git
equivalents.
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
---
suites/libvirt-cim/lib/XenKvmLib/reporting.py | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/suites/libvirt-cim/lib/XenKvmLib/reporting.py b/suites/libvirt-cim/lib/XenKvmLib/reporting.py
index b6df36e..d24f41b 100644
--- a/suites/libvirt-cim/lib/XenKvmLib/reporting.py
+++ b/suites/libvirt-cim/lib/XenKvmLib/reporting.py
@@ -33,10 +33,8 @@ def get_cmd_val(cmd, ip):
return out
def get_cimtest_version():
- revision = commands.getoutput("hg parents --template \
- \"{rev}\" 2>/dev/null")
- changeset = commands.getoutput("hg parents --template \
- \"{node|short}\" 2>/dev/null")
+ revision = commands.getoutput("git rev-list HEAD | wc -l 2>/dev/null")
+ changeset = commands.getoutput("git rev-parse --short HEAD 2>/dev/null")
return revision, changeset
def get_libvirt_ver(ip):
--
1.7.7.5
2
1
[PATCH] autoconfiscate.sh: Use proper command for revision count
by Eduardo Lima (Etrunko) 18 Jan '12
by Eduardo Lima (Etrunko) 18 Jan '12
18 Jan '12
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
---
autoconfiscate.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/autoconfiscate.sh b/autoconfiscate.sh
index 8ea8a30..f0ef048 100755
--- a/autoconfiscate.sh
+++ b/autoconfiscate.sh
@@ -19,7 +19,7 @@ autoconf --force &&
if test -x $(which git); then
git rev-parse --short HEAD > .changeset
- git log | grep "^commit" | wc -l > .revision
+ git rev-list --count HEAD > .revision
else
echo "Unknown" > .changeset
echo "0" > .revision
--
1.7.7.5
2
4
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
Yet another series of patches fixing errors revealed by Coverity tool. It would
be nice if we had a similar setup so we could run the tool on a regular basis. I
started playing with clang a while ago. It also provides a static analyser, but
I could not complete the setup by then.
https://bugzilla.redhat.com/show_bug.cgi?id=750418
Changes from v1:
- Fix compilation error in Patch 1
Best regards, Etrunko
Eduardo Lima (Etrunko) (4):
libxkutil: Fix possible NULL dereferences
Fix possible memory leaks
xml_parse_test: Fix invalid dereference
Fix possible use of unitialized variables
libxkutil/cs_util_instance.c | 5 +++++
libxkutil/device_parsing.c | 14 +++++++-------
libxkutil/pool_parsing.c | 5 +++--
libxkutil/xml_parse_test.c | 3 +--
libxkutil/xmlgen.c | 8 +++++---
src/Virt_AppliedFilterList.c | 3 ++-
src/Virt_Device.c | 20 ++++++++++++++++++++
src/Virt_DevicePool.c | 19 ++++++++++++++++++-
src/Virt_SwitchService.c | 24 ++++++++++++++++++++----
src/Virt_VirtualSystemManagementService.c | 16 ++++++++--------
src/Virt_VirtualSystemSnapshotService.c | 2 +-
11 files changed, 90 insertions(+), 29 deletions(-)
--
1.7.7.5
2
6
These patches would try introduce 4 class with readonly functionality.
It used libnl-3 and libbridge as static libarary as an implemention.
Program libnetwork_test would be generated under ./libnetwork/.libs/ .
Testing:
wbemcli -nl ein http://[]:[]@localhost:5988/root/virt:Net_VirtualEthernetSwitchSystem
wbemcli -nl ein http://[]:[]@localhost:5988/root/virt:Net_VirtualEthernetSwitchSystemSettingData
wbemcli -nl ein http://[]:[]@localhost:5988/root/virt:Net_EthernetPort
wbemcli -nl ein http://[]:[]@localhost:5988/root/virt:Net_EthernetPortAllocationSettingData
try with command vconfig and brctl modifying the system.
Note:
These patch only applys on libvirt-cim-0.5.15, Will try move it to 0.6.0
with libvirt 0.9.4 on RH6 on v4 patch.
repository:
git://gitorious.org/~xiaxia347/libvirt-cim/xiaxia347s-xiawenc.git
branch vlan_v3
https://gitorious.org/libvirt-cim/xiaxia347s-xiawenc/trees/vlan_v3
Wayne Xia (10):
add source code of libbridge and libnl-3
building system modification for libnl3 and libbridge
building system of libnetwork linking with libnl3 and libbridge
libnetwork source code with a test program
add a CIM model helper in libxkutil
CIM model - Makefile change
CIM model - VESS
CIM model - VESSSD
CIM model - EthernetPort
CIM model - EASD
Makefile.am | 14 +-
configure.ac | 19 +-
libnetwork/Makefile.am | 39 +
libnetwork/dll_magic.h | 13 +
libnetwork/host_network_API.c | 30 +
libnetwork/host_network_API.h | 25 +
libnetwork/host_network_basic.c | 657 ++++++
libnetwork/host_network_basic.h | 170 ++
libnetwork/host_network_error.h | 31 +
libnetwork/host_network_helper.c | 659 ++++++
libnetwork/host_network_helper.h | 202 ++
libnetwork/host_network_implement_OSAPI.c | 453 ++++
libnetwork/host_network_implement_OSAPI.h | 21 +
libnetwork/libbridge/.gitignore | 2 +
libnetwork/libbridge/Makefile.am | 20 +
libnetwork/libbridge/libbridge.h | 119 +
libnetwork/libbridge/libbridge_devif.c | 442 ++++
libnetwork/libbridge/libbridge_if.c | 117 +
libnetwork/libbridge/libbridge_init.c | 213 ++
libnetwork/libbridge/libbridge_misc.c | 51 +
libnetwork/libbridge/libbridge_private.h | 56 +
libnetwork/libnetwork_test.c | 82 +
libnetwork/libnl3/Makefile.am | 8 +
libnetwork/libnl3/include/Makefile.am | 122 +
libnetwork/libnl3/include/linux/fib_rules.h | 69 +
libnetwork/libnl3/include/linux/gen_stats.h | 67 +
libnetwork/libnl3/include/linux/genetlink.h | 83 +
libnetwork/libnl3/include/linux/if.h | 140 ++
libnetwork/libnl3/include/linux/if_addr.h | 55 +
libnetwork/libnl3/include/linux/if_arp.h | 156 ++
libnetwork/libnl3/include/linux/if_ether.h | 125 ++
libnetwork/libnl3/include/linux/if_link.h | 377 ++++
libnetwork/libnl3/include/linux/if_vlan.h | 62 +
libnetwork/libnl3/include/linux/inetdevice.h | 36 +
libnetwork/libnl3/include/linux/ip_mp_alg.h | 22 +
libnetwork/libnl3/include/linux/ipv6.h | 146 ++
libnetwork/libnl3/include/linux/neighbour.h | 155 ++
libnetwork/libnl3/include/linux/netfilter.h | 57 +
.../libnl3/include/linux/netfilter/nfnetlink.h | 60 +
.../include/linux/netfilter/nfnetlink_conntrack.h | 140 ++
.../libnl3/include/linux/netfilter/nfnetlink_log.h | 97 +
.../include/linux/netfilter/nfnetlink_queue.h | 94 +
libnetwork/libnl3/include/linux/netlink.h | 149 ++
libnetwork/libnl3/include/linux/pkt_cls.h | 467 ++++
libnetwork/libnl3/include/linux/pkt_sched.h | 606 +++++
libnetwork/libnl3/include/linux/rtnetlink.h | 605 +++++
libnetwork/libnl3/include/linux/snmp.h | 270 +++
.../libnl3/include/linux/tc_ematch/tc_em_meta.h | 89 +
libnetwork/libnl3/include/netlink-generic.h | 20 +
libnetwork/libnl3/include/netlink-local.h | 213 ++
libnetwork/libnl3/include/netlink-tc.h | 55 +
libnetwork/libnl3/include/netlink-types.h | 846 +++++++
libnetwork/libnl3/include/netlink/addr.h | 66 +
libnetwork/libnl3/include/netlink/attr.h | 283 +++
libnetwork/libnl3/include/netlink/cache-api.h | 230 ++
libnetwork/libnl3/include/netlink/cache.h | 134 ++
libnetwork/libnl3/include/netlink/cli/addr.h | 32 +
libnetwork/libnl3/include/netlink/cli/class.h | 21 +
libnetwork/libnl3/include/netlink/cli/cls.h | 24 +
libnetwork/libnl3/include/netlink/cli/ct.h | 34 +
libnetwork/libnl3/include/netlink/cli/link.h | 30 +
libnetwork/libnl3/include/netlink/cli/neigh.h | 27 +
libnetwork/libnl3/include/netlink/cli/qdisc.h | 23 +
libnetwork/libnl3/include/netlink/cli/route.h | 34 +
libnetwork/libnl3/include/netlink/cli/rule.h | 21 +
libnetwork/libnl3/include/netlink/cli/tc.h | 39 +
libnetwork/libnl3/include/netlink/cli/utils.h | 82 +
libnetwork/libnl3/include/netlink/data.h | 41 +
libnetwork/libnl3/include/netlink/errno.h | 64 +
.../libnl3/include/netlink/fib_lookup/lookup.h | 42 +
.../libnl3/include/netlink/fib_lookup/request.h | 51 +
libnetwork/libnl3/include/netlink/genl/ctrl.h | 40 +
libnetwork/libnl3/include/netlink/genl/family.h | 53 +
libnetwork/libnl3/include/netlink/genl/genl.h | 46 +
libnetwork/libnl3/include/netlink/genl/mngt.h | 87 +
libnetwork/libnl3/include/netlink/handlers.h | 146 ++
libnetwork/libnl3/include/netlink/list.h | 93 +
libnetwork/libnl3/include/netlink/msg.h | 147 ++
libnetwork/libnl3/include/netlink/netfilter/ct.h | 126 ++
libnetwork/libnl3/include/netlink/netfilter/log.h | 109 +
.../libnl3/include/netlink/netfilter/log_msg.h | 98 +
.../libnl3/include/netlink/netfilter/netfilter.h | 31 +
libnetwork/libnl3/include/netlink/netfilter/nfnl.h | 44 +
.../libnl3/include/netlink/netfilter/queue.h | 90 +
.../libnl3/include/netlink/netfilter/queue_msg.h | 104 +
libnetwork/libnl3/include/netlink/netlink-compat.h | 50 +
libnetwork/libnl3/include/netlink/netlink-kernel.h | 293 +++
libnetwork/libnl3/include/netlink/netlink.h | 93 +
libnetwork/libnl3/include/netlink/object-api.h | 348 +++
libnetwork/libnl3/include/netlink/object.h | 70 +
libnetwork/libnl3/include/netlink/route/addr.h | 98 +
libnetwork/libnl3/include/netlink/route/class.h | 66 +
.../libnl3/include/netlink/route/classifier.h | 51 +
.../libnl3/include/netlink/route/cls/basic.h | 31 +
.../libnl3/include/netlink/route/cls/cgroup.h | 30 +
.../libnl3/include/netlink/route/cls/ematch.h | 95 +
.../libnl3/include/netlink/route/cls/ematch/cmp.h | 32 +
.../libnl3/include/netlink/route/cls/ematch/meta.h | 41 +
.../include/netlink/route/cls/ematch/nbyte.h | 36 +
.../libnl3/include/netlink/route/cls/ematch/text.h | 42 +
libnetwork/libnl3/include/netlink/route/cls/fw.h | 29 +
.../libnl3/include/netlink/route/cls/police.h | 29 +
libnetwork/libnl3/include/netlink/route/cls/u32.h | 43 +
libnetwork/libnl3/include/netlink/route/link.h | 217 ++
libnetwork/libnl3/include/netlink/route/link/api.h | 134 ++
.../libnl3/include/netlink/route/link/bonding.h | 37 +
.../libnl3/include/netlink/route/link/inet.h | 29 +
.../libnl3/include/netlink/route/link/info-api.h | 20 +
.../libnl3/include/netlink/route/link/vlan.h | 57 +
.../libnl3/include/netlink/route/neighbour.h | 79 +
libnetwork/libnl3/include/netlink/route/neightbl.h | 65 +
libnetwork/libnl3/include/netlink/route/nexthop.h | 65 +
libnetwork/libnl3/include/netlink/route/pktloc.h | 49 +
libnetwork/libnl3/include/netlink/route/qdisc.h | 73 +
.../libnl3/include/netlink/route/qdisc/cbq.h | 30 +
.../libnl3/include/netlink/route/qdisc/dsmark.h | 41 +
.../libnl3/include/netlink/route/qdisc/fifo.h | 28 +
.../libnl3/include/netlink/route/qdisc/htb.h | 47 +
.../libnl3/include/netlink/route/qdisc/netem.h | 75 +
.../libnl3/include/netlink/route/qdisc/prio.h | 53 +
.../libnl3/include/netlink/route/qdisc/red.h | 17 +
.../libnl3/include/netlink/route/qdisc/sfq.h | 36 +
.../libnl3/include/netlink/route/qdisc/tbf.h | 40 +
libnetwork/libnl3/include/netlink/route/route.h | 124 +
libnetwork/libnl3/include/netlink/route/rtnl.h | 69 +
libnetwork/libnl3/include/netlink/route/rule.h | 75 +
libnetwork/libnl3/include/netlink/route/tc-api.h | 143 ++
libnetwork/libnl3/include/netlink/route/tc.h | 105 +
libnetwork/libnl3/include/netlink/socket.h | 69 +
libnetwork/libnl3/include/netlink/types.h | 110 +
libnetwork/libnl3/include/netlink/utils.h | 85 +
libnetwork/libnl3/include/netlink/version.h | 28 +
libnetwork/libnl3/include/netlink/version.h.in | 28 +
libnetwork/libnl3/lib/Makefile.am | 99 +
libnetwork/libnl3/lib/addr.c | 918 ++++++++
libnetwork/libnl3/lib/attr.c | 1213 ++++++++++
libnetwork/libnl3/lib/cache.c | 965 ++++++++
libnetwork/libnl3/lib/cache_mngr.c | 391 ++++
libnetwork/libnl3/lib/cache_mngt.c | 256 +++
libnetwork/libnl3/lib/cli/cls/basic.c | 93 +
libnetwork/libnl3/lib/cli/cls/cgroup.c | 75 +
libnetwork/libnl3/lib/cli/qdisc/bfifo.c | 83 +
libnetwork/libnl3/lib/cli/qdisc/blackhole.c | 64 +
libnetwork/libnl3/lib/cli/qdisc/htb.c | 203 ++
libnetwork/libnl3/lib/cli/qdisc/pfifo.c | 77 +
libnetwork/libnl3/lib/data.c | 186 ++
libnetwork/libnl3/lib/defs.h | 85 +
libnetwork/libnl3/lib/defs.h.in | 84 +
libnetwork/libnl3/lib/error.c | 116 +
libnetwork/libnl3/lib/fib_lookup/lookup.c | 348 +++
libnetwork/libnl3/lib/fib_lookup/request.c | 185 ++
libnetwork/libnl3/lib/genl/ctrl.c | 380 ++++
libnetwork/libnl3/lib/genl/family.c | 316 +++
libnetwork/libnl3/lib/genl/genl.c | 268 +++
libnetwork/libnl3/lib/genl/mngt.c | 273 +++
libnetwork/libnl3/lib/handlers.c | 395 ++++
libnetwork/libnl3/lib/msg.c | 1050 +++++++++
libnetwork/libnl3/lib/netfilter/ct.c | 601 +++++
libnetwork/libnl3/lib/netfilter/ct_obj.c | 785 +++++++
libnetwork/libnl3/lib/netfilter/log.c | 251 +++
libnetwork/libnl3/lib/netfilter/log_msg.c | 209 ++
libnetwork/libnl3/lib/netfilter/log_msg_obj.c | 458 ++++
libnetwork/libnl3/lib/netfilter/log_obj.c | 287 +++
libnetwork/libnl3/lib/netfilter/netfilter.c | 53 +
libnetwork/libnl3/lib/netfilter/nfnl.c | 245 ++
libnetwork/libnl3/lib/netfilter/queue.c | 251 +++
libnetwork/libnl3/lib/netfilter/queue_msg.c | 284 +++
libnetwork/libnl3/lib/netfilter/queue_msg_obj.c | 492 ++++
libnetwork/libnl3/lib/netfilter/queue_obj.c | 215 ++
libnetwork/libnl3/lib/nl.c | 896 ++++++++
libnetwork/libnl3/lib/object.c | 395 ++++
libnetwork/libnl3/lib/route/addr.c | 1054 +++++++++
libnetwork/libnl3/lib/route/class.c | 473 ++++
libnetwork/libnl3/lib/route/classid.c | 441 ++++
libnetwork/libnl3/lib/route/cls.c | 441 ++++
libnetwork/libnl3/lib/route/cls/basic.c | 229 ++
libnetwork/libnl3/lib/route/cls/cgroup.c | 189 ++
libnetwork/libnl3/lib/route/cls/ematch.c | 701 ++++++
libnetwork/libnl3/lib/route/cls/ematch/cmp.c | 93 +
libnetwork/libnl3/lib/route/cls/ematch/container.c | 41 +
libnetwork/libnl3/lib/route/cls/ematch/meta.c | 334 +++
libnetwork/libnl3/lib/route/cls/ematch/nbyte.c | 139 ++
libnetwork/libnl3/lib/route/cls/ematch/text.c | 183 ++
libnetwork/libnl3/lib/route/cls/ematch_grammar.l | 162 ++
libnetwork/libnl3/lib/route/cls/ematch_syntax.y | 497 +++++
libnetwork/libnl3/lib/route/cls/fw.c | 190 ++
libnetwork/libnl3/lib/route/cls/police.c | 66 +
libnetwork/libnl3/lib/route/cls/u32.c | 551 +++++
libnetwork/libnl3/lib/route/link.c | 2342 ++++++++++++++++++++
libnetwork/libnl3/lib/route/link/api.c | 316 +++
libnetwork/libnl3/lib/route/link/bonding.c | 217 ++
libnetwork/libnl3/lib/route/link/bridge.c | 83 +
libnetwork/libnl3/lib/route/link/dummy.c | 40 +
libnetwork/libnl3/lib/route/link/inet.c | 280 +++
libnetwork/libnl3/lib/route/link/inet6.c | 377 ++++
libnetwork/libnl3/lib/route/link/vlan.c | 565 +++++
libnetwork/libnl3/lib/route/neigh.c | 846 +++++++
libnetwork/libnl3/lib/route/neightbl.c | 815 +++++++
libnetwork/libnl3/lib/route/nexthop.c | 290 +++
libnetwork/libnl3/lib/route/pktloc.c | 260 +++
libnetwork/libnl3/lib/route/pktloc_grammar.l | 51 +
libnetwork/libnl3/lib/route/pktloc_syntax.y | 103 +
libnetwork/libnl3/lib/route/qdisc.c | 575 +++++
libnetwork/libnl3/lib/route/qdisc/blackhole.c | 37 +
libnetwork/libnl3/lib/route/qdisc/cbq.c | 204 ++
libnetwork/libnl3/lib/route/qdisc/dsmark.c | 413 ++++
libnetwork/libnl3/lib/route/qdisc/fifo.c | 169 ++
libnetwork/libnl3/lib/route/qdisc/htb.c | 643 ++++++
libnetwork/libnl3/lib/route/qdisc/netem.c | 906 ++++++++
libnetwork/libnl3/lib/route/qdisc/prio.c | 294 +++
libnetwork/libnl3/lib/route/qdisc/red.c | 190 ++
libnetwork/libnl3/lib/route/qdisc/sfq.c | 256 +++
libnetwork/libnl3/lib/route/qdisc/tbf.c | 460 ++++
libnetwork/libnl3/lib/route/route.c | 202 ++
libnetwork/libnl3/lib/route/route_obj.c | 1148 ++++++++++
libnetwork/libnl3/lib/route/route_utils.c | 171 ++
libnetwork/libnl3/lib/route/rtnl.c | 124 +
libnetwork/libnl3/lib/route/rule.c | 753 +++++++
libnetwork/libnl3/lib/route/tc.c | 1069 +++++++++
libnetwork/libnl3/lib/socket.c | 628 ++++++
libnetwork/libnl3/lib/stamp-h1 | 1 +
libnetwork/libnl3/lib/utils.c | 1040 +++++++++
libxkutil/Makefile.am | 12 +-
libxkutil/network_model_helper.c | 466 ++++
libxkutil/network_model_helper.h | 105 +
schema/EthernetPort.mof | 4 +
schema/EthernetPort.registration | 3 +
schema/EthernetPortAllocationSettingData.mof | 21 +
.../EthernetPortAllocationSettingData.registration | 3 +
schema/VirtualEthernetSwitchSystem.mof | 10 +
schema/VirtualEthernetSwitchSystem.registration | 3 +
schema/VirtualEthernetSwitchSystemSettingData.mof | 27 +
...ualEthernetSwitchSystemSettingData.registration | 3 +
src/Makefile.am | 23 +-
src/Virt_EASD.c | 729 ++++++
src/Virt_EASD.h | 59 +
src/Virt_EthernetPort.c | 561 +++++
src/Virt_EthernetPort.h | 58 +
src/Virt_VESSSD.c | 372 ++++
src/Virt_VESSSD.h | 39 +
src/Virt_VirtualEthernetSwitchSystem.c | 477 ++++
src/Virt_VirtualEthernetSwitchSystem.h | 52 +
242 files changed, 53037 insertions(+), 10 deletions(-)
create mode 100644 libnetwork/Makefile.am
create mode 100644 libnetwork/dll_magic.h
create mode 100644 libnetwork/host_network_API.c
create mode 100644 libnetwork/host_network_API.h
create mode 100644 libnetwork/host_network_basic.c
create mode 100644 libnetwork/host_network_basic.h
create mode 100644 libnetwork/host_network_error.h
create mode 100644 libnetwork/host_network_helper.c
create mode 100644 libnetwork/host_network_helper.h
create mode 100644 libnetwork/host_network_implement_OSAPI.c
create mode 100644 libnetwork/host_network_implement_OSAPI.h
create mode 100755 libnetwork/libbridge/.gitignore
create mode 100644 libnetwork/libbridge/Makefile.am
create mode 100644 libnetwork/libbridge/libbridge.h
create mode 100644 libnetwork/libbridge/libbridge_devif.c
create mode 100644 libnetwork/libbridge/libbridge_if.c
create mode 100644 libnetwork/libbridge/libbridge_init.c
create mode 100644 libnetwork/libbridge/libbridge_misc.c
create mode 100644 libnetwork/libbridge/libbridge_private.h
create mode 100644 libnetwork/libnetwork_test.c
create mode 100644 libnetwork/libnl3/Makefile.am
create mode 100644 libnetwork/libnl3/include/Makefile.am
create mode 100644 libnetwork/libnl3/include/linux/fib_rules.h
create mode 100644 libnetwork/libnl3/include/linux/gen_stats.h
create mode 100644 libnetwork/libnl3/include/linux/genetlink.h
create mode 100644 libnetwork/libnl3/include/linux/if.h
create mode 100644 libnetwork/libnl3/include/linux/if_addr.h
create mode 100644 libnetwork/libnl3/include/linux/if_arp.h
create mode 100644 libnetwork/libnl3/include/linux/if_ether.h
create mode 100644 libnetwork/libnl3/include/linux/if_link.h
create mode 100644 libnetwork/libnl3/include/linux/if_vlan.h
create mode 100644 libnetwork/libnl3/include/linux/inetdevice.h
create mode 100644 libnetwork/libnl3/include/linux/ip_mp_alg.h
create mode 100644 libnetwork/libnl3/include/linux/ipv6.h
create mode 100644 libnetwork/libnl3/include/linux/neighbour.h
create mode 100644 libnetwork/libnl3/include/linux/netfilter.h
create mode 100644 libnetwork/libnl3/include/linux/netfilter/nfnetlink.h
create mode 100644 libnetwork/libnl3/include/linux/netfilter/nfnetlink_conntrack.h
create mode 100644 libnetwork/libnl3/include/linux/netfilter/nfnetlink_log.h
create mode 100644 libnetwork/libnl3/include/linux/netfilter/nfnetlink_queue.h
create mode 100644 libnetwork/libnl3/include/linux/netlink.h
create mode 100644 libnetwork/libnl3/include/linux/pkt_cls.h
create mode 100644 libnetwork/libnl3/include/linux/pkt_sched.h
create mode 100644 libnetwork/libnl3/include/linux/rtnetlink.h
create mode 100644 libnetwork/libnl3/include/linux/snmp.h
create mode 100644 libnetwork/libnl3/include/linux/tc_ematch/tc_em_meta.h
create mode 100644 libnetwork/libnl3/include/netlink-generic.h
create mode 100644 libnetwork/libnl3/include/netlink-local.h
create mode 100644 libnetwork/libnl3/include/netlink-tc.h
create mode 100644 libnetwork/libnl3/include/netlink-types.h
create mode 100644 libnetwork/libnl3/include/netlink/addr.h
create mode 100644 libnetwork/libnl3/include/netlink/attr.h
create mode 100644 libnetwork/libnl3/include/netlink/cache-api.h
create mode 100644 libnetwork/libnl3/include/netlink/cache.h
create mode 100644 libnetwork/libnl3/include/netlink/cli/addr.h
create mode 100644 libnetwork/libnl3/include/netlink/cli/class.h
create mode 100644 libnetwork/libnl3/include/netlink/cli/cls.h
create mode 100644 libnetwork/libnl3/include/netlink/cli/ct.h
create mode 100644 libnetwork/libnl3/include/netlink/cli/link.h
create mode 100644 libnetwork/libnl3/include/netlink/cli/neigh.h
create mode 100644 libnetwork/libnl3/include/netlink/cli/qdisc.h
create mode 100644 libnetwork/libnl3/include/netlink/cli/route.h
create mode 100644 libnetwork/libnl3/include/netlink/cli/rule.h
create mode 100644 libnetwork/libnl3/include/netlink/cli/tc.h
create mode 100644 libnetwork/libnl3/include/netlink/cli/utils.h
create mode 100644 libnetwork/libnl3/include/netlink/data.h
create mode 100644 libnetwork/libnl3/include/netlink/errno.h
create mode 100644 libnetwork/libnl3/include/netlink/fib_lookup/lookup.h
create mode 100644 libnetwork/libnl3/include/netlink/fib_lookup/request.h
create mode 100644 libnetwork/libnl3/include/netlink/genl/ctrl.h
create mode 100644 libnetwork/libnl3/include/netlink/genl/family.h
create mode 100644 libnetwork/libnl3/include/netlink/genl/genl.h
create mode 100644 libnetwork/libnl3/include/netlink/genl/mngt.h
create mode 100644 libnetwork/libnl3/include/netlink/handlers.h
create mode 100644 libnetwork/libnl3/include/netlink/list.h
create mode 100644 libnetwork/libnl3/include/netlink/msg.h
create mode 100644 libnetwork/libnl3/include/netlink/netfilter/ct.h
create mode 100644 libnetwork/libnl3/include/netlink/netfilter/log.h
create mode 100644 libnetwork/libnl3/include/netlink/netfilter/log_msg.h
create mode 100644 libnetwork/libnl3/include/netlink/netfilter/netfilter.h
create mode 100644 libnetwork/libnl3/include/netlink/netfilter/nfnl.h
create mode 100644 libnetwork/libnl3/include/netlink/netfilter/queue.h
create mode 100644 libnetwork/libnl3/include/netlink/netfilter/queue_msg.h
create mode 100644 libnetwork/libnl3/include/netlink/netlink-compat.h
create mode 100644 libnetwork/libnl3/include/netlink/netlink-kernel.h
create mode 100644 libnetwork/libnl3/include/netlink/netlink.h
create mode 100644 libnetwork/libnl3/include/netlink/object-api.h
create mode 100644 libnetwork/libnl3/include/netlink/object.h
create mode 100644 libnetwork/libnl3/include/netlink/route/addr.h
create mode 100644 libnetwork/libnl3/include/netlink/route/class.h
create mode 100644 libnetwork/libnl3/include/netlink/route/classifier.h
create mode 100644 libnetwork/libnl3/include/netlink/route/cls/basic.h
create mode 100644 libnetwork/libnl3/include/netlink/route/cls/cgroup.h
create mode 100644 libnetwork/libnl3/include/netlink/route/cls/ematch.h
create mode 100644 libnetwork/libnl3/include/netlink/route/cls/ematch/cmp.h
create mode 100644 libnetwork/libnl3/include/netlink/route/cls/ematch/meta.h
create mode 100644 libnetwork/libnl3/include/netlink/route/cls/ematch/nbyte.h
create mode 100644 libnetwork/libnl3/include/netlink/route/cls/ematch/text.h
create mode 100644 libnetwork/libnl3/include/netlink/route/cls/fw.h
create mode 100644 libnetwork/libnl3/include/netlink/route/cls/police.h
create mode 100644 libnetwork/libnl3/include/netlink/route/cls/u32.h
create mode 100644 libnetwork/libnl3/include/netlink/route/link.h
create mode 100644 libnetwork/libnl3/include/netlink/route/link/api.h
create mode 100644 libnetwork/libnl3/include/netlink/route/link/bonding.h
create mode 100644 libnetwork/libnl3/include/netlink/route/link/inet.h
create mode 100644 libnetwork/libnl3/include/netlink/route/link/info-api.h
create mode 100644 libnetwork/libnl3/include/netlink/route/link/vlan.h
create mode 100644 libnetwork/libnl3/include/netlink/route/neighbour.h
create mode 100644 libnetwork/libnl3/include/netlink/route/neightbl.h
create mode 100644 libnetwork/libnl3/include/netlink/route/nexthop.h
create mode 100644 libnetwork/libnl3/include/netlink/route/pktloc.h
create mode 100644 libnetwork/libnl3/include/netlink/route/qdisc.h
create mode 100644 libnetwork/libnl3/include/netlink/route/qdisc/cbq.h
create mode 100644 libnetwork/libnl3/include/netlink/route/qdisc/dsmark.h
create mode 100644 libnetwork/libnl3/include/netlink/route/qdisc/fifo.h
create mode 100644 libnetwork/libnl3/include/netlink/route/qdisc/htb.h
create mode 100644 libnetwork/libnl3/include/netlink/route/qdisc/netem.h
create mode 100644 libnetwork/libnl3/include/netlink/route/qdisc/prio.h
create mode 100644 libnetwork/libnl3/include/netlink/route/qdisc/red.h
create mode 100644 libnetwork/libnl3/include/netlink/route/qdisc/sfq.h
create mode 100644 libnetwork/libnl3/include/netlink/route/qdisc/tbf.h
create mode 100644 libnetwork/libnl3/include/netlink/route/route.h
create mode 100644 libnetwork/libnl3/include/netlink/route/rtnl.h
create mode 100644 libnetwork/libnl3/include/netlink/route/rule.h
create mode 100644 libnetwork/libnl3/include/netlink/route/tc-api.h
create mode 100644 libnetwork/libnl3/include/netlink/route/tc.h
create mode 100644 libnetwork/libnl3/include/netlink/socket.h
create mode 100644 libnetwork/libnl3/include/netlink/types.h
create mode 100644 libnetwork/libnl3/include/netlink/utils.h
create mode 100644 libnetwork/libnl3/include/netlink/version.h
create mode 100644 libnetwork/libnl3/include/netlink/version.h.in
create mode 100644 libnetwork/libnl3/lib/Makefile.am
create mode 100644 libnetwork/libnl3/lib/addr.c
create mode 100644 libnetwork/libnl3/lib/attr.c
create mode 100644 libnetwork/libnl3/lib/cache.c
create mode 100644 libnetwork/libnl3/lib/cache_mngr.c
create mode 100644 libnetwork/libnl3/lib/cache_mngt.c
create mode 100644 libnetwork/libnl3/lib/cli/cls/.dirstamp
create mode 100644 libnetwork/libnl3/lib/cli/cls/basic.c
create mode 100644 libnetwork/libnl3/lib/cli/cls/cgroup.c
create mode 100644 libnetwork/libnl3/lib/cli/qdisc/.dirstamp
create mode 100644 libnetwork/libnl3/lib/cli/qdisc/bfifo.c
create mode 100644 libnetwork/libnl3/lib/cli/qdisc/blackhole.c
create mode 100644 libnetwork/libnl3/lib/cli/qdisc/htb.c
create mode 100644 libnetwork/libnl3/lib/cli/qdisc/pfifo.c
create mode 100644 libnetwork/libnl3/lib/data.c
create mode 100644 libnetwork/libnl3/lib/defs.h
create mode 100644 libnetwork/libnl3/lib/defs.h.in
create mode 100644 libnetwork/libnl3/lib/error.c
create mode 100644 libnetwork/libnl3/lib/fib_lookup/.dirstamp
create mode 100644 libnetwork/libnl3/lib/fib_lookup/lookup.c
create mode 100644 libnetwork/libnl3/lib/fib_lookup/request.c
create mode 100644 libnetwork/libnl3/lib/genl/.dirstamp
create mode 100644 libnetwork/libnl3/lib/genl/ctrl.c
create mode 100644 libnetwork/libnl3/lib/genl/family.c
create mode 100644 libnetwork/libnl3/lib/genl/genl.c
create mode 100644 libnetwork/libnl3/lib/genl/mngt.c
create mode 100644 libnetwork/libnl3/lib/handlers.c
create mode 100644 libnetwork/libnl3/lib/msg.c
create mode 100644 libnetwork/libnl3/lib/netfilter/.dirstamp
create mode 100644 libnetwork/libnl3/lib/netfilter/ct.c
create mode 100644 libnetwork/libnl3/lib/netfilter/ct_obj.c
create mode 100644 libnetwork/libnl3/lib/netfilter/log.c
create mode 100644 libnetwork/libnl3/lib/netfilter/log_msg.c
create mode 100644 libnetwork/libnl3/lib/netfilter/log_msg_obj.c
create mode 100644 libnetwork/libnl3/lib/netfilter/log_obj.c
create mode 100644 libnetwork/libnl3/lib/netfilter/netfilter.c
create mode 100644 libnetwork/libnl3/lib/netfilter/nfnl.c
create mode 100644 libnetwork/libnl3/lib/netfilter/queue.c
create mode 100644 libnetwork/libnl3/lib/netfilter/queue_msg.c
create mode 100644 libnetwork/libnl3/lib/netfilter/queue_msg_obj.c
create mode 100644 libnetwork/libnl3/lib/netfilter/queue_obj.c
create mode 100644 libnetwork/libnl3/lib/nl.c
create mode 100644 libnetwork/libnl3/lib/object.c
create mode 100644 libnetwork/libnl3/lib/route/.dirstamp
create mode 100644 libnetwork/libnl3/lib/route/addr.c
create mode 100644 libnetwork/libnl3/lib/route/class.c
create mode 100644 libnetwork/libnl3/lib/route/classid.c
create mode 100644 libnetwork/libnl3/lib/route/cls.c
create mode 100644 libnetwork/libnl3/lib/route/cls/.dirstamp
create mode 100644 libnetwork/libnl3/lib/route/cls/basic.c
create mode 100644 libnetwork/libnl3/lib/route/cls/cgroup.c
create mode 100644 libnetwork/libnl3/lib/route/cls/ematch.c
create mode 100644 libnetwork/libnl3/lib/route/cls/ematch/.dirstamp
create mode 100644 libnetwork/libnl3/lib/route/cls/ematch/cmp.c
create mode 100644 libnetwork/libnl3/lib/route/cls/ematch/container.c
create mode 100644 libnetwork/libnl3/lib/route/cls/ematch/meta.c
create mode 100644 libnetwork/libnl3/lib/route/cls/ematch/nbyte.c
create mode 100644 libnetwork/libnl3/lib/route/cls/ematch/text.c
create mode 100644 libnetwork/libnl3/lib/route/cls/ematch_grammar.l
create mode 100644 libnetwork/libnl3/lib/route/cls/ematch_syntax.y
create mode 100644 libnetwork/libnl3/lib/route/cls/fw.c
create mode 100644 libnetwork/libnl3/lib/route/cls/police.c
create mode 100644 libnetwork/libnl3/lib/route/cls/u32.c
create mode 100644 libnetwork/libnl3/lib/route/link.c
create mode 100644 libnetwork/libnl3/lib/route/link/.dirstamp
create mode 100644 libnetwork/libnl3/lib/route/link/api.c
create mode 100644 libnetwork/libnl3/lib/route/link/bonding.c
create mode 100644 libnetwork/libnl3/lib/route/link/bridge.c
create mode 100644 libnetwork/libnl3/lib/route/link/dummy.c
create mode 100644 libnetwork/libnl3/lib/route/link/inet.c
create mode 100644 libnetwork/libnl3/lib/route/link/inet6.c
create mode 100644 libnetwork/libnl3/lib/route/link/vlan.c
create mode 100644 libnetwork/libnl3/lib/route/neigh.c
create mode 100644 libnetwork/libnl3/lib/route/neightbl.c
create mode 100644 libnetwork/libnl3/lib/route/nexthop.c
create mode 100644 libnetwork/libnl3/lib/route/pktloc.c
create mode 100644 libnetwork/libnl3/lib/route/pktloc_grammar.l
create mode 100644 libnetwork/libnl3/lib/route/pktloc_syntax.y
create mode 100644 libnetwork/libnl3/lib/route/qdisc.c
create mode 100644 libnetwork/libnl3/lib/route/qdisc/.dirstamp
create mode 100644 libnetwork/libnl3/lib/route/qdisc/blackhole.c
create mode 100644 libnetwork/libnl3/lib/route/qdisc/cbq.c
create mode 100644 libnetwork/libnl3/lib/route/qdisc/dsmark.c
create mode 100644 libnetwork/libnl3/lib/route/qdisc/fifo.c
create mode 100644 libnetwork/libnl3/lib/route/qdisc/htb.c
create mode 100644 libnetwork/libnl3/lib/route/qdisc/netem.c
create mode 100644 libnetwork/libnl3/lib/route/qdisc/prio.c
create mode 100644 libnetwork/libnl3/lib/route/qdisc/red.c
create mode 100644 libnetwork/libnl3/lib/route/qdisc/sfq.c
create mode 100644 libnetwork/libnl3/lib/route/qdisc/tbf.c
create mode 100644 libnetwork/libnl3/lib/route/route.c
create mode 100644 libnetwork/libnl3/lib/route/route_obj.c
create mode 100644 libnetwork/libnl3/lib/route/route_utils.c
create mode 100644 libnetwork/libnl3/lib/route/rtnl.c
create mode 100644 libnetwork/libnl3/lib/route/rule.c
create mode 100644 libnetwork/libnl3/lib/route/tc.c
create mode 100644 libnetwork/libnl3/lib/socket.c
create mode 100644 libnetwork/libnl3/lib/stamp-h1
create mode 100644 libnetwork/libnl3/lib/utils.c
create mode 100644 libxkutil/network_model_helper.c
create mode 100644 libxkutil/network_model_helper.h
create mode 100644 schema/EthernetPort.mof
create mode 100644 schema/EthernetPort.registration
create mode 100644 schema/EthernetPortAllocationSettingData.mof
create mode 100644 schema/EthernetPortAllocationSettingData.registration
create mode 100644 schema/VirtualEthernetSwitchSystem.mof
create mode 100644 schema/VirtualEthernetSwitchSystem.registration
create mode 100644 schema/VirtualEthernetSwitchSystemSettingData.mof
create mode 100644 schema/VirtualEthernetSwitchSystemSettingData.registration
create mode 100644 src/Virt_EASD.c
create mode 100644 src/Virt_EASD.h
create mode 100644 src/Virt_EthernetPort.c
create mode 100644 src/Virt_EthernetPort.h
create mode 100644 src/Virt_VESSSD.c
create mode 100644 src/Virt_VESSSD.h
create mode 100644 src/Virt_VirtualEthernetSwitchSystem.c
create mode 100644 src/Virt_VirtualEthernetSwitchSystem.h
--
1.7.6
5
18
Provide a pure C test program employing libnetwork. Note it is linked
with libcmpiutil, so need CU_DEBUG to be set to stdout to see the output.
Try vconfig and brctl command modifying the network and then run the test
program to see the output.
Signed-off-by: Wenchao Xia <xiawenc(a)cn.ibm.com>
---
libnetwork/libnetwork_test.c | 91 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 91 insertions(+), 0 deletions(-)
create mode 100644 libnetwork/libnetwork_test.c
diff --git a/libnetwork/libnetwork_test.c b/libnetwork/libnetwork_test.c
new file mode 100644
index 0000000..a611846
--- /dev/null
+++ b/libnetwork/libnetwork_test.c
@@ -0,0 +1,91 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <time.h>
+#include <assert.h>
+#include <sys/time.h>
+
+#include "host_network_API.h"
+
+static long print_and_ret_time_stamp(void)
+{
+ struct timeval tv;
+ long ret;
+ gettimeofday(&tv, NULL);
+ ret = tv.tv_sec*1000+ tv.tv_usec/1000;
+ printf("time is [%ld] ms.", ret);
+ return ret;
+}
+
+int main(int argc, char **argv)
+{
+ EthIfacesList ifaces_list;
+ EthIface iface_ref,iface_br,iface_vlan;
+ int comp_ret = 0;
+ int persist_flag = 1;
+ long timestart, timeend;
+ int i;
+
+
+ printf("executing the program with persist flag %d.\n", persist_flag);
+ comp_ret = 0;
+
+ eth_ifaceslist_init(&ifaces_list);
+ eth_iface_init(&iface_ref);
+ eth_iface_init(&iface_br);
+ eth_iface_init(&iface_vlan);
+
+ eth_iface_add_br_prop(&iface_br);
+ eth_iface_add_vlan_prop(&iface_vlan, VLAN_TYPE_802_1_Q);
+ iface_br.eth_type = ETH_TYPE_ETHER_SUB_BRIDGE | ETH_TYPE_ETHER_ANY;
+ iface_vlan.eth_type = ETH_TYPE_ETHER_SUB_VLAN | ETH_TYPE_ETHER_ANY;
+
+ //iface_ref.name = SAFE_STRDUP("eth1.100");
+ iface_ref.eth_type = ETH_TYPE_ETHER_SUB_BRIDGE | ETH_TYPE_ETHER_ANY;
+
+ iface_br.name = SAFE_STRDUP("test_br");
+ iface_vlan.name = SAFE_STRDUP("eth0.1000");
+
+ iface_br.pbr_prop->STP = 1;
+
+ iface_vlan.pvlan_prop->vlan_type = VLAN_TYPE_802_1_Q;
+ iface_vlan.pvlan_prop->props.prop_8021q.parent = SAFE_STRDUP("eth0");
+ iface_vlan.pvlan_prop->props.prop_8021q.vlan_id = 1000;
+ iface_vlan.pvlan_prop->props.prop_8021q.reorder_hdr = 0;
+ iface_vlan.pvlan_prop->props.prop_8021q.ingress.count = 1;
+ iface_vlan.pvlan_prop->props.prop_8021q.ingress.values[0].from = 2;
+ iface_vlan.pvlan_prop->props.prop_8021q.ingress.values[0].to = 3;
+ iface_vlan.pvlan_prop->props.prop_8021q.egress.count = 1;
+ iface_vlan.pvlan_prop->props.prop_8021q.egress.values[0].from = 4;
+ iface_vlan.pvlan_prop->props.prop_8021q.egress.values[0].to = 6;
+
+ timestart = print_and_ret_time_stamp();
+ printf(" start list the host ifaces.\n");
+
+ get_host_ifaces(&ifaces_list, NULL, NULL);
+ //get_host_ifaces(&ifaces_list, eth_iface_filter_by_ref, &iface_ref);
+ //get_host_ifaces(&ifaces_list, eth_iface_filter_vlans, NULL);
+ //get_host_ifaces(&ifaces_list, eth_iface_filter_peths, NULL);
+
+ timeend = print_and_ret_time_stamp();
+ printf(" end list the host ifaces, cost [%ld]ms.\n", timeend-timestart);
+
+ eth_ifaceslist_print(&ifaces_list);
+ eth_ifaceslist_uninit(&ifaces_list);
+
+ /* test for mem leak */
+/*
+ for (i = 0; i < 10; i++) {
+ eth_ifaceslist_init(&ifaces_list);
+ get_host_ifaces(&ifaces_list, NULL, NULL);
+ eth_ifaceslist_uninit(&ifaces_list);
+ }
+*/
+ eth_iface_uninit(&iface_ref);
+ eth_iface_uninit(&iface_br);
+ eth_iface_uninit(&iface_vlan);
+
+ return 0;
+}
--
1.7.1
1
0
This patch simple add APIs.
Signed-off-by: Wenchao Xia <xiawenc(a)cn.ibm.com>
---
libnetwork/host_network_API.c | 30 ++++++++++++++++++++++++++++++
libnetwork/host_network_API.h | 25 +++++++++++++++++++++++++
2 files changed, 55 insertions(+), 0 deletions(-)
create mode 100644 libnetwork/host_network_API.c
create mode 100644 libnetwork/host_network_API.h
diff --git a/libnetwork/host_network_API.c b/libnetwork/host_network_API.c
new file mode 100644
index 0000000..975dbda
--- /dev/null
+++ b/libnetwork/host_network_API.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright IBM Corp. 2012
+ *
+ * Authors:
+ * Wenchao Xia <xiawenc(a)cn.ibm.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+
+#include "host_network_API.h"
+#include "host_network_implement_OSAPI.h"
+#include "host_network_error.h"
+
+/* this layer is added to devide the abstraction and implemention, so that
+ different implemention could be used and switched */
+
+int get_host_ifaces(EthIfacesList *plist,
+ eth_iface_filter_func filter_func, void *filter_opaque)
+{
+ return get_host_eth_ifaces_osapi(plist, filter_func, filter_opaque);
+}
+
+char *get_host_iface_error_reason(int errno)
+{
+ return translate_error_no(errno);
+}
diff --git a/libnetwork/host_network_API.h b/libnetwork/host_network_API.h
new file mode 100644
index 0000000..e3732a4
--- /dev/null
+++ b/libnetwork/host_network_API.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright IBM Corp. 2012
+ *
+ * Authors:
+ * Wenchao Xia <xiawenc(a)cn.ibm.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+#ifndef HOST_NETWORK_API
+#define HOST_NETWORK_API
+
+#include "dll_magic.h"
+#include "host_network_basic.h"
+#include "host_network_helper.h"
+
+DLL_PUBLIC int get_host_ifaces(EthIfacesList *plist,
+ eth_iface_filter_func filter_func, void *filter_opaque);
+
+DLL_PUBLIC char *get_host_iface_error_reason(int errno);
+
+#endif
--
1.7.1
1
0
18 Jan '12
This patch have help functions for libnetwork. It contains macro defines
and help functions for host network configuration. It also provide some basic
function such as conditional merge char*, int and properties of structure
EthIface.
Signed-off-by: Wenchao Xia <xiawenc(a)cn.ibm.com>
---
libnetwork/dll_magic.h | 13 ++
libnetwork/host_network_error.h | 23 ++++
libnetwork/host_network_helper.c | 266 ++++++++++++++++++++++++++++++++++++++
libnetwork/host_network_helper.h | 177 +++++++++++++++++++++++++
4 files changed, 479 insertions(+), 0 deletions(-)
create mode 100644 libnetwork/dll_magic.h
create mode 100644 libnetwork/host_network_error.h
create mode 100644 libnetwork/host_network_helper.c
create mode 100644 libnetwork/host_network_helper.h
diff --git a/libnetwork/dll_magic.h b/libnetwork/dll_magic.h
new file mode 100644
index 0000000..36bca83
--- /dev/null
+++ b/libnetwork/dll_magic.h
@@ -0,0 +1,13 @@
+#ifndef DLL_MAGIC_H
+#define DLL_MAGIC_H
+
+
+#if __GNUC__ >= 4
+ #ifdef DLL_BUILD
+ #define DLL_PUBLIC __attribute__ ((visibility ("default")))
+ #else
+ #define DLL_PUBLIC
+ #endif
+#endif
+
+#endif
diff --git a/libnetwork/host_network_error.h b/libnetwork/host_network_error.h
new file mode 100644
index 0000000..1882172
--- /dev/null
+++ b/libnetwork/host_network_error.h
@@ -0,0 +1,23 @@
+#ifndef HOST_NETWORK_ERROR_H
+#define HOST_NETWORK_ERROR_H
+
+#define ERR_REQUEST_NOT_SUPPORT -1
+
+#define ERR_LIBNETLINK -80
+#define ERR_LIBBR -90
+
+#define ERR_DEVICE_EXCEED_MAXNUM -100
+#define ERR_DEVICE_EXIST -101
+#define ERR_DEVICE_NOT_EXIST -102
+#define ERR_DEVICE_ALREADY_DONE -103
+#define ERR_DEVICE_CONNECT_OTHER -104
+
+#define ERR_FILE_OP_FAIL -125
+#define ERR_FILE_EMPTY -126
+#define ERR_FILE_TOO_LARGE -127
+#define ERR_FILE_CONT_TOO_LARGE -128
+#define ERR_FILE_LOCK_FAIL -129
+
+#define ERR_PERSIST_NOT_REDHAT -200
+
+#endif
diff --git a/libnetwork/host_network_helper.c b/libnetwork/host_network_helper.c
new file mode 100644
index 0000000..cda2732
--- /dev/null
+++ b/libnetwork/host_network_helper.c
@@ -0,0 +1,266 @@
+/*
+ * Copyright IBM Corp. 2012
+ *
+ * Authors:
+ * Wenchao Xia <xiawenc(a)cn.ibm.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+
+
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <linux/if.h>
+
+#include "host_network_helper.h"
+#include "host_network_error.h"
+
+static int compare_qos_8021q(const void *p1, const void *p2)
+{
+ const VLAN_Qos_8021q_elem *qos1 = (VLAN_Qos_8021q_elem *)p1;
+ const VLAN_Qos_8021q_elem *qos2 = (VLAN_Qos_8021q_elem *)p2;
+ int ret = 0;
+ if ((qos1->from) > (qos2->from)) {
+ ret = 1;
+ }
+ return ret;
+}
+
+/* it need to be checked see whether these are the conditions */
+int vlan_8021q_qos_check_valid(VLAN_Qos_8021q *pqos)
+{
+ int ret = 1;
+ int i = 0;
+ int last_num = -1;
+ if ((pqos->count < 0) || (pqos->count > 8)) {
+ ret = 0;
+ goto out;
+ } else if (pqos->count == 0) {
+ goto out;
+ }
+ qsort((void *)pqos->values, pqos->count, sizeof(VLAN_Qos_8021q_elem),
+ compare_qos_8021q);
+
+ while (i < pqos->count) {
+ if (pqos->values[i].from == last_num) {
+ CU_DEBUG("error: vlan 802.1.q qos setting have same <from> values: "
+ "last is %d, new is %d", last_num, pqos->values[i].from);
+ ret = 0;
+ goto out;
+ }
+ last_num = pqos->values[i].from;
+ if ((pqos->values[i].from < 0) || (pqos->values[i].from >= 8)) {
+ CU_DEBUG("error: vlan 802.1.q qos setting have outbound value: "
+ "from is %d.", pqos->values[i].from);
+ ret = 0;
+ goto out;
+ }
+ if ((pqos->values[i].to < 0) || (pqos->values[i].to >= 8)) {
+ CU_DEBUG("error: vlan 802.1.q qos setting have outbound value: "
+ "to is %d.", pqos->values[i].to);
+ ret = 0;
+ goto out;
+ }
+ i++;
+ }
+
+ out:
+ return ret;
+}
+
+int vlan_8021q_qos_str_to_num(VLAN_Qos_8021q *pqos, const char* str)
+{
+ int ret = 1;
+ char *str_line = NULL;
+ char *temp;
+ char *saveptr = NULL;
+ char *invalptr1, *invalptr2;
+ int qos_num1, qos_num2;
+ VLAN_Qos_8021q qos;
+
+ if (str == NULL) {
+ ret = 0;
+ goto out;
+ }
+ if (str[0] == '\0') {
+ ret = 1;
+ pqos->count = 0;
+ CU_DEBUG("empty vlan 802.1.q qos string found.");
+ goto out;
+ }
+ str_line = SAFE_STRDUP(str);
+ qos.count = 0;
+
+ temp = strtok_r(str_line, " ", &saveptr);
+ while (temp != NULL) {
+ qos_num1 = strtol(temp, &invalptr1, 10);
+ if (temp == invalptr1) {
+ ret = 0;
+ goto out;
+ }
+ if (*invalptr1 != ':') {
+ ret = 0;
+ goto out;
+ }
+ invalptr1++;
+ qos_num2 = strtol(invalptr1, &invalptr2, 10);
+ if (invalptr1 == invalptr2) {
+ ret = 0;
+ goto out;
+ }
+ if (*invalptr2 != '\0') {
+ ret = 0;
+ goto out;
+ }
+ if (qos.count >= 8) {
+ ret = 0;
+ CU_DEBUG("too many settings found in vlan 802.1.q qos string [%s]",
+ str);
+ goto out;
+ }
+ qos.values[qos.count].from = qos_num1;
+ qos.values[qos.count].to = qos_num2;
+ qos.count++;
+ temp = strtok_r(NULL, " ", &saveptr);
+ }
+ ret = vlan_8021q_qos_check_valid(&qos);
+ if (ret == 1) {
+ *pqos = qos;
+ }
+
+ out:
+ if (ret != 1) {
+ CU_DEBUG("vlan 802.1.q qos string [%s] is invalid.", str);
+ }
+ SAFE_FREE(str_line);
+ return ret;
+}
+
+int vlan_8021q_qos_num_to_str(char **str, const VLAN_Qos_8021q *pqos)
+{
+ char temp[16];
+ int i;
+ VLAN_Qos_8021q qos = *pqos;
+ int ret = vlan_8021q_qos_check_valid(&qos);
+ if (ret != 1) {
+ goto out;
+ }
+ SAFE_MALLOC(*str, 64);
+ *str[0] = '\0';
+ if (qos.count == 0) {
+ goto out;
+ }
+ i = 0;
+ snprintf(temp, sizeof(temp), "%d:%d",
+ qos.values[i].from, qos.values[i].to);
+ strcat(*str, temp);
+ i++;
+ while (i < qos.count) {
+ strcat(*str, " ");
+ snprintf(temp, sizeof(temp), "%d:%d",
+ qos.values[i].from, qos.values[i].to);
+ strcat(*str, temp);
+ i++;
+ }
+
+ out:
+ return ret;
+}
+
+char *combine_file_name(const char *prefix, const char *name)
+{
+ char *ret = NULL;
+ int size;
+ size = strlen(prefix) + strlen(name) + 1;
+ SAFE_CALLOC(ret, size, sizeof(char));
+ snprintf(ret, size, "%s%s", prefix, name);
+ return ret;
+}
+
+char *translate_error_no(int errno)
+{
+ char *ret = NULL;
+ switch (errno) {
+ case ERR_REQUEST_NOT_SUPPORT:
+ ret = "request is not supported now";
+ break;
+
+ case ERR_LIBNETLINK:
+ ret = "error happend in netlink.";
+ break;
+ case ERR_LIBBR:
+ ret = "error happend in bridge commands.";
+ break;
+
+ case ERR_DEVICE_EXCEED_MAXNUM:
+ ret = "too many devices found or set, check the environment.";
+ break;
+ case ERR_DEVICE_EXIST:
+ ret = "device already exist, can not execute the command.";
+ break;
+ case ERR_DEVICE_NOT_EXIST:
+ ret = "device do not exist, can not execute the command.";
+ break;
+ case ERR_DEVICE_ALREADY_DONE:
+ ret = "the operation you want have been done before, "
+ "will not do it again.";
+ break;
+ case ERR_DEVICE_CONNECT_OTHER:
+ ret = "the device you want to connect have been connect to another"
+ " device, can't change it directly.";
+ break;
+
+ case ERR_FILE_OP_FAIL:
+ ret = "failed in accessing the file.";
+ break;
+ case ERR_FILE_EMPTY:
+ ret = "the file it want is empty.";
+ break;
+ case ERR_FILE_TOO_LARGE:
+ ret = "the file it want is too large.";
+ break;
+ case ERR_FILE_CONT_TOO_LARGE:
+ ret = "the content it want to combine to file is too large.";
+ break;
+ case ERR_FILE_LOCK_FAIL:
+ ret = "failed in locking the file, "
+ "check if other process is using it.";
+ break;
+
+ case ERR_PERSIST_NOT_REDHAT:
+ ret = "host is not a RedHat distribution, can't persist the "
+ "configuration, it would not take effect after host is "
+ "rebooted. Other version would be supported in the future. "
+ "If you are sure host is RedHat, make sure command "
+ "<lsb_release -a> could work.";
+ break;
+
+ default:
+ ret = "internal error.";
+ break;
+ }
+ return ret;
+}
+
+int get_simple_state(struct EthIface *piface)
+{
+ if ((piface->eth_type & ETH_TYPE_ETHER_ANY) &&
+ (piface->eth_type & ETH_TYPE_ETHER_SUB_BRIDGE)) {
+ if (piface->run_prop.status == IF_OPER_UNKNOWN) {
+ return 1;
+ }
+ }
+ if (piface->run_prop.status == IF_OPER_UP) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
diff --git a/libnetwork/host_network_helper.h b/libnetwork/host_network_helper.h
new file mode 100644
index 0000000..fea4f05
--- /dev/null
+++ b/libnetwork/host_network_helper.h
@@ -0,0 +1,177 @@
+/*
+ * Copyright IBM Corp. 2012
+ *
+ * Authors:
+ * Wenchao Xia <xiawenc(a)cn.ibm.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+
+#ifndef HOST_NETWORK_HELPER_H
+#define HOST_NETWORK_HELPER_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+
+#include "dll_magic.h"
+#include "host_network_basic.h"
+
+#ifdef TESTLIB
+#include "TestDefines.h"
+#else
+#include <libcmpiutil/libcmpiutil.h>
+#endif
+
+#define CMD_DEBUG_LEVEL 2
+
+/* macro functions */
+#define CMD_DEBUG(lvl, fmt, args...) do { \
+ if (CMD_DEBUG_LEVEL && (lvl) <= CMD_DEBUG_LEVEL) { \
+ debug_print(fmt, ##args); \
+ } \
+} while (0)
+
+#define SAFE_MALLOC(p, size) \
+{ \
+ (p) = malloc((size)); \
+ if ((p) == NULL) { \
+ CU_DEBUG("malloc failed."); \
+ } \
+}
+
+#define SAFE_CALLOC(p, nmen, size) \
+{ \
+ (p) = calloc((nmen), (size)); \
+ if ((p) == NULL) { \
+ CU_DEBUG("calloc failed."); \
+ } \
+}
+
+#define SAFE_FREE(p) {free(p); (p) = NULL; }
+
+
+/* Macro used to compare two char*, it would skip if ref is NULL. It would
+ only set the result when src != ref, user need to set the result to 1 by
+ default before use the macro. If not set, the it could be used to do
+ check multi times in "one fail all die" mode. Empty lines is the place
+ where result should be set to 1. */
+#define CHARS_COMPARE_BY_REF(src, ref, result) do { \
+ if ((ref) == NULL) { \
+ ; \
+ } else { \
+ if ((src) == NULL) { \
+ (result) = 0; \
+ } else { \
+ if (0 == strcmp((src), (ref))) { \
+ ; \
+ } else { \
+ (result) = 0; \
+ } \
+ } \
+ } \
+} while (0)
+
+/* ignore case version */
+#define CHARS_COMPARE_CASE_BY_REF(src, ref, result) do { \
+ if ((ref) == NULL) { \
+ ; \
+ } else { \
+ if ((src) == NULL) { \
+ (result) = 0; \
+ } else { \
+ if (0 == strcasecmp((src), (ref))) { \
+ ; \
+ } else { \
+ (result) = 0; \
+ } \
+ } \
+ } \
+} while (0)
+
+/* compare the value if ref != default */
+#define NUM_COMPARE_BY_REF(src, ref, result, default) do { \
+ if ((ref) == (default)) { \
+ ; \
+ } else { \
+ if ((src) == (ref)) { \
+ ; \
+ } else { \
+ result = 0; \
+ } \
+ } \
+} while (0)
+
+/* merge the char* string to dest, only when dest == NULL */
+#define CHARS_MERGE_NORMAL(dest, src) do { \
+ if (((dest) == NULL) && ((src) != NULL)) { \
+ (dest) = strdup((src)); \
+ } \
+} while (0)
+
+/* merge the char* string to dest, only when dest == NULL,
+ pointer is moved instead of strdup */
+#define CHARS_MERGE_MOVE(dest, src) do { \
+ if (((dest) == NULL) && ((src) != NULL)) { \
+ (dest) = (src); \
+ (src) = NULL; \
+ } \
+} while (0)
+
+/* merge the value, only when dest == default */
+#define NUM_MERGE(dest, src, default) do { \
+ if ((dest) == (default)) { \
+ (dest) = (src); \
+ } \
+} while (0)
+
+/* this macro may cause "p" to be excuted twice if it is a function */
+#define SAFE_STRDUP(p) (p) == NULL ? NULL : strdup(p);
+
+/* this macro make sure "src" to be excuted once if it is function, so it is
+ safe for functions that have state logged, such as "strtok" */
+#define SAFE_STRDUP_WITH_FUNC(dest, src, iter) do { \
+ (iter) = (src); \
+ if ((iter) == NULL) { \
+ (dest) = NULL; \
+ } else { \
+ (dest) = strdup((iter)); \
+ } \
+} while (0)
+
+/* array version of SAFE_STRDUP, dest and src are char**. */
+#define SAFE_PSTR_ARRAY_DUP(ppdest, dest_num, ppsrc, src_num, iter) do { \
+ (dest_num) = (src_num); \
+ (ppdest) = NULL; \
+ if (((ppsrc) != NULL) && ((src_num) > 0)) { \
+ SAFE_CALLOC((ppdest), (src_num), sizeof(char *)); \
+ (iter) = 0; \
+ while ((iter) < (src_num)) { \
+ *((ppdest)+(iter)) = SAFE_STRDUP(*((ppsrc)+(iter))); \
+ (iter)++; \
+ } \
+ } \
+} while (0)
+
+/* this function would sort the pqos and check its values. */
+int vlan_8021q_qos_check_valid(VLAN_Qos_8021q *pqos);
+
+/* converting qos string of 802.1.Q, it should be as "0:0 1:0 2:0" */
+DLL_PUBLIC int vlan_8021q_qos_str_to_num(VLAN_Qos_8021q *pqos, const char *str);
+DLL_PUBLIC int vlan_8021q_qos_num_to_str(char **str, const VLAN_Qos_8021q *pqos);
+
+/* following functions would return string by malloc, so it need free later */
+char *combine_file_name(const char *prefix, const char *name);
+
+/* translate the iffstate to simple down or up, because orginal state is
+ complex for history reason in linux kernel */
+DLL_PUBLIC int get_simple_state(struct EthIface *piface);
+
+/* err message number to char* */
+char *translate_error_no(int errno);
+
+#endif
--
1.7.1
1
0
18 Jan '12
this patch have the structure defines and related functions, make program
in upper level easy to use.
Signed-off-by: Wenchao Xia <xiawenc(a)cn.ibm.com>
---
libnetwork/host_network_basic.c | 656 +++++++++++++++++++++++++++++++++++++++
libnetwork/host_network_basic.h | 158 ++++++++++
2 files changed, 814 insertions(+), 0 deletions(-)
create mode 100644 libnetwork/host_network_basic.c
create mode 100644 libnetwork/host_network_basic.h
diff --git a/libnetwork/host_network_basic.c b/libnetwork/host_network_basic.c
new file mode 100644
index 0000000..9260b33
--- /dev/null
+++ b/libnetwork/host_network_basic.c
@@ -0,0 +1,656 @@
+/*
+ * Copyright IBM Corp. 2012
+ *
+ * Authors:
+ * Wenchao Xia <xiawenc(a)cn.ibm.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+#include "host_network_basic.h"
+#include "host_network_helper.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+static void vlan_prop_print(VLAN_Prop *pvlan_prop)
+{
+ VLAN_Prop_8021q *p_8021q;
+ char *ingress = NULL, *egress = NULL;
+ CMD_DEBUG(1, "--VLAN props: type %d.\n",
+ pvlan_prop->vlan_type);
+ if (pvlan_prop->vlan_type == VLAN_TYPE_802_1_Q) {
+ p_8021q = &(pvlan_prop->props.prop_8021q);
+ vlan_8021q_qos_num_to_str(&ingress, &(p_8021q->ingress));
+ vlan_8021q_qos_num_to_str(&egress, &(p_8021q->egress));
+ CMD_DEBUG(1, "----IEEE802.1.Q: id %d, reorder %d, priority %d, "
+ "ingress %s, egress %s, parent %s.\n",
+ p_8021q->vlan_id, p_8021q->reorder_hdr, p_8021q->priv_flag,
+ ingress, egress, p_8021q->parent);
+ }
+ SAFE_FREE(ingress);
+ SAFE_FREE(egress);
+}
+
+static void br_prop_print(BR_Prop *pbr_prop)
+{
+ int i = 0;
+ CMD_DEBUG(1, "--Bridge props: id %s, stp %d, "
+ "bridge type %d, port_num %d.\n",
+ pbr_prop->bridge_id, pbr_prop->STP,
+ pbr_prop->type, pbr_prop->port_num);
+ if (pbr_prop->port_names != NULL) {
+ CMD_DEBUG(1, "----Ports attached: ");
+ while (i < pbr_prop->port_num) {
+ CMD_DEBUG(1, " %s,", *(pbr_prop->port_names+i));
+ i++;
+ }
+ CMD_DEBUG(1, "\n");
+ }
+}
+
+void eth_iface_print(EthIface *piface)
+{
+ CMD_DEBUG(1, "Iface device: name %s.\n"
+ "--Main Props: parent %s, attach to %s, mac %s,"
+ " RX %lld, TX %lld, status %d, iface type 0x%x.\n",
+ piface->name, piface->dep_ifname, piface->attach_bridge,
+ piface->mac,
+ piface->run_prop.rx_bytes, piface->run_prop.tx_bytes,
+ piface->run_prop.status, piface->eth_type);
+ if (piface->pbr_prop != NULL) {
+ br_prop_print(piface->pbr_prop);
+ }
+ if (piface->pvlan_prop != NULL) {
+ vlan_prop_print(piface->pvlan_prop);
+ }
+ return;
+}
+
+void eth_ifaceslist_print(EthIfacesList *plist)
+{
+ int i = 0;
+ CMD_DEBUG(1, "Have %d ifaces in the list:\n", plist->count);
+ while (i < plist->count) {
+ CMD_DEBUG(1, "%04d ", i);
+ eth_iface_print(plist->pifaces[i]);
+ i++;
+ }
+}
+
+void vlan_prop_init(VLAN_Prop *pvlan_prop, int vlan_type)
+{
+ VLAN_Prop_8021q *p_8021q;
+ memset(pvlan_prop, 0, sizeof(VLAN_Prop));
+ pvlan_prop->vlan_type = vlan_type;
+ if (pvlan_prop->vlan_type == VLAN_TYPE_802_1_Q) {
+ p_8021q = &(pvlan_prop->props.prop_8021q);
+ p_8021q->ingress.count = NUM_NOT_GOT;
+ p_8021q->egress.count = NUM_NOT_GOT;
+ p_8021q->vlan_id = NUM_NOT_GOT;
+ p_8021q->reorder_hdr = NUM_NOT_GOT;
+ p_8021q->priv_flag = NUM_NOT_GOT;
+ }
+}
+
+void br_prop_init(BR_Prop *pbr_prop)
+{
+ memset(pbr_prop, 0, sizeof(BR_Prop));
+ pbr_prop->STP = NUM_NOT_GOT;
+ pbr_prop->type = BR_TYPE_NOT_GOT;
+ pbr_prop->port_num = NUM_NOT_GOT;
+}
+
+void eth_iface_init(EthIface *piface)
+{
+ memset(piface, 0, sizeof(EthIface));
+ piface->eth_type = ETH_TYPE_NOT_GOT;
+ piface->run_prop.rx_bytes = NUM_NOT_GOT;
+ piface->run_prop.tx_bytes = NUM_NOT_GOT;
+ piface->run_prop.status = NUM_NOT_GOT;
+ return;
+}
+
+void eth_iface_add_br_prop(EthIface *piface)
+{
+ SAFE_MALLOC(piface->pbr_prop, sizeof(BR_Prop));
+ br_prop_init(piface->pbr_prop);
+}
+
+void eth_iface_add_vlan_prop(EthIface *piface, int vlan_type)
+{
+ SAFE_MALLOC(piface->pvlan_prop, sizeof(VLAN_Prop));
+ vlan_prop_init(piface->pvlan_prop, vlan_type);
+}
+
+void vlan_prop_uninit(VLAN_Prop *pvlan_prop)
+{
+ VLAN_Prop_8021q *p_8021q;
+ if (pvlan_prop == NULL) {
+ return;
+ }
+ if (pvlan_prop->vlan_type == VLAN_TYPE_802_1_Q) {
+ p_8021q = &(pvlan_prop->props.prop_8021q);
+ SAFE_FREE(p_8021q->parent);
+ }
+}
+
+void br_prop_uninit(BR_Prop *pbr_prop)
+{
+ int i;
+ if (pbr_prop == NULL) {
+ return;
+ }
+ SAFE_FREE(pbr_prop->bridge_id);
+ i = 0;
+ if (pbr_prop->port_names != NULL) {
+ while (i < pbr_prop->port_num) {
+ SAFE_FREE(pbr_prop->port_names[i]);
+ i++;
+ }
+ SAFE_FREE(pbr_prop->port_names);
+ }
+}
+
+void eth_iface_uninit(EthIface *piface)
+{
+ if (piface == NULL) {
+ return;
+ }
+ SAFE_FREE(piface->name);
+ SAFE_FREE(piface->dep_ifname);
+ SAFE_FREE(piface->attach_bridge);
+ SAFE_FREE(piface->mac);
+ br_prop_uninit(piface->pbr_prop);
+ SAFE_FREE(piface->pbr_prop);
+ vlan_prop_uninit(piface->pvlan_prop);
+ SAFE_FREE(piface->pvlan_prop);
+ return;
+}
+
+void eth_ifaces_clear(EthIface **ppifaces, int num)
+{
+ EthIface **t;
+ int i;
+ if (num <= 0) {
+ return;
+ }
+ t = ppifaces;
+ i = 0;
+ while (i < num) {
+ if (*t != NULL) {
+ eth_iface_uninit(*t);
+ SAFE_FREE(*t);
+ }
+ t++;
+ i++;
+ }
+ return;
+}
+
+void eth_ifaceslist_init(EthIfacesList *plist)
+{
+ plist->count = 0;
+}
+
+void eth_ifaceslist_uninit(EthIfacesList *plist)
+{
+ eth_ifaces_clear(plist->pifaces, plist->count);
+}
+
+int eth_ifaceslist_add(EthIfacesList *plist, EthIface *piface)
+{
+ if (plist->count >= MAX_IFACE_NUM) {
+ CU_DEBUG("too much device found.");
+ return 0;
+ }
+ SAFE_MALLOC(plist->pifaces[plist->count], sizeof(EthIface));
+ eth_iface_dup(plist->pifaces[plist->count], piface);
+ plist->count++;
+ return 1;
+}
+
+static void vlan_prop_dup(VLAN_Prop *dest, const VLAN_Prop *src)
+{
+ VLAN_Prop_8021q *pd_8021q;
+ const VLAN_Prop_8021q *ps_8021q;
+ dest->vlan_type = src->vlan_type;
+ if (dest->vlan_type == VLAN_TYPE_802_1_Q) {
+ pd_8021q = &(dest->props.prop_8021q);
+ ps_8021q = &(src->props.prop_8021q);
+ pd_8021q->vlan_id = ps_8021q->vlan_id;
+ pd_8021q->reorder_hdr = ps_8021q->reorder_hdr;
+ pd_8021q->priv_flag = ps_8021q->priv_flag;
+ pd_8021q->ingress = ps_8021q->ingress;
+ pd_8021q->egress = ps_8021q->egress;
+ pd_8021q->parent = SAFE_STRDUP(ps_8021q->parent);
+ }
+}
+
+static void br_prop_dup(BR_Prop *dest, const BR_Prop *src)
+{
+ int i;
+ dest->bridge_id = SAFE_STRDUP(src->bridge_id);
+ dest->STP = src->STP;
+ dest->type = src->type;
+ SAFE_PSTR_ARRAY_DUP(dest->port_names, dest->port_num,
+ src->port_names, src->port_num, i);
+}
+
+void eth_iface_dup(EthIface *dest, const EthIface *src)
+{
+ dest->name = SAFE_STRDUP(src->name);
+ dest->dep_ifname = SAFE_STRDUP(src->dep_ifname);
+ dest->attach_bridge = SAFE_STRDUP(src->attach_bridge);
+ dest->mac = SAFE_STRDUP(src->mac);
+ dest->eth_type = src->eth_type;
+ dest->run_prop.rx_bytes = src->run_prop.rx_bytes;
+ dest->run_prop.tx_bytes = src->run_prop.tx_bytes;
+ dest->run_prop.status = src->run_prop.status;
+
+ if (src->pbr_prop != NULL) {
+ SAFE_MALLOC(dest->pbr_prop, sizeof(BR_Prop));
+ /* doesn't need init it for that it would be copied at once */
+ br_prop_dup(dest->pbr_prop, src->pbr_prop);
+ } else {
+ dest->pbr_prop = NULL;
+ }
+
+ if (src->pvlan_prop != NULL) {
+ SAFE_MALLOC(dest->pvlan_prop, sizeof(VLAN_Prop));
+ /* doesn't need init it for that it would be copied at once */
+ vlan_prop_dup(dest->pvlan_prop, src->pvlan_prop);
+ } else {
+ dest->pvlan_prop = NULL;
+ }
+
+}
+
+int eth_iface_compare(const EthIface *p1, const EthIface *p2)
+{
+ int ret = 0;
+ if ((p1->name != NULL) || (p2->name != NULL)) {
+ if (0 == strcmp(p1->name, p2->name)) {
+ ret = 1;
+ }
+ }
+ return ret;
+}
+
+static void vlan_prop_merge(VLAN_Prop *pdest, VLAN_Prop *psrc, int style)
+{
+ VLAN_Prop_8021q *pd_8021q, *ps_8021q;
+
+ NUM_MERGE(pdest->vlan_type, psrc->vlan_type, VLAN_TYPE_NOT_GOT);
+
+ if (psrc->vlan_type == VLAN_TYPE_802_1_Q) {
+ pd_8021q = &(pdest->props.prop_8021q);
+ ps_8021q = &(psrc->props.prop_8021q);
+ NUM_MERGE(pd_8021q->vlan_id, ps_8021q->vlan_id, NUM_NOT_GOT);
+ NUM_MERGE(pd_8021q->reorder_hdr, ps_8021q->reorder_hdr, NUM_NOT_GOT);
+ NUM_MERGE(pd_8021q->priv_flag, ps_8021q->priv_flag, NUM_NOT_GOT);
+ if (pd_8021q->ingress.count == NUM_NOT_GOT) {
+ pd_8021q->ingress = ps_8021q->ingress;
+ }
+ if (pd_8021q->egress.count == NUM_NOT_GOT) {
+ pd_8021q->egress = ps_8021q->egress;
+ }
+ if (style == 0) {
+ CHARS_MERGE_NORMAL(pd_8021q->parent, ps_8021q->parent);
+ } else {
+ CHARS_MERGE_MOVE(pd_8021q->parent, ps_8021q->parent);
+ }
+ }
+}
+
+static void br_prop_merge(BR_Prop *pdest, BR_Prop *psrc, int style)
+{
+ int i;
+
+ if (style == 0) {
+ CHARS_MERGE_NORMAL(pdest->bridge_id, psrc->bridge_id);
+ /*merge it when dest have not been set */
+ if (pdest->port_names == NULL) {
+ SAFE_PSTR_ARRAY_DUP(pdest->port_names, pdest->port_num,
+ psrc->port_names, psrc->port_num, i);
+ }
+ } else {
+ CHARS_MERGE_MOVE(pdest->bridge_id, psrc->bridge_id);
+ /*merge it when dest have not been set */
+ if (pdest->port_names == NULL) {
+ pdest->port_names = psrc->port_names;
+ pdest->port_num = psrc->port_num;
+ psrc->port_names = NULL;
+ psrc->port_num = NUM_NOT_GOT;
+ }
+ }
+ NUM_MERGE(pdest->STP, psrc->STP, NUM_NOT_GOT);
+ NUM_MERGE(pdest->type, psrc->type, BR_TYPE_NOT_GOT);
+}
+
+void eth_iface_merge(EthIface *dest, EthIface *src, int style)
+{
+ if (style == 0) {
+ CHARS_MERGE_NORMAL(dest->name, src->name);
+ CHARS_MERGE_NORMAL(dest->dep_ifname, src->dep_ifname);
+ CHARS_MERGE_NORMAL(dest->attach_bridge, src->attach_bridge);
+ CHARS_MERGE_NORMAL(dest->mac, src->mac);
+ } else {
+ CHARS_MERGE_MOVE(dest->name, src->name);
+ CHARS_MERGE_MOVE(dest->dep_ifname, src->dep_ifname);
+ CHARS_MERGE_MOVE(dest->attach_bridge, src->attach_bridge);
+ CHARS_MERGE_MOVE(dest->mac, src->mac);
+ }
+
+ /* special case for eth_type*/
+ if (dest->eth_type == ETH_TYPE_NOT_GOT) {
+ dest->eth_type = src->eth_type;
+ } else {
+ if ((src->eth_type & ETH_TYPE_ETHER_ANY) &&
+ (dest->eth_type & ETH_TYPE_ETHER_ANY)) {
+ dest->eth_type |= (src->eth_type & ETH_TYPE_SUB_MASK);
+ }
+ }
+
+ NUM_MERGE(dest->run_prop.rx_bytes, src->run_prop.rx_bytes,
+ NUM_NOT_GOT);
+ NUM_MERGE(dest->run_prop.tx_bytes, src->run_prop.tx_bytes,
+ NUM_NOT_GOT);
+ NUM_MERGE(dest->run_prop.status, src->run_prop.status, NUM_NOT_GOT);
+
+ if (src->pbr_prop != NULL) {
+ if (dest->pbr_prop == NULL) {
+ SAFE_MALLOC(dest->pbr_prop, sizeof(BR_Prop));
+ br_prop_init(dest->pbr_prop);
+ }
+ br_prop_merge(dest->pbr_prop, src->pbr_prop, style);
+ }
+
+ if (src->pvlan_prop != NULL) {
+ if (dest->pvlan_prop == NULL) {
+ SAFE_MALLOC(dest->pvlan_prop, sizeof(VLAN_Prop));
+ vlan_prop_init(dest->pvlan_prop, src->pvlan_prop->vlan_type);
+ }
+ vlan_prop_merge(dest->pvlan_prop, src->pvlan_prop, style);
+ }
+
+}
+
+/* compare qos values */
+static int VLAN_Qos_8021q_compare_by_ref(const VLAN_Qos_8021q *pqos,
+ const VLAN_Qos_8021q *pref)
+{
+ int ret = 1;
+ int i, j;
+ if (pref->count == NUM_NOT_GOT) {
+ /* do not need to compare*/
+ goto out;
+ }
+ if ((pref->count < 0) || (pref->count > 8)) {
+ ret = 0;
+ goto out;
+ }
+ if ((pqos->count < 0) || (pqos->count > 8)) {
+ ret = 0;
+ goto out;
+ }
+
+ i = 0;
+ while (i < pref->count) {
+ j = 0;
+ while (j < pqos->count) {
+ if (pref->values[i].from == pqos->values[j].from) {
+ if (pref->values[i].to != pqos->values[j].to) {
+ ret = 0;
+ goto out;
+ }
+ break;
+ }
+ j++;
+ }
+ if (j == pqos->count) {
+ ret = 0;
+ goto out;
+ }
+ i++;
+ }
+
+ out:
+ return ret;
+}
+
+static int vlan_prop_filter_by_ref(const VLAN_Prop *pvlan_prop, void *pref)
+{
+ int compare_result = 1;
+ VLAN_Prop *ref = (VLAN_Prop *)pref;
+ char *p1, *p2;
+ const VLAN_Prop_8021q *pd_8021q;
+ VLAN_Prop_8021q *pref_8021q;
+
+ NUM_COMPARE_BY_REF(pvlan_prop->vlan_type, ref->vlan_type,
+ compare_result, VLAN_TYPE_NOT_GOT);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ if (ref->vlan_type == VLAN_TYPE_802_1_Q) {
+ pd_8021q = &(pvlan_prop->props.prop_8021q);
+ pref_8021q = &(ref->props.prop_8021q);
+
+ NUM_COMPARE_BY_REF(pd_8021q->vlan_id, pref_8021q->vlan_id,
+ compare_result, NUM_NOT_GOT);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ NUM_COMPARE_BY_REF(pd_8021q->reorder_hdr, pref_8021q->reorder_hdr,
+ compare_result, NUM_NOT_GOT);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ NUM_COMPARE_BY_REF(pd_8021q->priv_flag, pref_8021q->priv_flag,
+ compare_result, NUM_NOT_GOT);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ compare_result = VLAN_Qos_8021q_compare_by_ref(&(pd_8021q->ingress),
+ &(pref_8021q->ingress));
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ compare_result = VLAN_Qos_8021q_compare_by_ref(&(pd_8021q->egress),
+ &(pref_8021q->egress));
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ p1 = pd_8021q->parent;
+ p2 = pref_8021q->parent;
+ CHARS_COMPARE_BY_REF(p1, p2, compare_result);
+ if (compare_result == 0) {
+ goto out;
+ }
+ }
+
+ out:
+ return compare_result;
+
+}
+
+static int br_prop_filter_by_ref(const BR_Prop *pbr_prop, void *pref)
+{
+ int compare_result = 1;
+ BR_Prop *ref = (BR_Prop *)pref;
+ char *p1, *p2;
+
+ p1 = pbr_prop->bridge_id;
+ p2 = ref->bridge_id;
+ CHARS_COMPARE_BY_REF(p1, p2, compare_result);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ NUM_COMPARE_BY_REF(pbr_prop->STP, ref->STP,
+ compare_result, NUM_NOT_GOT);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ NUM_COMPARE_BY_REF(pbr_prop->type, ref->type,
+ compare_result, BR_TYPE_NOT_GOT);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ NUM_COMPARE_BY_REF(pbr_prop->port_num, ref->port_num,
+ compare_result, NUM_NOT_GOT);
+ /* skip the comparation of ports it attached, user can define
+ a special filter for that */
+ out:
+ return compare_result;
+}
+
+int eth_iface_filter_by_ref(const EthIface *piface, void *pref)
+{
+ int compare_result = 1;
+ EthIface *ref = (EthIface *)pref;
+ char *p1, *p2;
+
+ p1 = piface->name;
+ p2 = ref->name;
+ CHARS_COMPARE_BY_REF(p1, p2, compare_result);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ p1 = piface->dep_ifname;
+ p2 = ref->dep_ifname;
+ CHARS_COMPARE_BY_REF(p1, p2, compare_result);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ p1 = piface->attach_bridge;
+ p2 = ref->attach_bridge;
+ CHARS_COMPARE_BY_REF(p1, p2, compare_result);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ p1 = piface->mac;
+ p2 = ref->mac;
+ CHARS_COMPARE_CASE_BY_REF(p1, p2, compare_result);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ /* special case for eth_type */
+ NUM_COMPARE_BY_REF((piface->eth_type & ETH_TYPE_BASE_MASK),
+ (ref->eth_type & ETH_TYPE_BASE_MASK),
+ compare_result, ETH_TYPE_NOT_GOT);
+ if (compare_result == 0) {
+ goto out;
+ }
+ NUM_COMPARE_BY_REF((piface->eth_type & ETH_TYPE_SUB_MASK),
+ (ref->eth_type & ETH_TYPE_SUB_MASK),
+ compare_result, ETH_TYPE_NOT_GOT);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ NUM_COMPARE_BY_REF(piface->run_prop.status, ref->run_prop.status,
+ compare_result, NUM_NOT_GOT);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ if (ref->pbr_prop != NULL) {
+ if (piface->pbr_prop != NULL) {
+ compare_result = br_prop_filter_by_ref(piface->pbr_prop,
+ ref->pbr_prop);
+ } else {
+ compare_result = 0;
+ }
+ if (compare_result == 0) {
+ goto out;
+ }
+ }
+
+ if (ref->pvlan_prop != NULL) {
+ if (piface->pvlan_prop != NULL) {
+ compare_result = vlan_prop_filter_by_ref(piface->pvlan_prop,
+ ref->pvlan_prop);
+
+ } else {
+ compare_result = 0;
+ }
+ if (compare_result == 0) {
+ goto out;
+ }
+ }
+
+ out:
+ return compare_result;
+}
+
+int eth_iface_filter_by_refname(const EthIface *piface, void *pref)
+{
+ int compare_result = 1;
+ EthIface *ref = (EthIface *)pref;
+ char *p1, *p2;
+
+ p1 = piface->name;
+ p2 = ref->name;
+ CHARS_COMPARE_BY_REF(p1, p2, compare_result);
+ if (compare_result == 0) {
+ goto out;
+ }
+
+ out:
+ return compare_result;
+}
+
+int eth_iface_filter_vlans(const EthIface *piface, void *nouse)
+{
+ if (piface->name == NULL) {
+ return 0;
+ }
+ if (NULL == strstr(piface->name, ".")) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+/* the judgement condition is weak, but I can't find a better way */
+int eth_iface_filter_peths(const EthIface *piface, void *nouse)
+{
+ if (!(piface->eth_type & ETH_TYPE_ETHER_ANY)) {
+ return 0;
+ }
+ if (piface->eth_type & ETH_TYPE_ETHER_SUB_BRIDGE) {
+ return 0;
+ }
+ if (piface->eth_type & ETH_TYPE_ETHER_SUB_VLAN) {
+ return 0;
+ }
+ if (piface->dep_ifname != NULL) {
+ return 0;
+ }
+ if (NULL != strstr(piface->name, ".")) {
+ return 0;
+ }
+ /* this filter NetUSB etc */
+ if (NULL == strstr(piface->name, "eth")) {
+ return 0;
+ }
+
+ return 1;
+}
diff --git a/libnetwork/host_network_basic.h b/libnetwork/host_network_basic.h
new file mode 100644
index 0000000..f782e51
--- /dev/null
+++ b/libnetwork/host_network_basic.h
@@ -0,0 +1,158 @@
+/*
+ * Copyright IBM Corp. 2012
+ *
+ * Authors:
+ * Wenchao Xia <xiawenc(a)cn.ibm.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+#ifndef NETWORK_BASIC_HOST_H
+#define NETWORK_BASIC_HOST_H
+
+#include "dll_magic.h"
+
+/* value defines */
+#define MAX_IFACE_NUM 4096
+
+#define NUM_NOT_GOT -1
+
+#define ETH_TYPE_BASE_MASK 0xff00
+#define ETH_TYPE_SUB_MASK 0x00ff
+typedef enum {
+ ETH_TYPE_NOT_GOT = 0x0000,
+ ETH_TYPE_UNKNOWN = 0x0100,
+ ETH_TYPE_OTHER = 0x0200,
+ ETH_TYPE_ETHER_ANY = 0x0400,
+ ETH_TYPE_ETHER_SUB_PHYSICAL = 0x0001,
+ ETH_TYPE_ETHER_SUB_BRIDGE = 0x0002,
+ ETH_TYPE_ETHER_SUB_VLAN = 0x0004
+} EthType;
+
+typedef enum {
+ BR_TYPE_NOT_GOT = NUM_NOT_GOT,
+ BR_TYPE_UNKNOWN = 0,
+ BR_TYPE_SWITCH = 1,
+ BR_TYPE_NAT = 2
+} BrType;
+
+typedef enum {
+ VLAN_TYPE_NOT_GOT = NUM_NOT_GOT,
+ VLAN_TYPE_802_1_Q = 1,
+ VLAN_TYPE_802_1_QBG = 2,
+ VLAN_TYPE_802_1_QBH = 4
+} VLANType;
+
+typedef struct BR_Prop {
+ char *bridge_id;
+ int STP;
+ BrType type;
+ char **port_names;
+ int port_num;
+} BR_Prop;
+
+/* status use RFC 2863 operational status */
+typedef struct Run_Prop {
+ long long rx_bytes;
+ long long tx_bytes;
+ int status;
+} Run_Prop;
+
+typedef struct VLAN_Qos_8021q_elem {
+ int from;
+ int to;
+} VLAN_Qos_8021q_elem;
+
+typedef struct VLAN_Qos_8021q {
+ VLAN_Qos_8021q_elem values[8];
+ int count;
+} VLAN_Qos_8021q;
+
+typedef struct VLAN_Prop_8021q {
+ int vlan_id;
+ int reorder_hdr;
+ int priv_flag;
+ VLAN_Qos_8021q ingress;
+ VLAN_Qos_8021q egress;
+ char *parent;
+} VLAN_Prop_8021q;
+
+/* HP vlan standard, TBD */
+typedef struct VLAN_Prop_8021qbg {
+ int invalid;
+} VLAN_Prop_8021qbg;
+
+/* Cisco and VMware vlan standard, TBD */
+typedef struct VLAN_Prop_8021qbh {
+ int invalid;
+} VLAN_Prop_8021qbh;
+
+typedef struct VLAN_Prop {
+ int vlan_type;
+ union {
+ VLAN_Prop_8021q prop_8021q;
+ VLAN_Prop_8021qbg prop_8021qbg;
+ VLAN_Prop_8021qbh prop_8021qbh;
+ } props;
+} VLAN_Prop;
+
+/* EthIface is logical devices include eth ports and bridges */
+typedef struct EthIface {
+ char *name;
+ char *dep_ifname; /* parent dev name */
+ char *attach_bridge; /* bridge the iface is attached to */
+ char *mac;
+ EthType eth_type;
+ Run_Prop run_prop;
+ /* optional properties */
+ BR_Prop *pbr_prop;
+ VLAN_Prop *pvlan_prop;
+} EthIface;
+
+typedef struct EthIfacesList {
+ EthIface *pifaces[MAX_IFACE_NUM];
+ int count;
+} EthIfacesList;
+
+typedef int (*eth_iface_filter_func)(const EthIface *piface, void *opaque);
+
+/* uninit functions are only called when there is resource malloc */
+DLL_PUBLIC void vlan_prop_init(VLAN_Prop *pvlan_prop, int vlan_type);
+DLL_PUBLIC void vlan_prop_uninit(VLAN_Prop *pvlan_prop);
+
+DLL_PUBLIC void br_prop_init(BR_Prop *pbr_prop);
+DLL_PUBLIC void br_prop_uninit(BR_Prop *pbr_prop);
+
+DLL_PUBLIC void eth_iface_print(EthIface *piface);
+DLL_PUBLIC void eth_iface_init(EthIface *piface);
+DLL_PUBLIC void eth_iface_add_br_prop(EthIface *piface);
+DLL_PUBLIC void eth_iface_add_vlan_prop(EthIface *piface, int vlan_type);
+DLL_PUBLIC void eth_iface_uninit(EthIface *piface);
+DLL_PUBLIC void eth_ifaces_clear(EthIface **ppifaces, int num);
+
+DLL_PUBLIC void eth_ifaceslist_init(EthIfacesList *plist);
+DLL_PUBLIC void eth_ifaceslist_uninit(EthIfacesList *plist);
+DLL_PUBLIC void eth_ifaceslist_print(EthIfacesList *plist);
+DLL_PUBLIC int eth_ifaceslist_add(EthIfacesList *plist, EthIface *piface);
+
+/* this function assume dest have been uninited if it was used before*/
+DLL_PUBLIC void eth_iface_dup(EthIface *dest, const EthIface *src);
+
+/* see if it is refered to the same device */
+DLL_PUBLIC int eth_iface_compare(const EthIface *p1, const EthIface *p2);
+
+/* merge the properties that dest do not have value set, if style is set to 1,
+ the char* properties was moved instead of copy, safely reduce the memory
+ fragments, but src is modified. */
+DLL_PUBLIC void eth_iface_merge(EthIface *dest, EthIface *src, int style);
+
+DLL_PUBLIC int eth_iface_filter_by_ref(const EthIface *piface, void *pref);
+DLL_PUBLIC int eth_iface_filter_by_refname(const EthIface *piface, void *pref);
+DLL_PUBLIC int eth_iface_filter_vlans(const EthIface *piface, void *nouse);
+DLL_PUBLIC int eth_iface_filter_peths(const EthIface *piface, void *nouse);
+
+
+#endif
--
1.7.1
1
0
This patch use libnl-1.1 and ioctl bridge functions in patch 3.
Signed-off-by: Wenchao Xia <xiawenc(a)cn.ibm.com>
---
libnetwork/host_network_implement_OSAPI.c | 366 +++++++++++++++++++++++++++++
libnetwork/host_network_implement_OSAPI.h | 21 ++
2 files changed, 387 insertions(+), 0 deletions(-)
create mode 100644 libnetwork/host_network_implement_OSAPI.c
create mode 100644 libnetwork/host_network_implement_OSAPI.h
diff --git a/libnetwork/host_network_implement_OSAPI.c b/libnetwork/host_network_implement_OSAPI.c
new file mode 100644
index 0000000..2efcf37
--- /dev/null
+++ b/libnetwork/host_network_implement_OSAPI.c
@@ -0,0 +1,366 @@
+/*
+ * Copyright IBM Corp. 2012
+ *
+ * Authors:
+ * Wenchao Xia <xiawenc(a)cn.ibm.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <net/if_arp.h>
+#include <linux/if_vlan.h>
+
+#include <netlink/netlink.h>
+#include <netlink/socket.h>
+#include <netlink/list.h>
+#include <netlink/object.h>
+#include <netlink/object-api.h>
+#include <netlink/route/link.h>
+#include <netlink/route/link/vlan.h>
+#include <netlink/route/link/info-api.h>
+
+#include "host_network_implement_bridge.h"
+#include "host_network_implement_OSAPI.h"
+#include "host_network_helper.h"
+#include "host_network_error.h"
+
+/* macro defines */
+#define LN_PRINT_LEVEL 4
+
+struct nl_add2list_param {
+ EthIfacesList *plist;
+ struct nl_cache *cache;
+} ;
+
+/* libnl1 lackes a way to see if it is vlan8021q, added an implemention here*/
+static int rtnl_link_is_vlan(struct rtnl_link *link)
+{
+ char* type = rtnl_link_get_info_type(link);
+ if (type == NULL) {
+ return 0;
+ }
+ return !strcmp(type, "vlan");
+}
+
+/* the bridge seems have 0 value when it is up , so adjust the value,
+ and found out which are physical cards */
+static int host_iface_adjust(EthIface *piface)
+{
+ if (1 == eth_iface_filter_peths(piface, NULL)) {
+ piface->eth_type |= (ETH_TYPE_ETHER_ANY | ETH_TYPE_ETHER_SUB_PHYSICAL);
+ }
+ return 1;
+}
+
+static void find_iface_attached_bridge(EthIfacesList *peth_list, EthIface *pbr)
+{
+ int i, j;
+ char *name_on_br, *name_iface;
+ if (pbr->pbr_prop == NULL) {
+ return;
+ }
+ i = 0;
+ while (i < pbr->pbr_prop->port_num) {
+ name_on_br = pbr->pbr_prop->port_names[i];
+ j = 0;
+ while (j < peth_list->count) {
+ name_iface = peth_list->pifaces[j]->name;
+ if (0 == strcmp(name_on_br, name_iface)) {
+ if (peth_list->pifaces[j]->attach_bridge == NULL) {
+ peth_list->pifaces[j]->attach_bridge =
+ SAFE_STRDUP(pbr->name);
+ }
+ break;
+ }
+ j++;
+ }
+ i++;
+ }
+}
+
+/* assuming that one peth would be attached to at most 1 bridge */
+static void merge_eth_list_for_bridge(EthIfacesList *peth_list,
+ EthIfacesList *pbr_list,
+ int flag)
+{
+ int i, j;
+ i = 0;
+ while (i < pbr_list->count) {
+ find_iface_attached_bridge(peth_list, pbr_list->pifaces[i]);
+ j = 0;
+ while (j < peth_list->count) {
+ if (1 == eth_iface_compare(peth_list->pifaces[j],
+ pbr_list->pifaces[i])) {
+ /* found the matched device, merge them */
+ eth_iface_merge(peth_list->pifaces[j],
+ pbr_list->pifaces[i], flag);
+ break;
+ }
+ j++;
+ }
+ i++;
+ }
+ return;
+}
+
+static void ln_link_print(struct rtnl_link *link)
+{
+ char *name, *qdisk, *type = NULL;
+ const char *ifalias = NULL;
+ int ifindex, flags, mtu, txqlen, family, arptype, getlink, master, operstate, linkmode;
+ uint32_t num_vf = 0;
+ int ret, i;
+ int vlanid, vlanflag, egress_num = 0;
+ uint32_t *ingress_map;
+ struct vlan_map *egress_map;
+
+ qdisk = rtnl_link_get_qdisc(link);
+ name = rtnl_link_get_name(link);
+ flags = rtnl_link_get_flags(link);
+ mtu = rtnl_link_get_mtu(link);
+ txqlen = rtnl_link_get_txqlen(link);
+ ifindex = rtnl_link_get_ifindex(link);
+ family = rtnl_link_get_family(link);
+ arptype = rtnl_link_get_arptype(link);
+ getlink = rtnl_link_get_link(link);
+ master = rtnl_link_get_master(link);
+ operstate = rtnl_link_get_operstate(link);
+ linkmode = rtnl_link_get_linkmode(link);
+
+ CMD_DEBUG(1, "link name %s, alias %s, qdisk %s, type %s,\n"
+ "--ifindex 0x%x, flags 0x%x, mtu 0x%x, txqlen 0x%x, family 0x%x, arptype 0x%x,\n"
+ "--getlink 0x%x, master 0x%x, operstate 0x%x, linkmode 0x%x, vf_ret %d with num_vf 0x%x.\n",
+ name, ifalias, qdisk, type,
+ ifindex, flags, mtu, txqlen, family, arptype,
+ getlink, master, operstate, linkmode, ret, num_vf);
+
+ if (rtnl_link_is_vlan(link)) {
+ vlanid = rtnl_link_vlan_get_id(link);
+ vlanflag = rtnl_link_vlan_get_flags(link);
+ ingress_map = rtnl_link_vlan_get_ingress_map(link);
+ egress_map = rtnl_link_vlan_get_egress_map(link, &egress_num);
+ CMD_DEBUG(1, "--vlan properties:\n"
+ "----id %d, vlanflag 0x%x.",
+ vlanid, vlanflag);
+ CMD_DEBUG(1, "\n----ingress: ");
+ if (ingress_map != NULL) {
+ for (i = 0; i <= VLAN_PRIO_MAX; i++) {
+ CMD_DEBUG(1, "0x%x, ", ingress_map[i]);
+ }
+ }
+ CMD_DEBUG(1, "\n----egress: ");
+ if (egress_map != NULL) {
+ i = 0;
+ while (i < egress_num) {
+ CMD_DEBUG(1, "[%d %d], ", egress_map[i].vm_from, egress_map[i].vm_to);
+ i++;
+ }
+ }
+ CMD_DEBUG(1, "\n");
+ }
+}
+
+static void nl_add2list_func(struct nl_object *obj, void *opaque)
+{
+ struct rtnl_link *link;
+ struct nl_cache *cache;
+ struct rtnl_link *ll;
+ struct nl_addr *addr;
+ uint32_t *ingress_map;
+ int egress_num = 0, opstate;
+ struct vlan_map *egress_map;
+ EthIfacesList *plist;
+ EthIface tface;
+ VLAN_Prop_8021q *pprop_8021q;
+ char buf[128];
+ int t, i;
+
+ struct nl_add2list_param *pparam = (struct nl_add2list_param *)opaque;
+ plist = pparam->plist;
+ cache = pparam->cache;
+ link = (struct rtnl_link *)obj;
+
+ if (CMD_DEBUG_LEVEL && (LN_PRINT_LEVEL) <= CMD_DEBUG_LEVEL) {
+ ln_link_print(link);
+ }
+
+ /* get properties */
+ eth_iface_init(&tface);
+
+ /* get name */
+ tface.name = SAFE_STRDUP(rtnl_link_get_name(link));
+
+ /* get parent */
+ t = rtnl_link_get_link(link);
+ if (t > 0) {
+ ll = rtnl_link_get(cache, t);
+ if (ll == NULL) {
+ CU_DEBUG("failed to find interface with index %d.", t);
+ goto out;
+ }
+ tface.dep_ifname = SAFE_STRDUP(rtnl_link_get_name(ll));
+ rtnl_link_put(ll);
+ }
+
+ /* get mac */
+ addr =rtnl_link_get_addr(link);
+ if (addr && !nl_addr_iszero(addr)) {
+ nl_addr2str(addr, buf, sizeof(buf));
+ tface.mac = SAFE_STRDUP(buf);
+ }
+
+ /* get main type */
+ t = rtnl_link_get_arptype(link);
+ if (t == ARPHRD_ETHER) {
+ tface.eth_type = ETH_TYPE_ETHER_ANY;
+ } else {
+ tface.eth_type = ETH_TYPE_OTHER;
+ }
+
+ tface.run_prop.status = rtnl_link_get_operstate(link);
+
+ /* get vlan */
+ if (rtnl_link_is_vlan(link)) {
+ SAFE_MALLOC(tface.pvlan_prop, sizeof(VLAN_Prop));
+ vlan_prop_init(tface.pvlan_prop, VLAN_TYPE_802_1_Q);
+ pprop_8021q = &(tface.pvlan_prop->props.prop_8021q);
+ tface.eth_type |= ETH_TYPE_ETHER_SUB_VLAN;
+ pprop_8021q->vlan_id = rtnl_link_vlan_get_id(link);
+ pprop_8021q->reorder_hdr = (rtnl_link_vlan_get_flags(link) &
+ VLAN_FLAG_REORDER_HDR);
+ /* at any time parent of vlan8021.q is just what it depends on */
+ pprop_8021q->parent = SAFE_STRDUP(tface.dep_ifname);
+ ingress_map = rtnl_link_vlan_get_ingress_map(link);
+ egress_map = rtnl_link_vlan_get_egress_map(link, &egress_num);
+ if (ingress_map != NULL) {
+ for (i = 0; i <= VLAN_PRIO_MAX; i++) {
+ pprop_8021q->ingress.values[i].from = i;
+ pprop_8021q->ingress.values[i].to = ingress_map[i];
+ }
+ pprop_8021q->ingress.count = VLAN_PRIO_MAX;
+ i = 0;
+ while (i < egress_num) {
+ pprop_8021q->egress.values[i].from = egress_map[i].vm_from;
+ pprop_8021q->egress.values[i].to = egress_map[i].vm_to;
+ i++;
+ }
+ pprop_8021q->egress.count = egress_num;
+ }
+ }
+
+ /* put result to list */
+ if (1 != eth_ifaceslist_add(plist, &tface)) {
+ CU_DEBUG("failed to add device to list.");
+ goto out;
+ }
+
+ out:
+ eth_iface_uninit(&tface);
+}
+
+static int get_host_eth_ifaces_osapi_netlink(EthIfacesList *plist)
+{
+ struct nl_handle *nlh = NULL;
+ struct nl_cache *cache = NULL;
+ int ret, rtnl_ret;
+ struct nl_add2list_param param;
+
+ nlh = nl_handle_alloc();
+ if (nlh == NULL) {
+ CU_DEBUG("unable to allocate nl handle.");
+ ret = ERR_LIBNETLINK;
+ }
+ rtnl_ret = nl_connect(nlh, NETLINK_ROUTE);
+ if (rtnl_ret < 0) {
+ CU_DEBUG("error in connect to kernel, return %d, err %s.\n",
+ rtnl_ret, nl_geterror());
+ ret = ERR_LIBNETLINK;
+ }
+
+ cache = rtnl_link_alloc_cache(nlh);
+ if (cache == NULL) {
+ CU_DEBUG("error in talking to kernel.\n");
+ ret = ERR_LIBNETLINK;
+ }
+
+ param.plist = plist;
+ param.cache = cache;
+ nl_cache_foreach(cache, nl_add2list_func, ¶m);
+ if (plist->count >= MAX_IFACE_NUM) {
+ CU_DEBUG("too much device found.");
+ ret = ERR_DEVICE_EXCEED_MAXNUM;
+ goto out;
+ }
+
+ ret = 1;
+
+ out:
+ nl_cache_free(cache);
+ nl_close(nlh);
+ nl_handle_destroy(nlh);
+
+ return ret;
+}
+
+int get_host_eth_ifaces_osapi(EthIfacesList *plist,
+ eth_iface_filter_func filter_func, void *filter_opaque)
+{
+ int retvalue;
+ EthIfacesList *ifaces1, *ifaces2;
+ int i;
+ int filter_ret;
+ int count = 0;
+ SAFE_MALLOC(ifaces1, sizeof(EthIfacesList));
+ SAFE_MALLOC(ifaces2, sizeof(EthIfacesList));
+ eth_ifaceslist_init(ifaces1);
+ eth_ifaceslist_init(ifaces2);
+
+ retvalue = get_host_eth_ifaces_osapi_netlink(ifaces1);
+ if (retvalue != 1) {
+ goto out;
+ }
+
+ retvalue = get_host_eth_ifaces_osapi_bridge(ifaces2);
+ if (retvalue != 1) {
+ goto out;
+ }
+ /* merge the information */
+ merge_eth_list_for_bridge(ifaces1, ifaces2, 1);
+ eth_ifaceslist_uninit(ifaces2);
+
+ /* filter the result */
+ i = 0;
+ while (i < ifaces1->count) {
+ /* see if the result need to be put to the list */
+ filter_ret = 1;
+ if (filter_func != NULL) {
+ filter_ret = filter_func(ifaces1->pifaces[i], filter_opaque);
+ }
+ if (filter_ret == 1) {
+ if (count >= MAX_IFACE_NUM) {
+ retvalue = ERR_DEVICE_EXCEED_MAXNUM;
+ goto out;
+ }
+ host_iface_adjust(ifaces1->pifaces[i]);
+ plist->pifaces[count] = ifaces1->pifaces[i];
+ ifaces1->pifaces[i] = NULL;
+ count++;
+ }
+ i++;
+ }
+
+ out:
+ eth_ifaceslist_uninit(ifaces1);
+ SAFE_FREE(ifaces1);
+ eth_ifaceslist_uninit(ifaces2);
+ SAFE_FREE(ifaces2);
+ plist->count = count;
+ return retvalue;
+}
diff --git a/libnetwork/host_network_implement_OSAPI.h b/libnetwork/host_network_implement_OSAPI.h
new file mode 100644
index 0000000..34a261b
--- /dev/null
+++ b/libnetwork/host_network_implement_OSAPI.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright IBM Corp. 2012
+ *
+ * Authors:
+ * Wenchao Xia <xiawenc(a)cn.ibm.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+#ifndef HOST_NETWORK_IMPLEMENT_OSAPI_H
+#define HOST_NETWORK_IMPLEMENT_OSAPI_H
+
+#include "host_network_basic.h"
+
+int get_host_eth_ifaces_osapi(EthIfacesList *plist,
+ eth_iface_filter_func filter_func, void *filter_opaque);
+
+#endif
--
1.7.1
1
0
building system is changed to check libnl-devel-1.1. Also added Makefile in
sub dir. In sub dir CFLAGS and LDFLAGS were overwritten, because they have
other values set when configure was excuted. Libnetwork have -fPIC and
-fvisibility=hidden -D DLL_BUILD flags set.
Signed-off-by: Wenchao Xia <xiawenc(a)cn.ibm.com>
---
Makefile.am | 2 +-
acinclude.m4 | 9 +++++++++
configure.ac | 8 ++++++++
libnetwork/Makefile.am | 37 +++++++++++++++++++++++++++++++++++++
libvirt-cim.spec.in | 2 ++
5 files changed, 57 insertions(+), 1 deletions(-)
create mode 100644 libnetwork/Makefile.am
diff --git a/Makefile.am b/Makefile.am
index 94dc5f3..6689550 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Copyright IBM Corp. 2007
AUTOMAKE_OPTIONS=dist-bzip2
-SUBDIRS = libxkutil src doc base_schema
+SUBDIRS = libnetwork libxkutil src doc base_schema
MOFS = \
$(top_srcdir)/schema/ComputerSystem.mof \
diff --git a/acinclude.m4 b/acinclude.m4
index e0f76b6..3a2f76f 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -387,3 +387,12 @@ AC_DEFUN([SET_CSET],
CFLAGS="$CFLAGS $cs $rv"
]
)
+
+AC_DEFUN([CHECK_LIBNL],
+ [
+ PKG_CHECK_MODULES([LIBNL], [libnl-1 >= 1.1])
+ AC_SUBST([LIBNL_CFLAGS])
+ AC_SUBST([LIBNL_LIBS])
+# CPPFLAGS="$CPPFLAGS $LIBNL_CFLAGS"
+# LDFLAGS="$LDFLAGS $LIBNL_LIBS"
+ ])
diff --git a/configure.ac b/configure.ac
index 0f85baa..78a7438 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,12 @@ CC_WARNINGS="\
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE"
+# following are for libnetwork
+LIBNETWORK_CFLAGS="-fvisibility=hidden"
+LIBNETWORK_DEFINES="-D DLL_BUILD"
+AC_SUBST(LIBNETWORK_CFLAGS)
+AC_SUBST(LIBNETWORK_DEFINES)
+
# Configure command line options
AC_ARG_VAR([CIMSERVER],[the target CIM server (pegasus|sfcb|openwbem|sniacimom).
])
@@ -141,6 +147,7 @@ AC_CONFIG_FILES([
base_schema/install_base_schema.sh
base_schema/Makefile
libxkutil/Makefile
+ libnetwork/Makefile
src/Makefile
doc/Makefile
Makefile
@@ -165,6 +172,7 @@ CHECK_LIBXML2
CHECK_LIBCU
CHECK_LIBUUID
CHECK_LIBCONFIG
+CHECK_LIBNL
CFLAGS_STRICT="-Werror"
diff --git a/libnetwork/Makefile.am b/libnetwork/Makefile.am
new file mode 100644
index 0000000..aaa33c0
--- /dev/null
+++ b/libnetwork/Makefile.am
@@ -0,0 +1,37 @@
+# Copyright IBM Corp. 2012
+# Auther:
+# Wenchao Xia, <xiawenc(a)cn.ibm.com>
+#
+# Try build a dynamic library libnetwork.so, which
+# include libnl-3 and libbridge binaries. Doing this is
+# because there is no devel-libbridge.rpm, and there are
+# many program still using libnl1.so, which conflicts with
+# libnl-3.
+# Exported symbols are strictly limited by Macro DLL_PUBLIC
+# to reduce name space polution.
+# It need libcmpiutil to use CU_DEBUG facility.
+# A test program is generated named as libnetwork_test.
+
+LDFLAGS = $(LIBNETWORK_DEFINES)
+
+CFLAGS = $(CFLAGS_STRICT) \
+ -DLIBVIRTCIM_CONF=\"@sysconfdir@/@PACKAGE@.conf\" \
+ $(LIBNETWORK_CFLAGS) $(LIBNETWORK_DEFINES) \
+ -I $(top_srcdir)/libnetwork/include
+
+
+noinst_HEADERS = host_network_API.h host_network_basic.h host_network_helper.h host_network_error.h \
+ host_network_implement_OSAPI.h host_network_implement_bridge.h dll_magic.h
+noinst_HEADERS += include/netlink/route/link/vlan.h include/netlink/route/link/info-api.h
+
+lib_LTLIBRARIES = libnetwork.la
+
+libnetwork_la_SOURCES = host_network_API.c host_network_basic.c host_network_helper.c \
+ host_network_implement_OSAPI.c host_network_implement_bridge.c
+libnetwork_la_LDFLAGS = -version-info @VERSION_INFO@ -lcmpiutil $(LIBNL_LIBS)
+
+noinst_PROGRAMS = libnetwork_test
+
+libnetwork_test_SOURCES = libnetwork_test.c
+libnetwork_test_LDFLAGS = -lcmpiutil
+libnetwork_test_LDADD = libnetwork.la
diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in
index d78eee7..5fac166 100644
--- a/libvirt-cim.spec.in
+++ b/libvirt-cim.spec.in
@@ -13,9 +13,11 @@ Requires: libxml2 >= 2.6.0
Requires: libvirt >= 0.9.0
Requires: unzip
Requires: tog-pegasus
+Requires: libnl >= 1.1
BuildRequires: libcmpiutil >= 0.5.4
BuildRequires: tog-pegasus-devel
BuildRequires: libvirt-devel >= 0.9.0
+BuildRequires: libnl-devel >= 1.1
# In RHEL5 uuid-devel is provided by e2fsprogs
%if 0%{?el5}
--
1.7.1
1
0
These patches just add new library in libvirt-cim and do not touch
existing providers. It have a testing program added to see the functionalities.
V2: fix some problem in filter out NICs.
V3: using libnl3 and libbridge instead of string parsing, applys to libvirt-cim
0.5.5.
V4: switched to libnl1, using custom codes for bridge. Small fix about date
declaration. libnl1 provides less functions such as single root NICs, but it is
workable for vlan 8021q. Patch applys to latest libvirt-cim from git.
repository:
git://gitorious.org/libvirt-cim_develop/libvirt-cim_develop.git
page:
https://gitorious.org/libvirt-cim_develop/libvirt-cim_develop
Wenchao Xia (8):
vlan library - Makefile system change
vlan library - add missing header files in libnl-devel 1.1
vlan library - add a simple implemention for bridge
vlan library - add host network implemention
vlan library - add basic structure and related functions
vlan library - add help functions and error defines
vlan library - add interface for CIM model code
vlan library - testing program for libnetwork
Makefile.am | 2 +-
acinclude.m4 | 9 +
configure.ac | 8 +
libnetwork/Makefile.am | 37 ++
libnetwork/dll_magic.h | 13 +
libnetwork/host_network_API.c | 30 +
libnetwork/host_network_API.h | 25 +
libnetwork/host_network_basic.c | 656 ++++++++++++++++++++++
libnetwork/host_network_basic.h | 158 ++++++
libnetwork/host_network_error.h | 23 +
libnetwork/host_network_helper.c | 266 +++++++++
libnetwork/host_network_helper.h | 177 ++++++
libnetwork/host_network_implement_OSAPI.c | 366 ++++++++++++
libnetwork/host_network_implement_OSAPI.h | 21 +
libnetwork/host_network_implement_bridge.c | 224 ++++++++
libnetwork/host_network_implement_bridge.h | 8 +
libnetwork/include/netlink/route/link/info-api.h | 71 +++
libnetwork/include/netlink/route/link/vlan.h | 55 ++
libnetwork/libnetwork_test.c | 91 +++
libvirt-cim.spec.in | 2 +
20 files changed, 2241 insertions(+), 1 deletions(-)
create mode 100644 libnetwork/Makefile.am
create mode 100644 libnetwork/dll_magic.h
create mode 100644 libnetwork/host_network_API.c
create mode 100644 libnetwork/host_network_API.h
create mode 100644 libnetwork/host_network_basic.c
create mode 100644 libnetwork/host_network_basic.h
create mode 100644 libnetwork/host_network_error.h
create mode 100644 libnetwork/host_network_helper.c
create mode 100644 libnetwork/host_network_helper.h
create mode 100644 libnetwork/host_network_implement_OSAPI.c
create mode 100644 libnetwork/host_network_implement_OSAPI.h
create mode 100644 libnetwork/host_network_implement_bridge.c
create mode 100644 libnetwork/host_network_implement_bridge.h
create mode 100644 libnetwork/include/netlink/route/link/info-api.h
create mode 100644 libnetwork/include/netlink/route/link/vlan.h
create mode 100644 libnetwork/libnetwork_test.c
1
0
17 Jan '12
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
This series provides a generic linked list implementation for libxkutil that is
based on the one originally developed for the libvirt domain events support
recently integrated upstream.
As test case I ported the ComputerSystemIndication provider code to use this
list implementation. In the near future it will be also used by the event loop
that I am currently working on to allow systems with libvirt older than 0.9.0
to make use of the same feature.
Other possible use cases would be to port the code of libxkutil/*_parsing* to
also use the list implementation instead of static arrays.
Changes from v1:
- Fix version iformation in Makefile.am
--
Eduardo de Barros Lima
Software Engineer, Open Virtualization
Linux Technology Center - IBM/Brazil
eblima(a)br.ibm.com
Eduardo Lima (Etrunko) (2):
libxkutil: Linked list helper
CSI: Use list helper implementation
libxkutil/Makefile.am | 51 ++++++--
libxkutil/list_util.c | 231 +++++++++++++++++++++++++++++++++++
libxkutil/list_util.h | 76 ++++++++++++
src/Virt_ComputerSystemIndication.c | 95 ++++-----------
4 files changed, 370 insertions(+), 83 deletions(-)
create mode 100644 libxkutil/list_util.c
create mode 100644 libxkutil/list_util.h
--
1.7.7.5
1
2
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
This series provides a generic linked list implementation for libxkutil that is
based on the one originally developed for the libvirt domain events support
recently integrated upstream.
As test case I ported the ComputerSystemIndication provider code to use this
list implementation. In the near future it will be also used by the event loop
that I am currently working on to allow systems with libvirt older than 0.9.0
to make use of the same feature.
Other possible use cases would be to port the code of libxkutil/*_parsing* to
also use the list implementation instead of static arrays.
--
Eduardo de Barros Lima
Software Engineer, Open Virtualization
Linux Technology Center - IBM/Brazil
eblima(a)br.ibm.com
Eduardo Lima (Etrunko) (2):
libxkutil: Linked list helper
CSI: Use list helper implementation
libxkutil/Makefile.am | 48 +++++--
libxkutil/list_util.c | 231 +++++++++++++++++++++++++++++++++++
libxkutil/list_util.h | 76 ++++++++++++
src/Virt_ComputerSystemIndication.c | 95 ++++-----------
4 files changed, 367 insertions(+), 83 deletions(-)
create mode 100644 libxkutil/list_util.c
create mode 100644 libxkutil/list_util.h
--
1.7.7.5
1
3
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
Yet another series of patches fixing errors revealed by Coverity tool. It would
be nice if we had a similar setup so we could run the tool on a regular basis. I
started playing with clang a while ago. It also provides a static analyser, but
I could not complete the setup by then.
https://bugzilla.redhat.com/show_bug.cgi?id=750418
Best regards, Etrunko
Eduardo Lima (Etrunko) (4):
libxkutil: Fix possible NULL dereferences
Fix possible memory leaks
xml_parse_test: Fix invalid dereference
Fix possible use of unitialized variables
libxkutil/cs_util_instance.c | 5 +++++
libxkutil/device_parsing.c | 14 +++++++-------
libxkutil/pool_parsing.c | 5 +++--
libxkutil/xml_parse_test.c | 3 +--
libxkutil/xmlgen.c | 8 +++++---
src/Virt_AppliedFilterList.c | 3 ++-
src/Virt_Device.c | 28 ++++++++++++++++++++++++++++
src/Virt_DevicePool.c | 19 ++++++++++++++++++-
src/Virt_SwitchService.c | 24 ++++++++++++++++++++----
src/Virt_VirtualSystemManagementService.c | 16 ++++++++--------
src/Virt_VirtualSystemSnapshotService.c | 2 +-
11 files changed, 98 insertions(+), 29 deletions(-)
--
1.7.7.5
1
5
[ We carry the following patch in RHEL builds, I think it's best applied
upstream :-) ]
The /etc/ld.so.conf.d/libvirt-cim.conf file generated conflicted
between 23 bits and 64 bits arches leading to a multi-arch conflict.
Simply use a filename based on the expected architecture.
Signed-off-by: Daniel Veillard <veillard(a)redhat.com>
diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in
index f3289db..d78eee7 100644
--- a/libvirt-cim.spec.in
+++ b/libvirt-cim.spec.in
@@ -54,7 +54,7 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/cmpi/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/cmpi/*.a
rm -f $RPM_BUILD_ROOT%{_libdir}/libxkutil.so
mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d
-echo %{_libdir}/cmpi > $RPM_BUILD_ROOT/etc/ld.so.conf.d/libvirt-cim.conf
+echo %{_libdir}/cmpi > $RPM_BUILD_ROOT/etc/ld.so.conf.d/libvirt-cim.%{_arch}.conf
mkdir -p $RPM_BUILD_ROOT@INFO_STORE@
%clean
@@ -135,7 +135,7 @@ rm -fr $RPM_BUILD_ROOT
%{_datadir}/libvirt-cim/cimv*-cimv2_mof
%{_datadir}/libvirt-cim/*.registration
%{_datadir}/libvirt-cim/cim_schema_*-MOFs.zip
-%{_sysconfdir}/ld.so.conf.d/libvirt-cim.conf
+%{_sysconfdir}/ld.so.conf.d/libvirt-cim.%{_arch}.conf
%config(noreplace) %{_sysconfdir}/libvirt-cim.conf
%changelog
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
3
4
[PATCH 1/2] VirtualSystemManagementService: Remove dead code
- This patch simply removes some code that was already commented for some time
[PATCH 2/2] ComputerSystemIndication: Support libvirt domain events
- This one actually does the job. See its description for more details.
Best regards, Etrunko
--
Eduardo de Barros Lima
Software Engineer, Open Virtualization
Linux Technology Center - IBM/Brazil
eblima(a)br.ibm.com
3
14
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
I am building libvirt-cim with gcc 4.6.3 in fedora 16 and got a bunch of new
warnings. Most of them are about variables that are set but not used anywhere,
but there is one possible access to unitialized variables in Virt_RASD.c which
might result in unexpected behavior.
xmlgen.c: In function 'system_xml':
xmlgen.c:633:28: error: variable 'bl' set but not used [-Werror=unused-but-set-variable]
xmlgen.c:642:28: error: variable 'bl_args' set but not used [-Werror=unused-but-set-variable]
xmlgen.c: In function 'disk_pool_xml':
xmlgen.c:1244:20: error: variable 'path' set but not used [-Werror=unused-but-set-variable]
xmlgen.c: In function 'filter_to_xml':
xmlgen.c:1474:15: error: variable 'msg' set but not used [-Werror=unused-but-set-variable]
Virt_FilterEntry.c: In function 'enum_filter_rules':
Virt_FilterEntry.c:576:30: error: variable 'class_type' set but not used [-Werror=unused-but-set-variable]
Virt_RASD.c: In function 'rasd_from_vdev':
Virt_RASD.c:406:27: error: 'pool' may be used uninitialized in this function [-Werror=uninitialized]
Virt_RASD.c:330:27: note: 'pool' was declared here
Virt_RASD.c:407:26: error: 'vol' may be used uninitialized in this function [-Werror=uninitialized]
Virt_RASD.c:320:26: note: 'vol' was declared here
Virt_VSMigrationService.c: In function 'clear_infstore_migration_flag':
Virt_VSMigrationService.c:1185:15: error: variable 'ret' set but not used [-Werror=unused-but-set-variable]
Virt_VSMigrationService.c: In function 'migrate_do':
Virt_VSMigrationService.c:1478:15: error: variable 'thread' set but not used [-Werror=unused-but-set-variable]
Virt_Device.c: In function 'device_instances':
Virt_Device.c:431:15: error: variable 'ret' set but not used [-Werror=unused-but-set-variable]
Virt_Device.c: In function 'proc_dev_list':
Virt_Device.c:657:13: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
Virt_Device.c: In function 'get_device_by_name':
Virt_Device.c:769:21: error: variable 'ret' set but not used [-Werror=unused-but-set-variable]
Virt_Device.c:729:15: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
Virt_VirtualSystemManagementService.c: In function 'input_rasd_to_vdev':
Virt_VirtualSystemManagementService.c:1384:21: error: variable 'msg' set but not used [-Werror=unused-but-set-variable]
Changes since v1:
- xmlgen.c: Keep 'path' variable and fix value check.
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
---
libxkutil/xmlgen.c | 33 ++++++-----------------
src/Virt_Device.c | 39 +++++++++--------------------
src/Virt_FilterEntry.c | 11 ++------
src/Virt_RASD.c | 17 +++++++-----
src/Virt_VSMigrationService.c | 6 +---
src/Virt_VirtualSystemManagementService.c | 5 +--
6 files changed, 38 insertions(+), 73 deletions(-)
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index afd8c21..d73ffd0 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -630,21 +630,17 @@ static char *system_xml(xmlNodePtr root, struct domain *domain)
tmp = xmlNewChild(root, NULL, BAD_CAST "name", BAD_CAST domain->name);
if (domain->bootloader) {
- xmlNodePtr bl;
-
- bl = xmlNewChild(root,
- NULL,
- BAD_CAST "bootloader",
- BAD_CAST domain->bootloader);
+ tmp = xmlNewChild(root,
+ NULL,
+ BAD_CAST "bootloader",
+ BAD_CAST domain->bootloader);
}
if (domain->bootloader_args) {
- xmlNodePtr bl_args;
-
- bl_args = xmlNewChild(root,
- NULL,
- BAD_CAST "bootloader_args",
- BAD_CAST domain->bootloader_args);
+ tmp = xmlNewChild(root,
+ NULL,
+ BAD_CAST "bootloader_args",
+ BAD_CAST domain->bootloader_args);
}
tmp = xmlNewChild(root,
@@ -1272,7 +1268,7 @@ static const char *disk_pool_xml(xmlNodePtr root,
goto out;
path = xmlNewChild(target, NULL, BAD_CAST "path", BAD_CAST pool->path);
- if (target == NULL)
+ if (path == NULL)
goto out;
return NULL;
@@ -1471,7 +1467,6 @@ char *res_to_xml(struct virt_pool_res *res) {
char *filter_to_xml(struct acl_filter *filter)
{
- char *msg = XML_ERROR;
char *xml = NULL;
xmlNodePtr root = NULL;
xmlNodePtr tmp = NULL;
@@ -1504,17 +1499,7 @@ char *filter_to_xml(struct acl_filter *filter)
goto out;
}
- /* TODO: Not yet supported
- for (i = 0; i < filter->rule_ct; i++) {
- msg = rule_to_xml(root, filter->rules[i]);
- if (msg != NULL)
- goto out;
- }
- */
-
xml = tree_to_xml(root);
- if (xml != NULL)
- msg = NULL; /* no errors */
out:
CU_DEBUG("Filter XML: %s", xml);
diff --git a/src/Virt_Device.c b/src/Virt_Device.c
index faa304d..fd11370 100644
--- a/src/Virt_Device.c
+++ b/src/Virt_Device.c
@@ -428,7 +428,6 @@ static bool device_instances(const CMPIBroker *broker,
struct inst_list *list)
{
int i;
- bool ret;
uint64_t proc_count = 0;
CMPIInstance *instance = NULL;
@@ -475,11 +474,7 @@ static bool device_instances(const CMPIBroker *broker,
}
if (proc_count) {
- ret = vcpu_instances(broker,
- dom,
- ns,
- proc_count,
- list);
+ vcpu_instances(broker, dom, ns, proc_count, list);
}
return true;
@@ -654,16 +649,17 @@ static int proc_dev_list(uint64_t quantity,
struct virt_device **list)
{
int i;
- int rc;
-
*list = (struct virt_device *)calloc(quantity,
sizeof(struct virt_device));
for (i = 0; i < quantity; i++) {
char *dev_num;
+ int ret;
- rc = asprintf(&dev_num, "%d", i);
+ ret = asprintf(&dev_num, "%d", i);
+ if (ret == -1)
+ CU_DEBUG("asprintf error %d" , ret);
(*list)[i].id = strdup(dev_num);
@@ -726,7 +722,6 @@ CMPIStatus get_device_by_name(const CMPIBroker *broker,
virDomainPtr dom = NULL;
struct virt_device *dev = NULL;
struct inst_list tmp_list;
- bool rc;
inst_list_init(&tmp_list);
@@ -766,24 +761,14 @@ CMPIStatus get_device_by_name(const CMPIBroker *broker,
}
if (type == CIM_RES_TYPE_PROC) {
- int ret;
int dev_id_num;
-
- ret = sscanf(dev->id, "%d", &dev_id_num);
+ sscanf(dev->id, "%d", &dev_id_num);
- rc = vcpu_inst(broker,
- dom,
- NAMESPACE(reference),
- dev_id_num,
- &tmp_list);
+ vcpu_inst(broker, dom, NAMESPACE(reference),
+ dev_id_num, &tmp_list);
} else {
-
- rc = device_instances(broker,
- dev,
- 1,
- dom,
- NAMESPACE(reference),
- &tmp_list);
+ device_instances(broker, dev, 1, dom,
+ NAMESPACE(reference), &tmp_list);
}
cleanup_virt_devices(&dev, 1);
@@ -799,8 +784,8 @@ CMPIStatus get_device_by_name(const CMPIBroker *broker,
inst_list_free(&tmp_list);
virConnectClose(conn);
- return s;
-}
+ return s;
+}
CMPIStatus get_device_by_ref(const CMPIBroker *broker,
const CMPIObjectPath *reference,
diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c
index acc3d61..16b211e 100644
--- a/src/Virt_FilterEntry.c
+++ b/src/Virt_FilterEntry.c
@@ -573,17 +573,12 @@ CMPIStatus enum_filter_rules(
struct acl_filter *filters = NULL;
int i, j, count = 0;
CMPIStatus s = {CMPI_RC_OK, NULL};
- enum {NONE, MAC, IP} class_type = NONE;
CU_DEBUG("Reference = %s", REF2STR(reference));
- if (STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter")) {
- class_type = MAC;
- } else if (STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter")) {
- class_type = IP;
- } else if (STREQC(CLASSNAME(reference), "KVM_FilterEntry")) {
- class_type = NONE;
- } else {
+ if (!STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter") &&
+ !STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter") &&
+ !STREQC(CLASSNAME(reference), "KVM_FilterEntry")) {
cu_statusf(broker, &s,
CMPI_RC_ERR_FAILED,
"Unrecognized class type");
diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c
index 4ac2f93..4939f7b 100644
--- a/src/Virt_RASD.c
+++ b/src/Virt_RASD.c
@@ -289,6 +289,11 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
uint16_t type;
CMPIStatus s = {CMPI_RC_OK, NULL};
char *poolid = NULL;
+ virConnectPtr conn = NULL;
+ virStorageVolPtr vol = NULL;
+ virStoragePoolPtr pool = NULL;
+ const char *pool_name = NULL;
+ int ret = -1;
get_vol_size(broker, ref, dev->dev.disk.source, &cap);
@@ -308,7 +313,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
(CMPIValue *)dev->dev.disk.source,
CMPI_chars);
- virConnectPtr conn = connect_by_classname(broker, CLASSNAME(ref), &s);
+ conn = connect_by_classname(broker, CLASSNAME(ref), &s);
if (conn == NULL) {
virt_set_status(broker, &s,
CMPI_RC_ERR_NOT_FOUND,
@@ -317,8 +322,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
goto cont;
}
- virStorageVolPtr vol = virStorageVolLookupByPath(conn,
- dev->dev.disk.source);
+ vol = virStorageVolLookupByPath(conn, dev->dev.disk.source);
if (vol == NULL) {
virt_set_status(broker, &s,
CMPI_RC_ERR_NOT_FOUND,
@@ -327,7 +331,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
goto cont;
}
- virStoragePoolPtr pool = virStoragePoolLookupByVolume(vol);
+ pool = virStoragePoolLookupByVolume(vol);
if (pool == NULL) {
virt_set_status(broker, &s,
CMPI_RC_ERR_NOT_FOUND,
@@ -336,7 +340,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
goto cont;
}
- const char *pool_name = virStoragePoolGetName(pool);
+ pool_name = virStoragePoolGetName(pool);
if (pool_name == NULL) {
virt_set_status(broker, &s,
CMPI_RC_ERR_NOT_FOUND,
@@ -345,8 +349,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
goto cont;
}
- int ret = asprintf(&poolid, "DiskPool/%s", pool_name);
-
+ ret = asprintf(&poolid, "DiskPool/%s", pool_name);
if (ret == -1) {
CU_DEBUG("Failed to get disk poolid");
goto cont;
diff --git a/src/Virt_VSMigrationService.c b/src/Virt_VSMigrationService.c
index 4f48a68..d393787 100644
--- a/src/Virt_VSMigrationService.c
+++ b/src/Virt_VSMigrationService.c
@@ -1182,7 +1182,6 @@ static CMPIStatus ensure_dom_offline(virDomainPtr dom)
static void clear_infstore_migration_flag(virDomainPtr dom)
{
struct infostore_ctx *infp;
- bool ret = false;
infp = infostore_open(dom);
if (infp == NULL) {
@@ -1191,7 +1190,7 @@ static void clear_infstore_migration_flag(virDomainPtr dom)
return;
}
- ret = infostore_set_bool(infp, "migrating", false);
+ infostore_set_bool(infp, "migrating", false);
CU_DEBUG("Clearing infostore migrating flag");
infostore_close(infp);
@@ -1475,7 +1474,6 @@ static CMPIStatus migrate_do(const CMPIObjectPath *ref,
CMPIStatus s;
CMPIObjectPath *job_op;
struct migration_job *job;
- CMPI_THREAD_TYPE thread;
uint32_t retcode = 1;
CMPIInstance *ind = NULL;
CMPIInstance *inst = NULL;
@@ -1517,7 +1515,7 @@ static CMPIStatus migrate_do(const CMPIObjectPath *ref,
if (!rc)
CU_DEBUG("Failed to raise indication");
- thread = _BROKER->xft->newThread((void*)migration_thread, job, 0);
+ _BROKER->xft->newThread((void*)migration_thread, job, 0);
retcode = CIM_SVPC_RETURN_JOB_STARTED;
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
index 5229f56..f8c5f24 100644
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -1381,10 +1381,9 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst,
struct virt_device *dev)
{
const char *val;
- const char *msg;
if (cu_get_str_prop(inst, "ResourceSubType", &val) != CMPI_RC_OK) {
- msg = "InputRASD ResourceSubType field not valid";
+ CU_DEBUG("InputRASD ResourceSubType field not valid");
goto out;
}
dev->dev.input.type = strdup(val);
@@ -1395,7 +1394,7 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst,
else if (STREQC(dev->dev.input.type, "tablet"))
dev->dev.input.bus = strdup("usb");
else {
- msg = "Invalid value for ResourceSubType in InputRASD";
+ CU_DEBUG("Invalid value for ResourceSubType in InputRASD");
goto out;
}
} else
--
1.7.7.5
3
2
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
I am building libvirt-cim with gcc 4.6.3 in fedora 16 and got a bunch of new
warnings. Most of them are about variables that are set but not used anywhere,
but there is one possible access to unitialized variables in Virt_RASD.c which
might result in unexpected behavior.
xmlgen.c: In function 'system_xml':
xmlgen.c:633:28: error: variable 'bl' set but not used [-Werror=unused-but-set-variable]
xmlgen.c:642:28: error: variable 'bl_args' set but not used [-Werror=unused-but-set-variable]
xmlgen.c: In function 'disk_pool_xml':
xmlgen.c:1244:20: error: variable 'path' set but not used [-Werror=unused-but-set-variable]
xmlgen.c: In function 'filter_to_xml':
xmlgen.c:1474:15: error: variable 'msg' set but not used [-Werror=unused-but-set-variable]
Virt_FilterEntry.c: In function 'enum_filter_rules':
Virt_FilterEntry.c:576:30: error: variable 'class_type' set but not used [-Werror=unused-but-set-variable]
Virt_RASD.c: In function 'rasd_from_vdev':
Virt_RASD.c:406:27: error: 'pool' may be used uninitialized in this function [-Werror=uninitialized]
Virt_RASD.c:330:27: note: 'pool' was declared here
Virt_RASD.c:407:26: error: 'vol' may be used uninitialized in this function [-Werror=uninitialized]
Virt_RASD.c:320:26: note: 'vol' was declared here
Virt_VSMigrationService.c: In function 'clear_infstore_migration_flag':
Virt_VSMigrationService.c:1185:15: error: variable 'ret' set but not used [-Werror=unused-but-set-variable]
Virt_VSMigrationService.c: In function 'migrate_do':
Virt_VSMigrationService.c:1478:15: error: variable 'thread' set but not used [-Werror=unused-but-set-variable]
Virt_Device.c: In function 'device_instances':
Virt_Device.c:431:15: error: variable 'ret' set but not used [-Werror=unused-but-set-variable]
Virt_Device.c: In function 'proc_dev_list':
Virt_Device.c:657:13: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
Virt_Device.c: In function 'get_device_by_name':
Virt_Device.c:769:21: error: variable 'ret' set but not used [-Werror=unused-but-set-variable]
Virt_Device.c:729:15: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
Virt_VirtualSystemManagementService.c: In function 'input_rasd_to_vdev':
Virt_VirtualSystemManagementService.c:1384:21: error: variable 'msg' set but not used [-Werror=unused-but-set-variable]
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
---
libxkutil/xmlgen.c | 34 ++++++------------------
src/Virt_Device.c | 39 +++++++++--------------------
src/Virt_FilterEntry.c | 11 ++------
src/Virt_RASD.c | 17 +++++++-----
src/Virt_VSMigrationService.c | 6 +---
src/Virt_VirtualSystemManagementService.c | 5 +--
6 files changed, 38 insertions(+), 74 deletions(-)
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
index afd8c21..46712df 100644
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -630,21 +630,17 @@ static char *system_xml(xmlNodePtr root, struct domain *domain)
tmp = xmlNewChild(root, NULL, BAD_CAST "name", BAD_CAST domain->name);
if (domain->bootloader) {
- xmlNodePtr bl;
-
- bl = xmlNewChild(root,
- NULL,
- BAD_CAST "bootloader",
- BAD_CAST domain->bootloader);
+ tmp = xmlNewChild(root,
+ NULL,
+ BAD_CAST "bootloader",
+ BAD_CAST domain->bootloader);
}
if (domain->bootloader_args) {
- xmlNodePtr bl_args;
-
- bl_args = xmlNewChild(root,
- NULL,
- BAD_CAST "bootloader_args",
- BAD_CAST domain->bootloader_args);
+ tmp = xmlNewChild(root,
+ NULL,
+ BAD_CAST "bootloader_args",
+ BAD_CAST domain->bootloader_args);
}
tmp = xmlNewChild(root,
@@ -1241,7 +1237,6 @@ static const char *disk_pool_xml(xmlNodePtr root,
xmlNodePtr disk = NULL;
xmlNodePtr name = NULL;
xmlNodePtr target = NULL;
- xmlNodePtr path = NULL;
const char *type = NULL;
const char *msg = NULL;
struct disk_pool *pool = &_pool->pool_info.disk;
@@ -1271,7 +1266,7 @@ static const char *disk_pool_xml(xmlNodePtr root,
if (target == NULL)
goto out;
- path = xmlNewChild(target, NULL, BAD_CAST "path", BAD_CAST pool->path);
+ xmlNewChild(target, NULL, BAD_CAST "path", BAD_CAST pool->path);
if (target == NULL)
goto out;
@@ -1471,7 +1466,6 @@ char *res_to_xml(struct virt_pool_res *res) {
char *filter_to_xml(struct acl_filter *filter)
{
- char *msg = XML_ERROR;
char *xml = NULL;
xmlNodePtr root = NULL;
xmlNodePtr tmp = NULL;
@@ -1504,17 +1498,7 @@ char *filter_to_xml(struct acl_filter *filter)
goto out;
}
- /* TODO: Not yet supported
- for (i = 0; i < filter->rule_ct; i++) {
- msg = rule_to_xml(root, filter->rules[i]);
- if (msg != NULL)
- goto out;
- }
- */
-
xml = tree_to_xml(root);
- if (xml != NULL)
- msg = NULL; /* no errors */
out:
CU_DEBUG("Filter XML: %s", xml);
diff --git a/src/Virt_Device.c b/src/Virt_Device.c
index faa304d..fd11370 100644
--- a/src/Virt_Device.c
+++ b/src/Virt_Device.c
@@ -428,7 +428,6 @@ static bool device_instances(const CMPIBroker *broker,
struct inst_list *list)
{
int i;
- bool ret;
uint64_t proc_count = 0;
CMPIInstance *instance = NULL;
@@ -475,11 +474,7 @@ static bool device_instances(const CMPIBroker *broker,
}
if (proc_count) {
- ret = vcpu_instances(broker,
- dom,
- ns,
- proc_count,
- list);
+ vcpu_instances(broker, dom, ns, proc_count, list);
}
return true;
@@ -654,16 +649,17 @@ static int proc_dev_list(uint64_t quantity,
struct virt_device **list)
{
int i;
- int rc;
-
*list = (struct virt_device *)calloc(quantity,
sizeof(struct virt_device));
for (i = 0; i < quantity; i++) {
char *dev_num;
+ int ret;
- rc = asprintf(&dev_num, "%d", i);
+ ret = asprintf(&dev_num, "%d", i);
+ if (ret == -1)
+ CU_DEBUG("asprintf error %d" , ret);
(*list)[i].id = strdup(dev_num);
@@ -726,7 +722,6 @@ CMPIStatus get_device_by_name(const CMPIBroker *broker,
virDomainPtr dom = NULL;
struct virt_device *dev = NULL;
struct inst_list tmp_list;
- bool rc;
inst_list_init(&tmp_list);
@@ -766,24 +761,14 @@ CMPIStatus get_device_by_name(const CMPIBroker *broker,
}
if (type == CIM_RES_TYPE_PROC) {
- int ret;
int dev_id_num;
-
- ret = sscanf(dev->id, "%d", &dev_id_num);
+ sscanf(dev->id, "%d", &dev_id_num);
- rc = vcpu_inst(broker,
- dom,
- NAMESPACE(reference),
- dev_id_num,
- &tmp_list);
+ vcpu_inst(broker, dom, NAMESPACE(reference),
+ dev_id_num, &tmp_list);
} else {
-
- rc = device_instances(broker,
- dev,
- 1,
- dom,
- NAMESPACE(reference),
- &tmp_list);
+ device_instances(broker, dev, 1, dom,
+ NAMESPACE(reference), &tmp_list);
}
cleanup_virt_devices(&dev, 1);
@@ -799,8 +784,8 @@ CMPIStatus get_device_by_name(const CMPIBroker *broker,
inst_list_free(&tmp_list);
virConnectClose(conn);
- return s;
-}
+ return s;
+}
CMPIStatus get_device_by_ref(const CMPIBroker *broker,
const CMPIObjectPath *reference,
diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c
index acc3d61..16b211e 100644
--- a/src/Virt_FilterEntry.c
+++ b/src/Virt_FilterEntry.c
@@ -573,17 +573,12 @@ CMPIStatus enum_filter_rules(
struct acl_filter *filters = NULL;
int i, j, count = 0;
CMPIStatus s = {CMPI_RC_OK, NULL};
- enum {NONE, MAC, IP} class_type = NONE;
CU_DEBUG("Reference = %s", REF2STR(reference));
- if (STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter")) {
- class_type = MAC;
- } else if (STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter")) {
- class_type = IP;
- } else if (STREQC(CLASSNAME(reference), "KVM_FilterEntry")) {
- class_type = NONE;
- } else {
+ if (!STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter") &&
+ !STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter") &&
+ !STREQC(CLASSNAME(reference), "KVM_FilterEntry")) {
cu_statusf(broker, &s,
CMPI_RC_ERR_FAILED,
"Unrecognized class type");
diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c
index 4ac2f93..4939f7b 100644
--- a/src/Virt_RASD.c
+++ b/src/Virt_RASD.c
@@ -289,6 +289,11 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
uint16_t type;
CMPIStatus s = {CMPI_RC_OK, NULL};
char *poolid = NULL;
+ virConnectPtr conn = NULL;
+ virStorageVolPtr vol = NULL;
+ virStoragePoolPtr pool = NULL;
+ const char *pool_name = NULL;
+ int ret = -1;
get_vol_size(broker, ref, dev->dev.disk.source, &cap);
@@ -308,7 +313,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
(CMPIValue *)dev->dev.disk.source,
CMPI_chars);
- virConnectPtr conn = connect_by_classname(broker, CLASSNAME(ref), &s);
+ conn = connect_by_classname(broker, CLASSNAME(ref), &s);
if (conn == NULL) {
virt_set_status(broker, &s,
CMPI_RC_ERR_NOT_FOUND,
@@ -317,8 +322,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
goto cont;
}
- virStorageVolPtr vol = virStorageVolLookupByPath(conn,
- dev->dev.disk.source);
+ vol = virStorageVolLookupByPath(conn, dev->dev.disk.source);
if (vol == NULL) {
virt_set_status(broker, &s,
CMPI_RC_ERR_NOT_FOUND,
@@ -327,7 +331,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
goto cont;
}
- virStoragePoolPtr pool = virStoragePoolLookupByVolume(vol);
+ pool = virStoragePoolLookupByVolume(vol);
if (pool == NULL) {
virt_set_status(broker, &s,
CMPI_RC_ERR_NOT_FOUND,
@@ -336,7 +340,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
goto cont;
}
- const char *pool_name = virStoragePoolGetName(pool);
+ pool_name = virStoragePoolGetName(pool);
if (pool_name == NULL) {
virt_set_status(broker, &s,
CMPI_RC_ERR_NOT_FOUND,
@@ -345,8 +349,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker,
goto cont;
}
- int ret = asprintf(&poolid, "DiskPool/%s", pool_name);
-
+ ret = asprintf(&poolid, "DiskPool/%s", pool_name);
if (ret == -1) {
CU_DEBUG("Failed to get disk poolid");
goto cont;
diff --git a/src/Virt_VSMigrationService.c b/src/Virt_VSMigrationService.c
index 4f48a68..d393787 100644
--- a/src/Virt_VSMigrationService.c
+++ b/src/Virt_VSMigrationService.c
@@ -1182,7 +1182,6 @@ static CMPIStatus ensure_dom_offline(virDomainPtr dom)
static void clear_infstore_migration_flag(virDomainPtr dom)
{
struct infostore_ctx *infp;
- bool ret = false;
infp = infostore_open(dom);
if (infp == NULL) {
@@ -1191,7 +1190,7 @@ static void clear_infstore_migration_flag(virDomainPtr dom)
return;
}
- ret = infostore_set_bool(infp, "migrating", false);
+ infostore_set_bool(infp, "migrating", false);
CU_DEBUG("Clearing infostore migrating flag");
infostore_close(infp);
@@ -1475,7 +1474,6 @@ static CMPIStatus migrate_do(const CMPIObjectPath *ref,
CMPIStatus s;
CMPIObjectPath *job_op;
struct migration_job *job;
- CMPI_THREAD_TYPE thread;
uint32_t retcode = 1;
CMPIInstance *ind = NULL;
CMPIInstance *inst = NULL;
@@ -1517,7 +1515,7 @@ static CMPIStatus migrate_do(const CMPIObjectPath *ref,
if (!rc)
CU_DEBUG("Failed to raise indication");
- thread = _BROKER->xft->newThread((void*)migration_thread, job, 0);
+ _BROKER->xft->newThread((void*)migration_thread, job, 0);
retcode = CIM_SVPC_RETURN_JOB_STARTED;
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
index 5229f56..f8c5f24 100644
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -1381,10 +1381,9 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst,
struct virt_device *dev)
{
const char *val;
- const char *msg;
if (cu_get_str_prop(inst, "ResourceSubType", &val) != CMPI_RC_OK) {
- msg = "InputRASD ResourceSubType field not valid";
+ CU_DEBUG("InputRASD ResourceSubType field not valid");
goto out;
}
dev->dev.input.type = strdup(val);
@@ -1395,7 +1394,7 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst,
else if (STREQC(dev->dev.input.type, "tablet"))
dev->dev.input.bus = strdup("usb");
else {
- msg = "Invalid value for ResourceSubType in InputRASD";
+ CU_DEBUG("Invalid value for ResourceSubType in InputRASD");
goto out;
}
} else
--
1.7.7.5
2
2
[PATCHv2] ComputerSystemIndication: Support libvirt domain events
by Eduardo Lima (Etrunko) 03 Jan '12
by Eduardo Lima (Etrunko) 03 Jan '12
03 Jan '12
From: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
Port current implementation to use domain events implementation provided by
libvirt. It requires libvirt version 0.9.0 or newer, when the
virEventRegisterDefaultImpl and virEventRunDefaultImpl API's were introduced.
Now that all events are generated by libvirt itself, we don't need to trigger
them manually anymore. Thus, this patch also removes trigger and raise calls
from VirtualSystemManagementService and ComputerSystem providers.
Differences from v1:
- Move call to virRegisterDefaultImpl() to the provider code with protection
to ensure it is called only once.
- Call CBDetachThread() before exiting the lifecycle thread.
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
---
acinclude.m4 | 2 +-
libvirt-cim.spec.in | 4 +-
src/Virt_ComputerSystem.c | 51 +--
src/Virt_ComputerSystemIndication.c | 766 ++++++++++++++---------------
src/Virt_ComputerSystemIndication.h | 5 -
src/Virt_VirtualSystemManagementService.c | 30 +-
6 files changed, 378 insertions(+), 480 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
index e313891..e0f76b6 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -243,7 +243,7 @@ AC_DEFUN([CHECK_LIBCU],
AC_DEFUN([CHECK_LIBVIRT],
[
- PKG_CHECK_MODULES([LIBVIRT], [libvirt >= 0.3.2])
+ PKG_CHECK_MODULES([LIBVIRT], [libvirt >= 0.9.0])
AC_SUBST([LIBVIRT_CFLAGS])
AC_SUBST([LIBVIRT_LIBS])
CPPFLAGS="$CPPFLAGS $LIBVIRT_CFLAGS"
diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in
index 5b7267b..f3289db 100644
--- a/libvirt-cim.spec.in
+++ b/libvirt-cim.spec.in
@@ -10,12 +10,12 @@ Source: libvirt-cim-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
URL: http://libvirt.org/CIM/
Requires: libxml2 >= 2.6.0
-Requires: libvirt >= 0.6.3
+Requires: libvirt >= 0.9.0
Requires: unzip
Requires: tog-pegasus
BuildRequires: libcmpiutil >= 0.5.4
BuildRequires: tog-pegasus-devel
-BuildRequires: libvirt-devel >= 0.6.3
+BuildRequires: libvirt-devel >= 0.9.0
# In RHEL5 uuid-devel is provided by e2fsprogs
%if 0%{?el5}
diff --git a/src/Virt_ComputerSystem.c b/src/Virt_ComputerSystem.c
index 098b07a..582253a 100644
--- a/src/Virt_ComputerSystem.c
+++ b/src/Virt_ComputerSystem.c
@@ -492,6 +492,7 @@ static CMPIStatus set_properties(const CMPIBroker *broker,
}
if (!set_name_from_dom(dom, instance)) {
+ CU_DEBUG("Unable to get domain name");
virt_set_status(broker, &s,
CMPI_RC_ERR_FAILED,
virDomainGetConnect(dom),
@@ -500,6 +501,7 @@ static CMPIStatus set_properties(const CMPIBroker *broker,
}
if (!set_uuid_from_dom(dom, instance, &uuid)) {
+ CU_DEBUG("Unable to get domain uuid");
virt_set_status(broker, &s,
CMPI_RC_ERR_FAILED,
virDomainGetConnect(dom),
@@ -514,6 +516,7 @@ static CMPIStatus set_properties(const CMPIBroker *broker,
}
if (!set_state_from_dom(broker, dom, instance)) {
+ CU_DEBUG("Unable to get domain info");
virt_set_status(broker, &s,
CMPI_RC_ERR_FAILED,
virDomainGetConnect(dom),
@@ -660,6 +663,7 @@ CMPIStatus get_domain_by_name(const CMPIBroker *broker,
conn = connect_by_classname(broker, CLASSNAME(reference), &s);
if (conn == NULL) {
+ CU_DEBUG("No such instance");
cu_statusf(broker, &s,
CMPI_RC_ERR_NOT_FOUND,
"No such instance.");
@@ -668,6 +672,7 @@ CMPIStatus get_domain_by_name(const CMPIBroker *broker,
dom = virDomainLookupByName(conn, name);
if (dom == NULL) {
+ CU_DEBUG("Domain '%s' does not exist", name);
virt_set_status(broker, &s,
CMPI_RC_ERR_NOT_FOUND,
conn,
@@ -681,8 +686,10 @@ CMPIStatus get_domain_by_name(const CMPIBroker *broker,
conn,
dom,
&inst);
- if (s.rc != CMPI_RC_OK)
+ if (s.rc != CMPI_RC_OK) {
+ CU_DEBUG("Unable to retrieve instance from domain");
goto out;
+ }
*_inst = inst;
@@ -766,39 +773,6 @@ DEFAULT_DI();
DEFAULT_EQ();
DEFAULT_INST_CLEANUP();
-static bool trigger_mod_indication(const CMPIContext *context,
- CMPIInstance *prev_inst,
- const CMPIObjectPath *ref)
-{
- CMPIStatus s = {CMPI_RC_OK, NULL};
- const char *ind_name = "ComputerSystemModifiedIndication";
- CMPIInstance *ind = NULL;
- char *type = NULL;
-
- CU_DEBUG("Preparing ComputerSystem indication");
-
- ind = get_typed_instance(_BROKER,
- CLASSNAME(ref),
- ind_name,
- NAMESPACE(ref));
- if (ind == NULL) {
- CU_DEBUG("Failed to create ind '%s'", ind_name);
- goto out;
- }
-
- CU_DEBUG("Setting PreviousInstance");
- CMSetProperty(ind, "PreviousInstance",
- (CMPIValue *)&prev_inst, CMPI_instance);
-
- type = get_typed_class(CLASSNAME(ref), ind_name);
-
- s = stdi_raise_indication(_BROKER, context, type, NAMESPACE(ref), ind);
-
- out:
- free(type);
- return s.rc == CMPI_RC_OK;
-}
-
static int xen_scheduler_params(struct infostore_ctx *ctx,
virSchedParameter **params)
{
@@ -1253,7 +1227,6 @@ static CMPIStatus state_change(CMPIMethodMI *self,
int ret;
const char *name = NULL;
uint32_t rc = 1;
- bool ind_rc;
ret = cu_get_u16_arg(argsin, "RequestedState", &state);
if (ret != CMPI_RC_OK) {
@@ -1282,13 +1255,9 @@ static CMPIStatus state_change(CMPIMethodMI *self,
s = __state_change(name, state, reference);
- if (s.rc == CMPI_RC_OK) {
- ind_rc= trigger_mod_indication(context, prev_inst, reference);
- if (!ind_rc)
- CU_DEBUG("Unable to trigger indication");
-
+ if (s.rc == CMPI_RC_OK)
rc = 0;
- }
+
out:
CMReturnData(results, &rc, CMPI_uint32);
diff --git a/src/Virt_ComputerSystemIndication.c b/src/Virt_ComputerSystemIndication.c
index a00444d..eb1a71c 100644
--- a/src/Virt_ComputerSystemIndication.c
+++ b/src/Virt_ComputerSystemIndication.c
@@ -25,13 +25,13 @@
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
-#include <time.h>
#include <cmpidt.h>
#include <cmpift.h>
#include <cmpimacs.h>
#include <libvirt/libvirt.h>
+#include <libvirt/virterror.h>
#include <libcmpiutil/libcmpiutil.h>
#include <misc_util.h>
@@ -44,158 +44,187 @@
#include "Virt_ComputerSystemIndication.h"
#include "Virt_HostSystem.h"
-static const CMPIBroker *_BROKER;
#define CSI_NUM_PLATFORMS 3
-enum CSI_PLATFORMS {CSI_XEN,
- CSI_KVM,
- CSI_LXC,
+enum CSI_PLATFORMS {
+ CSI_XEN,
+ CSI_KVM,
+ CSI_LXC,
};
-static CMPI_THREAD_TYPE thread_id[CSI_NUM_PLATFORMS];
-static int active_filters[CSI_NUM_PLATFORMS];
-
-enum CS_EVENTS {CS_CREATED,
- CS_DELETED,
- CS_MODIFIED,
+#define CS_NUM_EVENTS 3
+enum CS_EVENTS {
+ CS_CREATED,
+ CS_DELETED,
+ CS_MODIFIED,
};
-static pthread_cond_t lifecycle_cond = PTHREAD_COND_INITIALIZER;
-static pthread_mutex_t lifecycle_mutex = PTHREAD_MUTEX_INITIALIZER;
-static bool lifecycle_enabled = 0;
-
-#define WAIT_TIME 60
-#define FAIL_WAIT_TIME 2
-
-struct dom_xml {
+typedef struct _csi_dom_xml_t csi_dom_xml_t;
+struct _csi_dom_xml_t {
char uuid[VIR_UUID_STRING_BUFLEN];
+ char *name;
char *xml;
- enum {DOM_OFFLINE,
- DOM_ONLINE,
- DOM_PAUSED,
- DOM_CRASHED,
- DOM_GONE,
- } state;
+ csi_dom_xml_t *next;
+ csi_dom_xml_t *prev;
+};
+
+typedef struct _csi_thread_data_t csi_thread_data_t;
+struct _csi_thread_data_t {
+ CMPI_THREAD_TYPE id;
+ int active_filters;
+ int dom_count;
+ csi_dom_xml_t *dom_list;
+ struct ind_args *args;
};
-static void free_dom_xml (struct dom_xml dom)
+static const CMPIBroker *_BROKER;
+static pthread_mutex_t lifecycle_mutex = PTHREAD_MUTEX_INITIALIZER;
+static bool lifecycle_enabled = false;
+static csi_thread_data_t csi_thread_data[CSI_NUM_PLATFORMS] = {{0}, {0}, {0}};
+
+/*
+ * Domain list manipulation
+ */
+static void csi_dom_xml_free(csi_dom_xml_t *dom)
{
- free(dom.xml);
+ free(dom->xml);
+ free(dom->name);
+ free(dom);
}
-static char *sys_name_from_xml(char *xml)
+static int csi_dom_xml_set(csi_dom_xml_t *dom, virDomainPtr dom_ptr, CMPIStatus *s)
{
- char *tmp = NULL;
- char *name = NULL;
- int rc;
+ const char *name;
- tmp = strstr(xml, "<name>");
- if (tmp == NULL)
- goto out;
+ name = virDomainGetName(dom_ptr);
+ if (name == NULL) {
+ cu_statusf(_BROKER, s,
+ CMPI_RC_ERR_FAILED,
+ "Failed to get domain name");
+ return -1;
+ }
- rc = sscanf(tmp, "<name>%a[^<]s</name>", &name);
- if (rc != 1)
- name = NULL;
+ dom->name = strdup(name);
+
+ /* xml */
+ dom->xml = virDomainGetXMLDesc(dom_ptr, VIR_DOMAIN_XML_SECURE);
+ if (dom->xml == NULL) {
+ cu_statusf(_BROKER, s,
+ CMPI_RC_ERR_FAILED,
+ "Failed to get xml desc");
+ return -1;
+ }
- out:
- return name;
+ return 0;
}
-static int dom_state(virDomainPtr dom)
+static csi_dom_xml_t *csi_dom_xml_new(virDomainPtr dom_ptr, CMPIStatus *s)
{
- virDomainInfo info;
- int ret;
+ int rc;
+ csi_dom_xml_t *dom;
- ret = virDomainGetInfo(dom, &info);
- if (ret != 0)
- return DOM_GONE;
+ dom = calloc(1, sizeof(*dom));
+ if (dom == NULL)
+ return NULL;
- switch (info.state) {
- case VIR_DOMAIN_NOSTATE:
- case VIR_DOMAIN_RUNNING:
- case VIR_DOMAIN_BLOCKED:
- return DOM_ONLINE;
+ /* uuid */
+ rc = virDomainGetUUIDString(dom_ptr, dom->uuid);
+ if (rc == -1) {
+ cu_statusf(_BROKER, s,
+ CMPI_RC_ERR_FAILED,
+ "Failed to get domain UUID");
+ goto error;
+ }
- case VIR_DOMAIN_PAUSED:
- return DOM_PAUSED;
+ if (csi_dom_xml_set(dom, dom_ptr, s) == -1)
+ goto error;
- case VIR_DOMAIN_SHUTOFF:
- return DOM_OFFLINE;
+ return dom;
- case VIR_DOMAIN_CRASHED:
- return DOM_CRASHED;
+ error:
+ csi_dom_xml_free(dom);
+ return NULL;
+}
- default:
- return DOM_GONE;
- };
+static void csi_thread_dom_list_append(csi_thread_data_t *thread,
+ csi_dom_xml_t *dom)
+{
+ /* empty list */
+ if (thread->dom_list == NULL) {
+ dom->next = dom->prev = dom;
+ thread->dom_list = dom;
+ goto end;
+ }
+
+ dom->next = thread->dom_list;
+ dom->prev = thread->dom_list->prev;
+
+ thread->dom_list->prev->next = dom;
+ thread->dom_list->prev = dom;
+
+ end:
+ thread->dom_count += 1;
}
-static CMPIStatus doms_to_xml(struct dom_xml **dom_xml_list,
- virDomainPtr *dom_ptr_list,
- int dom_ptr_count)
+static csi_dom_xml_t *csi_thread_dom_list_find(csi_thread_data_t *thread,
+ const char *uuid)
{
- int i;
- int rc;
- CMPIStatus s = {CMPI_RC_OK, NULL};
+ csi_dom_xml_t *dom;
- *dom_xml_list = calloc(dom_ptr_count, sizeof(struct dom_xml));
- for (i = 0; i < dom_ptr_count; i++) {
- rc = virDomainGetUUIDString(dom_ptr_list[i],
- (*dom_xml_list)[i].uuid);
- if (rc == -1) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Failed to get UUID");
- /* If any domain fails, we fail. */
- break;
- }
+ if (thread->dom_list == NULL)
+ return NULL;
- (*dom_xml_list)[i].xml = virDomainGetXMLDesc(dom_ptr_list[i],
- VIR_DOMAIN_XML_SECURE);
- if ((*dom_xml_list)[i].xml == NULL) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Failed to get xml desc");
- break;
- }
+ dom = thread->dom_list;
+
+ do {
+ if (STREQ(dom->uuid, uuid))
+ return dom;
- (*dom_xml_list)[i].state = dom_state(dom_ptr_list[i]);
+ dom = dom->next;
+ } while (dom != thread->dom_list);
+
+ return NULL;
+}
+
+static void csi_thread_dom_list_remove(csi_thread_data_t *thread,
+ csi_dom_xml_t *dom)
+{
+ if (dom->next == dom) { /* Only one node */
+ thread->dom_list = NULL;
+ } else {
+ if (thread->dom_list == dom) /* First node */
+ thread->dom_list = dom->next;
+
+ dom->prev->next = dom->next;
+ dom->next->prev = dom->prev;
}
-
- return s;
+
+ thread->dom_count -= 1;
+
+ csi_dom_xml_free(dom);
}
-static bool dom_changed(struct dom_xml prev_dom,
- struct dom_xml *cur_xml,
- int cur_count)
+static void csi_thread_dom_list_free(csi_thread_data_t *thread)
{
- int i;
- bool ret = false;
-
- for (i = 0; i < cur_count; i++) {
- if (strcmp(cur_xml[i].uuid, prev_dom.uuid) != 0)
- continue;
-
- if (strcmp(cur_xml[i].xml, prev_dom.xml) != 0) {
- CU_DEBUG("Domain config changed");
- ret = true;
- }
+ while(thread->dom_list != NULL)
+ csi_thread_dom_list_remove(thread, thread->dom_list);
+}
- if (prev_dom.state != cur_xml[i].state) {
- CU_DEBUG("Domain state changed");
- ret = true;
- }
+static void csi_free_thread_data(void *data)
+{
+ csi_thread_data_t *thread = (csi_thread_data_t *) data;
- break;
- }
-
- return ret;
+ if (data == NULL)
+ return;
+
+ csi_thread_dom_list_free(thread);
+ stdi_free_ind_args(&thread->args);
}
void set_source_inst_props(const CMPIBroker *broker,
- const CMPIContext *context,
- const CMPIObjectPath *ref,
- CMPIInstance *ind)
+ const CMPIContext *context,
+ const CMPIObjectPath *ref,
+ CMPIInstance *ind)
{
const char *host;
const char *hostccn;
@@ -225,7 +254,7 @@ static bool _do_indication(const CMPIBroker *broker,
CMPIInstance *prev_inst,
CMPIInstance *affected_inst,
int ind_type,
- char *prefix,
+ const char *prefix,
struct ind_args *args)
{
const char *ind_type_name = NULL;
@@ -254,10 +283,10 @@ static bool _do_indication(const CMPIBroker *broker,
ind_type_name,
args->ns);
- /* Generally report errors and hope to continue, since we have no one
+ /* Generally report errors and hope to continue, since we have no one
to actually return status to. */
if (ind == NULL) {
- CU_DEBUG("Failed to create ind, type '%s:%s_%s'",
+ CU_DEBUG("Failed to create ind, type '%s:%s_%s'",
args->ns,
prefix,
ind_type_name);
@@ -279,14 +308,15 @@ static bool _do_indication(const CMPIBroker *broker,
CU_DEBUG("problem getting affected_op: '%s'", s.msg);
goto out;
}
+
CMSetNameSpace(affected_op, args->ns);
uuid = CMGetProperty(affected_inst, "UUID", &s);
- CMSetProperty(ind, "IndicationIdentifier",
+ CMSetProperty(ind, "IndicationIdentifier",
(CMPIValue *)&(uuid.value), CMPI_string);
timestamp = CMNewDateTime(broker, &s);
- CMSetProperty(ind, "IndicationTime",
+ CMSetProperty(ind, "IndicationTime",
(CMPIValue *)×tamp, CMPI_dateTime);
if (ind_type == CS_MODIFIED) {
@@ -313,34 +343,6 @@ static bool _do_indication(const CMPIBroker *broker,
return ret;
}
-static bool wait_for_event(int wait_time)
-{
- struct timespec timeout;
- int ret;
-
-
- clock_gettime(CLOCK_REALTIME, &timeout);
- timeout.tv_sec += wait_time;
-
- ret = pthread_cond_timedwait(&lifecycle_cond,
- &lifecycle_mutex,
- &timeout);
-
- return true;
-}
-
-static bool dom_in_list(char *uuid, int count, struct dom_xml *list)
-{
- int i;
-
- for (i = 0; i < count; i++) {
- if (STREQ(uuid, list[i].uuid))
- return true;
- }
-
- return false;
-}
-
static bool set_instance_state(CMPIInstance *instance)
{
CMPIStatus s = {CMPI_RC_OK, NULL};
@@ -356,7 +358,7 @@ static bool set_instance_state(CMPIInstance *instance)
cim_state_other = CMNewString(_BROKER, "Guest destroyed", &s);
CMSetProperty(instance, "EnabledState",
(CMPIValue *)&cim_state, CMPI_uint16);
- CMSetProperty(instance, "OtherEnabledState",
+ CMSetProperty(instance, "OtherEnabledState",
(CMPIValue *)&cim_state_other, CMPI_string);
health_state = CIM_HEALTH_UNKNOWN;
@@ -382,13 +384,13 @@ static bool set_instance_state(CMPIInstance *instance)
req_state = CIM_STATE_UNKNOWN;
CMSetProperty(instance, "RequestedState",
(CMPIValue *)&req_state, CMPI_uint16);
-
+
return true;
}
-static bool create_deleted_guest_inst(char *xml,
- char *namespace,
- char *prefix,
+static bool create_deleted_guest_inst(const char *xml,
+ const char *namespace,
+ const char *prefix,
CMPIInstance **inst)
{
bool rc = false;
@@ -402,18 +404,18 @@ static bool create_deleted_guest_inst(char *xml,
goto out;
}
- s = instance_from_dominfo(_BROKER,
- namespace,
+ s = instance_from_dominfo(_BROKER,
+ namespace,
prefix,
- dominfo,
- inst);
+ dominfo,
+ inst);
if (s.rc != CMPI_RC_OK) {
CU_DEBUG("instance from domain info error: %s", s.msg);
goto out;
}
rc = set_instance_state(*inst);
- if (!rc)
+ if (!rc)
CU_DEBUG("Error setting instance state");
out:
@@ -422,14 +424,12 @@ static bool create_deleted_guest_inst(char *xml,
return rc;
}
-static bool async_ind(CMPIContext *context,
+static bool async_ind(struct ind_args *args,
int ind_type,
- struct dom_xml prev_dom,
- char *prefix,
- struct ind_args *args)
+ csi_dom_xml_t *dom,
+ const char *prefix)
{
bool rc = false;
- char *name = NULL;
char *cn = NULL;
CMPIObjectPath *op;
CMPIInstance *prev_inst;
@@ -441,13 +441,6 @@ static bool async_ind(CMPIContext *context,
return false;
}
- name = sys_name_from_xml(prev_dom.xml);
- CU_DEBUG("Name for system: '%s'", name);
- if (name == NULL) {
- rc = false;
- goto out;
- }
-
cn = get_typed_class(prefix, "ComputerSystem");
op = CMNewObjectPath(_BROKER, args->ns, cn, &s);
@@ -457,15 +450,32 @@ static bool async_ind(CMPIContext *context,
}
if (ind_type == CS_CREATED || ind_type == CS_MODIFIED) {
- s = get_domain_by_name(_BROKER, op, name, &affected_inst);
- if (s.rc != CMPI_RC_OK) {
+ s = get_domain_by_name(_BROKER, op, dom->name, &affected_inst);
+
+ /* If domain is not found, we create the instance from the data
+ previously stored */
+ if (s.rc == CMPI_RC_ERR_NOT_FOUND) {
+ rc = create_deleted_guest_inst(dom->xml,
+ args->ns,
+ prefix,
+ &affected_inst);
+ if (!rc) {
+ CU_DEBUG("Could not recreate guest instance");
+ goto out;
+ }
+
+ s.rc = CMPI_RC_OK;
+ }
+
+ if (s.rc != CMPI_RC_OK) {
CU_DEBUG("domain by name error");
goto out;
}
+
} else if (ind_type == CS_DELETED) {
- rc = create_deleted_guest_inst(prev_dom.xml,
- args->ns,
- prefix,
+ rc = create_deleted_guest_inst(dom->xml,
+ args->ns,
+ prefix,
&affected_inst);
if (!rc) {
CU_DEBUG("Could not recreate guest instance");
@@ -476,52 +486,134 @@ static bool async_ind(CMPIContext *context,
goto out;
}
- /* FIXME: We are unable to get the previous CS instance after it has
+ /* FIXME: We are unable to get the previous CS instance after it has
been modified. Consider keeping track of the previous
- state in the place we keep track of the requested state */
+ state in the place we keep track of the requested state */
prev_inst = affected_inst;
- CMSetProperty(affected_inst, "Name",
- (CMPIValue *)name, CMPI_chars);
+ CMSetProperty(affected_inst, "Name",
+ (CMPIValue *) dom->name, CMPI_chars);
CMSetProperty(affected_inst, "UUID",
- (CMPIValue *)prev_dom.uuid, CMPI_chars);
+ (CMPIValue *) dom->uuid, CMPI_chars);
- rc = _do_indication(_BROKER, context, prev_inst, affected_inst,
+ rc = _do_indication(_BROKER, args->context, prev_inst, affected_inst,
ind_type, prefix, args);
out:
free(cn);
- free(name);
return rc;
}
-static int platform_from_class(const char *cn)
+static int update_domain_list(virConnectPtr conn, csi_thread_data_t *thread)
{
- if (STARTS_WITH(cn, "Xen"))
- return CSI_XEN;
- else if (STARTS_WITH(cn, "KVM"))
- return CSI_KVM;
- else if (STARTS_WITH(cn, "LXC"))
- return CSI_LXC;
- else
- return -1;
+ virDomainPtr *dom_ptr_list;
+ csi_dom_xml_t *dom;
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ int i, count;
+
+ csi_thread_dom_list_free(thread);
+
+ count = get_domain_list(conn, &dom_ptr_list);
+
+ for (i = 0; i < count; i++) {
+ dom = csi_dom_xml_new(dom_ptr_list[i], &s);
+ if (dom == NULL) {
+ CU_DEBUG("Failed to get domain info %s", s.msg);
+ break;
+ }
+
+ csi_thread_dom_list_append(thread, dom);
+ }
+
+ free_domain_list(dom_ptr_list, count);
+ free(dom_ptr_list);
+
+ return s.rc;
+}
+
+static int csi_domain_event_cb(virConnectPtr conn,
+ virDomainPtr dom,
+ int event,
+ int detail,
+ void *data)
+{
+ int cs_event = CS_MODIFIED;
+ csi_thread_data_t *thread = (csi_thread_data_t *) data;
+ csi_dom_xml_t *dom_xml = NULL;
+ char *prefix = class_prefix_name(thread->args->classname);
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+
+ CU_DEBUG("Event: Domain %s(%d) event: %d detail: %d\n",
+ virDomainGetName(dom), virDomainGetID(dom), event, detail);
+
+ switch (event) {
+ case VIR_DOMAIN_EVENT_DEFINED:
+ if (detail == VIR_DOMAIN_EVENT_DEFINED_ADDED) {
+ CU_DEBUG("Domain defined");
+ cs_event = CS_CREATED;
+ dom_xml = csi_dom_xml_new(dom, &s);
+ } else if (detail == VIR_DOMAIN_EVENT_DEFINED_UPDATED) {
+ CU_DEBUG("Domain modified");
+ cs_event = CS_MODIFIED;
+ }
+
+ break;
+
+ case VIR_DOMAIN_EVENT_UNDEFINED:
+ CU_DEBUG("Domain undefined");
+ cs_event = CS_DELETED;
+ break;
+
+ default: /* STARTED, SUSPENDED, RESUMED, STOPPED, SHUTDOWN */
+ CU_DEBUG("Domain modified");
+ cs_event = CS_MODIFIED;
+ break;
+ }
+
+ if (cs_event != CS_CREATED) {
+ char uuid[VIR_UUID_STRING_BUFLEN] = {0};
+ virDomainGetUUIDString(dom, &uuid[0]);
+ dom_xml = csi_thread_dom_list_find(thread, uuid);
+ }
+
+ if (dom_xml == NULL) {
+ CU_DEBUG("Domain not found in current list");
+ goto end;
+ }
+
+ async_ind(thread->args, cs_event, dom_xml, prefix);
+
+ /* Update the domain list accordingly */
+ if (event == VIR_DOMAIN_EVENT_DEFINED) {
+ if (detail == VIR_DOMAIN_EVENT_DEFINED_ADDED) {
+ csi_thread_dom_list_append(thread, dom_xml);
+ } else if (detail == VIR_DOMAIN_EVENT_DEFINED_UPDATED) {
+ free(dom_xml->name);
+ free(dom_xml->xml);
+ csi_dom_xml_set(dom_xml, dom, &s);
+ }
+ } else if (event == VIR_DOMAIN_EVENT_DEFINED &&
+ detail == VIR_DOMAIN_EVENT_UNDEFINED_REMOVED) {
+ csi_thread_dom_list_remove(thread, dom_xml);
+ }
+
+ end:
+ free(prefix);
+ return 0;
}
static CMPI_THREAD_RETURN lifecycle_thread(void *params)
{
- struct ind_args *args = (struct ind_args *)params;
- CMPIContext *context = args->context;
- CMPIStatus s;
- int prev_count;
- int cur_count;
- virDomainPtr *tmp_list;
- struct dom_xml *cur_xml = NULL;
- struct dom_xml *prev_xml = NULL;
- virConnectPtr conn;
+ csi_thread_data_t *thread = (csi_thread_data_t *) params;
+ struct ind_args *args = thread->args;
char *prefix = class_prefix_name(args->classname);
- int platform = platform_from_class(args->classname);
- if (prefix == NULL || platform == -1)
+ virConnectPtr conn;
+
+ CMPIStatus s;
+ int cb_id;
+
+ if (prefix == NULL)
goto init_out;
conn = connect_by_classname(_BROKER, args->classname, &s);
@@ -531,86 +623,66 @@ static CMPI_THREAD_RETURN lifecycle_thread(void *params)
goto conn_out;
}
- pthread_mutex_lock(&lifecycle_mutex);
-
- CBAttachThread(_BROKER, context);
+ /* register callback */
+ cb_id = virConnectDomainEventRegisterAny(conn, NULL,
+ VIR_DOMAIN_EVENT_ID_LIFECYCLE,
+ VIR_DOMAIN_EVENT_CALLBACK(csi_domain_event_cb),
+ params, csi_free_thread_data);
- prev_count = get_domain_list(conn, &tmp_list);
- s = doms_to_xml(&prev_xml, tmp_list, prev_count);
- if (s.rc != CMPI_RC_OK)
- CU_DEBUG("doms_to_xml failed. Attempting to continue.");
- free_domain_list(tmp_list, prev_count);
- free(tmp_list);
-
- CU_DEBUG("Entering CSI event loop (%s)", prefix);
- while (active_filters[platform] > 0) {
- int i;
- bool res;
- bool failure = false;
-
- cur_count = get_domain_list(conn, &tmp_list);
- s = doms_to_xml(&cur_xml, tmp_list, cur_count);
- if (s.rc != CMPI_RC_OK) {
- CU_DEBUG("doms_to_xml failed. retry in %d seconds",
- FAIL_WAIT_TIME);
- failure = true;
- goto fail;
- }
-
- free_domain_list(tmp_list, cur_count);
- free(tmp_list);
-
- for (i = 0; i < cur_count; i++) {
- res = dom_in_list(cur_xml[i].uuid, prev_count, prev_xml);
- if (!res)
- async_ind(context, CS_CREATED,
- cur_xml[i], prefix, args);
-
- }
-
- for (i = 0; i < prev_count; i++) {
- res = dom_in_list(prev_xml[i].uuid, cur_count, cur_xml);
- if (!res)
- async_ind(context, CS_DELETED,
- prev_xml[i], prefix, args);
- }
+ if (cb_id == -1) {
+ CU_DEBUG("Failed to register domain event watch for '%s'",
+ args->classname)
+ goto cb_out;
+ }
- for (i = 0; i < prev_count; i++) {
- res = dom_changed(prev_xml[i], cur_xml, cur_count);
- if (res) {
- async_ind(context, CS_MODIFIED,
- prev_xml[i], prefix, args);
+ CBAttachThread(_BROKER, args->context);
- }
- free_dom_xml(prev_xml[i]);
- }
+ /* Get currently defined domains */
+ if (update_domain_list(conn, thread) != CMPI_RC_OK)
+ goto end;
- fail:
- if (failure) {
- wait_for_event(FAIL_WAIT_TIME);
- } else {
- free(prev_xml);
- prev_xml = cur_xml;
- prev_count = cur_count;
- wait_for_event(WAIT_TIME);
+ CU_DEBUG("Entering CSI event loop (%s)", prefix);
+ while (thread->active_filters > 0) {
+ if (virEventRunDefaultImpl() < 0) {
+ virErrorPtr err = virGetLastError();
+ CU_DEBUG("Failed to run event loop: %s\n",
+ err && err->message ? err->message : "Unknown error");
}
}
CU_DEBUG("Exiting CSI event loop (%s)", prefix);
- thread_id[platform] = 0;
+ CBDetachThread(_BROKER, args->context);
+ end:
+ virConnectDomainEventDeregisterAny(conn, cb_id);
- pthread_mutex_unlock(&lifecycle_mutex);
- stdi_free_ind_args(&args);
+ cb_out:
+
+ thread->id = 0;
+ thread->active_filters = 0;
+
+ if (thread->args != NULL)
+ stdi_free_ind_args(&thread->args);
conn_out:
virConnectClose(conn);
init_out:
free(prefix);
+ return (CMPI_THREAD_RETURN) 0;
+}
- return NULL;
+static int platform_from_class(const char *cn)
+{
+ if (STARTS_WITH(cn, "Xen"))
+ return CSI_XEN;
+ else if (STARTS_WITH(cn, "KVM"))
+ return CSI_KVM;
+ else if (STARTS_WITH(cn, "LXC"))
+ return CSI_LXC;
+ else
+ return -1;
}
static CMPIStatus ActivateFilter(CMPIIndicationMI* mi,
@@ -622,17 +694,25 @@ static CMPIStatus ActivateFilter(CMPIIndicationMI* mi,
{
CMPIStatus s = {CMPI_RC_OK, NULL};
struct std_indication_ctx *_ctx;
- struct ind_args *args;
+ struct ind_args *args = NULL;
int platform;
+ bool error = false;
+ csi_thread_data_t *thread = NULL;
+ static int events_registered = 0;
CU_DEBUG("ActivateFilter for %s", CLASSNAME(op));
pthread_mutex_lock(&lifecycle_mutex);
+ if (events_registered == 0) {
+ events_registered = 1;
+ virEventRegisterDefaultImpl();
+ }
+
_ctx = (struct std_indication_ctx *)mi->hdl;
if (CMIsNullObject(op)) {
- cu_statusf(_BROKER, &s,
+ cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"No ObjectPath given");
goto out;
@@ -647,13 +727,17 @@ static CMPIStatus ActivateFilter(CMPIIndicationMI* mi,
goto out;
}
- if (thread_id[platform] == 0) {
- args = malloc(sizeof(struct ind_args));
+ thread = &csi_thread_data[platform];
+ thread->active_filters += 1;
+
+ if (thread->id == 0) {
+ args = malloc(sizeof(*args));
if (args == NULL) {
CU_DEBUG("Failed to allocate ind_args");
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Unable to allocate ind_args");
+ error = true;
goto out;
}
@@ -663,7 +747,7 @@ static CMPIStatus ActivateFilter(CMPIIndicationMI* mi,
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Unable to create thread context");
- free(args);
+ error = true;
goto out;
}
@@ -671,15 +755,17 @@ static CMPIStatus ActivateFilter(CMPIIndicationMI* mi,
args->classname = strdup(CLASSNAME(op));
args->_ctx = _ctx;
- active_filters[platform] += 1;
-
- thread_id[platform] = _BROKER->xft->newThread(lifecycle_thread,
- args,
- 0);
- } else
- active_filters[platform] += 1;
+ thread->args = args;
+ thread->id = _BROKER->xft->newThread(lifecycle_thread,
+ thread, 0);
+ }
out:
+ if (error == true) {
+ thread->active_filters -= 1;
+ free(args);
+ }
+
pthread_mutex_unlock(&lifecycle_mutex);
return s;
@@ -705,11 +791,11 @@ static CMPIStatus DeActivateFilter(CMPIIndicationMI* mi,
goto out;
}
+
pthread_mutex_lock(&lifecycle_mutex);
- active_filters[platform] -= 1;
+ csi_thread_data[platform].active_filters -= 1;
pthread_mutex_unlock(&lifecycle_mutex);
- pthread_cond_signal(&lifecycle_cond);
out:
return s;
}
@@ -736,13 +822,6 @@ static _EI_RTYPE DisableIndications(CMPIIndicationMI* mi,
_EI_RET();
}
-static CMPIStatus trigger_indication(const CMPIContext *context)
-{
- CU_DEBUG("triggered");
- pthread_cond_signal(&lifecycle_cond);
- return(CMPIStatus){CMPI_RC_OK, NULL};
-}
-
DECLARE_FILTER(xen_created, "Xen_ComputerSystemCreatedIndication");
DECLARE_FILTER(xen_deleted, "Xen_ComputerSystemDeletedIndication");
DECLARE_FILTER(xen_modified, "Xen_ComputerSystemModifiedIndication");
@@ -766,126 +845,7 @@ static struct std_ind_filter *filters[] = {
NULL,
};
-static CMPIInstance *get_prev_inst(const CMPIBroker *broker,
- const CMPIInstance *ind,
- CMPIStatus *s)
-{
- CMPIData data;
- CMPIInstance *prev_inst = NULL;
-
- data = CMGetProperty(ind, "PreviousInstance", s);
- if (s->rc != CMPI_RC_OK || CMIsNullValue(data)) {
- cu_statusf(broker, s,
- CMPI_RC_ERR_NO_SUCH_PROPERTY,
- "Unable to get PreviousInstance of the indication");
- goto out;
- }
-
- if (data.type != CMPI_instance) {
- cu_statusf(broker, s,
- CMPI_RC_ERR_TYPE_MISMATCH,
- "Indication SourceInstance is of unexpected type");
- goto out;
- }
-
- prev_inst = data.value.inst;
-
- out:
- return prev_inst;
-}
-
-static CMPIStatus raise_indication(const CMPIBroker *broker,
- const CMPIContext *ctx,
- const CMPIObjectPath *ref,
- const CMPIInstance *ind)
-{
- CMPIStatus s = {CMPI_RC_OK, NULL};
- CMPIInstance *prev_inst;
- CMPIInstance *src_inst;
- CMPIObjectPath *_ref = NULL;
- struct std_indication_ctx *_ctx = NULL;
- struct ind_args *args = NULL;
- char *prefix = NULL;
- bool rc;
-
- if (!lifecycle_enabled) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "CSI not enabled, skipping indication delivery");
- goto out;
- }
-
- prev_inst = get_prev_inst(broker, ind, &s);
- if (s.rc != CMPI_RC_OK || CMIsNullObject(prev_inst))
- goto out;
-
- _ref = CMGetObjectPath(prev_inst, &s);
- if (s.rc != CMPI_RC_OK) {
- cu_statusf(broker, &s,
- CMPI_RC_ERR_FAILED,
- "Unable to get a reference to the guest");
- goto out;
- }
-
- /* FIXME: This is a Pegasus work around. Pegsus loses the namespace
- when an ObjectPath is pulled from an instance */
- if (STREQ(NAMESPACE(_ref), ""))
- CMSetNameSpace(_ref, "root/virt");
-
- s = get_domain_by_ref(broker, _ref, &src_inst);
- if (s.rc != CMPI_RC_OK || CMIsNullObject(src_inst))
- goto out;
-
- _ctx = malloc(sizeof(struct std_indication_ctx));
- if (_ctx == NULL) {
- cu_statusf(broker, &s,
- CMPI_RC_ERR_FAILED,
- "Unable to allocate indication context");
- goto out;
- }
-
- _ctx->brkr = broker;
- _ctx->handler = NULL;
- _ctx->filters = filters;
- _ctx->enabled = lifecycle_enabled;
-
- args = malloc(sizeof(struct ind_args));
- if (args == NULL) {
- cu_statusf(broker, &s,
- CMPI_RC_ERR_FAILED,
- "Unable to allocate ind_args");
- goto out;
- }
-
- args->ns = strdup(NAMESPACE(_ref));
- args->classname = strdup(CLASSNAME(_ref));
- args->_ctx = _ctx;
-
- prefix = class_prefix_name(args->classname);
-
- rc = _do_indication(broker, ctx, prev_inst, src_inst,
- CS_MODIFIED, prefix, args);
-
- if (!rc) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Unable to generate indication");
- }
-
- out:
- if (args != NULL)
- stdi_free_ind_args(&args);
-
- if (_ctx != NULL)
- free(_ctx);
-
- free(prefix);
- return s;
-}
-
static struct std_indication_handler csi = {
- .raise_fn = raise_indication,
- .trigger_fn = trigger_indication,
.activate_fn = ActivateFilter,
.deactivate_fn = DeActivateFilter,
.enable_fn = EnableIndications,
@@ -896,10 +856,10 @@ DEFAULT_IND_CLEANUP();
DEFAULT_AF();
DEFAULT_MP();
-STDI_IndicationMIStub(,
+STDI_IndicationMIStub(,
Virt_ComputerSystemIndicationProvider,
_BROKER,
- libvirt_cim_init(),
+ libvirt_cim_init(),
&csi,
filters);
diff --git a/src/Virt_ComputerSystemIndication.h b/src/Virt_ComputerSystemIndication.h
index 0f8f1b7..594c3ed 100644
--- a/src/Virt_ComputerSystemIndication.h
+++ b/src/Virt_ComputerSystemIndication.h
@@ -24,11 +24,6 @@
#include <cmpidt.h>
#include <stdbool.h>
-bool cs_lifecycle_indication(const CMPIBroker *broker,
- const CMPIContext *ctx,
- const CMPIObjectPath *newsystem,
- char *type);
-
void set_source_inst_props(const CMPIBroker *broker,
const CMPIContext *context,
const CMPIObjectPath *ref,
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
index 4d26429..46bc9b5 100644
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -1894,7 +1894,7 @@ static CMPIStatus raise_rasd_indication(const CMPIContext *context,
CMPIObjectPath *op = NULL;
int i;
- CU_DEBUG("raise_rasd_indication");
+ CU_DEBUG("raise_rasd_indication %s", base_type);
type = get_typed_class(CLASSNAME(ref), base_type);
@@ -2105,22 +2105,6 @@ static CMPIInstance *create_system(const CMPIContext *context,
return inst;
}
-static bool trigger_indication(const CMPIContext *context,
- const char *base_type,
- const CMPIObjectPath *ref)
-{
- char *type;
- CMPIStatus s;
-
- type = get_typed_class(CLASSNAME(ref), base_type);
-
- s = stdi_trigger_indication(_BROKER, context, type, NAMESPACE(ref));
-
- free(type);
-
- return s.rc == CMPI_RC_OK;
-}
-
static CMPIStatus define_system(CMPIMethodMI *self,
const CMPIContext *context,
const CMPIResult *results,
@@ -2156,9 +2140,6 @@ static CMPIStatus define_system(CMPIMethodMI *self,
CMAddArg(argsout, "ResultingSystem", &result, CMPI_ref);
}
- trigger_indication(context,
- "ComputerSystemCreatedIndication",
- reference);
out:
if (s.rc == CMPI_RC_OK)
rc = CIM_SVPC_RETURN_COMPLETED;
@@ -2261,9 +2242,6 @@ error:
NULL,
reference,
&list);
- trigger_indication(context,
- "ComputerSystemDeletedIndication",
- reference);
}
virDomainFree(dom);
@@ -2345,12 +2323,8 @@ static CMPIStatus update_system_settings(const CMPIContext *context,
connect_and_create(xml, ref, &s);
}
- if (s.rc == CMPI_RC_OK) {
+ if (s.rc == CMPI_RC_OK)
set_autostart(vssd, ref, dom);
- trigger_indication(context,
- "ComputerSystemModifiedIndication",
- ref);
- }
out:
free(xml);
--
1.7.4.4
2
2
I'm happy announce the release of libvirt-cim-0.6.
The new release is available at:
ftp://libvirt.org/libvirt-cim/libvirt-cim-0.6.0.tar.gz
libvirt-cim-0.6:
* ComputerSystemIndication: Support libvirt domain events (Eduardo Lima
(Etrunko))
* Network QoS Patch2 (Gareth S. Bestor)
* cpu cgroup patch 2 (Gareth S. Bestor)
* Build: Make 'make distcheck' happy (Eduardo Lima (Etrunko))
* Build: Remove tests subdirs from source (Eduardo Lima (Etrunko)
--
Chip Vincent
Open Virtualization
IBM Linux Technology Center
cvincent(a)linux.vnet.ibm.com
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim
1
0