[libvirt] [test-API][PATCH] Add 7 memory API related cases
by Wayne Sun
add 7 new cases using domain memory related API
add 1 conf for domain memory testing
7 new cases are:
memory_params_config: test set memory params with config flag
memory_params_live: test set memory params with live flag
memory_peek: test memory peek
memory_stats: test get memory stats
set_maxmem_config: test set maximum memory with config flag
set_memory_config: test set current memory with config flag
set_memory_live: test set current memory with live flag
memory hotplug is not supported yet, so live set max memory case
is not added.
Signed-off-by: Wayne Sun <gsun(a)redhat.com>
---
cases/domain_memory_test.conf | 99 +++++++++++++++++++++++++++++++
repos/domain/memory_params_config.py | 96 ++++++++++++++++++++++++++++++
repos/domain/memory_params_live.py | 109 +++++++++++++++++++++++++++++++++++
repos/domain/memory_peek.py | 48 +++++++++++++++
repos/domain/memory_stats.py | 65 +++++++++++++++++++++
repos/domain/set_maxmem_config.py | 59 +++++++++++++++++++
repos/domain/set_memory_config.py | 94 ++++++++++++++++++++++++++++++
repos/domain/set_memory_live.py | 86 +++++++++++++++++++++++++++
8 files changed, 656 insertions(+)
create mode 100644 cases/domain_memory_test.conf
create mode 100644 repos/domain/memory_params_config.py
create mode 100644 repos/domain/memory_params_live.py
create mode 100644 repos/domain/memory_peek.py
create mode 100644 repos/domain/memory_stats.py
create mode 100644 repos/domain/set_maxmem_config.py
create mode 100644 repos/domain/set_memory_config.py
create mode 100644 repos/domain/set_memory_live.py
diff --git a/cases/domain_memory_test.conf b/cases/domain_memory_test.conf
new file mode 100644
index 0000000..90879ab
--- /dev/null
+++ b/cases/domain_memory_test.conf
@@ -0,0 +1,99 @@
+domain:install_linux_cdrom
+ guestname
+ $defaultname
+ guestos
+ $defaultos
+ guestarch
+ $defaultarch
+ vcpu
+ $defaultvcpu
+ memory
+ $defaultmem
+ hddriver
+ $defaulthd
+ nicdriver
+ $defaultnic
+ macaddr
+ 54:52:00:4a:c1:22
+
+domain:balloon_memory
+ guestname
+ $defaultname
+ memorypair
+ 1024,2048
+
+domain:destroy
+ guestname
+ $defaultname
+
+domain:memory_params_config
+ guestname
+ $defaultname
+ hard_limit
+ 0
+ soft_limit
+ 9007199254740991
+ swap_hard_limit
+ -1
+
+domain:set_maxmem_config
+ guestname
+ $defaultname
+ memory
+ 16777216
+
+domain:set_memory_config
+ guestname
+ $defaultname
+ memory
+ 1048576
+ maxmem
+ 4194304
+
+domain:start
+ guestname
+ $defaultname
+
+domain:memory_stats
+ guestname
+ $defaultname
+
+domain:memory_peek
+ guestname
+ $defaultname
+
+domain:memory_params_live
+ guestname
+ $defaultname
+ hard_limit
+ 25417224
+ soft_limit
+ 9007199254740900
+ swap_hard_limit
+ -1
+
+domain:set_memory_live
+ guestname
+ $defaultname
+ memory
+ 2097152
+ username
+ $username
+ password
+ $password
+
+domain:set_memory_config
+ guestname
+ $defaultname
+ memory
+ 4194304
+
+domain:destroy
+ guestname
+ $defaultname
+
+domain:undefine
+ guestname
+ $defaultname
+
+options cleanup=enable
diff --git a/repos/domain/memory_params_config.py b/repos/domain/memory_params_config.py
new file mode 100644
index 0000000..af9781b
--- /dev/null
+++ b/repos/domain/memory_params_config.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+# Test set domain memory parameters with flag
+# VIR_DOMAIN_AFFECT_CONFIG
+
+from xml.dom import minidom
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname', 'hard_limit', 'soft_limit', 'swap_hard_limit', )
+optional_params = {}
+
+UNLIMITED = 9007199254740991
+
+def get_memory_config(domobj, param_dict):
+ """get domain config memory parameters
+ """
+ new_dict = {}
+ try:
+ guestxml = domobj.XMLDesc(2)
+ logger.debug("domain %s xml is :\n%s" %(domobj.name(), guestxml))
+ xml = minidom.parseString(guestxml)
+ logger.info("get domain memory parameters in config xml")
+ for i in param_dict.keys():
+ if xml.getElementsByTagName(i):
+ limit_element = xml.getElementsByTagName(i)[0]
+ limit = int(limit_element.childNodes[0].data)
+ logger.info("%s in config xml is: %s" % (i, limit))
+ new_dict[i] = limit
+ else:
+ logger.info("%s is not in config xml" % i)
+ new_dict[i] = 0
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return False
+
+ return new_dict
+
+def memory_params_config(params):
+ """set domain memory parameters with config flag and check
+ """
+ global logger
+ logger = params['logger']
+ guestname = params['guestname']
+ hard_limit = int(params['hard_limit'])
+ soft_limit = int(params['soft_limit'])
+ swap_hard_limit = int(params['swap_hard_limit'])
+
+ logger.info("the name of virtual machine is %s" % guestname)
+ param_dict = {'hard_limit': hard_limit,
+ 'soft_limit': soft_limit,
+ 'swap_hard_limit': swap_hard_limit
+ }
+
+ for i in param_dict.keys():
+ if param_dict[i] == -1:
+ param_dict[i] = UNLIMITED
+
+ logger.info("the param dict for setting is %s" % param_dict)
+
+ conn = sharedmod.libvirtobj['conn']
+
+ try:
+ domobj = conn.lookupByName(guestname)
+ flags = libvirt.VIR_DOMAIN_AFFECT_CONFIG
+ logger.info("set %s memory parameters with flag: %s" %
+ (guestname, flags))
+ domobj.setMemoryParameters(param_dict, flags)
+ logger.info("set memory parameters done")
+
+ logger.info("get %s memory parameters with flag: %s" %
+ (guestname, flags))
+ ret = domobj.memoryParameters(flags)
+ logger.info("%s memory parameters is %s" % (guestname, ret))
+
+ if ret == param_dict:
+ logger.info("memory parameters is as expected")
+ else:
+ logger.error("memory parameters is not as expected")
+ return 1
+
+ ret = get_memory_config(domobj, param_dict)
+ if ret == param_dict:
+ logger.info("memory parameters is as expected in config xml")
+ else:
+ logger.error("memory parameters is not as expected in config xml")
+ return 1
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
diff --git a/repos/domain/memory_params_live.py b/repos/domain/memory_params_live.py
new file mode 100644
index 0000000..68a71b2
--- /dev/null
+++ b/repos/domain/memory_params_live.py
@@ -0,0 +1,109 @@
+#!/usr/bin/env python
+# Test set domain memory parameters with flag
+# VIR_DOMAIN_AFFECT_LIVE
+
+import os
+import math
+from xml.dom import minidom
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname', 'hard_limit', 'soft_limit', 'swap_hard_limit', )
+optional_params = {}
+
+UNLIMITED = 9007199254740991
+CGROUP_PATH = "/cgroup/memory/libvirt/qemu"
+
+def get_cgroup_setting(guestname):
+ """get domain memory parameters in cgroup
+ """
+ if os.path.exists(CGROUP_PATH):
+ cgroup_path = "%s/%s" % (CGROUP_PATH, guestname)
+ else:
+ cgroup_path = "/sys/fs%s/%s" % (CGROUP_PATH, guestname)
+
+ f = open("%s/memory.limit_in_bytes" % cgroup_path)
+ hard = int(f.read())
+ logger.info("memory.limit_in_bytes value is %s" % hard)
+
+ f = open("%s/memory.soft_limit_in_bytes" % cgroup_path)
+ soft = int(f.read())
+ logger.info("memory.soft_limit_in_bytes value is %s" % soft)
+
+ f = open("%s/memory.memsw.limit_in_bytes" % cgroup_path)
+ swap = int(f.read())
+ logger.info("memory.memsw.limit_in_bytes value is %s" % swap)
+
+ new_dict = {'hard_limit': hard/1024,
+ 'soft_limit': soft/1024,
+ 'swap_hard_limit': swap/1024
+ }
+ logger.debug("memory parameters dict get from cgroup is %s" % new_dict)
+
+ return new_dict
+
+def memory_params_live(params):
+ """set domain memory parameters with live flag and check
+ """
+ global logger
+ logger = params['logger']
+ guestname = params['guestname']
+ hard_limit = int(params['hard_limit'])
+ soft_limit = int(params['soft_limit'])
+ swap_hard_limit = int(params['swap_hard_limit'])
+
+ logger.info("the name of virtual machine is %s" % guestname)
+ param_dict = {'hard_limit': hard_limit,
+ 'soft_limit': soft_limit,
+ 'swap_hard_limit': swap_hard_limit
+ }
+
+ for i in param_dict.keys():
+ if param_dict[i] == -1:
+ param_dict[i] = UNLIMITED
+
+ logger.info("the param dict for setting is %s" % param_dict)
+
+ conn = sharedmod.libvirtobj['conn']
+
+ try:
+ domobj = conn.lookupByName(guestname)
+ flags = libvirt.VIR_DOMAIN_AFFECT_LIVE
+ logger.info("get %s memory parameters with flag: %s" %
+ (guestname, flags))
+ ret_pre = domobj.memoryParameters(flags)
+ logger.info("%s memory parameters is %s" % (guestname, ret_pre))
+
+ logger.info("set %s memory parameters with flag: %s" %
+ (guestname, flags))
+ domobj.setMemoryParameters(param_dict, flags)
+ logger.info("set memory parameters done")
+
+ logger.info("get %s memory parameters with flag: %s" %
+ (guestname, flags))
+ ret_pos = domobj.memoryParameters(flags)
+ logger.info("%s memory parameters is %s" % (guestname, ret_pos))
+
+ if ret_pos == param_dict:
+ logger.info("memory parameters is as expected")
+ else:
+ logger.error("memory parameters is not as expected")
+ return 1
+
+ logger.info("check memory parameters in cgroup")
+ ret = get_cgroup_setting(guestname)
+ for i in param_dict.keys():
+ if math.fabs(param_dict[i] - ret[i]) > 1:
+ logger.error("%s value not match with cgroup setting" % i)
+ return 1
+
+ logger.info("memory parameters is as expected in cgroup setting")
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
diff --git a/repos/domain/memory_peek.py b/repos/domain/memory_peek.py
new file mode 100644
index 0000000..de1ff87
--- /dev/null
+++ b/repos/domain/memory_peek.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# Test domain memory peek
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname', )
+optional_params = {}
+
+def memory_peek(params):
+ """domain memory peek
+ """
+ logger = params['logger']
+ guestname = params['guestname']
+
+ flag_dict = {'1':"VIR_MEMORY_VIRTUAL", '2':"VIR_MEMORY_PHYSICAL"}
+
+ logger.info("the name of virtual machine is %s" % guestname)
+
+ conn = sharedmod.libvirtobj['conn']
+
+ try:
+ domobj = conn.lookupByName(guestname)
+ logger.info("test memory peek API")
+ for flag in flag_dict.keys():
+ logger.info("using flag: %s" % flag_dict[flag])
+ mem = domobj.memoryPeek(0, 0, int(flag))
+ if mem:
+ return 1
+ logger.info("memory peek API works fine with flag: %s" %
+ flag_dict[flag])
+
+ logger.info("peek 8 bytes from domain memory")
+ for flag in flag_dict.keys():
+ logger.info("using flag: %s" % flag_dict[flag])
+ mem = domobj.memoryPeek(0, 8, int(flag))
+ if not mem:
+ return 1
+ logger.info("8 bytes start with 0 with flag %s is: %s" %
+ (flag_dict[flag], mem))
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
diff --git a/repos/domain/memory_stats.py b/repos/domain/memory_stats.py
new file mode 100644
index 0000000..5de4028
--- /dev/null
+++ b/repos/domain/memory_stats.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# Test get domain memory stats
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('guestname', )
+optional_params = {}
+
+VIRSH = "virsh qemu-monitor-command"
+
+def get_memory_actual(guestname):
+ """get memory stats with virsh commands
+ """
+ qmp_actual = -1
+ cmd ="%s %s '{ \"execute\": \"query-balloon\" }'" % (VIRSH, guestname)
+ logger.info("check memory stats with virsh command: %s" % cmd)
+ ret, out = utils.exec_cmd(cmd, shell=True)
+ out_dict = eval(out[0])
+ if out_dict.has_key('return'):
+ if out_dict['return'].has_key('actual'):
+ qmp_actual = out_dict['return']['actual']
+ else:
+ return False
+
+ if qmp_actual == -1:
+ return False
+
+ logger.info("the memory actal is: %s" % qmp_actual)
+ return qmp_actual
+
+def memory_stats(params):
+ """get domain memory stats
+ """
+ global logger
+ logger = params['logger']
+ guestname = params['guestname']
+
+ logger.info("the name of virtual machine is %s" % guestname)
+
+ conn = sharedmod.libvirtobj['conn']
+
+ try:
+ domobj = conn.lookupByName(guestname)
+ mem = domobj.memoryStats()
+ logger.info("%s memory stats is: %s" % (guestname, mem))
+ ret = get_memory_actual(guestname)
+ if not ret:
+ logger.error("get memory actual with qmp command failed")
+ return 1
+
+ if ret == mem['actual']*1024:
+ logger.info("actual memory is equal to output of qmp command")
+ else:
+ logger.error("actual memory is not equal to output of qmp command")
+ return 1
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
diff --git a/repos/domain/set_maxmem_config.py b/repos/domain/set_maxmem_config.py
new file mode 100644
index 0000000..262d7b1
--- /dev/null
+++ b/repos/domain/set_maxmem_config.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# Test set domain max memory with API setMaxMemory.
+
+from xml.dom import minidom
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname', 'memory', )
+optional_params = {}
+
+def set_maxmem_config(params):
+ """set domain max memory, check with config xml and
+ maxMemory API
+ """
+ global logger
+ logger = params['logger']
+ guestname = params['guestname']
+ memory = int(params['memory'])
+
+ logger.info("the name of virtual machine is %s" % guestname)
+ logger.info("the given max memory value is %s" % memory)
+
+ conn = sharedmod.libvirtobj['conn']
+
+ try:
+ domobj = conn.lookupByName(guestname)
+ logger.info("set domain max memory as %s" % memory)
+ domobj.setMaxMemory(memory)
+
+ guestxml = domobj.XMLDesc(2)
+ logger.debug("domain %s xml is :\n%s" %(guestname, guestxml))
+ xml = minidom.parseString(guestxml)
+ mem = xml.getElementsByTagName('memory')[0]
+ maxmem = int(mem.childNodes[0].data)
+ logger.info("domain max memory in config xml is: %s" % maxmem)
+ if maxmem == memory:
+ logger.info("max memory in domain config xml is equal to set")
+ else:
+ logger.error("set max memory failed")
+ return 1
+
+ maxmem = domobj.maxMemory()
+ logger.info("max memory got by maxMemory API is: %s" % maxmem)
+ if maxmem == memory:
+ logger.info("max memory got by maxMemory API is equal to set")
+ else:
+ logger.error("set max memory failed")
+ return 1
+
+ logger.info("set max memory succeed")
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
diff --git a/repos/domain/set_memory_config.py b/repos/domain/set_memory_config.py
new file mode 100644
index 0000000..c8ef6c3
--- /dev/null
+++ b/repos/domain/set_memory_config.py
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+# Test set domain balloon memory with flag VIR_DOMAIN_AFFECT_CONFIG
+# or VIR_DOMAIN_VCPU_MAXIMUM, depend on which optional param is
+# given.
+
+from xml.dom import minidom
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname', )
+optional_params = {'memory': 1048576,
+ 'maxmem': 4194304,
+ }
+def get_memory_config(domobj):
+ """get domain config current memory and max memory
+ """
+ try:
+ guestxml = domobj.XMLDesc(2)
+ logger.debug("domain %s xml is :\n%s" %(domobj.name(), guestxml))
+ xml = minidom.parseString(guestxml)
+
+ logger.info("get domain memory info in config xml")
+ mem = xml.getElementsByTagName('currentMemory')[0]
+ current = int(mem.childNodes[0].data)
+ logger.info("current memory in config xml is: %s" % current)
+
+ mem = xml.getElementsByTagName('memory')[0]
+ max_memory = int(mem.childNodes[0].data)
+ logger.info("max memory in config xml is: %s" % max_memory)
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return False
+
+ return current, max_memory
+
+def set_memory_config(params):
+ """set domain memory with live flag and check
+ """
+ global logger
+ logger = params['logger']
+ guestname = params['guestname']
+ memory = params.get('memory', None)
+ maxmem = params.get('maxmem', None)
+
+ logger.info("the name of virtual machine is %s" % guestname)
+ if memory == None and maxmem == None:
+ logger.error("at least one of memory or maxmem should be provided")
+ return 1
+
+ conn = sharedmod.libvirtobj['conn']
+
+ try:
+ domobj = conn.lookupByName(guestname)
+ if memory:
+ memory = int(memory)
+ flags = libvirt.VIR_DOMAIN_AFFECT_CONFIG
+ logger.info("set domain memory as %s with flag: %s" %
+ (memory, flags))
+ domobj.setMemoryFlags(memory, flags)
+ ret = get_memory_config(domobj)
+ if not ret:
+ return 1
+
+ if ret[0] == memory:
+ logger.info("set current memory succeed")
+ else:
+ logger.error("set current memory failed")
+ return 1
+
+ if maxmem:
+ maxmem = int(maxmem)
+ flags = libvirt.VIR_DOMAIN_MEM_MAXIMUM
+ logger.info("set domain max memory as %s with flag: %s" %
+ (maxmem, flags))
+ domobj.setMemoryFlags(maxmem, flags)
+ ret = get_memory_config(domobj)
+ if not ret:
+ return 1
+
+ if ret[1] == maxmem:
+ logger.info("set max memory succeed")
+ else:
+ logger.error("set max memory failed")
+ return 1
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
diff --git a/repos/domain/set_memory_live.py b/repos/domain/set_memory_live.py
new file mode 100644
index 0000000..f7c77f9
--- /dev/null
+++ b/repos/domain/set_memory_live.py
@@ -0,0 +1,86 @@
+#!/usr/bin/env python
+# Test set domain balloon memory with flag VIR_DOMAIN_AFFECT_LIVE.
+# Check domain info and inside domain to get current memory value.
+# The live flag only work on running domain, so test on shutoff
+# domain will fail.
+
+import time
+import math
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('guestname', 'memory', 'username', 'password', )
+optional_params = {}
+
+def compare_memory(expect_memory, actual_memory):
+ """ comparing expected memory size with actual memory size """
+
+ logger.info("expected memory size is %s" % expect_memory)
+ logger.info("actual memory size is %s" % actual_memory)
+ diff = int(expect_memory) - int(actual_memory)
+
+ if math.fabs(diff)/expect_memory < 0.05:
+ return 0
+ else:
+ return 1
+
+def get_current_memory(guestname, username, password):
+ """get domain current memory inside domain
+ """
+ logger.debug("get the mac address of vm %s" % guestname)
+ mac = utils.get_dom_mac_addr(guestname)
+ logger.debug("the mac address of vm %s is %s" % (guestname, mac))
+ ip = utils.mac_to_ip(mac, 180)
+ current = utils.get_remote_memory(ip, username, password)
+
+ return current
+
+def set_memory_live(params):
+ """set domain memory with live flag and check
+ """
+ global logger
+ logger = params['logger']
+ params.pop('logger')
+ guestname = params['guestname']
+ memory = int(params['memory'])
+ username = params['username']
+ password = params['password']
+
+ logger.info("the name of virtual machine is %s" % guestname)
+ logger.info("the given memory value is %s" % memory)
+
+ conn = sharedmod.libvirtobj['conn']
+
+ try:
+ domobj = conn.lookupByName(guestname)
+ logger.info("set domain memory as %s with flag: %s" %
+ (memory, libvirt.VIR_DOMAIN_AFFECT_LIVE))
+ domobj.setMemoryFlags(memory, libvirt.VIR_DOMAIN_AFFECT_LIVE)
+ logger.info("get domain current memory")
+ time.sleep(3)
+ dominfo = domobj.info()
+ logger.debug("domain info list is: %s" % dominfo)
+ logger.info("domain current memory value is: %s KiB" % dominfo[2])
+ if memory == dominfo[2]:
+ logger.info("set memory match with domain info")
+ else:
+ logger.error("set memory not match with domain info")
+ return 1
+
+ logger.info("check domain memory inside domain")
+ ret = get_current_memory(guestname, username, password)
+ if not compare_memory(memory, ret):
+ logger.info("set domain memory succeed")
+ else:
+ logger.error("set domain memory failed")
+ return 1
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
--
1.8.1
12 years, 1 month
[libvirt] [PATCH] interface: fix udev backend use after free
by Doug Goldstein
udevIfaceListAllInterface() used the udev_device after it had its ref
count decremented which results in a use after free issue.
---
src/interface/interface_backend_udev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
index 92c35d9..2c41bde 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -359,7 +359,6 @@ udevIfaceListAllInterfaces(virConnectPtr conn,
name = udev_device_get_sysname(dev);
macaddr = udev_device_get_sysattr_value(dev, "address");
status = STREQ(udev_device_get_sysattr_value(dev, "operstate"), "up");
- udev_device_unref(dev);
/* Filter the results */
if (status && (flags & VIR_CONNECT_LIST_INTERFACES_ACTIVE))
@@ -375,6 +374,7 @@ udevIfaceListAllInterfaces(virConnectPtr conn,
}
count++;
}
+ udev_device_unref(dev);
}
/* Drop our refcounts */
--
1.7.12.4
12 years, 1 month
[libvirt] [PATCH] Add autogenerated lxc_protocol.[ch] to gitignore
by Doug Goldstein
/src/lxc/lxc_protocol.[ch] is autogenerated so add it to .gitignore
---
.gitignore | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.gitignore b/.gitignore
index 23fdc91..16ac708 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@
/COPYING
/ChangeLog
/GNUmakefile
+/HACKING
/INSTALL
/NEWS
/aclocal.m4
@@ -121,6 +122,7 @@
/src/lxc/lxc_monitor_dispatch.h
/src/lxc/lxc_monitor_protocol.c
/src/lxc/lxc_monitor_protocol.h
+/src/lxc/lxc_protocol.[ch]
/src/lxc/test_libvirtd_lxc.aug
/src/qemu/test_libvirtd_qemu.aug
/src/remote/*_client_bodies.h
--
1.7.12.4
12 years, 1 month
[libvirt] [PATCH 0/5] Clean up after recent Coverity scan
by John Ferlan
This is the last round of cleanup with a few Coverity errors from the
tests trees and a couple that just showed up in my recent scans within
security and virsh. The commandtest still has Valgrind errors, but errors
are not new to this change.
After this round of Coverity changes, the only remaining Coverity warnings
reported are within the gnulib tree. A few have been there all along within
vasnprintf.c, while others are new with the recent gnulib update (regexec.c,
regex_internal.c, and regcomp.c).
Once these are submitted I will have a baseline from which I can make
periodic comparisons. Since Coverity will sometimes "find" issues unrelated
to recent changes, using git bisect to point the fickle finger of fate at
a recent submission may not be possible.
John Ferlan (5):
drivermodule: Ignore coverity warning about leaked_storage
commandtest: Resolve some coverity resource leaks
vircommand: Remove unnecessary sa_assert
virsh: Resolve possible NULL dereference
security: Remove unnecessary checks for mgr == NULL
src/security/security_dac.c | 6 ------
src/security/security_selinux.c | 6 ------
src/util/vircommand.c | 3 ---
tests/commandtest.c | 17 ++++++++++++-----
tests/virdrivermoduletest.c | 2 ++
tools/virsh.c | 4 ++--
6 files changed, 16 insertions(+), 22 deletions(-)
--
1.7.11.7
12 years, 1 month
[libvirt] [PATCH 0/2] Restore DAC labels
by Michal Privoznik
If libvirt is doing labeling on a domain startup, the original
owner of files is not remembered. So later, when the domain is
shutting down and re-labelling is done, we have no other option,
just to fall back to 0:0. These patches are solving this issue
for DAC driver. I am sending them just to know if the path I wen
through is right so I don't bother with selinux if it is not.
Michal Privoznik (2):
conf: Add oldlabel field to virSecurityDeviceLabelDef
security driver: Remember the original DAC label
src/conf/domain_conf.c | 20 ++-
src/conf/domain_conf.h | 1 +
src/security/security_dac.c | 340 +++++++++++++++++++++++++++++++-------------
3 files changed, 260 insertions(+), 101 deletions(-)
--
1.8.0.2
12 years, 1 month
[libvirt] libvirt compilation error, libvirt.so: undefined reference to `xmlParseFile'
by nasb@ruedesrancy.org
Hi,
I'm currently trying to compile libvirt 1.0.2 on my custom
x86_64/uClibc environnement. Configuration goes well (./configure
--prefix=/usr --without-pyton), but during make I get the following
error message :
CCLD libvirtd
/lslbuild/svn/trunk/packages/virtualization/libvirt/libvirt-1.0.2/src/.libs/libvirt.so:
undefined reference to `xmlParseFile'
collect2: error: ld returned 1 exit status
Looks like a -lxml2 flag missing, but configure found the correct flags
according to the Makefile which contains :
LIBXML_CFLAGS = -I/usr/include/libxml2
LIBXML_LIBS = -lxml2
Does anyone have an idea on what's going wrong? What other informations
should I provide?
Thanks,
--
Eric LECAT
12 years, 1 month
[libvirt] Plan for the next release
by Daniel Veillard
February is short, but we are already at more then 180 commits
since 1.0.2 release, and well we ought to fix the python bindings
problems of 1.0.2 in an official release, so I think this makes
sense to push a new release at the end of the month.
I suggest to enter freeze in a week, targetting a 1.0.3 release
on the 28th or March 1st,
Daniel
--
Daniel Veillard | Open Source and Standards, Red Hat
veillard(a)redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
12 years, 1 month
[libvirt] How to catch libvirtd logs
by harryxiyou
Hi all,
I start a VM with command "virsh create hlfs.xml", which fork a child
process. But i am not sure how to catch this child process's logs?
Could anyone give me some suggestions? Thanks in advance.
--
Thanks
Harry Wei
12 years, 1 month
[libvirt] [PATCH] Add support for <option> tag in network config
by Pieter Hollants
This patch adds support for a new <option>-Tag in the <dhcp> block of network configs,
based on a subset of the fifth proposal by Laine Stump in the mailing list discussion at
https://www.redhat.com/archives/libvir-list/2012-November/msg01054.html. Any such defined
option will result in a dhcp-option=<number>,"<value>" statement in the generated dnsmasq
configuration file.
Currently, DHCP options can be specified by number only and there is no whitelisting or
blacklisting of option numbers, which should probably be added.
Signed-off-by: Pieter Hollants <pieter(a)hollants.com>
---
AUTHORS.in | 1 +
docs/schemas/network.rng | 6 +++
docs/schemas/networkcommon.rng | 6 +++
src/conf/network_conf.c | 54 +++++++++++++++++++++
src/conf/network_conf.h | 10 ++++
src/network/bridge_driver.c | 10 ++++
tests/networkxml2xmlin/netboot-network.xml | 1 +
tests/networkxml2xmlin/netboot-proxy-network.xml | 1 +
tests/networkxml2xmlout/netboot-network.xml | 1 +
tests/networkxml2xmlout/netboot-proxy-network.xml | 1 +
10 Dateien geändert, 91 Zeilen hinzugefügt(+)
diff --git a/AUTHORS.in b/AUTHORS.in
index 39fe68d..074185e 100644
--- a/AUTHORS.in
+++ b/AUTHORS.in
@@ -74,6 +74,7 @@ Michel Ponceau <michel.ponceau(a)bull.net>
Nobuhiro Itou <fj0873gn(a)aa.jp.fujitsu.com>
Pete Vetere <pvetere(a)redhat.com>
Philippe Berthault <philippe.berthault(a)Bull.net>
+Pieter Hollants <pieter(a)hollants.com>
Saori Fukuta <fukuta.saori(a)jp.fujitsu.com>
Shigeki Sakamoto <fj0588di(a)aa.jp.fujitsu.com>
Shuveb Hussain <shuveb(a)binarykarma.com>
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index 09d7c73..a2ce1c9 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -293,6 +293,12 @@
</optional>
</element>
</optional>
+ <zeroOrMore>
+ <element name="option">
+ <attribute name="number"><ref name="unsignedByte"/></attribute>
+ <attribute name="value"><text/></attribute>
+ </element>
+ </zeroOrMore>
</element>
</optional>
</element>
diff --git a/docs/schemas/networkcommon.rng b/docs/schemas/networkcommon.rng
index 51ff759..3510928 100644
--- a/docs/schemas/networkcommon.rng
+++ b/docs/schemas/networkcommon.rng
@@ -173,6 +173,12 @@
</data>
</define>
+ <define name='unsignedByte'>
+ <data type='integer'>
+ <param name="minInclusive">0</param>
+ <param name="maxInclusive">255</param>
+ </data>
+ </define>
<define name='unsignedShort'>
<data type='integer'>
<param name="minInclusive">0</param>
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 3604ff7..9d84c7e 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -777,6 +777,45 @@ cleanup:
}
static int
+virNetworkDHCPOptionDefParseXML(const char *networkName,
+ xmlNodePtr node,
+ virNetworkDHCPOptionDefPtr option)
+{
+ char *number = NULL;
+ int ret = -1;
+
+ if (!(number = virXMLPropString(node, "number"))) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Option definition in IPv4 network '%s' "
+ "must have number attribute"),
+ networkName);
+ goto cleanup;
+ }
+ if (number &&
+ virStrToLong_ui(number, NULL, 10, &option->number) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot parse <option> 'number' attribute"));
+ goto cleanup;
+ }
+ /* TODO: either whitelist numbers or blacklist numbers already occupied
+ * by other XML statements (eg. submask) */
+ if (!(option->value = virXMLPropString(node, "value"))) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Option definition in IPv4 network '%s' "
+ "must have value attribute"),
+ networkName);
+ goto cleanup;
+ }
+
+ ret = 0;
+
+cleanup:
+ VIR_FREE(number);
+ return ret;
+}
+
+
+static int
virNetworkDHCPDefParseXML(const char *networkName,
xmlNodePtr node,
virNetworkIpDefPtr def)
@@ -837,6 +876,17 @@ virNetworkDHCPDefParseXML(const char *networkName,
def->bootfile = file;
def->bootserver = inaddr;
VIR_FREE(server);
+ } else if (cur->type == XML_ELEMENT_NODE &&
+ xmlStrEqual(cur->name, BAD_CAST "option")) {
+ if (VIR_REALLOC_N(def->options, def->noptions + 1) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+ if (virNetworkDHCPOptionDefParseXML(networkName, cur,
+ &def->options[def->noptions])) {
+ return -1;
+ }
+ def->noptions++;
}
cur = cur->next;
@@ -2045,6 +2095,10 @@ virNetworkIpDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "/>\n");
}
+ for (ii = 0 ; ii < def->noptions ; ii++) {
+ virBufferAsprintf(buf, "<option number='%u' value='%s' />\n",
+ def->options[ii].number, def->options[ii].value);
+ }
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</dhcp>\n");
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 4c634ed..14f852a 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -77,6 +77,13 @@ struct _virNetworkDHCPHostDef {
virSocketAddr ip;
};
+typedef struct _virNetworkDHCPOptionDef virNetworkDHCPOptionDef;
+typedef virNetworkDHCPOptionDef *virNetworkDHCPOptionDefPtr;
+struct _virNetworkDHCPOptionDef {
+ unsigned int number;
+ char *value;
+};
+
typedef struct _virNetworkDNSTxtDef virNetworkDNSTxtDef;
typedef virNetworkDNSTxtDef *virNetworkDNSTxtDefPtr;
struct _virNetworkDNSTxtDef {
@@ -139,6 +146,9 @@ struct _virNetworkIpDef {
char *tftproot;
char *bootfile;
virSocketAddr bootserver;
+
+ size_t noptions; /* Zero or more additional dhcp options */
+ virNetworkDHCPOptionDefPtr options;
};
typedef struct _virNetworkForwardIfDef virNetworkForwardIfDef;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index c834f83..c7c0a9e 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -926,6 +926,15 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
virBufferAsprintf(&configbuf, "dhcp-boot=%s\n", ipdef->bootfile);
}
}
+
+ /* Any additional DHCP options? */
+ if (ipdef->noptions > 0) {
+ for (r = 0 ; r < ipdef->noptions ; r++) {
+ virBufferAsprintf(&configbuf, "dhcp-option=%u,\"%s\"\n",
+ ipdef->options[r].number,
+ ipdef->options[r].value);
+ }
+ }
}
ipdef = (ipdef == ipv6def) ? NULL : ipv6def;
}
@@ -959,6 +968,7 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
virBufferAsprintf(&configbuf, "addn-hosts=%s\n",
dctx->addnhostsfile->path);
+
/* Are we doing RA instead of radvd? */
if (DNSMASQ_RA_SUPPORT(caps)) {
if (ipv6def)
diff --git a/tests/networkxml2xmlin/netboot-network.xml b/tests/networkxml2xmlin/netboot-network.xml
index ed75663..4de8976 100644
--- a/tests/networkxml2xmlin/netboot-network.xml
+++ b/tests/networkxml2xmlin/netboot-network.xml
@@ -9,6 +9,7 @@
<dhcp>
<range start="192.168.122.2" end="192.168.122.254" />
<bootp file="pxeboot.img" />
+ <option number="252" value="\n" />
</dhcp>
</ip>
</network>
diff --git a/tests/networkxml2xmlin/netboot-proxy-network.xml b/tests/networkxml2xmlin/netboot-proxy-network.xml
index ecb6738..4c5c480 100644
--- a/tests/networkxml2xmlin/netboot-proxy-network.xml
+++ b/tests/networkxml2xmlin/netboot-proxy-network.xml
@@ -8,6 +8,7 @@
<dhcp>
<range start="192.168.122.2" end="192.168.122.254" />
<bootp file="pxeboot.img" server="10.20.30.40" />
+ <option number="252" value="\n" />
</dhcp>
</ip>
</network>
diff --git a/tests/networkxml2xmlout/netboot-network.xml b/tests/networkxml2xmlout/netboot-network.xml
index b8a4d99..c3ea95a 100644
--- a/tests/networkxml2xmlout/netboot-network.xml
+++ b/tests/networkxml2xmlout/netboot-network.xml
@@ -9,6 +9,7 @@
<dhcp>
<range start='192.168.122.2' end='192.168.122.254' />
<bootp file='pxeboot.img' />
+ <option number='252' value='\n' />
</dhcp>
</ip>
</network>
diff --git a/tests/networkxml2xmlout/netboot-proxy-network.xml b/tests/networkxml2xmlout/netboot-proxy-network.xml
index e11c50b..f5f2c0d 100644
--- a/tests/networkxml2xmlout/netboot-proxy-network.xml
+++ b/tests/networkxml2xmlout/netboot-proxy-network.xml
@@ -8,6 +8,7 @@
<dhcp>
<range start='192.168.122.2' end='192.168.122.254' />
<bootp file='pxeboot.img' server='10.20.30.40' />
+ <option number='252' value='\n' />
</dhcp>
</ip>
</network>
--
1.7.10.4
12 years, 1 month
[libvirt] [PATCH] build: fix vircommand build on mingw
by Eric Blake
CC libvirt_util_la-vircommand.lo
../../src/util/vircommand.c:2358:1: error: 'virCommandHandshakeChild' defined but not used [-Werror=unused-function]
* src/util/vircommand.c (virCommandHandshakeChild): Hoist earlier,
so that win32 build doesn't hit an unused forward declaration.
---
Pushing under the build-breaker rule.
src/util/vircommand.c | 98 +++++++++++++++++++++++++--------------------------
1 file changed, 48 insertions(+), 50 deletions(-)
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 5837fee..ee1b510 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -118,8 +118,6 @@ struct _virCommand {
#endif
};
-static int virCommandHandshakeChild(virCommandPtr cmd);
-
/*
* virCommandFDIsSet:
* @fd: FD to test
@@ -332,6 +330,54 @@ prepareStdFd(int fd, int std)
return 0;
}
+/* virCommandHandshakeChild:
+ *
+ * child side of handshake - called by child process in virExec() to
+ * indicate to parent that the child process has successfully
+ * completed its pre-exec initialization.
+ */
+static int
+virCommandHandshakeChild(virCommandPtr cmd)
+{
+ char c = '1';
+ int rv;
+
+ if (!cmd->handshake)
+ return true;
+
+ VIR_DEBUG("Notifying parent for handshake start on %d",
+ cmd->handshakeWait[1]);
+ if (safewrite(cmd->handshakeWait[1], &c, sizeof(c)) != sizeof(c)) {
+ virReportSystemError(errno, "%s",
+ _("Unable to notify parent process"));
+ return -1;
+ }
+
+ VIR_DEBUG("Waiting on parent for handshake complete on %d",
+ cmd->handshakeNotify[0]);
+ if ((rv = saferead(cmd->handshakeNotify[0], &c,
+ sizeof(c))) != sizeof(c)) {
+ if (rv < 0)
+ virReportSystemError(errno, "%s",
+ _("Unable to wait on parent process"));
+ else
+ virReportSystemError(EIO, "%s",
+ _("libvirtd quit during handshake"));
+ return -1;
+ }
+ if (c != '1') {
+ virReportSystemError(EINVAL,
+ _("Unexpected confirm code '%c' from parent"),
+ c);
+ return -1;
+ }
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
+
+ VIR_DEBUG("Handshake with parent is done");
+ return 0;
+}
+
/*
* virExec:
* @cmd virCommandPtr containing all information about the program to
@@ -2348,54 +2394,6 @@ void virCommandRequireHandshake(virCommandPtr cmd)
cmd->handshake = true;
}
-/* virCommandHandshakeChild:
- *
- * child side of handshake - called by child process in virExec() to
- * indicate to parent that the child process has successfully
- * completed its pre-exec initialization.
- */
-static int
-virCommandHandshakeChild(virCommandPtr cmd)
-{
- char c = '1';
- int rv;
-
- if (!cmd->handshake)
- return true;
-
- VIR_DEBUG("Notifying parent for handshake start on %d",
- cmd->handshakeWait[1]);
- if (safewrite(cmd->handshakeWait[1], &c, sizeof(c)) != sizeof(c)) {
- virReportSystemError(errno, "%s",
- _("Unable to notify parent process"));
- return -1;
- }
-
- VIR_DEBUG("Waiting on parent for handshake complete on %d",
- cmd->handshakeNotify[0]);
- if ((rv = saferead(cmd->handshakeNotify[0], &c,
- sizeof(c))) != sizeof(c)) {
- if (rv < 0)
- virReportSystemError(errno, "%s",
- _("Unable to wait on parent process"));
- else
- virReportSystemError(EIO, "%s",
- _("libvirtd quit during handshake"));
- return -1;
- }
- if (c != '1') {
- virReportSystemError(EINVAL,
- _("Unexpected confirm code '%c' from parent"),
- c);
- return -1;
- }
- VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
- VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
-
- VIR_DEBUG("Handshake with parent is done");
- return 0;
-}
-
/**
* virCommandHandshakeWait:
* @cmd: command to wait on
--
1.8.1.2
12 years, 1 month