Devel
Threads by month
- ----- 2026 -----
- March
- February
- 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
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- 25 participants
- 40112 discussions
[libvirt] [PATCH 0/8] Simplify mutually exclusive argument handling in virsh
by Peter Krempa 21 Mar '13
by Peter Krempa 21 Mar '13
21 Mar '13
This patchset introduces a new macro that allows simple checking for mutually
exclusive arguments in virsh and uses it in many occasions in virs.
Peter Krempa (8):
virsh: Introduce macros to reject mutually exclusive arguments
virsh-snapshot: Refactor virsh snapshot-list
virsh-host: Refactor cmdFreecell
virsh-domain: Fix flag name in error message to match the check
virsh-snapshot: Refactor cmdSnapshotCurrent
virsh-snapshot: Use the mutually exclusive params macro in
cmdSnapshotEdit
virsh-snapshot: Simplify cleanup path in cmdSnapshotEdit
virsh-domain: Simplify usage of --current, --live and --config flags
po/POTFILES.in | 1 +
tools/virsh-domain.c | 262 +++++++++++++++++++++----------------------------
tools/virsh-host.c | 55 +++++------
tools/virsh-snapshot.c | 181 +++++++++++++---------------------
tools/virsh.h | 42 ++++++++
5 files changed, 248 insertions(+), 293 deletions(-)
--
1.8.1.1
2
18
21 Mar '13
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The recent commit moved some of the use of libnuma out of the
driver code, and into src/util/. It did not, however, update
libvirt_util.la to link against libnuma. This caused linkage
failure with virt-aa-helper, since nothing else caused libnuma
to be pulled onto the linker command line.
The fix removes all reference to NUMACTL_LIBS/CFLAGS from the
various modules in src/Makefile.am and just adds them to the
libvirt_util.la module, which everything else depends on.
Technically a build-breaker fix, but wanted to wait for feedback
on this
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/Makefile.am | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 21f8882..3f69d39 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -768,11 +768,11 @@ libvirt_util_la_SOURCES = \
$(UTIL_SOURCES)
libvirt_util_la_CFLAGS = $(CAPNG_CFLAGS) $(YAJL_CFLAGS) $(LIBNL_CFLAGS) \
$(AM_CFLAGS) $(AUDIT_CFLAGS) $(DEVMAPPER_CFLAGS) \
- $(DBUS_CFLAGS) $(LDEXP_LIBM)
+ $(DBUS_CFLAGS) $(LDEXP_LIBM) $(NUMACTL_CFLAGS)
libvirt_util_la_LIBADD = $(CAPNG_LIBS) $(YAJL_LIBS) $(LIBNL_LIBS) \
$(THREAD_LIBS) $(AUDIT_LIBS) $(DEVMAPPER_LIBS) \
$(LIB_CLOCK_GETTIME) $(DBUS_LIBS) $(MSCOM_LIBS) $(LIBXML_LIBS) \
- $(SECDRIVER_LIBS)
+ $(SECDRIVER_LIBS) $(NUMACTL_LIBS)
noinst_LTLIBRARIES += libvirt_conf.la
@@ -809,10 +809,10 @@ libvirt_la_BUILT_LIBADD += libvirt_driver.la
libvirt_driver_la_SOURCES = $(DRIVER_SOURCES)
libvirt_driver_la_CFLAGS = \
- $(NUMACTL_CFLAGS) $(GNUTLS_CFLAGS) $(CURL_CFLAGS) \
+ $(GNUTLS_CFLAGS) $(CURL_CFLAGS) \
-I$(top_srcdir)/src/conf $(AM_CFLAGS)
libvirt_driver_la_LIBADD = \
- $(NUMACTL_LIBS) $(GNUTLS_LIBS) $(CURL_LIBS) $(DLOPEN_LIBS)
+ $(GNUTLS_LIBS) $(CURL_LIBS) $(DLOPEN_LIBS)
SYM_FILES = $(USED_SYM_FILES)
USED_SYM_FILES = $(srcdir)/libvirt_private.syms
@@ -958,13 +958,11 @@ noinst_LTLIBRARIES += libvirt_driver_qemu.la
#libvirt_la_BUILT_LIBADD += libvirt_driver_qemu.la
endif
-libvirt_driver_qemu_impl_la_CFLAGS = $(NUMACTL_CFLAGS) \
- $(GNUTLS_CFLAGS) \
+libvirt_driver_qemu_impl_la_CFLAGS = $(GNUTLS_CFLAGS) \
$(LIBNL_CFLAGS) \
-I$(top_srcdir)/src/conf $(AM_CFLAGS)
libvirt_driver_qemu_impl_la_LDFLAGS = $(AM_LDFLAGS)
-libvirt_driver_qemu_impl_la_LIBADD = $(NUMACTL_LIBS) \
- $(CAPNG_LIBS) \
+libvirt_driver_qemu_impl_la_LIBADD = $(CAPNG_LIBS) \
$(GNUTLS_LIBS) \
$(LIBNL_LIBS)
libvirt_driver_qemu_impl_la_SOURCES = $(QEMU_DRIVER_SOURCES)
@@ -1029,10 +1027,10 @@ noinst_LTLIBRARIES += libvirt_driver_uml.la
#libvirt_la_BUILT_LIBADD += libvirt_driver_uml.la
endif
-libvirt_driver_uml_impl_la_CFLAGS = $(NUMACTL_CFLAGS) \
+libvirt_driver_uml_impl_la_CFLAGS = \
-I$(top_srcdir)/src/conf $(AM_CFLAGS)
libvirt_driver_uml_impl_la_LDFLAGS = $(AM_LDFLAGS)
-libvirt_driver_uml_impl_la_LIBADD = $(NUMACTL_LIBS)
+# libvirt_driver_uml_impl_la_LIBADD =
libvirt_driver_uml_impl_la_SOURCES = $(UML_DRIVER_SOURCES)
endif
@@ -1969,7 +1967,6 @@ libvirt_lxc_SOURCES = \
$(DATATYPES_SOURCES)
libvirt_lxc_LDFLAGS = $(WARN_CFLAGS) $(AM_LDFLAGS)
libvirt_lxc_LDADD = \
- $(NUMACTL_LIBS) \
$(FUSE_LIBS) \
libvirt-net-rpc-server.la \
libvirt-net-rpc.la \
--
1.8.1.4
2
3
The patch covers all nwfilter api provided by libvirt.py. It includes
define/undefine/list nwfilters and check them via checking ebtables rule.
The following new files are added.
cases/nwfilter.conf
repos/nwfilter/__init__.py
repos/nwfilter/nwfilter_check.py
* Check the nwfilter via checking ebtales
repos/nwfilter/nwfilter_define.py
* Define the nwfilter using specified value
repos/nwfilter/nwfilter_list.py
* List all of the available network filters
repos/nwfilter/nwfilter_undefine.py
* Undefine the specified nwfilter
repos/nwfilter/xmls/nwfilter.xml
---
cases/nwfilter.conf | 59 +++++++++++++++++
repos/nwfilter/nwfilter_check.py | 120 +++++++++++++++++++++++++++++++++++
repos/nwfilter/nwfilter_define.py | 54 ++++++++++++++++
repos/nwfilter/nwfilter_list.py | 76 ++++++++++++++++++++++
repos/nwfilter/nwfilter_undefine.py | 43 +++++++++++++
repos/nwfilter/xmls/nwfilter.xml | 3 +
6 files changed, 355 insertions(+), 0 deletions(-)
create mode 100644 cases/nwfilter.conf
create mode 100644 repos/nwfilter/__init__.py
create mode 100644 repos/nwfilter/nwfilter_check.py
create mode 100644 repos/nwfilter/nwfilter_define.py
create mode 100644 repos/nwfilter/nwfilter_list.py
create mode 100644 repos/nwfilter/nwfilter_undefine.py
create mode 100644 repos/nwfilter/xmls/nwfilter.xml
diff --git a/cases/nwfilter.conf b/cases/nwfilter.conf
new file mode 100644
index 0000000..b394ee5
--- /dev/null
+++ b/cases/nwfilter.conf
@@ -0,0 +1,59 @@
+domain:install_linux_cdrom
+ guestname
+ $defaultname
+ guestos
+ $defaultos
+ guestarch
+ $defaultarch
+ vcpu
+ $defaultvcpu
+ memory
+ $defaultmem
+ hddriver
+ $defaulthd
+ nicdriver
+ $defaultnic
+ imageformat
+ qcow2
+ macaddr
+ 54:52:00:4a:16:30
+
+nwfilter:nwfilter_list
+
+# chain -- ipv4, ipv6, arp .etc
+# action -- mandatory; drop, accept, return
+# direction -- mandatory; must either be in, out or inout
+nwfilter:nwfilter_define
+ nwfiltername
+ disallow-arp
+ chain
+ arp
+ action
+ drop
+ direction
+ inout
+
+nwfilter:nwfilter_list
+
+nwfilter:nwfilter_check
+ nwfiltername
+ disallow-arp
+ guestname
+ $defaultname
+
+nwfilter:nwfilter_define
+ nwfiltername
+ disallow-ipv6
+ chain
+ ipv6
+ action
+ drop
+ direction
+ in
+
+nwfilter:nwfilter_undefine
+ nwfiltername
+ disallow-ipv6
+
+nwfilter:nwfilter_list
+
diff --git a/repos/nwfilter/__init__.py b/repos/nwfilter/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/repos/nwfilter/nwfilter_check.py b/repos/nwfilter/nwfilter_check.py
new file mode 100644
index 0000000..b2c7ece
--- /dev/null
+++ b/repos/nwfilter/nwfilter_check.py
@@ -0,0 +1,120 @@
+#!/usr/bin/env python
+import time
+import xml.dom.minidom
+
+from libvirt import libvirtError
+from utils import utils
+from xml.dom import minidom
+
+from src import sharedmod
+
+required_params = ('nwfiltername','guestname',)
+optional_params = {}
+
+EBTABLES = "ebtables -t nat -L"
+
+def get_ebtables():
+ """ Get the output of ebtables """
+ (status, output) = utils.exec_cmd(EBTABLES,shell=True)
+ logger.info("Execute command:" + EBTABLES)
+ ebtables_list = []
+
+ if status:
+ logger.error("Executing " + EBTABLES + " failed")
+ logger.error(output)
+ return False
+ else:
+ for i in range(len(output)):
+ ebtables_list.append(output[i])
+ logger.info("Get the output of ebtables list: %s" \
+ % ebtables_list)
+
+ return ebtables_list
+
+def check_ebtables(*args):
+ """ Check the ebtables """
+ (nwfiltername,conn)= args
+ ebtables_list = get_ebtables()
+
+ #Get the filter' attribute value
+ nwfilter_xml = conn.nwfilterLookupByName(nwfiltername).XMLDesc(0)
+ nwfilter_parsedxml = minidom.parseString(nwfilter_xml)
+ chain = nwfilter_parsedxml.getElementsByTagName("filter")[0].\
+ getAttribute("chain")
+ rule = nwfilter_parsedxml.getElementsByTagName("rule")[0]
+ action = rule.getAttribute("action").upper()
+ direction = rule.getAttribute("direction")
+ logger.info("The nwfilter chain:%s ,action:%s ,direction:%s " %\
+ (chain,action,direction) )
+ in_vnet_chain = "I-vnet0-" + chain
+ out_vnet_chain = "O-vnet0-" + chain
+
+ if cmp(direction,"inout") == 0 :
+ if len(ebtables_list) == 21 and in_vnet_chain in ebtables_list[-5]\
+ and out_vnet_chain in ebtables_list[-2] \
+ and action in ebtables_list[-1] \
+ and action in ebtables_list[-4]:
+ return True
+ else:
+ return False
+ elif cmp(direction,"in") == 0:
+ if len(ebtables_list) == 14 and out_vnet_chain in ebtables_list[-2]\
+ and action in ebtables_list[-1]:
+ return True
+ else:
+ return False
+
+ elif cmp(direction,"out") == 0:
+ if len(ebtables_list) == 14 and in_vnet_chain in ebtables_list[-2] \
+ and action in ebtables_list[-1]:
+ return True
+ else:
+ return False
+
+def nwfilter_check(params):
+ """Check the nwfilter via checking ebtales"""
+ global logger
+ logger = params['logger']
+ nwfiltername = params['nwfiltername']
+ guestname = params['guestname']
+ domain_nwfilter_xml = ""
+
+ conn = sharedmod.libvirtobj['conn']
+ domobj = conn.lookupByName(guestname)
+
+ try:
+
+ #Create the nwfilter's element and append it to domain xml
+ domxml = domobj.XMLDesc(0)
+ domain_parsedxml = minidom.parseString(domxml)
+ domain_ifxml = domain_parsedxml.getElementsByTagName("interface")
+ filterxml = domain_parsedxml.createElement("filterref")
+ filterxml.setAttribute("filter", nwfiltername)
+ domain_ifxml[0].appendChild(filterxml)
+
+ #Destroy the domain and redefine it with nwfilter
+ domobj.destroy()
+ time.sleep(5)
+ domobj.undefine()
+
+ #Define the new domain with the nwfilter
+ dom_nwfilter = conn.defineXML(domain_parsedxml.toxml())
+ logger.debug("The xml of new defined domain with nwfilter %s" % \
+ dom_nwfilter.XMLDesc(0))
+
+ #Start the new defined domain
+ dom_nwfilter.create()
+ time.sleep(5)
+
+ if check_ebtables(nwfiltername,conn):
+ logger.info("Successfully create nwfilter")
+ return 0
+ else:
+ logger.error("Failed to create nwfilter")
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s" % e.message)
+ return 1
+
+ return 0
\ No newline at end of file
diff --git a/repos/nwfilter/nwfilter_define.py b/repos/nwfilter/nwfilter_define.py
new file mode 100644
index 0000000..e20fd2d
--- /dev/null
+++ b/repos/nwfilter/nwfilter_define.py
@@ -0,0 +1,54 @@
+#! /usr/bin/env python
+
+
+
+from libvirt import libvirtError
+from src import sharedmod
+
+
+required_params = ('nwfiltername','chain','action','direction')
+optional_params = {'xml' : 'xmls/nwfilter.xml',}
+
+def nwfilter_define(params):
+ """ Define network filters."""
+ logger = params['logger']
+ conn = sharedmod.libvirtobj['conn']
+ xmlstr = params['xml']
+ nwfiltername = params['nwfiltername']
+ chain = params['chain']
+ action = params['action']
+ direction = params['direction']
+
+
+ xmlstr = xmlstr.replace('NWFILTERNAME', nwfiltername)
+ xmlstr = xmlstr.replace('CHAIN', chain)
+ xmlstr = xmlstr.replace('ACTION', action)
+ xmlstr = xmlstr.replace('DIRECTION', direction)
+ try:
+ logger.info("nwfiltername:%s chain:%s action:%s direction:%s" % \
+ (nwfiltername,chain,action,direction))
+ logger.info("The nwfilter's xml is %s" % xmlstr)
+
+ #Define the nwfilter with given attribute value from nwfilter.conf"""
+ conn.nwfilterDefineXML(xmlstr)
+ nwfilterxml = conn.nwfilterLookupByName(nwfiltername).XMLDesc(0)
+
+ if nwfiltername in conn.listNWFilters():
+ logger.info("The nwfilter list includes the defined nwfilter")
+ if cmp(xmlstr,nwfilterxml):
+ logger.info("Successfully define the nwfilter %s" % \
+ nwfiltername)
+ return 0
+ else:
+ logger.error("Fail to define the nwfilter %s" % nwfiltername)
+ return 1
+ else:
+ logger.error("Failed,nwfilter list doesn't include the defined \
+ nwfilter")
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s" % e.message)
+ return 1
+
+ return 0
\ No newline at end of file
diff --git a/repos/nwfilter/nwfilter_list.py b/repos/nwfilter/nwfilter_list.py
new file mode 100644
index 0000000..056ee1f
--- /dev/null
+++ b/repos/nwfilter/nwfilter_list.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+
+from libvirt import libvirtError
+from utils import utils
+
+from src import sharedmod
+
+required_params = ()
+optional_params = {}
+
+NWFILTER_LIST_API_DIR = "ls /etc/libvirt/nwfilter"
+
+def get_nwfilterlist_dir():
+ """ Get the nwfilter list from dir """
+
+ (status, output) = utils.exec_cmd(NWFILTER_LIST_API_DIR,shell=True)
+ logger.info("Execute command:" + NWFILTER_LIST_API_DIR)
+ nwfilter_list_api_dir = []
+ if status:
+ logger.error("Executing " + NWFILTER_LIST_API_DIR + " failed")
+ logger.error(output)
+ return False
+ else:
+ for i in range(len(output)):
+ nwfilter_list_api_dir.append(output[i][:-4])
+ logger.info("Get nwfilters name list under dir: %s" \
+ % nwfilter_list_api_dir)
+ return nwfilter_list_api_dir
+
+def nwfilter_list(params):
+ """ List all of the available network filters."""
+ global logger
+ logger = params['logger']
+ conn = sharedmod.libvirtobj['conn']
+
+ try:
+ #Get the nwfilter name list from API """
+ nwfilter_namelist_api = conn.listNWFilters()
+
+ #Get the nwfilter object list
+ nwfilter_list_api = conn.listAllNWFilters(0)
+ logger.info("The connection URI %s" % \
+ nwfilter_list_api[0].connect().getURI())
+
+ #Get the number of nwfilters from API
+ nwfilter_num = conn.numOfNWFilters()
+
+ nwfilter_list_dir = get_nwfilterlist_dir()
+ if nwfilter_num == len(nwfilter_list_api) and \
+ len(nwfilter_list_api) == len(nwfilter_list_dir) and \
+ cmp(nwfilter_namelist_api,nwfilter_list_dir):
+ logger.info("The number of available network filters is %s" % \
+ nwfilter_num)
+ else:
+ logger.error("Failed to get the nwfilters list")
+ return 1
+
+ for nwfilter_item in nwfilter_list_api:
+ if nwfilter_item.name()in nwfilter_list_dir and \
+ nwfilter_item.name()in nwfilter_namelist_api:
+ logger.info("The name is %s" % nwfilter_item.name())
+ else:
+ logger.error("Failed to get nwfilter's name.")
+ return 1
+ if cmp(str(nwfilter_item.UUID()),nwfilter_item.UUIDString()):
+ logger.info("The UUID is %s" % nwfilter_item.UUIDString())
+ else:
+ logger.error("Failed to get nwfilter's uuid.")
+ return 1
+
+
+ except libvirtError, e:
+ logger.error("API error message: %s" % e.message)
+ return 1
+
+ return 0
\ No newline at end of file
diff --git a/repos/nwfilter/nwfilter_undefine.py b/repos/nwfilter/nwfilter_undefine.py
new file mode 100644
index 0000000..b9ea332
--- /dev/null
+++ b/repos/nwfilter/nwfilter_undefine.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('nwfiltername',)
+optional_params = {}
+
+def nwfilter_undefine(params):
+ """Undefine the specified nwfilter"""
+ logger = params['logger']
+ nwfiltername = params['nwfiltername']
+ conn = sharedmod.libvirtobj['conn']
+
+ try:
+ nwfilter = conn.nwfilterLookupByName(nwfiltername)
+ uuidstr = nwfilter.UUIDString()
+ uuid = nwfilter.UUID()
+ # Lookup by nwfilter's uuid string
+ nwfilter_uuidstr = conn.nwfilterLookupByUUIDString(uuidstr)
+ # Lookup by nwfilter's uuid
+ nwfilter_uuid = conn.nwfilterLookupByUUID(uuid)
+
+ # Check if the nwfilter lookup by name/uuid/uuidstr is the same one
+ if cmp(nwfilter,nwfilter_uuidstr) and cmp(nwfilter_uuidstr,\
+ nwfilter_uuid):
+ # Undefine the nwfilter
+ nwfilter.undefine()
+ # Check if the nwfiler list includes the undefined nwfilter
+ if nwfiltername not in conn.listNWFilters():
+ logger.info("Successfully undefine the nwfilter %s" % \
+ nwfiltername)
+ return 0
+ else:
+ logger.error("Failed to undefine the nwfilter %s" % nwfiltername)
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s" % e.message)
+ return 1
+
+ return 0
diff --git a/repos/nwfilter/xmls/nwfilter.xml b/repos/nwfilter/xmls/nwfilter.xml
new file mode 100644
index 0000000..6d52d5d
--- /dev/null
+++ b/repos/nwfilter/xmls/nwfilter.xml
@@ -0,0 +1,3 @@
+<filter name='NWFILTERNAME' chain='CHAIN'>
+ <rule action='ACTION' direction='DIRECTION' priority='500'/>
+</filter>
--
1.7.7.6
2
1
[libvirt] [PATCH] qemu: s/VIR_ERR_NO_SUPPORT/VIR_ERR_OPERATION_UNSUPPORTED
by Michal Privoznik 21 Mar '13
by Michal Privoznik 21 Mar '13
21 Mar '13
The VIR_ERR_NO_SUPPORT error code is reserved for cases where an
API is not implemented in a driver. It definitely should not be
used when an API execution fails due to unsupported operation.
---
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_hotplug.c | 30 +++++++++++++++---------------
src/qemu/qemu_monitor.c | 2 +-
src/qemu/qemu_monitor_text.c | 2 +-
src/qemu/qemu_process.c | 2 +-
5 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9cd9e44..c6e579f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3141,7 +3141,7 @@ static int qemuDumpToFd(virQEMUDriverPtr driver, virDomainObjPtr vm,
int ret = -1;
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DUMP_GUEST_MEMORY)) {
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("dump-guest-memory is not supported"));
return -1;
}
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 044f8cd..de9edd4 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1468,7 +1468,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
int ret = -1;
if (!devslot || !(olddev = *devslot)) {
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("cannot find existing network device to modify"));
goto cleanup;
}
@@ -1476,7 +1476,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
oldType = virDomainNetGetActualType(olddev);
if (oldType == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
/* no changes are possible to a type='hostdev' interface */
- virReportError(VIR_ERR_NO_SUPPORT,
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change config of '%s' network type"),
virDomainNetTypeToString(oldType));
goto cleanup;
@@ -1499,7 +1499,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
if (virMacAddrCmp(&olddev->mac, &newdev->mac)) {
char oldmac[VIR_MAC_STRING_BUFLEN], newmac[VIR_MAC_STRING_BUFLEN];
- virReportError(VIR_ERR_NO_SUPPORT,
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change network interface mac address "
"from %s to %s"),
virMacAddrFormat(&olddev->mac, oldmac),
@@ -1508,7 +1508,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
}
if (STRNEQ_NULLABLE(olddev->model, newdev->model)) {
- virReportError(VIR_ERR_NO_SUPPORT,
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot modify network device model from %s to %s"),
olddev->model ? olddev->model : "(default)",
newdev->model ? newdev->model : "(default)");
@@ -1520,7 +1520,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
olddev->driver.virtio.txmode != newdev->driver.virtio.txmode ||
olddev->driver.virtio.ioeventfd != newdev->driver.virtio.ioeventfd ||
olddev->driver.virtio.event_idx != newdev->driver.virtio.event_idx)) {
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify virtio network device driver attributes"));
goto cleanup;
}
@@ -1534,7 +1534,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
}
if (STRNEQ_NULLABLE(olddev->script, newdev->script)) {
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network device script attribute"));
goto cleanup;
}
@@ -1546,7 +1546,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
goto cleanup;
}
if (STRNEQ_NULLABLE(olddev->ifname, newdev->ifname)) {
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network device tap name"));
goto cleanup;
}
@@ -1564,7 +1564,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
}
if (!virDevicePCIAddressEqual(&olddev->info.addr.pci,
&newdev->info.addr.pci)) {
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network device guest PCI address"));
goto cleanup;
}
@@ -1575,22 +1575,22 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
goto cleanup;
}
if (STRNEQ_NULLABLE(olddev->info.alias, newdev->info.alias)) {
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network device alias"));
goto cleanup;
}
if (olddev->info.rombar != newdev->info.rombar) {
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network device rom bar setting"));
goto cleanup;
}
if (STRNEQ_NULLABLE(olddev->info.romfile, newdev->info.romfile)) {
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network rom file"));
goto cleanup;
}
if (olddev->info.bootIndex != newdev->info.bootIndex) {
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network device boot index setting"));
goto cleanup;
}
@@ -1617,7 +1617,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
if (newType == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
/* can't turn it into a type='hostdev' interface */
- virReportError(VIR_ERR_NO_SUPPORT,
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change network interface type to '%s'"),
virDomainNetTypeToString(newType));
goto cleanup;
@@ -1675,7 +1675,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
break;
default:
- virReportError(VIR_ERR_NO_SUPPORT,
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("unable to change config on '%s' network type"),
virDomainNetTypeToString(newdev->type));
break;
@@ -1746,7 +1746,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
/* FINALLY - actually perform the required actions */
if (needReconnect) {
- virReportError(VIR_ERR_NO_SUPPORT,
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("unable to change config on '%s' network type"),
virDomainNetTypeToString(newdev->type));
goto cleanup;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 175aa57..30f7820 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2121,7 +2121,7 @@ qemuMonitorDumpToFd(qemuMonitorPtr mon, int fd)
/* We don't have qemuMonitorTextDump(), so we should check mon->json
* here.
*/
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("dump-guest-memory is not supported in text mode"));
return -1;
}
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 1b6efba..68df49d 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -470,7 +470,7 @@ int qemuMonitorTextSetLink(qemuMonitorPtr mon, const char *name, enum virDomainN
/* check if set_link command is supported */
if (strstr(info, "\nunknown ")) {
- virReportError(VIR_ERR_NO_SUPPORT,
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
"%s",
_("\'set_link\' not supported by this qemu"));
goto error;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2465938..0e1c286 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2021,7 +2021,7 @@ qemuProcessSetLinkStates(virDomainObjPtr vm)
VIR_DEBUG("Setting link state: %s", def->nets[i]->info.alias);
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("Setting of link state is not supported by this qemu"));
return -1;
}
--
1.8.1.5
2
2
21 Mar '13
Wanting to resolve rhbz#919372 (fixed in [3/4]) I came accross few
things that could've used some polishing, so here's the series.
Martin Kletzander (4):
Make vshDebug work when parsing parameters
Fix snapshot-create-as syntax in help output
Allow multiple parameters for schedinfo
Cleanup useless flags specifications
tools/virsh-domain-monitor.c | 26 ----
tools/virsh-domain.c | 274 ++++---------------------------------------
tools/virsh-host.c | 10 --
tools/virsh-interface.c | 7 --
tools/virsh-network.c | 12 --
tools/virsh-nodedev.c | 3 -
tools/virsh-pool.c | 23 ----
tools/virsh-secret.c | 4 -
tools/virsh-snapshot.c | 61 +---------
tools/virsh-volume.c | 29 -----
tools/virsh.c | 13 +-
11 files changed, 29 insertions(+), 433 deletions(-)
--
1.8.1.5
3
15
[libvirt] [PATCH] qemu: Add the new disk src into shared disk table when updating disk
by Osier Yang 21 Mar '13
by Osier Yang 21 Mar '13
21 Mar '13
We should record the new disk src in the shared disk table for
updating disk (CD-ROM or Floppy) API. Fortunately, we only allow
to update the disk source now, otherwise we might also want to
set the unpriv_sgio setting.
---
src/qemu/qemu_driver.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9cd9e44..d0d2b9e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6067,6 +6067,10 @@ qemuDomainChangeDiskMediaLive(virDomainObjPtr vm,
}
dev->data.disk = tmp;
+ /* Add the new disk src into shared disk hash table */
+ if (qemuAddSharedDisk(driver, dev->data.disk, vm->def->name) < 0)
+ goto end;
+
ret = qemuDomainChangeEjectableMedia(driver, vm, disk, orig_disk, force);
if (ret == 0) {
dev->data.disk = NULL;
--
1.7.7.6
2
2
[libvirt] libvirtd(0.9.10) crashed with Segmentation fault, Is someone ever come up against this problem , thanks
by Caizhifeng 21 Mar '13
by Caizhifeng 21 Mar '13
21 Mar '13
HI all,
Libvirtd of version 0.9.10, when several VMs migrate intercurrently, there comes up with the follow problem.
Has anyone come up against this problem? How can I fix it, Any suggestions appreciated.
thank you very much.
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x00007fce7b332fde in ?? () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0 0x00007fce7b332fde in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007fce7b335a45 in malloc () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007fce7b330314 in _IO_str_overflow () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007fce7b32ebcd in _IO_default_xsputn () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007fce7b2fcbee in vfprintf () from /lib/x86_64-linux-gnu/libc.so.6
#5 0x00007fce7b325b64 in vasprintf () from /lib/x86_64-linux-gnu/libc.so.6
#6 0x0000000000504abc in virVasprintf (strp=0x7fce780b3bc0, fmt=0x7fce7ccbf8d1 "%d: %s : %s:%lld : %s\n", list=0x7fce780b3a20)
at util/util.c:1809
#7 0x0000000000504ba1 in virAsprintf (strp=0x7fce780b3bc0, fmt=0x7fce7ccbf8d1 "%d: %s : %s:%lld : %s\n") at util/util.c:1827
#8 0x00007fce7cba52a7 in virLogFormatString (msg=0x7fce780b3bc0, funcname=0x7fce7cce7320 "virNetServerHandleJob", linenr=138,
priority=1, str=0x7fce60011440 "server=0x252acf0 client=0x252f020 message=0x25363c0 prog=0x25361b0") at util/logging.c:640
#9 0x00007fce7cba5505 in virLogMessage (category=0x7fce7cce6f17 "file.rpc/virnetserver.c", priority=1,
funcname=0x7fce7cce7320 "virNetServerHandleJob", linenr=138, flags=0,
fmt=0x7fce7cce6ef0 "server=%p client=%p message=%p prog=%p") at util/logging.c:725
#10 0x00007fce7cc8ca7e in virNetServerHandleJob (jobOpaque=0x2531ca0, opaque=0x252acf0) at rpc/virnetserver.c:137
#11 0x00007fce7cbb52c6 in virThreadPoolWorker (opaque=0x25107b0) at util/threadpool.c:144
#12 0x00007fce7cbb4ccf in virThreadHelper (data=0x2510720) at util/threads-pthread.c:165
#13 0x00007fce7b87ae9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#14 0x00007fce7b3a54bd in clone () from /lib/x86_64-linux-gnu/libc.so.6
#15 0x0000000000000000 in ?? ()
(gdb) c
Continuing.
[Thread 0x7fce790b6700 (LWP 37763) exited]
-------------------------------------------------------------------------------------------------------------------------------------
????????????????????????????????????????
????????????????????????????????????????
????????????????????????????????????????
???
This e-mail and its attachments contain confidential information from H3C, which is
intended only for the person or entity whose address is listed above. Any use of the
information contained herein in any way (including, but not limited to, total or partial
disclosure, reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender
by phone or email immediately and delete it!
3
2
[libvirt] [PATCH] python: fix about some of python binding APIs don't raise and exception
by Guannan Ren 21 Mar '13
by Guannan Ren 21 Mar '13
21 Mar '13
For example:
>>> dom.memoryStats()
libvir: QEMU Driver error : Requested operation is not valid:\
domain is not running
There are six such python API functions like so.
The root reason is that generator.py script checks the type of return
value of a python stub function defined in libvirt-api.xml or
libvirt-override-api.xml to see whether adding the raise clause or not
in python wrapper code in libvirt.py.
The type of return value is supposed to be C types.
For those stub functions which return python non-integer data type like
string, list, tuple, dictionary, the existing type in functions varies
from each other which leads problem like this.
Currently, in generator.py, it maintains a buggy whitelist for stub functions
returning a list type. I think it is easy to forget adding new function name
in the whitelist.
This patch makes the value of type consistent with C type "char *"
in libvirt-override-api.xml. For python, any of types could be printed
as string, so I choose "char *"in this case. And the comment in xml
could explain it when adding new function definition.
<function name='virNodeGetCPUStats' file='python'>
...
- <return type='virNodeCPUStats' info='...'/>
+ <return type='char *' info='...'/>
...
</function>
---
python/generator.py | 10 ++--
python/libvirt-override-api.xml | 116 +++++++++++++++++++++-------------------
2 files changed, 66 insertions(+), 60 deletions(-)
diff --git a/python/generator.py b/python/generator.py
index 8236bd2..bebc644 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -1008,11 +1008,9 @@ functions_list_exception_test = {
}
functions_list_default_test = "%s is None"
-def is_list_type (name):
- whitelist = [ "virDomainBlockStats",
- "virDomainInterfaceStats" ]
+def is_python_noninteger_type (name):
- return name[-1:] == "*" or name in whitelist
+ return name[-1:] == "*"
def nameFixup(name, classe, type, file):
# avoid a desastrous clash
@@ -1386,7 +1384,7 @@ def buildWrappers(module):
("ret", name))
classes.write(" return ret\n")
- elif is_list_type (ret[0]):
+ elif is_python_noninteger_type (ret[0]):
if not functions_noexcept.has_key (name):
if functions_list_exception_test.has_key (name):
test = functions_list_exception_test[name]
@@ -1656,7 +1654,7 @@ def buildWrappers(module):
classes.write (" return ret\n")
- elif is_list_type (ret[0]):
+ elif is_python_noninteger_type (ret[0]):
if not functions_noexcept.has_key (name):
if functions_list_exception_test.has_key (name):
test = functions_list_exception_test[name]
diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml
index 5976fb2..6087f86 100644
--- a/python/libvirt-override-api.xml
+++ b/python/libvirt-override-api.xml
@@ -1,5 +1,13 @@
<?xml version="1.0"?>
<api name='libvir-python'>
+ <!-- This file lists libvirt API functions whose Python stubs are written by hand
+ in libvirt-override.c, but the Python-level code are still automatically generated
+ by generator.py script.
+
+ The type of return value is supposed to be C types. If a function's stub will return
+ a python non-integer data type like string, list, tuple, dictionary, etc,
+ please using "char *" as the type of its return value.
+ -->
<symbols>
<function name="virConnectGetVersion" file='python'>
<info>Returns the running hypervisor version of the connection host</info>
@@ -14,34 +22,34 @@
<function name="virConnectListDomainsID" file='python'>
<info>Returns the list of the ID of the domains on the hypervisor</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='int *' info="the list of ID or None in case of error"/>
+ <return type='char *' info="the list of ID or None in case of error"/>
</function>
<function name='virConnectListDefinedDomains' file='python'>
<info>list the defined domains, stores the pointers to the names in @names</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='str *' info='the list of Names or None in case of error'/>
+ <return type='char *' info='the list of Names or None in case of error'/>
</function>
<function name='virConnectListAllDomains' file='python'>
<info>returns list of all defined domains</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='domain *' info='the list of domains or None in case of error'/>
+ <return type='char *' info='the list of domains or None in case of error'/>
</function>
<function name='virConnectListNetworks' file='python'>
<info>list the networks, stores the pointers to the names in @names</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='str *' info='the list of Names or None in case of error'/>
+ <return type='char *' info='the list of Names or None in case of error'/>
</function>
<function name='virConnectListDefinedNetworks' file='python'>
<info>list the defined networks, stores the pointers to the names in @names</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='str *' info='the list of Names or None in case of error'/>
+ <return type='char *' info='the list of Names or None in case of error'/>
</function>
<function name='virConnectListAllNetworks' file='python'>
<info>returns list of all networks</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='network *' info='the list of networks or None in case of error'/>
+ <return type='char *' info='the list of networks or None in case of error'/>
</function>
<function name='virDomainLookupByUUID' file='python'>
<info>Try to lookup a domain on the given hypervisor based on its UUID.</info>
@@ -57,54 +65,54 @@
</function>
<function name='virDomainGetInfo' file='python'>
<info>Extract information about a domain. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.</info>
- <return type='int *' info='the list of information or None in case of error'/>
+ <return type='char *' info='the list of information or None in case of error'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
</function>
<function name='virDomainGetState' file='python'>
<info>Extract domain state.</info>
- <return type='int *' info='the list containing state and reason or None in case of error'/>
+ <return type='char *' info='the list containing state and reason or None in case of error'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
<arg name='flags' type='unsigned int' info='additional flags'/>
</function>
<function name='virDomainGetControlInfo' file='python'>
<info>Extract details about current state of control interface to a domain.</info>
- <return type='int *' info='the list of information or None in case of error'/>
+ <return type='char *' info='the list of information or None in case of error'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
<arg name='flags' type='unsigned int' info='additional flags'/>
</function>
<function name='virDomainGetBlockInfo' file='python'>
<info>Extract information about a domain block device size</info>
- <return type='int *' info='the list of information or None in case of error'/>
+ <return type='char *' info='the list of information or None in case of error'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
<arg name='path' type='const char *' info='path to the block device or file'/>
<arg name='flags' type='unsigned int' info='currently unused'/>
</function>
<function name='virDomainGetJobInfo' file='python'>
<info>Extract information about an active job being processed for a domain.</info>
- <return type='int *' info='the list of information or None in case of error'/>
+ <return type='char *' info='the list of information or None in case of error'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
</function>
<function name='virDomainGetJobStats' file='python'>
<info>Extract information about an active job being processed for a domain.</info>
- <return type='virDomainJobStats' info='dictionary mapping field names to values or None in case of error'/>
+ <return type='char *' info='dictionary mapping field names to values or None in case of error'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
<arg name='flags' type='unsigned int' info='flags, currently unused, pass 0.'/>
</function>
<function name='virNodeGetInfo' file='python'>
<info>Extract hardware information about the Node.</info>
- <return type='int *' info='the list of information or None in case of error'/>
+ <return type='char *' info='the list of information or None in case of error'/>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
</function>
<function name='virNodeGetCPUStats' file='python'>
<info>Extract node's CPU statistics.</info>
- <return type='virNodeCPUStats' info='dictionary mapping field names to values or None in case of error'/>
+ <return type='char *' info='dictionary mapping field names to values or None in case of error'/>
<arg name='conn' type='virConnectPtr' info='pointer to hypervisor connection'/>
<arg name='cpuNum' type='int' info='number of node cpu. (VIR_NODE_CPU_STATS_ALL_CPUS means total cpu statistics)'/>
<arg name='flags' type='unsigned int' info='additional flags'/>
</function>
<function name='virNodeGetMemoryStats' file='python'>
<info>Extract node's memory statistics.</info>
- <return type='virNodeMemoryStats' info='dictionary mapping field names to values or None in case of error'/>
+ <return type='char *' info='dictionary mapping field names to values or None in case of error'/>
<arg name='conn' type='virConnectPtr' info='pointer to hypervisor connection'/>
<arg name='cellNum' type='int' info='number of node cell. (VIR_NODE_MEMORY_STATS_ALL_CELLS means total cell statistics)'/>
<arg name='flags' type='unsigned int' info='additional flags'/>
@@ -156,13 +164,13 @@
</function>
<function name='virDomainBlockStats' file='python'>
<info>Extracts block device statistics for a domain</info>
- <return type='virDomainBlockStats' info='a tuple of statistics'/>
+ <return type='char *' info='a tuple of statistics'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
<arg name='path' type='char *' info='the path for the block device'/>
</function>
<function name='virDomainBlockStatsFlags' file='python'>
<info>Extracts block device statistics parameters of a running domain</info>
- <return type='str *' info='None in case of error, returns a dictionary of params'/>
+ <return type='char *' info='None in case of error, returns a dictionary of params'/>
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
<arg name='path' type='char *' info='the path for the block device'/>
<arg name='flags' type='int' info='flags (unused; pass 0)'/>
@@ -175,20 +183,20 @@
[{cpu_time:xxx}, {cpu_time:xxx}, ...]
If it is True or 1, it returns total domain CPU statistics in the format of
[{cpu_time:xxx, user_time:xxx, system_time:xxx}]</info>
- <return type='str *' info='returns a list of dictionary in case of success, None in case of error'/>
+ <return type='char *' info='returns a list of dictionary in case of success, None in case of error'/>
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
<arg name='total' type='bool' info='on true, return total domain CPU statistics, false return per-cpu info'/>
<arg name='flags' type='int' info='flags (unused; pass 0)'/>
</function>
<function name='virDomainInterfaceStats' file='python'>
<info>Extracts interface device statistics for a domain</info>
- <return type='virDomainInterfaceStats' info='a tuple of statistics'/>
+ <return type='char *' info='a tuple of statistics'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
<arg name='path' type='char *' info='the path for the interface device'/>
</function>
<function name='virDomainMemoryStats' file='python'>
<info>Extracts memory statistics for a domain</info>
- <return type='virDomainMemoryStats' info='a dictionary of statistics'/>
+ <return type='char *' info='a dictionary of statistics'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
</function>
<function name="virNodeGetCellsFreeMemory" file='python'>
@@ -196,16 +204,16 @@
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<arg name='startCell' type='int' info='first cell in the list'/>
<arg name='maxCells' type='int' info='number of cell in the list'/>
- <return type='int *' info="the list available memory in the cells"/>
+ <return type='char *' info="the list available memory in the cells"/>
</function>
<function name='virDomainGetSchedulerParameters' file='python'>
<info>Get the scheduler parameters, the @params array will be filled with the values.</info>
- <return type='str *' info='None in case of error, returns a dictionary of params.'/>
+ <return type='char *' info='None in case of error, returns a dictionary of params.'/>
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
</function>
<function name='virDomainGetSchedulerParametersFlags' file='python'>
<info>Get the scheduler parameters</info>
- <return type='str *' info='None in case of error, returns a dictionary of params'/>
+ <return type='char *' info='None in case of error, returns a dictionary of params'/>
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
</function>
@@ -236,7 +244,7 @@
</function>
<function name='virDomainGetVcpuPinInfo' file='python'>
<info>Query the CPU affinity setting of all virtual CPUs of domain</info>
- <return type='unsigned char *' info='the array of cpumap'/>
+ <return type='char *' info='the array of cpumap'/>
<arg name='domain' type='virDomainPtr' info='pointer to domain object, or NULL for Domain0'/>
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
</function>
@@ -262,7 +270,7 @@
</function>
<function name='virDomainGetBlkioParameters' file='python'>
<info>Get the blkio parameters</info>
- <return type='str *' info='None in case of error, returns a dictionary of params'/>
+ <return type='char *' info='None in case of error, returns a dictionary of params'/>
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
</function>
@@ -275,7 +283,7 @@
</function>
<function name='virDomainGetMemoryParameters' file='python'>
<info>Get the memory parameters</info>
- <return type='str *' info='None in case of error, returns a dictionary of params'/>
+ <return type='char *' info='None in case of error, returns a dictionary of params'/>
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
</function>
@@ -288,7 +296,7 @@
</function>
<function name='virDomainGetNumaParameters' file='python'>
<info>Get the NUMA parameters</info>
- <return type='str *' info='returns a dictionary of params in case of success, None in case of error'/>
+ <return type='char *' info='returns a dictionary of params in case of success, None in case of error'/>
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
</function>
@@ -305,44 +313,44 @@
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
<arg name='device' type='const char *' info='interface name'/>
<arg name='flags' type='unsigned int' info='an OR'ed set of virDomainModificationImpact'/>
- <return type='str *' info='the bandwidth tunables value or None in case of error'/>
+ <return type='char *' info='the bandwidth tunables value or None in case of error'/>
</function>
<function name='virConnectListStoragePools' file='python'>
<info>list the storage pools, stores the pointers to the names in @names</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='str *' info='the list of Names of None in case of error'/>
+ <return type='char *' info='the list of Names of None in case of error'/>
</function>
<function name='virConnectListDefinedStoragePools' file='python'>
<info>list the defined storage pool, stores the pointers to the names in @names</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='str *' info='the list of Names of None in case of error'/>
+ <return type='char *' info='the list of Names of None in case of error'/>
</function>
<function name='virConnectListAllStoragePools' file='python'>
<info>returns list of all storage pools</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='pool *' info='the list of pools or None in case of error'/>
+ <return type='char *' info='the list of pools or None in case of error'/>
</function>
<function name='virStoragePoolListVolumes' file='python'>
<info>list the storage volumes, stores the pointers to the names in @names</info>
<arg name='pool' type='virStoragePoolPtr' info='pointer to the storage pool'/>
- <return type='str *' info='the list of Names or None in case of error'/>
+ <return type='char *' info='the list of Names or None in case of error'/>
</function>
<function name='virStoragePoolListAllVolumes' file='python'>
<info>return list of storage volume objects</info>
<arg name='pool' type='virStoragePoolPtr' info='pointer to the storage pool'/>
<arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='volume *' info='the list of volumes or None in case of error'/>
+ <return type='char *' info='the list of volumes or None in case of error'/>
</function>
<function name='virStoragePoolGetInfo' file='python'>
<info>Extract information about a storage pool. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.</info>
- <return type='int *' info='the list of information or None in case of error'/>
+ <return type='char *' info='the list of information or None in case of error'/>
<arg name='pool' type='virStoragePoolPtr' info='a storage pool object'/>
</function>
<function name='virStorageVolGetInfo' file='python'>
<info>Extract information about a storage volume. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.</info>
- <return type='int *' info='the list of information or None in case of error'/>
+ <return type='char *' info='the list of information or None in case of error'/>
<arg name='vol' type='virStorageVolPtr' info='a storage vol object'/>
</function>
<function name='virNodeListDevices' file='python'>
@@ -350,18 +358,18 @@
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<arg name='cap' type='const unsigned char *' info='capability name'/>
<arg name='flags' type='unsigned int' info='flags (unused; pass 0)'/>
- <return type='str *' info='the list of Names or None in case of error'/>
+ <return type='char *' info='the list of Names or None in case of error'/>
</function>
<function name='virConnectListAllNodeDevices' file='python'>
<info>returns list of all host node devices</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='device *' info='the list of host node device or None in case of error'/>
+ <return type='char *' info='the list of host node device or None in case of error'/>
</function>
<function name='virNodeDeviceListCaps' file='python'>
<info>list the node device's capabilities</info>
<arg name='dev' type='virNodeDevicePtr' info='pointer to the node device'/>
- <return type='str *' info='the list of Names or None in case of error'/>
+ <return type='char *' info='the list of Names or None in case of error'/>
</function>
<function name='virSecretGetValue' file='libvirt' module='libvirt'>
<info>Fetches the value associated with a secret.</info>
@@ -372,13 +380,13 @@
<function name='virConnectListSecrets' file='libvirt' module='libvirt'>
<info>List the defined secret IDs</info>
<arg name='conn' type='virConnectPtr' info='virConnect connection'/>
- <return type='str *' info='the list of secret IDs or None in case of error'/>
+ <return type='char *' info='the list of secret IDs or None in case of error'/>
</function>
<function name='virConnectListAllSecrets' file='python'>
<info>returns list of all interfaces</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='secret *' info='the list of secrets or None in case of error'/>
+ <return type='char *' info='the list of secrets or None in case of error'/>
</function>
<function name='virSecretSetValue' file='libvirt' module='libvirt'>
<info>Associates a value with a secret.</info>
@@ -406,13 +414,13 @@
<function name='virConnectListNWFilters' file='libvirt' module='libvirt'>
<info>List the defined network filters</info>
<arg name='conn' type='virConnectPtr' info='virConnect connection'/>
- <return type='str *' info='the list of network filter IDs or None in case of error'/>
+ <return type='char *' info='the list of network filter IDs or None in case of error'/>
</function>
<function name='virConnectListAllNWFilters' file='python'>
<info>returns list of all network fitlers</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='nwfilter *' info='the list of network filters or None in case of error'/>
+ <return type='char *' info='the list of network filters or None in case of error'/>
</function>
<function name='virNWFilterLookupByUUID' file='python'>
<info>Try to lookup a network filter on the given hypervisor based on its UUID.</info>
@@ -433,18 +441,18 @@
<function name='virConnectListInterfaces' file='python'>
<info>list the running interfaces, stores the pointers to the names in @names</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='str *' info='the list of Names of None in case of error'/>
+ <return type='char *' info='the list of Names of None in case of error'/>
</function>
<function name='virConnectListDefinedInterfaces' file='python'>
<info>list the defined interfaces, stores the pointers to the names in @names</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='str *' info='the list of Names of None in case of error'/>
+ <return type='char *' info='the list of Names of None in case of error'/>
</function>
<function name='virConnectListAllInterfaces' file='python'>
<info>returns list of all interfaces</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='interface *' info='the list of interfaces or None in case of error'/>
+ <return type='char *' info='the list of interfaces or None in case of error'/>
</function>
<function name='virConnectBaselineCPU' file='python'>
<info>Computes the most feature-rich CPU which is compatible with all given host CPUs.</info>
@@ -457,25 +465,25 @@
<info>collect the list of snapshot names for the given domain</info>
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
<arg name='flags' type='unsigned int' info='flags'/>
- <return type='str *' info='the list of Names or None in case of error'/>
+ <return type='char *' info='the list of Names or None in case of error'/>
</function>
<function name='virDomainListAllSnapshots' file='python'>
<info>returns the list of snapshots for the given domain</info>
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
<arg name='flags' type='unsigned int' info='flags'/>
- <return type='snapshot *' info='the list of snapshots or None in case of error'/>
+ <return type='char *' info='the list of snapshots or None in case of error'/>
</function>
<function name='virDomainSnapshotListChildrenNames' file='python'>
<info>collect the list of child snapshot names for the given snapshot</info>
<arg name='snapshot' type='virDomainSnapshotPtr' info='pointer to the snapshot'/>
<arg name='flags' type='unsigned int' info='flags'/>
- <return type='str *' info='the list of Names or None in case of error'/>
+ <return type='char *' info='the list of Names or None in case of error'/>
</function>
<function name='virDomainSnapshotListAllChildren' file='python'>
<info>returns the list of child snapshots for the given snapshot</info>
<arg name='snapshot' type='virDomainSnapshotPtr' info='pointer to the snapshot'/>
<arg name='flags' type='unsigned int' info='flags'/>
- <return type='snapshot *' info='the list of snapshots or None in case of error'/>
+ <return type='char *' info='the list of snapshots or None in case of error'/>
</function>
<function name='virDomainRevertToSnapshot' file='python'>
<info>revert the domain to the given snapshot</info>
@@ -489,7 +497,7 @@
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
<arg name='path' type='const char *' info='Fully-qualified filename of disk'/>
<arg name='flags' type='unsigned int' info='fine-tuning flags, currently unused, pass 0.'/>
- <return type='virDomainBlockJobInfo' info='A dictionary containing job information.' />
+ <return type='char *' info='A dictionary containing job information.' />
</function>
<function name='virDomainMigrateGetCompressionCache' file='python'>
<info>Get current size of the cache (in bytes) used for compressing
@@ -517,7 +525,7 @@
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
<arg name='disk' type='const char *' info='disk name'/>
<arg name='flags' type='unsigned int' info='an OR'ed set of virDomainModificationImpact'/>
- <return type='str *' info='the I/O tunables value or None in case of error'/>
+ <return type='char *' info='the I/O tunables value or None in case of error'/>
</function>
<function name='virDomainBlockPeek' file='python'>
<info>Read the contents of domain's disk device</info>
@@ -538,7 +546,7 @@
</function>
<function name='virDomainGetDiskErrors' file='python'>
<info>Extract errors on disk devices.</info>
- <return type='virDomainDiskErrorPtr' info='dictionary of disks and their errors or None in case of error'/>
+ <return type='char *' info='dictionary of disks and their errors or None in case of error'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
<arg name='flags' type='unsigned int' info='unused, always pass 0'/>
</function>
@@ -551,13 +559,13 @@
</function>
<function name='virNodeGetMemoryParameters' file='python'>
<info>Get the node memory parameters</info>
- <return type='str *' info='None in case of error, returns a dictionary of params'/>
+ <return type='char *' info='None in case of error, returns a dictionary of params'/>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<arg name='flags' type='int' info='unused, always pass 0'/>
</function>
<function name='virNodeGetCPUMap' file='python'>
<info>Get node CPU information</info>
- <return type='str *' info='(cpunum, cpumap, online) on success, None on error'/>
+ <return type='char *' info='(cpunum, cpumap, online) on success, None on error'/>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<arg name='flags' type='int' info='unused, pass 0'/>
</function>
--
1.7.11.2
2
4
21 Mar '13
This series improves support for NBD disks (patches 1-6), and adds
support for the libiscsi userspace initiator (patches 7-13).
Please review!
Paolo
Paolo Bonzini (13):
qemu: fix use-after-free when parsing NBD disk
qemu: do not support non-network disks without -drive
qemu: rewrite NBD command-line builder and parser
qemu: support named nbd exports
qemu: support NBD with Unix sockets
qemu: support URI syntax for NBD
domain: add support for iscsi network disks
qemu: add support for libiscsi
qemu: support LUN numbers for iSCSI disks
domain: make port optional for network disks
secret: add iscsi to possible usage types
domain: parse XML for iscsi authorization credentials
qemu: pass iscsi authorization credentials
docs/formatdomain.html.in | 42 +-
docs/formatsecret.html.in | 12 +
docs/schemas/domaincommon.rng | 37 +-
docs/schemas/secret.rng | 10 +
include/libvirt/libvirt.h.in | 1 +
src/conf/domain_conf.c | 51 ++-
src/conf/domain_conf.h | 3 +
src/conf/secret_conf.c | 22 +-
src/conf/secret_conf.h | 1 +
src/qemu/qemu_command.c | 432 ++++++++++++++-------
src/secret/secret_driver.c | 8 +
tests/qemuargv2xmltest.c | 5 +
.../qemuxml2argv-disk-drive-network-gluster.args | 2 +-
...qemuxml2argv-disk-drive-network-iscsi-auth.args | 1 +
.../qemuxml2argv-disk-drive-network-iscsi-auth.xml | 31 ++
.../qemuxml2argv-disk-drive-network-iscsi.args | 1 +
.../qemuxml2argv-disk-drive-network-iscsi.xml | 34 ++
...qemuxml2argv-disk-drive-network-nbd-export.args | 5 +
.../qemuxml2argv-disk-drive-network-nbd-export.xml | 33 ++
...ml2argv-disk-drive-network-nbd-ipv6-export.args | 5 +
...xml2argv-disk-drive-network-nbd-ipv6-export.xml | 33 ++
.../qemuxml2argv-disk-drive-network-nbd-ipv6.args | 5 +
.../qemuxml2argv-disk-drive-network-nbd-ipv6.xml | 33 ++
.../qemuxml2argv-disk-drive-network-nbd-unix.args | 5 +
.../qemuxml2argv-disk-drive-network-nbd-unix.xml | 33 ++
tests/qemuxml2argvtest.c | 12 +
tests/qemuxml2xmltest.c | 7 +
27 files changed, 687 insertions(+), 177 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.xml
--
1.8.1.2
4
62
Intend to reduce the redundant code,use virNumaSetupMemoryPolicy
to replace virLXCControllerSetupNUMAPolicy and
qemuProcessInitNumaMemoryPolicy.
This patch also moves the numa related codes to the
file virnuma.c and virnuma.h
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
src/conf/domain_conf.c | 31 ++++--------
src/conf/domain_conf.h | 25 +---------
src/libvirt_private.syms | 9 ++--
src/lxc/lxc_controller.c | 116 +------------------------------------------
src/qemu/qemu_cgroup.c | 4 +-
src/qemu/qemu_driver.c | 6 +--
src/qemu/qemu_process.c | 123 +--------------------------------------------
src/util/virnuma.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++
src/util/virnuma.h | 30 +++++++++++
9 files changed, 182 insertions(+), 288 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a1cfc76..fa70329 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -690,11 +690,6 @@ VIR_ENUM_IMPL(virDomainTimerMode, VIR_DOMAIN_TIMER_MODE_LAST,
"paravirt",
"smpsafe");
-VIR_ENUM_IMPL(virDomainNumatuneMemMode, VIR_DOMAIN_NUMATUNE_MEM_LAST,
- "strict",
- "preferred",
- "interleave");
-
VIR_ENUM_IMPL(virDomainStartupPolicy, VIR_DOMAIN_STARTUP_POLICY_LAST,
"default",
"mandatory",
@@ -709,12 +704,6 @@ VIR_ENUM_IMPL(virDomainDiskTray, VIR_DOMAIN_DISK_TRAY_LAST,
"closed",
"open");
-VIR_ENUM_IMPL(virDomainNumatuneMemPlacementMode,
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_LAST,
- "default",
- "static",
- "auto");
-
VIR_ENUM_IMPL(virDomainRNGModel,
VIR_DOMAIN_RNG_MODEL_LAST,
"virtio");
@@ -9852,7 +9841,7 @@ virDomainDefParseXML(virCapsPtr caps,
int placement_mode = 0;
if (placement) {
if ((placement_mode =
- virDomainNumatuneMemPlacementModeTypeFromString(placement)) < 0) {
+ virNumaTuneMemPlacementModeTypeFromString(placement)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Unsupported memory placement "
"mode '%s'"), placement);
@@ -9862,18 +9851,18 @@ virDomainDefParseXML(virCapsPtr caps,
VIR_FREE(placement);
} else if (def->numatune.memory.nodemask) {
/* Defaults to "static" if nodeset is specified. */
- placement_mode = VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC;
+ placement_mode = VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC;
} else {
/* Defaults to "placement" of <vcpu> if nodeset is
* not specified.
*/
if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC)
- placement_mode = VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC;
+ placement_mode = VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC;
else
- placement_mode = VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO;
+ placement_mode = VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO;
}
- if (placement_mode == VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC &&
+ if (placement_mode == VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC &&
!def->numatune.memory.nodemask) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("nodeset for NUMA memory tuning must be set "
@@ -9882,13 +9871,13 @@ virDomainDefParseXML(virCapsPtr caps,
}
/* Ignore 'nodeset' if 'placement' is 'auto' finally */
- if (placement_mode == VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO)
+ if (placement_mode == VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)
virBitmapFree(def->numatune.memory.nodemask);
/* Copy 'placement' of <numatune> to <vcpu> if its 'placement'
* is not specified and 'placement' of <numatune> is specified.
*/
- if (placement_mode == VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO &&
+ if (placement_mode == VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO &&
!def->cpumask)
def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO;
@@ -9907,7 +9896,7 @@ virDomainDefParseXML(virCapsPtr caps,
* and 'placement' of <vcpu> is 'auto'.
*/
if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
- def->numatune.memory.placement_mode = VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO;
+ def->numatune.memory.placement_mode = VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO;
def->numatune.memory.mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
}
}
@@ -14818,7 +14807,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAsprintf(buf, " <memory mode='%s' ", mode);
if (def->numatune.memory.placement_mode ==
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC) {
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC) {
nodemask = virBitmapFormat(def->numatune.memory.nodemask);
if (nodemask == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -14829,7 +14818,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAsprintf(buf, "nodeset='%s'/>\n", nodemask);
VIR_FREE(nodemask);
} else if (def->numatune.memory.placement_mode) {
- placement = virDomainNumatuneMemPlacementModeTypeToString(def->numatune.memory.placement_mode);
+ placement = virNumaTuneMemPlacementModeTypeToString(def->numatune.memory.placement_mode);
virBufferAsprintf(buf, "placement='%s'/>\n", placement);
}
virBufferAddLit(buf, " </numatune>\n");
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bfc37a0..6d856a3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -47,6 +47,7 @@
# include "device_conf.h"
# include "virbitmap.h"
# include "virstoragefile.h"
+# include "virnuma.h"
/* forward declarations of all device types, required by
* virDomainDeviceDef
@@ -1605,14 +1606,6 @@ enum virDomainCpuPlacementMode {
VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST
};
-enum virDomainNumatuneMemPlacementMode {
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_DEFAULT = 0,
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC,
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO,
-
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_LAST
-};
-
typedef struct _virDomainTimerCatchupDef virDomainTimerCatchupDef;
typedef virDomainTimerCatchupDef *virDomainTimerCatchupDefPtr;
struct _virDomainTimerCatchupDef {
@@ -1701,18 +1694,6 @@ virDomainVcpuPinDefPtr virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def,
int nvcpupin,
int vcpu);
-typedef struct _virDomainNumatuneDef virDomainNumatuneDef;
-typedef virDomainNumatuneDef *virDomainNumatuneDefPtr;
-struct _virDomainNumatuneDef {
- struct {
- virBitmapPtr nodemask;
- int mode;
- int placement_mode; /* enum virDomainNumatuneMemPlacementMode */
- } memory;
-
- /* Future NUMA tuning related stuff should go here. */
-};
-
typedef struct _virBlkioDeviceWeight virBlkioDeviceWeight;
typedef virBlkioDeviceWeight *virBlkioDeviceWeightPtr;
struct _virBlkioDeviceWeight {
@@ -1802,7 +1783,7 @@ struct _virDomainDef {
virDomainVcpuPinDefPtr emulatorpin;
} cputune;
- virDomainNumatuneDef numatune;
+ virNumaTuneDef numatune;
/* These 3 are based on virDomainLifeCycleAction enum flags */
int onReboot;
@@ -2397,8 +2378,6 @@ VIR_ENUM_DECL(virDomainGraphicsSpicePlaybackCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode)
VIR_ENUM_DECL(virDomainGraphicsSpiceClipboardCopypaste)
VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode)
-VIR_ENUM_DECL(virDomainNumatuneMemMode)
-VIR_ENUM_DECL(virDomainNumatuneMemPlacementMode)
VIR_ENUM_DECL(virDomainHyperv)
VIR_ENUM_DECL(virDomainRNGModel)
VIR_ENUM_DECL(virDomainRNGBackend)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index dc01bfa..8890859 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -252,10 +252,6 @@ virDomainNetRemove;
virDomainNetTypeToString;
virDomainNostateReasonTypeFromString;
virDomainNostateReasonTypeToString;
-virDomainNumatuneMemModeTypeFromString;
-virDomainNumatuneMemModeTypeToString;
-virDomainNumatuneMemPlacementModeTypeFromString;
-virDomainNumatuneMemPlacementModeTypeToString;
virDomainObjAssignDef;
virDomainObjCopyPersistentDef;
virDomainObjGetPersistentDef;
@@ -1557,7 +1553,12 @@ virNodeSuspendGetTargetMask;
# util/virnuma.h
+virDomainNumatuneMemModeTypeFromString;
+virDomainNumatuneMemModeTypeToString;
+virNumaTuneMemPlacementModeTypeFromString;
+virNumaTuneMemPlacementModeTypeToString;
virNumaGetAutoPlacementAdvice;
+virNumaSetupMemoryPolicy;
# util/virobject.h
virClassForObject;
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 405205c..f19f8c1 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -46,11 +46,6 @@
# include <cap-ng.h>
#endif
-#if WITH_NUMACTL
-# define NUMA_VERSION1_COMPATIBILITY 1
-# include <numa.h>
-#endif
-
#include "virerror.h"
#include "virlog.h"
#include "virutil.h"
@@ -469,113 +464,6 @@ cleanup:
return ret;
}
-#if WITH_NUMACTL
-static int virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl,
- virBitmapPtr nodemask)
-{
- nodemask_t mask;
- int mode = -1;
- int node = -1;
- int ret = -1;
- int i = 0;
- int maxnode = 0;
- bool warned = false;
- virDomainNumatuneDef numatune = ctrl->def->numatune;
- virBitmapPtr tmp_nodemask = NULL;
-
- if (numatune.memory.placement_mode ==
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC) {
- if (!numatune.memory.nodemask)
- return 0;
- VIR_DEBUG("Set NUMA memory policy with specified nodeset");
- tmp_nodemask = numatune.memory.nodemask;
- } else if (numatune.memory.placement_mode ==
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO) {
- VIR_DEBUG("Set NUMA memory policy with advisory nodeset from numad");
- tmp_nodemask = nodemask;
- } else {
- return 0;
- }
-
- VIR_DEBUG("Setting NUMA memory policy");
-
- if (numa_available() < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- "%s", _("Host kernel is not aware of NUMA."));
- return -1;
- }
-
- maxnode = numa_max_node() + 1;
-
- /* Convert nodemask to NUMA bitmask. */
- nodemask_zero(&mask);
- i = -1;
- while ((i = virBitmapNextSetBit(tmp_nodemask, i)) >= 0) {
- if (i > NUMA_NUM_NODES) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Host cannot support NUMA node %d"), i);
- return -1;
- }
- if (i > maxnode && !warned) {
- VIR_WARN("nodeset is out of range, there is only %d NUMA "
- "nodes on host", maxnode);
- warned = true;
- }
- nodemask_set(&mask, i);
- }
-
- mode = ctrl->def->numatune.memory.mode;
-
- if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
- numa_set_bind_policy(1);
- numa_set_membind(&mask);
- numa_set_bind_policy(0);
- } else if (mode == VIR_DOMAIN_NUMATUNE_MEM_PREFERRED) {
- int nnodes = 0;
- for (i = 0; i < NUMA_NUM_NODES; i++) {
- if (nodemask_isset(&mask, i)) {
- node = i;
- nnodes++;
- }
- }
-
- if (nnodes != 1) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- "%s", _("NUMA memory tuning in 'preferred' mode "
- "only supports single node"));
- goto cleanup;
- }
-
- numa_set_bind_policy(0);
- numa_set_preferred(node);
- } else if (mode == VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE) {
- numa_set_interleave_mask(&mask);
- } else {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Unable to set NUMA policy %s"),
- virDomainNumatuneMemModeTypeToString(mode));
- goto cleanup;
- }
-
- ret = 0;
-
-cleanup:
- return ret;
-}
-#else
-static int virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl,
- virBitmapPtr nodemask ATTRIBUTE_UNUSED)
-{
- if (ctrl->def->numatune.memory.nodemask) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("NUMA policy is not available on this platform"));
- return -1;
- }
-
- return 0;
-}
-#endif
-
/*
* To be run while still single threaded
@@ -638,7 +526,7 @@ static int virLXCControllerGetNumadAdvice(virLXCControllerPtr ctrl,
if ((ctrl->def->placement_mode ==
VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) ||
(ctrl->def->numatune.memory.placement_mode ==
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO)) {
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)) {
nodeset = virNumaGetAutoPlacementAdvice(ctrl->def->vcpus,
ctrl->def->mem.cur_balloon);
if (!nodeset)
@@ -675,7 +563,7 @@ static int virLXCControllerSetupResourceLimits(virLXCControllerPtr ctrl,
int ret = -1;
if (virLXCControllerGetNumadAdvice(ctrl, &nodemask) < 0 ||
- virLXCControllerSetupNUMAPolicy(ctrl, nodemask) < 0)
+ virNumaSetupMemoryPolicy(ctrl->def->numatune, nodemask) < 0)
goto cleanup;
if (virLXCControllerSetupCpuAffinity(ctrl) < 0)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 9d6e88b..c9b4ca2 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -423,12 +423,12 @@ int qemuSetupCgroup(virQEMUDriverPtr driver,
if ((vm->def->numatune.memory.nodemask ||
(vm->def->numatune.memory.placement_mode ==
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO)) &&
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)) &&
vm->def->numatune.memory.mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET)) {
char *mask = NULL;
if (vm->def->numatune.memory.placement_mode ==
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO)
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)
mask = virBitmapFormat(nodemask);
else
mask = virBitmapFormat(vm->def->numatune.memory.nodemask);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9cd9e44..f057d38 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7648,7 +7648,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
virBitmapFree(vm->def->numatune.memory.nodemask);
vm->def->numatune.memory.placement_mode =
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC;
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC;
vm->def->numatune.memory.nodemask = virBitmapNewCopy(nodeset);
}
@@ -7657,7 +7657,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
persistentDef->numatune.memory.nodemask = nodeset;
persistentDef->numatune.memory.placement_mode =
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC;
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC;
nodeset = NULL;
}
virBitmapFree(nodeset);
@@ -7667,7 +7667,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (!persistentDef->numatune.memory.placement_mode)
persistentDef->numatune.memory.placement_mode =
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO;
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO;
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
ret = -1;
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2465938..fcb3c50 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -45,11 +45,6 @@
#include "qemu_bridge_filter.h"
#include "qemu_migration.h"
-#if WITH_NUMACTL
-# define NUMA_VERSION1_COMPATIBILITY 1
-# include <numa.h>
-#endif
-
#include "datatypes.h"
#include "virlog.h"
#include "virerror.h"
@@ -1791,120 +1786,6 @@ qemuProcessDetectVcpuPIDs(virQEMUDriverPtr driver,
}
-/*
- * Set NUMA memory policy for qemu process, to be run between
- * fork/exec of QEMU only.
- */
-#if WITH_NUMACTL
-static int
-qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm,
- virBitmapPtr nodemask)
-{
- nodemask_t mask;
- int mode = -1;
- int node = -1;
- int ret = -1;
- int i = 0;
- int maxnode = 0;
- bool warned = false;
- virDomainNumatuneDef numatune = vm->def->numatune;
- virBitmapPtr tmp_nodemask = NULL;
-
- if (numatune.memory.placement_mode ==
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC) {
- if (!numatune.memory.nodemask)
- return 0;
- VIR_DEBUG("Set NUMA memory policy with specified nodeset");
- tmp_nodemask = numatune.memory.nodemask;
- } else if (numatune.memory.placement_mode ==
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO) {
- VIR_DEBUG("Set NUMA memory policy with advisory nodeset from numad");
- tmp_nodemask = nodemask;
- } else {
- return 0;
- }
-
- if (numa_available() < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Host kernel is not aware of NUMA."));
- return -1;
- }
-
- maxnode = numa_max_node() + 1;
- /* Convert nodemask to NUMA bitmask. */
- nodemask_zero(&mask);
- i = -1;
- while ((i = virBitmapNextSetBit(tmp_nodemask, i)) >= 0) {
- if (i > NUMA_NUM_NODES) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Host cannot support NUMA node %d"), i);
- return -1;
- }
- if (i > maxnode && !warned) {
- VIR_WARN("nodeset is out of range, there is only %d NUMA "
- "nodes on host", maxnode);
- warned = true;
- }
- nodemask_set(&mask, i);
- }
-
- mode = numatune.memory.mode;
-
- if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
- numa_set_bind_policy(1);
- numa_set_membind(&mask);
- numa_set_bind_policy(0);
- } else if (mode == VIR_DOMAIN_NUMATUNE_MEM_PREFERRED) {
- int nnodes = 0;
- for (i = 0; i < NUMA_NUM_NODES; i++) {
- if (nodemask_isset(&mask, i)) {
- node = i;
- nnodes++;
- }
- }
-
- if (nnodes != 1) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("NUMA memory tuning in 'preferred' mode "
- "only supports single node"));
- goto cleanup;
- }
-
- numa_set_bind_policy(0);
- numa_set_preferred(node);
- } else if (mode == VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE) {
- numa_set_interleave_mask(&mask);
- } else {
- /* XXX: Shouldn't go here, as we already do checking when
- * parsing domain XML.
- */
- virReportError(VIR_ERR_XML_ERROR,
- "%s", _("Invalid mode for memory NUMA tuning."));
- goto cleanup;
- }
-
- ret = 0;
-
-cleanup:
- return ret;
-}
-#else
-static int
-qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm,
- virBitmapPtr nodemask ATTRIBUTE_UNUSED)
-{
- if (vm->def->numatune.memory.nodemask) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("libvirt is compiled without NUMA tuning support"));
-
- return -1;
- }
-
- return 0;
-}
-#endif
-
-
/* Helper to prepare cpumap for affinity setting, convert
* NUMA nodeset into cpuset if @nodemask is not NULL, otherwise
* just return a new allocated bitmap.
@@ -2654,7 +2535,7 @@ static int qemuProcessHook(void *data)
qemuProcessInitCpuAffinity(h->driver, h->vm, h->nodemask) < 0)
goto cleanup;
- if (qemuProcessInitNumaMemoryPolicy(h->vm, h->nodemask) < 0)
+ if (virNumaSetupMemoryPolicy(h->vm->def->numatune, h->nodemask) < 0)
goto cleanup;
ret = 0;
@@ -3608,7 +3489,7 @@ int qemuProcessStart(virConnectPtr conn,
if ((vm->def->placement_mode ==
VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) ||
(vm->def->numatune.memory.placement_mode ==
- VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO)) {
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)) {
nodeset = virNumaGetAutoPlacementAdvice(vm->def->vcpus,
vm->def->mem.cur_balloon);
if (!nodeset)
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index f6a6eb2..bace06f 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -21,12 +21,30 @@
#include <config.h>
+#if WITH_NUMACTL
+# define NUMA_VERSION1_COMPATIBILITY 1
+# include <numa.h>
+#endif
+
#include "virnuma.h"
#include "vircommand.h"
#include "virerror.h"
+#include "virlog.h"
#define VIR_FROM_THIS VIR_FROM_NONE
+VIR_ENUM_IMPL(virDomainNumatuneMemMode,
+ VIR_DOMAIN_NUMATUNE_MEM_LAST,
+ "strict",
+ "preferred",
+ "interleave");
+
+VIR_ENUM_IMPL(virNumaTuneMemPlacementMode,
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_LAST,
+ "default",
+ "static",
+ "auto");
+
#if HAVE_NUMAD
char *
virNumaGetAutoPlacementAdvice(unsigned short vcpus,
@@ -59,3 +77,111 @@ virNumaGetAutoPlacementAdvice(unsigned short vcpus ATTRIBUTE_UNUSED,
return NULL;
}
#endif
+
+#if WITH_NUMACTL
+int
+virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
+ virBitmapPtr nodemask)
+{
+ nodemask_t mask;
+ int mode = -1;
+ int node = -1;
+ int ret = -1;
+ int i = 0;
+ int maxnode = 0;
+ bool warned = false;
+ virBitmapPtr tmp_nodemask = NULL;
+
+ if (numatune.memory.placement_mode ==
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC) {
+ if (!numatune.memory.nodemask)
+ return 0;
+ VIR_DEBUG("Set NUMA memory policy with specified nodeset");
+ tmp_nodemask = numatune.memory.nodemask;
+ } else if (numatune.memory.placement_mode ==
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO) {
+ VIR_DEBUG("Set NUMA memory policy with advisory nodeset from numad");
+ tmp_nodemask = nodemask;
+ } else {
+ return 0;
+ }
+
+ if (numa_available() < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("Host kernel is not aware of NUMA."));
+ return -1;
+ }
+
+ maxnode = numa_max_node() + 1;
+ /* Convert nodemask to NUMA bitmask. */
+ nodemask_zero(&mask);
+ i = -1;
+ while ((i = virBitmapNextSetBit(tmp_nodemask, i)) >= 0) {
+ if (i > NUMA_NUM_NODES) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Host cannot support NUMA node %d"), i);
+ return -1;
+ }
+ if (i > maxnode && !warned) {
+ VIR_WARN("nodeset is out of range, there is only %d NUMA "
+ "nodes on host", maxnode);
+ warned = true;
+ }
+ nodemask_set(&mask, i);
+ }
+
+ mode = numatune.memory.mode;
+
+ if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
+ numa_set_bind_policy(1);
+ numa_set_membind(&mask);
+ numa_set_bind_policy(0);
+ } else if (mode == VIR_DOMAIN_NUMATUNE_MEM_PREFERRED) {
+ int nnodes = 0;
+ for (i = 0; i < NUMA_NUM_NODES; i++) {
+ if (nodemask_isset(&mask, i)) {
+ node = i;
+ nnodes++;
+ }
+ }
+
+ if (nnodes != 1) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("NUMA memory tuning in 'preferred' mode "
+ "only supports single node"));
+ goto cleanup;
+ }
+
+ numa_set_bind_policy(0);
+ numa_set_preferred(node);
+ } else if (mode == VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE) {
+ numa_set_interleave_mask(&mask);
+ } else {
+ /* XXX: Shouldn't go here, as we already do checking when
+ * parsing domain XML.
+ */
+ virReportError(VIR_ERR_XML_ERROR,
+ "%s", _("Invalid mode for memory NUMA tuning."));
+ goto cleanup;
+ }
+
+ ret = 0;
+
+cleanup:
+ return ret;
+}
+#else
+int
+virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
+ virBitmapPtr nodemask ATTRIBUTE_UNUSED)
+{
+ if (numatune.memory.nodemask) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("libvirt is compiled without NUMA tuning support"));
+
+ return -1;
+ }
+
+ return 0;
+}
+#endif
diff --git a/src/util/virnuma.h b/src/util/virnuma.h
index d3d7d3e..9ff8e69 100644
--- a/src/util/virnuma.h
+++ b/src/util/virnuma.h
@@ -22,7 +22,37 @@
#ifndef __VIR_NUMA_H__
# define __VIR_NUMA_H__
+# include "internal.h"
+# include "virbitmap.h"
+# include "virutil.h"
+
+enum virNumaTuneMemPlacementMode {
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_DEFAULT = 0,
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC,
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO,
+
+ VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_LAST
+};
+
+VIR_ENUM_DECL(virNumaTuneMemPlacementMode)
+
+VIR_ENUM_DECL(virDomainNumatuneMemMode)
+
+typedef struct _virNumaTuneDef virNumaTuneDef;
+typedef virNumaTuneDef *virNumaTuneDefPtr;
+struct _virNumaTuneDef {
+ struct {
+ virBitmapPtr nodemask;
+ int mode;
+ int placement_mode; /* enum virNumaTuneMemPlacementMode */
+ } memory;
+
+ /* Future NUMA tuning related stuff should go here. */
+};
+
char *virNumaGetAutoPlacementAdvice(unsigned short vcups,
unsigned long long balloon);
+int virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
+ virBitmapPtr nodemask);
#endif /* __VIR_NUMA_H__ */
--
1.7.11.7
2
5