[PATCH v2] Fix AppliedFilterList creation and deletion
by Chip Vincent
From: Chip Vincent <cvincent(a)us.ibm.com>
Fixes many small issues with the current AppliedFilterList provider.
1) Fix Create to properly return a complete object path and fix Delete to
properly parse that path.
2) Persist applied filer rules. Since it's not possible to dyanmically update
a single device, I've changed the code to modify and re-define the VM to
essentially add/remove ACL filter associations.
I also updated the code to minimize domain/device parsing overhead. For
some strange reason, our internal APIs sometimes take a virDomainPtr and
other times a struct domain * forcing providers who work with domains
*and* devices to parse everything twice. Until the internal APIs are
cleaned up, I simply parse everything once and then fetch the device
manually from the struct domain *.
3) Add VIR_DOMAIN_XML_INACTIVE to virDomainGetXML(). By default, libvirt only
returns the XML of the running domain. We need to fetch the *stored* XML
that will be used for the next boot so that all changes made while the VM
is running are preserved.
Changes from v1:
- Fix leak and other comments
- Fix all cases virDomainGetXML()
- Fix NestedFilterList Create/Delete instance
Signed-off-by: Chip Vincent <cvincent(a)us.ibm.com>
---
libxkutil/device_parsing.c | 6 ++-
src/Virt_AppliedFilterList.c | 97 +++++++++++++++++++----------------
src/Virt_ComputerSystem.c | 3 +-
src/Virt_ComputerSystemIndication.c | 3 +-
src/Virt_FilterList.c | 5 ++-
src/Virt_NestedFilterList.c | 13 ++++-
src/Virt_VSMigrationService.c | 3 +-
7 files changed, 78 insertions(+), 52 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index a1e8d6c..ff86f2a 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -996,7 +996,8 @@ int get_devices(virDomainPtr dom, struct virt_device **list, int type)
char *xml;
int ret;
- xml = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_SECURE);
+ xml = virDomainGetXMLDesc(dom,
+ VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE);
if (xml == NULL)
return 0;
@@ -1241,7 +1242,8 @@ int get_dominfo(virDomainPtr dom, struct domain **dominfo)
char *xml;
int ret;
int start;
- xml = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_SECURE);
+ xml = virDomainGetXMLDesc(dom,
+ VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE);
if (xml == NULL)
return 0;
diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c
index bc31c14..538adf4 100644
--- a/src/Virt_AppliedFilterList.c
+++ b/src/Virt_AppliedFilterList.c
@@ -97,67 +97,60 @@ static CMPIrc cu_get_ref_path(const CMPIObjectPath *reference,
if ((s.rc != CMPI_RC_OK) || CMIsNullValue(value))
return CMPI_RC_ERR_NO_SUCH_PROPERTY;
- /* how to parse and object path? */
+ if ((value.type != CMPI_ref) || CMIsNullObject(value.value.ref))
+ return CMPI_RC_ERR_TYPE_MISMATCH;
+
+ *_reference = value.value.ref;
return CMPI_RC_OK;
}
-/* TODO: Port to libxkutil/device_parsing.c */
-static int update_device(virDomainPtr dom,
- struct virt_device *dev)
+static int update_domain(virConnectPtr conn,
+ struct domain *dominfo)
{
-#if LIBVIR_VERSION_NUMBER > 8000
char *xml = NULL;
- int flags = VIR_DOMAIN_DEVICE_MODIFY_CURRENT |
- VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
- int ret = 0;
+ virDomainPtr dom = NULL;
- xml = device_to_xml(dev);
+ xml = system_to_xml(dominfo);
if (xml == NULL) {
- CU_DEBUG("Failed to get XML for device '%s'", dev->id);
+ CU_DEBUG("Failed to get XML from domain %s", dominfo->name);
goto out;
}
- if (virDomainUpdateDeviceFlags(dom, xml, flags) != 0) {
- CU_DEBUG("Failed to dynamically update device");
+ dom = virDomainDefineXML(conn, xml);
+ if (dom == NULL) {
+ CU_DEBUG("Failed to update domain %s", dominfo->name);
goto out;
}
- ret = 1;
out:
free(xml);
+ virDomainFree(dom);
- return ret;
-#else
return 0;
-#endif
}
-/* TODO: Port to libxkutil/device_parsing.c */
-static int get_device_by_devid(virDomainPtr dom,
+static int get_device_by_devid(struct domain *dominfo,
const char *devid,
- int type,
struct virt_device **dev)
{
- int i, ret = 0;
- struct virt_device *devices = NULL;
- int count = get_devices(dom, &devices, type);
+ int i;
+ struct virt_device *devices = dominfo->dev_net;
+ int count = dominfo->dev_net_ct;
+
+ if (dev == NULL)
+ return 0;
for (i = 0; i < count; i++) {
if (STREQC(devid, devices[i].id)) {
CU_DEBUG("Found '%s'", devices[i].id);
- *dev = virt_device_dup(&devices[i]);
- if (*dev != NULL)
- ret = 1;
-
- break;
+ *dev = &devices[i];
+ return 0;
}
}
- cleanup_virt_devices(&devices, count);
-
- return ret;
+ return 1;
}
/**
@@ -425,6 +418,8 @@ static CMPIStatus CreateInstance(
struct virt_device *device = NULL;
virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
+ struct domain *dominfo = NULL;
+ CMPIObjectPath *_reference = NULL;
conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s);
if (conn == NULL)
@@ -487,8 +482,12 @@ static CMPIStatus CreateInstance(
goto out;
}
- get_device_by_devid(dom, net_name, CIM_RES_TYPE_NET, &device);
- if (device == NULL) {
+ if (get_dominfo(dom, &dominfo) == 0) {
+ CU_DEBUG("Failed to get dominfo");
+ goto out;
+ }
+
+ if (get_device_by_devid(dominfo, net_name, &device) != 0) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Dependent.Name object does not exist");
@@ -502,14 +501,19 @@ static CMPIStatus CreateInstance(
device->dev.net.filter_ref = strdup(filter_name);
- if (update_device(dom, device) == 0) {
+ if (update_domain(conn, dominfo) != 0) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Failed to update device");
+ "Failed to update domain");
goto out;
}
- CMReturnObjectPath(results, reference);
+ /* create new object path */
+ _reference = CMClone(reference, NULL);
+ CMAddKey(_reference, "Antecedent", (CMPIValue *)&antecedent, CMPI_ref);
+ CMAddKey(_reference, "Dependent", (CMPIValue *)&dependent, CMPI_ref);
+
+ CMReturnObjectPath(results, _reference);
CU_DEBUG("CreateInstance complete");
out:
@@ -542,6 +546,7 @@ static CMPIStatus DeleteInstance(
struct virt_device *device = NULL;
virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
+ struct domain *dominfo = NULL;
conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s);
if (conn == NULL)
@@ -557,7 +562,7 @@ static CMPIStatus DeleteInstance(
goto out;
}
- if (cu_get_str_path(reference, "DeviceID",
+ if (cu_get_str_path(antecedent, "DeviceID",
&device_name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -573,7 +578,7 @@ static CMPIStatus DeleteInstance(
goto out;
}
- if (cu_get_str_path(reference, "Name",
+ if (cu_get_str_path(dependent, "Name",
&filter_name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -585,7 +590,7 @@ static CMPIStatus DeleteInstance(
if (filter == NULL) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Antecedent.Name object does not exist");
+ "Dependent.Name object does not exist");
goto out;
}
@@ -600,11 +605,15 @@ static CMPIStatus DeleteInstance(
goto out;
}
- get_device_by_devid(dom, net_name, CIM_RES_TYPE_NET, &device);
- if (device == NULL) {
+ if (get_dominfo(dom, &dominfo) == 0) {
+ CU_DEBUG("Failed to get dominfo");
+ goto out;
+ }
+
+ if (get_device_by_devid(dominfo, net_name, &device) != 0) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Dependent.Name object does not exist");
+ "Antecedent.Name object does not exist");
goto out;
}
@@ -613,14 +622,14 @@ static CMPIStatus DeleteInstance(
device->dev.net.filter_ref = NULL;
}
- if (update_device(dom, device) == 0) {
+ if (update_domain(conn, dominfo) != 0) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Failed to update device");
+ "Failed to update domain");
goto out;
}
- CU_DEBUG("CreateInstance complete");
+ CU_DEBUG("DeleteInstance complete");
out:
free(domain_name);
diff --git a/src/Virt_ComputerSystem.c b/src/Virt_ComputerSystem.c
index 582253a..e6c7e55 100644
--- a/src/Virt_ComputerSystem.c
+++ b/src/Virt_ComputerSystem.c
@@ -926,7 +926,8 @@ static CMPIStatus domain_reset(virDomainPtr dom)
return s;
}
- xml = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_SECURE);
+ xml = virDomainGetXMLDesc(dom,
+ VIR_DOMAIN_XML_INACTIVE |VIR_DOMAIN_XML_SECURE);
if (xml == NULL) {
CU_DEBUG("Unable to retrieve domain XML");
virt_set_status(_BROKER, &s,
diff --git a/src/Virt_ComputerSystemIndication.c b/src/Virt_ComputerSystemIndication.c
index eb1a71c..6ef2ddc 100644
--- a/src/Virt_ComputerSystemIndication.c
+++ b/src/Virt_ComputerSystemIndication.c
@@ -107,7 +107,8 @@ static int csi_dom_xml_set(csi_dom_xml_t *dom, virDomainPtr dom_ptr, CMPIStatus
dom->name = strdup(name);
/* xml */
- dom->xml = virDomainGetXMLDesc(dom_ptr, VIR_DOMAIN_XML_SECURE);
+ dom->xml = virDomainGetXMLDesc(dom_ptr,
+ VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE);
if (dom->xml == NULL) {
cu_statusf(_BROKER, s,
CMPI_RC_ERR_FAILED,
diff --git a/src/Virt_FilterList.c b/src/Virt_FilterList.c
index 35d18a9..5b1b6e8 100644
--- a/src/Virt_FilterList.c
+++ b/src/Virt_FilterList.c
@@ -358,7 +358,10 @@ static CMPIStatus DeleteInstance(
goto out;
}
- delete_filter(conn, filter);
+ if (delete_filter(conn, filter) != 0) {
+ CU_DEBUG("Failed to delete filter %s", filter->name);
+ goto out;
+ }
out:
cleanup_filters(&filter, 1);
diff --git a/src/Virt_NestedFilterList.c b/src/Virt_NestedFilterList.c
index 894cd7c..b72c582 100644
--- a/src/Virt_NestedFilterList.c
+++ b/src/Virt_NestedFilterList.c
@@ -98,7 +98,10 @@ static CMPIrc cu_get_ref_path(const CMPIObjectPath *reference,
if ((s.rc != CMPI_RC_OK) || CMIsNullValue(value))
return CMPI_RC_ERR_NO_SUCH_PROPERTY;
- /* how to parse and object path? */
+ if ((value.type != CMPI_ref) || CMIsNullObject(value.value.ref))
+ return CMPI_RC_ERR_TYPE_MISMATCH;
+
+ *_reference = value.value.ref;
return CMPI_RC_OK;
}
@@ -305,6 +308,7 @@ static CMPIStatus CreateInstance(
const char *child_name = NULL;
struct acl_filter *child_filter = NULL;
virConnectPtr conn = NULL;
+ CMPIObjectPath *_reference = NULL;
CU_DEBUG("Reference = %s", REF2STR(reference));
@@ -383,6 +387,11 @@ static CMPIStatus CreateInstance(
goto out;
}
+ /* create new object path */
+ _reference = CMClone(reference, NULL);
+ CMAddKey(_reference, "Antecedent", (CMPIValue *)&antecedent, CMPI_ref);
+ CMAddKey(_reference, "Dependent", (CMPIValue *)&dependent, CMPI_ref);
+
CMReturnObjectPath(results, reference);
CU_DEBUG("CreateInstance completed");
@@ -475,7 +484,7 @@ static CMPIStatus DeleteInstance(
goto out;
}
- CU_DEBUG("CreateInstance completed");
+ CU_DEBUG("DeleteInstance completed");
out:
cleanup_filters(&parent_filter, 1);
diff --git a/src/Virt_VSMigrationService.c b/src/Virt_VSMigrationService.c
index d393787..76e3d25 100644
--- a/src/Virt_VSMigrationService.c
+++ b/src/Virt_VSMigrationService.c
@@ -1070,7 +1070,8 @@ static CMPIStatus prepare_migrate(virDomainPtr dom,
{
CMPIStatus s = {CMPI_RC_OK, NULL};
- *xml = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_SECURE);
+ *xml = virDomainGetXMLDesc(dom,
+ VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE);
if (*xml == NULL) {
virt_set_status(_BROKER, &s,
--
1.7.1
12 years, 10 months
[PATCH] Fix AppliedFilterList creation and deletion
by Chip Vincent
From: Chip Vincent <cvincent(a)us.ibm.com>
Fixes many small issues with the current AppliedFilterList provider.
1) Fix Create to properly return a complete object path and fix Delete to
properly parse that path.
2) Persist applied filer rules. Since it's not possible to dyanmically update
a single device, I've changed the code to modify and re-define the VM to
essentially add/remove ACL filter associations.
I also updated the code to minimize domain/device parsing overhead. For
some strange reason, our internal APIs sometimes take a virDomainPtr and
other times a struct domain * forcing providers who work with domains
*and* devices to parse everything twice. Until the internal APIs are
cleaned up, I simply parse everything once and then fetch the device
manually from the struct domain *.
3) Add VIR_DOMAIN_XML_INACTIVE to virDomainGetXML(). By default, libvirt only
returns the XML of the running domain. We need to fetch the *stored* XML
that will be used for the next boot so that all changes made while the VM
is running are preserved.
Signed-off-by: Chip Vincent <cvincent(a)us.ibm.com>
---
libxkutil/device_parsing.c | 3 +-
src/Virt_AppliedFilterList.c | 99 +++++++++++++++++++++++-------------------
src/Virt_FilterList.c | 5 ++-
3 files changed, 60 insertions(+), 47 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index a1e8d6c..238aa72 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -996,7 +996,8 @@ int get_devices(virDomainPtr dom, struct virt_device **list, int type)
char *xml;
int ret;
- xml = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_SECURE);
+ xml = virDomainGetXMLDesc(dom,
+ VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE);
if (xml == NULL)
return 0;
diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c
index bc31c14..892a90c 100644
--- a/src/Virt_AppliedFilterList.c
+++ b/src/Virt_AppliedFilterList.c
@@ -97,66 +97,59 @@ static CMPIrc cu_get_ref_path(const CMPIObjectPath *reference,
if ((s.rc != CMPI_RC_OK) || CMIsNullValue(value))
return CMPI_RC_ERR_NO_SUCH_PROPERTY;
- /* how to parse and object path? */
+ if ((value.type != CMPI_ref) || CMIsNullObject(value.value.ref))
+ return CMPI_RC_ERR_TYPE_MISMATCH;
+
+ *_reference = value.value.ref;
return CMPI_RC_OK;
}
-/* TODO: Port to libxkutil/device_parsing.c */
-static int update_device(virDomainPtr dom,
- struct virt_device *dev)
+static int update_domain(virConnectPtr conn,
+ struct domain *dominfo)
{
-#if LIBVIR_VERSION_NUMBER > 8000
char *xml = NULL;
- int flags = VIR_DOMAIN_DEVICE_MODIFY_CURRENT |
- VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
- int ret = 0;
+ virDomainPtr dom = NULL;
- xml = device_to_xml(dev);
+ xml = system_to_xml(dominfo);
if (xml == NULL) {
- CU_DEBUG("Failed to get XML for device '%s'", dev->id);
- goto out;
+ CU_DEBUG("Failed to get XML from domain %s", dominfo->name);
+ return 1;
}
- if (virDomainUpdateDeviceFlags(dom, xml, flags) != 0) {
- CU_DEBUG("Failed to dynamically update device");
- goto out;
+ dom = virDomainDefineXML(conn, xml);
+ if (dom == NULL) {
+ CU_DEBUG("Failed to update domain %s", dominfo->name);
+ return 1;
}
- ret = 1;
- out:
- free(xml);
+ virDomainFree(dom);
- return ret;
-#else
return 0;
-#endif
}
-/* TODO: Port to libxkutil/device_parsing.c */
-static int get_device_by_devid(virDomainPtr dom,
+static int get_device_by_devid(struct domain *dominfo,
const char *devid,
- int type,
struct virt_device **dev)
{
- int i, ret = 0;
- struct virt_device *devices = NULL;
- int count = get_devices(dom, &devices, type);
+ int i, ret = 1;
+ struct virt_device *devices = dominfo->dev_net;
+ int count = dominfo->dev_net_ct;
+
+ if (dev == NULL)
+ return ret;
for (i = 0; i < count; i++) {
if (STREQC(devid, devices[i].id)) {
CU_DEBUG("Found '%s'", devices[i].id);
- *dev = virt_device_dup(&devices[i]);
- if (*dev != NULL)
- ret = 1;
+ *dev = &devices[i];
+ ret = 0;
break;
}
}
- cleanup_virt_devices(&devices, count);
-
return ret;
}
@@ -425,6 +418,8 @@ static CMPIStatus CreateInstance(
struct virt_device *device = NULL;
virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
+ struct domain *dominfo = NULL;
+ CMPIObjectPath *_reference = NULL;
conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s);
if (conn == NULL)
@@ -487,8 +482,12 @@ static CMPIStatus CreateInstance(
goto out;
}
- get_device_by_devid(dom, net_name, CIM_RES_TYPE_NET, &device);
- if (device == NULL) {
+ if (get_dominfo(dom, &dominfo) == 0) {
+ CU_DEBUG("Failed to get dominfo");
+ goto out;
+ }
+
+ if (get_device_by_devid(dominfo, net_name, &device) != 0) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Dependent.Name object does not exist");
@@ -502,14 +501,19 @@ static CMPIStatus CreateInstance(
device->dev.net.filter_ref = strdup(filter_name);
- if (update_device(dom, device) == 0) {
+ if (update_domain(conn, dominfo) != 0) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Failed to update device");
+ "Failed to update domain");
goto out;
}
- CMReturnObjectPath(results, reference);
+ /* create new object path */
+ _reference = CMClone(reference, NULL);
+ CMAddKey(_reference, "Antecedent", (CMPIValue *)&antecedent, CMPI_ref);
+ CMAddKey(_reference, "Dependent", (CMPIValue *)&dependent, CMPI_ref);
+
+ CMReturnObjectPath(results, _reference);
CU_DEBUG("CreateInstance complete");
out:
@@ -542,6 +546,7 @@ static CMPIStatus DeleteInstance(
struct virt_device *device = NULL;
virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
+ struct domain *dominfo = NULL;
conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s);
if (conn == NULL)
@@ -557,7 +562,7 @@ static CMPIStatus DeleteInstance(
goto out;
}
- if (cu_get_str_path(reference, "DeviceID",
+ if (cu_get_str_path(antecedent, "DeviceID",
&device_name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -573,7 +578,7 @@ static CMPIStatus DeleteInstance(
goto out;
}
- if (cu_get_str_path(reference, "Name",
+ if (cu_get_str_path(dependent, "Name",
&filter_name) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -585,7 +590,7 @@ static CMPIStatus DeleteInstance(
if (filter == NULL) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Antecedent.Name object does not exist");
+ "Dependent.Name object does not exist");
goto out;
}
@@ -600,11 +605,15 @@ static CMPIStatus DeleteInstance(
goto out;
}
- get_device_by_devid(dom, net_name, CIM_RES_TYPE_NET, &device);
- if (device == NULL) {
+ if (get_dominfo(dom, &dominfo) == 0) {
+ CU_DEBUG("Failed to get dominfo");
+ goto out;
+ }
+
+ if (get_device_by_devid(dominfo, net_name, &device) != 0) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Dependent.Name object does not exist");
+ "Antedent.Name object does not exist");
goto out;
}
@@ -613,14 +622,14 @@ static CMPIStatus DeleteInstance(
device->dev.net.filter_ref = NULL;
}
- if (update_device(dom, device) == 0) {
+ if (update_domain(conn, dominfo) != 0) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Failed to update device");
+ "Failed to update domain");
goto out;
}
- CU_DEBUG("CreateInstance complete");
+ CU_DEBUG("DeleteInstance complete");
out:
free(domain_name);
diff --git a/src/Virt_FilterList.c b/src/Virt_FilterList.c
index 35d18a9..5b1b6e8 100644
--- a/src/Virt_FilterList.c
+++ b/src/Virt_FilterList.c
@@ -358,7 +358,10 @@ static CMPIStatus DeleteInstance(
goto out;
}
- delete_filter(conn, filter);
+ if (delete_filter(conn, filter) != 0) {
+ CU_DEBUG("Failed to delete filter %s", filter->name);
+ goto out;
+ }
out:
cleanup_filters(&filter, 1);
--
1.7.1
12 years, 10 months
[PATCH v2] autoconfiscate.sh: Use proper command for revision count
by Eduardo Lima (Etrunko)
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..6bdd90a 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 HEAD | wc -l > .revision
else
echo "Unknown" > .changeset
echo "0" > .revision
--
1.7.7.5
12 years, 10 months
[PATCH] [TEST] Add .gitignore
by Eduardo Lima (Etrunko)
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
---
.gitignore | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..cf5ec57
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.log
+*.pyc
+*.pyo
+run_report.txt
--
1.7.7.5
12 years, 10 months
[PATCH] [TEST] Update revision and changeset info
by Eduardo Lima (Etrunko)
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..67ec974 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 --count HEAD 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
12 years, 10 months
[PATCH v3 0/4] Fix errors raised by Coverity tool
by Eduardo Lima (Etrunko)
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
12 years, 10 months
[V4 PATCH 3/8] vlan library - add a simple implemention for bridge
by Wenchao Xia
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
12 years, 10 months
[V4 PATCH 2/8] vlan library - add missing header files in libnl-devel 1.1
by Wenchao Xia
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
12 years, 10 months
[PATCH v2] [TEST] Update revision and changeset info
by Eduardo Lima (Etrunko)
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
12 years, 10 months
[PATCH] autoconfiscate.sh: Use proper command for revision count
by Eduardo Lima (Etrunko)
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
12 years, 10 months