[libvirt] with vhostuser I cannot use hugepages
by Adnan Mundres
In my setup I am using qemu-kvm without openstack. I am trying to use ovs with dpdk. In my xml file I added following lines for the dpdkvhostuser
<cpu mode='host-passthrough'> <numa> <cell id="0" cpus="0-6" memory="16777216" unit='KiB' memAccess="shared"/> </numa> </cpu> I have enabled hugepages during boot time
ot@mvmgptb11hyp01 hyp-1]# cat /proc/meminfo | grep -i hugeAnonHugePages: 126976 kBHugePages_Total: 100HugePages_Free: 80HugePages_Rsvd: 0HugePages_Surp: 0Hugepagesize: 1048576 kB
But When I start my vm (virsh start vm1.xml) I am seeing that this vm is not using memory from hugepages, rather it is taking memory from total memory. When I checked the log file I see that it is using
-object memory-backend-file,id=ram-node0,prealloc=yes,mem-path=/var/lib/libvirt/qemu/ram,share=yes
It should use backend memory as following
-object memory-backend-file,id=ram-node0,prealloc=yes,mem-path=/dev/hugepages/libvirt/qemu/vm1,share=yes
Any idea how can I use memory from hugepages
6 years, 11 months
[libvirt] [PATCH-RUBY] The first argument passed should be the disk not the size.
by Marius Rieder
Calling block_resize on a Libvirt::Domain object leads to a TypeError.
The reason seems to be that ruby-libvirt tries to convert the size
instead of the disk to a string to pass as the disk parameter.
---
ext/libvirt/domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ext/libvirt/domain.c b/ext/libvirt/domain.c
index 7812450..aff1842 100644
--- a/ext/libvirt/domain.c
+++ b/ext/libvirt/domain.c
@@ -2882,7 +2882,7 @@ static VALUE libvirt_domain_block_resize(int argc, VALUE *argv, VALUE d)
ruby_libvirt_generate_call_nil(virDomainBlockResize,
ruby_libvirt_connect_get(d),
ruby_libvirt_domain_get(d),
- StringValueCStr(size), NUM2ULL(size),
+ StringValueCStr(disk), NUM2ULL(size),
ruby_libvirt_value_to_uint(flags));
}
#endif
--
2.7.4
6 years, 11 months
[libvirt] [PATCH] qemu: get VM's ip address from the output of arp command
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)gmail.com>
Introduce VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP to get ip address
of VM from the output of `arp -an` command.
We can use:
domifaddr f26-cloud --source arp
to get the address.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)gmail.com>
---
include/libvirt/libvirt-domain.h | 1 +
src/qemu/qemu_driver.c | 102 +++++++++++++++++++++++++++++++++++++++
tools/virsh-domain-monitor.c | 2 +
3 files changed, 105 insertions(+)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 4048acf38..38e2d9a3e 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -4665,6 +4665,7 @@ typedef virMemoryParameter *virMemoryParameterPtr;
typedef enum {
VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE = 0, /* Parse DHCP lease file */
VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT = 1, /* Query qemu guest agent */
+ VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP = 2, /* Query ARP tables */
# ifdef VIR_ENUM_SENTINELS
VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a203c9297..5aaf69442 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -160,6 +160,9 @@ static int qemuGetDHCPInterfaces(virDomainPtr dom,
virDomainObjPtr vm,
virDomainInterfacePtr **ifaces);
+static int qemuARPGetInterfaces(virDomainObjPtr vm,
+ virDomainInterfacePtr **ifaces);
+
static virQEMUDriverPtr qemu_driver;
@@ -20384,6 +20387,10 @@ qemuDomainInterfaceAddresses(virDomainPtr dom,
break;
+ case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP:
+ ret = qemuARPGetInterfaces(vm, ifaces);
+ break;
+
default:
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
_("Unknown IP address data source %d"),
@@ -20494,6 +20501,101 @@ qemuGetDHCPInterfaces(virDomainPtr dom,
}
+static int
+qemuARPGetInterfaces(virDomainObjPtr vm,
+ virDomainInterfacePtr **ifaces)
+{
+ size_t i, j;
+ size_t ifaces_count = 0;
+ int ret = -1;
+ char macaddr[VIR_MAC_STRING_BUFLEN];
+ virDomainInterfacePtr *ifaces_ret = NULL;
+ virDomainInterfacePtr iface = NULL;
+ virCommandPtr cmd = NULL;
+ char *outbuf;
+ char **lines = NULL;
+ char **matches = NULL;
+#define ARP_CMD "/usr/sbin/arp"
+
+ if (!(cmd = virCommandNewArgList(ARP_CMD,
+ "-an",
+ NULL)))
+ goto cleanup;
+
+ virCommandSetOutputBuffer(cmd, &outbuf);
+
+ if (virCommandRun(cmd, NULL) < 0)
+ goto cleanup;
+
+ lines = virStringSplit(outbuf, "\n", 0);
+ if (lines == NULL)
+ goto cleanup;
+
+ for (i = 0; i < vm->def->nnets; i++) {
+ if (vm->def->nets[i]->type != VIR_DOMAIN_NET_TYPE_NETWORK)
+ continue;
+
+ virMacAddrFormat(&(vm->def->nets[i]->mac), macaddr);
+
+ if (strstr(outbuf, macaddr)) {
+ for (j = 0; lines[j]; j++) {
+ const char *line = lines[j];
+ if (line == NULL)
+ break;
+ if (strstr(line, macaddr) &&
+ virStringSearch(line, "\\b([0-9]{1,3}\\.){3}[0-9]{1,3}\\b",
+ 1, &matches) == 1) {
+
+ if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0)
+ goto error;
+
+ if (VIR_ALLOC(ifaces_ret[ifaces_count - 1]) < 0)
+ goto error;
+
+ iface = ifaces_ret[ifaces_count - 1];
+ iface->naddrs = 1;
+ if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0)
+ goto error;
+
+ if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0)
+ goto cleanup;
+
+ if (VIR_STRDUP(iface->hwaddr, macaddr) < 0)
+ goto cleanup;
+
+ if (VIR_STRDUP(iface->addrs->addr, matches[0]) < 0)
+ goto cleanup;
+ }
+ }
+ } else {
+ VIR_DEBUG("Got nothing");
+ continue;
+ }
+ }
+
+ *ifaces = ifaces_ret;
+ ifaces_ret = NULL;
+ ret = ifaces_count;
+
+ cleanup:
+ virCommandFree(cmd);
+ VIR_FREE(outbuf);
+ virStringListFree(lines);
+ virStringListFree(matches);
+ cmd = NULL;
+ return ret;
+
+ error:
+ if (ifaces_ret) {
+ for (i = 0; i < ifaces_count; i++)
+ virDomainInterfaceFree(ifaces_ret[i]);
+ }
+ VIR_FREE(ifaces_ret);
+
+ goto cleanup;
+}
+
+
static int
qemuDomainSetUserPassword(virDomainPtr dom,
const char *user,
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 32a42707e..68da11ed5 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -2190,6 +2190,8 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
source = VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE;
} else if (STREQ(sourcestr, "agent")) {
source = VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT;
+ } else if (STREQ(sourcestr, "arp")) {
+ source = VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP;
} else {
vshError(ctl, _("Unknown data source '%s'"), sourcestr);
goto cleanup;
--
2.14.3
6 years, 11 months
[libvirt] [PATCH] libxl: add explicit linkage to xenstore library
by Daniel P. Berrange
The libxl driver calls a couple of xenstorage APIs, so it must
explicitly link to this library rather than rely on indirect linkage via
libxl or other xen libraries.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
m4/virt-driver-libxl.m4 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/m4/virt-driver-libxl.m4 b/m4/virt-driver-libxl.m4
index e6dbfef686..2cc1c062d8 100644
--- a/m4/virt-driver-libxl.m4
+++ b/m4/virt-driver-libxl.m4
@@ -75,9 +75,9 @@ AC_DEFUN([LIBVIRT_DRIVER_CHECK_LIBXL], [
dnl (since Xen 4.7) if not then assume it is in libxenctrl
dnl (as it was for 4.6 and earler)
AC_CHECK_LIB([xentoollog], [xtl_createlogger_stdiostream], [
- LIBXL_LIBS="$LIBXL_LIBS -lxentoollog"
+ LIBXL_LIBS="$LIBXL_LIBS -lxenstore -lxentoollog"
],[
- LIBXL_LIBS="$LIBXL_LIBS -lxenctrl"
+ LIBXL_LIBS="$LIBXL_LIBS -lxenstore -lxenctrl"
])
dnl Check if libxl_domain_config_from_json is available for domXML to
--
2.14.3
6 years, 11 months
[libvirt] [PATCH 0/8] virsh: Introduce more completers
by Michal Privoznik
It'd be nice if we could autocomplete the basic types like pools,
volumes, networks, ... before the release.
Michal Privoznik (8):
virsh: Introduce virshStoragePoolNameCompleter
virsh: Introduce virshStorageVolNameCompleter
virsh: Introduce virshInterfaceNameCompleter
virsh: Introduce virshNetworkNameCompleter
virsh: Introduce virshNodeDeviceNameCompleter
virsh: Introduce virshNWFilterNameCompleter
virsh: Introduce virshSecretUUIDCompleter
virsh: Introduce virshSnapshotNameCompleter
tools/virsh-completer.c | 388 ++++++++++++++++++++++++++++++++++++++++++++++++
tools/virsh-completer.h | 32 ++++
tools/virsh-interface.c | 16 +-
tools/virsh-network.c | 24 +--
tools/virsh-nodedev.c | 16 +-
tools/virsh-nwfilter.c | 9 +-
tools/virsh-pool.c | 28 ++--
tools/virsh-secret.c | 15 +-
tools/virsh-snapshot.c | 21 ++-
tools/virsh-volume.c | 45 +++---
tools/virsh.h | 6 +-
11 files changed, 525 insertions(+), 75 deletions(-)
--
2.13.6
6 years, 11 months
[libvirt] Libvirt fails to apply security context to fd/node to USB device
by Randy Aybar
Hi,
I'm attempting to attach and expose a USB device (WiFi adapter for testing) to an LXC container with SELinux enabled. But when enabling the XML snippet, the container fails to start with this error:
2018-01-12 19:24:31.914+0000: 2181: error : virSecuritySELinuxSetFileconHelper:1182 : unable to set security context 'system_u:object_r:svirt_sandbox_file_t:s0:c139,c284' on '//var/run/libvirt/lxc/lxc_0.dev/bus/usb//dev/bus/usb/002/002': No such file or directory
Failure in libvirt_lxc startup: unable to set security context 'system_u:object_r:svirt_sandbox_file_t:s0:c139,c284' on '//var/run/libvirt/lxc/lxc_0.dev/bus/usb//dev/bus/usb/002/002': No such file or directory
The XML snippet for attaching USB device:
<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
<vendor id='0x05ac'/>
<product id='0x1006'/>
</source>
<address type='usb' bus='2' port='2'/>
</hostdev>
SELinux snippet (using the dynamic label for the moment):
<seclabel type='dynamic' model='selinux' relabel='yes'/>
Running it on CentOS 7.2 and I've tried the distro from the package manager (1.3.3.3), as well as downloaded and compiled the latest stable from libvirt.org (3.10?) and came to the same error each time.
Did a small dive into the code after realizing that the path just doesn't seem right.
Path (seems to have an unusual and incorrect concatenation of folders) :
//var/run/libvirt/lxc/lxc_0.dev/bus/usb//dev/bus/usb/002/002
"vroot" seems to be declared by the LXC controller (src/lxc/lxc_controller.c) as such:
if (virAsprintf(&vroot, "/%s/%s.dev/bus/usb/",
LXC_STATE_DIR, vmDef->name) < 0)
goto cleanup;
Then upon setting up security for all of the container's attached devices, we call virUSBDeviceNew to setup the attached USB device and give us the path to apply a context to. Since vroot is present, we get this weird path when running through this (src/util/virusb.c):
if (virAsprintf(&dev->path, "%s" USB_DEVFS "%03d/%03d",
vroot ? vroot : "",
dev->bus, dev->dev) < 0) {
virUSBDeviceFree(dev);
return NULL;
}
Note:
# define USB_DEVFS "/dev/bus/usb/"
Should we just be blindly appending this definition if vroot is present, making the path incorrect?
If this isn't a bug, I propose the following change:
if (virAsprintf(&dev->path, "%s" "%03d/%03d",
vroot ? vroot : USB_DEVFS,
dev->bus, dev->dev) < 0) {
virUSBDeviceFree(dev);
return NULL;
}
Would kindly appreciate any feedback on whether this is a bug or maybe I'm missing something and is the reason why it's written this way.
Thanks,
Randy
6 years, 11 months
[libvirt] [PATCH 0/9] Yet another version of CAT stuff (no idea about the version number)
by Martin Kletzander
Added stuff that Pavel wanted, removed some testcases that I still have in my
repo, but it's way to complicated to add properly, so for now I would just go
with this and manual testing of starting some domains. I got no hardware to
test this on, currently, so some testing is needed before pushing this.
@Eli: Can you help with the testing?
Martin Kletzander (9):
Rename virResctrlInfo to virResctrlInfoPerCache
util: Add virResctrlInfo
conf: Use virResctrlInfo in capabilities
util: Remove now-unneeded resctrl functions
resctrl: Add functions to work with resctrl allocations
conf: Add support for cputune/cachetune
tests: Add virresctrltest
qemu: Add support for resctrl
docs: Add CAT (resctrl) support into news.xml
docs/formatdomain.html.in | 54 +
docs/news.xml | 9 +
docs/schemas/domaincommon.rng | 32 +
po/POTFILES.in | 1 +
src/Makefile.am | 2 +-
src/conf/capabilities.c | 55 +-
src/conf/capabilities.h | 4 +-
src/conf/domain_conf.c | 251 ++++
src/conf/domain_conf.h | 13 +
src/libvirt_private.syms | 16 +-
src/qemu/qemu_process.c | 61 +-
src/util/virresctrl.c | 1380 ++++++++++++++++++--
src/util/virresctrl.h | 86 +-
src/util/virresctrlpriv.h | 27 +
tests/Makefile.am | 8 +-
tests/genericxml2xmlindata/cachetune-cdp.xml | 36 +
.../cachetune-colliding-allocs.xml | 30 +
.../cachetune-colliding-tunes.xml | 32 +
.../cachetune-colliding-types.xml | 30 +
tests/genericxml2xmlindata/cachetune-small.xml | 29 +
tests/genericxml2xmlindata/cachetune.xml | 33 +
tests/genericxml2xmltest.c | 10 +
tests/virresctrldata/resctrl-cdp.schemata | 2 +
.../virresctrldata/resctrl-skx-twocaches.schemata | 1 +
tests/virresctrldata/resctrl-skx.schemata | 1 +
tests/virresctrldata/resctrl.schemata | 1 +
tests/virresctrltest.c | 102 ++
27 files changed, 2174 insertions(+), 132 deletions(-)
create mode 100644 src/util/virresctrlpriv.h
create mode 100644 tests/genericxml2xmlindata/cachetune-cdp.xml
create mode 100644 tests/genericxml2xmlindata/cachetune-colliding-allocs.xml
create mode 100644 tests/genericxml2xmlindata/cachetune-colliding-tunes.xml
create mode 100644 tests/genericxml2xmlindata/cachetune-colliding-types.xml
create mode 100644 tests/genericxml2xmlindata/cachetune-small.xml
create mode 100644 tests/genericxml2xmlindata/cachetune.xml
create mode 100644 tests/virresctrldata/resctrl-cdp.schemata
create mode 100644 tests/virresctrldata/resctrl-skx-twocaches.schemata
create mode 100644 tests/virresctrldata/resctrl-skx.schemata
create mode 100644 tests/virresctrldata/resctrl.schemata
create mode 100644 tests/virresctrltest.c
--
2.15.1
6 years, 11 months
[libvirt] [dbus PATCH v2] main: add support for all usable libvirt drivers
by Pavel Hrdina
Some of the drivers are remote only, such as ESX, GSX, VPX, PHyp and
HyperV. Currently we support only local drivers.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/main.c | 21 +++++++++++++++++----
test/libvirttest.py | 2 +-
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/main.c b/src/main.c
index ab03bc1..32c1cc4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -85,13 +85,26 @@ struct virtDBusDriver {
};
static const struct virtDBusDriver sessionDrivers[] = {
- { "qemu:///session", "/org/libvirt/qemu" },
- { "test:///default", "/org/libvirt/test" },
+ { "qemu:///session", "/org/libvirt/QEMU" },
+ { "test:///default", "/org/libvirt/Test" },
+ { "uml:///session", "/org/libvirt/UML" },
+ { "vbox:///session", "/org/libvirt/VBox" },
+ { "vmwarefusion:///session", "/org/libvirt/VMwareFusion" },
+ { "vmwareplayer:///session", "/org/libvirt/VMwarePlayer" },
+ { "vmwarews:///session", "/org/libvirt/VMwareWS" },
};
static const struct virtDBusDriver systemDrivers[] = {
- { "qemu:///system", "/org/libvirt/qemu" },
- { "test:///default", "/org/libvirt/test" },
+ { "XenApi://localhost/", "/org/libvirt/XenAPI" },
+ { "bhyve:///system", "/org/libvirt/BHyve" },
+ { "lxc:///", "/org/libvirt/LXC" },
+ { "openvz:///system", "/org/libvirt/OpenVZ" },
+ { "qemu:///system", "/org/libvirt/QEMU" },
+ { "test:///default", "/org/libvirt/Test" },
+ { "uml:///system", "/org/libvirt/UML" },
+ { "vbox:///system", "/org/libvirt/VBox" },
+ { "vz:///system", "/org/libvirt/VZ" },
+ { "xen:///", "/org/libvirt/Xen" },
};
int
diff --git a/test/libvirttest.py b/test/libvirttest.py
index 579485f..6a00aea 100644
--- a/test/libvirttest.py
+++ b/test/libvirttest.py
@@ -38,7 +38,7 @@ class TestCase(unittest.TestCase):
else:
raise TimeoutError('error starting libvirt-dbus')
- obj = self.bus.get_object('org.libvirt', '/org/libvirt/test')
+ obj = self.bus.get_object('org.libvirt', '/org/libvirt/Test')
self.connect = dbus.Interface(obj, 'org.libvirt.Connect')
def tearDown(self):
--
2.14.3
6 years, 11 months
[libvirt] [dbus RFC 00/11] improve libvirt connections handling
by Pavel Hrdina
This patch series is a proposal to how to implement libvirt connections
in the libvirt D-Bus binding. The design is based on a discussion with
Daniel and it should follow D-Bus convention.
Each connection is represented as existing object where the object
path contains the driver name:
/org/libvirt/qemu
and there is no need to call any connect API but simply use the existing
object directly to operate with that connection.
This patch series also implements strict difference between system and
user bus. On the user bus only drivers with session capability are
available and on the system bus only drivers with system capability
are available.
Pavel Hrdina (11):
util: introduce VIRT_ARRAY_CARDINALITY macro
util: introduce virtDBusUtilSetError helper
src: rename manager to connect
connect: implement lazy connection
connect: don't use default libvirt authentication callback
connect: implement reconnect functionality to libvirt
connect: move domain related code to domain.c
connect: store connect path in connect structure
domain: derive domain path from connect path
main: implement multiple connection within one daemon
main: add support for all libvirt drivers
src/Makefile.am | 2 +-
src/connect.c | 308 ++++++++++++++++++++++++++++++
src/connect.h | 27 +++
src/domain.c | 131 ++++++++-----
src/domain.h | 4 +-
src/events.c | 64 +++----
src/events.h | 4 +-
src/main.c | 75 ++++++--
src/manager.c | 216 ---------------------
src/manager.h | 20 --
src/util.c | 17 +-
src/util.h | 12 +-
test/Makefile.am | 2 +-
test/libvirttest.py | 6 +-
test/{test_manager.py => test_connect.py} | 12 +-
test/test_domain.py | 6 +-
16 files changed, 543 insertions(+), 363 deletions(-)
create mode 100644 src/connect.c
create mode 100644 src/connect.h
delete mode 100644 src/manager.c
delete mode 100644 src/manager.h
rename test/{test_manager.py => test_connect.py} (79%)
--
2.14.3
6 years, 11 months
[libvirt] [PATCH] docs: formatdomain: Document the CPU feature 'name' attribute
by Kashyap Chamarthy
Currently, the CPU feature 'name' XML attribute, as in:
[...]
<cpu match='exact'>
<model fallback='forbid'>IvyBridge</model>
<vendor>Intel</vendor>
<feature policy='require' name='pcid'/>
</cpu>
[...]
isn't explicitly documented in formatdomain.html.
Document it now.
Signed-off-by: Kashyap Chamarthy <kchamart(a)redhat.com>
---
docs/formatdomain.html.in | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index d272cc1ba..e717fb3aa 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1454,6 +1454,23 @@
<span class="since">Since 0.8.5</span> the <code>policy</code>
attribute can be omitted and will default to <code>require</code>.
+
+ Individual CPU feature names can be specified as part of the
+ <code>name</code> attribute. The list of known CPU feature
+ names (e.g. 'vmx', 'cmt', et cetera) can be found in the same
+ file as CPU models -- <code>cpu_map.xml</code>. For example,
+ to explicitly specify the 'pcid' feature with Intel IvyBridge
+ CPU model:
+
+<pre>
+...
+<cpu match='exact'>
+ <model fallback='forbid'>IvyBridge</model>
+ <vendor>Intel</vendor>
+ <feature policy='require' name='pcid'/>
+</cpu>
+...</pre>
+
</dd>
<dt><code>cache</code></dt>
--
2.13.6
6 years, 11 months