[libvirt] [PATCH 00/13] iothread code cleanup
by Pavel Hrdina
This is a preparation for implementation of recently added iothread
polling feature into QEMU.
Pavel Hrdina (13):
conf: fix indentation
conf: remove redundant iothreads variable
conf: move iothread parse code into its own function
conf: store iothreads in order by iothread_id
conf: always display iothread ids in the XML
qemu_driver: check invalid iothread_id before we do anything else
qemu_process: move capabilities check for iothreads
qemu_process: remove unnecessary iothread check
conf: move iothread XML validation from qemu_command
qemu_driver: always check whether iothread is used by disk or not
qemu_driver: move iothread existence check into one place
qemu_driver: check whether iothread is used by controller
qemu_driver: move iothread duplicate check into one place
src/conf/domain_conf.c | 260 ++++++++++++++-------
src/conf/domain_conf.h | 2 -
src/qemu/qemu_command.c | 121 +---------
src/qemu/qemu_driver.c | 131 ++++++-----
src/qemu/qemu_process.c | 61 ++---
.../qemuxml2argv-iothreads-ids-partial.args | 4 +-
.../qemuxml2xmlout-cputune-iothreads.xml | 4 +
...l2xmlout-cputune-iothreadsched-zeropriority.xml | 6 +
.../qemuxml2xmlout-cputune-iothreadsched.xml | 6 +
.../qemuxml2xmlout-cputune-numatune.xml | 4 +
.../qemuxml2xmlout-iothreads-disk-virtio-ccw.xml | 4 +
.../qemuxml2xmlout-iothreads-disk.xml | 4 +
.../qemuxml2xmlout-iothreads-ids-partial.xml | 2 +
.../qemuxml2xmlout-iothreads-virtio-scsi-ccw.xml | 4 +
.../qemuxml2xmlout-iothreads-virtio-scsi-pci.xml | 4 +
.../qemuxml2xmlout-iothreads.xml | 4 +
.../qemuxml2xmlout-vcpu-placement-static.xml | 4 +
17 files changed, 334 insertions(+), 291 deletions(-)
--
2.11.1
7 years, 9 months
[libvirt] [PATCH] node_device: Check return value for udev_new()
by Marc Hartmayer
The comment was actually wrong as
https://www.freedesktop.org/software/systemd/man/udev_new.html
mentions that on failure NULL is returned.
Signed-off-by: Marc Hartmayer <mhartmay(a)linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk(a)linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
---
src/node_device/node_device_udev.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 4b81312..4b0a875 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1491,13 +1491,11 @@ static int nodeStateInitialize(bool privileged,
if (udevPCITranslateInit(privileged) < 0)
goto cleanup;
- /*
- * http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/libudev-udev...
- *
- * indicates no return value other than success, so we don't check
- * its return value.
- */
udev = udev_new();
+ if (!udev) {
+ virReportOOMError();
+ goto cleanup;
+ }
#if HAVE_UDEV_LOGGING
/* cast to get rid of missing-format-attribute warning */
udev_set_log_fn(udev, (udevLogFunctionPtr) udevLogFunction);
--
2.5.5
7 years, 9 months
[libvirt] [PATCH] nwfilter_gentech_driver: Fix indentation and typo
by Nitesh Konkar
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
src/nwfilter/nwfilter_gentech_driver.c | 4 ++--
src/nwfilter/nwfilter_gentech_driver.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index 761a01b..7dd2c97 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -448,7 +448,7 @@ virNWFilterIncludeDefToRuleInst(virNWFilterDriverStatePtr driver,
* the filter and its subfilters.
* @useNewFilter: instruct whether to use a newDef pointer rather than a
* def ptr which is useful during a filter update
- * @foundNewFilter: pointer to int indivating whether a newDef pointer was
+ * @foundNewFilter: pointer to int indicating whether a newDef pointer was
* ever used; variable expected to be initialized to 0 by caller
* @rulesout: array to be filled with rule instance
* @nrulesout: counter to be filled with number of rule instances
@@ -738,7 +738,7 @@ virNWFilterInstantiate(const unsigned char *vmuuid ATTRIBUTE_UNUSED,
if (rc == 0 && (virNetDevValidateConfig(ifname, NULL, ifindex) <= 0)) {
virResetLastError();
- /* interface changed/disppeared */
+ /* interface changed/disappeared */
techdriver->allTeardown(ifname);
rc = -1;
}
diff --git a/src/nwfilter/nwfilter_gentech_driver.h b/src/nwfilter/nwfilter_gentech_driver.h
index 8349ab4..8163273 100644
--- a/src/nwfilter/nwfilter_gentech_driver.h
+++ b/src/nwfilter/nwfilter_gentech_driver.h
@@ -58,7 +58,7 @@ int virNWFilterInstantiateFilterLate(virNWFilterDriverStatePtr driver,
int virNWFilterTeardownFilter(const virDomainNetDef *net);
virNWFilterHashTablePtr virNWFilterCreateVarHashmap(char *macaddr,
- const virNWFilterVarValue *value);
+ const virNWFilterVarValue *value);
int virNWFilterDomainFWUpdateCB(virDomainObjPtr vm,
void *data);
--
2.1.0
7 years, 9 months
[libvirt] [PATCH] Disallow inclusion of files from src/conf into src/utils
by Peter Krempa
The utils code should stay separated from other code (except for very
well justified cases). Unfortunately commit 272769beccd7479c75e700a6cb
made it trivial to break the separation (and not get slapped by the
syntax-check rule) by adding -I src/conf to the CFLAGS for utils.
Remove this shortcut and except the two offenders from the syntax check
so that the codebase can be kept separated.
---
cfg.mk | 3 +++
src/Makefile.am | 3 +--
src/util/virclosecallbacks.h | 2 +-
src/util/virhostdev.h | 2 +-
4 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 69e3f3a1a..aaba61f1d 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1242,3 +1242,6 @@ exclude_file_name_regexp--sc_prohibit_always-defined_macros = \
exclude_file_name_regexp--sc_prohibit_readdir = \
^tests/.*mock\.c$$
+
+exclude_file_name_regexp--sc_prohibit_cross_inclusion = \
+ ^(src/util/virclosecallbacks\.h|src/util/virhostdev\.h)$$
diff --git a/src/Makefile.am b/src/Makefile.am
index 46ca272eb..4f3f8f0bd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1137,8 +1137,7 @@ libvirt_util_la_SOURCES = \
libvirt_util_la_CFLAGS = $(CAPNG_CFLAGS) $(YAJL_CFLAGS) $(LIBNL_CFLAGS) \
$(AM_CFLAGS) $(AUDIT_CFLAGS) $(DEVMAPPER_CFLAGS) \
$(DBUS_CFLAGS) $(LDEXP_LIBM) $(NUMACTL_CFLAGS) \
- $(POLKIT_CFLAGS) $(GNUTLS_CFLAGS) $(ACL_CFLAGS) \
- -I$(srcdir)/conf
+ $(POLKIT_CFLAGS) $(GNUTLS_CFLAGS) $(ACL_CFLAGS)
libvirt_util_la_LIBADD = $(CAPNG_LIBS) $(YAJL_LIBS) $(LIBNL_LIBS) \
$(THREAD_LIBS) $(AUDIT_LIBS) $(DEVMAPPER_LIBS) \
$(LIB_CLOCK_GETTIME) $(DBUS_LIBS) $(WIN32_EXTRA_LIBS) $(LIBXML_LIBS) \
diff --git a/src/util/virclosecallbacks.h b/src/util/virclosecallbacks.h
index 4df0a0060..d48997181 100644
--- a/src/util/virclosecallbacks.h
+++ b/src/util/virclosecallbacks.h
@@ -25,7 +25,7 @@
#ifndef __VIR_CLOSE_CALLBACKS__
# define __VIR_CLOSE_CALLBACKS__
-# include "virdomainobjlist.h"
+# include "conf/virdomainobjlist.h"
typedef struct _virCloseCallbacks virCloseCallbacks;
typedef virCloseCallbacks *virCloseCallbacksPtr;
diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h
index 4c1fea3ef..1202136c2 100644
--- a/src/util/virhostdev.h
+++ b/src/util/virhostdev.h
@@ -31,7 +31,7 @@
# include "virusb.h"
# include "virscsi.h"
# include "virscsivhost.h"
-# include "domain_conf.h"
+# include "conf/domain_conf.h"
typedef enum {
VIR_HOSTDEV_STRICT_ACS_CHECK = (1 << 0), /* strict acs check */
--
2.11.0
7 years, 9 months
[libvirt] [PATCH] qemu: Forbid slashes in shmem name
by Martin Kletzander
With that users could access files outside /dev/shm. That itself
isn't a security problem, but might cause some errors we want to
avoid. So let's forbid slashes as we do with domain and volume names
and also mention that in the schema.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1395496
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
docs/schemas/domaincommon.rng | 6 +++++-
src/qemu/qemu_process.c | 23 +++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index cc6e0d0c0d65..00cdc93bca59 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3598,7 +3598,11 @@
<define name="shmem">
<element name="shmem">
- <attribute name="name"/>
+ <attribute name="name">
+ <data type="string">
+ <param name="pattern">[^/]*</param>
+ </data>
+ </attribute>
<interleave>
<optional>
<element name="model">
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 184440dc1af6..0f63668100a6 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4586,6 +4586,26 @@ qemuProcessStartValidateVideo(virDomainObjPtr vm,
static int
+qemuProcessStartValidateShmem(virDomainObjPtr vm)
+{
+ size_t i;
+
+ for (i = 0; i < vm->def->nshmems; i++) {
+ virDomainShmemDefPtr shmem = vm->def->shmems[i];
+
+ if (strchr(shmem->name, '/')) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("shmem name '%s' must not contain '/'"),
+ shmem->name);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
+static int
qemuProcessStartValidateXML(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virQEMUCapsPtr qemuCaps,
@@ -4661,6 +4681,9 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
if (qemuProcessStartValidateVideo(vm, qemuCaps) < 0)
return -1;
+ if (qemuProcessStartValidateShmem(vm) < 0)
+ return -1;
+
VIR_DEBUG("Checking for any possible (non-fatal) issues");
qemuProcessStartWarnShmem(vm);
--
2.11.0
7 years, 9 months
[libvirt] [PATCH] qemu: Check for maximum vcpus exceeding cpu topology
by Kothapally Madhu Pavan
This patch will prevent guest to start when the maximum
vcpus are greater than cpu topology limit. Currently similar
checks do exist only during setvcpus. The patch adds the
missing check. The c9cb35c255222 reverted similar check to
avoid older configs from vanishing. The current patch adds
it in domain validation part to be consistent with the
original intent.
Signed-off-by: Kothapally Madhu Pavan <kmp(a)linux.vnet.ibm.com>
---
src/qemu/qemu_process.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 184440d..f0d42b8 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3738,6 +3738,13 @@ qemuValidateCpuCount(virDomainDefPtr def,
return -1;
}
+ if (def->cpu->sockets && virDomainDefGetVcpusMax(def) >
+ def->cpu->sockets * def->cpu->cores * def->cpu->threads) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Maximum CPUs greater than topology limit"));
+ return -1;
+ }
+
if (maxCpus > 0 && virDomainDefGetVcpusMax(def) > maxCpus) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Maximum CPUs greater than specified machine type limit"));
7 years, 9 months
[libvirt] [PATCH 0/2] QEMU caps data
by Pavel Hrdina
Pavel Hrdina (2):
tests: update QEMU 2.8.0 caps data
tests: add QEMU 2.9.0 caps data
.../qemucapabilitiesdata/caps_2.8.0.x86_64.replies | 107 +-
tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 7 +-
.../qemucapabilitiesdata/caps_2.9.0.x86_64.replies | 14671 +++++++++++++++++++
tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 302 +
tests/qemucapabilitiestest.c | 1 +
5 files changed, 15049 insertions(+), 39 deletions(-)
create mode 100644 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.replies
create mode 100644 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
--
2.11.1
7 years, 9 months
[libvirt] [PATCH v2] qemu: Allow @rednernode for virgl domains
by Michal Privoznik
When enabling virgl, qemu opens /dev/dri/render*. So far, we are
not allowing that in devices cgroup nor creating the file in
domain's namespace and thus requiring users to set the paths in
qemu.conf. This, however, is suboptimal as it allows access to
ALL qemu processes even those which don't have virgl configured.
Now that we have a way to specify render node that qemu will use
we can be more cautious and enable just that.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Technically, this is v2 of:
https://www.redhat.com/archives/libvir-list/2017-February/msg00497.html
diff to v1:
- now that we have @rendernode for <gl/> which selects just one path (and does
it in predictable fashion) only that path is enabled in the CGgroups and
created in the namespace.
src/qemu/qemu_cgroup.c | 27 +++++++++++++++++++++++++++
src/qemu/qemu_domain.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 209cbc275..f0729743a 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -335,6 +335,28 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm,
return ret;
}
+
+static int
+qemuSetupGraphicsCgroup(virDomainObjPtr vm,
+ virDomainGraphicsDefPtr gfx)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ const char *rendernode = gfx->data.spice.rendernode;
+ int ret;
+
+ if (gfx->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE ||
+ gfx->data.spice.gl != VIR_TRISTATE_BOOL_YES ||
+ !rendernode)
+ return 0;
+
+ ret = virCgroupAllowDevicePath(priv->cgroup, rendernode,
+ VIR_CGROUP_DEVICE_RW, false);
+ virDomainAuditCgroupPath(vm, priv->cgroup, "allow", rendernode,
+ "rw", ret == 0);
+ return ret;
+}
+
+
static int
qemuSetupBlkioCgroup(virDomainObjPtr vm)
{
@@ -604,6 +626,11 @@ qemuSetupDevicesCgroup(virQEMUDriverPtr driver,
goto cleanup;
}
+ for (i = 0; i < vm->def->ngraphics; i++) {
+ if (qemuSetupGraphicsCgroup(vm, vm->def->graphics[i]) < 0)
+ goto cleanup;
+ }
+
for (i = 0; i < vm->def->ninputs; i++) {
if (qemuSetupInputCgroup(vm, vm->def->inputs[i]) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 92a9a105c..ea4b28288 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7526,6 +7526,42 @@ qemuDomainSetupTPM(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
}
+static int
+qemuDomainSetupGraphics(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
+ virDomainGraphicsDefPtr gfx,
+ const char *devPath)
+{
+ const char *rendernode = gfx->data.spice.rendernode;
+
+ if (gfx->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE ||
+ gfx->data.spice.gl != VIR_TRISTATE_BOOL_YES ||
+ !rendernode)
+ return 0;
+
+ return qemuDomainCreateDevice(rendernode, devPath, false);
+}
+
+
+static int
+qemuDomainSetupAllGraphics(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ const char *devPath)
+{
+ size_t i;
+
+ VIR_DEBUG("Setting up graphics");
+ for (i = 0; i < vm->def->ngraphics; i++) {
+ if (qemuDomainSetupGraphics(driver,
+ vm->def->graphics[i],
+ devPath) < 0)
+ return -1;
+ }
+
+ VIR_DEBUG("Setup all graphics");
+ return 0;
+}
+
+
static int
qemuDomainSetupInput(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
virDomainInputDefPtr input,
@@ -7679,6 +7715,9 @@ qemuDomainBuildNamespace(virQEMUDriverPtr driver,
if (qemuDomainSetupTPM(driver, vm, devPath) < 0)
goto cleanup;
+ if (qemuDomainSetupAllGraphics(driver, vm, devPath) < 0)
+ goto cleanup;
+
if (qemuDomainSetupAllInputs(driver, vm, devPath) < 0)
goto cleanup;
--
2.11.0
7 years, 9 months
[libvirt] [PATCH] news: add entries for recent nodedev driver improvements
by Michal Privoznik
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
docs/news.xml | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/docs/news.xml b/docs/news.xml
index 54337f782..8d53e0797 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -63,6 +63,23 @@
other than what's required for remote access of libvirtd.
</description>
</change>
+ <change>
+ <summary>
+ qemu: add rendernode argument
+ </summary>
+ <description>
+ Add a new attribute 'rendernode' to <gl> spice element.
+ </description>
+ </change>
+ <change>
+ <summary>
+ nodedev: add drm capability
+ </summary>
+ <description>
+ Add a new 'drm' capability for Direct Rendering Manager (DRM)
+ devices, providing device type information.
+ </description>
+ </change>
</section>
<section title="Improvements">
<change>
--
2.11.0
7 years, 9 months
[libvirt] [PATCH] tests: Add couple of nodedev tests
by Michal Privoznik
With recent DRM device addition we report more devices. I happen
to have some on my system therefore add the nodedev XMLs intou
our test suite so that we make sure we won't break it.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tests/nodedevschemadata/drm_card0.xml | 9 +++++++++
tests/nodedevschemadata/drm_controlD64.xml | 9 +++++++++
tests/nodedevschemadata/drm_renderD128.xml | 9 +++++++++
tests/nodedevxml2xmltest.c | 3 +++
4 files changed, 30 insertions(+)
create mode 100644 tests/nodedevschemadata/drm_card0.xml
create mode 100644 tests/nodedevschemadata/drm_controlD64.xml
create mode 100644 tests/nodedevschemadata/drm_renderD128.xml
diff --git a/tests/nodedevschemadata/drm_card0.xml b/tests/nodedevschemadata/drm_card0.xml
new file mode 100644
index 000000000..307bada1a
--- /dev/null
+++ b/tests/nodedevschemadata/drm_card0.xml
@@ -0,0 +1,9 @@
+<device>
+ <name>drm_card0</name>
+ <path>/sys/devices/pci0000:00/0000:00:02.0/drm/card0</path>
+ <devnode type='dev'>/dev/dri/card0</devnode>
+ <parent>pci_0000_00_02_0</parent>
+ <capability type='drm'>
+ <type>primary</type>
+ </capability>
+</device>
diff --git a/tests/nodedevschemadata/drm_controlD64.xml b/tests/nodedevschemadata/drm_controlD64.xml
new file mode 100644
index 000000000..4f36a7068
--- /dev/null
+++ b/tests/nodedevschemadata/drm_controlD64.xml
@@ -0,0 +1,9 @@
+<device>
+ <name>drm_controlD64</name>
+ <path>/sys/devices/pci0000:00/0000:00:02.0/drm/controlD64</path>
+ <devnode type='dev'>/dev/dri/controlD64</devnode>
+ <parent>pci_0000_00_02_0</parent>
+ <capability type='drm'>
+ <type>control</type>
+ </capability>
+</device>
diff --git a/tests/nodedevschemadata/drm_renderD128.xml b/tests/nodedevschemadata/drm_renderD128.xml
new file mode 100644
index 000000000..7ae5474b1
--- /dev/null
+++ b/tests/nodedevschemadata/drm_renderD128.xml
@@ -0,0 +1,9 @@
+<device>
+ <name>drm_renderD128</name>
+ <path>/sys/devices/pci0000:00/0000:00:02.0/drm/renderD128</path>
+ <devnode type='dev'>/dev/dri/renderD128</devnode>
+ <parent>pci_0000_00_02_0</parent>
+ <capability type='drm'>
+ <type>render</type>
+ </capability>
+</device>
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c
index 5e1ae170c..5a8dd7dee 100644
--- a/tests/nodedevxml2xmltest.c
+++ b/tests/nodedevxml2xmltest.c
@@ -101,6 +101,9 @@ mymain(void)
DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all");
DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all_header_type");
DO_TEST("drm_renderD129");
+ DO_TEST("drm_card0");
+ DO_TEST("drm_controlD64");
+ DO_TEST("drm_renderD128");
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
--
2.11.0
7 years, 9 months