[PATCH] Check libvirt version before compiling ACL library code
by Chip Vincent
# HG changeset patch
# User Chip Vincent <cvincent(a)us.ibm.com>
# Date 1308765905 14400
# Node ID 090e8ae2a0c18fad143df826dececb48d4de6b3a
# Parent f5c86ef03e64f61bb142f1aeaf448c438b28bd23
Check libvirt version before compiling ACL library code.
RHEL 5.5 that ships with libvirt 0.6.3. The NWFilter* APIs were created in
0.8.1 so the ACL code should be stubbed when LIBVIR_VERSION_NUMBER > 8000.
Same thing with using virDomainUpdateDeviceFlags().
Signed-off-by: Chip Vincent <cvincent(a)us.ibm.com>
diff --git a/libxkutil/acl_parsing.c b/libxkutil/acl_parsing.c
--- a/libxkutil/acl_parsing.c
+++ b/libxkutil/acl_parsing.c
@@ -456,6 +456,7 @@
const char *name,
struct acl_filter **filter)
{
+#if LIBVIR_VERSION_NUMBER > 8000
virNWFilterPtr vfilter = NULL;
char *xml = NULL;
@@ -474,6 +475,9 @@
get_filter_from_xml(xml, filter);
return 1;
+#else
+ return 0;
+#endif
}
int get_filter_by_uuid(
@@ -481,6 +485,7 @@
const char *uuid,
struct acl_filter **filter)
{
+#if LIBVIR_VERSION_NUMBER > 8000
virNWFilterPtr vfilter = NULL;
char *xml = NULL;
@@ -499,12 +504,16 @@
get_filter_from_xml(xml, filter);
return 1;
+#else
+ return 0;
+#endif
}
int get_filters(
virConnectPtr conn,
struct acl_filter **list)
{
+#if LIBVIR_VERSION_NUMBER > 8000
int count = 0;
char **names = NULL;
struct acl_filter *filters = NULL;
@@ -537,6 +546,9 @@
free(names);
return i;
+#else
+ return 0;
+#endif
}
diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c
--- a/src/Virt_AppliedFilterList.c
+++ b/src/Virt_AppliedFilterList.c
@@ -105,6 +105,7 @@
static int update_device(virDomainPtr dom,
struct virt_device *dev)
{
+#if LIBVIR_VERSION_NUMBER > 8000
char *xml = NULL;
int flags = VIR_DOMAIN_DEVICE_MODIFY_CURRENT |
VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
@@ -132,6 +133,9 @@
free(xml);
return ret;
+#else
+ return 0;
+#endif
}
/* TODO: Port to libxkutil/device_parsing.c */
13 years, 4 months
[PATCH] Fix AppliedFilterList Associators
by Chip Vincent
# HG changeset patch
# User Chip Vincent <cvincent(a)us.ibm.com>
# Date 1308792349 14400
# Node ID 26cfeade3cb76c4ee43a7bd33ea456a250c1c1c2
# Parent a37f80f80d4b2dab73391989168592866c23ba9b
Fix AppliedFilterList Associators.
Fixed a few small issues relating to reading AppliedFilterList.
Signed-off-by: Chip Vincent <cvincent(a)us.ibm.com>
diff --git a/schema/AppliedFilterList.registration b/schema/AppliedFilterList.registration
--- a/schema/AppliedFilterList.registration
+++ b/schema/AppliedFilterList.registration
@@ -1,3 +1,3 @@
# Copyright IBM Corp. 2011
# Classname Namespace ProviderName ProviderModule ProviderTypes
-KVM_AppliedFilterList root/virt Virt_AppliedFilterList Virt_AppliedFilterList association
+KVM_AppliedFilterList root/virt Virt_AppliedFilterList Virt_AppliedFilterList instance association
diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c
--- a/src/Virt_AppliedFilterList.c
+++ b/src/Virt_AppliedFilterList.c
@@ -218,7 +218,7 @@
CU_DEBUG("filterref = %s", ndev->filter_ref);
if ((ndev->filter_ref != NULL) &&
- STREQC(name, ndev->filter_ref)) {
+ STREQC(name, ndev->filter_ref)) {
CU_DEBUG("Getting network device instance");
CMPIInstance *instance = NULL;
@@ -235,10 +235,10 @@
CIM_RES_TYPE_NET,
&instance);
- if (instance != NULL) {
- CU_DEBUG("adding instance to list");
+ free(device_id);
+
+ if (instance != NULL)
inst_list_add(list, instance);
- }
}
}
@@ -317,7 +317,7 @@
CU_DEBUG("Checking net device '%s' for filterref",
devices[i].id);
- if (STREQC(device_name, devices[i].id)) {
+ if (STREQC(net_name, devices[i].id)) {
CMPIInstance *instance = NULL;
CU_DEBUG("Processing %s", ndev->filter_ref);
@@ -332,18 +332,18 @@
filter,
&instance);
+ cleanup_filter(filter);
+
if (instance != NULL)
inst_list_add(list, instance);
-
}
}
cleanup_virt_devices(&devices, count);
+
out:
-
free(domain_name);
- free((char *)device_name);
free(net_name);
virDomainFree(dom);
13 years, 4 months
[PATCH] [TEST] Fix syntax errors introduced by previous patch
by Eduardo Lima (Etrunko)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1308764046 10800
# Node ID 51b9e8dda4ed81bd692c6a23f14506b4561da09b
# Parent 9dcade76d903ae2c28fb35d1b28546a2324c1190
[TEST] Fix syntax errors introduced by previous patch
LogicalDisk - 01_disk.py: FAIL
File "01_disk.py", line 63
else if dev.Name != test_dev:
^
SyntaxError: invalid syntax
Memory - 01_memory.py: FAIL
File "01_memory.py", line 62
else if dev.ConsumableBlocks > dev.NumberOfBlocks:
^
SyntaxError: invalid syntax
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
diff --git a/suites/libvirt-cim/cimtest/LogicalDisk/01_disk.py b/suites/libvirt-cim/cimtest/LogicalDisk/01_disk.py
--- a/suites/libvirt-cim/cimtest/LogicalDisk/01_disk.py
+++ b/suites/libvirt-cim/cimtest/LogicalDisk/01_disk.py
@@ -60,7 +60,7 @@
if dev is None:
logger.error("GetInstance() returned None")
status = 1
- else if dev.Name != test_dev:
+ elif dev.Name != test_dev:
logger.error("Name should be `%s' instead of `%s'", test_dev, dev.Name)
status = 1
diff --git a/suites/libvirt-cim/cimtest/Memory/01_memory.py b/suites/libvirt-cim/cimtest/Memory/01_memory.py
--- a/suites/libvirt-cim/cimtest/Memory/01_memory.py
+++ b/suites/libvirt-cim/cimtest/Memory/01_memory.py
@@ -59,7 +59,7 @@
if dev is None:
logger.error("GetInstance() returned None")
status = 1
- else if dev.ConsumableBlocks > dev.NumberOfBlocks:
+ elif dev.ConsumableBlocks > dev.NumberOfBlocks:
logger.error("ConsumableBlocks should not be larger than NumberOfBlocks")
status = 1
13 years, 4 months
[PATCH] (#2) Conditional build requirement for RPM package
by Eduardo Lima (Etrunko)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1308750020 10800
# Node ID c6f1723d2c68c5e8ba371e4dea4d7aaae6cca326
# Parent 6c29c5b284443e226e7d97e7e5f11848b0c4e761
Conditional build requirement for RPM package
In RHEL5 uuid development files are provided by e2fsprogs-devel package,
while in most recent distros, it is provided by libuuid-devel.
Changes from #1:
- Remove libconfig-devel build dependency
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in
--- a/libvirt-cim.spec.in
+++ b/libvirt-cim.spec.in
@@ -16,7 +16,14 @@
BuildRequires: libcmpiutil >= 0.5.4
BuildRequires: tog-pegasus-devel
BuildRequires: libvirt-devel >= 0.6.4
+
+# In RHEL5 uuid-devel is provided by e2fsprogs
+%if 0%{?el5}
+BuildRequires: e2fsprogs-devel
+%else
BuildRequires: libuuid-devel
+%endif
+
BuildRequires: libxml2-devel
BuildRequires: libcmpiutil-devel
BuildConflicts: sblim-cmpi-devel
13 years, 4 months
[PATCH] Conditional build requirement for RPM package
by Eduardo Lima (Etrunko)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1308748522 10800
# Node ID d47d6105d725641ed8fdbb2d2fd0c300c9f1e773
# Parent 6c29c5b284443e226e7d97e7e5f11848b0c4e761
Conditional build requirement for RPM package
In RHEL5 uuid development files are provided by e2fsprogs-devel package,
while in most recent distros, it is provided by libuuid-devel.
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in
--- a/libvirt-cim.spec.in
+++ b/libvirt-cim.spec.in
@@ -16,9 +16,17 @@
BuildRequires: libcmpiutil >= 0.5.4
BuildRequires: tog-pegasus-devel
BuildRequires: libvirt-devel >= 0.6.4
+
+# In RHEL5 uuid-devel is provided by e2fsprogs
+%if 0%{?el5}
+BuildRequires: e2fsprogs-devel
+%else
BuildRequires: libuuid-devel
+%endif
+
BuildRequires: libxml2-devel
BuildRequires: libcmpiutil-devel
+BuildRequires: libconfig-devel
BuildConflicts: sblim-cmpi-devel
%description
13 years, 4 months
[PATCH] Fix MemoryPool.Reserved to show only actively allocated memory
by Chip Vincent
# HG changeset patch
# User Chip Vincent <cvincent(a)us.ibm.com>
# Date 1308669482 14400
# Node ID 637801be4b6f6cc0c065f4fe406e85b78186654b
# Parent 6c29c5b284443e226e7d97e7e5f11848b0c4e761
Fix MemoryPool.Reserved to show only actively allocated memory.
It appears Reserved is meant to show memory that is taken (actively in use by
VMs) as opposed to memory that is potentially taken (assigned to defined, but
not running VMs).
Also added CurrentlyConsumedResource (a much clearer name for the same thing)
and ConsumedResourceUnits, fixed units to conform with DSP1045, and cleaned
up some extraneous whitespace.
Signed-off-by: Chip Vincent <cvincent(a)us.ibm.com>
diff --git a/src/Virt_DevicePool.c b/src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c
+++ b/src/Virt_DevicePool.c
@@ -676,17 +676,47 @@
return memory != 0;
}
-static bool mempool_set_reserved(CMPIInstance *inst, virConnectPtr conn)
+static bool mempool_set_consumed(CMPIInstance *inst, virConnectPtr conn)
{
- uint64_t memory;
+ uint64_t memory = 0;
+ int *domain_ids = NULL;
+ int count, i = 0;
- /* NB: This doesn't account for memory to be claimed
- * by ballooning dom0
- */
- memory = allocated_memory(conn);
+ count = virConnectNumOfDomains(conn);
+ if (count <= 0)
+ goto out;
+
+ domain_ids = calloc(count, sizeof(domain_ids[0]));
+ if (domain_ids == 0)
+ goto out;
+
+ if (virConnectListDomains(conn, domain_ids, count) == 0)
+ goto out;
+
+ for (i = 0; i < count; i++) {
+ virDomainPtr dom = NULL;
+ virDomainInfo dom_info;
+
+ dom = virDomainLookupByID(conn, domain_ids[i]);
+ if (dom == NULL) {
+ CU_DEBUG("Cannot connect to domain %n: excluding",
+ domain_ids[i]);
+ continue;
+ }
+
+ if (virDomainGetInfo(dom, &dom_info) == 0)
+ memory += dom_info.memory;
+
+ virDomainFree(dom);
+ }
+
+ out:
+ free(domain_ids);
CMSetProperty(inst, "Reserved",
(CMPIValue *)&memory, CMPI_uint64);
+ CMSetProperty(inst, "CurrentlyConsumedResource",
+ (CMPIValue *)&memory, CMPI_uint64);
return memory != 0;
}
@@ -726,10 +756,14 @@
CMSetProperty(inst, "ResourceType",
(CMPIValue *)&type, CMPI_uint16);
- if (units != NULL)
+ if (units != NULL) {
CMSetProperty(inst, "AllocationUnits",
(CMPIValue *)units, CMPI_chars);
+ CMSetProperty(inst, "ConsumedResourceUnits",
+ (CMPIValue *)units, CMPI_chars);
+ }
+
if (caption != NULL)
CMSetProperty(inst, "Caption",
(CMPIValue *)caption, CMPI_chars);
@@ -761,9 +795,9 @@
ns);
mempool_set_total(inst, conn);
- mempool_set_reserved(inst, conn);
+ mempool_set_consumed(inst, conn);
- set_params(inst, CIM_RES_TYPE_MEM, id, "KiloBytes", NULL, true);
+ set_params(inst, CIM_RES_TYPE_MEM, id, "byte*2^10", NULL, true);
inst_list_add(list, inst);
13 years, 4 months
腾讯 failed to remove the ptmx file when the vm is down
by kevenzhu(朱以军)
Hi Guys:
I'm writing an web-based vm managerment system using libvirt which is convenient to use. but when I want to remove the template, the PTMX file could NOT
be removed. below is the error message, would you please give me some suggestions, thanks a lot.
virsh # list --all
Id Name State
----------------------------------
- lxc6 shut off
root@Tencent:/usr/local/project/LXC/template/suse/dev/pts <blocked::mailto:root@Tencent:/usr/local/project/LXC/template/suse/dev/pts> # ls -l
total 0
crw-rw-rw- 1 root root 5, 2 Jun 17 10:23 ptmx
root@Tencent:/usr/local/project/LXC/template/suse/dev/pts <blocked::mailto:root@Tencent:/usr/local/project/LXC/template/suse/dev/pts> # rm ptmx -f
rm: cannot remove `ptmx': Operation not permitted
13 years, 4 months
[PATCH] [NetRASD]: Fill up NetworkName attribute for non-bridged network
by Eduardo Lima (Etrunko)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1308246930 10800
# Node ID 6c29c5b284443e226e7d97e7e5f11848b0c4e761
# Parent a37f80f80d4b2dab73391989168592866c23ba9b
[NetRASD]: Fill up NetworkName attribute for non-bridged network
This patch fixes the behavior for the read operation.
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c
--- a/src/Virt_RASD.c
+++ b/src/Virt_RASD.c
@@ -370,8 +370,7 @@
(CMPIValue *)dev->dev.net.mac,
CMPI_chars);
- if ((dev->dev.net.source != NULL) &&
- (STREQ(dev->dev.net.type, "bridge")))
+ if (dev->dev.net.source != NULL)
CMSetProperty(inst,
"NetworkName",
(CMPIValue *)dev->dev.net.source,
13 years, 4 months
Re: [Libvirt-cim] [PATCH] #3 Configure tweaks
by Chip Vincent
Sorry it took so long to review this patch. It's seems to have escaped
my mailbox so thank goodnews for list archives :-)
Output is as expected:
...
libVirt_ComputerSystem.so
libVirt_ComputerSystem.so.0
libVirt_ComputerSystem.so.0.5.12
...
+1 and pushed.
--
Chip Vincent
Open Virtualization
IBM Linux Technology Center
cvincent(a)linux.vnet.ibm.com
13 years, 4 months
[PATCH] #2 Cimtest: Check for None return value
by Eduardo Lima (Etrunko)
# HG changeset patch
# User Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
# Date 1306960999 10800
# Node ID df7d1969cedff2ba8cbb6bdd8a465939d815e2bc
# Parent f303bd9615f23b8b79c5532dd5489899a13a0f8e
Cimtest: Check for None return value
Some tests were raising Attribute Exception due to None value returned.
Changes from #1:
- Explicitly check for None if value returned from GetInstance()
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
diff -r f303bd9615f2 -r df7d1969cedf suites/libvirt-cim/cimtest/LogicalDisk/01_disk.py
--- a/suites/libvirt-cim/cimtest/LogicalDisk/01_disk.py Wed Jun 01 16:44:39 2011 -0300
+++ b/suites/libvirt-cim/cimtest/LogicalDisk/01_disk.py Wed Jun 01 17:43:19 2011 -0300
@@ -57,7 +57,10 @@
dev = GetInstance(options.ip, disk, key_list)
status = 0
- if dev.Name != test_dev:
+ if dev is None:
+ logger.error("GetInstance() returned None")
+ status = 1
+ else if dev.Name != test_dev:
logger.error("Name should be `%s' instead of `%s'", test_dev, dev.Name)
status = 1
diff -r f303bd9615f2 -r df7d1969cedf suites/libvirt-cim/cimtest/Memory/01_memory.py
--- a/suites/libvirt-cim/cimtest/Memory/01_memory.py Wed Jun 01 16:44:39 2011 -0300
+++ b/suites/libvirt-cim/cimtest/Memory/01_memory.py Wed Jun 01 17:43:19 2011 -0300
@@ -56,7 +56,10 @@
status = 0
- if dev.ConsumableBlocks > dev.NumberOfBlocks:
+ if dev is None:
+ logger.error("GetInstance() returned None")
+ status = 1
+ else if dev.ConsumableBlocks > dev.NumberOfBlocks:
logger.error("ConsumableBlocks should not be larger than NumberOfBlocks")
status = 1
diff -r f303bd9615f2 -r df7d1969cedf suites/libvirt-cim/cimtest/NetworkPort/01_netport.py
--- a/suites/libvirt-cim/cimtest/NetworkPort/01_netport.py Wed Jun 01 16:44:39 2011 -0300
+++ b/suites/libvirt-cim/cimtest/NetworkPort/01_netport.py Wed Jun 01 17:43:19 2011 -0300
@@ -83,6 +83,11 @@
vsxml.undefine(options.ip)
return FAIL
+ if dev is None:
+ logger.error("GetInstance() returned None")
+ vsxml.undefine(options.ip)
+ return FAIL
+
if dev.DeviceID == None:
logger.error("Error retrieving instance for devid %s", devid)
vsxml.undefine(options.ip)
diff -r f303bd9615f2 -r df7d1969cedf suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Wed Jun 01 16:44:39 2011 -0300
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Wed Jun 01 17:43:19 2011 -0300
@@ -47,6 +47,10 @@
rasds = get_default_rasds(options.ip, options.virt)
+ if not rasds:
+ logger.error("get_default_rasds() returned None")
+ return FAIL
+
rasd_list = {}
for rasd in rasds:
@@ -56,6 +60,10 @@
rasd['AllocationUnits'] = units
rasd_list[mrasd_cn] = inst_to_mof(rasd)
+ if mrasd_cn not in rasd_list.keys():
+ logger.error("Key '%s' not found in dictionary '%s'" % (mrasd_cn, rasd_list))
+ return FAIL
+
if rasd_list[mrasd_cn] is None:
logger.error("Unable to get template MemRASD")
return FAIL
diff -r f303bd9615f2 -r df7d1969cedf suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py Wed Jun 01 16:44:39 2011 -0300
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py Wed Jun 01 17:43:19 2011 -0300
@@ -154,7 +154,7 @@
logger.error(details)
status = FAIL
- if os.path.exists(addr):
+ if addr and os.path.exists(addr):
os.remove(addr)
if guest_defined == True:
13 years, 5 months